Display Two Level Interactive
List in ALV
This is a sample code to display 2 level interactive list in alv: REPORT ZYP_ALV_INTERACTIVE_LIST1 MESSAGE-ID ZSERP. ************************************************************************ * PROGRAM INFORMATION ************************************************************************ * PROGRAM....... ZYP_ALV_CUST_DETAILS * TITLE......... TEST PROGRAM * AUTHOR........ <Author name> (<user-id) * DATE WRITTEN.. <Date written> * R/3 RELEASE... 6.0 * TRANSPORTNR... <Transport number> * COPIED FROM... ZSAMPLE_ALV_RSA *----------------------------------------------------------------------* * PROGRAM FUNCTION: * THIS PROGRAM IS USED TO DISPLAY THE VENDOR MASTER INFORMATION AS * ALV-GRID DISPLAY USING CLASSES. *----------------------------------------------------------------------* * PROGRAM TYPE.. EXECUTABLE * PACKAGE.... <Package> * LOGICAL DB.... <Logical database used> ************************************************************************ ************************************************************************ * CHANGE HISTORY ************************************************************************ * DATE CHANGE... <Date of change written> * AUTHOR........ <yugapreetha.t> * CHANGE DESCR.. <Description of change> * R/3 RELEASE... <Release> * TRANSPORTNR... <Transport number> ************************************************************************ ************************************************************************ *Data Declaration * ************************************************************************ INCLUDE ZYP_DATA_DEC_INTERACTIVE. *include ZSDN_DATA_DEC. ************************************************************************ *Selection screen * ************************************************************************ SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME. PARAMETER: P_LAYOUT TYPE X_KAEP_DISVARIANT. "Layout. SELECTION-SCREEN END OF BLOCK B1. ************************************************************************ *Class Declaration * ************************************************************************ INCLUDE ZYP_ALV_CLASS_INTERACTIVE. *include ZSDN_ALV_CLASS. ************************************************************************ * Forms section * ************************************************************************ INCLUDE ZYP_ALV_FORMS_ITERACTIVE. *include ZSDN_ALV_FORMS. ************************************************************************ *To validate the selection screen * ************************************************************************ AT SELECTION-SCREEN. PERFORM VALIDATE-SELECTIONS. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_LAYOUT. PERFORM VARIANT-INPUT-HELP. *********************************************************************** *Start of Selection * ************************************************************************ START-OF-SELECTION. PERFORM GET_DATA_CUST. "Subroutine to retrieve data from Customer PERFORM DISPLAY_DATA_GRID. "Subroutine to display data in grid *&---------------------------------------------------------------------* *& Include ZYP_DATA_DEC_WASE *&---------------------------------------------------------------------* TABLES: MAKT,KNA1,LFA1,LFB1. *&---------------------------------------------------------------------* *Types declarations *&---------------------------------------------------------------------* TYPES: BEGIN OF X_KNA1 , KUNNR TYPE KNA1-KUNNR, "customer number LAND1 TYPE KNA1-LAND1, "country key NAME1 TYPE KNA1-NAME1, "name END OF X_KNA1. TYPES: BEGIN OF X_MAKT, MATNR TYPE MAKT-MATNR, "material number MAKTX TYPE MAKT-MAKTX, "material describtion END OF X_MAKT. TYPES: BEGIN OF X_LFA1, LIFNR TYPE LFA1-LIFNR, "account number ORT01 TYPE LFA1-NAME1, "city NAME1 TYPE LFA1-ORT01, "name END OF X_LFA1. *&---------------------------------------------------------------------* *Constants used *&---------------------------------------------------------------------* CONSTANTS: C_ALL TYPE C VALUE 'A', "Variable used to Save Layout C_CHECK TYPE C VALUE 'X', "temporary variable C_CONTAINER TYPE SCRFNAME VALUE 'WASE', "Name of a Screen Element. C_SELECTOPTION TYPE TEXTPOOL-KEY VALUE 'S'. "Text element key (number/selection name) TYPES: X_KAEP_DISVARIANT LIKE DISVARIANT- VARIANT. "Layout *&---------------------------------------------------------------------* *Internal table for Vendor data *&---------------------------------------------------------------------* DATA: T_KNA1 TYPE STANDARD TABLE OF X_KNA1, "customer table T_MAKT TYPE STANDARD TABLE OF X_MAKT, "material table T_LFA1 TYPE STANDARD TABLE OF X_LFA1. "vendor table *creating a work area for internal table. DATA: W_KNA1 TYPE X_KNA1, "workarea for customer table W_MAKT TYPE X_MAKT, "workarea for material table W_LFA1 TYPE X_LFA1. "workarea for vendor table DATA: LW_VARIANT TYPE DISVARIANT, "Layout LW_LAYOUT TYPE LVC_S_LAYO, "Layout LW_PRINT TYPE LVC_S_PRNT. "Print settings for LVC RANGES: R_DUMMY FOR LVC_S_FILT-LOW. "ALV control: Filter structure-text CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED. *&---------------------------------------------------------------------* *Reference objects for classes *&---------------------------------------------------------------------* DATA: LR_GRID TYPE REF TO CL_GUI_ALV_GRID, "ALV List Viewer LR_HTML TYPE REF TO CL_DD_DOCUMENT, "Dynamic Documents: Document LR_CUSTOM_CONTNR TYPE REF TO CL_GUI_CUSTOM_CONTAINER, "Container for Custom Controls in the Screen Area LR_CUSTOM_CONTNR1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER, LR_CUSTOM_CONTNR2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER, L_VARIANT_SAVE TYPE C VALUE C_ALL, LR_SPLIT TYPE REF TO CL_GUI_EASY_SPLITTER_CONTAINER, "Reduced Version of Splitter Container Control LR_CONTNR_TOP TYPE REF TO CL_GUI_CONTAINER, "Abstract Container for GUI Controls LR_CONTNR_BOT TYPE REF TO CL_GUI_CONTAINER, "Abstract Container for GUI Controls LT_FIELDCAT TYPE LVC_T_FCAT. "Field Catalog for List Viewer Control *&---------------------------------------------------------------------* *& Include ZYP_ALV_CLASS_INTERACTIVE *&---------------------------------------------------------------------* CLASS LCL_EVENT_RECEIVER DEFINITION. PUBLIC SECTION. * Method for handling Event-Top of Page event METHODS ON_HANDLE_TOP_OF_PAGE FOR EVENT TOP_OF_PAGE OF CL_GUI_ALV_GRID IMPORTING E_DYNDOC_ID. * Method for handling Event-Print Top of Page event METHODS ON_HANDLE_PRINT_TOP_OF_PAGE FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID. * Method for handling Event-Print End of List event METHODS ON_HANDLE_PRINT_END_OF_LIST FOR EVENT PRINT_END_OF_LIST OF CL_GUI_ALV_GRID. * Method for handling Event-HOTSPOT CLICK METHODS ON_HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO. ENDCLASS. "lcl_event_receiver DEFINITION *---------------------------------------------------------------------* * CLASS LCL_EVENT_RECEIVER IMPLEMENTATION *---------------------------------------------------------------------* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION. * Method for Handling Top of Page event METHOD ON_HANDLE_TOP_OF_PAGE. PERFORM OUTPUT-PARAMETERS USING E_DYNDOC_ID 'OUTPUT_PARAMS'. ENDMETHOD. "on_handle_top_of_page * Method for Handling Top of Page at Print event METHOD ON_HANDLE_PRINT_TOP_OF_PAGE. PERFORM OUTPUT-HEADINGS. ENDMETHOD. "on_handle_print_top_of_page * Method for Handling End of List at Print event METHOD ON_HANDLE_PRINT_END_OF_LIST. PERFORM OUTPUT-PARAMETERS USING LR_HTML SPACE. ENDMETHOD. "on_handle_print_end_of_list * Method for handling Hotspot METHOD ON_HANDLE_HOTSPOT_CLICK. PERFORM HANDLE_HOTSPOT_CLICK USING E_ROW_ID E_COLUMN_ID ES_ROW_NO . ENDMETHOD . "ON_HANDLE_HOTSPOT_CLICK ENDCLASS. "lcl_event_receiver IMPLEMENTATION *Object for handling events DATA: LR_EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER. *&---------------------------------------------------------------------* *& Include ZYP_ALV_FORMS_INTERACTIVE *&---------------------------------------------------------------------* * To retrieve the data. FORM GET_DATA_CUST. CLEAR T_KNA1. REFRESH T_KNA1. SELECT KUNNR NAME1 LAND1 FROM KNA1 INTO TABLE T_KNA1. "fetching customer details ENDFORM. " get_Data *&---------------------------------------------------------------------* *& Form used to display data in grid *&---------------------------------------------------------------------* * To display the ALV-GRID FORM DISPLAY_DATA_GRID. IF LR_CUSTOM_CONTNR IS INITIAL. *----------------------------------------------------------------------* * Create Event Receiver *----------------------------------------------------------------------* CREATE OBJECT LR_EVENT_RECEIVER. IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL. *----------------------------------------------------------------------* * Creates the custom container *----------------------------------------------------------------------* CREATE OBJECT LR_CUSTOM_CONTNR EXPORTING CONTAINER_NAME = C_CONTAINER. "Element name *----------------------------------------------------------------------* * Create the splitter control *----------------------------------------------------------------------* CREATE OBJECT LR_SPLIT EXPORTING PARENT = LR_CUSTOM_CONTNR "Container for Custom Controls in the Screen Area * ORIENTATION = 0 SASH_POSITION = 15 WITH_BORDER = 0 EXCEPTIONS CNTL_ERROR = 1 CNTL_SYSTEM_ERROR = 2 OTHERS = 3. *----------------------------------------------------------------------* * Get the containers of the splitter control *----------------------------------------------------------------------* LR_CONTNR_TOP = LR_SPLIT->TOP_LEFT_CONTAINER. LR_CONTNR_BOT = LR_SPLIT->BOTTOM_RIGHT_CONTAINER. ENDIF. *----------------------------------------------------------------------* * ALV grid creation at the bottom right container *----------------------------------------------------------------------* CREATE OBJECT LR_GRID EXPORTING I_PARENT = LR_CONTNR_BOT. *----------------------------------------------------------------------* * Handle events *----------------------------------------------------------------------* * SET HANDLER LR_EVENT_RECEIVER->ON_HANDLE_TOP_OF_PAGE FOR LR_GRID. * SET HANDLER LR_EVENT_RECEIVER->ON_HANDLE_PRINT_TOP_OF_PAGE FOR LR_GRID. * SET HANDLER LR_EVENT_RECEIVER->ON_HANDLE_PRINT_END_OF_LIST FOR LR_GRID. SET HANDLER LR_EVENT_RECEIVER->ON_HANDLE_HOTSPOT_CLICK FOR LR_GRID. *----------------------------------------------------------------------* * Object for display of selection parameters in HTML top container * *----------------------------------------------------------------------* * CREATE OBJECT LR_HTML EXPORTING STYLE = 'ALV_GRID'. * IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL. **----------------------------------------------------------------------* ** Must be after the SET HANDLER for TOP_OF_PAGE and foreground only* **----------------------------------------------------------------------* * CALL METHOD LR_GRID->LIST_PROCESSING_EVENTS * EXPORTING * I_EVENT_NAME = 'TOP_OF_PAGE' * I_DYNDOC_ID = LR_HTML. "Dynamic Documents: Document * ENDIF. *----------------------------------------------------------------------* * Retrieve Field specifications and descriptions for ALV Grid *----------------------------------------------------------------------* CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING I_BUFFER_ACTIVE = SPACE I_STRUCTURE_NAME = 'YPSTRUC_CUST_INTERACTIVE' CHANGING CT_FIELDCAT = LT_FIELDCAT. *----------------------------------------------------------------------* *This perform changes the text heading on the grid *----------------------------------------------------------------------* PERFORM GET_FEILDCAT_DESC." TO CHANGE THE LIST HEADINGS LW_LAYOUT-SMALLTITLE = C_CHECK. "Default Grid title to small font LW_LAYOUT-ZEBRA = C_CHECK. "Output rows with alternating colors LW_LAYOUT-NO_AUTHOR = C_CHECK. "Allow users to enter global layouts LW_PRINT-PRNT_TITLE = C_CHECK. "Do not print out grid title LW_LAYOUT-CWIDTH_OPT = C_CHECK. "ALV control: Optimize column width LW_LAYOUT-SEL_MODE = SPACE. "ALV control: SelectionMode LW_LAYOUT-NO_F4 = C_CHECK. "Character Field Length 1 LW_VARIANT-REPORT = SY-REPID. "Program name LW_VARIANT-USERNAME = SY-UNAME. "User name ENDIF. *----------------------------------------------------------------------* *Display an output table in the ALV Grid Control instance. *----------------------------------------------------------------------* CALL METHOD LR_GRID->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING IS_LAYOUT = LW_LAYOUT "Layout IS_VARIANT = LW_VARIANT "Layout I_SAVE = C_ALL "Variable used to Save Layout IS_PRINT = LW_PRINT "Print settings for LVC CHANGING IT_FIELDCATALOG = LT_FIELDCAT "Fieldcatalog IT_OUTTAB = T_KNA1. "master internal table *----------------------------------------------------------------------* *Calls screen with container * *----------------------------------------------------------------------* CALL SCREEN 0100. ENDFORM. " display_data_grid *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. CASE SY-UCOMM. WHEN 'BACK'. SET SCREEN 0. LEAVE SCREEN. WHEN 'EXIT'. SET SCREEN 0. LEAVE SCREEN. WHEN 'CANCEL'. SET SCREEN 0. LEAVE SCREEN. ENDCASE. CLEAR SY-UCOMM. ENDMODULE. " USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* *& Form OUTPUT-PARAMETERS *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* * Subroutine to handle End of List at Print *&---------------------------------------------------------------------* FORM OUTPUT-PARAMETERS USING PW_DYNDOC TYPE REF TO CL_DD_DOCUMENT PW_TABID TYPE C. DATA: LT_FILTER TYPE LVC_T_FILT. "ALV control: Table of filter conditions FIELD-SYMBOLS: <FS_L_FILTER> TYPE LVC_S_FILT. "ALV control: Filter structure RANGES: R_DUMMY FOR LVC_S_FILT-LOW. "ALV control: Filter structure-low IF PW_TABID IS INITIAL. *********************************************************************** * Output Filter Criteria on last printed page * *********************************************************************** CALL METHOD LR_GRID->GET_FILTER_CRITERIA IMPORTING ET_FILTER = LT_FILTER. LOOP AT LT_FILTER ASSIGNING <FS_L_FILTER>. AT FIRST. SKIP. WRITE:/ TEXT-132 UNDER TEXT-131. ENDAT. AT NEW FIELDNAME. REFRESH R_DUMMY. ENDAT. R_DUMMY-SIGN = <FS_L_FILTER>-SIGN. R_DUMMY-OPTION = <FS_L_FILTER>-OPTION. WRITE <FS_L_FILTER>-LOW TO R_DUMMY-LOW LEFT-JUSTIFIED. IF <FS_L_FILTER>-OPTION = 'BT' OR <FS_L_FILTER>-OPTION = 'NB'. WRITE <FS_L_FILTER>-HIGH TO R_DUMMY-HIGH LEFT-JUSTIFIED. ELSE. CLEAR R_DUMMY-HIGH. ENDIF. APPEND R_DUMMY. AT END OF FIELDNAME. PERFORM PARAMETERS TABLES R_DUMMY USING C_SELECTOPTION SPACE SPACE <FS_L_FILTER>-SELTEXT PW_DYNDOC->HTML_TABLE. ENDAT. ENDLOOP. *----------------------------------------------------------------------* * Indicates end of printed report *----------------------------------------------------------------------* CALL FUNCTION 'Z_CMS_REPORT_END'. ELSE. *----------------------------------------------------------------------* * Invoke routine to display HTML document *----------------------------------------------------------------------* CALL METHOD PW_DYNDOC->DISPLAY_DOCUMENT EXPORTING PARENT = LR_CONTNR_TOP. ENDIF. ENDFORM. " OUTPUT-PARAMETERS *&---------------------------------------------------------------------* *& Form get_feildcat_desc *&---------------------------------------------------------------------* FORM GET_FEILDCAT_DESC. FIELD-SYMBOLS: <FS_L_FIELDCAT> TYPE LVC_S_FCAT. "ALV control: Field catalog LOOP AT LT_FIELDCAT ASSIGNING <FS_L_FIELDCAT>. CASE <FS_L_FIELDCAT>-FIELDNAME . WHEN 'KUNNR'. <FS_L_FIELDCAT>-SCRTEXT_L = TEXT-002. "customer No <FS_L_FIELDCAT>-SCRTEXT_M = TEXT-002. <FS_L_FIELDCAT>-SCRTEXT_S = TEXT-002. <FS_L_FIELDCAT>-HOTSPOT = 'X'. <FS_L_FIELDCAT>-REPTEXT = TEXT-002. <FS_L_FIELDCAT>-EMPHASIZE = 'C310'. WHEN 'LAND1'. <FS_L_FIELDCAT>-SCRTEXT_L = TEXT-003. "country key <FS_L_FIELDCAT>-SCRTEXT_M = TEXT-003. <FS_L_FIELDCAT>-SCRTEXT_S = TEXT-003. <FS_L_FIELDCAT>-REPTEXT = TEXT-003. <FS_L_FIELDCAT>-EMPHASIZE = 'C310'. WHEN 'NAME1'. <FS_L_FIELDCAT>-SCRTEXT_L = TEXT-004. "Name <FS_L_FIELDCAT>-SCRTEXT_M = TEXT-004. <FS_L_FIELDCAT>-SCRTEXT_S = TEXT-004. <FS_L_FIELDCAT>-REPTEXT = TEXT-004. <FS_L_FIELDCAT>-EMPHASIZE = 'C310'. ENDCASE. ENDLOOP. ENDFORM. " get_feildcat_desc *&---------------------------------------------------------------------* *& Form variant-input-help *&---------------------------------------------------------------------* ************************************************************************************ *************To validate the selection screen * ********************************************************************* *************** FORM VARIANT-INPUT-HELP. DATA: LT_DYNPFIELDS TYPE TABLE OF DYNPREAD, "Fields of the current screen (with values) L_EXIT TYPE C, LW_L_VARIANT LIKE LW_VARIANT, LW_L_DYNPFIELDS TYPE DYNPREAD. *----------------------------------------------------------------------* * Get values from the selection screen to determine layout set *----------------------------------------------------------------------* LW_L_DYNPFIELDS-FIELDNAME = 'P_LAYOUT'. APPEND LW_L_DYNPFIELDS TO LT_DYNPFIELDS. CALL FUNCTION 'DYNP_VALUES_READ' EXPORTING DYNAME = SY-CPROG "Program name DYNUMB = '1000' TRANSLATE_TO_UPPER = C_CHECK TABLES DYNPFIELDS = LT_DYNPFIELDS. "Fields of the current screen (with values) LOOP AT LT_DYNPFIELDS INTO LW_L_DYNPFIELDS. CASE LW_L_DYNPFIELDS-FIELDNAME. WHEN 'LW_LAYOUT'. LW_VARIANT-VARIANT = LW_L_DYNPFIELDS-FIELDVALUE. ENDCASE. ENDLOOP. LW_VARIANT-REPORT = SY-REPID. "Program name LW_VARIANT-USERNAME = SY-UNAME. "User name *----------------------------------------------------------------------* * Invoke function to provide drop down entries *----------------------------------------------------------------------* CALL FUNCTION 'REUSE_ALV_VARIANT_F4' EXPORTING IS_VARIANT = LW_VARIANT "Layout I_SAVE = L_VARIANT_SAVE IMPORTING E_EXIT = L_EXIT ES_VARIANT = LW_L_VARIANT EXCEPTIONS NOT_FOUND = 1 PROGRAM_ERROR = 2 OTHERS = 3. IF SY-SUBRC = 0. IF L_EXIT IS INITIAL. * P_LAYOUT = LW_L_VARIANT-VARIANT. "Layout ENDIF. ELSE. MESSAGE I000(ZSERP) WITH TEXT-VAR SPACE SPACE SPACE. ENDIF. FREE: LT_DYNPFIELDS. ENDFORM. " variant-input-help ************ *&---------------------------------------------------------------------* *& Form OUTPUT-HEADINGS *&---------------------------------------------------------------------* * Handle Top of Page at Print FORM OUTPUT-HEADINGS. *To handle title report CALL FUNCTION 'Z_CMS_REPORT_TITLE' EXPORTING I_TITLE2 = 'TEST'. "abap Internal ABAP/4 text ENDFORM. " OUTPUT-HEADINGS *&---------------------------------------------------------------------* *& Form parameters *&---------------------------------------------------------------------* FORM PARAMETERS TABLES LT_PT_RANGE USING L_PW_TEXT TYPE TEXTPOOL-KEY L_PW_VALUE TYPE ANY L_PW_TABID TYPE C L_PW_PASTX TYPE C LT_PT_HTML LIKE LR_HTML->HTML_TABLE. DATA: LW_L_TYPE. LW_L_TYPE = L_PW_TEXT(1). *To handle report selections CALL FUNCTION 'Z_CMS_REPORT_SELECTIONS' EXPORTING TEXT_NAME = L_PW_TEXT SELECTION_TYPE = LW_L_TYPE SELECTION_VALUE = L_PW_VALUE TABLE_ID = L_PW_TABID PASSED_TEXT = L_PW_PASTX TABLES SELECTION_RANGE = LT_PT_RANGE HTML_TABLE = LT_PT_HTML. ENDFORM. " PARAMETERS *&---------------------------------------------------------------------* *& Module user_command_output OUTPUT *&---------------------------------------------------------------------* MODULE USER_COMMAND_OUTPUT OUTPUT. SET PF-STATUS 'ZSAMPLE' IMMEDIATELY. SET TITLEBAR 'ZSAMPLE'. ENDMODULE. " user_command_output OUTPUT *&---------------------------------------------------------------------* *& Form HANDLE_HOTSPOT_CLICK *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_E_ROW_ID text * -->P_E_COLUMN_ID text * -->P_ES_ROW_NO text *----------------------------------------------------------------------* FORM HANDLE_HOTSPOT_CLICK USING P_E_ROW_ID TYPE LVC_S_ROW P_E_COLUMN_ID TYPE LVC_S_COL P_ES_ROW_NO TYPE LVC_S_ROID. IF SY-SUBRC = 0. " AND p_E_COLUMN_ID-FIELDNAME = 'KUNNR'. SET PARAMETER ID 'AUN' FIELD W_KNA1-KUNNR. READ TABLE T_KNA1 INDEX P_E_ROW_ID INTO W_KNA1. SELECT LIFNR NAME1 ORT01 FROM LFA1 INTO TABLE T_LFA1 . "fetching vendor details PERFORM DISPLAY_DATA_GRID1. "Subroutine to display data in grid *** IF SY-LSIND = 1. *** SET PARAMETER ID 'AUN' FIELD W_LFA1-LIFNR. *** READ TABLE T_LFA1 INDEX P_E_ROW_ID INTO W_LFA1. *** SELECT MATNR MAKTX FROM MAKT INTO TABLE T_MAKT . "fetching material details *** PERFORM DISPLAY_DATA_GRID2. "Subroutine to display data in grid *** *** *** ENDIF. ENDIF. ENDFORM. " HANDLE_HOTSPOT_CLICK *&---------------------------------------------------------------------* *& Form VALIDATE-SELECTIONS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM VALIDATE-SELECTIONS . IF NOT P_LAYOUT IS INITIAL. * Check Layout LW_VARIANT-REPORT = SY-REPID. "Program name LW_VARIANT-USERNAME = SY-UNAME. "User name LW_VARIANT-VARIANT = P_LAYOUT. "Layout CALL FUNCTION 'LVC_VARIANT_EXISTENCE_CHECK' EXPORTING I_SAVE = L_VARIANT_SAVE CHANGING CS_VARIANT = LW_VARIANT EXCEPTIONS OTHERS = 01. IF SY-SUBRC NE 0. MESSAGE E000(ZSERP) WITH TEXT-VAR SPACE SPACE SPACE. ENDIF. ENDIF. ENDFORM. " VALIDATE-SELECTIONS *&---------------------------------------------------------------------* *& Form used to display data in grid *&---------------------------------------------------------------------* * To display the ALV-GRID FORM DISPLAY_DATA_GRID1. CONSTANTS:C_CONTAINER TYPE SCRFNAME VALUE 'CUSTOM CONTROL'. IF LR_CUSTOM_CONTNR1 IS INITIAL. *----------------------------------------------------------------------* * Create Event Receiver *----------------------------------------------------------------------* CREATE OBJECT LR_EVENT_RECEIVER. IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL. *----------------------------------------------------------------------* * Creates the custom container *----------------------------------------------------------------------* CREATE OBJECT LR_CUSTOM_CONTNR1 EXPORTING CONTAINER_NAME = C_CONTAINER. "Element name *----------------------------------------------------------------------* * Create the splitter control *----------------------------------------------------------------------* CREATE OBJECT LR_SPLIT EXPORTING PARENT = LR_CUSTOM_CONTNR1 "Container for Custom Controls in the Screen Area * ORIENTATION = 0 SASH_POSITION = 15 WITH_BORDER = 0 EXCEPTIONS CNTL_ERROR = 1 CNTL_SYSTEM_ERROR = 2 OTHERS = 3. *----------------------------------------------------------------------* * Get the containers of the splitter control *----------------------------------------------------------------------* LR_CONTNR_TOP = LR_SPLIT->TOP_LEFT_CONTAINER. LR_CONTNR_BOT = LR_SPLIT->BOTTOM_RIGHT_CONTAINER. ENDIF. *----------------------------------------------------------------------* * ALV grid creation at the bottom right container *----------------------------------------------------------------------* CREATE OBJECT LR_GRID EXPORTING I_PARENT = LR_CONTNR_BOT. *----------------------------------------------------------------------* * Handle events *----------------------------------------------------------------------* SET HANDLER LR_EVENT_RECEIVER->ON_HANDLE_TOP_OF_PAGE FOR LR_GRID. SET HANDLER LR_EVENT_RECEIVER->ON_HANDLE_PRINT_TOP_OF_PAGE FOR LR_GRID. SET HANDLER LR_EVENT_RECEIVER->ON_HANDLE_PRINT_END_OF_LIST FOR LR_GRID. * SET HANDLER LR_EVENT_RECEIVER->ON_HANDLE_HOTSPOT_CLICK FOR LR_GRID. *----------------------------------------------------------------------* * Object for display of selection parameters in HTML top container * *----------------------------------------------------------------------* * CREATE OBJECT LR_HTML EXPORTING STYLE = 'ALV_GRID'. * IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL. **----------------------------------------------------------------------* ** Must be after the SET HANDLER for TOP_OF_PAGE and foreground only* **----------------------------------------------------------------------* * CALL METHOD LR_GRID->LIST_PROCESSING_EVENTS * EXPORTING * I_EVENT_NAME = 'TOP_OF_PAGE' * I_DYNDOC_ID = LR_HTML. "Dynamic Documents: Document * ENDIF. *----------------------------------------------------------------------* * Retrieve Field specifications and descriptions for ALV Grid *----------------------------------------------------------------------* CLEAR LT_FIELDCAT. REFRESH LT_FIELDCAT. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING I_BUFFER_ACTIVE = SPACE I_STRUCTURE_NAME = 'YPSTRUC_VEND_INTERACTIVE' CHANGING CT_FIELDCAT = LT_FIELDCAT. *----------------------------------------------------------------------* *This perform changes the text heading on the grid *----------------------------------------------------------------------* PERFORM GET_FEILDCAT_DESC1." TO CHANGE THE LIST HEADINGS LW_LAYOUT-SMALLTITLE = C_CHECK. "Default Grid title to small font LW_LAYOUT-ZEBRA = C_CHECK. "Output rows with alternating colors LW_LAYOUT-NO_AUTHOR = C_CHECK. "Allow users to enter global layouts LW_PRINT-PRNT_TITLE = C_CHECK. "Do not print out grid title LW_LAYOUT-CWIDTH_OPT = C_CHECK. "ALV control: Optimize column width LW_LAYOUT-SEL_MODE = SPACE. "ALV control: SelectionMode LW_LAYOUT-NO_F4 = C_CHECK. "Character Field Length 1 LW_VARIANT-REPORT = SY-REPID. "Program name LW_VARIANT-USERNAME = SY-UNAME. "User name ENDIF. *----------------------------------------------------------------------* *Display an output table in the ALV Grid Control instance. *----------------------------------------------------------------------* CALL METHOD LR_GRID->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING IS_LAYOUT = LW_LAYOUT "Layout IS_VARIANT = LW_VARIANT "Layout I_SAVE = C_ALL "Variable used to Save Layout IS_PRINT = LW_PRINT "Print settings for LVC CHANGING IT_FIELDCATALOG = LT_FIELDCAT "Fieldcatalog IT_OUTTAB = T_LFA1. "master internal table *----------------------------------------------------------------------* *Calls screen with container * *----------------------------------------------------------------------* CALL SCREEN 0200. ENDFORM. " display_data_grid *&---------------------------------------------------------------------* *& Form GET_FEILDCAT_DESC1 *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM GET_FEILDCAT_DESC1 . FIELD-SYMBOLS: <FS_L_FIELDCAT> TYPE LVC_S_FCAT. LOOP AT LT_FIELDCAT ASSIGNING <FS_L_FIELDCAT>. CASE <FS_L_FIELDCAT>-FIELDNAME . WHEN 'LIFNR'. <FS_L_FIELDCAT>-SCRTEXT_L = TEXT-005. <FS_L_FIELDCAT>-SCRTEXT_M = TEXT-005. <FS_L_FIELDCAT>-SCRTEXT_S = TEXT-005. <FS_L_FIELDCAT>-HOTSPOT = 'X'. <FS_L_FIELDCAT>-REPTEXT = TEXT-005. <FS_L_FIELDCAT>-EMPHASIZE = 'C310'. WHEN 'ORT01'. <FS_L_FIELDCAT>-SCRTEXT_L = TEXT-006. "country key <FS_L_FIELDCAT>-SCRTEXT_M = TEXT-006. <FS_L_FIELDCAT>-SCRTEXT_S = TEXT-006. <FS_L_FIELDCAT>-REPTEXT = TEXT-006. <FS_L_FIELDCAT>-EMPHASIZE = 'C310'. WHEN 'NAME1'. <FS_L_FIELDCAT>-SCRTEXT_L = TEXT-007. "Name <FS_L_FIELDCAT>-SCRTEXT_M = TEXT-007. <FS_L_FIELDCAT>-SCRTEXT_S = TEXT-007. <FS_L_FIELDCAT>-REPTEXT = TEXT-007. <FS_L_FIELDCAT>-EMPHASIZE = 'C310'. ENDCASE. ENDLOOP. ENDFORM. " GET_FEILDCAT_DESC1 *&---------------------------------------------------------------------* *& Module USER_COMMAND_OUTPUT1 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_OUTPUT1 OUTPUT. SET PF-STATUS 'ZSAMPLE' IMMEDIATELY. SET TITLEBAR 'ZSAMPLE'. ENDMODULE. " USER_COMMAND_OUTPUT1 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0200 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0200 INPUT. CASE SY-UCOMM. WHEN 'BACK'. SET SCREEN 0. LEAVE SCREEN. WHEN 'EXIT'. SET SCREEN 0. LEAVE SCREEN. WHEN 'CANCEL'. SET SCREEN 0. LEAVE SCREEN. ENDCASE. CLEAR SY-UCOMM. ENDMODULE. " USER_COMMAND_0200 INPUT More Abapers Questions: ABAP Books ListABAP/4 Certification, Programming and Object Oriented Programming Books Smart Forms
ABAP Menu:
Return to Index:-
(c) www.gotothings.com All material on this site is Copyright.
|