Creation of Normal screen to enter single entry - Module Pool/Dialog Programming
To
create screen programming we need to do 3 Major steps:
DATA: IT_BANK TYPE TABLE OF ZACC_DATA,
WA_BANK TYPE ZACC_DATA.
Once you place the fields on the screen few of the fields will not placed with Text labels.
Double click on the Button & Provide the below Properties:
Name, Text and Function Code as per sequence given in the below screen
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0002 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0002 INPUT.
ENDMODULE.
Make use of Function codes to build the logic
Note: SY-UCOMM holds the Function code Name during Run time of Program
Implement the logic for 'BACK'.
----
ENDMODULE.
Steps to Create a Transaction for a Program
Now, We have completed the Transaction Creation.
and successfully linked the Program with the Transaction.
----------------
Test your transaction:
*&------------------------------------------
IF SY-UCOMM = 'SAVE'. " SAVE-> Function Code
INSERT ZACC_DATA FROM WA_BANK.
IF SY-SUBRC = 0.
CLEAR WA_BANK.
MESSAGE 'Successfully Record Inserted' TYPE 'I'. " I-> Information Message
ELSE.
MESSAGE 'Record not created' TYPE 'E'. " E-> Error Message
ENDIF.
ELSEIF SY-UCOMM = 'BACK'. " BACK-> Function Code
LEAVE TO SCREEN 0. " Go back to entry screen
ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_0002 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0002 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'TITLE_0002'.
ENDMODULE.
- Screen Design
- Flow Logic (Program)
- Transaction code creation
Requirement: Create a
transaction program to enter data into database table.
Table Structure:
Program flow:
Step1: Screen Design
Declare the Internal table & Work area
*& IT & WA with the table referenceDATA: IT_BANK TYPE TABLE OF ZACC_DATA,
WA_BANK TYPE ZACC_DATA.
SAVE-CHECK-ACTIVATE.
Step2:
One Pop-Up screen will appear as below,
Enter the screen no as input.
Click On Continue....
Do the steps 1, 2 and then click on Layout
(Step 3)
Then-> Screen Painter (Where we can design
the screen)
Select required fields and click on
continue...
Note:Once you place the fields on the screen few of the fields will not placed with Text labels.
To create the texts we need to select Text Field and drag and drop.
Then 2 properties we need to set to the Text field as below:
Provide the Name: (Same as Input Field Name)
Provide the Text: As Per Your wish
Note:
When
we are designing a screen, remember always place your screen position on the
Left side Top Corner.
Provide the Button (To SAVE & BACK) on
the screen.
Select Push Button Property from screen
elements-> Place it on the screen.Double click on the Button & Provide the below Properties:
Name, Text and Function Code as per sequence given in the below screen
Set the properties for SAVE Button as below:
Set the properties for BACK Button as below:
Click on the Flow Logic Button/ to write the Functionality.
Step2: Build Flow
Logic (Program/Functionality of screen)
In the above screen we can see 2 events as
PBO & PAI.
Note:
Event:
Decides Timing
of execution of the statements.
As per our screen design The save and Back Buttons Will Trigger in PAI
Event.
Uncomment The PAI Module
MODULE USER_COMMAND_0002.
Then double click on 'USER_COMMAND_0002' in the above statement -> To build the
logic.
->Click 'Yes'-> One more window
will open-> Select Main program
Click on 'Continue'
Click On'Yes'.
You will get the below logic in your
program.*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0002 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0002 INPUT.
ENDMODULE.
-----------
Now, implement the logic between Module and Endmodule of 'USER_COMMAND_0002' as shown above.Make use of Function codes to build the logic
Note: SY-UCOMM holds the Function code Name during Run time of Program
Implement the logic for 'SAVE'.
IF SY-UCOMM = 'SAVE'. " SAVE-> Function Code
INSERT ZACC_DATA FROM WA_BANK.
IF SY-SUBRC = 0.
CLEAR WA_BANK.
MESSAGE 'Successfully Record Inserted' TYPE 'I'. " I-> Information Message ELSE.
MESSAGE 'Record not created' TYPE 'E'. " E-> Error Message ENDIF.
IF SY-SUBRC = 0.
CLEAR WA_BANK.
MESSAGE 'Successfully Record Inserted' TYPE 'I'. " I-> Information Message ELSE.
MESSAGE 'Record not created' TYPE 'E'. " E-> Error Message ENDIF.
endif.
----Implement the logic for 'BACK'.
----
IF SY-UCOMM = 'BACK'. " BACK-> Function Code
LEAVE TO SCREEN 0. " Go back to entry screen
ENDIF.
Now,
go to flow logic Section of your Screen
Uncomment the Module Under PBO
PROCESS BEFORE OUTPUT.
MODULE STATUS_0002.
MODULE STATUS_0002.
Double click on ' STATUS_0002' then
Click -> Yes->Then select MainProgram
The below section of code will appear.
MODULE STATUS_0002 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
*
SET TITLEBAR 'XXXXXXX'. * SET PF-STATUS 'xxxxxxxx'.
ENDMODULE.
write the SET TITLEBAR as below:
SET TITLEBAR 'TITLE_0002'.
Double click on 'TITLE_0002' then One
Pop-Up window appears.
Enter the Title in that screen as below:
SAVE->CHECK->ACTIVATE.
Step3: Create a Transaction
for Our Program
Steps to Create a Transaction for a Program
Open Transaction SE93
and select the properties as below
Click On Continue...
One more screen Opens
do the above steps 1,2 & 3
Save ->Check-> ActivateNow, We have completed the Transaction Creation.
and successfully linked the Program with the Transaction.
----------------
Test your transaction:
And press Enter
Your screen will display
Click on SAVE
Button
You will get Pop-Up Message as below:
The Entry is successfully stored in the
database from the screen.
Thats It...!
*& --------------------------------------
*& Source Code*&------------------------------------------
PROGRAM ZNORMAL_SCREEN2.
*& IT & WA with the table reference
DATA: IT_BANK TYPE TABLE OF ZACC_DATA,
WA_BANK TYPE ZACC_DATA.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0002 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0002 INPUT.
*& Make use of Function codes to build the logic
*& Note: SY-UCOMM holds the Function code Name during Run time of Program
*& IT & WA with the table reference
DATA: IT_BANK TYPE TABLE OF ZACC_DATA,
WA_BANK TYPE ZACC_DATA.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0002 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0002 INPUT.
*& Make use of Function codes to build the logic
*& Note: SY-UCOMM holds the Function code Name during Run time of Program
IF SY-UCOMM = 'SAVE'. " SAVE-> Function Code
INSERT ZACC_DATA FROM WA_BANK.
IF SY-SUBRC = 0.
CLEAR WA_BANK.
MESSAGE 'Successfully Record Inserted' TYPE 'I'. " I-> Information Message
ELSE.
MESSAGE 'Record not created' TYPE 'E'. " E-> Error Message
ENDIF.
ELSEIF SY-UCOMM = 'BACK'. " BACK-> Function Code
LEAVE TO SCREEN 0. " Go back to entry screen
ENDIF.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_0002 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0002 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'TITLE_0002'.
ENDMODULE.
Comments
Post a Comment