0% found this document useful (0 votes)
5 views64 pages

Module Pool

The document provides an overview of SAP-ADV ABAP, focusing on Module Pool Programming, Reports, and Object-Oriented ABAP (OOABAP). It includes detailed sections on various topics such as events in module pool programming, flow logic, and debugging techniques, along with practical examples and assignments. The index outlines the structure of the content, covering a wide range of ABAP functionalities and reporting methods.

Uploaded by

itsmeakashv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views64 pages

Module Pool

The document provides an overview of SAP-ADV ABAP, focusing on Module Pool Programming, Reports, and Object-Oriented ABAP (OOABAP). It includes detailed sections on various topics such as events in module pool programming, flow logic, and debugging techniques, along with practical examples and assignments. The index outlines the structure of the content, covering a wide range of ABAP functionalities and reporting methods.

Uploaded by

itsmeakashv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SAP-ADV ABAP

SAP-ADV ABAP

NAME : B V Ashok kumar


TOPICS : MODULE POOL PROGRAMMING
REPORTS
OOABAP

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

36 Customer master details Report 99


37 PP - Movement type wise sale production consumption details for materials 108
Report
38 SD - Sales register report 120
39 SD Flow 122
40 J_1IEXCHDR, VBFA Tables 123
41 VBKD Table 124
42 Material wise Invoice & Realization details Report(Assignment) 124
43 ii) Blocked ALV 125
44 Function Modules for Blocked ALVs 125
45 SD - Invoice details Customer wise, Material wise & Segment wise Report 126
46 iii) Hierarchal Sequential ALV 128
47 MM - PO Price Change Report 128
48 FI Module 136
49 HR Module 139
50 4. Logical Database 145
51 HR - Employee Details Report 145
52 Employee Total Details Report (Assignment) 149
53 5. SAP Query 150
54 Performance Tuning 152
55 Indexing (Primary Index & Secondary Index) 153
56 SQL Tracer 155
57 Runtime Analysis 157
58 ABAP Examples & ABAP Documentation 158
59 Extended Program Check 159
60 Code Inspector 160
61 GET RUN TIME FIELD keyword 161
62 Creating Custom Logical Database 163
63 Material Ageing Report (Assignment) 165
64 Packing Cost Material Report (Assignment) 166
65 Overview of Reports 167
66 OOABAP 168
67 Section of a Class (Class Definition, Class Implementation & Class Execution) 170
68 FI - Statement of Account based on Customer Report 172
69 Local Class 178
70 BSID & BSAD Tables 178
71 Inheritance 179
72 FI - Vendor Aging Report 179
73 BSIT & BSAK Tables 186
74 Abstract Class 187

Ashok
SAP-ADV ABAP

75 Employee Family & Previous Employers Details Report (Assignment) 194


76 Employee Late Coming Report (Assignment) 195
77 Global Class 196
78 Constructor 201
79 Asset Register Report (Assignment) 202
80 PR to GR Report (Assignment) 203
81 Interface Functionality 204
82 Alias 210
83 PP Module 211
84 Event Functionality 213
85 Exception Class 220
86 B) ALV Object Oriented Programming 221
87 Custom Control 221
88 QM - Report for Quality Notifications Report 222
89 PP - Packing cost material report using interactive functionality with 2 custom 226
controls Report
90 MAST, STAS, STOP & MBEW Tables 234
91 Exception Coding 235
92 Button Functionality 236
93 Hyperlinks Functionality 243
94 Questions & Answers 244
95 Module Pool Programming 244
96 Reports 246
97 Interactive Reports 272
98 OOABAP 278

Ashok
SAP-ADV ABAP

MODULE POOL PROGRAMMING


24-09-2014
ABAP Transactions:
 It is also known as Module Pool Programming
 It is also known as Dialog Programming

Transaction:
A transaction is a series of Dialog Steps in which application will accept data from user which
is finally updated to Database

Name1

Ort01 Dialog Programming


Flow Logic
Land1

Display exit

Note:
Flow Logic (Events) acts as interface between Screen Painter & Dialog Programming

Events in Dialog Programming:


1. PAI (Process After Input)
2. PBO (Process Before Output)
3. POH (Process on Help Request)
4. POV (Process on Value Request)

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

2. PBO will brings the data from Program Variables to Screen

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

Flow of Data in Module Pool Programming:

Transfer data from Screen to Program variables


Dialog
Screen Programming

Transfer data from Program Variables to Screen

Function Control Codes:


 It is also known as FCT codes
 Using FCT codes Function Codes can be controlled (or) identified in Module Pool
Programming
SY-UCOMM
Logic Logic

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

4. Run the T code

Ashok
SAP-ADV ABAP

Requirement:

Kunnar

Land1

Name1

Ort01

Pstlz

strs

Display Clear Exit

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.

DATA: BEGIN OF wa_kna1,


Land1 TYPE land1,
Name1 TYPE name1,
Ort01 TYPE ort01,
Pstlz TYPE pstlz,
Stras TYPE stras,
END OF wa_kna1.

 Scroll down to bottom


 Place cursor between MODULE…………ENDMODULE of USER_COMMAND_100.

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.

 Activate the program


 Back (F3)
 Remove comment for MODULE STATUS_100.
 Double click on STATUS_100
 Yes
 Main Program
 Enter
 Enter
 Place mouse pointer between MODULE…………ENDMODULE of STATUS_100

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.

 Activate the program


Ashok
SAP-ADV ABAP

 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)

Debugging a Module Pool Program:


 Go to SE38
 Program: ZSD_CUSTOMER_DETAILS
 Change
 Place cursor at WHEN ‘DISPLAY’.
 Select Stop
 Place cursor between MODULE………..ENDMODULE of STATUS_100.
 Select Stop
 Run T code (ZCUSTOMER)
 Enter

Ashok
SAP-ADV ABAP

Sub Screen Area:


It is a location where sub screens can be called in Main screen

Note:
In SAP you can create only 1 Normal Screen in an application & remaining all are Sub screens

Requirement:

Material Code Material Type

Material Group

Gross Weight

Net Weight

Division

Display Clear Exit Material Description

Sub screen area (sub) sub screen (110)


Main screen (100)

Syntax for Calling Sub Screen in Sub screen area:


CALL SUBSCREEN <sub screen area name> INCLUDING <program name>
<sub screen number>

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

TABLES: MARA, MAKT.

 Place cursor between MODULE……….ENDMODULE of USER_COMMAND_100

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

SELECT SINGLE maktx FROM MAKT INTO MAKT-maktx


WHERE matnr = MARA-matnr
AND spras = ‘EN’.

WHEN ‘CLEAR’.
CLEAR: MARA, MAKT.

WHEN ‘EXIT’.
LEAVE PROGRAM.
ENDCASE.

 Activate program
 Back (F3)
 Place cursor under PROCESS BEFORE OUTPUT

CALL SUBSCREEN SUB INCLUDING ‘ZMM_MATERIAL_SUB’ ‘110’.

 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

Syntax for declaring Table Control:


CONTROLS <table control name> TYPE TABLEVIEW USING SCREEN <screen no>

Object:
Truck Entry Screen

Vendor

DC DC Truck Gross Net Tare PO Vendor


Numbe Date Number weight Weight Weight Numbe number
r r

Display Insert Update Reset Exit

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

 Currency Quantity Fields


Field Reference Table Reference Field
BRGEW EKPO MEINS
TWT EKPO MEINS
NTGEW EKPO MEINS

 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

TABLES: ZMM_DEMO, LFA1.

CONTROLS: vcontrol TYPE TABLEVIEW USING SCREEN ‘100’.


DATA: n TYPE I.
wa_demo TYPE zmm_demo.
it_demo TYPE TABLE OF zmm_demo.

 Activate
 Back (F3)
Ashok
SAP-ADV ABAP

 Right click on ZTCGR function group


 Create
 Screen
 You will find a pop-up
 Program: SAPLZTCGR
 Screen Number: 100
 Enter
 Short Description: Screen 100
 Layout
 F6
 Table Name: LFA1
 Enter
 Select Lifnr
 Enter
 Place the field on top of the screen
 Place a Box on the screen
 Double click on box frame
 Text: Truck Entry
 Close
 Place Table Control (last from 4th option) on the box
 Double click on Table Control
 At bottom under Separators check Vertical & check Horizontal
 Close
 F6
 Table Name: ZMM_DEMO
 Select all fields except MANDT
 Enter
 Place the fields on table control
 Place 5 push buttons under table control
 Provide Text & FCT code as per requirement
 Flow Logic

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.

 Place cursor under PROCESS BEFORE OUTPUT.

LOOP AT it_demo INTO wa_demo WITH CONTROL vcontrol.


MODULE STATUS_100.
ENDLOOP.

 Double click on USER_DML


 Yes
 Enter
 Enter
 Yes

 Place cursor between MODULE………..ENDMODULE of USER_DML

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

 Remove comment for MODULE USER_COMMAND_100.


 Double click on USER_COMMAND_100
 Yes
 Enter
 Enter
 Yes
 Place cursor between MODULE…………..ENDMODULE of USER_COMMAND_100

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.

MODIFY it_demo FROM zmm_demo INDEX vcontrol-current_line.


IF SY-SUBRC NE 0.
APPEND zmm_demo TO it_demo.
ENDIF.

 Activate
 Back (F3)

 Remove comment for MODULE STATUS_100.


 Double click on STATUS_100
 Yes
 Enter
 Enter
 Yes

MOVE wa_demo-dcno TO zmm_demo-dcno.


MOVE wa_demo-dcdate TO zmm_demo-dcdate.
MOVE wa_demo-tno TO zmm_demo-tno.
MOVE wa_demo-brgew TO zmm_demo-brgew.
MOVE wa_demo-twt TO zmm_demo-twt.
MOVE wa_demo-ntgew TO zmm_demo-ntgew.
MOVE wa_demo-ebeln TO zmm_demo-ebeln.
MOVE wa_demo-lifnr TO zmm_demo-lifnr.
Ashok
SAP-ADV ABAP

DESCRIBE TABLE it_demo LINES n.


vcontrol-lines = n. //---it activates vertical scroll bar

 Back (F3)
 Activate screen

 Right click on ZTCGR function group


 Activate
 Enter
 Right click on ZTCGR
 Create
 Transaction
 Transaction Code: ZTRUCK
 Short Text: Truck Entry
 ***Program: SAPLTCGR
 ***Screen Number: 100
 Save

 Run T code (ZTRUCK)

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

Tab Strip Control:


Syntax:
CONTROLS <strip name> TYPE TABSTRIP.

Object:
Former Loan Application

Cooperative Bank

-------- Main Screen 100

Farmer Loan Payment


- Tab Strip

Sub Screen Area

Sub Screen 110


ZFARMER TABLE
FNAME
Account fname fcountry Fcity Postal Tel address
FCOUNTRY number code
FCITY

POSTAL CODE

TEL
Automatically account number should be generated by system
ADDRESS
i.e. 90000001

SAVE

Ashok
SAP-ADV ABAP

Sub Screen 120


ZLOAN Table
A/C NUMBER
A/C FNAME LOAN APPROVE
FNAME
NUMBE AMOUNT
LOAN AMOUNT R

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

Sub Screen 130


A/C NUMBER ZPAYMENT Table

FNAME A/C FNAME LOAN LOAN INTEREST DUE


NUMBER AMOUNT PAID
LOAN AMOUNT
A/C Number field is
mandatory
LOAN PAID
FName, Loan Amount &
InterestINTEREST
fields are in display mode
DUE When you enter Loan Paid & press Calc button Interest will
generated 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

Step-2: Providing Variables & Tables


 Expand Includes
 Double click on Top Include
 Display / Change

TABLES: ZFARMER, ZLOAN, ZPAYMENT.

CONTROLS STRIP TYPE TABSTRIP.

DATA: x TYPE SY-DYNNR VALUE ‘110’.

DATA: days TYPE I,


approve TYPE C.

* for mails
DATA: t_doc TYPE SODOCCHGI1,
t_receive TYPE SOMLRECI1 OCCURS 0 WITH HEADERLINE,
t_text TYPE SOLISTI1 OCCURS 0 WITH HEADERLINE.

DATA: v_interest(10) TYPE C,


v_due(10) TYPE C,
v_paid(10) TYPE C,
text(100) TYPE C.

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)

 Place cursor under USER_COMMAND_100


CALL SUBSCREEN SUB.

 Place cursor under PROCESS BEFORE OUTPUT


CALL SUBSCREEN SUB INCLUDING ‘SAPLZFARMGR’ x.

 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

 Text: Farmer Details


 Close
 F6
 Table Name: ZFARMER
 Enter
 Except Mandt & Acno select all fields
 Enter
 Place the fields on the box
 Place a Push button on the box
 Double click on push button
 Text: Save
 FCT Code: SAVE
 Close
 Flow Logic
 Remove comment for MODULE USER_COMMAND_110
 Double click on USER_COMMAND_110
 Yes
 Enter
 Enter
 Yes
 Place cursor between MODULE……….ENDMODULE of USER_COMMAND_110

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.

 Double click on ZMESS_CLS


 Yes
 Short Text: Message Handling
 Messages tab
 Enter
 Enter
Ashok
SAP-ADV ABAP

000 Successfully generated a/c number &


 Save
 Back (F3)
 Activate
 Back (F3)
 Activate screen
 Back

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

 Place cursor under PROCESS AFTER INPUT

CHAIN.
FIELD: zloan-acno MODULE CHECK ON INPUT,
zloan-lamount.

 Remove comment for MODULE USER_COMMAND_120.


ENDCHAIN.

 Double click on CHECK


 Yes
 Enter
 Enter
 Yes

SELECT SINGLE acno FROM ZFARMER INTO zloan-acno WHERE acno =


zloan-acno.
IF SY-SUBRC NE 0.
MESSAGE ‘Enter Valid Account Number’ TYPE ‘E’.
ENDIF.

 Activate
 Back
 Double click on USER_COMMAND_120.
 Yes
 Enter
 Enter
 Yes
 Place cursor between MODULE……..ENDMODULE of USER_COMMAND_120

SELECT SINGLE fname FROM ZFARMER INTO zloan-fname WHERE acno =


zloan-acno.
CASE SY-UCOMM.
WHEN ‘SAVE’.
zloan-ldate = SY-DATUM.
zloan-approve = APPROVE.
INSERT ZLOAN.
IF SY-SUBRC EQ 0.
MESSAGE ‘Record inserted’ TYPE ‘S’.
ENDIF.
ENDCASE.
Ashok
SAP-ADV ABAP

 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

FIELD: zpayment-acno MODULE CHECK1 ON INPUT,


zpayment-lamount.

 Remove comment for MODULE USER_COMMAND_130


ENDCHAIN.

 Double click on CHECK1


 Yes
 Enter
 Enter
 Yes
 Place cursor between MODULE…………ENDMODULE of USER_COMMAND_130

SELECT SINGLE acno FROM ZLOAN INTO zpayment-acno WHERE acno =


zpayment-acno.
IF SY-SUBRC NE 0.
MESSAGE ‘Enter valid a/c number’ TYPE ‘E’.
ENDIF.

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

CONCATENATE ‘Account Number:’ zpayment-acno INTO TEXT.


APPEND TEXT TO T_TEXT.

CONCATENATE ‘Loan Paid:’ l_paid INTO TEXT.


APPEND TEXT TO T_TEXT.

CONCATENATE ‘Loan Due:’ v_due INTO TEXT.


APPEND TEXT TO T_TEXT.

CONCATENATE ‘Interest Amount:’ v_interest INTO TEXT.


APPEND TEXT TO T_TEXT.

CALL FUNCTION ‘SO_NEW_DOCUMENT_SEND_API1’.


EXPORTING
Document_data = t_doc.
Commit_work = ‘x’.
TABLES
Object-content = t_text.
Receivers = t_receiver.
IF SY-SUBRC EQ 0.
COMMIT WORK.
* push mails to SAP inbox
SUBMIT RSLONN01 WITH MODE = ‘INT’ AND RETURN.
ENDIF.
Ashok
SAP-ADV ABAP

 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

Buffer LFA1 LFAK

VENDOR: 9872 NAME RECON


C CODE: 1000 CITY CASH MANAGEMENT
P ORG: 1000 GROUP
COUNTRY
A/C NUMBER: 0001

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

Advantages & Disadvantages of LUW:


Disadvantage of LUW:
If number of screens increases in an application, interaction between Presentation Server &
Database Server also increases there by reducing the performance of system

Advantage of LUW:
With LUW the data is concisely transferred to Database

Ashok
SAP-ADV ABAP

Table Control Wizard:


 It is advance to Table Control
 In Table Control Wizard most of the logic is already provided by system

Requirement:
Equipment details based on Plant

Input:

Add New Update Delete Display

Equipment Number: To

Equipment Date: To

Plant To

Material Code To

Save

Equi no Equi date Plant Material Quantity Production Dept


code order
5001 1.2.2014 1001 F001 2 3006001 M & pp

Sall dsall delete

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

 Double click on ZDEPT_DAT


 Yes
 Enter
 Yes
 Short Description: Department
 Domain: ZDEPT_DEM
 Double click on ZDEPT_DEM
 Yes
 Short Description: Domain for Department Field
 Data type: CHAR 10
 Value Range tab
Fix val short description
P & Engg Plant & Engg
Mech Mechanical
Prod Production’
Mstores Mould Stroes

 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

Menge EKPO meins


 Activate

Step-2:
 Go to SE38
 Program: ZPP_EQUIPMENT_DETAILS
 Create
 Title: Equipment Details
 Type: Executable Program
 Save

TABLES: ZPP_EQUIPMENT, SSCRFIELDS.

SELECTION-SCREEN: BEGIN OF LINE.


PUSHBUTTON 10(10) BUTTON1 USER-COMMAND BUT1,
PUSHBUTTON 30(10) BUTTON2 USER-COMMAND BUT2,
PUSHBUTTON 50(10) BUTTON3 USER-COMMAND BUT3,
PUSHBUTTON 70(10) BUTTON4 USER-COMMAND BUT4.
SELECTION-SCREEN: END OF LINE.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE screen-000.


SELECT-OPTION: s_equnr FOR zpp_equipment-equnr,
S_edate FOR zpp_equipment-edate,
S_werks FOR zpp_equipment-werks,
S_matnr FOR zpp_equipment-matnr.
SELECTION-SCREEN: END OF BLOCK b1.

INITIALIZATION.
BUTTON1 = ‘Add New’.
BUTTON2 = ‘Update’.
BUTTON3 = ‘Delete’.
BUTTON4 = ‘Display’.

DATA: wa TYPE ZPP_EQUIPMENT,


It TYPE TABLE OF ZPP_EQUIPMENT.

* validate the buttons


AT SELECTION-SCREEN.

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.

LOOP AT it INTO wa.


ENDLOOP.

CALL SCREEN 100.

ELSEIF SSCRFIELDS-UCOMM EQ ‘BUT3’.


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.

LOOP AT it INTO wa.


ENDLOOP.

CALL SCREEN 200.

ELSEIF SSCRFIELDS-UCOMM EQ ‘BUT4’.


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.

LOOP AT it INTO wa.


ENDLOOP.

CALL SCREEN 100.

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

MESSAGE ‘Record saved’ TYPE ‘S’.


ENDIF.
UPDATE ZPP_EQUIPMENT SET erdat = sy-datum ernam = sy-uname
WHERE equnr = wa-equnr.

 Place cursor after MODIFY it FROM wa INDEX VCONTROL-CURRENT_LINE


 Enter

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.

 And remove the 3 lines


 Paste the 3 lines under Declaration
 Activate
 Back

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

DATA: v_ans type C.

CASE SY-UCOMM.
WHEN ‘DELETE’.

CALL FUNCTION ‘POPUP_TO_CONFIRM’


EXPROTING
TITLEBAR = ‘Deletion Conformation’
TEXT_QUESTION = ‘Do you want to delete’
TEXT_BUTTON_1 = ‘Yes’
Ashok
SAP-ADV ABAP

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

Ques: What is the difference between SSCRFIELDS-UCOMM & SY-UCOMM?


Ans:
SSCRFIELDS is a structure for maintaining text for the buttons in SELECTION-SCREEN
SSCRFIELDS-UCOMM returns FCT code for buttons maintained in SELECTION-SCREEN
SY-UCOMM returns FCT code for buttons maintained in SCREEN
SY-UCOMM will works for both Screen & Selection-screen

Syntax for creating Push buttons on selection screen:


SELECTION-SCREEN PUSHBUTTON (size) <button name> USER-COMMAND
<FCT value>.

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.

It is having following fields


1. Group1
2. Group2
3. Group3……………
4. Input
5. Required
6. Invisible
7. Active

Ashok
SAP-ADV ABAP

Input / Output Field:


Object: Screen Making Report
Input:

Add New Display

------Selection-Screen

P_Date 01.10.2014

When you press Add New the Date should transfer to Screen
Screen 100
Screen Making Report

Save Clear Back

Date Machine Material Code Red Blue Green Total

Average

When you press Enter Total & Average display automatically

ZPP_SCREEN Table:
Date
Machine
Matnr
Red
Ashok
SAP-ADV ABAP

Blue
Green Total
Solution:
TABLES: YMM_IOFIELDS, SSCRFIELDS

SELECTION-SCREEN: BEGIN OF LINE.


SELECTION-SCREEN:
PUSHBUTTON 10(10) button1 USER-COMMAND BUT1,
PUSHBUTTON 30(10) button2 USER-COMMAND BUT2.
SELECTION-SCREEN: END OF LINE.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


PARAMETERS p_date TYPE edate.
SELECTION-SCREEN: END OF BLOCK b1.

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.

DATA: wa1 TYPE YMM_IOFIELDS,


wa2 TYPE YMM_IOFIELDS,
wa3 TYPE YMM_IOFIELDS,
it TYPE TABLE OF YMM_IOFIELDS.

AT SELECTION-SCREEN.
IF SSCRFIELDS-UCOMM EQ ‘BUT1’.
wa1-edate = p_date.
wa2-edate = p_date.
wa3-edate = p_date.

CALL SCREEN 100.

ELSEIF SSCRFIELDS EQ ‘BUT2’.


SELECT * FROM YMM_IOFIELDS INTO TABLE it WHERE edate = p_date.

Ashok
SAP-ADV ABAP

READ TABLE it INTO wa1 INDEX 1.


READ TABLE it INTO wa2 INDEX 2.
READ TABLE it INTO wa3 INDEX 3.
ENDIF.

 Double click on 100


 Short Description: Screen 100
 Layout
 Design screen as per requirement
 Flow Logic
 Remove comment for MODULE USER_COMMAND_100
 Double click on USER_COMMAND_100
 Yes
 Enter
 Enter
 Yes
 Place cursor between MODULE…………ENDMODULE

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.

redgavg = ( wa1-red + wa2-red + wa3-red ) / v1.


blueavg = ( wa1-blue + wa2-blue + wa3-blue ) / v2.
greenavg = ( wa1-green + wa2-green + wa3-green ) / v3.

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:

Add New Display


------ Selection-Screen

Furnance

Date

Screen 100
Log Sheet Temparature Details

Furnance Shif Date T1 T2 T3 T4 T5 T6

Average

Booster Holder Temparature Details

Furnance Shif Date E1 E2 E3 E4 E5 E6

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

2. Cheques Date Entry Screen

Input:

------ Selection-Screen

ZCHEQUE Table:
Cheque Number
Cheque Date
Issue Date
Deposit Date
Realization Date
Customer Number
Cheque Status
Cheque Amount

Solution:

TABLES: YMM_CHEQUE, SSCRFIELDS.

SELECTION-SCREEN: BEGIN OF LINE.


Ashok
SAP-ADV ABAP

SELECTION-SCREEN: PUSHBUTTON 10(10) button1 USER-COMMAND BUT1,


PUSHBUTTON 10(10) button2 USER-COMMAND BUT2.
SELECTION-SCREEN: END OF LINE.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.


SELECT-OPTIONS: s_cheqno FOR ymm_cheque-cheqno,
s_chdate FOR ymm_cheque-cheqdate.
SELECTION-SCREEN: END OF BLOCK b1.

INITIALIZATION.

button1 = ‘Add new’.


button2 = ‘Update’.
button3 = ‘Display’.

DATA: wa TYPE YMM_CHEQUE,


it TYPE TABLE OF YMM_CHEQUE.

AT SELECTION-SCREEN.

IF SSCRFIELDS-UCOMM EQ ‘BUT1’.

CALL SCREEN 100.

ELSEIF SSCRFIELDS-UCOMM EQ ‘BUT2’.

SELECT * FROM YMM_CHEQUE INTO TABLE it


WHERE cheqno IN s_cheqno
AND cheqdate IN s_chdate.

LOOP AT it INTO wa.

ENDLOOP.

CALL SCREEN 100.

ELSEIF SSCRFIELDS-UCOMM EQ ‘BUT3’.

SELECT * FROM YMM_CHEQUE INTO TABLE it


WHERE cheqno IN s_cheqno
AND cheqdate IN s_chdate.
LOOP AT it INTO wa.
Ashok
SAP-ADV ABAP

ENDLOOP.
CALL SCREEN 100.

ENDIF.

Double click on 100


Yes
Enter
Enter
Yes
Design screen with table control with wizard as per requirement
Flow Logic
Place cursor between MODULE………..ENDMODULE of VCONTROL_MODIFY INPUT

CASE SY-UCOMM.

WHEN ‘SAVE’.

MODIFY YMM_CHEQUE FROM wa.

IF SY-SUBRC EQ 0.
MESSAGE ‘Record saved’ TYPE ‘S’.
ENDIF.

ENDCASE.

MODIFY it FROM wa INDEX VCONTROL-CURRENT_LINE.

IF SY-SUBRC NE 0.
APPEND wa TO it.
ENDIF.

Place cursor between MODULE……….ENDMODULE of STATUS_100 OUTPUT

SET PF-STATUS ‘BACK’.

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.

Place cursor between MODULE………..ENDMODULE of USER_COMMAND 100

CASE SY-UCOMM.
WHEN ‘BACK’.
Ashok
SAP-ADV ABAP

LEAVE TO SCREEN 0.

Ashok
SAP-ADV ABAP

ENDCASE.
3. Simple calculator

Ashok

You might also like