Skip to Content
author's profile photo Former Member
Former Member

I need some sample alvs using merge with help of multiple tables like ...

I need some sample alvs using merge with help of multiple tables like mara,marc,makt.

when to use fieldcatalog_merge and fieldcatalog.?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 03:02 PM
    REPORT Y_RK_MATERIAL_STOCK_INT_REPORT LINE-SIZE 180
    LINE-COUNT 25(5)
    NO STANDARD PAGE HEADING.
    
    
    *&---------------------------------------------------------------------*
    *& TABLE DECLARATION *
    *&---------------------------------------------------------------------*
    
    TABLES: MARA, "GENERAL MASTER DATA
    MARC, "PLANT DATA FOR MATERIAL
    MARD, "STORAGE LOCATION DATA FOR MATERIAL
    MBEW, "MATERIAL VALUATION
    MVKE, "SALES DATA FOR MATERIAL
    MAKT. "MATERIAL DESCRIPTION
    
    TYPE-POOLS : SLIS.
    
    DATA: VT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
    VT_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV.
    
    *&---------------------------------------------------------------------*
    *& INTERNAL TABLE DECLARATION *
    *&---------------------------------------------------------------------*
    
    
    DATA: BEGIN OF I_MARC OCCURS 0,
    MATNR LIKE MARC-MATNR,
    WERKS LIKE MARC-WERKS,
    LVORM LIKE MARC-LVORM,
    PSTAT LIKE MARC-PSTAT,
    END OF I_MARC.
    
    DATA: BEGIN OF I_MARA OCCURS 0,
    MATNR LIKE MARA-MATNR,
    MBRSH LIKE MARA-MBRSH,
    MEINS LIKE MARA-MEINS,
    END OF I_MARA.
    
    DATA: BEGIN OF I_MAKT OCCURS 0,
    MATNR LIKE MAKT-MATNR,
    MAKTX LIKE MAKT-MAKTX,
    END OF I_MAKT.
    
    DATA: BEGIN OF I_MBEW OCCURS 0,
    MATNR LIKE MBEW-MATNR,
    BWKEY LIKE MBEW-BWKEY,
    BWTAR LIKE MBEW-BWTAR,
    LBKUM LIKE MBEW-LBKUM,
    END OF I_MBEW.
    
    DATA: BEGIN OF I_MVKE OCCURS 0,
    MATNR LIKE MVKE-MATNR,
    VKORG LIKE MVKE-VKORG,
    VTWEG LIKE MVKE-VTWEG,
    END OF I_MVKE.
    
    DATA: BEGIN OF I_MARD OCCURS 0,
    MATNR LIKE MARD-MATNR,
    WERKS LIKE MARD-WERKS,
    LGORT LIKE MARD-LGORT,
    LABST LIKE MARD-LABST,
    END OF I_MARD.
    
    
    
    DATA: BEGIN OF I_OUT OCCURS 0,
    MATNR LIKE MARC-MATNR,
    WERKS LIKE MARC-WERKS,
    LVORM LIKE MARC-LVORM,
    PSTAT LIKE MARC-PSTAT,
    MBRSH LIKE MARA-MBRSH,
    MEINS LIKE MARA-MEINS,
    MAKTX LIKE MAKT-MAKTX,
    BWKEY LIKE MBEW-BWKEY,
    BWTAR LIKE MBEW-BWTAR,
    LBKUM LIKE MBEW-LBKUM,
    VKORG LIKE MVKE-VKORG,
    VTWEG LIKE MVKE-VTWEG,
    LGORT LIKE MARD-LGORT,
    LABST LIKE MARD-LABST,
    END OF I_OUT.
    
    
    *&---------------------------------------------------------------------*
    *& S E L E C T I O N - S C R E E N *
    *&---------------------------------------------------------------------*
    
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-101.
    PARAMETERS: P_WERKS LIKE MARC-WERKS.
    SELECTION-SCREEN END OF BLOCK B1.
    
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-102.
    SELECT-OPTIONS: S_MATNR FOR MARC-MATNR,
    S_LGORT FOR MARD-LGORT.
    SELECTION-SCREEN END OF BLOCK B2.
    
    
    *&-------------------------------------------------------------------*
    *& INITIALIZATION.
    *&-------------------------------------------------------------------*
    
    INITIALIZATION.
    
    P_WERKS = '3000'.
    
    S_MATNR-SIGN = 'I'.
    S_MATNR-OPTION = 'EQ'.
    S_MATNR-LOW = '1'.
    S_MATNR-HIGH = '995'.
    
    S_LGORT-SIGN = 'I'.
    S_LGORT-OPTION = 'EQ'.
    S_LGORT-LOW = '0001'.
    S_LGORT-HIGH = '0007'.
    
    APPEND S_LGORT.
    APPEND S_MATNR.
    CLEAR S_MATNR.
    CLEAR S_LGORT.
    
    
    *&---------------------------------------------------------------------*
    *& S T A R T - O F - S E L E C T I O N *
    *&---------------------------------------------------------------------*
    
    START-OF-SELECTION.
    
    SELECT MATNR WERKS LVORM FROM MARC
    INTO TABLE I_MARC
    WHERE WERKS = P_WERKS
    AND MATNR IN S_MATNR.
    
    SELECT MATNR MBRSH MEINS FROM MARA
    INTO TABLE I_MARA
    FOR ALL ENTRIES IN I_MARC
    WHERE MATNR = I_MARC-MATNR.
    
    SELECT MATNR MAKTX FROM MAKT
    INTO TABLE I_MAKT
    FOR ALL ENTRIES IN I_MARA
    WHERE MATNR = I_MARA-MATNR
    AND SPRAS = SY-LANGU.
    
    SELECT MATNR BWKEY BWTAR FROM MBEW
    INTO TABLE I_MBEW
    FOR ALL ENTRIES IN I_MARA
    WHERE MATNR = I_MARA-MATNR.
    
    SELECT MATNR VKORG VTWEG FROM MVKE
    INTO TABLE I_MVKE
    FOR ALL ENTRIES IN I_MARA
    WHERE MATNR = I_MARA-MATNR.
    
    SELECT MATNR WERKS LGORT LABST FROM MARD
    INTO TABLE I_MARD
    FOR ALL ENTRIES IN I_MARC
    WHERE MATNR = I_MARC-MATNR
    AND WERKS = P_WERKS
    AND LGORT IN S_LGORT..
    
    *&---------------------------------------------------------------------*
    *& MOVING DATA TO I-OUT *
    *&---------------------------------------------------------------------*
    
    
    LOOP AT I_MARC.
    
    MOVE I_MARC-MATNR TO I_OUT-MATNR.
    MOVE I_MARC-WERKS TO I_OUT-WERKS.
    MOVE I_MARC-LVORM TO I_OUT-LVORM.
    
    READ TABLE I_MARA WITH KEY MATNR = I_MARD-MATNR.
    MOVE I_MARA-MBRSH TO I_OUT-MBRSH.
    MOVE I_MARA-MEINS TO I_OUT-MEINS.
    
    READ TABLE I_MAKT WITH KEY MATNR = I_MARD-MATNR.
    MOVE I_MAKT-MAKTX TO I_OUT-MAKTX.
    
    READ TABLE I_MBEW WITH KEY MATNR = I_MARD-MATNR.
    MOVE I_MBEW-BWKEY TO I_OUT-BWKEY.
    MOVE I_MBEW-BWTAR TO I_OUT-BWTAR.
    
    READ TABLE I_MVKE WITH KEY MATNR = I_MARD-MATNR.
    MOVE I_MVKE-VKORG TO I_OUT-VKORG.
    MOVE I_MVKE-VTWEG TO I_OUT-VTWEG.
    
    LOOP AT I_MARD WHERE MATNR = I_MARC-MATNR
    AND WERKS = I_MARC-WERKS.
    
    MOVE I_MARD-LGORT TO I_OUT-LGORT.
    MOVE I_MARD-LABST TO I_OUT-LABST.
    
    APPEND I_OUT.
    ENDLOOP.
    
    CLEAR I_OUT.
    ENDLOOP.
    
    
    *&---------------------------------------------------------------------*
    *& E N D -- O F -- S E L E C T I O N *
    *&---------------------------------------------------------------------*
    END-OF-SELECTION.
    
    
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_program_name = sy-repid
    i_internal_tabname = 'I_OUT'
    i_client_never_display = 'X'
    i_inclname = sy-repid
    CHANGING
    ct_fieldcat = VT_FIELDCAT1.
    
    
    IF sy-subrc <> 0.
    ENDIF.
    
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_user_command = 'DISP_DETAIL'
    it_fieldcat = VT_FIELDCAT1
    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE1'
    TABLES
    t_outtab = I_OUT.
    
    IF sy-subrc <> 0.
    ENDIF.
    
    
    *&---------------------------------------------------------------------*
    *& F O R M D I S P_D E T A I L *
    *&---------------------------------------------------------------------*
    
    FORM disp_detail USING ucomm LIKE sy-ucomm
    selfield TYPE slis_selfield.
    
    IF selfield-fieldname = 'MATNR'.
    
    IF ucomm = '&IC1'.
    READ TABLE I_OUT INDEX selfield-tabindex.
    SELECT MATNR WERKS LGORT LABST
    FROM MARD
    INTO TABLE I_MARD
    WHERE MATNR = I_OUT-MATNR
    AND WERKS = P_WERKS.
    
    IF sy-subrc = 0.
    
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_program_name = sy-repid
    i_internal_tabname = 'I_MARD'
    i_client_never_display = 'X'
    i_inclname = sy-repid
    CHANGING
    ct_fieldcat = VT_FIELDCAT2.
    .
    IF sy-subrc <> 0.
    ENDIF.
    
    
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    it_fieldcat = VT_FIELDCAT2
    I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE2'
    TABLES
    t_outtab = I_MARD.
    
    ENDIF.
    
    ENDIF.
    
    ENDIF.
    
    ENDFORM. "DISP_DETAIL
    
    
    *&---------------------------------------------------------------------*
    *& E N D F O R M D I S P_D E T A I L *
    *&---------------------------------------------------------------------*
    
    
    
    *&---------------------------------------------------------------------*
    *& F O R M SET_PF_STATUS *
    *&---------------------------------------------------------------------*
    
    
    FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
    SET PF-STATUS 'SELECTION'.
    ENDFORM. "SET_PF_STATUS
    
    
    *&---------------------------------------------------------------------*
    *& E N D F O R M SET_PF_STATUS *
    *&---------------------------------------------------------------------*
    
    
    *&---------------------------------------------------------------------*
    *& F O R M USER_COMMAND *
    *&---------------------------------------------------------------------*
    
    
    FORM USER_COMMAND USING RK_UCOMM LIKE SY-UCOMM
    rs_selfield TYPE slis_selfield.
    
    CASE RK_UCOMM.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    ENDCASE.
    
    ENDFORM. "USER_COMMAND
    
    *&---------------------------------------------------------------------*
    *& E N D F O R M USER_COMMAND *
    *&---------------------------------------------------------------------*
    
    *&--------------------------------------------------------------------*
    *& Form TOP_OF_PAGE1
    *&--------------------------------------------------------------------*
    
    
    FORM TOP_OF_PAGE1.
    
    DATA: ILISTHEADER TYPE SLIS_T_LISTHEADER,
    WLISTHEADER TYPE SLIS_LISTHEADER.
    WLISTHEADER-TYP = 'A'.
    WLISTHEADER-INFO =
    'DOUBLE CLICK ON MATERIAL TO GET THE STORAGE LOCATION DETAILS'.
    
    APPEND WLISTHEADER TO ILISTHEADER.
    
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = ILISTHEADER.
    
    ENDFORM. " TOP_OF_PAGE1
    
    
    
    *&--------------------------------------------------------------------*
    *& Form TOP_OF_PAGE2
    *&--------------------------------------------------------------------*
    FORM TOP_OF_PAGE2.
    
    DATA: SLISTHEADER TYPE SLIS_T_LISTHEADER,
    WLISTHEADER TYPE SLIS_LISTHEADER.
    WLISTHEADER-TYP = 'S'.
    WLISTHEADER-INFO =
    'STOCK,STORAGE LOCATION DETAILS FOR A SELECTED PLANT'.
    APPEND WLISTHEADER TO SLISTHEADER.
    
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = SLISTHEADER.
    
    ENDFORM. " TOP_OF_PAGE2
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.