Tuesday, July 23, 2013
REPORT ZALV_LIST_PROGRAM. *&---------------------------------------------------------------------* *& Declaration part *&---------------------------------------------------------------------* "Types TYPES: BEGIN OF T__DATA, MATNR TYPE MARD-MATNR, WERKS TYPE MARD-WERKS, LGORT TYPE MARD-LGORT, END OF T__DATA. "Work Areas DATA:W__DATA TYPE T__DATA. "Internal tables DATA:I__DATA TYPE STANDARD TABLE OF T__DATA. *&---------------------------------------------------------------------* * ALV Declarations *----------------------------------------------------------------------* * Types Pools TYPE-POOLS: SLIS. * Types TYPES: T_FIELDCAT TYPE SLIS_FIELDCAT_ALV, T_EVENTS TYPE SLIS_ALV_EVENT, T_LAYOUT TYPE SLIS_LAYOUT_ALV. * Workareas DATA: W_FIELDCAT TYPE T_FIELDCAT, W_EVENTS TYPE T_EVENTS, W_LAYOUT TYPE T_LAYOUT. * Internal Tables DATA: I_FIELDCAT TYPE STANDARD TABLE OF T_FIELDCAT, I_EVENTS TYPE STANDARD TABLE OF T_EVENTS. *&---------------------------------------------------------------------* *& start of selection *&---------------------------------------------------------------------* START-OF-SELECTION. PERFORM GET_DATA. *&---------------------------------------------------------------------* *& end-of-selection. *&---------------------------------------------------------------------* END-OF-SELECTION. PERFORM BUILD_FIELDCATLOG. PERFORM BUILD_LAYOUT. PERFORM LIST_DISPLAY. *&---------------------------------------------------------------------* *& Form get_data *&---------------------------------------------------------------------* FORM GET_DATA . SELECT MATNR WERKS LGORT FROM MARD INTO CORRESPONDING FIELDS OF TABLE I__DATA UP TO 10 ROWS. IF I__DATA[] IS INITIAL. "Dummy data DO 10 TIMES. W__DATA-MATNR = SY-INDEX. W__DATA-WERKS = SY-INDEX + 1. W__DATA-LGORT = SY-INDEX + 2. APPEND W__DATA TO I__DATA. CLEAR W__DATA. ENDDO. ENDIF. ENDFORM. " get_data *&---------------------------------------------------------------------* *& Form build_fieldcatlog *&---------------------------------------------------------------------* FORM BUILD_FIELDCATLOG . CLEAR:W_FIELDCAT,I_FIELDCAT[]. W_FIELDCAT-FIELDNAME = 'MATNR'. W_FIELDCAT-SELTEXT_M = 'MATNR'. APPEND W_FIELDCAT TO I_FIELDCAT. CLEAR W_FIELDCAT. W_FIELDCAT-FIELDNAME = 'WERKS'. W_FIELDCAT-SELTEXT_M = 'WERKS'. APPEND W_FIELDCAT TO I_FIELDCAT. CLEAR W_FIELDCAT. W_FIELDCAT-FIELDNAME = 'LGORT'. W_FIELDCAT-SELTEXT_M = 'LGORT'. APPEND W_FIELDCAT TO I_FIELDCAT. CLEAR W_FIELDCAT. ENDFORM. " build_fieldcatlog *&---------------------------------------------------------------------* *& Form build_layout *&---------------------------------------------------------------------* FORM BUILD_LAYOUT . W_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. W_LAYOUT-ZEBRA = 'X'. ENDFORM. " build_layout *&---------------------------------------------------------------------* *& Form list_display *&---------------------------------------------------------------------* FORM LIST_DISPLAY . DATA: L_PROGRAM TYPE SY-REPID. L_PROGRAM = SY-REPID. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = L_PROGRAM IS_LAYOUT = W_LAYOUT IT_FIELDCAT = I_FIELDCAT TABLES T_OUTTAB = I__DATA 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. ENDFORM. " list_display
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Step by step tutorial on Smart Forms - Template Node
- ABAP - Sending email with pdf attachment
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
0 comments:
Post a Comment
Your useful comments, suggestions are appreciated.Your comments are moderated.