0% found this document useful (0 votes)
149 views

ALV Report

This document contains code for two ABAP reports that display customer data from a database table in an ALV grid. The reports create an internal table from a database query, generate field catalog metadata, and call functions to display the ALV grid populated with the customer data. Selection screens are used to filter the database query by country or region.

Uploaded by

charan817
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views

ALV Report

This document contains code for two ABAP reports that display customer data from a database table in an ALV grid. The reports create an internal table from a database query, generate field catalog metadata, and call functions to display the ALV grid populated with the customer data. Selection screens are used to filter the database query by country or region.

Uploaded by

charan817
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

*&---------------------------------------------------------------------* *& Report ZALV_REPORT *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zalv_report NO STANDARD PAGE HEADING.

TYPE-POOLS: slis. TABLES: kna1. TYPES: BEGIN OF ty_customer. INCLUDE STRUCTURE kna1. TYPES: END OF ty_customer.

DATA: it_customer TYPE STANDARD TABLE OF ty_customer, it_fieldcat TYPE slis_t_fieldcat_alv. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. SELECT-OPTIONS: so_cntry FOR kna1-land1. SELECTION-SCREEN END OF BLOCK b1. START-OF-SELECTION . SELECT * FROM kna1 INTO TABLE it_customer WHERE land1 IN so_cntry.

* * * *

* *

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_program_name = sy-repid " 'ZALV_REPORT' i_internal_tabname = 'IT_CUSTOMER' i_structure_name = 'KNA1' I_CLIENT_NEVER_DISPLAY = 'X' I_INCLNAME = I_BYPASSING_BUFFER = I_BUFFER_ACTIVE = CHANGING ct_fieldcat = it_fieldcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3 . IF sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_INTERFACE_CHECK = ' ' I_BYPASSING_BUFFER = ' ' I_BUFFER_ACTIVE = ' ' i_callback_program = sy-repid I_CALLBACK_PF_STATUS_SET = ' ' I_CALLBACK_USER_COMMAND = ' ' I_CALLBACK_TOP_OF_PAGE = ' ' I_CALLBACK_HTML_TOP_OF_PAGE = ' ' I_CALLBACK_HTML_END_OF_LIST = ' ' I_STRUCTURE_NAME = I_BACKGROUND_ID = ' ' I_GRID_TITLE = I_GRID_SETTINGS = IS_LAYOUT = it_fieldcat = it_fieldcat[] IT_EXCLUDING = IT_SPECIAL_GROUPS = IT_SORT = IT_FILTER = IS_SEL_HIDE = I_DEFAULT = 'X' I_SAVE = ' ' IS_VARIANT = IT_EVENTS = IT_EVENT_EXIT = IS_PRINT = IS_REPREP_ID = I_SCREEN_START_COLUMN = 0 I_SCREEN_START_LINE = 0 I_SCREEN_END_COLUMN = 0 I_SCREEN_END_LINE = 0 I_HTML_HEIGHT_TOP = 0 I_HTML_HEIGHT_END = 0 IT_ALV_GRAPHICS = IT_HYPERLINK = IT_ADD_FIELDCAT = IT_EXCEPT_QINFO = IR_SALV_FULLSCREEN_ADAPTER = IMPORTING E_EXIT_CAUSED_BY_CALLER = ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = it_customer EXCEPTIONS program_error = 1 OTHERS = 2

. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

*&---------------------------------------------------------------------* *& Report ZALV_REPORT_PRACTICE *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zalv_report_practice NO STANDARD PAGE HEADING.

TYPE-POOLS: slis. TABLES: kna1. TYPES: BEGIN OF ty_customer. INCLUDE STRUCTURE kna1. TYPES: END OF ty_customer. data : lv_regio type c. DATA: it_customer TYPE STANDARD TABLE OF ty_customer, it_fieldcat TYPE slis_t_fieldcat_alv. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. SELECT-OPTIONS: so_regio FOR kna1-regio. SELECTION-SCREEN END OF BLOCK b1. AT SELECTION-SCREEN. SELECT SINGLE bland FROM t005s INTO lv_regio WHERE bland IN so_regio. IF sy-subrc NE 0. MESSAGE e002(zreports). ENDIF.

START-OF-SELECTION. SELECT * FROM kna1 INTO TABLE it_customer WHERE regio IN so_regio. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING I_PROGRAM_NAME = sy-repid I_INTERNAL_TABNAME = 'IT_CUSTOMER' I_STRUCTURE_NAME = 'KNA1' I_CLIENT_NEVER_DISPLAY = 'X' I_INCLNAME = I_BYPASSING_BUFFER = I_BUFFER_ACTIVE = CHANGING ct_fieldcat = it_fieldcat EXCEPTIONS INCONSISTENT_INTERFACE = 1 PROGRAM_ERROR = 2

* * * *

* * *

= 3 . IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_INTERFACE_CHECK = ' ' I_BYPASSING_BUFFER = ' ' I_BUFFER_ACTIVE = ' ' i_callback_program = sy-repid I_CALLBACK_PF_STATUS_SET = ' ' I_CALLBACK_USER_COMMAND = ' ' I_CALLBACK_TOP_OF_PAGE = ' ' I_CALLBACK_HTML_TOP_OF_PAGE = ' ' I_CALLBACK_HTML_END_OF_LIST = ' ' I_STRUCTURE_NAME = I_BACKGROUND_ID = ' ' I_GRID_TITLE = I_GRID_SETTINGS = IS_LAYOUT = it_fieldcat = it_fieldcat[] IT_EXCLUDING = IT_SPECIAL_GROUPS = IT_SORT = IT_FILTER = IS_SEL_HIDE = I_DEFAULT = 'X' I_SAVE = ' ' IS_VARIANT = IT_EVENTS = IT_EVENT_EXIT = IS_PRINT = IS_REPREP_ID = I_SCREEN_START_COLUMN = 0 I_SCREEN_START_LINE = 0 I_SCREEN_END_COLUMN = 0 I_SCREEN_END_LINE = 0 I_HTML_HEIGHT_TOP = 0 I_HTML_HEIGHT_END = 0 IT_ALV_GRAPHICS = IT_HYPERLINK = IT_ADD_FIELDCAT = IT_EXCEPT_QINFO = IR_SALV_FULLSCREEN_ADAPTER = IMPORTING E_EXIT_CAUSED_BY_CALLER =

OTHERS

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = it_customer EXCEPTIONS program_error = 1 OTHERS = 2 . IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

You might also like