如何在SET_GET_ENTITY方法中为类型为“ quantity”的字段编写SELECT?

时间:2019-09-05 13:17:42

标签: odata sap abap sap-gateway

我想从表zbookings中选择一行包含所有列的行。 zbookings表的结构基于zbooking数据结构-请参见下表。

ZBOOKINGSenter image description here

结构ZBOOKINGenter image description here

我的BOOKINGSET_GET_ENTITY方法:

method BOOKINGSET_GET_ENTITY.

    DATA: ls_keytab TYPE LINE OF /IWBEP/T_MGW_NAME_VALUE_PAIR,
          i_carrid TYPE string,
          i_connid TYPE string,
          i_fldate TYPE string,
          i_bookid TYPE string.

    LOOP AT it_key_tab INTO ls_keytab.
      CASE ls_keytab-name.
        WHEN 'Carrid'.
          i_carrid = ls_keytab-value.
        WHEN 'Connid'.
          i_connid = ls_keytab-value.
        WHEN 'Fldate'.
          i_fldate = ls_keytab-value.
        WHEN 'Bookid'.
          i_bookid = ls_keytab-value.
      ENDCASE.
    ENDLOOP.

    SELECT SINGLE *
      INTO CORRESPONDING FIELDS OF er_entity
      FROM ybookings AS a
      WHERE
        a~carrid = i_carrid AND
        a~connid = i_connid AND
        a~fldate = i_fldate AND
        a~bookid = i_bookid.

endmethod.

我通过SAP Gateway Client测试了它。当我从luggweight语句中删除列SELECT SINGLE *时,就可以了。但是,当我通过SELECT SINGLE *选择所有列时,它将输出错误

  

运行时错误:“ SAPSQL_PARSER_TODO_WARNING”`

<?xml version="1.0" encoding="UTF-8"?>
<error>
  <code>SAPSQL_PARSER_TODO_WARNING</code>
  <message>Runtime Error: 'SAPSQL_PARSER_TODO_WARNING'. 
     The OData request processing has been abnormal terminated. If "Runtime Error"
     is not initial, launch transaction ST22 for details and analysis. Otherwise,
     launch transaction SM21 for system log analysis.</message>
  <timestamp>20190905144432</timestamp>
</error>

您可以看到问题出在luggweight类型的quantity字段中,其键入方法是Type ref to。当我通过ctr + F2检查我的BOOKINGSET_GET_ENTITY方法时,它会输出警告:

  

聚集函数LUGGWEIGHT的数据库字段或结果类型与“ ER_ENTITY”的组件“ LUGGWEIGHT”不兼容。

如何修改我的SELECT查询/ BOOKINGSET_GET_ENTITY方法以使其起作用?

1 个答案:

答案 0 :(得分:0)

在创建/修改Luggweight数据结构时,

Types字段的键入方法应设置为Type ref to(而不是zbooking)。