ABAP程序中运行时语法错误(使ALV列表(标题)显示徽标)

问题描述 投票:0回答:1

我似乎无法弄清楚我的程序中的代码有什么问题。我收到运行时错误 GETWA_NOT_ASSIGNED(数据段 -1)。

希望比我聪明的人能够发现这个错误...我的桌子叫 z311bookings。 这是我的代码:

&------------------------------------------------------------ ---------------------- *&报告z_db_311_handin1_alv_list &------------------------------------------------ --------------------------------- *& &------------------------------------------------ ---------------------

    REPORT z_db_311_handin1_alv_list.

    "The "SLIS" type pool provides a wide range of data types and constants that are commonly used    in creating ALV (ABAP List Viewer) reports
    TYPE-POOLS: slis.

"Here we are doing data declaration for our internal table (Z311BOOKINGS) and specifying the logo name (Logo).
    DATA: it_z311bookings TYPE TABLE OF Z311BOOKINGS,
      g_repid          TYPE sy-repid. "predefined data type in ABAP, and it represents the Repository ID of the current ABAP program (g) stands for global variable

"Declare data structure - used to store a list of ALV headers
    DATA: it_listheader TYPE slis_t_listheader,
      wa_listheader TYPE slis_listheader.


"Collect data from our custom table Z311BOOKINGS
     START-OF-SELECTION.
      g_repid = sy-repid.

      SELECT * FROM z311bookings INTO TABLE it_z311bookings.

      PERFORM build_alv_header. "This subroutine is used to set up the header information for an ABAP List Viewer report, which helps define how the report's header should look and what content it should contain.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' "This line is used to display an ALV grid. (Displays a tabular report)
        EXPORTING
      i_callback_program     = g_repid "The callback program with variable name g_rapid is a routine   used to do formatting headers, footers, or handling user interactions like clicking on a row or  column in the report.
      i_callback_top_of_page = 'TOP_OF_PAGE' "Same as above code but just for the top of each page    in the report.
      i_structure_name       = 'BOOKINGS'
      TABLES
      t_outtab               = it_z311bookings. "Here we specify the data to be displayed in the ALV   report.

      FORM build_alv_header .

    "Type H is used to display headers i.e. big font
     wa_listheader-typ  = 'H'.
     wa_listheader-info ='Booking Details'.
     APPEND wa_listheader TO it_listheader.
     CLEAR wa_listheader.

     "Type S is used to display key and value pairs. In our case the key is 'Date :' and the value is the current date shown as 'dd/mm/yyyy.'
      wa_listheader-typ = 'S'.
     wa_listheader-key = 'Date :' .
     CONCATENATE  sy-datum+6(2)
           sy-datum+4(2)
           sy-datum(4)
           INTO wa_listheader-info
           SEPARATED BY '/'.
     APPEND wa_listheader TO it_listheader.
     CLEAR wa_listheader.


     "Type A is used to display italic font
    wa_listheader-typ = 'A'.
     wa_listheader-key = 'Date    :' .
     wa_listheader-info ='SAP ALV Report'.
    APPEND wa_listheader TO it_listheader.
     CLEAR wa_listheader.

    ENDFORM.

     FORM top_of_page.
     CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' "This code is used to format and display the header    content, including our custom logo, at the top of each page in our ALV .
      EXPORTING`your text`
      it_list_commentary = it_listheader
      i_logo         = 'Logo'.

ENDFORM.                    "top_of_page.

谢谢你:D

我似乎无法弄清楚我的程序中的代码有什么问题。我收到运行时错误 GETWA_NOT_ASSIGNED(数据段 -1)。

abap erp sap
1个回答
0
投票

这一行:

i_structure_name       = 'BOOKINGS'

必须是这样的:

i_structure_name       = 'Z311BOOKINGS'

数据是从表Z311BOOKINGS中选取的,因此ALV功能模块必须基于该表建立字段目录。

© www.soinside.com 2019 - 2024. All rights reserved.