&---------------------------------------------------------------------
*& Module STATUS_3005 OUTPUT
&---------------------------------------------------------------------
----------------------------------------------------------------------
MODULE STATUS_3005 OUTPUT.
DATA: LR_DYN_TABLE TYPE REF TO DATA,
LR_WA_DYN_TABLE TYPE REF TO DATA,
LR_DOCK_CTNR TYPE REF TO CL_GUI_DOCKING_CONTAINER,
LR_ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,
IT_FIELDCAT1 TYPE LVC_T_FCAT, "with cell color
IT_FIELDCAT2 TYPE LVC_T_FCAT, "without cell color
WA_FIELDCAT1 LIKE LINE OF IT_FIELDCAT1,
WA_CELLCOLORS TYPE LINE OF LVC_T_SCOL,
WA_IS_LAYOUT TYPE LVC_S_LAYO.
FIELD-SYMBOLS:<IT_DYN_TABLE> TYPE STANDARD TABLE,
<WA_DYN_TABLE> TYPE ANY,
<IT_CELLCOLORS> TYPE LVC_T_SCOL,
<W_FIELD> TYPE ANY.
SET PF-STATUS 'ZTOOL'.
BREAK-POINT.
IF LR_DOCK_CTNR IS INITIAL.
PERFORM BUILD_FIELDCATALOG1 USING 'VBELN' 'LIPS' 'C' '10' 'Delivery No' 'Delivery No'.
PERFORM BUILD_FIELDCATALOG1 USING 'POSNR' 'LIPS' 'N' '6' 'Item No' 'Item No'.
PERFORM BUILD_FIELDCATALOG1 USING 'MATNR' 'LIPS' 'C' '18' 'Material No' 'Material No'.
PERFORM BUILD_FIELDCATALOG1 USING 'MATKL' 'LIPS' 'C' '9' 'Material Group' 'Material Group'.
PERFORM BUILD_FIELDCATALOG1 USING 'VKORG' 'LIKP' 'C' '4' 'Sales org' 'Sales org'.
PERFORM BUILD_FIELDCATALOG1 USING 'WERKS' 'LIPS' 'C' '4' 'Plant' 'Plant'.
PERFORM BUILD_FIELDCATALOG1 USING 'LGORT' 'LIPS' 'C' '4' 'STOR Loc' 'STOR Loc'.
PERFORM BUILD_FIELDCATALOG1 USING 'WADAT' 'LIKP' 'D' '8' 'Planned Goods movement date' 'Planned Goods movement date'.
PERFORM BUILD_FIELDCATALOG1 USING 'LFIMG' 'LIPS' 'C' '17' 'Delivered Qty' 'Delivered Qty'.
PERFORM BUILD_FIELDCATALOG1 USING 'MEINS' 'LIPS' 'C' '3' 'Unit of Measure' 'Unit of Measure'.
PERFORM BUILD_FIELDCATALOG1 USING 'NETPR' 'LIPS' 'C' '16' 'Net Price' 'Net Price'.
IT_FIELDCAT2
] = IT_FIELDCAT1[.
WA_FIELDCAT1-FIELDNAME = 'T_CELLCOLORS'.
WA_FIELDCAT1-REF_FIELD = 'COLTAB'.
WA_FIELDCAT1-REF_TABLE = 'CALENDAR_TYPE'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCAT1
IMPORTING
EP_TABLE = LR_DYN_TABLE
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 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.
ASSIGN LR_DYN_TABLE->* TO <IT_DYN_TABLE>.
CREATE DATA LR_WA_DYN_TABLE LIKE LINE OF <IT_DYN_TABLE>.
ASSIGN LR_WA_DYN_TABLE->* TO <WA_DYN_TABLE>.
LOOP AT IG_LIPS INTO WG_LIPS.
READ TABLE IG_LIKP INTO WG_LIKP WITH KEY VBELN = WG_LIPS-VBELN.
ASSIGN COMPONENT 'VBELN' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-VBELN.
ASSIGN COMPONENT 'POSNR' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-POSNR.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-MATNR.
ASSIGN COMPONENT 'MATKL' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-MATKL.
ASSIGN COMPONENT 'VKORG' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIKP-VKORG.
ASSIGN COMPONENT 'WERKS' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-WERKS.
ASSIGN COMPONENT 'LGORT' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-LGORT.
ASSIGN COMPONENT 'WADAT' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIKP-WADAT.
ASSIGN COMPONENT 'LFIMG' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-LFIMG.
ASSIGN COMPONENT 'MEINS' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-MEINS.
ASSIGN COMPONENT 'NETPR' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
<W_FIELD> = WG_LIPS-NETPR.
APPEND <WA_DYN_TABLE> TO <IT_DYN_TABLE>.
ENDLOOP.
- Color cells based on your criteria. In this example, a test on
- FIELD2 is used to decide on color.
LOOP AT <IT_DYN_TABLE> INTO <WA_DYN_TABLE>.
ASSIGN COMPONENT 'POSNR' OF STRUCTURE <WA_DYN_TABLE> TO <W_FIELD>.
- Get access to internal table used to color cells.
ASSIGN COMPONENT 'T_CELLCOLORS' OF STRUCTURE <WA_DYN_TABLE> TO <IT_CELLCOLORS>.
CLEAR WA_CELLCOLORS.
WA_CELLCOLORS-FNAME = 'POSNR'.
IF <W_FIELD> = '000010'.
WA_CELLCOLORS-COLOR-COL = '7'.
ELSE.
WA_CELLCOLORS-COLOR-COL = '5'.
ENDIF.
APPEND WA_CELLCOLORS TO <IT_CELLCOLORS>.
MODIFY <IT_DYN_TABLE> FROM <WA_DYN_TABLE>.
ENDLOOP.
CREATE OBJECT LR_DOCK_CTNR
EXPORTING
SIDE = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_LEFT
RATIO = '95'.
CREATE OBJECT LR_ALV_GRID
EXPORTING I_PARENT = LR_DOCK_CTNR.
- Set ALV controls for cell coloring table.
WA_IS_LAYOUT-CTAB_FNAME = 'T_CELLCOLORS'.
CALL METHOD LR_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = WA_IS_LAYOUT
CHANGING
IT_OUTTAB = <IT_DYN_TABLE>
IT_FIELDCATALOG = IT_FIELDCAT2.
ELSE. "grid already prepared
CALL METHOD LR_ALV_GRID->REFRESH_TABLE_DISPLAY
EXPORTING
I_SOFT_REFRESH = ' '
EXCEPTIONS
FINISHED = 1
OTHERS = 2.
ENDIF.
ENDMODULE. " STATUS_3005 OUTPUT
&---------------------------------------------------------------------
*& Module USER_COMMAND_3005 INPUT
&---------------------------------------------------------------------
----------------------------------------------------------------------
MODULE USER_COMMAND_3005 INPUT.
BREAK-POINT.
CASE G_OK_CODE.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_3005 INPUT
FORM BUILD_FIELDCATALOG1 USING FP_FNAME FP_TNAME FP_DTYPE FP_LEN FP_CTEXT FP_STEXT.
DATA: WA_FIELDCAT1 LIKE LINE OF IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-FIELDNAME = FP_FNAME.
WA_FIELDCAT1-TABNAME = FP_TNAME.
WA_FIELDCAT1-INTTYPE = FP_DTYPE.
WA_FIELDCAT1-OUTPUTLEN = FP_LEN.
WA_FIELDCAT1-COLTEXT = FP_CTEXT.
WA_FIELDCAT1-SELTEXT = FP_STEXT.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
ENDFORM. " BUILD_FIELDCATALOG1