以下ABAP代码有什么问题

时间:2016-03-06 13:25:47

标签: abap

REPORT  zbc400_figure157.

TYPES: BEGIN OF t_conn,
    cityfrom TYPE spfli-cityfrom,
    cityto TYPE spfli-cityto,
    carrid TYPE spfli-carrid,
    connid TYPE spfli-connid,
  END OF t_conn.

DATA:
conn_list LIKE STANDARD TABLE OF t_conn,
startline LIKE sy-tabix,

 BEGIN OF wa_travel,
     dest TYPE spfli-cityto,
     cofl_list LIKE conn_list,
 END OF wa_travel,
      travel_list LIKE SORTED TABLE OF wa_travel WITH UNIQUE KEY dest.

FIELD-SYMBOLS:
               <fs_conn> TYPE t_conn,
               <fs_conn_int> TYPE t_conn,
               <fs_travel> TYPE wa_travel.

PARAMETERS pa_start TYPE spfli-cityfrom DEFAULT 'FRANKFURT'.

SELECT carrid cityfrom cityto
  FROM spfli
  INTO CORRESPONDING FIELDS OF TABLE conn_list.
SORT conn_list BY cityfrom cityto ASCENDING AS TEXT.

** build up nested table.

LOOP AT conn_list ASSIGNING <fs_conn> WHERE cityfrom = pa_start.
  CLEAR wa_travel.
  wa_travel-dest = <fs_conn>-cityto.

  READ TABLE conn_list
      WITH KEY cityfrom = wa_travel-dest
      TRANSPORTING NO FIELDS
      BINARY SEARCH.
  startline = sy-tabix.

  LOOP AT conn_list ASSIGNING <fs_conn_int>
      FROM startline.

    IF <fs_conn_int>-cityfrom <> wa_travel-dest.
      EXIT.
    ENDIF.

    APPEND <fs_conn_int> TO wa_travel-cofl_list.
  ENDLOOP.

  SORT wa_travel-cofl_list BY cityto carrid ASCENDING AS TEXT.
  INSERT wa_travel INTO TABLE travel_list.
ENDLOOP.
Error: Field "T_CONN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement . . . . . . . . . .

我们声明一个内部表COFL_LIST和一个带有相应工作区的外表TRAVEL_LIST。内部表CONN_LIST缓冲所有航班连接并对其进行排序。

该程序使用3个表,内部表,外部表和内部表。

我按照LPK的建议对程序进行了更改:

conn_list TYPE STANDARD TABLE OF t_conn,

然而,现在问题在于:

FIELD-SYMBOLS:
               <fs_conn> TYPE t_conn,
               <fs_conn_int> TYPE t_conn,
               <fs_travel> TYPE wa_travel.

错误:“WA_TRAVEL”类型未知。 在程序中,wa_travel变量已经在它的BEGIN OF wa_travel和END OF wa_travel块中定义。为什么系统不能选择这个?

2 个答案:

答案 0 :(得分:6)

这一行错了:

  

conn_list LIKE标准表t_conn,

T_CONN是一种类型,因此您必须使用TYPE代替LIKE

您可以找到有关差异here的解释。

答案 1 :(得分:0)

声明不正确......

FIELD-符号:                 TYPE t_conn,                 TYPE t_conn,                 TYPE wa_travel。

应该是

FIELD-符号:                 TYPE t_conn,                 TYPE t_conn,                 喜欢wa_travel。

您需要查看上一个答案中提供的链接...或者您可以使用TYPE&amp;上的Help Portal中的以下内容。 LIKE