简体   繁体   中英

GET_ENTITY query for selecting 4 columns of a single table row

I am writing a SELECT query for oData service EMPLOYEESET_GET_ENTITY (code below) but I am getting warnings saying:

The database field or the result type of the aggregate function NACHN and the component "PERNR" of "ER_ENTITY" are not compatible.

SELECT query:

method EMPLOYEESET_GET_ENTITY.

    DATA: ls_keytab TYPE LINE OF /IWBEP/T_MGW_NAME_VALUE_PAIR,
          enteredPernr TYPE string.

    LOOP AT it_key_tab INTO ls_keytab.
      enteredPernr = ls_keytab-value.
    ENDLOOP.

    SELECT SINGLE pernr nachn vorna gbdat
      INTO er_entity
      FROM pa0002
      WHERE pernr = enteredPernr.

endmethod.

I am basically just selecting 4 columns of a single row from only 1 table named pa0002 . PERNR is the key, so it should not really interfere with NACHN . I already checked types and all those properties have Edm.String and correspondig Max. length. The order of selected columns in my SELECT query corresponds with the order of those columns I specified when the entity type Employee was being created.

What exactly is the problem?

Use INTO CORRESPONDING FIELDS OF er_entity as below.

method EMPLOYEESET_GET_ENTITY.

    DATA: ls_keytab TYPE LINE OF /IWBEP/T_MGW_NAME_VALUE_PAIR,
          enteredPernr TYPE string.

    LOOP AT it_key_tab INTO ls_keytab.
      enteredPernr = ls_keytab-value.
    ENDLOOP.

    SELECT SINGLE Pernr Nachn Vorna Gbdat
      INTO CORRESPONDING FIELDS OF er_entity
      FROM pa0002
      WHERE pernr = enteredPernr.

endmethod.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM