Search this site

Saturday, December 15, 2012

Module pool programming: Example input,output field element


1. Go to SE80 , create program:

 2. Create the screen for user dialog program:


3. Click on the button Layout to go to screen paiter.Screen painter is a tool that helps design the screen of module program.
 
4. In this example, we will create a simple program that calculate two number and show its result:
You could see on the left side is the elements you will add to the screen.First,add two input fields A and B.


Second,Create the output field RESULT to contain the calculation result from A + B.

 Third,create the button with the name CAL , fctCode CAL.

Double click to the screen 1000 ,it will show you the flow logic of the screen 1000.
It has two PROCESSES:

 PROCESS BEFORE OUTPUT : In this proscess,you could set the initial values of the screen elements or do the initial logics.
 PROCESS AFTER INPUT: In this proscess,you could get the value from the screen elements and do the needful.


 Create the MOUDLEs in each PROCESS.
 Here' code example.Notice that the name of variants in the flow logic must be same name with the name of screen elements:
REPORT  ZUSERDIALOG_01.
DATA: A TYPE I,
      B TYPE I,
      RESULT type i.

CALL SCREEN 1000.
*&---------------------------------------------------------------------*
*&      Module  STATUS_1000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_1000 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.
 A = 1.
 B = 1.
ENDMODULE.                 " STATUS_1000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_1000  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1000 INPUT.
IF sy-ucomm = 'CAL'.
  RESULT  = A + B.

 ENDIF.
ENDMODULE.                 " USER_COMMAND_1000  INPUT


F8 to run program:

The result will show after pressing CAL button.

The end. Hope this information helpful for you.

6 comments:

  1. I am a beginner and most of the sites make module pool very complicated , thank you very much

    finally i was able to actually create a screen

    ReplyDelete
  2. Interesting and easy sample/tutorial i tested the sample, and calculate the result, but if i put in A: 4 and B: 1 the result was 5, at this time all is OK, but immediatly (after) calculate the result, the Input A and Input B was restored wit initial value to 1, why? how to fix it?

    Thanks

    ReplyDelete
    Replies
    1. Becouse you have set initilal value on this fields.

      Delete
  3. Gangaur Realtech is a professionally managed organisation specializing in real estate services where integrated services are provided by professionals to its clients seeking increased value by owning, occupying or investing in real estate. forbes

    ReplyDelete