2022 Dec 29 7:12 AM
Hello all,
I have a requirement to display a table in ABAP report.
The table of data should be displayed on the next screen if the table is not empty else display an error message on the same selection screen.
I have tried at selection-screen, but getting error even if the table is not empty.
Can anyone help me with this ?
2023 Jan 03 6:36 PM
I didn't quite understand your question, but I think this solves it:
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS: p_carrid TYPE spfli-carrid.
SELECTION-SCREEN: END OF BLOCK b1.
START-OF-SELECTION.
SELECT *
FROM spfli
INTO TABLE @DATA(lt_spfli)
WHERE carrid EQ @p_carrid.
IF sy-subrc IS NOT INITIAL.
MESSAGE 'Error' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = DATA(lo_alv)
CHANGING
t_table = lt_spfli.
CATCH cx_salv_msg.
ENDTRY.
lo_alv->display( ).
2023 Jan 04 5:02 AM
2023 Jan 04 7:30 AM
Hi rimjhim_agrawal28,
As per your requirement, you can use Module pool Programming. Simply by creating another screen and generate
table control.
or else, you can also refer to the code below.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
PARAMETERS p_vbln TYPE vbak-vbeln.
SELECTION-SCREEN END OF BLOCK blk1.
SELECT
vbeln,
erdat,
erzet,
ernam,
auart
FROM vbak
INTO TABLE @DATA(lt_vbak)
WHERE vbeln = @p_vbln.
IF sy-subrc = 0.
cl_demo_output=>display( lt_vbak ).
ELSE.
MESSAGE 'TABLE NOT FOUND!' TYPE 'E'.
ENDIF.
Hope this Helps.
Regards,
Wajiha Fathima.
2023 Jan 04 4:35 PM