*&--------------------------------------------------------------------- * * PROGRAM NAME : ZCOE_ALV_BLOCKED * * TITLE : Blocled alv report for material information * * AUTHOR : Naveen * Jayan * Fareeduddin * CREATE

DATE : 15/12/2008 * * PURPOSE : This is a blocked alv report displays material infor * * mation regarding description,plant,storeloc * * * I/N PARAMETERS: Material num * * O/P PARAMETERS: N/A * * SAP TABLES : MARA,MAKT,MARD * * * * T code : ZALV_BLOCKED * *-----------------------------------------------------------------------* *MODIFICATION LOG * *-----------------------------------------------------------------------* * Development Request Number : * * Date of Change : 30/12/2008 * * ABAP Developer Name : ECIK901005 * * Description of Change : Initial Development * *-----------------------------------------------------------------------* REPORT ZCOE_ALV_BLOCKED NO STANDARD PAGE HEADING LINE-SIZE 255 LINE-COUNT 20(3). * tables involved in this program TABLES: MARA, MAKT, MARD. *provide type-pools TYPE-POOLS: SLIS. *Selection-screen details *&--------------------------------------------------------------------* *& SELECTION-SCREEN *&--------------------------------------------------------------------* SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY. "Material num SELECTION-SCREEN: END OF BLOCK B1. *&--------------------------------------------------------------------* *& TYPES DECLARATION *&--------------------------------------------------------------------* *Declaring types for MARA. TYPES : BEGIN OF T_MARA, MATNR TYPE MATNR, "Material num ERSDA TYPE ERSDA, "Created on ERNAM TYPE ERNAM, "Name of person who created LAEDA TYPE LAEDA, "Date of last change END OF T_MARA. *Declaring types for MAKT. TYPES :BEGIN OF T_MAKT, MATNR TYPE MATNR, "Material num MAKTX TYPE MAKTX, "Material Description (Short Text) MAKTG TYPE MAKTG, "Material description in upper case for matchcodes END OF T_MAKT. *Declaring types for MARD. TYPES : BEGIN OF T_MARD, MATNR TYPE MATNR, "Material num WERKS TYPE WERKS_D, "Plant det LGORT TYPE LGORT_D, "Storage Location END OF T_MARD. *&--------------------------------------------------------------------* *& DECLARING VARIABLES,INTERNAL TABLES & WORK AREAS *&--------------------------------------------------------------------*

" For events *Calling the function module to initialize block list output CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT' EXPORTING I_CALLBACK_PROGRAM = V_REPID. "Internal table for events(MARA) WA_EVENTS TYPE SLIS_ALV_EVENT. "Layout for blocks I_EVENTS TYPE SLIS_T_EVENT.DATA: V_REPID TYPE SY-REPID. "Work area for events(MAKT) I_EVENTS2 TYPE SLIS_T_EVENT. PERFORM FIELD_CAT. "Internal table for events(MARD) WA_EVENTS2 TYPE SLIS_ALV_EVENT. "Work area for mara WA_MAKT TYPE MAKT. ENDIF. "Work area for events(MARD) *&--------------------------------------------------------------------* *& INITIALIZATION *&--------------------------------------------------------------------* INITIALIZATION. IF SY-SUBRC NE 0. "Internal table for makt I_MARD TYPE TABLE OF T_MARD. "Internal table for events(MAKT) WA_EVENTS1 TYPE SLIS_ALV_EVENT. MESSAGE TEXT-004 TYPE 'E'. "Work area for field catalog makt WA_MARD_FIELD TYPE SLIS_FIELDCAT_ALV. SELECT SINGLE MATNR FROM MARA INTO V_MATNR WHERE MATNR IN S_MATNR. "Work area for field catalog mara WA_MAKT_FIELD TYPE SLIS_FIELDCAT_ALV. *&--------------------------------------------------------------------* *& START-OF-SELECTION *&--------------------------------------------------------------------* START-OF-SELECTION. *Calling the function module to append block mara CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND' EXPORTING IS_LAYOUT = I_LAYOUT IT_FIELDCAT = I_MARA_FIELD[] I_TABNAME = 'MARA' IT_EVENTS = I_EVENTS[] TABLES T_OUTTAB = I_MARA EXCEPTIONS PROGRAM_ERROR =1 MAXIMUM_OF_APPENDS_REACHED = 2 . "Work area for field catalog mard WA_MARA TYPE MARA. * Fetching final data for blocks PERFORM SELECT_DATA. "varible for passing report name in FM. "Work area for makt WA_MARD TYPE MARD. "For validating matnr WA_MARA_FIELD TYPE SLIS_FIELDCAT_ALV. "Internal table for fieldcatalog makt I_MARD_FIELD TYPE SLIS_T_FIELDCAT_ALV. "Internal table for fieldcatalog mard I_MARA TYPE TABLE OF T_MARA. "Internal table for fieldcatalog mara I_MAKT_FIELD TYPE SLIS_T_FIELDCAT_ALV. "Work area for mard I_MARA_FIELD TYPE SLIS_T_FIELDCAT_ALV. "Internal table for mard I_LAYOUT TYPE SLIS_LAYOUT_ALV. "Internal table for mara I_MAKT TYPE TABLE OF T_MAKT. V_REPID = SY-REPID. *&--------------------------------------------------------------------* *& AT SELECTION SCREEN *&--------------------------------------------------------------------* * Validatingj material num at selection-screen AT SELECTION-SCREEN. " For fieldcatalog PERFORM EVENTS_TOP. "Work area for events(MARA) I_EVENTS1 TYPE SLIS_T_EVENT. V_MATNR TYPE MATNR.

"TOP_PAGE2 *&---------------------------------------------------------------------* *& Form FIELD_CAT *&---------------------------------------------------------------------* * Preparing fields which we want to display in blocks *----------------------------------------------------------------------* FORM FIELD_CAT . "TOP_PAGE * Heading for block makt FORM TOP_PAGE1. *&--------------------------------------------------------------------* *& Form TOP_PAGE *&--------------------------------------------------------------------* * Providing heading for each block *---------------------------------------------------------------------* * Heading for block mara FORM TOP_PAGE. *Calling the function module to append block mard CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND' EXPORTING IS_LAYOUT = I_LAYOUT IT_FIELDCAT = I_MAKT_FIELD I_TABNAME = 'MAKT' IT_EVENTS = I_EVENTS1[] TABLES T_OUTTAB = I_MAKT EXCEPTIONS PROGRAM_ERROR =1 MAXIMUM_OF_APPENDS_REACHED = 2 OTHERS = 3. "TOP_PAGE1 * Heading for block mard FORM TOP_PAGE2. WRITE:/ 'BLOCK FOR MARA' COLOR 7. *Calling the function module to append block mard CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND' EXPORTING IS_LAYOUT = I_LAYOUT IT_FIELDCAT = I_MARD_FIELD I_TABNAME = 'MARD' IT_EVENTS = I_EVENTS2[] TABLES T_OUTTAB = I_MARD EXCEPTIONS PROGRAM_ERROR =1 MAXIMUM_OF_APPENDS_REACHED = 2 OTHERS = 3. ENDFORM. WRITE:/ 'BLOCK FOR MARD' COLOR 5. ENDFORM. WA_MARA_FIELD-FIELDNAME = 'ERSDA'. **Calling the function module to display blocks CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'. WA_MARA_FIELD-REF_TABNAME = 'MARA'. WRITE:/ 'BLOCK MAKT' COLOR 4. . APPEND WA_MARA_FIELD TO I_MARA_FIELD. * Preparing fieldcatalog for field created on WA_MARA_FIELD-COL_POS = 2.OTHERS = 3. CLEAR WA_MARA_FIELD. ENDFORM. WA_MARA_FIELD-FIELDNAME = 'MATNR'. * Preparing fieldcatalog for field material num WA_MARA_FIELD-COL_POS = 1.

makt. * Preparing fieldcatalog for field name of person created obj WA_MARA_FIELD-COL_POS = 3. * Preparing fieldcatalog for field material num WA_MAKT_FIELD-COL_POS = '1'. WA_MARD_FIELD-REF_TABNAME = 'MARD'. WA_MARD_FIELD-REF_TABNAME = 'MARD'. APPEND WA_MARD_FIELD TO I_MARD_FIELD. APPEND WA_MARA_FIELD TO I_MARA_FIELD. * Preparing fieldcatalog for field Material description in upper case for matchcodes WA_MAKT_FIELD-COL_POS = 3. ENDFORM. CLEAR WA_MARD_FIELD. WA_MAKT_FIELD-FIELDNAME = 'MAKTG'. CLEAR WA_MARA_FIELD. APPEND WA_MARD_FIELD TO I_MARD_FIELD. CLEAR WA_MAKT_FIELD. WA_MARD_FIELD-FIELDNAME = 'MATNR'. * Preparing fieldcatalog for field material des WA_MAKT_FIELD-COL_POS = 2. * Preparing fieldcatalog for field date of last change WA_MARA_FIELD-COL_POS = 4. WA_MARA_FIELD-FIELDNAME = 'LAEDA'. CLEAR WA_MARA_FIELD. WA_MAKT_FIELD-FIELDNAME = 'MAKTX'. CLEAR WA_MARA_FIELD. APPEND WA_MAKT_FIELD TO I_MAKT_FIELD.mard) based on selection-screen * material numbers *----------------------------------------------------------------------* FORM SELECT_DATA . WA_MARA_FIELD-FIELDNAME = 'ERNAM'. WA_MAKT_FIELD-REF_TABNAME = 'MAKT'. APPEND WA_MARA_FIELD TO I_MARA_FIELD. " FIELD_CAT *&---------------------------------------------------------------------* *& Form SELECT_DATA *&---------------------------------------------------------------------* * Fetching data from three tables(mara. APPEND WA_MAKT_FIELD TO I_MAKT_FIELD. APPEND WA_MARA_FIELD TO I_MARA_FIELD. CLEAR WA_MAKT_FIELD. WA_MAKT_FIELD-REF_TABNAME = 'MAKT'. APPEND WA_MAKT_FIELD TO I_MAKT_FIELD.WA_MARA_FIELD-REF_TABNAME = 'MARA'. * Preparing fieldcatalog for field Material num WA_MARD_FIELD-COL_POS = 1. * Fetching data from mara table SELECT MATNR . APPEND WA_MARD_FIELD TO I_MARD_FIELD. WA_MAKT_FIELD-FIELDNAME = 'MATNR'. CLEAR WA_MARD_FIELD. WA_MAKT_FIELD-REF_TABNAME = 'MAKT'. WA_MARD_FIELD-REF_TABNAME = 'MARD'. CLEAR WA_MAKT_FIELD. * Preparing fieldcatalog for field Plant WA_MARD_FIELD-COL_POS = 2. WA_MARD_FIELD-FIELDNAME = 'LGORT'. WA_MARD_FIELD-FIELDNAME = 'WERKS'. WA_MARA_FIELD-REF_TABNAME = 'MARA'. WA_MARA_FIELD-REF_TABNAME = 'MARA'. * Preparing fieldcatalog for field storage loc WA_MARD_FIELD-COL_POS = 3. CLEAR WA_MARD_FIELD.

* block makt WA_EVENTS1-FORM = 'TOP_PAGE1'. " EVENTS_TOP .ERSDA ERNAM LAEDA FROM MARA INTO TABLE I_MARA WHERE MATNR IN S_MATNR. * block mard WA_EVENTS2-FORM = 'TOP_PAGE2'. ENDFORM. ENDFORM. WA_EVENTS1-NAME = 'TOP_OF_PAGE'. WA_EVENTS2-NAME = 'TOP_OF_PAGE'. * Fetching data from mard table SELECT MATNR WERKS LGORT FROM MARD INTO TABLE I_MARD WHERE MATNR IN S_MATNR. APPEND WA_EVENTS TO I_EVENTS. WA_EVENTS-NAME = 'TOP_OF_PAGE'. " SELECT_DATA *&---------------------------------------------------------------------* *& Form EVENTS_TOP *&---------------------------------------------------------------------* * Preparing events for top-of-page for each block *----------------------------------------------------------------------* FORM EVENTS_TOP . APPEND WA_EVENTS2 TO I_EVENTS2. APPEND WA_EVENTS1 TO I_EVENTS1. * Fetching data from makt table SELECT MATNR MAKTX MAKTG FROM MAKT INTO TABLE I_MAKT WHERE MATNR IN S_MATNR. * block mara WA_EVENTS-FORM = 'TOP_PAGE'.