Professional Documents
Culture Documents
12:12 PM
1. At first create a report and create a custom screen (9000) without modifying the standard
one.
2. Go to Layout and then create the custom containers (here 2 is in our example).
3. Now create the PBO & PAI modules at the custom screen.
4. In PBO we are creating custom container, ALV grid & calling the ALV grid method along with
PF status & Title Bar.
5. In PAI the BACK, EXIT & CANCEL buttons are activated.
TABLES: mara.
"-Material Descriptions
TYPES: BEGIN OF ty_makt,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
END OF ty_makt.
DATA: wa_makt TYPE ty_makt,
it_makt TYPE TABLE OF ty_makt.
"-Output Table
TYPES: BEGIN OF ty_out,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
ersda TYPE mara-ersda,
mtart TYPE mara-mtart,
END OF ty_out.
DATA: wa_out TYPE ty_out,
it_fg TYPE TABLE OF ty_out, "-Finished Goods Table
it_rm TYPE TABLE OF ty_out. "-Raw Materials Table
"-Field Catalouge
DATA: wa_fcat TYPE lvc_s_fcat,
it_fcat TYPE TABLE OF lvc_s_fcat.
"-Layout
DATA: wa_lay_fg TYPE lvc_s_layo,
wa_lay_rm TYPE lvc_s_layo,
ok_code TYPE sy-ucomm.
INITIALIZATION.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS s_ersda FOR mara-ersda OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
IF sy-subrc = 0.
SORT it_mara BY matnr.
SELECT matnr maktx
FROM makt INTO TABLE it_makt
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr.
IF sy-subrc = 0.
SORT it_makt BY matnr.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD prepare_output.
IF it_mara IS NOT INITIAL.
LOOP AT it_mara INTO wa_mara.
READ TABLE it_makt INTO wa_makt
WITH KEY matnr = wa_mara-matnr
BINARY SEARCH.
IF sy-subrc = 0.
wa_out-maktx = wa_makt-maktx.
ENDIF.
wa_out-matnr = wa_mara-matnr.
wa_out-ersda = wa_mara-ersda.
wa_out-mtart = wa_mara-mtart.
IF wa_out-mtart = 'FERT'.
APPEND wa_out TO it_fg. "-Finished Goods Table
CLEAR: wa_out, wa_mara, wa_makt.
ELSE.
APPEND wa_out TO it_rm. "-Raw Materials Table
CLEAR: wa_out, wa_mara, wa_makt.
ENDIF.
ENDLOOP.
ENDIF.
FREE: it_mara, it_makt.
ENDMETHOD.
METHOD fieldcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'MAKTX'.
wa_fcat-reptext = 'Description'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'ERSDA'.
wa_fcat-reptext = 'Created On'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
lv_col = lv_col + 1.
wa_fcat-col_pos = lv_col.
wa_fcat-fieldname = 'MTART'.
wa_fcat-reptext = 'Material Type'.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
"-Creating Layout
wa_lay_fg-zebra = 'X'.
wa_lay_fg-cwidth_opt = 'X'.
wa_lay_fg-grid_title = 'Finished Goods Materials'.
wa_lay_rm-zebra = 'X'.
wa_lay_rm-cwidth_opt = 'X'.
wa_lay_rm-grid_title = 'Raw Materials'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: ob_material TYPE REF TO cl_material.
CREATE OBJECT ob_material.
CALL METHOD: ob_material->get_material,
ob_material->prepare_output,
ob_material->fieldcat.
CALL SCREEN 9000. "-Calling Custom Screen
*&--------------------------------------------------------------------
-*
*& Module STATUS_9000 OUTPUT
*&--------------------------------------------------------------------
-*
* PBO of 9000
*---------------------------------------------------------------------
-*
MODULE status_9000 OUTPUT.
SET PF-STATUS 'PF_9000'.
SET TITLEBAR 'MAT'.
PERFORM finished_goods_alv.
PERFORM raw_materials_alv.
ENDMODULE.
*&--------------------------------------------------------------------
-*
*& Module USER_COMMAND_9000 INPUT
*&--------------------------------------------------------------------
-*
* PAI of 9000
*---------------------------------------------------------------------
-*
MODULE user_command_9000 INPUT.
IF ok_code = 'BACK'
OR ok_code = 'EXIT'
OR ok_code = 'CANCEL'.
FREE: ob_cont_fg, ob_grid_fg, ob_cont_rm, ob_grid_rm,
it_fcat, it_fg, it_rm.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
*&--------------------------------------------------------------------
-*
*& Form FINISHED_GOODS_ALV
*&--------------------------------------------------------------------
-*
* ALV of FG
*---------------------------------------------------------------------
-*
FORM finished_goods_alv .
CREATE OBJECT ob_cont_fg
EXPORTING
container_name = 'CONT_FG'. "-Creating Container
"-In layout CONT_FG name is given