Design a screen with the custom control, name it as ALV_CONTAINER.
ZALV.
TABLES: zctp_ch_spare.
DATA tab type zctp_ch_spare occurs 0.
* declarations for Custom container
Data : container_r TYPE REF TO cl_gui_custom_container,
grid_r TYPE REF TO cl_gui_alv_grid.
Call screen 100.
MODULE status_0100 OUTPUT.
SELECT * FROM zctp_ch_spare INTO TABLE tab.
IF container_r IS INITIAL.
CREATE OBJECT container_r
EXPORTING
container_name = 'ALV_CONTAINER'. "Custom container name
CREATE OBJECT grid_r EXPORTING i_parent = container_r.
CALL METHOD grid_r->set_table_for_first_display
EXPORTING
i_structure_name = 'ZCTP_CH_SPARE' "DB table name
CHANGING
it_outtab = TAB "internal table name
.
ELSE.
CALL METHOD grid_r->refresh_table_display
EXPORTING
i_soft_refresh = 'X'.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
ALV in Screen painter with FIELDCATALOG.
code:
ZALV.
TABLES: zctp_ch_spare,zctp_spare_dt.
TYPES: BEGIN OF ty_tab,
f_vkorg TYPE zctp_ch_spare-f_vkorg,
f_mctype TYPE zctp_ch_spare-f_mctype,
quantity TYPE zctp_ch_spare-quantity,
slno TYPE zctp_spare_dt-slno,
s_date TYPE zctp_spare_dt-s_date,
END OF ty_tab.
DATA tab TYPE ty_tab OCCURS 0.
DATA: it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
Data :container_r TYPE REF TO cl_gui_custom_container,
grid_r TYPE REF TO cl_gui_alv_grid.
Call screen 100.
MODULE status_0100 OUTPUT.
SELECT a~f_vkorg a~f_mctype a~quantity b~slno b~s_date INTO CORRESPONDING FIELDS OF TABLE tab FROM zctp_ch_spare AS a INNER JOIN zctp_spare_dt AS b ON a~f_vkorg = b~vkorg.
sort tab by f_vkorg slno.
delete adjacent duplicates from tab comparing slno.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-fieldname = 'F_VKORG'.
wa_fieldcat-coltext = 10.
wa_fieldcat-seltext = 'SALES ORG.'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-fieldname = 'F_MCTYPE'.
wa_fieldcat-outputlen = 10.
wa_fieldcat-coltext = 'MACHINE'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-fieldname = 'QUANTITY'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'QUANTITY'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-fieldname = 'SLNO'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'SLNO'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-fieldname = 'S_DATE'.
wa_fieldcat-outputlen = 8.
wa_fieldcat-coltext = 'DATE'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
IF container_r IS INITIAL.
CREATE OBJECT container_r
EXPORTING container_name = 'PICTURE_CONTAINER'.
‘Custom container name’
CREATE OBJECT grid_r EXPORTING i_parent = container_r.
CALL METHOD grid_r->set_table_for_first_display
CHANGING
it_fieldcatalog = it_fieldcat “Fieldcatalog name
it_outtab = tab. “internal table name
ELSE.
CALL METHOD grid_r->refresh_table_display
EXPORTING
i_soft_refresh = 'X'.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
No comments:
Post a Comment