Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP ABAP Report

former_member41141
Discoverer
0 Kudos
606

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 ?

4 REPLIES 4

estevaoblara99
Discoverer
517

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( ).

TarunTakshak
Participant
0 Kudos
517

Can you specify the error which you are getting?

fathimawajiha
Explorer
0 Kudos
517

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.

raymond_giuseppi
Active Contributor
0 Kudos
517

Can you post relevant part of your code?