Академический Документы
Профессиональный Документы
Культура Документы
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@ibm.com’.
* 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
SAP-ADV ABAP
Solution:
REPORTS
ABAP Reports:
In real time ABAP Reports are designed for analysis & based on the that analysis decision
making will done
In real time every report is designed based on certain format & every report have 3 parts
1. Input
2. Processing Logic
3. Output
The reports that will designed up to now are without a proper structured format
Design the same reports in a proper structure format (with events)
Types of Reports:
1. Classical Reports
2. Interactive Reports
3. ALV Reports (ABAP List Viewer)
4. LDB Reports (Logical Data Base) ------- for HR module only
5. SAP Query Reports
Ashok
SAP-ADV ABAP
Classical Reports:
In classical reporting the entire output is maintained in a single list called Basic list
09-10-2014
INITIALIZATION:
It triggers before selection-screen display
Note:
Use this event for initializing
1. Default values in selection-screen
2. Texts on push buttons in selection-screen
3. Texts for blocks, radio buttons, check boxes…………..etc
AT SELECTION-SCREEN:
It triggers once the control leaves from selection-screen & still selection-screen is in active
mode
i.e. It triggers at end of PAI when all the values are passed from selection-screen to program
variables
AT SELECTION-SCREEN OUTPUT:
It triggers after initialization & before selection-screen display
Use this event for modifying selection-screen
Ashok
SAP-ADV ABAP
AT SELECTION-SCREEN ON VALUE-REQUEST:
It triggers when you apply F4 function key on selection-screen fields
Use this event for Search Help
AT SELECTION-SCREEN ON HELP-REQUEST:
It triggers when you apply F1 function key on selection-screen fields
Use this event for Help Documentation
START-OF-SELECTION:
Note:
In your program no need to provide this event
But when you are writing INITIALIZATION (or) AT SELECTION-SCREEN it is mandatory
to use START-OF-SELECTION
END-OF-SELECTION:
It triggers once all the data is read from logical database
Note:
Use this event in HR ABAP for displaying HR data
You can use this event for writing one time logics (Display data…………..etc)
TOP-OF-PAGE:
It triggers before 1st record is output in Output List
Note:
Use this event for maintaining headers in ABAP reports
END-OF-PAGE:
It triggers after last record is output is Output List
Note:
Ashok
SAP-ADV ABAP
Ques-1: Suppose there are 20 pages in my report. How many times INITIALIZATION will
triggers & TOP-OF-PAGE will triggers?
Ans:
INITIALIZATION will triggers only 1 time
TOP-OF-PAGE will triggers 20 times
Example:
REPORT ZEVENTS NO STANDARD PAGE HEADING LINE-COUNT 20(4).
TABLES: EKPO.
INITIALIZATION.
S_werks-low = ‘1000’.
S_werks-high = ‘1001’.
S_werks-sign = ‘I’.
S_werks-option = ‘BT’.
APPEND s_werks.
SELECT matnr FROM MARA INTO TABLE it_mara WHERE mtart IN (‘FERT’)
T1 = ‘Selection’.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘s_werks-low’
OR SCREEN-NAME EQ ‘s_werks-high’
OR SCREEN-NAME EQ ‘s_matnr-low’
OR SCREEN-NAME EQ ‘s_matnr-high’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN ON s_werks.
SELECT werks FROM T001W INTO TABLE it_t001w WHERE werks IN
s_werks.
IF SY-SUBRC NE 0.
MESSAGE ‘Enter valid plant’ TYPE ‘E’ DISPLAY LIKE ‘I’.
LEAVE LIST-PROCESSING.
ENDIF.
START-OF-SELECTION.
Ashok
SAP-ADV ABAP
SELECT ebeln matnr menge netpr FROM EKPO INTO TABLE it_ekpo WHERE
matnr IN s_matnr AND werks IN s_werks.
TOP-OF-PAGE.
WRITE:/40 ‘PO Details Report’ COLOR 1.
SKIP.
ULINE.
END-OF-PAGE.
WRITE:/10 ‘page no’, SY-PAGNO.
Ans:
INITIALIZATION
AT SELECTION-SCREEN OUTPUT
START-OF-SELECTION
Ashok
SAP-ADV ABAP
Object:
PO and Tax Details Report
Input:
S_lifnr (so)
S_werks (so)
S_mtart (so)
S_burks (so)
S_bedat (so)
Output:
Po number
Po date
Vendor name
Vendor number
Po quantity
Unit price
Total price
Unit of measurement
Material code
Material description
VAT
CST
Freight
Processing Logic:
1. Get ebeln bedat matnr menge netpr meins netwr knumv ebelp lifnr from EKKO & EKPO
using inner-joins based on input
2. Pass lifnr of EKKO to lfa1 and get name1
3. Pass matnr of EKPO to MAKT and get maktx
4. Get kumv kposn kschl kwert from KONV by passing knumv of EKKO and ebelp of
EKKO
Solution:
Ashok
SAP-ADV ABAP
INITIALIZATION.
t1 = ‘Selection’.
p_bukrs = ‘1000’.
AT SELECTION-SCREEN.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘p_bukrs’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
PERFORM get_ekko.
PERFORM get_lfa1.
PERFORM get_makt.
PERFORM get_konv.
PERFORM combine_data.
PERFORM display_data.
Ashok
SAP-ADV ABAP
FORM get_ekko.
SELECT ekko~ebeln ekko~bedat ekko~knumv ekko~lifnr
ekpo~matnr ekpo~ebelp ekpo~menge ekpo~netpr ekpo~netwr ekpo~meins
INTO TABLE it_ekko FROM EKKO
INNER JOIN EKPO ON ekko~ebeln = ekpo~ebeln
WHERE ekko~lifnr IN s_lifnr
AND ekko~bukrs EQ p_bukrs
AND ekpo~mtart IN s_mtart
AND ekpo~bedat IN s_bedat.
IF SY-BUBRC NE 0.
MESSAGE ‘Enter valid input’ TYPE ‘E’ DISPLAY LIKE ‘I’.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
FORM get_lfa1.
IF NOT it_ekko IS INITIAL.
SELECT lifnr name1 FROM LFA1 INTO TABLE it_lfa1
WHERE lifnr = it_ekko-lifnr.
ENDIF.
ENDFORM.
FORM get_makt.
IF NOT it_ekko IS INITIAL.
SELECT matnr maktx FROM MAKT INOT TABLE it_makt
FOR ALL ENTRIES IN it_ekko
WHERE matnr = it_ekko-matnr
AND spras EQ ‘EN’.
ENDIF.
ENDFORM.
FORM combine_data.
LOOP AT it_ekko INTO wa_ekko.
wa_final-ebeln = wa_ekko-ebeln.
wa_final-bedat = wa_ekko-bedat.
wa_final-matnr = wa_ekko-matnr.
wa_final-menge = wa_ekko-menge.
wa_final-meins = wa_ekko-meins.
wa_final-netpr = wa_ekko-netpr.
wa_final-netwr = wa_ekko-netwr.
wa_final-knumv = wa_ekko-knumv.
Ashok
SAP-ADV ABAP
wa_final-ebelp = wa_ekko-ebelp.
wa_final-lifnr = wa_ekko-lifnr.
FORM get_konv.
SORT it_final BY knumv ebelp.
FORM displaly_data.
LOOP AT it_final INTO wa_final.
WRITE:/10 wa_final-ebeln,
Ashok
SAP-ADV ABAP
20 wa_final-bedat,
30 wa_final-lifnr,
40 wa_final-name1,
50 wa_final-menge,
60 wa_final-netpr,
70 wa_final-netwr,
80 wa_final-meins,
90 wa_final-matnr,
100 wa_final-maktx,
110 wa_final-vat,
120 wa_final-cst,
130 wa_final-frei.
ENDLOOP.
ENDFORM.
Ashok
SAP-ADV ABAP
10-10-2014
KONV Table:
It is a conditions table for holding tax data.
Fields:
1. KNUMV------ condition number
2. KPOSN ------- item number for condition
3. KSCHL ------- condition / tax type
4. KAWRT------ condition base value
5. KBETR ------ condition rate
6. KWERT ----- condition value
Ashok
SAP-ADV ABAP
Assignment:
Po Delivery Status Report
Input:
S_Lifnr
S_Bedat
P_bukrs
Output:
Po number
Po date
Vendor number
Vendor name
Po quantity
Delivery quantity
Open quantity
Status
Processing Logic:
1. Get ebeln, bedat, lifnr from EKKO based on input
2. Get lifnr, name1 from LFA1 by passing lifnr of EKKO
3. Get ebeln, menge, wemng from EKET by passing ebeln of EKKO
Solution:
Go to SE38
Program: YMM_PO_DELIVERY_STATUS
Create
Package: ZABAP
Enter
Ashok
SAP-ADV ABAP
Interactive Reporting:
In Classical Reporting the entire output is maintained in a single output list called Basic
List.
In Interactive Reporting you will find N number of output lists called Interactive Lists
(or) Secondary Lists.
In one interactive reporting you can maintain 20 secondary lists in sequence.
AT LINE-SELECTION:
It triggers whenever user interacts with a list
HIDE Keyword:
It holds the records selected by user in interactive reporting
SY-LSIND:
It returns current list index
SY-LISEL:
It returns list of contents selected by user from output list
11-10-2014
GET CURSOR keyword:
If fetches the field name & value selected by user from output list
Syntax:
GET CURSOR FIELD <field name> VALUE <value>.
Ashok
SAP-ADV ABAP
SAP Memory:
Using SAP memory concept we can transfer the data from ABAP program to standard
application
Syntax:
SET PARAMETER ID <id> FIELD <value>.
Example:
SET PARAMETER ID ‘mat’ FIELD f001.
Ashok
SAP-ADV ABAP
Object:
Invoice Details based on Customers
Input:
S_kunrg (so) ------ customer number
S_matnr (so)
S_werks (so)
S_ekdat (so) --------- bill date
Output:
Basic list screen 0
Customer Customer Customer Customer Telephone
number name city street number
C001
C002
When you click on C001 then the control will goes to Interactive list 1
Interactive list 1
Bill number Bill date Material Bill quantity Bill amount
code
400103 01.02.2014 100-101 150 120000
400104 10.10.2014 200-201 500 9500000
When you click on 400103 then the control will goes to Interactive list 2
When you click on 200-201 then the control will goes to T code VF03
Interactive list 2
Material code Material text Material type
VF03
Ashok
SAP-ADV ABAP
Solution:
Go to SE38
Program: ZSD_CUSTOMER_INVOICE_DETAILS
Create
Title: Customer Invoice Details Report
Type: Executable Program
Enter
Packge: ZABAP
Enter
Ashok
SAP-ADV ABAP
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
GET CURSOR FIELD v_fnam VALUE v_kunnr.
IF v_fnam EQ wa_kna1-kunnr.
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
EXPORTING
INPUT = v_kunnr
IMPORTING
OUTPUT = v_kunnr.
WHEN 2.
GET CURSOR FIELD v_fnam VALUE v_matnr.
IF v_fnam EQ wa_vbrk-matnr.
ENDIF.
ENDCASE.
TOP-OF-PAGE.
SKIP.
ULINE.
CASE SY-LSIND.
WHEN 1.
WRITE:/50 ‘Customer Invoice Details’ COLOR 1.
SKIP.
ULINE.
WHEN 2.
WRITE:/50 ‘Materials Details’ COLOR 3.
SKIP.
ULINE.
ENDCASE.
Ashok
SAP-ADV ABAP
VBRK Table:
This table holds billing document header data
Fields:
1. VBELN ------- invoice number
2. FKDAT ------- billing type (domestic / export)
3. WAERK ------ document currency
4. VKOGR ------ sales organization
5. VTWEG ------ distribution channel
6. KALSM ------ pricing procedure
7. KNUMV ----- condition number
Link:
VBRK-KNUMV
KONV-KNUMV
VBRP Table:
This table holds billing document item data
Fields:
1. VBELN -------- invoice number
Link:
VBRK-VBELN
VBRP-VBELN
Note:
VGBEL is nothing but delivery document number
ADRC Table:
It holds business addresses
Fields:
1. ADDRNUMBER ---------- address number
Link:
LFA1-ADRNR
KNA1-ADRNR
ADRC-ADDRNUMBER
Ashok
SAP-ADV ABAP
13-10-2014
ALV Reporting:
ABAP List Viewer
ALV is advanced reporting with additional features of reporting
Types of ALVs:
1. Traditional ALV
2. ALV with OOP (Object Oriented Programming)
Traditional ALV:
These are classified into 3 categories
1. Simple ALV
2. Blocked ALV
3. Hierarchal Sequential ALV
Advantages of ALV:
1. In traditional reporting you cannot maintain logos (pictures…………etc)
With ALV reporting you can maintain logos using ALV Function Modules
2. With ALV reporting you can improve performance of programming by avoiding
LOOP…..ENDLOOP
3. Using ALV reporting you can maintain Main Headings, Sub Headings……….etc
4. The main features of reporting are
i) Exporting Data
ii) Totals
iii) Sub Totals
iv) Filtering
v) Column Alignment
vi) Sorting ……………….etc
The above features requires large amount of coding with traditional reporting
Using ALV Function Modules you can minimize such coding
5. Layout Management
With traditional reporting you cannot select output fields dynamically (no layout management)
Suppose in a company there are 10 departments & each department users requires different
fields from the same report
Using layout management you can create & save his own layout
Ashok
SAP-ADV ABAP
Simple ALV:
These are classified into 2 categories
1. Classical ALV
2. Interactive ALV
Classical ALV:
Object:
Open PO Details Report
Solution:
Go to SE38
Program: ZMM_PO_STATUS_DETAILS
Create
Title: PO Status Report
Type: Executable Program
Enter
Package: ZABAP
Enter
TYPE-POOLS SLIS.
Ashok
SAP-ADV ABAP
PERFORM get_ekko.
PERFORM get_lfa1.
PERFORM get_eket.
PERFORM fill_cat.
PERFORM combine_data.
PERFORM layout.
PERFORM display_data.
Ashok
SAP-ADV ABAP
FORM get_ekko.
SELECT ebeln bedat lifnr FROM EKKO INTO TABLE it_ekko
WHERE lifnr IN s_lifnr
AND bukrs IN s_bukrs
AND bedat IN s_bedat.
ENDFORM.
FORM get_lfa1.
IF it_ekko IS NOT INITIAL.
SELECT lifnr name1 FROM LFA1 INTO TABLE it_lfa1
FOR ALL ENTRIES IN it_ekko
WHERE lifnr = it_ekko-lifnr.
ENDIF.
ENDFORM.
FORM get_eket.
IF it_ekko IS NOT INITIAL.
SELECT ebeln menge wemng FROM EKET INTO TABLE it_eket
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
ENDIF.
ENDFORM.
FORM combine_data.
LOOP AT it_eket INTO wa_eket.
wa_final-ebeln = wa_eket-ebeln.
wa_final-eindt = wa_eket-eindt.
wa_final-menge = wa_eket-menge.
wa_final-wemng = wa_eket-wemng.
wa_final-open = wa_eket-menge - wa_eket-wemng.
IF wa_eket_menge GT wa_eket_wemng.
wa_final-status = ‘Not delivered’.
ELSE.
wa_final-status = ‘delivered’.
Ashok
SAP-ADV ABAP
FORM fill_cat.
WA_FCAT-FIELDNAME = ‘ebeln’.
WA_FCAT-SELTEXT_M = ‘PO Number’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘eindt’.
WA_FCAT-SELTEXT_M = ‘Delivery date’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘lifnr’.
WA_FCAT-SELTEXT_M = ‘Vendor Number’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘name1’.
WA_FCAT-SELTEXT_M = ‘Vendor name.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘menge’.
WA_FCAT-SELTEXT_M = ‘Quantity’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘wemng’.
WA_FCAT-SELTEXT_M = ‘Delivery Quantity’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘open’.
WA_FCAT-SELTEXT_M = ‘Open quantity’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘status’.
WA_FCAT-SELTEXT_M = ‘Status’.
APPEND WA_FCAT TO IT_FCAT.
ENDFORM.
Ashok
SAP-ADV ABAP
FORM layout.
WA_LAYOUT-ZEBRA = ‘X’.
WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’.
ENDFORM.
FORM display.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID ----- it returns current program name
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FCAT
I_SAVE = ‘X’.
TABLES.
T_OUTTAB = it_final.
ENDFORM.
Ashok
SAP-ADV ABAP
14-10-2014
Note-1:
REUSE_ALV_GRID_DISPLAY
It is for display the data in ALV grid
The parameters are
1. Current program name
It is important for activating layout management & for displaying logos & headings
5. I_STRUCTURE_NAME
For providing structure
6. I_BACKGROUND_ID
For maintaining background pictures
7. I_GRID_TITLE
For maintaining title in ALV grid
8. IT_SORT
For sorting data & for maintaining sub totals
9. I_SAVE
For saving layouts
10.IT_EVENTS
For events internal table
11.IS_PRINT
For deactivating (or) activating the print mode for PDF formats…………etc
12.T_OUTTAB
For output internal table
Note-2:
SLIS ------- is a Type Group
Type Group:
Ashok
SAP-ADV ABAP
Note-3:
SLIS_FIELDCAT_ALV is a standard SLIS structure with following fields
1. COL_POS ----------- column position
2. FIELDNAME ------ field name of output internal table
3. TABNAME --------- internal table name
4. CHECKBOX ------- with this option you can create check box for a specific field
5. JUST ----------------- it specifies left (or) right format for a specific field
6. NO_ZERO ---------- removes zeros from output list
7. EDIT_MASK ------- it hides the field data
8. NO_OUT ------------ removes a specific field catalog from output list
9. EMPHASIZE ------- it provides a specific default color for a field in ALV grid
10.OUTPUTLEN ------ specifies length (or) size for a catalog
11.SELTEXT_M ------ provides text for a particular field
12.FIX_COLOUMN
13.DECIMALS_OUT -- it round off a particular floating value by removing decimal values
from it
14.EDIT ------------------- by default the field catalogs in a layout are in display mode. Using
this option a field should be converted into change mode
15.HOTSPOT ------------ provides hand symbol
16.DO_SUM ----------- provides totals
Note-4:
SLIS_LAYOUT_ALV is a standard SLIS structure for maintaining layout settings for ALV
reporting
It is having following fields
1. ZEBRA --------- alternate colors
2. COLWIDTH _OPTIMIZE ------- it will optimize the width of field catalog automatically
based on domain length
Ashok
SAP-ADV ABAP
Object:
Restricted & Unrestricted stock details report material wise & plant wise
Input:
S_matnr (so)
S_werks (so)
Output:
Material code
Material description
Hyd uns
Hyd res
Pune uns
Pune res
Total uns
Total res
Total stock
Tables:
MARA
MAKT
MARD
*** Ques-2: This report is already provided by SAP (MMBE). Then why you created it?
Ans:
MMBE is providing materials details plant wise & storage location wise material by material
My client gave a requirement for viewing all restricted & unrestricted stock at one time
Solution:
Go to SE38
Program: ZMM_STOCK_DETAILS_REPORT
Create
Package: ZABAP
Ashok
SAP-ADV ABAP
Enter
TYPE-POOLS SLIS.
Ashok
SAP-ADV ABAP
MARD Table:
It holds storage location data for materials
Fields:
1. MATNR --------- material code
2. WERKS --------- plant
3. LGORT ---------- storage location
4. *** LABST ----- unrestricted stock
5. INSME ---------- stock in quality inspection
6. EINME ---------- total stock of all restricted stock
7. SPEME ---------- blocked stock
8. RETME --------- blocked stock returns
Note:
The above 4 fields combine to form restricted stock
Ashok
SAP-ADV ABAP
15-10-2014
SLIS_SORTINFO_ALV:
It is a standard ALV structure for sorting output list
It is having following fields
1. FIELDNAME -------------- field name for sorting
2. TABNAME ---------------- internal table name
3. UP --------------------------- ascending order
4. DOWN --------------------- descending order
5. SUBTOT ------------------ performs subtotals
SLIS_LISTHEADER:
It is a standard ALV structure for maintaining headings in output list
It is having following fields
1. TYP -------------- type of heading (H, S, A)
2. KEY ------------- text for heading in 20 characters
3. INFO ------------ text for heading in 60 characters
SLIS_ALV_EVENT:
It is a standard ALV structure for maintaining events
It is having following fields
1. NAME ----------- name of event
2. FORM ----------- subroutine name
16-10-2014
Navigation for Maintaining Logos:
Go to Paint
Design a picture
Save it on desktop
Go to OAER
Class Name: Pictures
Class Type: OT
Object Key: ABAP
Execute
At bottom expand Standard Document Types
Double click on Screen
Select your Logo
Enter
Enter
Ashok
SAP-ADV ABAP
Assignment-1:
Monthly sales report based on customers
Input:
S_kunrg -------- customer code
S_werks -------- plant
S_fkart --------- bill type
S_spart --------- division
S_fkdat --------- bill date (01.04.2006 to 30.09.2006)
S_bukrs -------- company code
Output:
Customer code (vbrk-kunrg)
Customer name (kna1-name1)
Apr 06 (vbrp-fkdat)
May 06 (vbrp-fkdat)
Jun 06 (vbrp-fkdat)
July 06 (vbrp-fkdat)
Aug 06 (vbrp-fkdat)
Sep 06 (vbrp-fkdat)
Oct 06 (vbrp-fkdat)
Nov 06 (vbrp-fkdat)
Dec 06 (vbrp-fkdat)
Total
Solution:
Ashok
SAP-ADV ABAP
Assignment-2:
Sales analysis report
Input:
S_kunrg
S_werks
S_fkart
S_bukrs
S_fkdat
S_spart
Output:
Customer name
Today sales --------------- (15.10.2014)
Yesterday sales ---------- (15.10.2013)
Growth -------------------- ((Today sales – Yesterday sales) / Yesterday sales) * 100)
Mtd sales ------------------ (01.10.2014 to 15.10.2014)
Pmtd sales ---------------- (01.10.2013 to 15.10.2013)
Growth -------------------- ((Mtd sales – Pmtd sales) / Pmtd sales) * 100)
Ytd sales ------------------ (01.04.2014 to 15.10.2014)
Pytd sales ----------------- (01.04.2013 to 15.10.2013)
Growth -------------------- ((Ytd sales – Pytd sales) / Pytd sales) * 100)
Solution:
Ashok
SAP-ADV ABAP
Interactive ALV:
Syntax:
FORM <interactive> USING <ucomm> TYPE SY-UCOMM <sel> TYPE
SLIS_SELFIELD.
-------------
-------------
ENDFORM.
Requirement:
Customer master details
Input:
S_kunnr
Customer (button)
Address (button)
Output-1:
Customer number
Customer name
Customer group
Customer group description
Region
Region description
Division
Division description
Output-2:
Customer code
Customer name
Customer city
Customer postal code
Customer Street
Customer telephone number
Interactive Logic:
If I double click on customer code switch to XD03 application
Processing Logic-1:
1. Get kunnr name1 regio from kna1 table based on input
2. Get kunnr spart kdgrp from knvv table by passing kunnr of kna1 table
Ashok
SAP-ADV ABAP
3. Get spart vtext from tspat table by passing spart of knvv table
4. Get kdgrp ktext from t151t table by passing kdgrp of knvv table
5. Get bland bezei from t005u table by passing region of kna1 table
Processing Logic-2:
1. Provide inner join between kna1 table & adrc table (kunnr, name1, city1, post_code1,
street, tel_number)
Solution:
TABLES: KNA1, ADRC.
TYPE-POOLS SLIS.
END OF ty_t151t.
PERFORM get_kna1.
PERFORM get_knvv.
PERFORM get_tspat.
PERFORM get_t151t.
PERFORM get_t005u.
PERFORM get_adrc.
PERFORM combine_data.
PERFORM field_cat.
PERFORM layout.
PERFORM field_event.
PERFORM display_data.
FORM get_kna1.
IF SY-SUBRC NE 0.
MESSAGE ‘Enter valid input’ TYPE ‘E’ DISPLAY LIKE ‘I’.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
FORM get_knvv.
ENDFORM.
FORM get_tspat.
Ashok
SAP-ADV ABAP
ENDFORM.
FORM get_t151t.
ENDFORM.
FORM get_t005u.
ENDFORM.
FORM get_adrc.
ENDFORM.
FORM combine_data.
Ashok
SAP-ADV ABAP
ENDLOOP.
ENDFORM.
FORM FIELD_CAT.
WA_FCAT-FIELDNAME = ‘KUNNR’.
WA_FCAT-SELTEXT_M = ‘customer code’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘NAME1’.
WA_FCAT-SELTEXT_M = ‘name’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘KDGRP’.
WA_FCAT-SELTEXT_M = ‘customer group’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘KTEXT’.
WA_FCAT-SELTEXT_M = ‘customer group description’.
APPEND WA_FCAT TO IT_FCAT.
Ashok
SAP-ADV ABAP
WA_FCAT-FIELDNAME = ‘REGIO’.
WA_FCAT-SELTEXT_M = ‘region’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘BEZEI’.
WA_FCAT-SELTEXT_M = ‘region description’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘SPART’.
WA_FCAT-SELTEXT_M = ‘division’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘VTEXT’.
WA_FCAT-SELTEXT_M = ‘division description’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘KUNNR’.
WA_FCAT-SELTEXT_M = ‘customer code’.
WA_FCAT-TABNAME = ‘it_adrc’
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘NAME1’.
WA_FCAT-SELTEXT_M = ‘name’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘CITY1’.
WA_FCAT-SELTEXT_M = ‘city’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘POST_CODE1’.
WA_FCAT-SELTEXT_M = ‘postal code’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘STREET’.
WA_FCAT-SELTEXT_M = ‘street’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘TEL_NUMBER’.
WA_FCAT-SELTEXT_M = ‘tel_number’.
APPEND WA_FCAT TO IT_FCAT1.
ENDFORM.
Ashok
SAP-ADV ABAP
FORM field_event.
WA_EVENT-NAME = ‘USER_COMMAND’.
WA_EVENT-FORM = ‘INTERACTIVE’.
APPEND wa_event TO it_event.
ENDFORM.
FORM layout.
WA_LAYOUT-ZEBRA = ‘X’.
WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’.
ENDFORM.
FORM display.
IF customer EQ ‘X’.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FCAT
IT_EVENTS = IT_EVENT
I_SAVE = ‘X’
TABLES
T_OUTTAB = it_final.
ELSE.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FCAT1
IT_EVENTS = IT_EVENT
I_SAVE = ‘X’
TABLES
T_OUTTAB = it_adrc.
ENDIF.
ENDFORM.
Ashok
SAP-ADV ABAP
IF SEL-SEL_TAB_FIELD = ‘it_final-kunnr’
OR SEL-SET_TAB_FIELD = ‘it_adrc-kunnr’.
SET PARAMETER ID ‘KUN’ FIELD SEL-VALUE.
CALL TRANSACTION ‘XD03’.
ENDIF.
ENDFORM.
Ashok
SAP-ADV ABAP
17-10-2014
Object:
Movement typewise sale production consumption details for materials
Input:
S_matnr ------------ material code
S_werks ------------ plant
S_bwart ------------ movement type
S_budat ------------ posting date
Input:
Material code
Material description
Plant
Production quantity
Sale quantity
Consumption quantity
Return quantity
Plant wise (button)
Segment wise (button)
All (button)
All Output:
Material code
Ashok
SAP-ADV ABAP
Material description
Division
Division description
Plant
Production (101, 102 movement types)
Sale (601, 602 movement types)
Consumption (261, 262 movement types)
Return quantity (651, 652 movement types)
Tables:
MAKT
MKPF
MSEG
Solution:
ZNP_STOCK_MOVEMENT_DETAILS
TYPE-POOLS SLIS.
START-OF-SELECTION.
PERFORM get_mara.
PERFORM get_mseg.
PERFORM get_tspat.
PERFORM combine_data.
PERFORM combine_data1.
PERFORM fill_cat.
PERFORM layout.
PERFORM fill_event.
PERFORM display_data.
FORM get_mara.
ENDFORM.
FORM get_mseg.
ENDFORM.
FORM get_tspat.
ENDFORM.
FORM combine_data.
ENDFORM.
Ashok
SAP-ADV ABAP
FORM combine_data1.
it_mseg1[ ] = it_mseg[ ].
IF wa_mseg-bwart EQ ‘101’.
wa_final-prod = wa_mara-prod + wa_mseg-menge.
ENDIF.
IF wa_mseg-bwart EQ ‘102’.
wa_mseg-menge = (-1) * wa_mseg-menge.
wa_final-prod = wa_mara-prod + wa_mseg-menge.
ENDIF.
IF wa_mseg-bwart EQ ‘602’.
wa_final-sale = wa_mara-sale + wa_mseg-menge.
ENDIF.
IF wa_mseg-bwart EQ ‘601’.
wa_mseg-menge = (-1) * wa_mseg-menge.
wa_final-sale = wa_mara-sale + wa_mseg-menge.
ENDIF.
IF wa_mseg-bwart EQ ‘262’.
wa_final-cons = wa_mara-cons + wa_mseg-menge.
ENDIF.
IF wa_mseg-bwart EQ ‘261’.
wa_mseg-menge = (-1) * wa_mseg-menge.
wa_final-cons = wa_mara-cons + wa_mseg-menge.
ENDIF.
IF wa_mseg-bwart EQ ‘651’.
Ashok
SAP-ADV ABAP
IF wa_mseg-bwart EQ ‘652’.
wa_mseg-menge = (-1) * wa_mseg-menge.
wa_final-return = wa_mara-return + wa_mseg-menge.
ENDIF.
ENDLOOP.
wa_final-werks = wa_mseg-werks.
MODIFY it_final FROM wa_final TRANSPORTING werks prod cons sale return
WHERE matnr = wa_mseg-matnr.
CLEAR wa_final.
ENDLOOP.
ENDFORM.
FORM fill_cat.
WA_FCAT-FIELDNAME = ‘MATNR’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Material Code’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘MAKTX’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Material description’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘WERKS’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Plant’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘VTEXT’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Segment’.
APPEND WA_FCAT TO IT_FCAT.
Ashok
SAP-ADV ABAP
WA_FCAT-FIELDNAME = ‘PROD’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Production’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘SALE’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Sale’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘CONS’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Consumption’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘RETURN’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Returns’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘MAKTX’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Material description’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘WERKS’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Plant’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘PROD’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Production’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘SALE’.
WA_FCAT-TABNAME = ‘it_final’.
Ashok
SAP-ADV ABAP
WA_FCAT-SELTEXT_M = ‘Sale’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘CONS’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Consumption’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘RETURN’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Returns’.
APPEND WA_FCAT TO IT_FCAT1.
WA_FCAT-FIELDNAME = ‘MAKTX’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Material description’.
APPEND WA_FCAT TO IT_FCAT2.
WA_FCAT-FIELDNAME = ‘VTEXT’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Segment’.
APPEND WA_FCAT TO IT_FCAT2.
WA_FCAT-FIELDNAME = ‘PROD’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Production’.
APPEND WA_FCAT TO IT_FCAT2.
WA_FCAT-FIELDNAME = ‘SALE’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Sale’.
APPEND WA_FCAT TO IT_FCAT2.
WA_FCAT-FIELDNAME = ‘CONS’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Consumption’.
Ashok
SAP-ADV ABAP
WA_FCAT-FIELDNAME = ‘RETURN’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-SELTEXT_M = ‘Returns’.
APPEND WA_FCAT TO IT_FCAT2.
ENDFORM.
FORM layout.
WA_LAYOUT-ZEBRA = ‘X’.
WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’.
ENDFORM.
FORM fill_event.
WA_EVENT-NAME = ‘USER-COMMAND’.
WA_EVENT-FORM = ‘INTERACTIVE’.
APPEND wa_event TO it_event.
ENDFORM.
FORM display_data.
IF p_rb1 EQ ‘X’.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FCAT1
IS_LAYOUT = WA_LAYOUT
IT_EVENTS = IT_EVENT
TABLES
T_OUTTAB = IT_FINAL.
it_final1[ ] = it_final.
Ashok
SAP-ADV ABAP
ENDIF.
ENDFORM.
REFRESH it_final2.
IF SEL-SEL_TAB_FIELD EQ ‘it_final-matnr’.
LOOP AT it_final INTO wa_final WHERE matnr = SEL-VALUE.
APPEND wa_final TO it_final2.
ENDLOOP.
ENDIF.
ENDFORM.
Ashok
SAP-ADV ABAP
Object:
Sales register report
Input:
S_fkart --------- billing type
S_vbeln -------- billing number
S_werks
S_matnr
S_fkdat -------- billing date
S_bukrs
S_spart
Output:
Invoice number
Bill date
Customer number
Customer name
Material number
Material description
Bill quantity
Bill amount
Customer PO number
Customer PO date
Excise number
Excise date
VAT
CST
CForm number
CForm date
Issue date
Delivery number
Sales order number
Note:
In real time vendor bill sell goods to customer to different states. To avail CST benefits
customer will provide a CForm to vendor which is entered into SAP system through report
Processing Logic:
1. Get vbeln fkdat kunrg matnr fkimg netwr knumv posnr based on input from
vbrk & vbrp tables
Ashok
SAP-ADV ABAP
Solution:
ZSD_SALES_REGISTER_SJU
Ashok
SAP-ADV ABAP
SD Flow:
Inquiry
Sales order
Delivery
Invoice
Ashok
SAP-ADV ABAP
18-10-2014
J_1IEXCHDR Table:
It is also called Excise table
It holds invoice header data
Fields:
1. DOCYR ---------- year
2. DOCNO --------- excise document number
3. BUKRS ---------- company code
4. WERKS ---------- plant
5. EXGRP ---------- excise group
6. EXNUM --------- excise number
7. EXDAT --------- excise date
8. LIFNR ----------- vendor number
9. EXBED --------- basic excise duty
10.EXSED --------- special excise duty
11.EXAED -------- additional excise duty
12.CESS ----------- cess amount
13.RDOC --------- reference document (invoice)
Link:
VBRK-vbeln
J_1IEXCHDR-rdoc
VBFA Table:
It holds sales document flow data
In sales document flow, if one document is given you can get other document details from this
table
Fields:
1. VBELN ---------- subsequent document number
2. VBELV ---------- preceding document number
3. VBTYP_N ------ document category of subsequent document
4. RFMNG --------- reference quantity
5. MEINS ---------- unit of measurement
6. RFWRT --------- reference value
7. VBTYP_V ----- document category of preceding document
Ashok
SAP-ADV ABAP
VBKD Table:
It holds sale document business data
Fields:
1. VBELN -------------- sales order number
2. KDGRP ------------- customer group
3. LCNUM ------------ letter of credit number
4. BSTKD ------------- customer PO number
5. BSTKD ------------- customer PO date
Assignment:
Material wise Invoice & Realization details
Input:
S_matnr
S_werks
S_exdat -------invoice date
Tables:
VBRK
VBRD
MAKT
TSPAT
Output:
Material number
Material description
Division description
Remarks
Jan
Feb
March
Total
Solution:
Ashok
SAP-ADV ABAP
20-10-2014
Blocked ALV:
Using Blocked ALVs you can display multiple lists at one place
In real time we are using blocked alvs in few scenarios such as if you want to display
production affiance of different machines of one furnace in one Output list
If client requires invoice details based on customers, materials, segments at one place we
have to work with Blocked ALVs
REUSE_ALV_BLOCK_LIST_INIT:
It initializes lists in blocked alvs
REUSE_ALV_BLOCK_LIST_APPEND:
This function module
1. Maintains field catalogs
2. Maintains data in list
3. Append field catalogs & data with layout
REUSE_ALV_BLOCK_LIST_DISPLAY:
It displays data in list in blocked alvs
Ashok
SAP-ADV ABAP
Requirement:
Invoice details Customer wise, Material wise & Segment wise
Input:
S_kunrg
S_matnr
S_werks
S_bukrs
S_fkdat
Output:
Heading
Customer number Name Total quantity Total value
Heading
Material code Material description Total quantity Total value
Heading
Segment Segment description total quantity Total value
Tables:
VBRK
VBRP
MAKT
KNA1
TSPAT
Solution:
ZSD_AUMR_SALES_CUS_MAT_DIV
Ashok
SAP-ADV ABAP
Note:
REUSE_ALV_BLOCK_LIST_ALV:
It will initialize blocks in blocked alvs
You should pass current program name to this function module
REUSE_ALV_BLOCK_LIST_APPEND:
It maintains blocks with field catalogs with data &
Append field catalog & data to layout
The parameters are
1. Layout work area
2. Field catalog internal table
3. Internal table name
4. Events internal table
5. Output internal table
REUSE_ALV_BLOCK_LIST_DISPLAY:
It will displays the data in output list
No need to pass any parameters to this function module
Note:
In layout work area you should pass INFO-FIELDNAME for displaying row with a specific
color given in output list
Ashok
SAP-ADV ABAP
Requirement:
PO Price Change Report
Input:
S_lifnr
S_matnr
S_mtart
S_werks
S_matkl
S_bedat
Output:
Material code Material description
Sno PO number PO date Vendor name Unit of measurement Quantity
Processing Logic:
1. Get matnr from MARA based on input
2. Get ebeln bedat meins menge matnr netpr lifnr by passing matnr of MARA & based
on input
3. Get lifnr name1 from LFA1 by passing lifnr of EKKO
Solution:
ZMM_PO_PRICE_CHANGE_REPORT
TYPE-POOLS SLIS.
Ashok
SAP-ADV ABAP
END OF ty_final.
DATA: wa_lfa1 TYPE ty_lfa1,
wa_mara TYPE ty_mara,
wa_ekko TYPE ty_ekko,
wa_final TYPE ty_final,
it_lfa1 TYPE TABLE OF ty_lfa1,
it_mara TYPE TABLE OF ty_mara,
it_ekko TYPE TABLE OF ty_ekko,
it_final TYPE TABLE OF ty_final,
it_final1 TYPE TABLE OF ty_final.
PERFORM get_mara.
PERFORM get_ekko.
PERFORM get_lfa1.
PERFORM combine_data.
PERFORM layout.
PERFORM sort.
PERFORM fill_cat.
PERFORM key.
PERFORM display_hierseq.
FORM get_mara.
ENDFORM.
Ashok
SAP-ADV ABAP
FORM get_ekko.
ENDFORM.
FORM get_lfa1.
ENDFORM.
FORM combine_data.
wa_final-maktx = wa_mara-maktx.
cnt = cnt + 1.
wa_final-sno = cnt.
wa_final-key = count.
APPEND wa_final TO it_final.
ENDLOOP.
CLEAR cnt.
count = count + 1.
ENDLOOP.
ENDFORM.
FORM fill_cat.
WA_FCAT-FIELDNAME = ‘MATNR’.
WA_FCAT-SELTEXT_M = ‘Material Code’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘MAKTX’.
WA_FCAT-SELTEXT_M = ‘Material Description’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘SNO’.
WA_FCAT-SELTEXT_M = ‘S.no’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘EBELN’.
WA_FCAT-SELTEXT_M = ‘PO Number’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘BEDAT’.
WA_FCAT-SELTEXT_M = ‘PO Date’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘LIFNR’.
WA_FCAT-SELTEXT_M = ‘Vendor Code’.
Ashok
SAP-ADV ABAP
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘NAME1’.
WA_FCAT-SELTEXT_M = ‘Name’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘MEINS’.
WA_FCAT-SELTEXT_M = ‘Unit of Measurement’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘MENGE’.
WA_FCAT-SELTEXT_M = ‘PO Quantity’.
WA_FCAT-TABNAME = ‘it_final’.
WA_FCAT-DO_SUM = ‘X’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘NETPR’.
WA_FCAT-SELTEXT_M = ‘Unit Price’.
WA_FCAT-TABNAME = ‘it_final’.
APPEND WA_FCAT TO IT_FCAT.
ENDFORM.
FORM sort.
WA_SORT-FIELDNAME = ‘MATNR’.
WA_SORT-TABNAME = ‘it_final1’.
WA_SORT-SUBTOT = ‘X’.
WA_SORT-UP = ‘X’.
APPEND wa_sort TO it_sort.
ENDFORM.
FORM key.
WA_KEY-HEADER01 = ‘KEY’.
WA_KEY-ITEM01 = ‘KEY’.
ENDFORM.
Ashok
SAP-ADV ABAP
FORM layout.
WA_LAYOUT-ZEBRA = ‘X’.
WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’.
ENDFORM.
FORM display-hierseq.
it_final1[ ] = it_final[ ].
ENDFORM.
Ashok
SAP-ADV ABAP
21-10-2014
Note:
SLIS_KEYINFO_ALV:
It holds the Key field details of bifurcation in hierarchal sequential alvs
It is having fields such as
1. HEADER01 -------- header key field
2. ITEM01 ------------- item key field
REUSE_ALV_HIRESEQ_LIST_DISPLAY:
Using this function module you can display the in hierarchal format
The parameters are
1. Current program name
2. Layout work area
3. Field catalog internal table
4. Sorting internal table
5. Layout for sale
6. Events internal table
7. Header internal table name
8. Item internal table name
9. Key work area for bifurcation
10.Header internal table
11.Item internal table
Ashok
SAP-ADV ABAP
FI Module: FICO
Finance & Controlling Module
In every company vendor will sell goods & customer will purchase
In both the cases money inflow & outflow will take place
Then FI module comes into picture
Components in FI Module:
1. Accounting Document Number:
For every finance transaction system will creates an accounting document number
T Codes:
1. FB01
2. FB02
3. FB03
Tables:
1. BKPF
2. BSEG
2. Account Receivable:
This document is created when vendor will receive money form customer
T Codes:
1. F-28
2. FB02
3. FB03
Tables:
1. BSID
2. BSAD
3. Account Payable:
This document is created when customer will pay money to vendor
T Codes:
1. F-43
Ashok
SAP-ADV ABAP
2. FB02
3. FB03
Tables:
1. BSIK
2. BSAK
4. Asset Accounting:
Every company has to purchase assets
All assets are posted to asset accounting
T Codes:
1. AB01
2. AB02
3. AB03
Tables:
1. ANEK
2. ANEP
3. ANLC
4. ANLZ
5. ANKA
5. G/L Account:
General Ledger Account
It is heart of Finance module
All finance transactions are ultimately posted to a specific G/L Accont
G/L Account holds both master data & transactional data
T Codes:
1. FS01
2. FS10N
3. FAGLL03
4. FBL1N
5. FBL3N
6. FBL5N
Tables:
1. SKA1
Ashok
SAP-ADV ABAP
2. SKB1
3. BSIS
4. BSAS
Key field: HKONT, SAKNR
Ashok
SAP-ADV ABAP
HR Module:
Human Resource Module
Components in HR Module:
1. Personal Administration
i) Personal management
ii) Organizational structure
iii) Personality development
iv) Compensation management
v) Recruitment
2. *** Organizational Management
3. *** Payroll
4. Time Management
5. Travel Management
Info Types:
It is a set of related data fields stores information at one place in HR
Every Info type is a 4 letter word
Example:
0008 ------- basic salory
0021 ------- family
0023 ------- previous employers
0006 ------- addresses ……………….etc
Applications in HR Module:
1. PA10
2. PA20
3. *** PA30
4. PA40
5. PA60
6. PA61
7. PC00_M40_CALC
8. PAYPC_RESULTS
Ashok
SAP-ADV ABAP
Tables:
1. PA0001 Info Type:
It is an info type for organizational assignment
Fields:
1. *** PERNR ------------ employee number
2. BUKRS ----------------- company code
3. PERSG ----------------- employee group
4. PERSK ----------------- employee sub group
5. BTRTL ----------------- personal sub area (department)
6. *** ABKRS ----------- payroll area
7. KOSTL ---------------- department
8. SNAME --------------- employee full name
9. ENAME --------------- employee name
Fields:
1. PERNR -------- employee number
2. NACHN ------- last name
3. VORNA ------- first name
4. CNAME------- complete name
5. RUFNM ------- nick name
6. ANRED ------- title
7. GESCH ------- gender
8. *** GBDAT --- date of birth
9. ANZKD -------- number of children
10.FAMST -------- material status
22-10-2014
3. PA0006 Info Type:
It is for Employee addresses
Fields:
1. PERNR ---------- employee number
2. NAME2 --------- C/O name
3. STRAS ---------- street
4. ORT01 ---------- city
5. PSTLZ ---------- postal code
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
Fields:
1. PERNR ---------- employee number
2. BANKS --------- bank country name (sbi, icici)
3. BANKL --------- bank key (fct code)
4. BANKN --------- bank account number
Fields:
1. PERNR ---------- employee number
2. BEGDA --------- start date
3. ENDDA --------- end date
4. LGORT ---------- wage type (salary type )
5. BETRG ---------- amount
Fields:
1. PERNR ----------- employee number
2. BEGDA ---------- retirement date
Fields:
1. PERNR ------------ employee number
2. FGBAT ------------ date of birth of family members
3. FAVOR ------------ first name
4. FANAM ----------- last name
5. SUBTY ------------ sub type
6. OBJPS ------------- object identification
Ashok
SAP-ADV ABAP
Example:
Pernr Subty Objps Fanam
1000 11 (Father) -- suresh
12 (Mother) -- laxmi
1 (Wife) -- sita
2 (children) 01 chinnu
02 banti
Fields:
1. PERNR ---------- employee number
2. ARBGP --------- name of employer (google, tcs)
3. ORT01 ---------- city
4. BRANK -------- industry
5. TAETE --------- job of employee
Fields:
1. PERNR ---------- employee number
2. NMF01 ---------- value (blood group)
3. NMF02 --------- value (height)…………..etc
Fields:
1. PERNR --------- employee number
2. USRTY --------- communication type (phone, email)
3. USRID ---------- communication number
Fields:
1. PERNR ----------- employee number
2. EEPFM ----------- PF account number
3. TSTID ------------ PF trust
4. PFAMT ---------- PF amount
Fields:
1. PERNR ---------- employee number
2. *** ESINO ----- employee state insurance number
3. ESIDP ----------- ESI dispensary (hospital)
Fields:
1. PERNR ---------- employee number
2. LDATE ---------- logical date
3. LTIME ----------- logical time
Fields:
1. PERNR ---------- employee number
2. AWART -------- absence type
3. ABWTG -------- absence days
4. ** ABRTG ----- payroll days
5. ** BEGDA ----- start date
6. ENDDA -------- end date
Example:
Pernr Begda Endda Awart Abwtg Abrtg
1000 01.11.2014 04.11.2014 EL 2 Days 3 Days
(Saturday) (Tuesday)
Ashok
SAP-ADV ABAP
Fields:
1. PERNR ----------- employee number
2. BEGDA ---------- start date
3. ENDDA ---------- end date
4. AWART ---------- attendance type
5. ABWTG ---------- attendance days
6. ABRTG ---------- payroll days
Fields:
1. PERNR ---------- employee number
2. TRFGR ---------- pay scale group
3. LGA01 ---------- wage type (salary type)---DA
4. BET01 ---------- amount for wage type (salary type)
5. LGA02 --------- wage type (salary type)---HRA
6. BET02 --------- amount for wage type (salary type)…………up to 30
Ashok
SAP-ADV ABAP
Logical Database:
Logical database is a special type of program provided by SAP
It collects a group of (or) a set of Related Fields together from Database & supplied it to
Application program
Note:
The T code for working with logical database is SLDB
Object:
Employee Details Report
Input:
S_pernr ---------- Employee number
S_persg --------- Employee group
S_persk --------- Employee sub group
S_abkrs --------- Payroll area
Output:
Employee number
Employee name
Date of joining
Date of birth
Department
Designation
Age
Solution:
Step-1:
Create a structure with output fields
Go to SE11
Structure: ZHR_EMP_STR
Step-2:
Inserting logical database in our program
Go to SE38
Program: ZHR_EMPLOYEE_DETAILS_REPORT
Create
Title: Employee Details Report
Type: Executable Program
*** Logical Database: PNP (It is a special type of program name)
Ashok
SAP-ADV ABAP
Enter
TABLES: PERNR
INFOTYPES: 0001, 0002.
Activate
Back
Attributes
Change
HR Report Category
You will find a pop-up provide Master Data: IE_P35L (for no selection screen display of
PNP program)
Enter
Save
Source Code
Change
ZHR_EMPLOYEE_DETAILS
GET PERNR.
IF SY-SUBRC EQ 0.
PERFORM get_data.
ENDIF.
END-OF-SELECTION.
PERFORM layout.
PERFORM display_data.
FORM get_data.
SELECT SINGLE plstx FROM T528T INTO design WHERE plans = pernr-plans
AND sprsl EQ ‘EN’
AND dept EQ ‘S’.
SELECT SINGLE orgtx FROM T527X INTO dept WHERE orgeh = pernr-orgeh.
wa_final-pernr = p0002-pernr.
Ashok
SAP-ADV ABAP
wa_final-ename = p0002-nachn.
wa_final-doj = hdate.
wa_final-gbdat = p0002-gbdat.
wa_final-dept = dept.
wa_final-age = age.
ENDFORM.
FORM display_data.
ENDFORM.
24-10-2014
Ashok
SAP-ADV ABAP
Assignment:
Employee Total Details Report
Input:
S_pernr --------employee number
S_persg -------- employee group
S_persk -------- employee sub group
S_abkrs -------- payroll area
Output:
Gender (0002)
Number of Children (0002)
Address (0006)
Telephone Number (0105)
Mail Id (0105)
Height (0028)
Weight (0028)
Employee group (0001)
Employee sub group (0001)
Bank account number (0009)
Employee grade (0008)
Solution:
Ashok
SAP-ADV ABAP
SAP Query:
In real time for developing a report it will take lot of time for development
i.e. Requirement ---- Functional Consultant-----Functional Document----Technical
Consultant-----Technical Document------Object Creation------Unit Testing-----
Functional Testing-----User Testing-----go live (transfer to Production)
using SAP Query you can create a report immediately through navigation
Drawbacks:
1. If you want to perform calculations & other complex logics you cannot work with SAP
Query
2. The T code for working SAP Query is SQVI
Example:
Customer Details Report
Ashok
SAP-ADV ABAP
Quick View ---- Additional Funtions -----Display Report Name (copy this name)
Note:
1. You can create SAP Query directly in Production Server in real time
2. Selection screen number is 1000
Ashok
SAP-ADV ABAP
Performance Tuning:
In real time we should create programs according coding standards along with that our program
should show good performance as per performance standards
Ashok
SAP-ADV ABAP
25-10-2014
Indexing:
Indexing is a way of searching
Indexing is a way of improving performance while accessing the data from database
Index:
Index is a copy of a table with reduced fields
Every index table contains
1. Primary key fields,
2. Non Primary key fields &
3. A Pointer field which always points to the position of record
Index takes advantage of sorting using Binary search
Every index contains pointer also
So, that it points to the records of actual table which are not contained in the index table
Types of Indexes:
1. Primary Index
2. Secondary Index
Primary Index:
Primary index contains primary key fields
It always points to non primary key fields
Primary index always take advantage of sorting
Note:
Primary Index is automatically created whenever a table is created in database
Secondary Index:
Secondary index is applied whenever a table will not take the advantage of sorting
Secondary index contains non primary key fields
It always points to primary key fields
Secondary indexes are created
1. On large tables
2. Table which are frequently access
3. Tables having more coloumns
Go to SE11
Database Table: AFRU
Display
Select Indexes
Select Create option
Create Entries
Provide Index: ZAP
You will find a warning there you will find a message “make reports in foreign name
spaces”, Enter
Again you will find a pop-up then select Maintain in Original Language
Provide Short Description: Index for BUDAT field
Field Name: BUDAT
Activate (ctrl+F3)
Ashok
SAP-ADV ABAP
26-10-2014
SQL Tracer: (ST05)
It provides information on
1. SQL statements operated in a program
2. All embedded SQL operations on a table
i.e. prepare
open
cursor
fetch
reopen
3. Number of extracted by SELECT statements
4. Performance time for tables
5. Indexes associated with tables
Example:
Step-1:
Go to ST05
Select Activate Tracer option
Step-2:
Program: any program name
Execute
Provide selection screen input
Execute
Step-3:
Go to ST05
Select Performance Tracer ---------Tracer off
Select Display Tracer option
You will find a pop-up Enter
Here you will find a screen with following fields
1. Duration
2. Object name
3. Operation
4. Number of records
5. Statement
Select Index Fields option ---------- here you will find indexes created in that table
Select Trace List ----- Summarized Trace by SQL Statement --------- here you will find
screen of summarized information of all executions on database table
Select Display Detailed Trace List (F7) --------- here you will find a screen of all summarized
information of all SELECT statements operated in your program
Note:
In real time SQL Tracer is used for identifying
1. The tables
2. The time taken by tables for a specific database operation, based on this we can
identifying whether a table can be Buffered (or) Not
Ashok
SAP-ADV ABAP
Back
Tips & Tricks
Expand SQL Interface option
Double click on Select With Select List
Select Measure Run Time option
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
Example:
Go to SLIN (or)
Go to SE38
Program: any program name
Program ------ Check ------ Extended Program Check
Select last 4 check boxes
Select Execute (F8)
Note:
Try to maintain all options (Internal Errors, Warnings & Messages) as per as possible zeros
Ashok
SAP-ADV ABAP
Example:
Go to SCI
Provide Object Sel Name: ZOBJ
Create
Save
Back
Provide Check Variant Name: ZVAR
Create
Select General Checks, Performance Checks, Syntax Check Generation, Programming
Convention & Internal Performance Test
Save
Back
Provide Inspection Name: ZINS
Create
Select Single: Program: ZSD_SALES_REGISTER
Check Variant: ZVAR
Save
Execute (F8)
Results (shift + F6)
Ashok
SAP-ADV ABAP
Example:
DATA t1 TYPE I.
DO 10 TIMES.
GET RUN TIME FIELD t1.
WRITE:/ t1.
ENDDO.
Activate
Execute
Example:
Ashok
SAP-ADV ABAP
Performance Tuning:
Ashok
SAP-ADV ABAP
Activate
Back
Database Program
Change
Yes
Double click on 1st INCLUDE DBZLD_SDNXXX
You will find 4 includes, double click on 1st include (DBZLD_SDN001)
Remove 1st comment (SELECT * FROM KNA1)
Remove 4th comment (WHERE kunnr IN s_kunnr)
Remove comment for ENDSELECT
Activate
Back
Ashok
SAP-ADV ABAP
Go to SE38
Program: ZCALL_LDB
Create
Title: Calling LDB program
Type: Executable Program
Logical Database: ZLD_SD
Enter
TABLES KNA1.
GET KNA1.
WRITE:/10 kna1-kunnr,
30 kna1-name1,
50 kna1-ort01.
Activate
Execute
Ashok
SAP-ADV ABAP
Assignment-1:
*** Material Ageing Report
Input:
S_matnr
S_werks
S_budat
Output:
Material code
Material description
Last consumption date
0 to 30 days (A30)
31 to 60 days (A60)
61 to 90 days (A90)
91 to 120 days (A120)
121 to 150 days (A150)
151 to 180 days (A180)
>180 days (A181)
Tables:
MKPF
MSEG
MARA
MAKT
Solution:
Ashok
SAP-ADV ABAP
Assignment-2:
Packing Cost Material Report
Input:
S_matnr
S_werks
Output:
Header Data:
Material code
Material description
Item Data:
Bom component
Bom component description
Unit of measurement
Price
Quantity
Tables:
MAST
STAS
MAKT
MBEW
Processing Logic:
1. Get matnr stlnr stlal from mast based on input
2. Get stlnr stlal from stas by passing stlal of mast & stlnr of mast where stlty EQ ‘m’
3. Get stlnr idnrk meins menge from stop by passing stlnr of stas & stlkn of stas where
stlty EQ ‘m’
4. Get matnr verpr from mbew by passing matnr of mast where bwkey IN s_werks
5. Get matnr maktx from makt by passing matnr of mast & spras EQ ‘EN’
6. Get matnr maktx from makt by passing idnrk of stop & spras EQ ‘EN’
Solution:
Ashok
SAP-ADV ABAP
Overview of Reports:
Interview Topics:
1. More than 50 objects
2. System landscape
3. Objects (Ex: Material Ageing Report)
3.1. Inputs
3.2. Outputs
3.3. Tables & Fields
4. Business Process Flows (Ex: MM)
5. Events
5.1. Differences between Events
5.2. Flow of Events
5.3. Usage of Events
6. ALV Reporting
6.1. Field catalogs
6.2. Export & Import parameters
6.3. Function modules
6.4. Blocked ALV
6.5. Hierarchal Sequential ALV
6.6. Interactive ALV
Flow of Events:
Initialization
At selection screen
Start of selection
End of selection
Top of page
Top of page during line selection
End of page
At user command
Ashok
SAP-ADV ABAP
Inheritance:
Creating new objects from existing object is called inheritance
Example:
DATA it_kna1 TYPE TABLE OF KNA1.
Polymorphism:
An identical object behaves differently in different different locations. This concept is called
polymorphism
Example:
VBAK LIKP VBRK
Abstraction:
Hiding the implementation details is called abstraction
Example:
Function module, Include, Sub routine
Encapsulation:
In real world every object acts as a capsule of data
Every object hides the data in such a way that outside world cannot access it.
Ashok
SAP-ADV ABAP
Object:
It is real time entity
It is always created based on a class (object is an instance of a class)
As object is a real time entity memory is allocated by system to an object
Every object holds data in such a way that outside world cannot access
Access Specifiers:
1. Private
2. Protected
3. Public
Private:
Attributes declared under private access specifier can be access only by the methods of that
particular class
Protected:
Attributes declared under protected access specifier can be access by the methods of base class
as well as derived class
Public:
Attributes declared under public access specifier can be access by any object in your program
Note:
Methods should be declared under public access specifier
Types of Classes:
1. Local class
2. Global class
3. Exception class
4. Unit Test class
5. Persistent class
Ashok
SAP-ADV ABAP
Section of a Class:
1. Class Definition
2. Class Implementation
3. Class Execution
Class Definition:
Attributes & Methods are defined under this section
Syntax:
CLASS <class name> DEFINITION.
Example:
CLASS cl_abc DEFINITION.
PUBLIC SECTION.
METHOD: get_data,
combine_data,
display_data.
PRIVATE SECTION.
DATA: var1,
var2.
PROTECTED SECTION.
DATA: var3,
var4.
ENDCLASS.
Class Implementation:
Methods are implemented under this section
Syntax:
CLASS <class name> IMPLEMENTATION.
Example:
CLASS cl_abc IMPLEMENTATION.
METHOD get_data.
------------
------------
Ashok
SAP-ADV ABAP
ENDMETHOD.
METHOD combine_data.
------------
------------
ENDMETHOD.
METHOD display_data.
------------
------------
ENDMETHOD.
ENDCLASS.
Class Execution:
Under this section
1. Objects are defined
2. Objects are created
3. Methods are called
Example:
DATA obj TYPE REF TO cl_abc.
Ashok
SAP-ADV ABAP
Requirement:
Statement of Account based on Customer
Input:
Customer code
Company code
Special G/L indicator
Accounting document number
Posting date
Output:
Customer number
Customer name
Accounting document number
Document date
Document type
Reference document number
Debit
Credit
Over due -------- Total
Solution:
ZFI_STATEMENT_ACCOUNT
TYPE-POOLS SLIS.
PUBLIC SECTION.
METHODS: get_bsid,
Ashok
SAP-ADV ABAP
combine_data,
combine_data1,
fill_cat,
layout,
display_data.
PRIVATE SECTION.
ENDCLASS.
METHOD get_bsid.
SELECT kna1~kunnr kna1~name1 bsid~belnr bsid~blart bsid~bldat bsid~xblnr
bsid~shkzg bsid~dmbtr INTO TABLE it_bsid FROM BSID INNER JOIN KNA1
ON bsid~kunnr = kna1~kunnr
WHERE bsid~kunnr IN s_kunnr
AND bsid~umskz IN s_umskz
AND bsid~budat IN s_budat
AND bsid~bukrs IN s_bukrs
AND bsid~belnr IN s_belnr.
ENDMETHOD.
METHOD combine_data.
SORT it_bsid BY kunnr.
LOOP AT it_bsid INTO wa_bsid.
wa_final-kunnr = wa_bsid-kunnr.
wa_final-name1 = wa_bsid-name1.
wa_final-xblnr = wa_bsid-xblnr.
wa_final-belnr = wa_bsid-belnr.
wa_final-bldat = wa_bsid-bldat.
wa_final-blart = wa_bsid-blart.
IF wa_bsid-shkzg = ‘H’.
wa_final-credit = (-1) * wa_bsid-dmbtr.
ELSE.
wa_final-debit = wa_bsid-dmbtr.
ENDIF.
CLEAR wa_final.
ENDLOOP.
ENDMETHOD.
Ashok
SAP-ADV ABAP
METHOD combine_data1.
SORT it_final BY kunnnr.
AT NEW kunnr.
MOVE wa_final-kunnr TO wa_final1-kunnr.
APPEND wa_final1 TO it_final1.
CLEAR wa_final1.
ENDAT.
wa_final1-name1 = wa_final-name1.
wa_final1-belnr = wa_final-belnr.
wa_final1-bldat = wa_final-bldat.
wa_final1-xblnr = wa_final-xblnr.
wa_final1-blart = wa_final-blart.
wa_final1-debit = wa_final-debit.
wa_final1-credit = wa_final-credit.
wa_final1-due = wa_final-due.
CLEAR wa_final1.
AT END OF kunnr.
SUM.
wa_final1-due = wa_final-due.
wa_final1-kunnr = wa_final-‘Total’.
wa_final1-line_color = ‘C510’.
CLEAR wa_final1.
ENDAT.
AT LAST.
SUM.
wa_final1-due = wa_final-due.
wa_final1-kunnr = wa_final-‘Grand Total’.
wa_final1-line_color = ‘C510’.
Ashok
SAP-ADV ABAP
CLEAR wa_final1.
ENDAT.
ENDLOOP.
ENDMETHOD.
METHOD fill_cat.
wa_fcat-fieldname = ‘KUNNR’.
Wa_fcat-seltext_m = ‘Customer Code’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘NAME1’.
Wa_fcat-seltext_m = ‘Customer Name’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘BELNR’.
Wa_fcat-seltext_m = ‘Accounting Document Number’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘BLDAT’.
Wa_fcat-seltext_m = ‘Document Date’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘BLART’.
Wa_fcat-seltext_m = ‘Document Type’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘XBLNR’.
Wa_fcat-seltext_m = ‘Reference Document Number’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘DEBIT’.
Wa_fcat-seltext_m = ‘Debit’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘CREDIT’.
Wa_fcat-seltext_m = ‘Credit’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘DUE’.
Ashok
SAP-ADV ABAP
METHOD layout.
wa_layout-zebra = ‘X’.
wa_layout-colwidth_optimize = ‘X’.
wa_layout-info_fieldname = ‘LINE_COLOR’.
ENDMETHOD.
METHOD display_data.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
IT_FIELDCAT = IT_FCAT.
IS_LAYOUT = WA_LAYOUT
I_SAVE = ‘X’
TABLES
T_OUTTAB = IT_FINAL1.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
Ashok
SAP-ADV ABAP
27-10-2014
Local Class:
In local class all the 3 sections of a class are maintained in ABAP Editor
Fields:
1. BUKRS ---------- company code
2. KUNNR --------- customer code
3. UMSKZ --------- special G/L indicator
4. ** ZUONR ------ assignment (or) bill number
5. GJAHR ---------- financial year
6. BELNR ---------- accounting document number
7. BUDAT --------- posting date
8. BLDAT --------- bill date
9. XBLNR --------- reference document number
10.BLART --------- document type
11.SHKZG --------- debit (s) / credit (h) indicator
12.**DMBTR ----- amount in local currency
13.HKONT -------- G/L amount
14.**ZFBDT ------ base line date for due date calculation
15.ZTERM -------- payment terms
Ashok
SAP-ADV ABAP
Inheritance:
Creating new objects from existing objects is called inheritance
Requirement:
Vendor Aging Report
Vendor aging report is prepared by customer based on respective vendors
Input:
S_lifnr
S_prctr
S_umskz
S_bukrs
Output:
Vendor code
Vendor name
0-30 days
31-60 days
61-90 days
91-120 days
121-150 days
151-180 days
>-180 days
Total amount
Solution:
ZFI_VENDOR_AGING_REPORTS
TYPE-POOLS SLIS.
INITIALIZATION.
keydate = SY-DATUM.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘keydate’.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
PROTECTED SECTION.
TYPES: BEGIN OF ty_bsik,
belnr TYPE belnr_d,
bldat TYPE bldat,
shkzg TYPE shkzg,
dmbtr TYPE dmbtr,
lifnr TYPE lifnr,
END OF ty_bsik.
DATA n TYPE I.
ENDCLASS.
METHOD get_bsik.
SELECT belnr bldat shkzg dmbtr lifnr FROM BSIK INTO TABLE it_bsik
WHERE lifnr IN s_lifnr
AND bukrs IN s_bukrs
AND prctr IN s_prctr
AND umskz IN s_umskz
AND bldat < keydate.
SELECT belnr bldat shkzg dmbtr lifnr FROM BSAK APPENDING TABLE it_bsik
WHERE lifnr IN s_lifnr
AND bukrs IN s_bukrs
AND prctr IN s_prctr
AND umskz IN s_umskz
AND bldat < keydate
AND augdt > keydate.
Ashok
SAP-ADV ABAP
METHOD combine_data.
SORT it_bsik BY lifnr.
LOOP AT it_lfa1 INTO wa_lfa1.
LOOP AT it_bsik INTO wa_bsik WHERE lifnr = wa_lfa1-lifnr.
IF wa_bsik-zhkzg = ‘H’.
wa_bsik-dmbtr = (-1) * wa_bsik-dmbtr.
ENDIF.
n = keydate - wa_bsik-bldat.
IF n = 0.
CONTINUE.
ENDIF.
ELSEIF n GT 180 .
wa_final-Ag180 = wa_final-ag180 + wa_bsik-dmbtr.
ENDIF.
Ashok
SAP-ADV ABAP
ENDLOOP.
CLEAR wa_final.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
wa_fcat-filename = ‘name1’.
wa_fcat-key = ‘x’.
wa_fcat-seltext_m = ‘vendor name’.
APPEND wa_fcat TO it_fcat.
wa_fcat-filename = ‘a30’.
wa_fcat-do_sum = ‘x’.
wa_fcat-seltext_m = ‘0-30 days’.
APPEND wa_fcat TO it_fcat.
wa_fcat-filename = ‘a60’.
wa_fcat-do_sum = ‘x’.
wa_fcat-seltext_m = ‘31-60 days’.
Ashok
SAP-ADV ABAP
wa_fcat-filename = ‘a90’.
wa_fcat-do_sum = ‘x’.
wa_fcat-seltext_m = ‘61-90 days’.
APPEND wa_fcat TO it_fcat.
wa_fcat-filename = ‘a120’.
wa_fcat-do_sum = ‘x’.
wa_fcat-seltext_m = ‘91-120 days’.
APPEND wa_fcat TO it_fcat.
wa_fcat-filename = ‘a150’.
wa_fcat-do_sum = ‘x’.
wa_fcat-seltext_m = ‘121-150 days’.
APPEND wa_fcat TO it_fcat.
wa_fcat-filename = ‘a180’.
wa_fcat-do_sum = ‘x’.
wa_fcat-seltext_m = ‘151-180 days’.
APPEND wa_fcat TO it_fcat.
wa_fcat-filename = ‘ag180’.
wa_fcat-do_sum = ‘x’.
wa_fcat-seltext_m = ‘> 180 days’.
APPEND wa_fcat TO it_fcat.
wa_fcat-filename = ‘total’.
wa_fcat-do_sum = ‘x’.
wa_fcat-seltext_m = ‘total amount’.
APPEND wa_fcat TO it_fcat.
ENDMETHOD.
METHOD layout.
wa_layout-zebra = ‘x’.
wa_layout-colwidth_optimize = ‘x’.
ENDMETHOD.
METHOD display_data.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
Ashok
SAP-ADV ABAP
I_CALLBACK_PROGRAM = ‘X’
IS_LAYOUT = wa_layout
IT_FIELDCAT = it_fcat
I_SAVE = ‘X’
TABLES
T_OUTTAB = it_final.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA obj TYPE REF TO cl_derived.
Ashok
SAP-ADV ABAP
Fields:
1. LIFNR ----------- vendor code
2. BUKRS ---------- company code
3. KUNNR --------- customer code
4. UMSKZ --------- special G/L indicator
5. ** ZUONR ------ assignment (or) bill number
6. GJAHR ---------- financial year
7. BELNR ---------- accounting document number
8. BUDAT --------- posting date
9. BLDAT --------- bill date
10.XBLNR --------- reference document number
11.BLART --------- document type
12.SHKZG --------- debit (s) / credit (h) indicator
13.**DMBTR ----- amount in local currency
14.HKONT -------- G/L amount
15.**ZFBDT ------ base line date for due date calculation
16.ZTERM -------- payment terms
Ashok
SAP-ADV ABAP
28-10-2014
Abstract Class:
Abstract classes are cannot be implemented
Objects cannot be created for abstract classes
Abstract class methods are also abstract in nature
Derived class can implement abstract class methods by redefining the methods of abstract
class in derived class
Requirement:
Employee Salary & Attendance Details report
Input:
S_pernr --------- employee number
S_persg -------- employee group
S_persk -------- employee sub group
S_abkrs -------- payroll area
S_date --------- period
Attendance (radio button)
Salary (radio button)
Output:
For Attendance:
Employee number
Employee name
Present
Leaves
Rest
Holiday enjoyed
For Salary:
Employee number
Employee name
Date of birth
Basic salary
Da
Hra
Solution:
Go to SE11
Create structure YHR_SAL with following fields
Ashok
SAP-ADV ABAP
Pernr
Ename
Bsal
Da
Hra
Go to SE38
Program: ZHR_ATTEN_SAL_DETAILS
Create
Title: Employee salary & attendance details report
Type: Executable Program
Logical Database: PNP
Enter
Enter
Activate program
Back
Attributes
Change
HR Report Category
Master Data (info types): IE_P35L
Enter
Enter
Source Code
Change
TABLES: PERNR.
Ashok
SAP-ADV ABAP
PUBLIC SECTION.
METHODS: get_emp ABSTRACT IMPORTING pernr TYPE person,
display_data ABSTRACT.
PROTECTED SECTION.
DATA: wa_sal TYPE yhr_sal,
wa_atten TYPE yhr_atten,
it_sal TYPE TABLE OF yhr_sal,
it_atten TYPE TABLE OF yhr_atten,
gwa_tim TYPE hrf_tim_b2,
wa_ph TYPE ptr_f_psp,
wa_ab TYPE ptr_f_ab,
wa_tp TYPE ptr_f_tp,
rest TYPE I,
present TYPE I,
el TYPE I,
wrk TYPE I,
he TYPE I.
ENDCLASS.
PUBLIC SECTION.
METHODS: get_emp REDEFINITION,
display_data REDEFINITION.
ENDCLASS.
METHOD get_emp.
Ashok
SAP-ADV ABAP
Wrk = wrk + 1.
IF wa_psp-trprog = ‘OFF’.
Rest = rest + 1.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD display_data.
Ashok
SAP-ADV ABAP
ENDMETHOD.
ENDCLASS.
PUBLIC SECTION.
METHODS: get_emp REDEFINITION,
display_data REDEFINITION,
calc_sal,
hold_sal.
ENDCLASS.
METHOD get_emp.
wa_sal-pernr = pernr.
wa_sal-ename = p0002-nachn.
ENDMETHOD.
METHOD calc_sal.
CASE p_lgart.
WHEN ‘MA90’.
wa_sal-bsal = p_betrg.
WHEN ‘MA80’.
wa_sal-da = p_betrg.
WHEN ‘MA70’.
wa_sal-hra = p_betrg.
ENDCASE.
ENDMETHOD.
METHOD hold_sal.
APPEND wa_sal TO it_sal.
ENDMETHOD.
METHOD display_data.
Ashok
SAP-ADV ABAP
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: obj TYPE REF TO cl_atten,
obj1 TYPE REF TO cl_sal.
IF p_rb1 EQ ‘X’.
CREATE OBJECT obj.
ELSE.
CREATE OBJECT obj1.
ENDIF.
GET PERNR.
CHECK pernr-pernr IN s_pernr.
IF SY-SUBRC EQ 0.
IF p_rb1 EQ ‘X’.
CALL METHOD obj->get_emp
EXPORTING
Pernr = pernr-pernr.
ENDDO.
ENDIF.
ENDIF.
END-OF-SELECTION.
IF p_rb1 EQ ‘X’.
CALL METHOD obj->display_data.
ELSE.
CALL METHOD obj1->display_data.
ENDIF.
Ashok
SAP-ADV ABAP
Assignment:
Employee Family & Previous Employers Details Report
Input:
S_pernr
S_persg
S_abkrs
Experience (radio button)
Family (radio button)
Output:
Experience:
Employee number
Employee name
Date of birth
Previous experience
Current experience
Total experience
Family:
Employee number
Employee name
Father
Mather
Spouse
Child1
Child2
Solution:
Ashok
SAP-ADV ABAP
Assignment:
Employee Late Coming Report
Input:
S_pernr
S_persg
S_abkrs
S_period
Output:
Employee number
Employee name
Department
Date
In time
Late
Solution:
Ashok
SAP-ADV ABAP
29-10-2014
Global Class:
In global class CLASS DEFINITION & CLASS IMPLEMENTATION parts are maintained
in Class Builder (SE24) & Execution part is maintained in ABAP Editor (SE38)
Requirement:
Asset Acquisition Date Report
Input:
Asset number
Output:
Asset number
Sub asset number
Acquisition date
Tables:
ANLA
Solution:
Step-1: creating Structure & Table Type
Go to SE11
Data Type: ZFI_ASSET
Create
** Structure
Enter
Short Description: Structure for Asset fields
Component Component Type
ANLN1 ANLN1
ANLN2 ANLN2
ZUGDT ZUGDT
Activate
Back
Data Type: ZFI_TAB
Create
** Table Type
Enter
Short Description: Table Type for Asset
** Line Type: ZFI_ASSET
Ashok
SAP-ADV ABAP
Activate
Methods tab
Method level visibility description
CONSTRUCTOR INSTANCE PUBLIC default method
Methods
Double click on CONSTRUCTOR
Yes
Place cursor between METHOD…………..ENDMETHOD
A_LOW = ASSET_LOW.
A_HIGH = ASSET_HIGH.
Activate
Back
Method level visibility description
GET_DATA INSTANCE PUBLIC method for getting data
Activate
Back
Method level visibility description
GET_DATA INSTANCE PUBLIC method for getting data
Activate
Back
Method level visibility description
LAYOUT INSTANCE PUBLIC method for layout management
WA_LAYOUT-ZEBRA = ‘X’.
WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’.
Activate
Back
Method level visibility description
FILL_CAT INSTANCE PUBLIC method for field catalogs
WA_FCAT-FIELDNAME = ‘ANLN1’.
WA_FCAT-SELTEXT_M = ‘Asset Number’.
APPEND WA_FCAT TO IT_FCAT.
Ashok
SAP-ADV ABAP
WA_FCAT-FIELDNAME = ‘ANLN2’.
WA_FCAT-SELTEXT_M = ‘Sub Asset Number’.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME = ‘ZUGDT’.
WA_FCAT-SELTEXT_M = ‘Acquisition Date’.
APPEND WA_FCAT TO IT_FCAT.
Activate
Back
Method level visibility description
DISPLAY_DATA INSTANCE PUBLIC method for displaying output list
Activate
Back
Activate
TABLES: ANLA.
Asset_low = s_anln1-low.
Asset_high = s_anln1-high.
Pattern
ABAP object patterns
Enter
Call Method
Instance: obj
Class: ZCL_ASSET_CLASS
Method: get_data
Enter
Activate
Execute
Provide input
Execute
Ashok
SAP-ADV ABAP
30-10-2014
Constructor:
Constructor is a default method in Object Oriented ABAP
It is called automatically whenever object is created
Use this method for initializing values in Object Oriented ABAP
Ashok
SAP-ADV ABAP
Assignment:
Asset Register Report
Input:
S_anln1
S_bukrs
Output:
Asset number (anln1)
Sub asset number (anln2)
Company code (bukrs)
Plant (werks)
Capitalization date (aktlv)
Asset description (txt50)
Acquisition value (kansw)
Accumulated depreciated (knafa)
Asset location (start)
Asset class (anlkl)
Quantity (menge)
Unit of measurement (meins)
Currency (waers)
Tables:
ANLC
ANLA
ANLB
T499S
T093B
Solution:
Ashok
SAP-ADV ABAP
Assignment:
PR to GR Report
Input:
S_pr number
S_pr date
Output:
Pr number
Pr quantity
Item text
Vendor number
Vendor name
Material number
Material description
Po number
Po quantity
Gr number
Gr quantity
Pending pr
Pending po
Solution:
Ashok
SAP-ADV ABAP
Interface Functionality:
It is a template which extends the scope of a class & implements polymorphism
Instances cannot be created based on interface
Interface methods are always implemented in other class
Requirement:
Input:
S_sales order
Deliver (radio button)
Invoice (radio button)
Solution:
Step-1: creating Structure & Table Type
Go to SE11
Data Type: ZSD_LIKP
Create
** Structure
Enter
Short Description: Structure for Delivery fields
Component Component Type
VBELN VBELN_VF
LFDAT LFDAT
MATNR MATNR
LFIMG LFIMG
Activate
Back
Data Type: ZSD_LIKPTAB
Create
Ashok
SAP-ADV ABAP
** Table Type
Enter
Short Description: Table Type for LIKP
** Line Type: ZSD_LIKP
Activate
Activate
Back
Data Type: ZSD_VBRKTAB
Create
** Table Type
Enter
Short Description: Table Type for VBRK
** Line Type: ZSD_VBRK
Activate
Attributes tab
Attribute level visibility associated type
WA_VBELN INSTANCE PUBLIC VBELN
Methods tab
Method level visibility description
GET_DATA INSTANCE PUBLIC method for getting data
DISPLAY_DATE INSTANCE PUBLIC method for displaying data
Activate
Back
Object Type: ZCL-DEL_CLASS
Create
Description: Delivery class
Enter
Enter
Attributes tab
Attribute level visibility associated type
IT_LIKP INSTANCE PRIVATE ZSD_LIKPTAB
Interfaces
Interface methods description
ZINT_DEL_INV
Methods
Double click on GET_DATA
Yes
Place cursor between METHOD…………..ENDMETHOD
ON likp~vbeln = lips~vbeln
WHERE likp~vbeln = zint_del_inv~wa_vbeln.
ENDIF.
Activate
Back
Method level visibility description
DISPLAY_DATA INSTANCE PUBLIC method for displaying output list
Activate
Back
Activate
Interfaces
Interface methods description
ZINT_DEL_INV
Methods
Double click on GET_DATA
Yes
Place cursor between METHOD…………..ENDMETHOD
Activate
Back
Method level visibility description
DISPLAY_DATA INSTANCE PUBLIC method for displaying output list
Activate
Back
Activate
IF p_rb1 EQ ‘X’.
CALL METHOD obj1->zint_del_inv~get_data
EXPORTING
P_vbeln = p_order.
ELSE.
CALL METHOD obj2->zint_del_inv~get_data
EXPORTING
P_vbeln = p_order.
Activate
Execute
Provide input
Execute
Ashok
SAP-ADV ABAP
31-10-2014
Alias:
Go to SE24
Object Type: ZCL_DEL_CLASS
Change
Aliases
Method alias name visibility
Zint_del_inv~get_data sel1 public
Zint_del_inv~display_data sel public
Activate
Go to SE38
Program: ZSD_DEL_BILLING_DETAILS
Change
Ashok
SAP-ADV ABAP
PP Module:
Production & Planning Module
BOM:
Every main material is having sub components (sub materials) called BOM
Costing department should calculate main material cost as well as sub material cost also
T Codes:
CS01, CS02, CS03
Tables:
MAST, STOP, STKO
Key Field:
Stlnr
Routing:
These are the sequence of operations performed on a material in order to manufacture it
T Codes:
CA01, CA02, CA03
Tables:
PLKO, PLPO, PLMZ
Work Center:
It is a place where operations are carried out
T Codes:
CR01, CR02, CR03
Tables:
CRHD
Production Order:
Ashok
SAP-ADV ABAP
In order to produce finished goods sales department have to give (or) raise production order to
production department
T Codes:
CO01, CO02, CO03, COLLN
Tables:
AFKO, AFPO, AFRU
Key Field:
Aufnr
Types of Planning:
1. MRP (Material Requirement Planning)
2. Demand
3. Sales & Operations
4. Capacity
Process Flow:
Customers
Marketing
Ashok
SAP-ADV ABAP
Event Functionality:
In Object Oriented ABAP events will trigger & at the same time respective method will
be executed
In Object Oriented ABAP every event is having Event Handler (Method) which is
executed whenever the event is fired
Requirement:
Production Details based on Production Order
Input:
P_furnance
P_plant
S_posting date
Output:
Purchase order number
Posting date
Production start date
Production end date
Material number
Production quantity
Solution:
Step-1: creating Structure & Table Type
Go to SE11
Data Type: ZPP_AFRU
Create
** Structure
Enter
Short Description: Structure for Order fields
Component Component Type
AUFNR AUFNR
BUDAT BUDAT
LMNGA RU_LMNGA
EKPO MEINS
Activate
Back
Data Type: ZPP_AFRUTAB
Create
** Table Type
Enter
Short Description: Table Type for AFRU
** Line Type: ZPP_AFRU
Activate
Back
Activate
Back
Data Type: ZPP_AFKOTAB
Create
** Table Type
Enter
Short Description: Table Type for AFKO
** Line Type: ZPP_AFKO
Activate
Back
BUDAT BUDAT
GSTRI CO_GSTRI
GLTRI CO_GLTRI
PLNBEZ MATNR
LMNGA RU_LMNGA
Activate
Back
Data Type: ZPP_FINALTAB
Create
** Table Type
Enter
Short Description: Table Type for FINAL
** Line Type: ZPP_FINAL
Activate
Back
Events tab
Event level visibility Description
CHECK_DATA INSTANCE PUBLIC checking data
Methods tab
Ashok
SAP-ADV ABAP
Methods
Double click on GET_AFRU
Yes
Place cursor between METHOD………..ENDMETHOD
IF SU-SUBRC NE 0.
RAISE EVENT CHECK_DATA.\
ENDIF.
Activate
Back
Double click on NO_DATA
Place cursor between METHOD………..ENDMETHOD
Ashok
SAP-ADV ABAP
Activate
Back
Method level visibility description
GET_AFKO INSTANCE PUBLIC method for getting afko data
Activate
Back
ENDLOOP.
Activate
Back
Ashok
SAP-ADV ABAP
WA_LAYOUT-ZEBRA = ‘X’.
WA_LAYOUT-COWIDTH_OPTIMIZE = ‘X’.
Activate
Back
Activate
Back
Activate
TABLES AFRU.
Ashok
SAP-ADV ABAP
Exception Class:
In real time you will find number of exceptions (Run time errors) such as
1. Time out exception
2. SQL statement exception
3. Division by zero exception
4. No convert number exception
5. Type conflict exception
6. BCD overflow exception
7. *** Storage exception for internal table
For all the above exceptions SAP is providing standard exception classes
Exception class starting with prefix ‘CX’
These exception classes should be provided with in TRY……………ENDTRY using
CATCH keyword
Example:
DATA: v1 TYPE I VALUE 0,
v2 TYPE I,
v3 TYPE I.
TRY.
v3 = v1 / v2.
CATCH CX_SY_ZERODIVIDE.
MESSAGE ‘Division by zero exception’ TYPE I.
ENDTRY.
Ashok
SAP-ADV ABAP
All these features are maintained by using a control called List Viewer Control
SLV is totally based on Object Oriented Programming
01-11-2014
Custom Control:
Step-2:
Display control in the location identified using class CL_GUI_AVL_GRID
Step-3:
Display data in the control using method SET_TABLE_FOR_FIRST_DISPLAY of
CL_GUI_GRID class
Ashok
SAP-ADV ABAP
Requirement:
Report for Quality Notifications
Input:
S_date
Output:
Notification number
Complaint text
Date
Material code
Solution:
Go to SE38
Program: ZQM_QUALITY_NOTIF
Create
Title: Quality Notifications
Type: Executable Program
Enter
Enter
TABLES QMEL.
Ashok
SAP-ADV ABAP
PERFORM get_qmel.
PERFORM layout.
PERFORM fill_cat.
CALL SCREEN 100.
FORM get_qmel.
SELECT qmnum qmtxt erdat matnr FROM QMEL INTO TABLE it_qmel
WHERE erdat IN s_erdat.
ENDFORM.
FORM layout.
WA_LAYO-ZEBRA = ‘X’.
WA_LAYO-CWIDTH_OPT = ‘X’.
ENDFORM.
FORM fill_cat.
wa_fcat-fieldname = ‘QMNUM’.
wa_fcat-scrtext_m = ‘Notification Number’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘QMTXT’.
wa_fcat-scrtext_m = ‘Complaint Text’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘ERDAT’.
wa_fcat-scrtext_m = ‘Date’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘MATNR’.
wa_fcat-scrtext_m = ‘Material Number’.
APPEND wa_fcat TO it_fcat.
ENDFORM.
Activate
Double click on 100
Yes
Short Description: Screen 100
Ashok
SAP-ADV ABAP
Layout
Place Custom Control on the screen
Double click on Custom Control
name: container
Close
Flow Logic
Remove comment for MODULE STATUS_100
Double click on STATUS_100
Yes
Main Program
Enter
Place cursor between MODULE…………ENDMODULE of STATUS_100
IF SY-SUBRC EQ 0.
CREATE OBJECT grid
EXPORTING
I_PARENT = container.
IF SY-SUBRC EQ 0.
CALL METHOD grid->set_table_for_first_display
EXPORTING
IS_LAYOUT = wa_layo
CHANGING
IT_FIELDCATALOG = it_fcat
IT_OUTTAB = it_qmel.
ENDIF.
ENDIF.
Activate
Back
CASE SY-UCOMM.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
ENDCASE.
Activate
Back
Activate
Back
Execute
Provide input
Execute
Ashok
SAP-ADV ABAP
Assignment:
Packing cost material report using interactive functionality with 2 custom controls
Input:
S_matnr
S_werks
Output:
Material code
BOM component
Material description
BOM component description
BOM quantity
Amount
Interactive Logic:
If I double click on any material I should switch to MM03 along with material code
Solution:
ZPP_BOM_DETAILS
TYPE-POOLS SLIS.
END METHOD.
END CLASS.
START-OF-SELECTION.
PERFORM get_mast.
PERFORM get_stas.
PERFORM get_stpo.
PERFORM get_makt.
PERFORM get_mbew.
PERFORM combine_data.
Ashok
SAP-ADV ABAP
PERFORM sort.
PERFORM layout.
PERFORM fill_cat.
CALL SCREEN 100.
FORM get_mast.
SELECT matnr stlnr stlal FROM MAST INTO TABLE it_mast
WHERE matnr IN s_matnr
AND werks IN s_werks.
ENDFORM.
FORM get_stas.
IF NOT it_mast IS INITIAL.
SELECT stlnr stlal stlkn FROM STAS INTO TABLE it_stas
FOR ALL ENTRIES IN it_mast
WHERE stlnr = it_mast-stlnr
AND stlty EQ ‘M’.
ENDIF.
ENDFORM.
FORM get_stpo.
IF NOT it_stas IS INITIAL.
SELECT stlnr ldnrk menge FROM STOP INTO TABLE it_stpo
FOR ALL ENTRIES IN it_stas
WHERE stlnr = it_stas-stlnr
AND stlkn = it_stas-stlkn
AND stlty EQ ‘M’.
ENDIF.
ENDFORM.
FORM get_makt.
IF NOT it_mast IS INITIAL.
SELECT matnr maktx FROM MAKT INTO TABLE it_makt
FOR ALL ENTRIES IN it_mast
WHERE matnr = it_mast-matnr
AND spras EQ ‘EN’.
ENDIF.
FORM get_mbew.
IF NOT it_stpo IS INITIAL.
SELECT matnr verpr FROM MBEW INTO TABLE it_mbew
FOR ALL ENTRIES IN it_stpo
WHERE matnr = it_stpo-ldnrk.
ENDIF.
ENDFORM.
FORM combine_data.
LOOP AT it_mast INTO wa_mast.
LOOP AT it_stpo INTO wa_stpo WHERE stlnr = wa_mast-stlnr.
wa_final-matnr = wa_mast-matnr.
ENDLOOP.
ENDFORM.
FORM fill_cat.
wa_fcat-fieldname = ‘MATNR’.
wa_fcat-seltext_m = ‘Material Code’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘MAKTX’.
wa_fcat-seltext_m = ‘Material Description’.
APPEND wa_fcat TO it_fcat.
Ashok
SAP-ADV ABAP
wa_fcat-fieldname = ‘IDNRK’.
wa_fcat-seltext_m = ‘BOM Component’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘MAKTX1’.
wa_fcat-seltext_m = ‘BOM Component Description’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘MENGE’.
wa_fcat-seltext_m = ‘Quantity’.
wa_fcat-do_sum = ‘X’.
APPEND wa_fcat TO it_fcat.
wa_fcat-fieldname = ‘VERPR’.
wa_fcat-seltext_m = ‘Amount’.
wa_fcat-do_sum = ‘X’.
APPEND wa_fcat TO it_fcat.
ENDFORM.
FORM sort.
wa_sort-fieldname = ‘MATNR’.
wa_sort-up = ‘X’.
wa_sort-subtot = ‘X’.
APPEND wa_sort TO it_sort.
ENDFORM.
FORM layout.
wa_layout-zebra = ‘X’.
wa_layout-colwidth_optimize = ‘X’.
ENDFORM.
Main Program
Enter
Place cursor between MODULE…………..ENDMODULE
wa_header-typ = ‘H’.
wa_header-info = ‘Reddy Labs’.
APPEND wa_header TO it_header.
wa_header-typ = ‘S’.
wa_header-info = header.
APPEND wa_header TO it_header.
IF SY-SUBRC NE 0.
CREATE OBJECT grid
EXPORTING
I_PARENT = container.
IF SY-SUBRC EQ 0.
CALL METHOD grid->set_table_for_first_display
EXPORTING
I_SAVE = ‘X’
IS_LAYOUT = wa_layout
CHANGING
IT_OUTTAB = it_final
IT_FIELDCATALOG = it_fcat
IT_SORT = it_sort.
Ashok
SAP-ADV ABAP
CASE SY-UCOMM.
WHEN ‘&F03’.
LEAVE TO SCREEN 0.
ENDCASE.
Ashok
SAP-ADV ABAP
03-11-2014
MAST Table:
It holds material header data
Fields:
1. MATNR ------------ material number
2. WERKS ------------ plant
3. STLAN ------------- BOM usage
4. STLAL ------------- alternate BOM
5. STLNR ------------- BOM number
STAS Table:
It holds items in BOM
Fields:
1. STLTY ------------ BOM category
2. STLNR ------------ BOM number
3. STLAL ------------ alternate BOM
4. STLKN ----------- BOM item number
STPO Table:
It holds BOM item data
Fields:
1. STLTY ------------ BOM category
2. STLNR ------------ BOM number
3. STLKN ----------- BOM item number
4. IDNRK ----------- BOM component (MATNR)
5. MENGE --------- quantity
6. MEINS ---------- unit of measurement
MBEW Table:
It holds material valuation data
Fields:
1. MATNR ---------- material number
2. BWKEY ---------- plant
3. LBKUM ---------- total stock
4. SALK3 ----------- total value
5. VERPR ---------- moving average price
Ashok
SAP-ADV ABAP
Exception Coding:
Using Exception coding you can display color in ALV OOPs
For displaying color you can add a field called exception using standard field EXCP-
FNAME which is part of LVC_S_LAYO
Requirement:
Open Sales Order Report
The sales orders for which delivery is partially done are called open sales orders
In some companies delivery (or) invoice is done for more quantity then given in sales
order
Such sales orders are opening nature
Input:
S_kunnr
S_vbeln ------- sales order number
P_werks
S_erdat
Output:
Sales order number
Sales order date
Customer number
Customer name
Sale order quantity
Delivery quantity
Invoice quantity
Open quantity
Solution:
ZSD_OPEN_SALESORDER_REPORT
Ashok
SAP-ADV ABAP
Button Functionality:
Using this functionality you can add additional buttons on ALV tool bar
Requirement:
Employee Allowances Report
Input:
S_pernr --------- employee number
S_persg --------- employee group
S_abkrs --------- payroll area
S_persk --------- employee sub group
Output:
Check box
Employee number
Date of birth
Date of joining
Medical allowance
CA (Canteen Allowance)
LTA (Leave Travelling Allowance)
INSERT (button)
SELECT ALL (button)
DESELECT ALL (button)
Solution:
Step-1:
Go to SE11
Database Table: ZHR_TAB_ALLOW
Create
Short Description: Table for allowances
Field Data Element
MANDT MANDT
SEL CHAR1
PERNR PERSNO
GBDAT GBDAT
DOJ ZEMPDOJ
MEDICAL ZMEDICAL
LAT ZLTA
CA ZCA
Ashok
SAP-ADV ABAP
Activate
Back
Step-2:
Go to SE38
Program: ZHR_EMPLOYEE_ALLOWANCE_REPORT
Create
Title: employee allowance report using button functionality
Type: Executable Program
Enter
Enter
TABLES PERNR.
PUBLIC SECTION.
METHODS: tool FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING
e_object e_interactive,
command FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING e_ucomm.
ENDCLASS.
Ashok
SAP-ADV ABAP
METHOD tool.
wa_button-function = ‘INSERT’.
wa_button-text = ‘Insert’.
APPEND wa_button TO e_object->mt_toolbar.
wa_button-function = ‘SAL’.
wa_button-text = ‘Select All’.
APPEND wa_button TO e_object->mt_toolbar.
wa_button-function = ‘DALL’.
wa_button-text = ‘Deselect All’.
APPEND wa_button TO e_object->mt_toolbar.
ENDMETHOD.
METHOD command.
CASE e_ucomm.
WHEN ‘INSERT’.
LOOP AT it_allow INTO wa_allow WHERE sel = ‘X’.
MODIFY ZHR_TAB_ALLOW FROM wa_allow.
ENDLOOP.
WHEN ‘SALL’.
LOOP AT it_allow INTO wa_allow.
wa_allow-sel = ‘X’.
MODIFY it_allow FROM wa_allow TRANSPORING sel.
ENDLOOP.
WHEN ‘DALL’.
LOOP AT it_allow INTO wa_allow.
wa_allow-sel = ‘ ’.
MODIFY it_allow FROM wa_allow TRANSPORING sel.
ENDLOOP.
ENDCASE.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
GET PERNR.
CHECK pernr-pernr IN s_pernr
AND pernr-persg IN s_persg
AND pernr-persk IN s_persk
AND pernr-abkrs IN s_abkrs.
IF SY-SUBRC EQ 0.
PERFORM get_emp.
ENDIF.
END-OF-SELECTION.
PERFORM layout.
PERFORM fill_cat.
CALL SCREEN 100.
FORM get_emp.
wa_allow-pernr = pernr-pernr.
wa_allow-gbdat = pernr-gbdat.
CLEAR wa_allow.
ENDFORM.
FORM layout.
wa_layo-zebra = ‘X’.
wa_layo-cwidth_opt = ‘X’.
ENDFORM.
Ashok
SAP-ADV ABAP
FORM fill_cat.
wa_fcat-fieldname = ‘SEL’.
wa_fcat-scrtext_m = ‘Check’.
wa_fcat-checkbox = ‘X’.
wa_fcat-edit = ‘X’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = ‘PERNR’.
wa_fcat-scrtext_m = ‘Employee Number’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = ‘GBDAT’.
wa_fcat-scrtext_m = ‘Date of Birth’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = ‘DOJ’.
wa_fcat-scrtext_m = ‘Date of Joining’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = ‘MEDICAL’.
wa_fcat-scrtext_m = ‘Medical Allowance’.
wa_fcat-edit = ‘X’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = ‘LTA’.
wa_fcat-scrtext_m = ‘Leave Travelling Allowance’.
wa_fcat-edit = ‘X’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
wa_fcat-fieldname = ‘CA’.
wa_fcat-scrtext_m = ‘Canteen Allowance’.
wa_fcat-edit = ‘X’.
APPEND wa_fcat TO it_fcat.
CLEAR wa_fcat.
Ashok
SAP-ADV ABAP
ENDFORM.
Double click on 100
Yes
Short Description: Screen 100
Layout
Design screen as per your requirement
Flow Logic
Remove comment for MODULE STATUS_100 OUTPUT.
Double click on STATUS_100
Place cursor between MODULE…………….ENDMODULE
IF SY-SUBRC EQ 0.
CREATE OBJECT grid
EXPORTING
I_PARENT = container.
IF SY-SUBRC EQ 0.
CALL METHOD grid->set_table_for_first_display
EXPORTING
IS_LAYOUT = wa_layo
CHANGING
IT_FIELDCATALOG = it_fcat
IT_OUTTAB = it_allow.
ENDIF.
ENDIF.
Ashok
SAP-ADV ABAP
ENDMODULE.
Remove comment for MODULE USER_COMMAND_100 INPUT.
Double click on USER_COMMAND_100
Place cursor between MODULE…………….ENDMODULE
CASE SY-UCOMM.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
ENDCASE.
04-11-2014
Syntax for Declaring Event Handler:
METHODS: <event handler> FOR EVENT <event name> OF <class name>
IMPORTING <param 1> <param 2>………………..
Note:
E_object is an instance created based on standard class
CL_ALV_EVENT_TOOLBAR_SET
The respective class is having an attribute MT_TOOLBAR (Table Type)
Ashok
SAP-ADV ABAP
Hyperlinks Functionality:
Using hyperlink functionality you can switch to respective hyperlink based on specific URL
address
Requirement:
Vendor hyperlinks report
Input:
S_erdat
Output:
Vendor number
Vendor name
Hyperlink Logic:
When you click on vendor number we have to switch particular web address
Solution:
ZMM_VENDOR_LINKS
Ashok
SAP-ADV ABAP
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’.
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
Ashok
SAP-ADV ABAP
Reports:
Ques-1:
Suppose there are 20 pages in my report. How many times INITIALIZATION will triggers &
TOP-OF-PAGE will triggers?
Ans:
INITIALIZATION will triggers only 1 time
TOP-OF-PAGE will triggers 20 times
Ans:
INITIALIZATION
AT SELECTION-SCREEN OUTPUT
START-OF-SELECTION
END-OF-SELECTION
TOP-OF-PAGE
END-OF-PAGE
*** Ques-5: This report is already provided by SAP (MMB). Then why you created it?
Ans:
MMB is providing materials details plant wise & storage location wise material by
material
My client gave a requirement for viewing all restricted & unrestricted stock at one time
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
FAQS IN REPORTS
1.) What is the purpose of reports in real time?
Ans:
In real time ABAP Reports are designed for analysis & based on the that analysis decision
making will done
2.) What are the three mandatory details for generating report?
Ans:
a.) Input
b.) Processing Logic
c.) Output
AT SELECTION-SCREEN:
It triggers once the control leaves from selection-screen & still selection-screen is in
active mode
i.e. It triggers at end of PAI when all the values are passed from selection-screen to
program variables
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
AT SELECTION-SCREEN OUTPUT:
It triggers after initialization & before selection-screen display
Use this event for modifying selection-screen
START-OF-SELECTION:
This event will triggers once your selection-screen is processed
It triggers when you select F8 function key
It triggers before reading data from database
It triggers for all processing blocks in a program
It is a default event triggered before extracting data from database
Ashok
SAP-ADV ABAP
Syntax:
GET CURSOR FIELD <field name> VALUE <value>.
Ashok
SAP-ADV ABAP
INITIALIZATION.
18.) What is the diff between SELECT SINGLE .... & SELECT SINGLE…. UP TO 1 ROW?
Ans:
2. REUSE_ALV_BLOCK_LIST_INIT
It initializes lists in blocked alvs
3. REUSE_ALV_BLOCK_LIST_APPEND
This function module
Maintains field catalogs
Maintains data in list
Ashok
SAP-ADV ABAP
4. REUSE_ALV_BLOCK_LIST_DISPLAY
It displays data in list in blocked alvs
5. REUSE_ALV_HIRESEQ_LIST_DISPLAY
Using this function module, you can display the in hierarchal format
Ashok
SAP-ADV ABAP
In layout work area you should pass INFO-FIELDNAME for displaying row with a specific
color given in output list
30.) What is the function module used for printing heading and logo in alv?
Ans:
SLIS_LISTHEADER:
It is a standard ALV structure for maintaining headings in output list
It is having following fields
4. TYP -------------- type of heading (H, S, A)
5. KEY ------------- text for heading in 20 characters
6. INFO ------------ text for heading in 60 characters
Save it on desktop
Go to OAER
Class Name: Pictures
Class Type: OT
Object Key: ABAP
Execute
At bottom expand Standard Document Types
Double click on Screen
Select you Logo
Enter
Enter
Ans:
SLIS_ALV_EVENT:
It is a standard ALV structure for maintaining events
It is having following fields
3. NAME ----------- name of event
4. FORM ----------- subroutine name
Syntax:
FORM <interactive> USING <ucomm> TYPE SY-UCOMM <sel> TYPE
SLIS_SELFIELD.
-------------
-------------
ENDFORM.
Ashok
SAP-ADV ABAP
17.I_STRUCTURE_NAME
For providing structure
18.I_BACKGROUND_ID
For maintaining background pictures
19.I_GRID_TITLE
For maintaining title in ALV grid
20.IT_SORT
For sorting data & for maintaining sub totals
21.I_SAVE
For saving layouts
22.IT_EVENTS
For events internal table
23.IS_PRINT
For deactivating (or) activating the print mode for PDF formats…………etc
24.T_OUTTAB
For output internal table
Ans:
2. REUSE_ALV_BLOCK_LIST_APPEND
This function module
Maintains field catalogs
Maintains data in list
Append field catalogs & data with layout
3. REUSE_ALV_BLOCK_LIST_DISPLAY
It displays data in list in blocked alvs
40.) How u can improve performance of programming?Give atleast 15 tips for the same?
Ans:
43.) What are the pitfalls for for all entries keyword?
Ans:
Ashok
SAP-ADV ABAP
44.) How many times initialization and top-of-page triggers in report having 20 pages?
Ans:
INITIALIZATION will triggers only 1 time
TOP-OF-PAGE will triggers 20 times
45.) Why u created restricted and unrestricted stock report when already SAP is providing
such report in the form of MMBE?
Ans:
MMBE is providing materials details plant wise & storage location wise material by
material
My client gave a requirement for viewing all restricted & unrestricted stock at one time
48.) How u can transfer data from alv reporting to MM01 Application?
Ans:
50.) If there are 50 records i want message at 10th record then how to do you do.
Ans:
52.) How you can convert alv report to oo abap report, is there any possibilities ?
Ans:
Ashok
SAP-ADV ABAP
55.) In interactive reports in 20th secondary list if double click what will happen?
Ans:
56.) What are the abap runtime errors we have faced in reporting?
Ans:
In real time you will find number of exceptions (Run time errors) such as
8. Time out exception
9. SQL statement exception
10.Division by zero exception
11.No convert number exception
12.Type conflict exception
13.BCD overflow exception
14.*** Storage exception for internal table
57.) What is the use of initialization event? We can initialize the input values in selection screen
without initialization event also but why we are using initialization event?
Ans:
Initialization Event triggers before selection-screen display
Note:
Use this event for initializing
1. Default values in selection-screen
2. Texts on push buttons in selection-screen
3. Texts for blocks, radio buttons, check boxes…………..etc
58.) After developing source code in development server how many reviews we will get for our
source code.
Ans:
60.) What is the toughest report u created, what difficulties u faced and how u overcome those?
Ashok
SAP-ADV ABAP
Ans:
62.) What are Alv reports? How they are different from normal reports?
Ans:
ALV is advanced reporting with additional features of reporting
63.) What are the various ways of creating buttons in selection screens?
Ans:
Page number: 230
64.) How indexing is helpful in resolving performance issues in reports? Explain with ur
experience in real time?
Ans:
Indexing is a way of searching
Indexing is a way of improving performance while accessing the data from database
I created secondary index on production efficient report
First I debugged the program
I found that control is taking lot of time for program execution
Then I will identify none primary key fields of that SELECT statement & based on that non-
primary key fields I will created a secondary index
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
FAQS IN REPORTS:
4Q: what is the event that will be triggered first in an ABAP report?
Ans:
Initialization event is triggered first if user executes an ABAP report
But if the program is of type 1, M, F, or S; then LOAD-OF-PROGRAM is triggered first
and then INITIALIZATION event.
5Q: What are the differences between simple and interactive ABAP reports?
Ans:
A simple ABAP report allows the user to interact with the whole business-result data.
In case of interactive reports user can interact with specific result data at a time.
Ashok
SAP-ADV ABAP
6Q: How do you read selected lines of database table into an internal table in packages of
predefined size?
Ans:
SELECT * FROM <SPFLI> INTO TABLE <ITAB> PACKAGE SIZE <N>.
Where n is variable.
7Q: How do you write a DATA object from ABAP/4 program to ABAP/4 memory and restore
the same from memory to program.
Ans:
EXPORT <f1> [FROM <g1>] <f2> [FROM <g2>]…. TO MEMORY ID <key>.
The ID <key>, which can be up to 32 characters long, identifies the data in memory.
8Q: Name the function modules to write data from an Internal Table to the Presentation Server.
Ans:
1. DOWNLOAD
2. WS_DOWNLOAD.
Ashok
SAP-ADV ABAP
Ans:
It allows you to enhance the information presented in the basic list
The user can, for example, select a line of the basic list for which he wants to see more
detailed information
You display these details on a secondary list
Secondary lists may either overlay the basic list completely or you can display them in an
extra window on the screen
The secondary lists can themselves be interactive again.
14Q: Can we call reports and transactions from interactive reporting lists?
Ans:
Yes,
It also allows you to call transactions or other reports from lists
These programs then use values displayed in the list as input values
Ashok
SAP-ADV ABAP
The user can, for example, call a transaction from within a list of change the database
table whose data is displayed in the list
15Q: What are system fields for secondary lists?
Ans:
1. SY-LSIND Index of the list created during the current event (basic list = 0)
2. SY-LISTI Index of the list level from which the event was triggered.
3. SY-LILLI Absolute number of the line from which the event was triggered.
4. SY-LISEL Contents of the line from which the event was triggered.
5. SY-CUROW Position of the line in the window from which the event was triggered
6. SY-CUCOL Position of the column in the window from which the event was triggered
7. SY-CPAGE Page number of the first displayed page of the list from which the event
was triggered.
8. SY-STARO Number of the first line of the first page displayed of the list from which
the event was triggered (counting starts with 1). Possibly, a page header
occupies this line.
9. SY-STACO Number of the first column displayed in the list from which the event was
triggered
10.SY-UCOMM Function code that triggered the event.
11.SY-PFKEY Status of the displayed list.
Ashok
SAP-ADV ABAP
18Q: What are the drill-down features provided by ABAP/4 in interactive lists?
Ans:
ABAP/4 provides some interactive events on lists such as AT LINE-SELECTION
(double click) or AT USER-COMMAND (pressing a button).
You can use these events to move through layers of information about individual items in
a list.
19Q: Is the basic list deleted when the new list is created?
Ans:
No. It is not deleted and you can return back to it using one of the standard navigation
functions like clicking on the back button or the cancel button.
Ans:
A Hotspot is a list area where the mouse pointer appears as an upright hand symbol.
When a user points to that area (and the hand cursor is active), a single click does the
same thing as a double-click.
Hotspots are supported from R/3 release 3.0c.
22Q: Can we create a GUI status in a program from the object browser?
Ans:
Yes. You can create a GUI STATUS in a program using SET PF-STATUS.
23Q: In which system field does the name of current gui status is there?
Ans:
The name of the current GUI STATUS is available in the system field SY-PFKEY.
Ashok
SAP-ADV ABAP
24Q: Can we display a list in a pop-up screen other than full-size stacked list?
Ans:
Yes, we can display a list in a pop-up screen using the command WINDOW with the additions
starting at X1 Y1 and ending at X2 Y2 to set the upper-left and the lower-right corners where x1
y1 and x2 y2 are the coordinates.
27Q: How can you display frames (horizontal and vertical lines) in lists?
Ans:
You can display tabular lists with horizontal and vertical lines (FRAMES) using the
ULINE command and the system field SY-VLINE.
The corners arising at the intersection of horizontal and vertical lines are automatically
drawn by the system.
28Q: What are the events used for page headers and footers?
Ans:
The events TOP-OF-PAGE and END-OF-PAGE are used for pager headers and footers.
29Q: How can you access the function code from menu painter?
Ans:
From within the program, you can use the SY-UCOMM system field to access the
function code.
You can define individual interfaces for your report and assign them in the report to any
list level.
If you do not specify self-defined interfaces in the report but use at least one of the three
interactive event keywords.
Ashok
SAP-ADV ABAP
32Q: How can you manipulate the presentation and attributes of interactive lists?
Ans:
1. Scrolling through Interactive Lists.
2. Setting the Cursor from within the Program.
3. Modifying List Lines.
Ans:
Report Transaction
1. Call and return SUBMIT AND RETURN CALL TRANSACTION
2. Call without return SUBMIT LEAVE TO TRANSACTION
You can use these statements in any ABAP/4 program.
Ashok
SAP-ADV ABAP
Views:
Views are logical views on more than one table.
The structure of the view is defined in the ABAP Dictionary.
A view on the database can then be created from this structure.
Lock objects:
These are used to synchronize access to the same data by more than one user.
Function modules that can be used in application programs are generated from the
definition of a lock object in the ABAP Dictionary.
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
Domains:
Different fields having the same technical type can be combined in domains.
Domain defines the value range of all table fields and structure components that refer to
this domain.
Data element:
The ABAP Dictionary also contains the information displayed with the F1 and F4 help
for a field in an input template.
The documentation about the field is created for a data element.
Input help:
The list of possible input values that appears for the input help is created by a foreign key
or a search help.
Foreign keys:
Relationship between the table and the other tables are defined.
Technical settings:
Data class and size category defines that what type of table to be created and how much space
required.
Indexes:
Secondary indexes are created for a table for faster data selection.
Ashok
SAP-ADV ABAP
Ans:
1. Choose APPL0(master data) for data that is frequently accessed but rarely
updated/changed.
2. Choose APPL1 (transaction data) for data that is frequently changed.
3. Choose APPL2 (organizational data) for customizing data that is defined/entered during
system installation and rarely changed.
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
2. AT USER-COMMAND
Moment at which the user presses a function key
Ashok
SAP-ADV ABAP
If you want to include additional functionality, such as pushbuttons, you must define your
own interface status.
To create a new status, the Development Workbench offers the Menu Painter.
With the Menu Painter, you can create menus and application toolbars.
And you can assign Function keys to certain functions.
At the beginning of the statement block of AT END-OF-SELECTION, activate the status
of the basic list using the statement: SET PF-STATUS 'STATUS'.
5Q: Can we call reports and transactions from interactive reporting lists ?
Ans:
YES,
Interactive reporting also allows you to call transactions or other reports from lists.
These programs then use values displayed in the list as input values.
The user can, for example, call a transaction from within a list to change the database
table whose data is displayed in the list.
Ashok
SAP-ADV ABAP
On secondary lists, the system does not display a standard page header and it does not
trigger the event TOP-OF-PAGE.
To create page headers for secondary list, you must enhance TOP-OF-PAGE:
Syntax:
TOP-OF-PAGE DURING LINE-SELECTION
The system triggers this event for each secondary list.
If you want to create different page headers for different list levels,
You must program the processing block of this event accordingly,
For example by using system fields such as SY-LSIND or SY-PFKEY in control
statements (IF, CASE).
9Q: Is the basic list deleted when the new list is created?
Ans:
No. It is not deleted and you can return back to it using one of the standard navigation functions
like clicking on the back button or the cancel button.
11Q: In which system field does the name of current gui status is there ?
Ans:
The name of the current GUI STATUS is available in the system field SY-PFKEY.
Ashok
SAP-ADV ABAP
Ans:
HIDE:
The HIDE statement is one of the fundamental statements for interactive reporting
Using the HIDE technique, you can at the moment you create a list level define, which
information later to pass to the subsequent secondary lists.
Example:
HIDE: SPFLI-CARRID, SPFLI-CONNID, NUM.
READ LINE:
Use the statements READ LINE & READ CURRENT LINE to explicitly read data from
the lines of existing list levels.
These statements are tightly connected to the HIDE technique.
Syntax:
READ LINE [INDEX ]
[FIELD VALUE [INTO ]... [INTO ]]
[OF CURRENT PAGE|OF PAGE ].
Example:
READ LINE SY-INDEX FIELD VALUE BOX.
Ashok
SAP-ADV ABAP
GET CURSOR:
Use the statements GET CURSOR FIELD & GET CURSOR LINE to pass the output field or
output line on which the cursor was positioned during the interactive event to the processing
block.
Syntax:
GET CURSOR FIELD [OFFSET ] [LINE ]
[VALUE ] [LENGTH ].
SET CURSOR:
To set the cursor, use the SET CURSOR statement
This statement sets the cursor in the most recently created list
While creating the basic list, this is always the basic list itself
While creating a secondary list, this is the previous list.
ABAP allows you to call reports as well as transactions using these statements:
Report Transaction
Call and return SUBMIT AND RETURN CALL TRANSACTION
Call without return SUBMIT LEAVE TO TRANSACTION
Ashok
SAP-ADV ABAP
9. Initialization
OOABAP:
1Q: Principles of oops?
Ans:
5. Inheritance
6. Polymorphism
7. Abstraction
8. Encapsulation
Ashok
SAP-ADV ABAP
8Q: Can we put non declarative statement e.g. START-OF-SELECTION within a class
Ans:
9Q: What is static attribute & method?
Ans:
Ashok
SAP-ADV ABAP
25Q: Can we implement abstract method in abstract class? If not then where it can be
implemented?
Ans:
Ashok
SAP-ADV ABAP
36Q: Can we have more than one event handler method for same event?
Ans:
43Q: What is Value table and Check table, Difference between them?
Ans:
Ashok
SAP-ADV ABAP
Ashok
SAP-ADV ABAP
Ashok