*----------------------------------------------------------------*
* type-pools
*----------------------------------------------------------------*
TYPE-POOLS: icon.
*----------------------------------------------------------------*
* internal tables and container declarations
*----------------------------------------------------------------*
DATA: grid TYPE REF TO cl_gui_alv_grid,
CUST_CONT TYPE REF TO cl_gui_custom_container.
TYPES: BEGIN OF ty_vbap ,
vbeln LIKE vbap-vbeln,
matnr LIKE vbap-matnr,
posnr LIKE vbap-posnr,
kunnr LIKE vbak-kunnr,
kwmeng LIKE vbap-kwmeng,
id TYPE icon-id,
END OF ty_vbap.
DATA: it_vbap TYPE TABLE OF ty_vbap,
wa_vbap TYPE ty_vbap,
it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
*----------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------*
START-OF-SELECTION.
perform get_data .
perform insert_icon .
perform build_fieldcat .
*--calling a screen to display the data
CALL SCREEN 111.
*&---------------------------------------------------------------------*
*& Module STATUS_0111 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0111 OUTPUT.
SET PF-STATUS 'TEST'.
SET TITLEBAR 'TEST'.
ENDMODULE. " STATUS_0111 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0111 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0111 INPUT.
CASE: SY-UCOMM .
WHEN 'BACK'.
LEAVE TO SCREEN 0 .
ENDCASE .
ENDMODULE. " USER_COMMAND_0111 INPUT
*&---------------------------------------------------------------------*
*& Module FILL_DATA OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE FILL_DATA OUTPUT.
*---create a custom container
CREATE OBJECT CUST_CONT
EXPORTING
CONTAINER_NAME = 'CUST_CONT' .
CREATE OBJECT GRID
EXPORTING
I_PARENT = CUST_CONT .
*----display the data through custom container
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = it_vbap
IT_FIELDCATALOG = it_fieldcat .
ENDMODULE. " FILL_DATA OUTPUT
*&---------------------------------------------------------------------*
*& Form get_data
*----------------------------------------------------------------------*
FORM get_data .
SELECT vbak~vbeln
vbak~kunnr
vbap~posnr
vbap~matnr
vbap~kwmeng
INTO CORRESPONDING FIELDS OF TABLE it_vbap
FROM vbak JOIN vbap
ON vbak~vbeln = vbap~vbeln
UP TO 20 ROWS.
SORT it_vbap BY matnr.
DELETE it_vbap WHERE matnr IS INITIAL.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form insert_icon
*----------------------------------------------------------------------*
FORM insert_icon .
LOOP AT it_vbap INTO wa_vbap.
wa_vbap-id = '@08@'. " icon green light
MODIFY it_vbap FROM wa_vbap.
ENDLOOP.
ENDFORM. " insert_icon
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*----------------------------------------------------------------------*
FORM build_fieldcat .
wa_fieldcat-fieldname = 'ID'.
wa_fieldcat-coltext = 'Icon'.
wa_fieldcat-icon = 'X'. "This is important
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-coltext = 'MATNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'KUNNR'.
wa_fieldcat-coltext = 'KUNNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'VBELN'.
wa_fieldcat-coltext = 'VBELN'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'POSNR'.
wa_fieldcat-coltext = 'POSNR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'KWMENG'.
wa_fieldcat-coltext = 'KWMENG'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " build_fieldcat
ALSO READ:
- ALV Report With User Defined Buttons In It's Toolbar.
- ALV Report Program - Colors- Using REUSE_ALV_GRID_DISPLAY_LVC.
- Displaying Percentage In ALV List / Grid Display.
- Handling An ALV Grid With Check Box Using A Method.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
No comments:
Post a Comment