STEPS:
Create a custom container. You can change the name of your own.
Create a method to instantiate your custom container:
IF at_custom_container IS INITIAL.
CREATE OBJECT at_custom_containerEXPORTING
container_name = at_container.
CREATE OBJECT at_grid1
EXPORTING
i_parent = at_custom_container.
ENDIF.
Call the method below to generate your alv:
data: variant type disvariant. "to save the alv layout
variant-report = sy-repid. "to save the alv layout
variant-username = sy-uname. "to save the alv layout
* Displaying ALV Grid
CALL METHOD at_grid1->set_table_for_first_display
EXPORTING
IS_LAYOUT = at_wa_alv_layout
is_variant = variant "to show the alv layout button
i_save = 'A' "to show the alv layout button
CHANGING
it_outtab = at_it_tab_alv"i_tab "should always be declared at
"the top or attributes
it_fieldcatalog = at_it_fieldcat.
IF sy-subrc NE 0.
MESSAGE 'ERROR FOUND in displaying records!' TYPE 'E' DISPLAY LIKE 'I'.
EXIT.
ENDIF.
No comments:
Post a Comment