Icon ALV

mail@pastecode.io avatar
unknown
abap
3 years ago
1.4 kB
1
Indexable
Never
TABLES VBAP. SELECT-OPTIONS S_VBELN FOR VBAP-VBELN. TYPES: BEGIN OF TY_VBAP, VBELN TYPE VBAP-VBELN, KWMENG TYPE VBAP-KWMENG, MEINS TYPE VBAP-MEINS, NETWR TYPE VBAP-NETWR, ICON TYPE C, END OF TY_VBAP. DATA: WA_VBAP TYPE TY_VBAP, IT_VBAP TYPE TABLE OF TY_VBAP. DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV, WA_FCAT LIKE LINE OF IT_FCAT. DATA WA_LAYOUT TYPE SLIS_LAYOUT_ALV. SELECT VBELN KWMENG MEINS NETWR FROM VBAP INTO TABLE IT_VBAP WHERE VBELN IN S_VBELN. WA_FCAT-FIELDNAME = 'VBELN'. WA_FCAT-COL_POS = '1'. WA_FCAT-SELTEXT_M = 'SALES DOC NUM'. APPEND WA_FCAT TO IT_FCAT. CLEAR WA_FCAT. WA_FCAT-FIELDNAME = 'KWMENG'. WA_FCAT-COL_POS = '2'. WA_FCAT-SELTEXT_M = 'QUANTITY'. APPEND WA_FCAT TO IT_FCAT. CLEAR WA_FCAT. WA_FCAT-FIELDNAME = 'MEINS'. WA_FCAT-COL_POS = '3'. WA_FCAT-SELTEXT_M = 'UNITS'. APPEND WA_FCAT TO IT_FCAT. CLEAR WA_FCAT. WA_FCAT-FIELDNAME = 'NETWR'. WA_FCAT-COL_POS = '4'. WA_FCAT-SELTEXT_M = 'NET VALUE'. WA_FCAT-DO_SUM = 'X'. APPEND WA_FCAT TO IT_FCAT. CLEAR WA_FCAT. LOOP AT IT_VBAP INTO WA_VBAP. IF WA_VBAP-NETWR <= 500. WA_VBAP-ICON = 1. ELSEIF WA_VBAP-NETWR >= 501 AND WA_VBAP-NETWR <= 1000. WA_VBAP-ICON = 2. ELSE. WA_VBAP-ICON = 3. ENDIF. MODIFY IT_VBAP FROM WA_VBAP TRANSPORTING ICON. CLEAR WA_VBAP. ENDLOOP. WA_LAYOUT-LIGHTS_FIELDNAME = 'ICON'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = SY-CPROG IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = IT_FCAT TABLES T_OUTTAB = IT_VBAP.