In the following example we are creating a module pool program
where a Modal dialog box will be implemented. There is a selection screen with
select option for creation date of materials. There are radio buttons of Raw
materials and finished good materials. We can enter date range here and select
the material type radio button and click on the display button. Now it will
open a pop up screen where a table control will display the required list of
materials.
1) At
first we created the module pool program. Four includes will be there as
follows.
INCLUDE zsr_top . " global Data
INCLUDE zsr_o01 . " PBO-Modules
INCLUDE zsr_i01 . " PAI-Modules
INCLUDE zsr_f01 . " FORM-Routines
INCLUDE zsr_o01 . " PBO-Modules
INCLUDE zsr_i01 . " PAI-Modules
INCLUDE zsr_f01 . " FORM-Routines
2) Create
the top include where all data & table declarations are there.
PROGRAM sapmzsr_test.
TABLES: mara.
DATA: ok_9000 TYPE sy-ucomm,
ok_9001 TYPE sy-ucomm,
roh TYPE c VALUE 'X',
fert TYPE c.
TYPES: BEGIN OF ty_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
meins TYPE mara-meins,
END OF ty_mara.
DATA: wa_mara TYPE ty_mara,
it_mara TYPE TABLE OF ty_mara.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECT-OPTIONS s_date FOR mara-ersda.
SELECTION-SCREEN END OF SCREEN 100.
CONTROLS: tabc TYPE TABLEVIEW USING SCREEN 9001.
TABLES: mara.
DATA: ok_9000 TYPE sy-ucomm,
ok_9001 TYPE sy-ucomm,
roh TYPE c VALUE 'X',
fert TYPE c.
TYPES: BEGIN OF ty_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
meins TYPE mara-meins,
END OF ty_mara.
DATA: wa_mara TYPE ty_mara,
it_mara TYPE TABLE OF ty_mara.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECT-OPTIONS s_date FOR mara-ersda.
SELECTION-SCREEN END OF SCREEN 100.
CONTROLS: tabc TYPE TABLEVIEW USING SCREEN 9001.
3) Now
create the screens where the modal dialog box will be selected. Since we are implementing
select option, a default 100 number of screen will be created. Hence there will
be three screens: sub screen for select option, calling screen 9000 and modal
dialog box 9001.
PROCESS BEFORE OUTPUT.
MODULE status_9000.
CALL SUBSCREEN sel INCLUDING sy-repid '100'.
PROCESS AFTER INPUT.
CALL SUBSCREEN sel.
MODULE user_command_9000.
MODULE status_9000.
CALL SUBSCREEN sel INCLUDING sy-repid '100'.
PROCESS AFTER INPUT.
CALL SUBSCREEN sel.
MODULE user_command_9000.
__________________________________________________________________________
PROCESS BEFORE OUTPUT.
MODULE status_9001.
LOOP AT it_mara INTO wa_mara WITH CONTROL tabc.
MODULE tabc_modal.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT it_mara.
MODULE tabc_modify_modal.
ENDLOOP.
MODULE user_command_9001.
MODULE status_9001.
LOOP AT it_mara INTO wa_mara WITH CONTROL tabc.
MODULE tabc_modal.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT it_mara.
MODULE tabc_modify_modal.
ENDLOOP.
MODULE user_command_9001.
4) Now
create the GUI status of 9000 and then call the sub screen for select option @
PBO.
MODULE status_9000 OUTPUT.
SET PF-STATUS 'PF_9000'.
* SET TITLEBAR 'T_9000'.
ENDMODULE.
SET PF-STATUS 'PF_9000'.
* SET TITLEBAR 'T_9000'.
ENDMODULE.
5) Then
create the PAI logic for 9000 screen. Write the logic of the Display button to
display material list.
MODULE user_command_9000 INPUT.
CASE ok_9000.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'DISP'.
PERFORM display_materials.
ENDCASE.
ENDMODULE.
CASE ok_9000.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'DISP'.
PERFORM display_materials.
ENDCASE.
ENDMODULE.
____________________________________________________________________________
FORM display_materials .
DATA: lv_mtart TYPE mara-mtart.
IF roh = 'X'.
lv_mtart = 'ROH'.
ELSE.
lv_mtart = 'FERT'.
ENDIF.
SELECT matnr ersda ernam mtart matkl meins
FROM mara INTO TABLE it_mara
WHERE ersda IN s_date
AND mtart = lv_mtart.
IF sy-subrc = 0.
SORT it_mara BY ersda.
REFRESH CONTROL 'TABC' FROM SCREEN 9001.
CALL SCREEN 9001
STARTING AT 4 4
ENDING AT 95 18.
ENDIF.
ENDFORM.
DATA: lv_mtart TYPE mara-mtart.
IF roh = 'X'.
lv_mtart = 'ROH'.
ELSE.
lv_mtart = 'FERT'.
ENDIF.
SELECT matnr ersda ernam mtart matkl meins
FROM mara INTO TABLE it_mara
WHERE ersda IN s_date
AND mtart = lv_mtart.
IF sy-subrc = 0.
SORT it_mara BY ersda.
REFRESH CONTROL 'TABC' FROM SCREEN 9001.
CALL SCREEN 9001
STARTING AT 4 4
ENDING AT 95 18.
ENDIF.
ENDFORM.
6) Here
we shall mention the modal dialog screen starting and ending co-ordinate. This
co-ordinate is mandatory to display the modal dialog box.
CALL SCREEN 9001
STARTING AT 4 4
ENDING AT 95 18.
STARTING AT 4 4
ENDING AT 95 18.
7) Now
write the PBO modules of modal dialog. There is no need to create GUI status (if
you want then you can) separately. Since we are using table control here, loop
with control for ITAB. The same pattern will be used as we use to create table
control. Similarly to modify the table we create PAI module over there. In screen you can disable the input option in table control as usual.
MODULE tabc_modal OUTPUT.
DESCRIBE TABLE it_mara LINES sy-dbcnt.
tabc-current_line = sy-loopc.
tabc-lines = sy-dbcnt.
mara-matnr = wa_mara-matnr.
mara-ersda = wa_mara-ersda.
mara-ernam = wa_mara-ernam.
mara-mtart = wa_mara-mtart.
mara-matkl = wa_mara-matkl.
mara-meins = wa_mara-meins.
CLEAR: wa_mara.
ENDMODULE.
DESCRIBE TABLE it_mara LINES sy-dbcnt.
tabc-current_line = sy-loopc.
tabc-lines = sy-dbcnt.
mara-matnr = wa_mara-matnr.
mara-ersda = wa_mara-ersda.
mara-ernam = wa_mara-ernam.
mara-mtart = wa_mara-mtart.
mara-matkl = wa_mara-matkl.
mara-meins = wa_mara-meins.
CLEAR: wa_mara.
ENDMODULE.
_________________________________________________________________________
MODULE tabc_modify_modal INPUT.
READ TABLE it_mara INTO wa_mara INDEX tabc-current_line.
IF sy-subrc = 0.
MODIFY it_mara FROM wa_mara INDEX tabc-current_line.
ENDIF.
ENDMODULE.
READ TABLE it_mara INTO wa_mara INDEX tabc-current_line.
IF sy-subrc = 0.
MODIFY it_mara FROM wa_mara INDEX tabc-current_line.
ENDIF.
ENDMODULE.
8) Now
create the PAI user command code as follows.
MODULE user_command_9001 INPUT.
CASE ok_9001.
WHEN 'ENTER'.
LEAVE LIST-PROCESSING.
CLEAR ok_9001.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.
CASE ok_9001.
WHEN 'ENTER'.
LEAVE LIST-PROCESSING.
CLEAR ok_9001.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.
9) Finally
create the transaction code to execute this program.
9 comments:
Very useful document thank you for sharing..............
you provide a lot of information
sap successfactors in chennai
It has been great for me to read such great information about HR Outsourcing.sap hr apap training
thank you for the useful post.
for more info visit us sap mm training in chennai
I've learned a lot about this blog.
In this tutorial, you can find the new dialog box and can get the new module for your life style. Just catch the best movement of your life on this page and get the special pattern here. You can get the best tutorial here.
the dialogue boxes are really important for the blog post as they attracted the main. Go to here https://www.appscomparator.com/bookbub-review/ to get the proper review for the bookhub site.
Thank you ,
Well it was nice post and very helpful information on sap video.
Post a Comment