Tuesday, April 24, 2018

Modal Dialog BOX


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

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 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.
__________________________________________________________________________

      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.



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.




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.

____________________________________________________________________________

   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
    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
    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.
_________________________________________________________________________

   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.




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.

9)      Finally create the transaction code to execute this program.

 Enter T-code.


Click on the Display button. Then the following pop up screen will open which contains the list of Raw materials.


Now click on the close button and it will be back to the previous screen. Select the finished good button and then Display.


The following pop up screen will come which contains the list of finished good materials.



16 comments:

ravi gr ravi gr said...

Very useful document thank you for sharing..............

ananthinfo said...

nice post..
SAP BUSINESS ONE for leather solution
ERP for leather solution
ERP leather garment solution
SAP BUSINESS ONE for leather garment solution
ERP for footwear solution

ERP Training said...

It was so nice article.I was really satisified by seeing this article sap video tutorials.

ERP Training Videos said...

Thank you. sir, Really I like your post on sap video tutorials.

suresh smart said...

you provide a lot of information
sap successfactors in chennai

calfre services said...

It has been great for me to read such great information about HR Outsourcing.sap hr apap training

ERP Training Videos said...

Fabulous..!! Thank you.The information you provided is much usful information on sap hana training videos.

ERP Training Videos said...

Thank you ,
Well it was nice post and very helpful information on sap learning videos.

ERP Training Videos said...

Thank you ,
Well it was nice post and very helpful information on sap video.

ERP Training Videos said...

Thank you. sir, Really I like your post on sap video tutorials.

ERP Training Videos said...

Thankyou for Sharing Great Information. It is Very Helpful Information on sap videos.

sandra said...

thank you for the useful post.
for more info visit us sap mm training in chennai

Danah Booker said...

I've learned a lot about this blog.

calfre services said...
This comment has been removed by the author.
ERP Training Videos said...

It was Nice post and very useful information on sap simple logistics videos.

ERP Training Videos said...

It was Nice post and very useful information on sap training videos.