Search this site

Saturday, December 15, 2012

Module pool programming: Create GUI Status example

Create the Guide status for program.

Enter the status name STATUS_1000

 Add item CAL to menu bar.Enter the name of menu

 Double click to CAL item.The screen will show as below:

 Create the action for the item on the Standard tool bar.In this example ,We create the action for the button BACK on the standard toolbar:


 Use the code as below to call the status bar STATUS_1000 which created on the first  step:

 Create the item CAL for the application toolbar :

 Run the progarm:You coud use function Calculate via menu item Calculate on Menu bar or button Calculate standard tool bar.The screen will show as below:

The end!


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.