I can't seem to figure out what is wrong with my code in my program. I get the runtime error GETWA_NOT_ASSIGNED
(data segment -1).
Hopefully someone way smarter than me can spot the mistake... My table is called z311bookings
.
THANK YOU :D
Here is my code:
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.
This line:
has to be like:
Data is selected from table Z311BOOKINGS, so the ALV function module has to build up the field cataloge based on this table.