We have developed here a Module Pool program where Table Control has been used for output and Select Option for input. In the standard selection screen 100 we have maintained a select option for input like follows.
Here the Selection Screen is actually a sub screen and screen number 100 has been maintained by the program. The buttons DISPLAY and CLEAR have been maintained from the custom screen 9001. Hence the 9001 screen contains the selection screen as a sub screen and the sub screen 100 is maintained from the program. The layout of the 9001 screen is as follows:
Hence the logic of the selection screen is Calling the sub screen <sub screen name> which is including program name and screen number 100. This logic has to be maintained in the PBO block. After that PAI block is started. Here we have to Call sub screen <sub screen name> and then we shall call the user command module.
Here calling the sub screen in PBO is basically calling the selection screen and calling the sub screen in PAI is basically passing the value from the screen to the program. Hence if we don't call sub screen in PAI then input parameter and selection option will be blank in the main program.
Now we have prepared second screen 9002 where the Table Control is there. In the PBO block of the 9002 screen we have to Loop at output table with table control <table control name>. Inside this loop we have created a module table_control which passes data of output table to the screen fields.
After that in the PAI block we have to maintain the table control's next page which is triggered by Scroll down or by clicking the down arrow of table control. Hence we have Loop at output table again and inside the loop we have read output table with index Current Line. This Read is for checking if any further lines exist or not. So by checking sy-subrc value we have modified output table with current line index.
The layout of Screen 9002 is as follows:
The steps are as follows.
Now entering the Material number range we are getting this details with table control.
Now we can scroll as follows.
Similarly we can scroll to view further column at right side.
Here the Selection Screen is actually a sub screen and screen number 100 has been maintained by the program. The buttons DISPLAY and CLEAR have been maintained from the custom screen 9001. Hence the 9001 screen contains the selection screen as a sub screen and the sub screen 100 is maintained from the program. The layout of the 9001 screen is as follows:
Hence the logic of the selection screen is Calling the sub screen <sub screen name> which is including program name and screen number 100. This logic has to be maintained in the PBO block. After that PAI block is started. Here we have to Call sub screen <sub screen name> and then we shall call the user command module.
Here calling the sub screen in PBO is basically calling the selection screen and calling the sub screen in PAI is basically passing the value from the screen to the program. Hence if we don't call sub screen in PAI then input parameter and selection option will be blank in the main program.
Now we have prepared second screen 9002 where the Table Control is there. In the PBO block of the 9002 screen we have to Loop at output table with table control <table control name>. Inside this loop we have created a module table_control which passes data of output table to the screen fields.
After that in the PAI block we have to maintain the table control's next page which is triggered by Scroll down or by clicking the down arrow of table control. Hence we have Loop at output table again and inside the loop we have read output table with index Current Line. This Read is for checking if any further lines exist or not. So by checking sy-subrc value we have modified output table with current line index.
The layout of Screen 9002 is as follows:
The steps are as follows.
Step 1:
Create a module pool program with proper naming
convention and activate all the include programs.
INCLUDE mz_test_top . "
global Data
INCLUDE mz_test_o01 . " PBO-Modules
INCLUDE mz_test_i01 . " PAI-Modules
INCLUDE mz_test_f01 . " FORM-Routines
INCLUDE mz_test_o01 . " PBO-Modules
INCLUDE mz_test_i01 . " PAI-Modules
INCLUDE mz_test_f01 . " FORM-Routines
Step 2:
Declare all the important declarations at top include.
PROGRAM sapmz_test.
TABLES mara.
TYPES: BEGIN OF ty_mara,
matnr TYPE mara-matnr, "Material Number
ersda TYPE mara-ersda, "Date
ernam TYPE mara-ernam, "Name
laeda TYPE mara-laeda, "Date of Last Change
aenam TYPE mara-aenam, "Name of Person Who Changed Object
pstat TYPE mara-pstat, "Maintenance status
mtart TYPE mara-mtart, "Material Type
mbrsh TYPE mara-mbrsh, "Industry sector
matkl TYPE mara-matkl, "Material Group
meins TYPE mara-meins, "Base Unit of Measure
bstme TYPE mara-bstme, "Purchase Order Unit of Measure
END OF ty_mara.
DATA: wa_mara TYPE ty_mara,
it_mara TYPE TABLE OF ty_mara.
DATA: ok_code_sel TYPE sy-ucomm,
ok_code_mat TYPE sy-ucomm.
CONTROLS tab_ctrl TYPE TABLEVIEW USING SCREEN 9002.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECT-OPTIONS s_matnr FOR mara-matnr.
SELECTION-SCREEN END OF SCREEN 100.
TABLES mara.
TYPES: BEGIN OF ty_mara,
matnr TYPE mara-matnr, "Material Number
ersda TYPE mara-ersda, "Date
ernam TYPE mara-ernam, "Name
laeda TYPE mara-laeda, "Date of Last Change
aenam TYPE mara-aenam, "Name of Person Who Changed Object
pstat TYPE mara-pstat, "Maintenance status
mtart TYPE mara-mtart, "Material Type
mbrsh TYPE mara-mbrsh, "Industry sector
matkl TYPE mara-matkl, "Material Group
meins TYPE mara-meins, "Base Unit of Measure
bstme TYPE mara-bstme, "Purchase Order Unit of Measure
END OF ty_mara.
DATA: wa_mara TYPE ty_mara,
it_mara TYPE TABLE OF ty_mara.
DATA: ok_code_sel TYPE sy-ucomm,
ok_code_mat TYPE sy-ucomm.
CONTROLS tab_ctrl TYPE TABLEVIEW USING SCREEN 9002.
SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECT-OPTIONS s_matnr FOR mara-matnr.
SELECTION-SCREEN END OF SCREEN 100.
Step 3:
Create a screen 9001 and set the ok code = ok_code_sel.
Step 4:
Write the flow logic as follows.
PROCESS BEFORE OUTPUT.
MODULE status_9001.
"Calling the Subscreen including program name & screen
CALL SUBSCREEN sel INCLUDING sy-repid '100'.
PROCESS AFTER INPUT.
"Calling the Subscreen at PAI
CALL SUBSCREEN sel.
MODULE user_command_9001.
MODULE status_9001.
"Calling the Subscreen including program name & screen
CALL SUBSCREEN sel INCLUDING sy-repid '100'.
PROCESS AFTER INPUT.
"Calling the Subscreen at PAI
CALL SUBSCREEN sel.
MODULE user_command_9001.
Step 5:
Create the custom layout as follows. In the layout we
need to create the sub screen by layout palate.
Step 6:
Create the PBO module of screen 9001.
MODULE status_9001 OUTPUT.
SET PF-STATUS 'GUI_9001'.
SET TITLEBAR 'TITLE_9001'.
ENDMODULE. " status_9001 OUTPUT
SET PF-STATUS 'GUI_9001'.
SET TITLEBAR 'TITLE_9001'.
ENDMODULE. " status_9001 OUTPUT
Step 7:
Create the PAI module of screen 9001.
MODULE user_command_9001 INPUT.
CASE ok_code_sel.
WHEN 'DISP'. "Display button
PERFORM get_data_mara.
WHEN 'CLR'. "Clear button
CLEAR s_matnr.
REFRESH s_matnr[].
WHEN 'BACK'. "Back button
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " user_command_9001 INPUT
CASE ok_code_sel.
WHEN 'DISP'. "Display button
PERFORM get_data_mara.
WHEN 'CLR'. "Clear button
CLEAR s_matnr.
REFRESH s_matnr[].
WHEN 'BACK'. "Back button
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " user_command_9001 INPUT
Step 8:
Now we need to create the subroutine get_data_mara.
FORM get_data_mara .
IF s_matnr[] IS NOT INITIAL.
SELECT matnr ersda ernam laeda aenam
pstat mtart mbrsh matkl meins bstme
FROM mara INTO TABLE it_mara
WHERE matnr IN s_matnr.
IF sy-subrc = 0.
SORT it_mara.
"Refreshing table control from the screen
REFRESH CONTROL 'TAB_CTRL' FROM SCREEN 9002.
"Calling the screen of table control
CALL SCREEN 9002.
ENDIF.
ENDIF.
ENDFORM. " get_data_mara
IF s_matnr[] IS NOT INITIAL.
SELECT matnr ersda ernam laeda aenam
pstat mtart mbrsh matkl meins bstme
FROM mara INTO TABLE it_mara
WHERE matnr IN s_matnr.
IF sy-subrc = 0.
SORT it_mara.
"Refreshing table control from the screen
REFRESH CONTROL 'TAB_CTRL' FROM SCREEN 9002.
"Calling the screen of table control
CALL SCREEN 9002.
ENDIF.
ENDIF.
ENDFORM. " get_data_mara
Step 9:
Now create the 9002 screen and set ok code = ok_code_mat.
Step 10:
Write the flow logic of table control as follows.
PROCESS BEFORE OUTPUT.
MODULE status_9002.
"Looping the table with table control
LOOP AT it_mara INTO wa_mara WITH CONTROL tab_ctrl.
MODULE prepare_table_control.
ENDLOOP.
PROCESS AFTER INPUT.
"Looping the table at PAI
LOOP AT it_mara.
MODULE modify_table_control.
ENDLOOP.
MODULE user_command_9002.
MODULE status_9002.
"Looping the table with table control
LOOP AT it_mara INTO wa_mara WITH CONTROL tab_ctrl.
MODULE prepare_table_control.
ENDLOOP.
PROCESS AFTER INPUT.
"Looping the table at PAI
LOOP AT it_mara.
MODULE modify_table_control.
ENDLOOP.
MODULE user_command_9002.
Step 11:
Create the PBO & PAI module as follows.
MODULE status_9002 OUTPUT.
SET PF-STATUS 'GUI_9001'.
SET TITLEBAR 'TITLE_9002'.
ENDMODULE. " status_9002 OUTPUT
SET PF-STATUS 'GUI_9001'.
SET TITLEBAR 'TITLE_9002'.
ENDMODULE. " status_9002 OUTPUT
MODULE user_command_9002 INPUT.
CASE ok_code_mat.
WHEN 'BACK'.
CLEAR ok_code_mat.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN 9001.
ENDCASE.
ENDMODULE. " user_command_9002 INPUT
CASE ok_code_mat.
WHEN 'BACK'.
CLEAR ok_code_mat.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN 9001.
ENDCASE.
ENDMODULE. " user_command_9002 INPUT
Step 12:
Now prepare the table control at PBO level as follows.
MODULE prepare_table_control OUTPUT.
"Describing table to populate sy-dbcnt
DESCRIBE TABLE it_mara LINES sy-dbcnt.
"Current line populates the loop information in table control
tab_ctrl-current_line = sy-loopc.
"Lines are populated with number of table lines
tab_ctrl-lines = sy-dbcnt.
"Moving data from work area to screen fields
mara-matnr = wa_mara-matnr.
mara-ersda = wa_mara-ersda.
mara-ernam = wa_mara-ernam.
mara-laeda = wa_mara-laeda.
mara-aenam = wa_mara-aenam.
mara-pstat = wa_mara-pstat.
mara-mtart = wa_mara-mtart.
mara-mbrsh = wa_mara-mbrsh.
mara-matkl = wa_mara-matkl.
mara-meins = wa_mara-meins.
mara-bstme = wa_mara-bstme.
CLEAR wa_mara.
ENDMODULE. " prepare_table_control OUTPUT
"Describing table to populate sy-dbcnt
DESCRIBE TABLE it_mara LINES sy-dbcnt.
"Current line populates the loop information in table control
tab_ctrl-current_line = sy-loopc.
"Lines are populated with number of table lines
tab_ctrl-lines = sy-dbcnt.
"Moving data from work area to screen fields
mara-matnr = wa_mara-matnr.
mara-ersda = wa_mara-ersda.
mara-ernam = wa_mara-ernam.
mara-laeda = wa_mara-laeda.
mara-aenam = wa_mara-aenam.
mara-pstat = wa_mara-pstat.
mara-mtart = wa_mara-mtart.
mara-mbrsh = wa_mara-mbrsh.
mara-matkl = wa_mara-matkl.
mara-meins = wa_mara-meins.
mara-bstme = wa_mara-bstme.
CLEAR wa_mara.
ENDMODULE. " prepare_table_control OUTPUT
Step 13:
Create the PAI module of table control to modify the
internal table.
MODULE modify_table_control INPUT.
"Reading the table with current line of table control
READ TABLE it_mara INTO wa_mara INDEX tab_ctrl-current_line.
IF sy-subrc = 0.
"Modifying the table with table control current line
MODIFY it_mara FROM wa_mara INDEX tab_ctrl-current_line.
ENDIF.
ENDMODULE. " modify_table_control INPUT
"Reading the table with current line of table control
READ TABLE it_mara INTO wa_mara INDEX tab_ctrl-current_line.
IF sy-subrc = 0.
"Modifying the table with table control current line
MODIFY it_mara FROM wa_mara INDEX tab_ctrl-current_line.
ENDIF.
ENDMODULE. " modify_table_control INPUT
Step 14:
Now create the T-code to execute this program.
5 comments:
Hi, good presentation with screenshots thanx
Hi. It was a good tutorial on table controls but I could not get the selection screen inspite of following the steps accurately. Can you please help me with this.
Thanks in advance.
Ankit.
Thank you so much!. Nice tutorial with nice explanation in simple way.
SAP Success Factors Real Time Hands on Training in Chennai...
Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286
Both Classroom/Online Training is Available!!!!!!
Hi, I learned SAP Training in Chennai from THE CREATING EXPERTS. The training was good and i got selected in leading MNC company as SAP Consultant.
contact 8122241286
www.thecreatingexperts.com
Post a Comment