Module Pool
Module Pool
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
INDEX
1 ABAP Transactions (or) Module Pool Programming (or) Dialog Programming 5
2 Events in Module Pool Programming 5
3 Sub Screen Area 11
4 Table Control 15
5 Tab Strip Control 22
6 Mail Coding 33
7 Applications 34
8 LUW Functionality 36
9 CHAIN Keyword 37
10 Table Control Wizard 38
11 Input / Output Field 49
12 Assignment Log sheet Temperature Details 54
13 Assignment Cheques Date Entry Screen 56
14 Assignment Simple calculator 60
15 Reports (Classical, Interactive, ALV, LDB (Logical Data Base) &SAP Query 61
Reports )
16 1. Classical Reports (Events in Classical Reporting) 62
17 MM - PO and Tax Details Report 67
18 KONV Table 73
19 MM - Po Delivery Status Report (Assignment) 74
20 2. Interactive Reporting ( HIDE, SY-LSIND, SY-LISEL, GET CURSOR) 75
21 SAP Memory (SET PARAMETER) 76
22 SD - Invoice Details based on Customers 77
23 VBRK, VBRP, ADRC Tables 82
24 3. ALV Reporting (Traditional ALV & ALV with OOP ) 84
25 A)Traditional ALV(Simple, Blocked & Hierarchal Sequential ALVs) 84
26 i) Simple ALV (Classical & Interactive ALV) 85
27 a) Classical ALV 85
28 MM - Open PO Details Report 85
29 REUSE_ALV_GRID_DISPLAY 90
30 MM - Restricted & Unrestricted stock details report material wise & plant wise 92
Report
31 MARD Table 95
32 SLIS_SORTINFO_ALV, SLIS_LISTHEADER, SLIS_ALV_EVENT 96
33 Monthly sales report based on customers Report (Assignment) 97
34 Sales analysis report (Assignment) 98
35 b) Interactive ALV 99
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
Transaction:
A transaction is a series of Dialog Steps in which application will accept data from user which
is finally updated to Database
Name1
Display exit
Note:
Flow Logic (Events) acts as interface between Screen Painter & Dialog Programming
PAI:
It triggers after processing input values in a screen
This event triggers whenever user interacts with a screen
PBO:
It triggers before screen display
Note:
1. PAI will brings the data from Screen to Program Variables
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
POH:
It triggers whenever user select F1 Function Key. It is for help
POV:
It triggers whenever user select F4 Function Key. It is for search help
FCT FCT
Display Insert
Dialog Programming
SY-UCOMM:
It returns FCT value for a function key (button) in Dialog programming selected by user
Steps:
1. Work with SE38 (create a Dialog Programming)
2. Work with SE51 (create a Screen)
3. Work with SE93 (create a T code)
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
Requirement:
Kunnar
Land1
Name1
Ort01
Pstlz
strs
Solution:
Step-1:
Go to SE38
Program: ZSD_CUSTOMER_DETAILS
Create
Title: Customer Details
Type: Module Pool
Enter
Package: ZABAP
Save
Create Request
Short Description: SD/ABAP: Customer Details (25.09.2014)
Enter
Enter
Step-2:
Go to SE51
Program: ZSD_CUSTOMER_DETAILS
Screen Number: 100
Create
Short Description: Screen 100
Layout button
Place a box (last from 6th option) on the screen
Ashok
SAP-ADV ABAP
Note:
Place the mouse pointer on the icon & click on it
Bring mouse pointer on the screen & drag & drop it on the screen according to
requirement
Double click on Frame of the box
You will find an attributes pop-up
Provide Text: Customer Details
Close
Select Dictionary Program Fields button (F6)
You will find a pop-up
Table Name: KNA1
Enter
You will find fields of the table
Select Kunnr, Land1, Name1, Ort01, Pstlz, Stras
Enter
Place the fields with the help of mouse pointer on the box & right click
Place 3 Push buttons (starting from 6th option) on Tool bar
Double click on 1st Push button
Text: Display
FCT Code: Display
Close
Double click on 2nd Push button
Text: Clear
FCT Code: Clear
Close
Double click on 3rd Push button
Text: Exit
FCT Code: Exit
Close
Flow Logic button (F9)
Remove comment for MODULE USER_COMMAND_100.
Double click on USER_COMMAND_100
You will find a pop-up Create Object: Yes
By default New Include selected
Select Main Program
Enter
Yes
Ashok
SAP-ADV ABAP
TABLES: KNA1.
CASE SY-UCOMM.
WHEN ‘Display’.
SELECT SINGLE land1 name1 ort01 pstlz stras INTO wa_kna1 FROM KNA1
WHERE kunnr EQ KNA1-kunnr.
WHEN ‘Clear’.
CLEAR: wa_kna1, KNA1-kunnr.
WHEN ‘Exit’.
LEAVE PROGRAM.
ENDCASE.
KNA1-land1 = wa_kna1-land1.
KNA1-name1 = wa_kna1-name1.
KNA1-ort01 = wa_kna1-ort01.
KNA1-pstlz = wa_kna1-pstlz.
KNA1-stras = wa_kna1-stras.
Back (F3)
Activate the screen
Step-3:
Go to SE93
Transaction Code: ZCUSTOMER
Create
Title: T code for Customer Details
Enter
Program: ZSD_CUSTOMER_DETAILS
Screen Number: 100
Save
Enter
Run the T code (ZCUSTOMER)
25-09-2014
Brief Flow:
1. PBO (Screen is called)
2. PAI (This event will triggers whenever you select a Button)
3. PBO (This will carry the data from Program Variables i.e. wa_kna1-kunnr = KNA1-
kunnr to screen field)
Ashok
SAP-ADV ABAP
Note:
In SAP you can create only 1 Normal Screen in an application & remaining all are Sub screens
Requirement:
Material Group
Gross Weight
Net Weight
Division
Example:
CALL SUBSCREEN SUB INCLUDING ‘ZMM_MATERIAL_SUB’ ‘110’
Solution:
Step-1:
Go to SE38
Program: ZMM_MATERIAL_SUB
Create
Title: Materials Details with Sub Screen
Type: Module Pool
Save
Package: ZABAP
Ashok
SAP-ADV ABAP
Enter
Create Request
Short Description: MM/ABAP: Materials Details with Sub Screen (26.09.2014)
Enter
Enter
Step-2:
Go to SE51
Program: ZMM_MATERIAL_SUB
Screen: 100
Create
Short Description: Screen 100
Layout
Dictionary Program Fields (F6)
Table Name: MARA
Enter
Select matnr field
Enter
Place the field on the top of the screen
Place Sub Screen Area (last from 5th option) on the screen
Double click on Sub Screen Area
Name: SUB
Close
Place 3 Push Buttons (starting from 6th option) under Sub Screen Area
Provide Text & FCT code as per requirement
Select Flow Logic
Remove comment for MODULE USER_COMMAND_100
Double click on USER_COMMAND_100
Yes
Main Program
Enter
Yes
CASE SY-UCOMM.
WHEN ‘DISPLAY’.
SELECT SINGLE mtart matkl brgew ntgew spart FROM MARA
INTO (MARA-mtart, MARA-matkl, MARA-brgew, MARA-ntgew, MARA-spart)
WHERE matnr = MARA-matnr.
Ashok
SAP-ADV ABAP
WHEN ‘CLEAR’.
CLEAR: MARA, MAKT.
WHEN ‘EXIT’.
LEAVE PROGRAM.
ENDCASE.
Activate program
Back (F3)
Place cursor under PROCESS BEFORE OUTPUT
Activate screen
Back (F3)
Screen: 110
Create
Short Description: Sub Screen 110
** Screen Type: Sub Screen
Layout
**place a box (last from 6th option) on top left corner of the screen
Double click on frame of the box
Text: Material Details
Close
Dictionary Program Fields (F6)
Table Name: MARA
Enter
Select matnr, matkl, brgew, ntgew, spart fields
Enter
Place the fields on the box
Dictionary Program Fields (F6)
Table Name: MAKT
Enter
Select maktx field
Enter
Place the field on the box
Flow Logic
Ashok
SAP-ADV ABAP
Activate screen
Step-3:
Go to SE93
Transaction Code: ZMATERIAL
Create
Short Text: T code for Materials Details
Enter
Program: ZMM_MATERIAL_SUB
Screen Number: 100
Save
Enter
Run T code (ZMATERIAL)
Ashok
SAP-ADV ABAP
27-09-2014
Table Control:
Use table control for processing multiple records
Object:
Truck Entry Screen
Vendor
Screen 100
Solution:
Step-1:
Go to SE11
Database Table: ZMM_DEMO
Create
Short Description: Truck Entry Table
Delivery Class: A
Table View Maintenance: Table View Maintained with Restrictions
Fields
Field key Data Element
MANDT _/ MANDT
DCNO _/ ZDCNO
DCDATE _/ ZDC_DATE
TNO ZTNO
Ashok
SAP-ADV ABAP
BRGEW BRGEW
TWT TWT
NTGEW NTGEW
EBELN EBELN
LIFNR LIFNR
Technical Settings
Data Class: APPL1
Size Category: 0
Save
Back (F3)
Activate Table
Yes
Step-2:
Go to SE80
Function Group: ZTCGR
Enter
Yes
Short Text: Function Group for Truck Details
Enter
Local Object
Under ZTCGR you will find INCLUDES, Expand it
You will find 2 INCLUDES
Double click on an include with TOP as suffix
Select Display/Change option
Activate
Back (F3)
Ashok
SAP-ADV ABAP
Step-3:
Place cursor under PROCESS AFTER INPUT.
MODULE USER_DML.
LOOP AT it_demo.
FIELD: zmm_demo-dcno,
zmm_demo-dcdate,
zmm_demo-tno,
zmm_demo-brgew,
zmm_demo-twt
Ashok
SAP-ADV ABAP
zmm_demo-ntgew
zmm_demo-ebeln,
zmm_demo-lifnr.
ENDLOOP.
CASE SY-UCOMM.
WHEN ‘INSERT’.
MODIFY zmm_demo FROM zmm_demo.
IF SY-SUBRC EQ 0.
MESSAGE ‘Record Inserted’ TYPE ‘S’.
ENDIF.
WHEN ‘UPDATE’.
UPDATE zmm_demo SET brgew = zmm_demo-brgew
twt = zmm_demo-twt
ntgew = zmm_demo-ntgew
WHERE dcno = zmm_demo-dcno.
IF SY-SUBRC EQ 0.
MESSAGE ‘Record Updated’ TYPE ‘S’.
ENDIF.
WHEN ‘ENTER’.
zmm_demo-ntgew = zmm_demo-brgew - zmm_demo-twt.
ENDCASE.
Activate
Back (F3)
Ashok
SAP-ADV ABAP
CASE SY-UCOMM.
WHEN ‘DISPLAY’.
SELECT * FROM zmm_demo INTO TABLE it_demo WHERE lifnr = lfa1-lifnr.
WHEN ‘RESET’.
REFRESH it_demo.
WHEN ‘EXIT’.
LEAVE TO SCREEN 0.
ENDCASE.
Activate
Back (F3)
Back (F3)
Activate screen
29-09-2014
Ques-1: Suppose in table control when I entered few records then I selected ‘Enter’ option, I
found that the records are completely vanished from table control. Why it happens & What
logic you will write to avoid problem?
Ans:
When you select ‘Enter’ control will moves from screen to program
In program there is no logic provided for storing the table control data in internal table
So nothing is transferred back to table control screen
So it looks like empty
Logic:
MODIFY it_demo FROM zmm_demo INDEX vcontrol-current_line.
IF SY-SUBRC NE 0.
APPEND zmm_demo TO it_demo.
ENDIF.
Ques-2: In table control how you can perform auto calculations whenever ‘Enter’ key selected?
Ans:
Remove comment for SET PF_STATUS.
Under MODULE STATUS_100 ‘xxxxxxxxx’.
Remove ‘xxxxxxxxxx’ provide ’BACK’.
Ashok
SAP-ADV ABAP
Yes
Yes
Short Text: BACK
Enter
Expand function keys option
_/ ENTER
Activate
You will find a pop-up, Enter
Function Text: Enter
Enter
Back (F3)
Activate program
Ashok
SAP-ADV ABAP
Object:
Former Loan Application
Cooperative Bank
POSTAL CODE
TEL
Automatically account number should be generated by system
ADDRESS
i.e. 90000001
SAVE
Ashok
SAP-ADV ABAP
APPROVE
A/C
Number field is mandatory
SAVE FName field is in display mode
When you enter A/CNumber & then press Enter, FName will
display automatically
CALC MAIL
Ashok
SAP-ADV ABAP
30-09-2014
Solution:
Step-1: Function Group Creation
Go to SE80
Function Group: ZFARMGR
Enter
Yes
Short Text: Function Group for Farmer Loan
Enter
Package: ZABAP
Enter
Create Request Number
Short Description: MM:ABAP/ Farmer Loan (30.09.2014)
Enter
Enter
* for mails
DATA: t_doc TYPE SODOCCHGI1,
t_receive TYPE SOMLRECI1 OCCURS 0 WITH HEADERLINE,
t_text TYPE SOLISTI1 OCCURS 0 WITH HEADERLINE.
Ashok
SAP-ADV ABAP
Activate
Back (F3)
Step-3:
Right click on ZFARMER
Create
Screen
Screen Number: 100
Enter
Short Description: Screen 100
Layout
Place Text Field (starting from 2nd option)
Double click on Text Field
Text: Cooperative Bank
Close
Place Tab Strip Control on screen
Double click on Tab Strip Control
Name: STRIP
Tab Title: 3
Close
Place Sub Screen Area (last from 5th option) on tab strip control
Double click on Sub Screen Area
Name: SUB
Close
Double click on Tab1
Text: Farmer
FCT Code: TAB1
Close
Double click on Tab2
Text: Loan
FCT Code: TAB2
***Ref Field: SUB
Close
Double click on Tab3
Text: Payment
FCT Code: TAB3
***Ref Field: SUB
Close
Flow Logic
Step-4:
Remove comment for MODULE USER_COMMAND_100
Double click on USER_COMMAND_100
Ashok
SAP-ADV ABAP
Yes
Enter
Enter
Yes
Place cursor between MODULE…………….ENDMODULE of
USER_COMMAND_100
CASE SY-UCOMM.
WHEN ‘TAB1’.
x = ‘110’.
STRIP-ACTIVETAB = ‘TAB1’.
WHEN ‘TAB2’.
x = ‘120’.
STRIP-ACTIVETAB = ‘TAB2’.
WHEN ‘TAB3’.
x = ‘130’.
STRIP-ACTIVETAB = ‘TAB3’.
ENDCASE.
Activate
Back (F3)
Activate
Back (F3)
Step-5:
Right click on ZFARMGR
Create
Screen
Screen Number: 110
Enter
Short Description: Sub Screen 110
Screen Type: Sub Screen
Layout
Place a Box on top left corner of the screen
Double click on frame of box
Ashok
SAP-ADV ABAP
CASE SY-UCOMM.
WHEN ‘SAVE’.
SELECT SINGLE MAX( acno ) FROM ZFARMER INTO zfarmer-acno.
IF zfarmer-acno EQ 0.
zfarmer-acno = ‘9000000’.
ELSE.
zfarmer-acno = zfarmer-acno + 1.
ENDIF.
INSERT ZFARMER.
IF SY-SUBRC EQ 0.
MESSAGE S000(ZMESS_CLS) WITH zfarmer-acno.
ENDIF.
ENDCASE.
Step-6:
Right click on ZFARMGR
Create
Screen
Screen Number: 120
Enter
Short Description: Sub Screen 120
Screen Type: Sub Screen
Layout
Place a Box on top left corner of the screen
Double click on frame of box
Text: Farmer Loan
Close
F6
Table Name: ZLOAN
Enter
Select Acno, Fname, Lamount fields
Enter
Place fields on the box
Place a check box (starting from 4th option) on the box
Double click on check box
Name: APPROVE
Text: Approve
Close
Place a push button on the box
Double click on push button
Text: Save
FCT Code: SAVE
Close
Double click on Fname I/O field
*** at bottom select Program tab
Input: Not Possible
Close
Flow Logic
Ashok
SAP-ADV ABAP
CHAIN.
FIELD: zloan-acno MODULE CHECK ON INPUT,
zloan-lamount.
Activate
Back
Double click on USER_COMMAND_120.
Yes
Enter
Enter
Yes
Place cursor between MODULE……..ENDMODULE of USER_COMMAND_120
Activate
Back
Activate screen
Back
Step-7:
Right click on ZFARMGR
Create
Screen
Screen Number: 130
Enter
Short Description: Sub Screen 130
Screen Type: Sub Screen
Layout
Place a Box on top left corner
Double click on frame of box
Text: Payment Details
F6
Table Name: ZPAYMENT
Enter
Except Mandt select all fields
Enter
Place fields on box
Double click on Fname I/O field
At bottom select Program tab
Input: Not Possible
Close
Repeat the same procedure with Lamount, Iamount & Due amount
*** double click on Loan Paid I/O field
At bottom select Program tab
Input: Required
Place a push button on the box
Text: Calc
FCT Code: CALC
Place another push button
Text: Mail
FCT Code: MAIL
Flow Logic
Place cursor under PROCESS AFTER INPUT
CHAIN.
Ashok
SAP-ADV ABAP
Activate
Back
Double click on USER_COMMAND_130
Yes
Enter
Enter
Yes
Place cursor between MODULE………..ENDMODULE of USER_COMMAND_130
SELECT SINGLE fname lamount ldate approve FROM ZLOAN INTO (zpayment-
fname, zpayment-lamount, zloan-ldate, zloan-approve) WHERE acno = zpayment-acno.
CASE SY-UCOMM.
WHEN ‘CALC’.
IF zloan-approve EQ ‘x’.
CALL FUNCTION ‘HR_99S_INTERVAL_BETWEEN_DATES’.
EXPORTING
begda = zloan-ldate
endda = sy-datum
IMPORTING
days = days
zpayment-iamount = ( (zpayment-lamount * 1 * days) / (100 * 30) ).
zpayment-due = (zpayment-lamount + zpayment-iamount) - zpayment-lpaid.
UPDATE ZLOAN SET lamount = zpayment-due WHERE acno = zpayment-acno.
Ashok
SAP-ADV ABAP
INSERT ZPAYMENT.
ENDIF.
ENDCASE.
Activate
Back
Activate screen
Step-8:
Right click on ZFARMGR
Create
Transaction
Transaction Code: YFARMER
Enter
Program: SAPLZFARMGR
Screen Number: 100
Save
Back
Step-9:
Right click on ZFARMGR
Activate
Run T code (YFARMER)
Ashok
SAP-ADV ABAP
01-10-2014
Mail Coding:
* for mail address
T_receiver_rec_type = ‘U’.
T_receiver_receiver = ‘satya@[Link]’.
* fill subject
T_doc_obj_name = ‘TEXT’.
T_doc_obj_descr = ‘Payment Details’.
T_doc_obj_langu = SY-LANGU.
*fill contents
V_paid = zpayment-lpaid.
V_due = zpayment-due.
V_interest = zpayment-iamount.
Activate
Applications:
Application is a collection of screens
Screen is a collection of fields
Applications are created by Technical Consultant
Customization of data in application is done by Functional Consultant
Applications are used by End Users
Example:
Go to XK01
Vendor: 9872
Company Code: 1000
Purchase Organization: 1000
Account Group: 0001
Enter
Title: MR
Name: Ashok
Search Tem: Broacomm
Street: Ameerpet
Postal Code: 500074
City: Hyderabad
Country: IN
Enter
No data in this screen
Enter
Country: IN
Bank Key: F000158
A/C Number: 9000006
Enter
Enter
Recon Account: 31000
Cash Management Group: A1
Enter
No data in this screen
Enter
No data in this screen
Enter
Order Currency: INR
Enter
Save
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
Go to SE11
Database Table: LFA1
Display
Contents
Lifnr: 9872
F8
Ashok
SAP-ADV ABAP
LUW Functionality:
Logical Unit of Work
By default all SAP applications follows LUW functionality
Database Server
SAVE
Screen level validation Screen level validation Screen level validation Explicit commit
Implicit commit Implicit commit Implicit commit
06-10-2014
By default all SAP applications follows LUW functionality
In between the Screens implicit commit will take place where implicit commit data from
Screen is transferred to Database Buffer
Whenever user applies Save option explicit commit will take place where explicit commit
data from Database Buffer is transferred to respective Database Table
Ashok
SAP-ADV ABAP
CHAIN Keyword:
By default standard application allows screen level validations
If you want to perform field level validations you should write logic explicitly using
CHAIN……..ENDCHAIN
All implicit commit as DB LUW Commit & all explicit commit as SAP LUW Commit
Advantage of LUW:
With LUW the data is concisely transferred to Database
Ashok
SAP-ADV ABAP
Requirement:
Equipment details based on Plant
Input:
Equipment Number: To
Equipment Date: To
Plant To
Material Code To
Save
Solution:
Step-1:
Go to SE11
Database Table: ZPP_EQUIPMENT
Create
Short Description: Equipment Details
Ashok
SAP-ADV ABAP
Delivery Class: A
Table View Maint: Display / Maint Allowed with Restrictions
Field tab
Field key Data Element
Mandt _/ MANDT
Sel _/ CHAR1
Equnr _/ EQUNR
Edate _/ ZEDATE
Werks WERKS_D
Matnr MATNR
Menge MENGE_D
Aufnr AUFNR
Dept ZDEPT_DAT
Activate domain
Field Label
Medium 20 Department
Activate
Back
Field key Data Element
Erdat ERDAT
Ernam ERNAM
Technical Settings
Data Class: APPL1
Ashok
SAP-ADV ABAP
Size Category: 0
Currency Quantity Fields tab
Step-2:
Go to SE38
Program: ZPP_EQUIPMENT_DETAILS
Create
Title: Equipment Details
Type: Executable Program
Save
INITIALIZATION.
BUTTON1 = ‘Add New’.
BUTTON2 = ‘Update’.
BUTTON3 = ‘Delete’.
BUTTON4 = ‘Display’.
Ashok
SAP-ADV ABAP
IF SSCRFIELDS-UCOMM EQ ‘BUT1’.
CALL SCREEN 100.
ELSEIF SSCRFIELDS-UCOMM EQ ‘BUT2’.
SELECT * FROM ZPP_EQUIPMENT INTO TABLE it
WHERE equnr IN s_equnr
AND matnr IN s_matnr
AND werks IN s_werks
AND edate IN s_edate.
ENDIF.
Step-3:
Double click on 100
Ashok
SAP-ADV ABAP
Yes
Yes
Short Description: Screen 100
Main Screen
Layout
Place Table Control Wizard (last from 3rd option) on the screen
Continue
Name of Table Control: vcontrol (any name)
Continue
Internal Table: it
Table Work Area: wa
Continue
Select Equnr, Edate, Werks, Matnr, Menge, Aufnr, Dept fields
Continue
Input Control
Continue
Scroll
Continue
Continue
Complete
Step-4:
Double click on equnr = equipment number
Double click on edate = eq date
Similarly maintain labels of all the fields
Double click under Department field
Provide drop down list box
Place a push button on top of table control
Double click on push button
Text: Save
FCT Code: SAVE
Flow Logic
Search for MODULE VCONTROL_MODIFY
Double click on VCONTROL_MODIFY
Yes
Place cursor after MODULE VCONTROL MODIFY INPUT
Enter
CASE SY-UCOMM.
WHEN ‘SAVE’.
MODIFY ZPP_EQUIPMENT FROM wa.
IF SY-SUBRC EQ 0.
Ashok
SAP-ADV ABAP
IF SY-SUBRC NE 0.
APPEND wa TO it.
ENDIF.
Activate
During activation you will find an error---controls can only be defined globally
Double click on Error
Copy the lines
CONTROLS: VCONTROL TYPE TABLE VIEW………………..
DATA: G_VCONTROL_LINES LIKE SY-LOOPC
DATA: OK_CODE LIKE SY-UCOMM.
Step-5:
Remove comment for MODULE STATUS_100
Double click on STATUS_100
Yes
Main Program
Yes
Place cursor between MODULE……..ENDMODULE of STATUS_100
CASE SY-UCOMM.
WHEN ‘BUT2’.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘wa-equnr’
OR SCREEN-NAME EQ ‘wa-edate’
OR SCREEN-NAME EQ ‘wa-werks’
OR SCREEN-NAME EQ ‘wa-dept’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
Ashok
SAP-ADV ABAP
ENDIF.
ENDLOOP.
WHEN ‘BUT4’.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘wa-equnr’
OR SCREEN-NAME EQ ‘wa-edate’
OR SCREEN-NAME EQ ‘wa-werks’
OR SCREEN-NAME EQ ‘wa-dept’
OR SCREEN-NAME EQ ‘wa-matnr’
OR SCREEN-NAME EQ ‘wa-menge’
OR SCREEN-NAME EQ ‘wa-aufnr’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDCASE.
Step-6:
Remove comment for SET PF-STATUS ‘BACK’.
Double click on BACK
Yes
Yes
Short Text: Back
Enter
Expand Function Keys
Provide BACK
Activate
Back
Activate program
Back
Step-7:
Remove comment for MODULE USER_COMMAND_100
Double click on USER_COMMAND_100
Yes
Main Program
Enter
Place cursor between MODULE……….ENDMODULE of USER_COMMAND_100
CASE SY-UCOMM.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
Ashok
SAP-ADV ABAP
ENDCASE.
Activate
Step-8:
Double click on 200
Yes
Short Description: Screen 200
Layout
Place Table Control With Wizard (last from 3rd option) on the screen
Continue
Name of Table Control: VCONTROL1
Continue
Internal Program Tabel: it
Table Work Area: wa
Continue
Select all fields (SEL, EQUNR, ……………DEPT)
Continue
Input Control
Scroll
Continue
Continue
Complete
Change the Labels of fields as per requirement
*** select under SEL field & right click
Convert
Check Box
Left Button
Double click under DEPT field
Drop Down
List Box
Close
Place 3 push buttons above Table Control
Provide Text & FCT codes as per requirement
Flow Logic
Step-9:
Remove comment for MODULE STATUS_200
Double click on STATUS_200
Yes
Main Program
Enter
Yes
Place cursor between MODULE…………ENDMODULE of STATUS_200
Ashok
SAP-ADV ABAP
CASE SY-UCOMM.
WHEN ‘BUT3’.
LOOP AT SCREEN.
IF SCREEN-NUMBER EQ ‘wa-qunr’
OR SCREEN-NUMBER EQ ‘wa-edate’
OR SCREEN-NUMBER EQ ‘wa-matnr’
OR SCREEN-NUMBER EQ ‘wa-werks’
OR SCREEN-NUMBER EQ ‘wa-aufnr’
OR SCREEN-NUMBER EQ ‘wa-menge’
OR SCREEN-NUMBER EQ ‘wa-dept’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDCASE.
Activate
Back
Step-10:
Remove comment for MODULE USER_COMMAND_200
Double click on USER_COMMAND_200
Yes
Main Program
Enter
Place cursor between MODULE………ENDMODULE of USER_COMMAND_200
CASE SY-UCOMM.
WHEN ‘DELETE’.
TEXT_BUTTON_2 = ‘No’
IMPORTING
ANSWER = v_ans.
IF v_ans EQ 1.
LOOP AT it INTO wa.
IF wa-sel EQ ‘X’
DELETE FROM ZPP_EQUIPMENT WHERE equnr = wa-equnr.
IF SY-SUBRC EQ 0.
MESSAGE ‘Record deleted’ TYPE ‘S’.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
WHEN ‘SALL’.
LOOP AT it INTO wa.
wa-sel = ‘X’.
MODIFY it FROM wa TRANSPORTING sel
ENDLOOP.
WHEN ‘DSALL’.
LOOP AT it INTO wa.
wa-sel = ‘ ’.
MODIFY it FROM wa TRANSPORTING sel
ENDLOOP.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
Activate
Back
Step-11:
Double click on STATUS_200
Remove comment for SET PF_STATUS ‘BACK1’
Double click on BACK1
Ashok
SAP-ADV ABAP
Yes
Short Text: BACK
Enter
Expand Function Keys option
Type ENTER
Activate
Back
Activate
Back
Activate
Example:
SELECTION-SCREEN PUSHBUTTON 10(10) button1 USER-COMMAND BUT1.
08-10-2014
Note:
SCREEN is a dynamic internal table.
It is used for modifying screen.
Ashok
SAP-ADV ABAP
------Selection-Screen
P_Date 01.10.2014
When you press Add New the Date should transfer to Screen
Screen 100
Screen Making Report
Average
ZPP_SCREEN Table:
Date
Machine
Matnr
Red
Ashok
SAP-ADV ABAP
Blue
Green Total
Solution:
TABLES: YMM_IOFIELDS, SSCRFIELDS
INITIALIZATION:
button1 = ‘Add New’.
button2 = ‘Dispay’.
DATA: v1 TYPE I,
v2 TYPE I,
v3 TYPE I,
redavg TYPE I,
blueavg TYPE I,
greenavg TYPE I.
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM EQ ‘BUT1’.
wa1-edate = p_date.
wa2-edate = p_date.
wa3-edate = p_date.
Ashok
SAP-ADV ABAP
CASE SY-UCOMM.
WHEN ‘SAVE’.
MODIFY YMM_IOFIELDS FROM wa1.
MODIFY YMM_IOFIELDS FROM wa2.
MODIFY YMM_IOFIELDS FROM wa3.
IF SY-SUBRC EQ 0.
MESSAGE ‘Record saved’ TYPE ‘S’.
ENDIF.
WHEN ‘ENTER’.
wa1-total = wa1-red + wa1-blue + wa1-green.
wa2-total = wa2-red + wa2-blue + wa2-green.
wa3-total = wa3-red + wa3-blue + wa3-green.
IF wa1-red IS INITIAL.
v1 = v1 + 1.
ENDIF.
IF wa2-red IS INITIAL.
v1 = v2 + 1.
ENDIF.
Ashok
SAP-ADV ABAP
IF wa3-red IS INITIAL.
v1 = v1 + 1.
ENDIF.
IF wa1-blue IS INITIAL.
v2 = v2 + 1.
ENDIF.
IF wa2-blue IS INITIAL.
v2 = v2 + 1.
ENDIF.
IF wa3-blue IS INITIAL.
v2 = v2 + 1.
ENDIF.
IF wa1-green IS INITIAL.
v3 = v3 + 1.
ENDIF.
IF wa2-green IS INITIAL.
v3 = v3 + 1.
ENDIF.
IF wa3-green IS INITIAL.
v3 = v3 + 1.
ENDIF.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
WHEN ‘CLEAR’.
CLEAR: wa1, wa2, wa3, redavg, blueavg, greenavg.
ENDCASE.
Activate
Ashok
SAP-ADV ABAP
Back
Remove comment for MODULE STATUS_100
Double click on STATUS_100
Remove comment for SET PF-STATUS ‘ENTER’.
Double click on ENTER
Yes
Short Text: Enter
Enter
Expand Function Keys
Type ENTER
Activate
Back
Activate
Back
Activate
Ashok
SAP-ADV ABAP
Assignments:
1. Log sheet Temperature Details
Input:
Furnance
Date
Screen 100
Log Sheet Temparature Details
Average
Ashok
SAP-ADV ABAP
ZLOGSHEET Table:
Furnance
Date
Shift
T1
T2
T3
T4
T5
T6
E1
E2
E3
E4
E5
E6
Solution:
Ashok
SAP-ADV ABAP
Input:
------ Selection-Screen
ZCHEQUE Table:
Cheque Number
Cheque Date
Issue Date
Deposit Date
Realization Date
Customer Number
Cheque Status
Cheque Amount
Solution:
INITIALIZATION.
AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM EQ ‘BUT1’.
ENDLOOP.
ENDLOOP.
CALL SCREEN 100.
ENDIF.
CASE SY-UCOMM.
WHEN ‘SAVE’.
IF SY-SUBRC EQ 0.
MESSAGE ‘Record saved’ TYPE ‘S’.
ENDIF.
ENDCASE.
IF SY-SUBRC NE 0.
APPEND wa TO it.
ENDIF.
CASE SY-UCOMM.
WHEN ‘BUT2’.
LOOP AT SCREEN.
Ashok
SAP-ADV ABAP
IF SCREEN-NAME EQ ‘wa-cheqno’
OR SCREEN-NAME EQ ‘wa-cheqdate’
OR SCREEN-NAME EQ ‘wa-idate’
OR SCREEN-NAME EQ ‘wa-ddate’
OR SCREEN-NAME EQ ‘wa-rdate’
OR SCREEN-NAME EQ ‘wa-custno’
OR SCREEN-NAME EQ ‘wa-cheqstatus’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
WHEN ‘BUT3’.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘wa-cheqno’
OR SCREEN-NAME EQ ‘wa-cheqdate’
OR SCREEN-NAME EQ ‘wa-idate’
OR SCREEN-NAME EQ ‘wa-ddate’
OR SCREEN-NAME EQ ‘wa-rdate’
OR SCREEN-NAME EQ ‘wa-custno’
OR SCREEN-NAME EQ ‘wa-cheqamt’
OR SCREEN-NAME EQ ‘wa-cheqstatus’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDCASE.
CASE SY-UCOMM.
WHEN ‘BACK’.
Ashok
SAP-ADV ABAP
LEAVE TO SCREEN 0.
Ashok
SAP-ADV ABAP
ENDCASE.
3. Simple calculator
Ashok