Code: Alles auswählen.
REPORT Z_ANU_TEST.
TABLES: MARA.
TYPES: BEGIN OF ALV_OUT_TABLE_T,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
ERNAM LIKE MARA-ERNAM,
LAEDA LIKE MARA-LAEDA,
END OF ALV_OUT_TABLE_T.
DATA: CTL_ALV_SCARR TYPE REF TO CL_GUI_ALV_GRID,
CTL_CCCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
FCT_SCARR2SPFLI TYPE LVC_T_FCAT,
T_ALV_OUT_TABLE TYPE TABLE OF ALV_OUT_TABLE_T,
OK_CODE LIKE SY-UCOMM.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
START-OF-SELECTION.
PERFORM FILL_ALV_TABLE CHANGING T_ALV_OUT_TABLE.
PERFORM CREATE_FCT_SCARR2SPFLI
CHANGING FCT_SCARR2SPFLI.
PERFORM TURN_OFF_COLS CHANGING FCT_SCARR2SPFLI.
PERFORM SET_FCT_SCARR2SPFLI CHANGING FCT_SCARR2SPFLI.
CALL SCREEN 100.
END-OF-SELECTION.
* ----------------------------------------------------------
* FORMS
* ----------------------------------------------------------
FORM SET_FCT_SCARR2SPFLI
CHANGING I_FCT_SCARR2SPFLI TYPE LVC_T_FCAT.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MATNR' 'COL_POS' 1 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MATNR' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'ERSDA' 'COL_POS' 2 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'ERSDA' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'ERNAM' 'COL_POS' 3 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'ERNAM' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'LAEDA' 'COL_POS' 4 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'LAEDA' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
ENDFORM. "set_fct_scarr2spfli
* ----------------------------------------------------------
FORM TURN_OFF_COLS
CHANGING I_FIELDCAT TYPE LVC_T_FCAT.
DATA: WA_FIELDCAT TYPE LVC_S_FCAT.
LOOP AT I_FIELDCAT INTO WA_FIELDCAT.
WA_FIELDCAT-TECH = 'X'.
MODIFY I_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
ENDLOOP.
ENDFORM. "turn_off_cols
* ----------------------------------------------------------
FORM CREATE_FCT_SCARR2SPFLI
CHANGING FCT_SCARR2SPFLI TYPE LVC_T_FCAT.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'MARA'
I_CLIENT_NEVER_DISPLAY = 'X'
CHANGING
CT_FIELDCAT = FCT_SCARR2SPFLI.
********************************************************************
* CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
* EXPORTING
* I_STRUCTURE_NAME = 'SCARR'
* I_CLIENT_NEVER_DISPLAY = 'X'
* CHANGING
* CT_FIELDCAT = FCT_SCARR2SPFLI.
ENDFORM. "create_fct_scarr2spfli
* ----------------------------------------------------------
FORM FILL_ALV_TABLE
CHANGING T_ALV_OUT_TABLE TYPE ANY TABLE.
* SELECT SC~CARRID SC~CARRNAME
* SP~CONNID SP~CITYFROM SP~CITYTO
* FROM ( SCARR AS SC INNER JOIN SPFLI AS SP
* ON SC~CARRID = SP~CARRID
* )
* INTO CORRESPONDING FIELDS OF TABLE T_ALV_OUT_TABLE
* ORDER BY SC~CARRID SP~CONNID.
SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE T_ALV_OUT_TABLE WHERE MATNR IN S_MATNR ORDER BY MATNR.
ENDFORM. "fill_alv_table
* ----------------------------------------------------------
FORM CUSTOMIZE_FIELDCATALOG
USING VALUE(I_COLNAME) TYPE LVC_FNAME
VALUE(I_MODFIELD) TYPE C
VALUE(I_MODVALUE) TYPE ANY
CHANGING I_FIELDCAT TYPE LVC_T_FCAT.
DATA: WA_FIELDCAT TYPE LVC_S_FCAT.
FIELD-SYMBOLS: <FS_MODFIELD> TYPE ANY.
ASSIGN: COMPONENT I_MODFIELD OF STRUCTURE
WA_FIELDCAT TO <FS_MODFIELD>.
READ TABLE I_FIELDCAT WITH KEY FIELDNAME = I_COLNAME
INTO WA_FIELDCAT.
<FS_MODFIELD> = I_MODVALUE.
MODIFY I_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
ENDFORM. "customize_fieldcatalog
* ----------------------------------------------------------
* MODULES
* ----------------------------------------------------------
MODULE INIT_CONTROLS OUTPUT.
IF CTL_CCCONTAINER IS INITIAL.
CREATE OBJECT CTL_CCCONTAINER
EXPORTING CONTAINER_NAME = 'CCCONTAINER'.
CREATE OBJECT CTL_ALV_SCARR
EXPORTING I_PARENT = CTL_CCCONTAINER.
CTL_ALV_SCARR->SET_TABLE_FOR_FIRST_DISPLAY(
CHANGING IT_OUTTAB = T_ALV_OUT_TABLE
IT_FIELDCATALOG = FCT_SCARR2SPFLI ).
ENDIF.
ENDMODULE. "init_controls OUTPUT
*----------------------------------------------------------------------*
* MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'TITEL'.
ENDMODULE. "status_0100 OUTPUT
*----------------------------------------------------------------------*
* MODULE handle_input INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE HANDLE_INPUT INPUT.
IF OK_CODE = 'EXIT'.
LEAVE PROGRAM.
ENDIF.
CLEAR OK_CODE.
ENDMODULE. "EXIT_PROGRAM
Code: Alles auswählen.
*&---------------------------------------------------------*
*& Report Z_BP_FIELD_CATALOG_01
*&---------------------------------------------------------*
REPORT Z_ANU_TEST.
TABLES: MARA, MARM.
TYPES: BEGIN OF ALV_OUT_TABLE_T,
MATNR LIKE MARA-MATNR,
MATKL LIKE MARA-MATKL,
MEINS LIKE MARA-MEINS,
UMREZ LIKE MARM-UMREZ,
MEINH LIKE MARM-MEINH,
HOEHE LIKE MARM-HOEHE,
UMREN LIKE MARM-UMREN,
END OF ALV_OUT_TABLE_T.
DATA: CTL_ALV_SCARR TYPE REF TO CL_GUI_ALV_GRID,
CTL_CCCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
FCT_SCARR2SPFLI TYPE LVC_T_FCAT,
T_ALV_OUT_TABLE TYPE TABLE OF ALV_OUT_TABLE_T,
OK_CODE LIKE SY-UCOMM.
SELECT-OPTIONS: S_MATNR FOR MARM-MATNR,
S_MATKL FOR MARA-MATKL.
START-OF-SELECTION.
PERFORM FILL_ALV_TABLE CHANGING T_ALV_OUT_TABLE.
PERFORM CREATE_FCT_SCARR2SPFLI
CHANGING FCT_SCARR2SPFLI.
PERFORM TURN_OFF_COLS CHANGING FCT_SCARR2SPFLI.
PERFORM SET_FCT_SCARR2SPFLI CHANGING FCT_SCARR2SPFLI.
CALL SCREEN 100.
END-OF-SELECTION.
* ----------------------------------------------------------
* FORMS
* ----------------------------------------------------------
FORM SET_FCT_SCARR2SPFLI
CHANGING I_FCT_SCARR2SPFLI TYPE LVC_T_FCAT.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MATNR' 'COL_POS' 1 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MATNR' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MATKL' 'COL_POS' 2 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MATKL' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MEINS' 'COL_POS' 3 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MEINS' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'UMREZ' 'COL_POS' 4 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'UMREZ' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MEINH' 'COL_POS' 5 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'MEINH' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'HOEHE' 'COL_POS' 6 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'HOEHE' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'UMREN' 'COL_POS' 7 CHANGING FCT_SCARR2SPFLI.
PERFORM CUSTOMIZE_FIELDCATALOG
USING 'UMREN' 'TECH' SPACE CHANGING FCT_SCARR2SPFLI.
ENDFORM. "set_fct_scarr2spfli
* ----------------------------------------------------------
FORM TURN_OFF_COLS
CHANGING I_FIELDCAT TYPE LVC_T_FCAT.
DATA: WA_FIELDCAT TYPE LVC_S_FCAT.
LOOP AT I_FIELDCAT INTO WA_FIELDCAT.
WA_FIELDCAT-TECH = 'X'.
MODIFY I_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
ENDLOOP.
ENDFORM. "turn_off_cols
* ----------------------------------------------------------
FORM CREATE_FCT_SCARR2SPFLI
CHANGING FCT_SCARR2SPFLI TYPE LVC_T_FCAT.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'MARA'
I_CLIENT_NEVER_DISPLAY = 'X'
CHANGING
CT_FIELDCAT = FCT_SCARR2SPFLI.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'MARM'
I_CLIENT_NEVER_DISPLAY = 'X'
CHANGING
CT_FIELDCAT = FCT_SCARR2SPFLI.
ENDFORM. "create_fct_scarr2spfli
* ----------------------------------------------------------
FORM FILL_ALV_TABLE
CHANGING T_ALV_OUT_TABLE TYPE ANY TABLE.
* SELECT SC~CARRID SC~CARRNAME
* SP~CONNID SP~CITYFROM SP~CITYTO
* FROM ( SCARR AS SC INNER JOIN SPFLI AS SP
* ON SC~CARRID = SP~CARRID
* )
* INTO CORRESPONDING FIELDS OF TABLE T_ALV_OUT_TABLE
* ORDER BY SC~CARRID SP~CONNID.
SELECT SP~MATNR
SP~MATKL
SP~MEINS
SC~UMREZ
SC~MEINH
SC~HOEHE
SC~UMREN
FROM ( MARA AS SP INNER JOIN MARM AS SC
ON SC~MATNR = SP~MATNR
)
INTO CORRESPONDING FIELDS OF TABLE T_ALV_OUT_TABLE
WHERE SP~MATNR IN S_MATNR
AND SP~MATKL IN S_MATKL
ORDER BY SP~MATNR.
ENDFORM. "fill_alv_table
* ----------------------------------------------------------
FORM CUSTOMIZE_FIELDCATALOG
USING VALUE(I_COLNAME) TYPE LVC_FNAME
VALUE(I_MODFIELD) TYPE C
VALUE(I_MODVALUE) TYPE ANY
CHANGING I_FIELDCAT TYPE LVC_T_FCAT.
DATA: WA_FIELDCAT TYPE LVC_S_FCAT.
FIELD-SYMBOLS: <FS_MODFIELD> TYPE ANY.
ASSIGN: COMPONENT I_MODFIELD OF STRUCTURE
WA_FIELDCAT TO <FS_MODFIELD>.
READ TABLE I_FIELDCAT WITH KEY FIELDNAME = I_COLNAME
INTO WA_FIELDCAT.
<FS_MODFIELD> = I_MODVALUE.
MODIFY I_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
ENDFORM. "customize_fieldcatalog
* ----------------------------------------------------------
* MODULES
* ----------------------------------------------------------
MODULE INIT_CONTROLS OUTPUT.
IF CTL_CCCONTAINER IS INITIAL.
CREATE OBJECT CTL_CCCONTAINER
EXPORTING CONTAINER_NAME = 'CCCONTAINER'.
CREATE OBJECT CTL_ALV_SCARR
EXPORTING I_PARENT = CTL_CCCONTAINER.
CTL_ALV_SCARR->SET_TABLE_FOR_FIRST_DISPLAY(
CHANGING IT_OUTTAB = T_ALV_OUT_TABLE
IT_FIELDCATALOG = FCT_SCARR2SPFLI ).
ENDIF.
ENDMODULE. "init_controls OUTPUT
*----------------------------------------------------------------------*
* MODULE status_0100 OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
ENDMODULE. "status_0100 OUTPUT
*----------------------------------------------------------------------*
* MODULE handle_input INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE HANDLE_INPUT INPUT.
IF OK_CODE = 'EXIT'.
LEAVE PROGRAM.
ENDIF.
CLEAR OK_CODE.
ENDMODULE. "handle_input INPUT