Comprehensive Guide to SAP ABAP
Comprehensive Guide to SAP ABAP
INDEX
1 Introduction to ERP 5
2 Introduction to SAP R/3 6
3 SAP R/3 Services 8
4 Introduction to ABAP/4 & ABAP Work Bench Tools 10
5 ABAP Data types 12
6 ABAP Programming Structures 14
7 Steps to Write & Create SAP Program 16
8 Tips for Writing a Program in Real Time 19
9 Internal Table & difference between database table & internal table 20
10 Reading Data from Body to Work Area (or) Header Line 22
(1. LOOP….ENDLOOP, 2. READ)
11 Selection Screen (1. Select-options, 2. Ranges, 3. Parameters ) 26
12 Other SELECT-OPTIONS keywords (1. Obligatory, 2. No Intervals, 28
3. No-Extension, 4. No-Display)
Rohini kumar
SAP-ABAP 2
13 Other Important Keywords for Internal Table (1. Append, 2. Sort, 3. Delete 31
Adjacent Duplicates, 4. Collect 5. Modify )
14 6. Deleting Data from Internal Table by (1. Fresh, 2. Refresh, 3. Clear, 4. 36
Delete )
15 7. Describe Keyword 37
16 8. Coping data b/w work areas (1. Move, 2. Move-Correspondig) 38
17 9. Coping data b/w internal tables (1. Loop…….Endloop, 2. Append Lines) 39
18 Control Break Statements (1. At First, 2. At Last, 3. At New, 4. At Change, 41
5. At End )
19 Insert keyword & Syntaxes for Internal Tables 45
20 System Fields for Internal Table 46
21 DML Operations on Database Table (insert, update, delete, modify keywords) 48
22 Types of Internal Tables 50
23 Data Dictionary (9 objects) 1. Database Table 51
24 2. Structure (.include & Append Structure) 55
25 3. View(Database view, Projection view) 58
26 4. Search Help (Elementary search help, Collective search help) 60
27 Table Maintenance Generator (TMG) (TCode, Default values, Check boxes) 63
28 Text Table 70
29 Some Important Steps for Working with Standard Tables 72
30 Types of Tables (Transparent, Cluster, Pooled Tables) 73
31 Open SQL Statements & Native SQL Statements 74
32 Buffering (Single Record, Generic, Full Buffering) 75
33 MODULES(1. MM Module) 76
34 Inner Joins 79
35 Table Fields & Links (1. LFA1, 2. EKKO, 3. EKPO) 84
36 Message Handling 86
37 Modularization Techniques (5) 88
1. Subroutines (Internal Subroutine, External Subroutine)
38 Break Point (1. Static Break Point 2. Dynamic Break Point) 90
39 Pass by Value & Pass by Reference 91
40 Table Fields & Links (1. MKPF, 2. MSEG) 94
41 Function Module (1. Normal, 2. Remote Enabled, 3. ALv) 96
42 Include Program 100
43 Field Symbol 101
44 FOR ALL ENTRIES 103
45 Table Fields & Links (1. MARA, 2. MAKT, 3. TSPAT) 108
46 2. SD Module 109
47 String Operations (shift, translate, replace, strlen, offset functionality, split, 111
concatenate, condense)
48 Looping Statements (1. Conditional, 2. Unconditional) 115
Rohini kumar
SAP-ABAP 3
Rohini kumar
SAP-ABAP 4
ERP
ERP:
Enterprise Resource Planning
ERP is a package under which all the business resources are integrated in one system
Enterprise-------organization
Resource--------FICO, HR, MM, PP, SD, CRM
Types of ERP:
1. High End ERP
2. Mid Range ERP
SAP R/3
SAP R/3:
Systems, Applications, Products in data processing
R/3------ Real time 3 tier architecture
History:
SAP AG---- developed by 5 IBM employees in 1973----in woldoff (Germany)
SAP R/1(Finance)------1973
SAP R/2 (Mainframes)------1978
SAP R/3 (Client Server Technology)----1992
Systems:
These are basic resources for implementing a project
Examples:
Servers, Hardware, Soft ware, Systems, Network, Database………etc
Rohini kumar
SAP-ABAP 6
BASIS Consultant:
Roles:
1. Installation
2. Maintenance
3. Configuration
4. Customization (or) Administration
Applications:
These are collection of Screens
Each Screen is a collection of Fields
Use---Applications are used by Clients (or) End Users
Create---Applications are created by Abapars (or) Technical Consultant (or) ABAP Consultant
Customized Data----Applications data customized by Functional Consultant
Functional Consultant:
Roles:
1. Customization of Data
2. Getting requirements from Clients
3. Preparing Functional Documents
4. Preparing End User Manuals (or) Snapshots
5. Providing end user Training
Products:
These are called Objects
These are created by Programming
14-08-2014
Features of SAP:
1. Designed based on RDBMS
2. Designed based on R/3 Architecture
3. Database independent
4. Supports all types of industry specific solutions
5. International package available in 40 languages
Rohini kumar
SAP-ABAP 7
Spool Service
Note:
In real time once report is created, then it is scheduled in background by BASIS Consultants,
they will set time & event related to it
5. En-queue Service:
It maintains data integrity (locking mechanism) in SAP
6. Message Service:
Rohini kumar
SAP-ABAP 8
Versions in SAP:
Version Year
1.0 & 1.1 1991
2.0 & 2.1 1991
3.0 & 3.1 1992
4.0 1998
4.6A, 4.6B, 4.6C 2000
4.7EE 2003
ECC 5.0 2005 (ECC----Enterprise Core Component)
ECC 6.0 2006 (Present Working)
BI/BO 2008 (Business Independent)
CRM, SCM, PLM 2009 (Customer Relationship Management, Product Lifecycle Management)
1. Production Software:
It is Real time
Every company should purchase this software from SAP
Here you will find only live data
Clients (End Users) are works with Production Software
2. IDES Software:
International Demonstration & Education System Software
It is also known as Training Software
Here you can find data for practice & examples for practice
Rohini kumar
SAP-ABAP 9
16-08-2014
ABAP/4
Advanced Business Application Programming 4th Generation Language
All SAP applications are designed & developed using ABAP Language
It is a high level language
Features of ABAP:
1. It was designed based on ‘C’ language
2. It is a platform independent language
3. It is a case insensitive language
4. It is database independent
5. It is truly business oriented language
6. It is rich in data types
7. It was designed based on Object Oriented Programming
8. It is an event driven programming language
9. It is highly user friendly
[Link] supports web based applications also
2. ABAP Editor:
It works with Transaction Code (OR) T Code SE38 (System Engineering)
Here we can create & execute Programs
3. Screen Painter:
It works with Transaction Code (OR) T Code SE51 (System Engineering)
Here we can design Applications (OR) Screens
4. Class Builder:
It works with Transaction Code (OR) T Code SE24 (System Engineering)
It is for Object Oriented ABAP
5. Function Builder:
Rohini kumar
SAP-ABAP 10
6. Object Navigator:
It works with Transaction Code (OR) T Code SE80 (System Engineering)
Here we can create & modify the Objects & store the Objects
Note:
In Object Navigator you can develop all Objects in SAP
It is also known as a True ABAP Development Work Bench
Rohini kumar
SAP-ABAP 11
18-08-2014
ABAP Programming
ABAP Data Types:
ABAP data types are classified into 4 categories
They are:
1. Numeric
2. Character
3. String
4. Hexadecimal
1. Numeric:
These are classified into 3 categories
They are:
i) Integer (I)
ii) bPacked Decimal (P)
iii) Floating point (F)
i) Integer (I):
It holds integer values
Ex: 102, 55, 74, …..
2. Character:
These are classified into 3 categories:
They are:
i) Character (C)
ii) Date (D)
iii) Time (T)
i) Character (C):
It holds character value provided in ‘ ’ (single quotes)
Rohini kumar
SAP-ABAP 12
Note:
In ABAP programming the default data type is Character
ii) Date:
Use Date data type to store date values
The default SAP format for date is YYYYMMDD
iii) Time:
Use Time data type to store time values
The default SAP format for time is HHMMSS
3. String (String):
A group of characters combined to form a String
4. Hexadecimal (HX):
It is for SAP graphics management
Note:
QUAN, CURR, NUME are SAP provided business data types for storing Quantities, Currencies
& other Numeric values
Type Keyword:
It specifies the type of data an Object (Variable) can hold
Example:
1. Data ch type String --------hi, hello, how are you,………
2. Data cnt type I ------54, 1025, 748,…….
3. Data count type P values 2 -------145.22, 52.69,……
4. Data chr(10) type C ------ ‘a’, ‘h’,………
Data Keyword:
Using Data keyword Objects are defined in ABAP programming
Using Data keyword memory is allocated in buffer by system
Note:
Every Object (OR) Variable should be define using Data keyword
Rohini kumar
SAP-ABAP 13
Programming Structures:
These are 2 types
They are:
1. Pre defined Programming Structure
2. User defined Programming Structure
1. Work Area:
Work Area is a Structure (group of fields with different data types)
It holds only one single record during run time
Syntax: Chain Operator Name of Work Area (any name)
Data: Begin of wa_KNA1, { wa_table name (OR) w_table name is recommended }
Customer(10) type C,
Name(20) type C,
City(20) type C,
End of wa_KAN1. Period Symbol
Field Name
Note-1:
With above syntax during run time a Work Area wa_KNA1 is created in Application Server
Note-2:
Work Area name can be any name
In companies we have to follow Naming (Coding) standards while creating a program
According to these standards Work Area should always begins with w_ (OR) wa_
followed by Table Name
Note-3:
Every Object (Work Area) should be define with Data keyword
Note-4:
Every Programming Structure should begins with Begin of & ends with End of followed by the
Programming Structure name
Rohini kumar
SAP-ABAP 14
Note-5:
: is known as Chain Operator
It provides the repetition of the Declarative Part
Requirement:
Transfer Customer Master Data from Database Server to Application Server & from
Application Server to Presentation Server
Solution:
Select kunnr name1 ORT01 from KNA1 into wa_KNA1. ----- Data transfer from
Database Server to Application Server (Work Area)
Write:/10 wa_KNA1-Customer,
30 wa_KNA1-Name, data transfer from Work Area to Virtual Page then
60 wa_KNA1-City. Presentation Server
Endselect. ----------- it repeats the Select statement until records completed
Work Area
Virtual Page
Rohini kumar
SAP-ABAP 15
20-08-2014
Steps to write & execute SAP program:
Double click on SAP Logon on Desktop
You will find a Logon Pad
Double click on Development ([Link])
Provide Client: 800 (only for practice purpose)
User: user1 to user10
Password: Rgsabap
You will find SAP Easy Access screen (Screen 0)
On top of the screen you will find cursor blinking at Command Prompt (or) Command
Field. Here you should type Transaction Codes (T Codes) in real time
Next to Command Prompt you will find Standard Icons (Standard Application Tool
Bar). Here you cannot add Customized Icons
Under Standard Application Tool Bar you will find Text Area. It specifies
documentation of current application
Under Text Area you will find Customized Application Tool Bar when you can add
your own icons apart from Standard ones
Under Customize Application Tool Bar you will find Work Area where user performs
his tasks (or) navigations
Then press Enter you will find a pop-up here leave Package:___________ as blank
Click on Local Object button
Note-1:
In real time Objects needs to be transported from Development client to Testing client & from
Testing client to Production client. For that Objects should always be saved in a package. If an
Object is saved in Local Object it cannot be transported between clients (Non Transportable
Objects)
Note-2:
Local Object is meant for practicing Objects in real time
Note-3:
Rohini kumar
SAP-ABAP 16
Writing Program:
Report ZSD_Customer_Report -----------title of program
Rohini kumar
SAP-ABAP 17
Select Ctrl+F3 (or) Candle Icon to activate. You will find an Inactive Objects pop-up
then press Enter
With activation Objects are ultimately stored in Database Server
With activation Objects can be integrated with each other in SAP
21-08-2014
Debugging:- Work Area
Using debugging you can check (OR) test internal execution of a program
It is an important tool for testing programs in real time
Note:
/H is T Code for debugging
New Debugger:
Currently in real time we are working with only New Debugger
It is providing additional features compare to Old Debugger
Working:
Provide Program:_______ name
Select Debugging button
Select Desktop1 tab
Under Variable: type wa_kna1-customer, wa_kna1-name, wa_kna1-city & press Enter
Select F5 for single step debugging
Rohini kumar
SAP-ABAP 18
Rohini kumar
SAP-ABAP 19
INTERNAL TABLES
2. Internal Table:
Internal table is a temporary table created in RAM in Application Server
It is created & filled with data during run time (execution time)
Once execution is performed it is rolled out (or) discarded
Note:
Use Internal table for storing multiple records during run time
Que: What is exact purpose of Internal table. Do you think should be created in ABAP
programming?
Ans: In real time we are creating Internal table for storing different types of application data
from different tables at one place
2. Header Line:
It is a default Work Area & holds single record
Note:
Header Line is system defined Work Area & Work Area is user defined Header Line
Syntax:
DATA: BEGIN OF it_kna1 OCCURS 0,
customer(20) TYPE C,
name(20) TYPE C,
city(20) TYPE C,
END OF it_kna1.
Rohini kumar
SAP-ABAP 20
Note:
1. With above syntax an Internal table it_kna1 is crated in Application Server
2. You can provide any name. But in real time Internal table should always begins with it_
(or) i_ followed by table name
3. With BEGIN option Header Line is created & OCCURS option Body is created
4. 0, 1, 2, 3, …..9 is called Size Category
5. Both Header Line & Body name is same (it_kna1)
Rohini kumar
SAP-ABAP 21
22-08-2014
Reading Data from Body to Work Area (or) Header Line:
1. LOOP ……….. ENDLOOP
2. READ keywords
Syntax:
LOOP AT it[INTO wa]
[FROM m][TO n]
[where codition].
…………
…………
ENDLOOP.
LOOP AT it:
Reads multiple records (record by record) from Body to Header Line
Note:
Internally system converts LOOP AT it as LOOP AT it INTO it.
Working:
Go to SE38
Program: ZSD_LOOPENDLOOP
Select Create option
Title; Internal Table
Type: Executable Program
Select Save option
Leave Package:__________ blank
Select Local Object option
Note;
Activate the program then select F8 to execute the program
Note:
You will find a Cap symbol which indicates Header Line (holds only single record)
Select F5 for single step debugging
Note:
1. Table keyword will transfer the data directly to Internal Table to Body
2. Always use Table keyword in select statement if you are working with Internal Tables
3. As long as you are in loop system will read next record in-line in an Internal Table. Once
the loop is terminated again the loop starts reading from 1st line
Working:
Go to SE38
Program: ZSD_INTERNAL_WORKAREA
Select Create option
Title: Internal Table & Work Area
Type: Executable Program
Select Save option
Leave Package:__________ blank
Select Local Object option
Rohini kumar
SAP-ABAP 23
Note:
1. Using TABLE OF you can create your own body
2. Using TYPES keyword Structures are created in ABAP programming
3. In ABAP programming always create Objet (Work Area & Body) based on Structures
4. Avoid creating Internal Table with OCCURS clause
Example:
1. LOOP AT it INTO wa FROM 100.
2. LOOP AT it INTO wa FROM TO 50.
3. LOOP AT it INTO wa FROM 100 TO 200.
Rohini kumar
SAP-ABAP 24
23-08-2014
2. READ:
It reads a single record from Body to Header Line (or) Work Area
Syntax:
READ TABLE it[INTO wa]
[INDEX n][WITH KEY keyexpression]
[TRANSPORTING fieldname]
[Binary Serach]
Binary Search:
It reads data from Body to Work Area based on binary search algorithm
Note:
1. Use binary search if Internal table is larze
2. Data should be sorted before Appling binary search algorithm
3. There should be no duplicate records in Internal Table
4. Binary search algorithm improves performance of programming
Rohini kumar
SAP-ABAP 25
SELECTION-SCREEN:
Using Selection Screen you can create a selection screen based on given requirement (Input
Values, Radio Buttons, Check Boxes…………..)
Input Values:
1. You can create with ------ Select-Options
2. You can create with ------ Parameters
3. You can create with ------ Ranges
1. SELECT-OPTIONS:
Using select-options you can create a selection screen with range of input values
Syntax:
SELECT-OPTIONS: s_kunnr for kna1-kunnr.
With above syntax system will create a selection screen in the following manner
With above syntax system will create an implicit Internal Table with following fields
Low High Sign Option
100 200 I (including) BT (between)
Note:
The default comparison operator for select-options in ‘IN’
SELECT kunnr name1 ort01 FROM kna1 INTO TABLE it_kna1 WHERE
kunnr IN s_kunnr.
* Appling processing logic
LOOP AT it_kna1 INTO wa_kna1.
WRITE:/10 wa_kna1-customer,
30 wa_kna1-name,
60 wa_kna1-city.
ENDLOOP.
Text Elements:
Using text elements (text-000 to text-009) you can provide field labels in selection screen
Double click on Text-000
You will find a pop-up Yes
Provide Text: Enter Customer Code
Select Selection Texts tab
Provide Text: Customer Code
Activate the screen (Ctrl+F3)
Go to back (F3)
Note:
Using Tables work area system will create a Work Area with all the fields of kna1 table. In
programming it is mandatory to declare for declaring select-options
Rohini kumar
SAP-ABAP 27
25-08-2014
Other SELECT-OPTIONS keywords:
i) OBLIGATORY
ii) NO INTERVALS
iii) NO-EXTENSION
iv) NO-DISPLAY
i) OBLIGATORY:
Using this addition you can make selection screen fields as Mandatory
Syntax:
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr OBLIGATORY.
ii) NO INTERVALS:
Using no intervals you can remove high option from selection screen input field with select-
options
Syntax:
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr NO INTERVALS.
iii) NO-EXTENSION:
With this addition Multiple Selections option is removed from selection screen with select-
options
Syntax:
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr NO-EXTENSION.
iv) NO-DISPLAY:
With this addition selection screen input field will be hidden mode
Syntax:
SELECT-OPTIONS: s_kunnr FOR kna1-kunnr NO-DISPLAY.
Execute (F8)
2. PARAMETERS:
Using parameters you can create a selection screen with single input value
Syntax:
PARAMETERS p_kunnr TYPE kunnr. (or)
PARAMETERS p_kunnr LIKE kna1-kunnr.
Note:
1. With above syntax system will define (or) create a selection screen in the following
manner
P_kunnr
Rohini kumar
SAP-ABAP 29
* provide objects
DATA: BEGIN OF wa_kna1,
customer(20) TYPE C,
name(20) TYPE C,
city(20) TYPE C,
END OF wa_kna1.
Note:
1. If you are not providing SINGLE addition with PARAMETERS for fletching a single
record then it is mandatory to provide ENDSELECT
2. In real time never use SELECT with ENDSELECT (it reduces performance of the
program)
3. RANGES:
It work similar to SELECT-OPTIONS
Syntax:
RANGES s_kunnr FOR kna1-kunnr.
Note:
In new versions RANGES keyword is not allowed (it is out dated)
Rohini kumar
SAP-ABAP 30
2. SORT keyword:
It sorts Internal Table Body data based on ascending (or) descending
Syntax:
SORT <it> BY <field1> ASCENDING (or) DESCENDING
Note:
The default order of sorting is ASCENDING
wa-material=’F001’.
wa-quan=50.
APPEND wa TO it.
wa-material=’F002’.
wa-quan=70.
APPEND wa TO it.
wa-material=’F002’.
wa-quan=100.
APPEND wa TO it.
wa-material=’F001’.
wa-quan=80.
APPEND wa TO it.
SORT it BY material ASCENDING.
LOOP AT it INTO wa.
WRITE:/10 wa-material,
30 wa-quan.
ENDLOOP.
Note:
Before Appling above keyword it is mandatory to sort Internal Table
wa-material=’F001’.
wa-quan=80.
APPEND wa TO it.
SORT it BY material.
DELETE ADJACENT DUPLICATES FROM it COMPARING material.
LOOP AT it INTO wa.
WRITE:/10 wa-material,
30 wa-quan.
ENDLOOP.
26-08-2014
4. COOLECT Keyword:
It provides summarized representation of data in an Internal Table
Note:
COLLECT checks the data based on Key Field (Character Field) in an internal table Body, if
the record is not existing it will performs Append job, if it is already existing it will Add
(Collects) Numeric Values based on Character Field inside the Body.
Syntax:
COLLECT wa INTO it.
Ques-3: Suppose there are more than one Character Fields then what is the rollback of
COLLECT keyword?
Ans: If there are two (or) more than two Character Fields it will Collect (add) the data only
when both the Character Fields are same
5. MODIFY keyword:
This keyword modifies Internal Table’s Body data based on given requirement
Syntax:
MODIFY it FROM wa [TRANSPORTING <field1> <filed2> ……..]
[INDEX n]
[WHERE condition]
wa-material = ‘F002’.
wa-quan = 350
APPEND wa TO it.
LOOP AT it INTO wa.
wa-unit = ‘kg’.
MODIFY it FROM wa TRANSPORTING unit.
ENDLOOP.
LOOP AT it INTO wa.
WRITE:/10 wa-material,
30 wa-quan,
60 wa-unit.
ENDLOOP.
Note:
1. Always provide MODIFY with in LOOP………..ENDLOOP of the Internal Table which
you want to modify
2. If you are providing MODIFY outside LOOP……..ENDLOOP then INDEX addition (or)
WHERE condition is mandatory
Rohini kumar
SAP-ABAP 35
i) FREE:
It deletes Internal Table’s Body data along with memory
Syntax:
FREE it. (where it is Internal Table name)
ii) REFRESH:
It deletes Internal Table’s Body data but memory will not be affected
Syntax:
REFRESH it.
iii) CLEAR:
It deletes 1. Body data------- CLEAR it[ ].
2. Work Area data------- CLEAR wa.
3. Ordinary Variable data --------- CLEAR total.
Note:
CLEAR it[ ] is applicable only where Internal Table is created with OCCURS clause
Example:
1. CLEAR it[ ]. ------- deletes Header Line’s data
2. CLEAR it. -------- deletes Body’s data
iv) DELETE:
It deletes Body data based on requirement
Syntax:
DELETE it [INDEX n]
[FROM m] [TO n]
[WHERE condition]
Example:
1. LOOP AT it INTO wa.
DELETE it.
ENDLOOP.
2. DELETE it INDEX 5.
27-08-2014
Rohini kumar
SAP-ABAP 36
7. DESCRIBE keyword:
It returns the Count of number of records in an Internal Table
Syntax:
DATA n TYPE I.
DESCRIBE TABLE it LINES n.
Example:
DATA: BEGIN OF wa,
material(20) TYPE C,
quan TYPE I,
END OF wa.
DATA it LIKE TABLE OF wa.
DATA n TYPE I.
wa-material = ‘F001’.
wa-quan = 50.
APPEND wa TO it.
wa-material = ‘F002’.
wa-quan = 150.
APPEND wa TO it.
wa-material = ‘F001’.
wa-quan = 250.
APPEND wa TO it.
wa-material = ‘F002’.
wa-quan = 350.
APPEND wa TO it.
DESRIBE TABLE it LINES n.
WRITE n.
Rohini kumar
SAP-ABAP 37
Note:
In real time avoid using MOVE-CORRESPONDING
instead use wa1-material = wa-material.
wa1-quan = wa-quan.
Rohini kumar
SAP-ABAP 38
APPEND wa TO it1.
* coping data one body to another body
APPEND LINES OF it TO it1.
* displaying data of target body
LOOP AT it1 INTO wa.
------------- CLEAR wa.
WRITE:/10 wa-material,
30 wa-quan.
------------- CLEAR wa.
ENDLOOP.
Ques: What will happened if CLEAR is provided before WRITE & the same CLEAR is
provided after WRITE?
Ans: If CLEAR is provided before WRITE statements it will clear Work Area data so nothing
is transformed from Work Area to Virtual page (Hence no output)
If CLEAR is provided after WRITE statements data is transformed from Work Area to
Virtual page then Work Area is cleared (Hence you will find output list)
Rohini kumar
SAP-ABAP 40
28-08-2014
Control Break Statements:- (Events)
1. AT FIRST
2. AT LAST
3. AT NEW
4. AT END OF
5. ON CHANGE OF
Using these statements you can control the flow of ABAP programming statement with in the
LOOP……………ENDLOOP
AT FIRST:
It triggers during first loop iteration (first loop pass)
Syntax:
AT FIRST.
------------
-----------
ENDAT.
Note:
Use AT FIRST for providing Headers in ABAP Report
AT LAST:
It triggers for last line of an Internal Table (or) It triggers during last loop iteration
Syntax:
AT LAST.
------------
-----------
ENDAT.
Note:
Use AT LAST for printing Grand Totals in a Report
AT NEW:
It triggers for a group of similar contents (based on Character Value) in an Internal Table. (or) It
triggers whenever there is a change in field values in an Internal Table based on Character
Value
Syntax:
AT NEW <field name>.
------------
-----------
ENDAT.
Note:
Rohini kumar
SAP-ABAP 41
Use AT NEW for printing unique values for key fields in an Internal Table
AT END OF:
It will triggers the end of group of similar values in an Internal Table based on Character Field
Syntax:
AT END OF <field name>.
------------
-----------
ENDAT.
Note:
Use AT END OF for returning grand totals in an Internal Table
ON CHANGE OF:
It works similar to AT NEW
Syntax:
ON CHANGE OF <field name>.
------------
-----------
ENDON.
Note:
1. Due to some draw backs currently we are not using ON CHANGE OF
2. You should provide above Control Break Statements within the LOOP……..ENDLOOP
3. Don’t provide any conditional statements (IF, CASE,…….etc) with in Control Break
Statements
Requirement:
Material Details Report
--------- AT FIRST
The Material Cod is: F001
50 5000
100 10000
The Total Quantity is: 150 AT NEW
The Total Amount is: 15000
wa-material = ‘F002’.
wa-quan = 70.
wa-amount = 6000.
APPEND wa TO it.
wa-material = ‘F001’.
wa-quan = 100.
wa-amount = 10000.
APPEND wa TO it.
wa-material = ‘F002’.
wa-quan = 100.
wa-amount = 12000.
APPEND wa TO it.
* sorting it by material
SORT it BY material.
AT FIRST.
WRITE:/50 ‘Materials Details Report’ COLOR 1.
SKIP.
ULINE.
ENDAT.
Rohini kumar
SAP-ABAP 43
AT NEW material.
WRITE:/ ‘The Material Code is:’, wa-material.
SKIP.
ENDAT.
WRITE:/10 wa-quan,
30 wa-amount.
AT END OF material.
SUM.
WRITE:/ ‘The Total Quantity is:’, wa-quan,
/ ‘The Total Amount is:’, wa-amount.
ULINE.
ENDAT.
AT LAST.
SUM.
WRITE:/ ‘The Grand Total Quantity is:’, wa-quan,
/ ‘The Grand Total Amount is:’, wa-amount.
ULINE.
ENDAT.
ENDLOOP.
30-08-2014
Ques: What is the difference between SUM & COLLECT keywords?
Ans: COLLECT keyword is applicable LOOP……….ENDLOOP without usage of Control
Break Statements
COLLECT keyword performs totals inside internal table body based on one (or) more
than one Character Values
SUM keyword performs totals only one Single Character Value for Control Break
Statements places the values in Work Area
COLLECT keyword works outside LOOP………ENDLOOP also where as SUM
keyword can be applied only with in LOOP………ENDLOOP
Rohini kumar
SAP-ABAP 44
INSERT keyword:
Inserts Work Area data at a specific index position inside Internal Table Body
Syntax:
INSERT <work area name> INTO <internal table name> INDEX <line number>.
The above Body is created when you transfer whole Body data to another Body
Example: it1[ ] = it[ ].
* creating variable
DATA n TYPE I.
wa-material = ‘F002’.
wa-quan = 70.
wa-amount = 6000.
APPEND it TO it.
wa-material = ‘F001’.
wa-quan = 100.
wa-amount = 10000.
Rohini kumar
SAP-ABAP 46
APPEND it TO it.
wa-material = ‘F002’.
wa-quan = 100.
wa-amount = 12000.
APPEND it TO it.
Rohini kumar
SAP-ABAP 47
Syntax:
1. MODIFY <database table name> FROM TABLE <internal table name>
2. MODIFY <database table name> FROM TABLE <work area name>
Example-1:
TABLES kna1.
wa-kunnr = ‘0000009083’.
wa-name1 = ‘rahul’.
wa-ort01 = ‘mumbai’.
wa-pstlz = ‘400002’.
APPEND wa TO it.
Example-2:
UPDATE keyword:
Updates specific fields based on given requirement
Syntax:
UPDATE <database table name> SET field1 = wa-filed1, field2 = wa-field2……….
………….. WHERE <codition>.
Rohini kumar
SAP-ABAP 48
Example:
DELETE keyword:
Deletes database tables data based on given requirement
Syntax:
1. DELETE <database table name> FROM TABLE <internal table name>.
2. DELETE FROM <database table name> WHERE <condition>
Example-1:
DELETE kna1 FROM TABLE it.
WRITE:/ ‘number of records deleted:’, SY-DBCNT.
Example-2:
LOOP AT it INTO wa.
DELETE FROM kna1 WHERE kunnr = wa-kunnr.
ENDLOOP.
Example-3:
DELETE FROM kna1 WHERE kunnr = ‘0000009083’.
INSERT keyword:
Inserts data into database table
Syntax:
INSERT INTO <database table name> VALUES <work area name>.
Rohini kumar
SAP-ABAP 49
Assignments-1:
Students Details Report
Sno Sname Phy Chem Maths Total
100 satya 70 60 90 220
101 pruthvi 80 70 60 210
102 raj 90 80 80 250
240 210 230 680
Assignment-2:
Material Quan
F001 50 F001 150
F001 100 F002 220
F002 70
F002 150
Hint:
1. Create 3 Internal Tables
2. Use DELETE ADJACENT DUPLICATE keyword
3. Use CLEAR keyword
Rohini kumar
SAP-ABAP 50
01-09-2014
Data Dictionary
It is also called ABAP Dictionary
It is a repository of data
T Code for Data Dictionary is SE11
Database Table:
It is a set of fields which holds data persistently
Data Element:
Using Data Element you can provide field documentation for a specific field
Conceptually Data Element = Field Lable + Domain
Domain:
It specifies the technical attributes of a field (Data Type & Field Size)
Ques-2: SAP is providing so many tables then why you created a table?
Ans: SAP is not providing table for Allowances,
Similarly SAP is not providing a table for Transportation Details.
Example: Delivery challana number, date, truck number……….etc
Similarly in real time we have to create a table for Customer mail ids for sending invoice
details…….etc
Rohini kumar
SAP-ABAP 51
Table Creation:
Go to SE11
Provide Title: ZMM_TR
Select Create option
Provide Short Description: Truck Entry Details
Note:
In real time we are working with application data.
Application data is 2 types
1. Master Data
2. Transactional Data
Master Data:
It is created only once in Client Database & modified very rarely
Example:
Bank Master Data, Customer Master Data, Vendor Master Data, Employee Master Data…etc
Transactional Data:
It is always created based on Master Data
It is modified frequently in SAP database
Example:
Purchase Order Data, Sales Order Data………..etc
Delivery Class:
It specifies the type of data a table can hold
A-------specifies Application Data
Provide Table View Maintenance: Display Maintenance Allowed (both display & create
entries is allowed)
Select Fields tab
Field key Data Element
TRNO ZTR_DAT
Double click on ZTR_DAT
You will find a message pop-up select Yes option
Select Local Object option
Again you will find a warning: application table should be client specific the press Enter
You will find a pop-up: create the data element then click Yes
Provide Short Description: Truck Number
Provide Domain: ZTR_Domain
Double click on Domain Name (ZTR_Domain)
Click Yes
Select Local Object
Note:
Rohini kumar
SAP-ABAP 52
Step-1:
Navigation for Inserting Records into a Table:
Select Utilites---Table Contents---Create Entries
TRNO:_______
Ddate:_________
Driver:_________
Save (Ctrl+S)
Select Reset button for new record
Step-2:
Navigation for Viewing Records in a Table:
Select Utilities---Table Contents---Display
Select Clock symbol (F8)
Rohini kumar
SAP-ABAP 54
02-09-2014
Structure:
It is a group of fields
Physically it will never hold any data
Structure can be reuse in other programs & other tables
Structure Creation:
Go to SE11
Select Data Type: ZMM_Order
Select Create option
You will find a pop-up select Structure option & press Enter
Provide Short Description: Order Fields
Provide Component: EBELN
BEDAT
Provide Component Type: EBELN
BEDAT
Activate structure (Ctrl+F3)
Select Local Object
You will find warnings pop-up then select Yes
Ignore warnings & go back (F3)
Condition (or) Pre represents for maintaining a Relationship between Two Tables:
In SAP if you want to create relationship between two tables there should be Key Field with
common data between tables even the fields are not common there should be common data
between two tables
MANDT MANDT
DCNO ZDAT_DC
Double click on ZDAT_DC
Click on Yes, Local Object & Yes
Provide Short Description: Data Element for DC
Provide Domain: CHAR10
Select Field Label option
Medium: 20
Field Label: Delivery Challana
Activate Field (Ctrl+F3)
Like add all required fields (DCdate, TRNO)
Select TRNO field
Select Foreign Keys option
You will find a pop-up provide Short Text: Relationship
Check Table: ZMM_TR
Select Generate Proposal button
Select Enter option
Provide Field: .include
Rohini kumar
SAP-ABAP 56
Data Class:
It is a physical storage location (or) table space where tables are stored ultimately after
activation. It is of 3 types
1. APPL0 (holds master data tables)
2. APPL1 (holds transactional data tables)
3. APPL2 (holds organizational & customizing data related tables)
Size Category:
It specifies the probable space requirement for a table in the database
Go to back (F3)
Activate the table (Ctrl+F3)
Select Content option
Apply F4 on Truck Number field
You will find data related to Check Table
Go to back (F3)
Select Utilities--Table Contents--Create Entries
Note:
In real time we are not creating any relationships between tables
Ques: What is the difference between Client Dependant & Client Independent tables?
Ans: A table created without MANDT field is Client Independent table. Client Independent
tables are available in other clients also with data
A table created with MANDT field is Client Dependant table. Client Dependent tables
are available in other clients also without data
Note:
In real time it is always advisable to create Client Dependant tables
Rohini kumar
SAP-ABAP 57
View:
It is a logical table (virtual table) which is created based on other tables
It hires Fields & Data from other tables
Types of Views:
1. Database View
2. Projection View
3. Help View
4. Maintenance View
Database View:
It is always created based on two (or) more than two tables having relationship between them
Rohini kumar
SAP-ABAP 58
Note:
View always holds common data (linked data between two (or) more than two tables)
03-09-2014
Projection View:
It created based on a single table with specific fields
Rohini kumar
SAP-ABAP 59
Search Help:
Using search help you can search application data based on given search criteria
Search help works based on F4 function key
Note:
In a table (or) tables there is large volume of application data. Manual search of data will take
lot of time. SAP is providing an option called Search Help for searching data as for requirement
DCDATE _/ _/ 2 2
Activate search help (Ctrl+F3)
Testing Search Help:
Select F8
You will find a pop-up then press Enter
Note:
In real time calling a search help using MATCHCODE OBJECT is outdated
Testing:
Select Contents option
Apply F4 on TRNO field
You will find an error then
Go to SE38
Provide Program: ZMM_TR
Select Create option
Write PARAMETERS p_tr TYPE ZMM_TR-TRNO.
Activate program then go back & test the table
Rohini kumar
SAP-ABAP 62
Note:
1. In real time for certain requirements when data is not linked with other tables. Data can
be inserted (or) manipulated from table level directly. This can be done by creating a
TMG on that table
2. TMG is allowed only for ZEE tables
Creating TMG:
Go to SE80
Under Test Repository select Function Group option
Provide Function Group: ZMAIL_GR then press Enter
You will find a pop-up create object press Yes
Again you will find a pop-up Short Text: Mail Group then press Enter
Select Local Object
Go to SE11
Provide Database Table: ZSD_MAIL
Select Change option
Select Utilities---Table Maintenance Generator
Provide Authorization Group: &NC&
Provide Function Group: ZMAIL_GR
Select One Step option
Select Scr Number(s) button
You will find a pop-up select Propose Screen Number option then press Enter
Select Create option (F6)
Rohini kumar
SAP-ABAP 64
Creating TCode:
Go to SE93
Provide Transaction Code: ZMAIL
Select Create option
Provide Short Text: Customer Mail Details
Select Transaction with Parameters (Parameter Transaction) option then press Enter
Provide Transaction: SM30
Scroll down to bottom then provide
Name of Screen Field Value
ViewName SZD_MAIL
Update X
Save (Ctrl+s)
Select Favorites---Inset Transaction
Provide Transaction Code: ZMAIL then press Enter
Testing TMG:
Provide Run TCode: ZMAIL then press Enter
Provide Table: ZSD_MAIL
Select Maintain option
Select New Entries button
Insert records & save
ERDAT ERDAT
Uname ZUSER
ERTIM ZTIMEDAT
Select Currency Quantity Fields tab
Provide Amount: Reference Table Reference Field
T001 WAERS
Select Technical Settings button
Provide Data Class: APPL0 (APPL0---for master data & APPL1---for transactional
data)
Provide Size Category: 0 (it means table holds up to 8000 records)
Select Save option (Ctrl+s)
Select back (F3)
Activate Table (Ctrl+F3)
During activation you will find a warning pop-up select Yes
Ignore the warnings & go back (F3)
Go to SE38
Provide Program: SAPLZMAIL_GR
Select Change option
Activate the program (Ctrl+F3)
Go to SM30
Provide Table: ZFI_LIMITS
Select Maintain option
Select New Entries option
Insert records & Save
04-09-2014
Adding Check boxes in Table in TMG:
Create Table First:
Go to SE11
Provide Database Table: ZPP_MACHINE
Select Create option
Provide Short Description: Machine Down Time
Provide Delivery Class: A
Provide Table View Maintenance: Display Maintenance Allowed (both display & create
entries is allowed)
Select Fields tab
Field key Data Element
MANDT _/ MANDT
MACHNO _/ ZMACH_DAT
BUDAT _/ BUDAT
STIME ZSTART_DAT
ETIME ZEND_DAT
DTIME ZDOWN_DAT
CHK ZCHK_DAT
Creating TCode:
Go to SE93
Provide Transaction Code: ZDOWN
Select Create option
Provide Short Text: Machine Down Time
Select Transaction with Parameters (Parameter Transaction) option then press Enter
Provide Transaction: SM30
Scroll down to bottom then provide
Name of Screen Field Value
ViewName SPP_MACHINE
Update X
Save (Ctrl+s)
Select Favorites---Inset Transaction
Provide Transaction Code: ZDOWN then press Enter
Testing:
Go to SE38
Provide Program: SAPLZDOWN
Select Change option
Activate the program (Ctrl+F3)
Go to SM30
Provide Table: ZPP_MACHINE
Select Maintain option
Select New Entries option
Insert records & Save
Rohini kumar
SAP-ABAP 69
Text Table:
Use text table for storing explanatory texts. For storing such texts it is not advisable to store in
Primary Table
Note:
Text Tables works based on Primary & Foreign key relationship
Select SPRAS
Select Foreign keys option
You will find a pop-up then press Yes & then press Enter
Select DEPT
Select Foreign keys option
Provide Check Table: ZTEXT_TAB
Select Generate Proposal button
At bottom select Keys Fields of a Text Table option
Provide Cardinality 1:N then press Enter
Select MANDT
Select Foreign keys option
You will find a pop-up then press Yes & then press Enter
Activate table (Ctrl+F3)
Rohini kumar
SAP-ABAP 71
Step-2:
Adding (or) Removing Fields from Selection Screen:
Select Settings---Fields for Selection option
Select & deselect fields based on requirement then Enter
Step-3:
Transforming Data from SAP to Local File (XL Sheet):
Select F8
Select Local File option (last from 5th option) (Ctrl+Shift+F9)
You will find a pop-up select Spread Sheet option then Enter
You will find a pop-up apply F4 on Directory field
You will find a pop-up then select Desktop
Provide File Name: Customer then select Save option
Select Generate option
Rohini kumar
SAP-ABAP 72
05-09-2014
Types of Tables:
1. Transparent Table
2. Cluster Table
3. Pooled Table
Transparent Table:
It is a default table in SAP
It holds application data (master data & transactional data)
It follows one-to-one relationship (a table created in Presentation Server, if with the same
Structure & Fields another table created in Database Server)
These tables can be accessed even outside SAP
This table allows both Open SQL & Native SQL statements
In real time we are mostly working with Transparent Table
Note:
You cannot apply Inner-Join statement on Cluster Table
Rohini kumar
SAP-ABAP 73
These are normal SQL statements which are converted to embedded SQL using database
interface which is further passed to Buffer, if data is available in Buffer you will get the
response
Rohini kumar
SAP-ABAP 74
Buffering Concept:
Buffering is a way of improving performance which accessing data from database. Whenever
you run a program it will make a request to Buffer for data, if it is not available it will make a
request to Database Server which returns response to Buffer & simultaneously to Program. Next
time whenever you run the same program this time it will collect the data directly from Buffer
Note:
Buffering is important for frequent & common accessing of application data
Types of Buffering:
1. Single Record Buffering
2. Generic Buffering
3. Full Buffering
Full Buffering:(SELECT *)
This buffer is allocated when you are fletching all the fields from database table
Check Table:
It works based on Primary & Foreign key relationship. Data is always validated at Field level
Value Table:
It is a default Check Table & it always maintained under Domain under Value Range option
Rohini kumar
SAP-ABAP 75
09-09-2014
MODULES
MM Module:
Materials Management Module
Departments in MM Module:
1. Purchase
2. Warehouse
3. General Stores
4. Finance in MM
Quotation PO Approval
Vendor Payment
Rohini kumar
SAP-ABAP 76
Purchase Order:
Vendor: PO Date:
Vendor Details:
Payment Terms:
Item [Link] Pieces Unit price Amount
10 2 100 200
-- - - -
- - - -
Brief Flow:
PR
PR Purchase
RFQ
PO
PO Release
GRN
IV
Vendor Payment
2. Purchase Order:
Tcodes: ME21N, ME22N, ME23N
Tables: EKKO, EKPO, EKBE, EKKN, EKAN, EKET
Note: The key field is EBELN (PO number)
3. Goods Receipt:
Rohini kumar
SAP-ABAP 77
Tcodes: MIGO
Tables: MKPF, MIEG
Note: The key field is MBLNR (Material Document Number)
4. Invoice Verification:
Tcodes: MIR0, MIR7
Tables: RBKP, RSEG
Note: The key field is BELNR (Accounting Document Number)
Rohini kumar
SAP-ABAP 78
Inner Joins:
Use inner joins for fletching common data from two (or) more than two tables
Syntax-1:
SELECT LFA1~lifnr LFA1~name1
EKKO~ebeln EKKO~bedat
EKPO~menge EKPO~netpr
INTO TABLE <it> FROM LFA1
INNER JOIN EKKO ON LFA1~lifnr=EKKO~lifnr
INNER JOIN EKPO ON EKKO~ebeln=EKPO~ebeln
WHERE <codition>
Syntax-2:
SELECT A~lifnr A~name1
B~ebeln B~bedat
C~menge C~netpr
INTO TABLE <it> FROM LFA1 AS A
INNER JOIN EKKO AS B ON A~lifnr=B~lifnr
INNER JOIN KKPO AS C ON B~ebeln=C~ebeln
WHERE <codition>
10-09-2014
Example:
Lifnr name1 ebeln lifnr bedat
1 X 100 1 1.6.2014
2 Y 200 1 2.3.2014
3 Z 300 2 3.10.2014
4 M 400 2 5.6.2014
500 3 10.9.2014
Inner Join Left Outer Join
1 X 100 1.6.2014 1 X 100 1.6.2014
1 X 200 2.3.2014 1 X 200 2.3.2014
2 Y 300 3.10.2014 2 Y 300 3.10.2014
2 Y 400 5.6.2014 2 Y 400 5.6.2014
3 Z 500 10.9.2014 3 Z 500 10.9.2014
4 M
Rohini kumar
SAP-ABAP 79
Requirement:
Purchase Order Details based on Vendors
Input:
Vendor code------- s_lifnr to
Company code---- s_bukrs to
Plant ------- s_werks to
Material type------ s_matnr to
Material group---- s_matkl to
Po date-------------- s_bedat to
Summary
Details
1000 EKPO-meins
3000 [Link] 100-100 50 2000 PC
3001 15.6.2014 100-101 70 3000 PC
Totals 120 5000
1001
5001 3.6.201 F001 2 80 PC
5002 9.6.2014 F002 1 90 PC
5003 15.6.2014 F003 3 100 PC
Totals 6 270
Solution:
Go to SE38
Provide Program: ZMM_Purchase_Order_Details
Select Create
Title: Purchase Order Details based on Vendors
Type: Executable Program
Select Save, Local Object
IF p_rb1 EQ ‘X’.
SORT it_po BY lifnr.
Rohini kumar
SAP-ABAP 81
AT NEW lifnr.
WRITE:/10 wa_po-lifnr COLOR 1.
SKIP.
ENDAT.
AT END OF lifnr.
SUM.
FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
[Link] AT 1(135).
WRITE:/ SY-VLINE,
10 ‘Totals’,
70 wa_po-menge,
90 wa_po-netpr,
135 SY-VLINE.
ENDAT.
AT LAST.
SUM.
FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
[Link] AT 1(135).
WRITE:/10 ‘Grand Totals’,
70 wa_po-menge,
90 wa_po-netpr,
135 SY-VLINE.
ENDAT.
ENDLOOP.
ELSE
LOOP AT it_po INTO wa_po.
Rohini kumar
SAP-ABAP 82
AT FIRST.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
[Link] AT 1(135).
WRITE:/ SY-VLINE,
10 ‘Vendor Code’,
25 ‘PO Number’,
35 ‘PO Date’,
45 ‘Material Code’,
60 ‘Unit of Measure’,
70 ‘Quantity’,
80 ‘Unit Price’,
135 SY-VLINE.
[Link] AT 1(135).
ENDAT.
ENDLOOP.
ENDIF.
Rohini kumar
SAP-ABAP 83
LFA1 Table:
This table holds Vendor Master Data
Fields:
1. Lifnr-------Vendor Number
2. Land1-----Country of Vendor
3. Name1----Name of Vendor
4. Ort01-----City of Vendor
5. Pstlz------Postal Code of Vendor
6. Adrnr-----Address Number
Links:
LFA1~adrnr
ADRC~addrnumber
7. Brsch-----Industry Key
EKKO Table:
This table holds Purchase Order Header Data
Fields:
1. Ebeln-------Purchase Order Number
2. Bukrs------Company Code
3. Bsart-------Purchasing Document Type
4. Statu-------Status of Purchase Order
5. Lifnr-------Vendor Number
Links:
LFA1~lifnr
EKKO~lifnr
6. Zterm------Payment Terms
7. Zbd1p-----Cash Discount Percentage
8. Ekorg------Purchase Organization (Purchase Department)
9. Ekgrp------Purchasing Group
[Link]------Currency
[Link]------Exchange Rate
[Link]-------Purchase Order Date
13.Inco1, Inco2-------International Terms for Carrying Bussiness
[Link]------Tax Number
Links:
Rohini kumar
SAP-ABAP 84
EKKO~knumv
KONU~knumv
[Link]------Pricing Procedure
[Link]-------Release Indicator
EKPO Table:
This table holds Purchase Document Item Data
Fields:
1. Ebeln-------Purchase Order Number
Links:
EKKO~ebeln
EKPO~ebeln
2. Ebelp------Item Number
3. Txzo1-----Item Text
4. Matnr-----Material Code
5. Werks-----Plant
6. Lgort------Storage Location
7. Matkl-----Material Group
8. Menge------Purchase Order Quantity
9. Meins------Unit of Measurement
[Link]------Unit Price
[Link]------Total Price
[Link]-----Sales Tax Code
[Link]--------Delivery Completed Indicator
Rohini kumar
SAP-ABAP 85
11-09-2014
Message Handling:
Using MESSAGE keyword you can display your own message
Note:
SY-SUBRC
It returns values after ABAP statement
It returns 0 if an ABAP statement is processed successfully otherwise it returns Exception
(other than 0 value)
Example:
SELECT…………………
…………………………..
IF SY-SUBRC EQ 0.
MESSAGE ‘Data Found’ TYPE ‘I’.
ELSE.
MESSAGE ‘Enter Valid Input’ TYPE ‘E’.
Message Class:
You can store all the messages in Message Class also
T-code for Message Class is SE91
Example:
IF SY-SUBRC EQ 0.
MESSAGE I000(zmm_mess1).
ELSE.
MESSAGE E001(zmm_mess1).
Rohini kumar
SAP-ABAP 86
Message Options:
I-----Information------Information pop-up is displayed
S----Status------Message is displayed in Status Bar
W----Warning-----A yellow color warning message is displayed & Control will switch to next
Screen
E-----Error------Red color message is displayed & Control will stay in same Screen
A----Amend-----Control will switch to Screen 0
X-----Exit-------Control will switch to ABAP Runtime Screen (ST22)
Rohini kumar
SAP-ABAP 87
12-09-2014
Modularization Techniques:
There are 5 modularization techniques in SAP.
They are
1. Subroutines
2. Function Modules
3. Include
4. Macro
5. Field Symbol
In real time you should ensure that every program should be highly readable & reusable
For achieving readability & reusability we have to work with modularization techniques
Subroutines:
Subroutine is like a mini program which can be called within the same program (or) from
other programs
Using Subroutines you can perform Calculations, Call other function modules, Write
statements……….etc
Types of Subroutines:
1. Internal Subroutines
2. External Subroutines
Internal Subroutines:
In this both calling part & definition part are in same program
Syntax:
PERFORM <subroutine name> USING <param1> <param2> ………….
Note:
1. In above syntax PERFORM will call its FORM & simultaneously pass Parameters to its
FORM
2. Subroutine name can be any name. The same name should be used both in PERFORM &
FORM
3. The Parameters defined in PERFORM are called Actual Parameters. These parameters
have global visibility & must be defined in a program
Rohini kumar
SAP-ABAP 88
4. The parameters maintained in FORM are called Formal Parameters. These parameters
have local visibility & are automatically created based on Actual Parameters
5. Actual Parameters will pass values to Formal Parameters by using USING option
6. The number of Actual Parameters should be same that of Formal Parameters
Example:
WRITE:/ ‘Welcome to Subroutine’.
PERFORM sub.
WRITE:/ ‘First Call’.
PERFORM sub.
WRITE:/ ‘Second Call’.
FORM sub.
WRITE:/ ‘Inside Sub’.
ENDFORM.
Output:
Welcome to Subroutine
Inside Sub
First Call
Inside Sub
Second Call
Rohini kumar
SAP-ABAP 89
Debugging:
Break Point:
Using break point the execution of a program can be terminated & until the break point is
reached
Note:
In real time for large programs debugging each & every part of a program is time consuming. If
you know where the problem arises you can directly keep a break point & test the program
Note:
Dynamic break point is used if you are not aware of the exact problem in your program. During
debugging you can set dynamic break point at different, different places & you can remove the
same dynamically
Note:
Static break point is used if you know the exact problem in your program & you want to debug
the same code N number of times
Rohini kumar
SAP-ABAP 90
Example:
DATA v1 TYPE C VALUE ‘a’.
PERFORM sub USING v1.
WRITE:/ v1.
FORM sub USING VALUE(p1).
p1 = ‘b’.
WRITE:/ p1.
ENDFORM.
Output:
b
a
Pass by Reference:
In pass by reference value is not passed to Formal Parameters instead a Pointer (or)
Reference (or) Address is passed to Formal Parameters
Any changes done in Formal Parameters will be effected to Actual Parameters also
Example:
DATA v1 TYPE C VALUE ‘a’.
PERFORM sub USING (or) CHANGING v1.
WRITE:/ v1.
FORM sub USING (or) CHANGING p1.
p1 = ‘b’.
WRITE:/ p1.
ENDFORM.
Output:
b
b
Rohini kumar
SAP-ABAP 91
External Subroutines:
In external subroutines both PERFORM & FORM maintained in separate programs
Example:
Go to SE38
Program: ZMM_GRM_DETAILS
Create
Title: GRM Details
Type: Executable Program
Save
Local Object
Rohini kumar
SAP-ABAP 92
Output:
s_mblnr : 49000000 to 490005000
s_werks: 1000 to 1200
s_budat: 15.11.1994 to 01.06.2009
Execute (F8)
Rohini kumar
SAP-ABAP 93
13-09-2014
MKPF Table:
It holds Material Document Header Data
Fields:
1. Mblnr ---------- Material Document Number
2. Mjahr ---------- Material Document Year
3. Blart ---------- Material Document Type
4. Budat ---------- Material Document Date
5. Xblrn ---------- Reference Document (Purchase Order Document) Number
MSEG Table:
It holds Material Document Item Data
Fields:
1. Mblnr ------ Material Document Number
2. Mjahr ------ Material Document Year
3. Bwart ------ Moment Type
4. Werks ------ Plant
5. Lgort ------- Storage Location
6. Charg ------ Batch Number
7. Lifnr ------- Vendor Account Number
Link:
LFA1-lifnr
MSEG-lifnr
Link:
EKPO-ebeln
MSEG-ebeln
Link:
Rohini kumar
SAP-ABAP 94
EKPO-ebelp
MSEG-ebelp
Rohini kumar
SAP-ABAP 95
Function Module:
Function Module is a piece of code which performs a specific task based on given
requirement
Function Module is a responsible program which always accepts Parameters & returns a
Value
Function Group:
It is a collection of identical objects
Without Function Group you cannot create a Function Module
In one Function Group we can maintain 99 Function Modules
Apart from this SAP providing more than 120000 Function Modules which are
surrounding more than 10000 Function Modules
Syntax:
CALL FUNCTION ‘<FUNCTION MODULE NAME>’. ------ calling part (SE38)
These are Parameters which are pass & return from a Function Module
Exporting:
These are Variables (or) Field Groups which are pass to a Function Module in order to perform
a task
Importing:
Function Modules always returns a value via Importing Parameters
Tables:
These are Internal Tables
Changing:
In latest versions Table Parameters are replaced by Changing
Note:
1. Exporting & Importing Parameters works based on Pass by Value
2. Tables & Changing Parameters works based on Pass by Reference
Step-1:
Go to SE80
Under Test Repository select Function Group
Provide Function Group name: ZCAL_GR
Enter, Yes
Provide Short Text: Function Group for Calculations
Select Save, Local Object
Rohini kumar
SAP-ABAP 97
Step-2:
Go to SE37
Function Module: ZCALC_MOD
Create
Function Group: ZCAL_GR
Short Text: Function Module for Calculations
Enter, Enter
Import tab
Parameter Name Typing Associated Type
X TYPE I
Y TYPE I
Export tab
Parameter Name Typing Associated Type
Z TYPE I
Exception tab
Exception Short Text
No_Data Wrong Calculation
Step-3:
Go to SE38
Program: ZCALC_CALL_SUM
Create
Title: Function Module for Calculations
Type: Executable Program
Save, Local Object
PARAMETERS: a TYPE I,
b TYPE I.
DATA c TYPE I.
x = a.
y = b.
(or)
IMPORTING.
z = c.
Select Pattern option
Call Function: ZCALC_MOD
Assignment:
Accept a number as input say 3900 & the Function Module should return the same number in
figures say Three Thousand and Nine Hundred
Rohini kumar
SAP-ABAP 99
Include Program:
Include Program’s memory is available to any ABAP work bench tool
Example:
INCLUDE ZNC1
WRITE:/ ‘work’.
INCLUDE ZNC2
INCLUDE ZNC1.
WRITE:/ ‘hard’.
REPORT ZNC3
INCLUDE ZNC2.
Note:
Include Program is a program (or) reusable program without any Parameters
Rohini kumar
SAP-ABAP 100
Field Symbol:
Field Symbol is analog to pointer concept in ‘C’ language
It holds Reference of other Variables & returns Value stored in the Reference
Note:
Using Field Symbol you can improve performance of a program
Example:
Go to SE38
Program: ZMM_FIELDSYMBOL
Create
Title: Field Symbols
Type: Executable Program
Save, Local Object
TABLES: LFA1.
INCLUDE ZVEND_DECC.
PERFORM get_data.
PERFORM display_data.
FORM get_data.
Rohini kumar
SAP-ABAP 101
SELECT lifnr land1 name1 ort01 pstlz stras INTO TABLE it_lfa1
FROM LFA1
WHERE lifnr IN s_lifnr
AND land1 IN s_land1.
ENDFORM.
FORM display_data.
LOOP AT it_lfa1 ASSIGNING <l_fs>.
WRITE:/10 <l_fs>-lifnr,
30 <l_fs>-land1,
50 <l_fs>-name1,
70 <l_fs>-ort01,
90 <l_fs>-pstlz,
110 <l_fs>-stras,
ENDLOOP.
ENDFORM.
Note:
Nowadays most of the companies are using Field Symbols instead of Work area
Rohini kumar
SAP-ABAP 102
19-09-2014
FOR ALL ENTRIES keyword:
Using FOR ALL ENTRIES you can fetch common data between two tables
Syntax:
SELECT <field1> <field2>……… FROM <database table> INTO TABLE
<internal table> FOR ALL ENTRIES IN <database internal table> WHERE <condition>
Example:
Segment wise Materials Details
Input:
1. Material Code
2. Material Type
3. Material Group
4. Division
Output:
Material Code Material Description Segment Description
Processing Logic:
1. Get Matnr Spart fields from MARA table based on input
2. Pass Spart field of MARA table to TSPAT table & get Vtext field where Spras field EQ
to ‘EN’
3. Pass Matnr field of MARA table to MAKT table & get Maktx field where Spars field EQ
to ‘EN’
Solution:
Go to SE38
Program: ZMM_SEGMENTWISE_MATERIALS
Create
Title: Segment wise Materials Details
Save, Local Object
* calling Subroutines
PERFORM get_mara.
PERFORM get_makt.
PERFORM get_tspat.
Rohini kumar
SAP-ABAP 104
PERFORM combine_data.
PERFORM display_data.
* getting matnr & spart from MARA table by comparing with input
FORM get_mara.
IF SY-SUBRC NE 0.
MESSAGE ‘Enter Valid Input’ TYPE ‘E’ DISPLAY LIKE ‘I’.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
* getting spart & vtext from TSPAT table by comparing spart of TSPAT with spart of MARA
FORM get_tspat.
ENDFORM.
* getting matnr & maktx from MAKT table by comparing matnr of MAKT with matnr of
MARA
FORM get_makt.
Rohini kumar
SAP-ABAP 105
ENDFORM.
ENDFORM.
* displaying output
FORM display-data.
LOOP AT it_final INTO wa_final.
AT FIRST.
[Link] AT 1(135).
WRITE:/ SY-VLINE,
10 ‘Material Code’,
30 ‘Material Description’,
60 ‘Segment Description’,
135 SY-VLINE.
[Link] AT 1(135).
ENDAT.
20-09-2014
Pitfalls of FOR ALL ENTRIES: (Drawbacks)
1. Before applying FOR ALL EMTRIES it is mandatory to check whether base internal
table is having data (or) not
If you are not checking,
Assume if base internal table is completely empty then it will fetch all records from
database table
2. It act as a SELECT DISTINCT (It removes duplicate set of records from an internal
table)
Example:
BSEG Table
belnr hkgnt
1000 301011
301012
301012 ---- These records will be removed
301012
301013
301014
3. If base internal table is too large there will be performance degration
Note:
In real time always use
1. INNER JOINS for extracting common data between two tables
2. FOR ALL ENTRIES for extracting & combining multiple tables records
Rohini kumar
SAP-ABAP 107
MARA Table:
It holds Material Master Data
Fields:
1. Matnr -------- Material Number
2. Ersda --------- Date of Creation
3. Ernam -------- Person who Created that Material
4. Mtart --------- Material Type
5. Mbrsg -------- Industry Key
6. Matkl --------- Material Group
7. Bismt --------- Old Material Number
8. Miens --------- Unit of Measurement
9. Brgew -------- Gross Weight
[Link] -------- Net Weight
[Link] ---------- Division Code
MAKT Table:
TSPAT Table:
It holds Division Description Details
Fields:
1. Spras --------- Language Key
2. Spart --------- Division Code
3. Vtext --------- Division Description
Rohini kumar
SAP-ABAP 108
SD Module:
Sales & Distribution Module
Departments in SD Module:
1. Marketing
2. Excise
3. Billing
4. Finance part of SD
Process Flow:
Inquiry
Quotation
Sales Order
Delivery
Excise Invoice
Invoice
FI Module
Quotation:
Tcodes: VA21, VA22, VA23
Tables: VBAK, VBAP
Note: The key field is vbeln
Sales Order:
Tcodes: VA01, VA02, VA03
Tables: VBAK, VBAP
Note: The key field is vbeln
Delivery:
Rohini kumar
SAP-ABAP 109
Excise Invoice:
Tcodes: J1IS, J1IEX, J1ID
Tables: J_1IEXCHDR, J_1IEXCDTL, J_1IMOCUST
Note: The key field is exnum
Invoice:
Tcodes: VF01, VF02, VF03
Tables: VBRK, VBRP
Note: The key field is vbeln (Invoice Number)
Other Tables:
VBKD, VBFA, VBPA, VBUK, VBUV, KONV, KONR
Rohini kumar
SAP-ABAP 110
String Operations:
1. SHIFT
2. TRANSLATE
3. REPLACE
4. STRLEN
5. OFFSET FUNCTIONALITY
6. SPLIT
7. CONCATINATE
8. CONDENSE
SHIFT keyword:
It shifts a specific string to left (or) right side by deleting required options in a particular string
Syntax-1:
SHIFT <string> LEFT DELETING LEADING <option>
Syntax-2:
SHIFT <string> RIGHT DELETING TRAILING <option>
TRANSLATE keyword:
It converts the case of a particular string from lower to upper and vice-versa
Syntax-1:
TRANSLATE str TO UPPER CASE
Syntax-2:
TRANSLATE str TO LOWER CASE
Example: SATYA--------satya
DATA: str(10) TYPE C VALUE ‘SATYA’.
TRANSLATE str TO LOWER CASE.
WRITE:/ str
Output:
satya
REPLACE keyword:
Rohini kumar
SAP-ABAP 111
Syntax:
REPLACE <string1> WITH <string2> INTO <final string>
Example: rupees-------dollars
DATA: str(30) TYPE C VALUE ‘one thousand rupees’.
REPLACE ‘rupees’ WITH ‘dollars’ INTO str.
WRITE:/ str.
Output:
one thousand dollars
STRLEN keyword:
It returns length of a string
Syntax:
n = STRLEN ( str ).
Where n is Integer Variable
Example:
DATA: str(10) TYPE C VALUE ‘satya’,
n TYPE I.
n = STRLEN ( str ).
WRITE:/ n.
Output:
5
1. st = str + 2 ( 1 ). --------output------ C
2. st = str + 4 ( 2 ). --------output------ EF
SPLIT keyword:
It splits a single string based on special charectors
Syntax:
SPLIT <string> AT <special charector> INTO <stirng1> <string2> <string3>…..
Example:
DATA: str(10) TYPE C VALUE ‘cool-drink’,
Rohini kumar
SAP-ABAP 112
str1(10) TYPE C,
str2(10) TYPE C.
SPLIT str AT ‘-’ INTO str1 str2.
WRITE:/ str1,
str2.
Output:
cool
drink
CONCATENATE keyword:
It concatenates two (or) more than two strings into a final string
Syntax:
CONCATENATE <str1> <str2> <str3> INTO <final string> SAPARATED BY
<special character>.
Example-1:
DATA: data(10) TYPE C.
CONCATENATE SY-DATUM + 6(2) SY-DATUM + 4(2) SY-DATUM + 0(4) INTO
date SAPARATED BY ‘.’.
WRITE:/ date.
Output:
20.09.2014
Example-2:
DATA: year(4),
mon(2),
day(2),
date(10).
year = SY-DATUM + 0(4).
mon = SY-DATUM + 4(2).
day = SY-DATUM + 6(2).
CONCATENATE day mon year INTO date SAPARATED BY ‘.’.
WRITE:/ date.
Output:
20.09.2014
Rohini kumar
SAP-ABAP 113
CONDENSE keyword:
It combines a specific string by removing gaps between them
Syntax:
CONDENSE <string> NO-GAPS.
Example:
DATA: str(20) TYPE C VALUE ‘satya narayana’.
CONDENSE str NO-GAPS.
WRITE:/ str.
Output:
satyanarayana
Assignment:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Rohini kumar
SAP-ABAP 114
Looping Statements:
Branching:
a. Conditional Statements
b. Unconditional Statements
Conditional Statements:
1. IF…………ENDIF.
Sytax-1:
IF <condition>.
Do this
ENDIF.
Sytax-2:
IF <condition>.
Do this
ELSE.
Do this
ENDIF.
Sytax-3:
IF <condition>.
Do this
ELSE IF <condition>
Do this
ELSE.
Do this
ENDIF.
Note:
Use ELSE IF condition only a single condition is true
2. CASE…………..ENDCASE
Syntax:
CASE <expression>.
WHEN <exp1>.
Do this
WHEN <exp2>.
Do this
……….
……….
Rohini kumar
SAP-ABAP 115
WHEN OTHERS.
Do this
ENDCASE.
3. WHILE statement:
Syntax:
WHILE <condition>
----------
----------
ENDWHILE.
Unconditional Statements:
1. DO…………….ENDDO.
Syntax-1:
DO.
---------
---------
ENDDO.
Syntax-2:
DO <n> TIMES.
---------
---------
ENDDO.
Syntax-3:
DO <n> TIMES VARYING <expression> FROM <m> NEXT <n>.
---------
---------
ENDDO.
Operators:
a. Logical Operators
b. Relational Operators
Logical Operators:
1. AND
2. OR
3. NOT
Relational Operators:
1. GT----- >
Rohini kumar
SAP-ABAP 116
2. LT ----- <
3. GE ---- >=
4. LE ---- <=
5. NE ------ <>
6. EQ ------ =
Rohini kumar
SAP-ABAP 117
CONTINUE keyword:
Whenever CONTINUE is executed it terminates the current LOOP pass & returns the control to
next LOOP pass
Example:
DATA rem TYPE I.
DO 20 TIMES.
rem = SY-INDEX MOD 2.
IF rem NE 0.
CONTINUE.
ENDIF.
WRITE:/ SY-INDEX.--------- current LOOP pass number
ENDDO.
Output:
2 4 6 8 …………………… 20
CHECK keyword:
If check expression is true it will allows the remaining LOOP pass else it will terminates the
current loop pass
Syntax:
CHECK <expression>.
Example:
DATA rem TYPE I.
DO 20 TIMES.
rem = SY-INDEX MOD 2.
CHECK rem = 2.
WRITE:/ SY-INDEX.--------- current LOOP pass number
ENDDO.
22-09-2014
EXIT keyword:
When the keyword EXIT is executed the whole loop will be terminated
Example:
DATA: n TYPE I VALUE 10.
DO n TIMES.
IF SY-INDEX >= n.
EXIT.
ENDIF.
Rohini kumar
SAP-ABAP 118
WRITE:/ SY-INDEX.
ENDDO.
Rohini kumar
SAP-ABAP 119
Mathematical Operations:
Ex: 5.55
1. FRAC -------- 0.55
2. CEIL --------- 6.0
3. FLOOR ----- 5.0
4. SIGN -------- 1 (+)
5. ABS --------- 5.55 (always returns only positive value)
6. TRUNC ---- 5.0
Ex: 6 / 2
7. REM -------- 0
8. DIV --------- 3
9. MOD ------- 0
FRAC:
It returns fraction part from a decimal value
CEIL:
It returns highest value in existing decimal value
FLOOR:
It returns lowest value from a particular decimal value
SIGN:
It returns the signature (positive (or) negative) from a particular numeric value
ABS:
It returns absolute value from a numeric value
TRUNC:
It truncates (removes) decimal part from a numeric value
DIV:
It returns devisor
Example:
DATA: n TYPE P DECIMALS 2 VALUE ‘5.55’,
m TYPE P DECIMALS 2.
m = FRAC(n). WRITE:/ m
m = TRUNC(n). WRITE:/ m
Rohini kumar
SAP-ABAP 120
m = CEIL(n). WRITE:/ m
m = FLOOR(n). WRITE:/ m
m = ABS(n). WRITE:/ m
m = SIGN(n). WRITE:/ m
Assignments:
1. Formats
a. 1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
b. *
* *
* * *
* * * *
* * * * *
c. *
* * *
* * * * *
* * * * * * *
Rohini kumar
SAP-ABAP 121
Question: Explain why you written Export Import Functionality in your real time?
Answer:
The above functionality is for reusability
Sometimes we needs to write a logic which already provided by a program
Instead of writing the same program from beginning you can use the above functionality
for getting the data from other programs
Example:
Go to SE38
Program: YIMPORT_PROG
Create
Title: Import Program
Type: Executable Program
Save, Local Object
TABLES: EKPO.
TABLES: EKPO.
SELECT ebeln matnr menge netpr FROM EKPO INTO TABLE it_ekpo
WHERE matnr IN s_matnr
AND werks IN s_werks.
Output:
Execute IMPORT_PROG
s_matnr 100-100 to 100-500
s_werks 1000 to 1100
Rohini kumar
SAP-ABAP 124
23-09-2014
Support Project:
In Support Project End user will raise Tickets (Issues) based on priority
Issues are directly raised by End user in Production Client which are automatically
updated to Solution Manager
Solution Manager is a free Ticketing Tool given by SAP for raising tickets
Help Desk people from Consulting Company will receive the Tickets & forward it to
respective Functional Consultants based on priority
If the issue is Functional (related to Application, Customizing Issue……….etc) then
Functional Consultant will resolve it
If the issue is Technical (related to Programming, Enhancement…….etc) then Functional
Consultant will prepare Functional Document & forward it to Technical Consultant
(ABAPER)
Based on Functional Document ABAPER will create Technical Document & forward it
to Team Leader for approval
If everything is fine ABAPER will develop the Object in Development Client
Once the Object is developed then series of Testing will done by ABAPER, Functional
Consultant & End user
Finally after final testing by End user the Object is transported to Production System with
the help of Basis Consultant
Rohini kumar
SAP-ABAP 125
System Landscape:
It is also known as Correction & Transportation System (CTS)
In real time End user will raise issues which are received by Functional Consultant
For Technical Issues Functional Consultant will prepare Functional Document & based
on that Technical Consultant will prepare Technical Document
Technical Consultant will forward Technical Document to Team Leader who will
approve it
Objects are developed in Development Client
While creating Objects system will prompt you for to save the object
In real time Objects are always saved in a Package
Once Objects are saved system will generate Request Numbers (Main Request Number &
Sub Request Number)
Objects are always stored in Sub Request Number
Once Object is developed based on coding standards you should release Request
Numbers in SE10
Then you should forward a mail to Basis Consultant for transporting Transport Request
(TR) numbers from Development Client to Quality Client
In Quality Server testing is done by ABAPER, Functional Consultant, End user
If everything is fine again you will forward a mail to Basis Consultant to transport the TR
Numbers from Quality Server to Production Server
4. Quality Server is meant for testing. Here recent data (10 days back) is available
5. Production Server is Live Server in real time. It holds live data of a company. Day to day
activities of a company are maintained (or) stored in Production Server
6. Only Development Client is in change mode. Quality & Production Clients are always in
display mode
7. In real time as an ABAPER you can access Development & Quality Clients
8. End user can access Quality & Production Clients
9. FC can access any of these Clients
[Link] is a collection of Objects. In real time we are not creating any package.
Throughout the life time in a company we are working with a single package
Rohini kumar
SAP-ABAP 126
[Link] are always stored in Sub Request Number is transported from one client to
another
[Link] real time Basis Consultant is responsible for transporting Request Numbers from one
client to another
[Link] a Request Number is released (or) transported system will prompt you for a new
Request Number
[Link] real time as a TC we have to work with Work Bench Request. FC will work with
Customizing Request
[Link] Numbers are always forwarded from Development to Quality & Quality to
Production Clients
Note:
Reverse transportation of a Request Number is not possible under any circumstances in SAP
[Link] real time all the issues are posted in Production System & Threads are updated in
Solution Manager
17.E071 is a standard table which holds all Objects & their Request Numbers history
[Link] real time our job to create Object & release the Request Number in SE10
[Link] real time different companies are having different System Landscapes. In some
companies there will 1 Development & 3 Testing Clients & in some 1 Development & 1
Testing Client & in some companies Development & Quality Clients are Cross Clients
[Link] Quality Server only 85% to 90% of testing is done as it holds recent data. If you want
to test the live data you have to work with Production Server
24-09-2014
Steps in System Landscape:
1. Work with SE80 (create a Package)
2. Work with SE38 (create a Program)
3. Work with SE10 (release Sub Request Number, release Main Request Number)
Step-1:
Go to SE80
Select Package option
Provide Package name: ZABAP
Yes
Short Description: New Package
Save
(OR)
Go to SE11
Provide Database Table name: V_TDEVC
Select Display option
Select Contents option
Select Package option
Rohini kumar
SAP-ABAP 127
Step-2:
Go to SE38
Program: ZDEMO_PACKAGE
Create
Title: Package Program
Type: Executable Program
Save
Package: ZABAP
Save (Enter)
Note:
1. By default you may find a Request Number. The Request Number belongs to some other
ABAPER
2. Never select Enter option on that pop-up
Step-3:
Go to SE10
Select Work Bench Request
Under Request Status, select Modifiable check box & deselect Released check box
Select Display option
Expand Main Request Number
Select Sub Request Number
Select Truck Symbol (F9)
Select Main Request Number
Select Truck Symbol (F9)
Go to Back (F3)
Select Released check box & deselect Modifiable check box
Select Display option
Note:
Rohini kumar
SAP-ABAP 128
Up to here you have to perform in real time, from here you have to send a mail to your Basis
Consultant for transporting TR-Number from Development Client to Quality Client
Once the Request Number is transported from Development Client to Quality Client as a
TC now you have to login to Quality Server & test the Object
If it is fine now you will send a mail to your FC to test the same
If it is fine FC will update the Tread in Solution Manager to test the Object
Similarly End user will perform final testing in Quality Server
Note:
Always store identical Objects in one Request Number & different Objects in different Request
Numbers
Rohini kumar
SAP-ABAP 129
Version Management:
Using Version Management you can get the history of a program with Request Numbers,
User name, Date of creation & change
It is highly useful to programmer if requires to retrieve old version instead of current
version
Example:
Go to SE38
Program: ZDEMO
Select Utilities ----------- Versions ------ Version Management
Ques: How you can store an Object from Local Object to existing Package?
Ans:
Go to SE38
Program: name which is stored in Local object
Select Goto ---- Object Directory Entry
Select Change option
Package: ZABAP
Save
Ques: How you can delete an Object from existing Request Number?
Ans:
Go to SE11
Database Table: E071
Display
Contents option
Object Name; program name (ZDEMO)
Execute (F8)
Go to SE10
Select Display
Expand Main Request Number
Expand Sub Request Number
Expand Program option
Select your program
Select Delete option
You will find a message, Enter
Yes
Rohini kumar
SAP-ABAP 130
Source Code:
It is nothing but source code of a program
Attributes:
It specifies attributes of a program (Title, Type, Date of creation & Change,………..etc)
Documentation:
Using this option you can provide documentation for a program
Example:
Go to SE38
Program: ZDEMO
Documentation
Change
Provide Purpose: The report is displaying segment wise materials details
Provide Integration: No
Provide Prerequisites: s_matnr
s_werks
Save
Text Elements:
Using Text Elements you can maintain Labels (or) Selection Screen Fields
Example:
Go to SE38
Program: ZDEMO
Text Elements
Change
Selection Text
Name Text
s_matnr Material Code
s_werks Plant
Activate
Rohini kumar
SAP-ABAP 131
Variants:
Using Variants you can provide default input values for a Selection Screen
In background scheduling report, the reports are executed automatically by system in
background. For such reports the input values are supplied by using Variants
Example:
Go to SE38
Program: ZDEMO
Variants
Change
Variant: ZVAR
Create
Enter input values
i.e. 100-100 to 100-500
fart
Select Attribute option (F6)
Meaning: Variant Creation
Save
Run the report
Select Get Variant option
Double click on variant name (ZVAR)
Rohini kumar
SAP-ABAP 132
ABAP-EDITOR
Interview Questions & Answers:
1Q: What is ERP?
Ans: ERP is a package under which all the business resources are integrated in one system
4Q: Where you can also execute programs other than ABAP Editor (SE38)?
Ans: We can also execute programs in Object Navigator (SE80)
8Q: Which file is generated by system when you execute the program?
Ans: [Link] file
Rohini kumar
SAP-ABAP 133
13Q: What is the difference between Database table & Internal table?
Ans: Database Table Internal Table
4. It is created in Database Server ------- 1. It is created in Application Server
5. It holds data permanently ------- 2. It holds data temporarily
6. It holds only specific type of data ----- 3. It holds data of different tables of at one place
19Q: Suppose there are more than two Character Fields then what is the roll of COLLECT
keyword?
Ans: If there are more than two Character Fields it will collect the data (adds) only when both
the Character Fields are same
Ans:
APPEND always appends record to Internal Table (if record exists (or) not)
MODIFY always modifies (adds field value) only if record exists in an Internal Table
22Q: What will happen if CLEAR is providing before Work Area & the same CLEAR is
provided in after Work Area?
Ans:
If CLEAR is provided before Work Area data so nothing is transferred from Work Area
to Virtual Page (hence no output)
If CLEAR is provided after Work Area, data is transferred from Work Area to Virtual
Page then Work Area is cleared (hence you will find output)
Rohini kumar
SAP-ABAP 135
INTERNAL TABLES
All duplicates with same combination of matnr and werks will be deleted
Rohini kumar
SAP-ABAP 136
Rohini kumar
SAP-ABAP 137
Ans:
Field groups are nothing but a similar type of fields grouped under single name (group)
or grouping of the fields is called field groups.
Internal tables are stored temp memory/in buffer for the further processing of the fields.
Rohini kumar
SAP-ABAP 138
Rohini kumar
SAP-ABAP 139
An additional restriction for hashed tables is that they may not contain more than 2
million entries.
The line types of internal tables can be any ABAP data types - elementary, structured, or
internal tables.
The individual lines of an internal table are called table lines or table entries.
Each component of a structured line is called a column in the internal table.
Rohini kumar
SAP-ABAP 140
15Q: What are internal tables, value tables, check tables, transparent tables?
Ans:
Internal table:
It is a standard data type object, which exists only during the runtime of the program.
Check table:
Check table will be at field level checking.
Value table:
Value table will be at domain level checking
Ex: scarr table is check table for carrid.
Transparent table:
Exists with the same structure both in dictionary as well as in database exactly with the same
data and fields
16Q: Explain choosing a table type in internal table.
Ans : The table type (and particularly the access method) that you will use depends on how the
typical internal table operations will be most frequently executed.
18Q: What is the difference between internal table and work area?
Ans :
An internal table is a run time instance.
It get created when program starts execution.
*It get destroyed when program terminates.
It has two different parts:
Header Line (optional)
Body (Compulsory).
*Any value that comes to (or) goes from internal table, that travels through header line.
Rohini kumar
SAP-ABAP 141
Rohini kumar
SAP-ABAP 142
DATA DICTIONARY
Interview Questions & Answers:
1Q: Have you ever created a Z-Table? Why explain the requirement?
Ans: Yes, SAP is not providing table for Allowances. Simultaneously SAP is not providing a
table for Transportation Details. Simultaneously in real time we have to create a table for
Customer Mail Ids for sending invoice details………….etc
5 Q: What is the difference between Top-Bottom & Bottom-Top approach of crating tables?
Ans: Top-Bottom:
Table---Data Element----Domain
Bottom-Top:
Domain-----Data Element----Table
Rohini kumar
SAP-ABAP 143
8 Q: What is the difference between Open SQL statements & Native SQL statements?
11Q: Mention some Cluster Tables that you are using in real time?
Ans: These tables hold SAP proprietary format data (system data, statistical data, control
data……)
Example: BSEG, KONU
Ans:
Using .INCLUDE you can add a Structure in N no. of tables
.INCLUDE is best for adding Structure in ZEE tables
Using APPEND STRUCTURE you can add a Structure only in a single table
APPEND STRUCTURE is best for adding Structure in Standard Tables
Domain:
It specifies the technical attributes of a field (Data Type & Field Size)
21Q: What is the difference between Client Dependent Table & Client Independent Table?
Ans:
A table created without MANDT field is Client Independent table. Client Independent
tables are available in other clients also with data
A table created with MANDT field is Client Dependant table. Client Dependent tables
are available in other clients also without data
23Q: What is the difference between Master Data & Transactional Data?
Ans: Master Data:
It is created only once in Client Database & modified very rarely
Example:
Bank Master Data, Customer Master Data, Vendor Master Data, Employee Master Data…etc
Transactional Data:
It is always created based on Master Data
It is modified frequently in SAP database
Example:
Purchase Order Data, Sales Order Data………..etc
Size Category:
It specifies the probable space requirement for a table in the database
25Q: What is TMG? What is the need of creating TMG in real time?
Ans:
Using TMG you can directly Insert, Update, Delete data from a database table
Rohini kumar
SAP-ABAP 146
In real time for certain requirements when data is not linked with other tables. Data can
be inserted (or) manipulated from table level directly. This can be done by creating a
TMG on that table
27Q: How you can create List Boxes & Check Boxes in TMG?
28Q: How you can provide Default Values such as Date & Time automatically in a table
whenever user select Save option?
29Q: Mention some important Events that you created with TMG?
Ans: CREATE_ENTRY
Ans:
Rohini kumar
SAP-ABAP 148
Ans:
It is also called ABAP Dictionary
It is a repository of data
T Code for Data Dictionary is SE11
Rohini kumar
SAP-ABAP 150
7Q : How many types of size categories and data classes are there?
Ans:
There are five size categories (0-4) and
11 data classes
Only three of size categories are appropriate for application tables:
1. APPL0- Master data (data frequently accessed but rarely updated)
2. APPL1- Transaction data (data that is changed frequently)
3. APPL2- Organizational data (customizing data that is entered when system is configured and
then rarely changed)
Rohini kumar
SAP-ABAP 151
15Q: How is conversion of data types done between ABAP/4 & DB layer?
Ans : Conversion between ABAP/4 data types and the database layer is done within the
database interface.
16Q: How is conversion of data types done between ABAP/4 & external level?
Ans : Conversion between the external layer and the ABAP/4 layer is done in the SAP dialog
manager DYNP.
C: Character.
D: Date, format YYYYMMDD.
F: Floating-point number in DOUBLE PRECISION (8 bytes).
I: Integer.
N: Numerical character string of arbitrary length.
P: Amount of counter field (packed; implementation depends on h/w platform).
S: Time Stamp YYYYMMDDHHMMSS.
V: Character string of variable length, length is given in the first two bytes.
X: Hexadecimal (binary) storage.
19Q: How can we set the table spaces and extent sizes?
Ans : You can specify the extent sizes and the table space (physical storage area in the
database) in which a transparent table is to be stored by setting the size category and data class.
Rohini kumar
SAP-ABAP 153
26Q: What are the uses of the information in the Data dictionary?
Ans :
The following information is directly taken from the Data dictionary:
• Information on fields displayed with F1 help.
• Possible entries for fields displayed with F4 help.
• Matchcode and help views search utilities.
29Q: In the ABAP/4 Dictionary Tables can be defined independent of the underlying database
(T/F).
Ans: True.
Rohini kumar
SAP-ABAP 154
31Q: A field containing currency amounts (data type CURR) must be assigned to a reference
table and a reference field. Explain.
Ans:
As a reference table, a system containing all the valid currencies is assigned or any other
table, which contains a field with the currency key format.
This field is called as reference field.
The assignment of the field containing currency amounts to the reference field is made at
runtime.
The value in the reference field determines the currency of the amount.
32Q: A field containing quantity amounts (data type QUAN) must be assigned to a reference
table and a reference field. Explain?
Ans :
As a reference table, a system table containing all the valid quantity units is assigned or
any other table, which contains a field with the format or quantity units (data type UNIT).
This field is called as reference field.
The assignment of the field containing quantity amounts to the reference field is made at
runtime.
The value in the reference field determines the quantity unit of the amount.
33Q: What is the significance of Technical settings (specified while creating a table in the data
dictionary)?
Ans:
By specifying technical settings we can control how database tables are created in the database.
The technical settings allows us to
• Optimize storage space requirements.
• Table access behavior.
• Buffering required.
• Changes to entries logged.
Ans:
• The delivery class controls the degree to which the SAP or the customer is responsible for
table maintenance.
• Whether SAP provides the table with or without contents.
• Determines the table type.
• Determines how the table behaves when it is first installed, at upgrade, when it is transported,
and when a client copy is performed.
36Q: What is the max. no. Of structures that can be included in a table or structure.
Ans: Nine.
Ans:
• Append Structures and
• Customizing Includes.
40Q: If a table that is to be extended contains a long field, we cannot use append structures
why?
Ans:
Long fields in a table must always be located in the end, as the last field of the table.
If a table has an append structure the append line must also be on the last field of the
table.
41Q: Can we include customizing include or an append structure with Pooled or Cluster tables?
Ans: No.
42Q: What are the two ways for restricting the value range for a domain?
Rohini kumar
SAP-ABAP 156
Ans:
• By specifying fixed values.
• By stipulating a value table.
43Q: Structures can contain data only during the runtime of a program (T/F)
Ans: True.
46Q: The data of a view is not physically stored, but derived from one or more tables (t/f)
Ans: True.
47Q: What are the 2 other types of Views, which are not allowed in Release 3.0?
Ans:
• Structure Views.
• Entity Views.
*50Q: What is the max no of match code Id's that can be defined for one Match code object?*
Ans: A match code Id is a one character ID that can be a letter or a number.
*51Q: Can we define our own Match Code ID's for SAP Matchcodes?*
Ans : Yes, the number 0 to 9 are reserved for us to create our own Match Code Ids for a SAP
defined Match code object.
Rohini kumar
SAP-ABAP 157
If the data in one of the base tables of a match code ID changes, the match code data has
to be updated.
The update type stipulates when the match code is to be updated and how it is to be done.
The update type also specifies which method is to be used for Building match codes.
You must specify the update type when you define a match code ID.
53Q: Can matchcode object contain Ids with different update types?
Ans: Yes.
55Q: What are the two different ways of building a match code object?
Ans :
A match code can be built in two different ways:
1. Logical structure:
The match code data is set up temporarily at the moment when the match code is accessed.
(Update type I, k).
2. Physical Structure:
The match code data is physically stored in a separate table in the database. (Update type A, S,
P).
Rohini kumar
SAP-ABAP 158
56Q: What are the differences between a Database index and a match code?
Ans:
• Match code can contain fields from several tables whereas an index can contain fields from
only one table.
• Match code objects can be built on transparent tables and pooled and cluster tables.
58Q: Can you delete a domain, which is being used by data elements?
Ans: No.
62Q: Can you delete data element, which is being used by table fields.
Ans : No.
63Q: Can you define a field without a data element?
Ans : Yes. If you want to specify no data element and therefore no domain for a field, you can
enter data type and field length and a short text directly in the table maintenance.
Rohini kumar
SAP-ABAP 159
Ans:
• Database View
• Help View
• Projection View
• Maintenance View
Rohini kumar
SAP-ABAP 160
LFA1 Table:
This table holds Vendor Master Data
Fields:
1. Lifnr-------Vendor Number
2. Land1-----Country of Vendor
3. Name1----Name of Vendor
4. Ort01-----City of Vendor
5. Pstlz------Postal Code of Vendor
6. Adrnr-----Address Number
Links:
LFA1~adrnr
ADRC~addrnumber
7. Brsch-----Industry Key
Rohini kumar
SAP-ABAP 161
EKKO Table:
This table holds Purchase Order Header Data
Fields:
1. Ebeln-------Purchase Order Number
2. Bukrs------Company Code
3. Bsart-------Purchasing Document Type
4. Statu-------Status of Purchase Order
5. Lifnr-------Vendor Number
Links:
LFA1~lifnr
EKKO~lifnr
6. Zterm------Payment Terms
7. Zbd1p-----Cash Discount Percentage
8. Ekorg------Purchase Organization (Purchase Department)
9. Ekgrp------Purchasing Group
[Link]------Currency
[Link]------Exchange Rate
[Link]-------Purchase Order Date
13.Inco1, Inco2-------International Terms for Carrying Bussiness
[Link]------Tax Number
Links:
EKKO~knumv
KONU~knumv
[Link]------Pricing Procedure
[Link]-------Release Indicator
Rohini kumar
SAP-ABAP 162
EKPO Table:
This table holds Purchase Document Item Data
Fields:
1. Ebeln-------Purchase Order Number
Links:
EKKO~ebeln
EKPO~ebeln
2. Ebelp------Item Number
3. Txzo1-----Item Text
4. Matnr-----Material Code
5. Werks-----Plant
6. Lgort------Storage Location
7. Matkl-----Material Group
8. Menge------Purchase Order Quantity
9. Meins------Unit of Measurement
[Link]------Unit Price
[Link]------Total Price
[Link]-----Sales Tax Code
[Link]--------Delivery Completed Indicator
Rohini kumar
SAP-ABAP 163
MKPF Table:
It holds Material Document Header Data
Fields:
1. Mblnr ---------- Material Document Number
2. Mjahr ---------- Material Document Year
3. Blart ---------- Material Document Type
4. Budat ---------- Material Document Date
5. Xblrn ---------- Reference Document (Purchase Order Document) Number
Rohini kumar
SAP-ABAP 164
MSEG Table:
It holds Material Document Item Data
Fields:
1. Mblnr ------ Material Document Number
2. Mjahr ------ Material Document Year
3. Bwart ------ Moment Type
4. Werks ------ Plant
5. Lgort ------- Storage Location
6. Charg ------ Batch Number
7. Lifnr ------- Vendor Account Number
Link:
LFA1-lifnr
MSEG-lifnr
Link:
EKPO-ebeln
MSEG-ebeln
Link:
EKPO-ebelp
MSEG-ebelp
Rohini kumar
SAP-ABAP 165
MARA Table:
It holds Material Master Data
Fields:
1. Matnr -------- Material Number
2. Ersda --------- Date of Creation
3. Ernam -------- Person who Created that Material
4. Mtart --------- Material Type
5. Mbrsg -------- Industry Key
6. Matkl --------- Material Group
7. Bismt --------- Old Material Number
8. Miens --------- Unit of Measurement
9. Brgew -------- Gross Weight
[Link] -------- Net Weight
[Link] ---------- Division Code
Rohini kumar
SAP-ABAP 166
MAKT Table:
TSPAT Table:
It holds Division Description Details
Fields:
1. Spras --------- Language Key
2. Spart --------- Division Code
3. Vtext --------- Division Description
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
Rohini kumar
SAP-ABAP 167
Rohini kumar
SAP-ABAP 168
Rohini kumar
SAP-ABAP 169
Rohini kumar
SAP-ABAP 170
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
2. PBO will brings the data from Program Variables to Screen
Rohini kumar
SAP-ABAP 171
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)
4. Run the T code
Rohini kumar
SAP-ABAP 172
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
Rohini kumar
SAP-ABAP 173
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
Rohini kumar
SAP-ABAP 174
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.
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)
Rohini kumar
SAP-ABAP 176
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
Enter
Create Request
Rohini kumar
SAP-ABAP 177
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.
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
Activate screen
Rohini kumar
SAP-ABAP 179
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)
Rohini kumar
SAP-ABAP 180
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
BRGEW BRGEW
TWT TWT
Rohini kumar
SAP-ABAP 181
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)
Right click on ZTCGR function group
Create
Rohini kumar
SAP-ABAP 182
Screen
You will find a pop-up
Program: SAPLZTCGR
Screen Number: 100
Enter
Short Description: Screen 100
Layout
F6
Table Name: LFA1
Enter
Select Lifnr
Enter
Place the field on top of the screen
Place a Box on the screen
Double click on box frame
Text: Truck Entry
Close
Place Table Control (last from 4th option) on the box
Double click on Table Control
At bottom under Separators check Vertical & check Horizontal
Close
F6
Table Name: ZMM_DEMO
Select all fields except MANDT
Enter
Place the fields on table control
Place 5 push buttons under table control
Provide Text & FCT code as per requirement
Flow Logic
Step-3:
Place cursor under PROCESS AFTER INPUT.
MODULE USER_DML.
LOOP AT it_demo.
FIELD: zmm_demo-dcno,
zmm_demo-dcdate,
zmm_demo-tno,
zmm_demo-brgew,
zmm_demo-twt
zmm_demo-ntgew
zmm_demo-ebeln,
Rohini kumar
SAP-ABAP 183
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)
Yes
Enter
Enter
Yes
Place cursor between MODULE…………..ENDMODULE of USER_COMMAND_100
CASE SY-UCOMM.
WHEN ‘DISPLAY’.
SELECT * FROM zmm_demo INTO TABLE it_demo WHERE lifnr = lfa1-lifnr.
WHEN ‘RESET’.
REFRESH it_demo.
WHEN ‘EXIT’.
LEAVE TO SCREEN 0.
ENDCASE.
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’.
Yes
Yes
Rohini kumar
SAP-ABAP 186
Rohini kumar
SAP-ABAP 187
Object:
Former Loan Application
Cooperative Bank
POSTAL CODE
TEL
ADDRESS
Rohini kumar
SAP-ABAP 188
APPROVE
LOAN PAID
INTEREST
A/C Number field is mandatory
DUE FName, Loan Amount & Interest fields are in display mode
When you enter Loan Paid & press Calc button Interest will
generated automatically
CALC MAIL
Rohini kumar
SAP-ABAP 189
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.
Activate
Back (F3)
Rohini kumar
SAP-ABAP 190
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
Yes
Enter
Rohini kumar
SAP-ABAP 191
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
Text: Farmer Details
Close
Rohini kumar
SAP-ABAP 192
F6
Table Name: ZFARMER
Enter
Except Mandt & Acno select all fields
Enter
Place the fields on the box
Place a Push button on the box
Double click on push button
Text: Save
FCT Code: SAVE
Close
Flow Logic
Remove comment for MODULE USER_COMMAND_110
Double click on USER_COMMAND_110
Yes
Enter
Enter
Yes
Place cursor between MODULE……….ENDMODULE of USER_COMMAND_110
CASE SY-UCOMM.
WHEN ‘SAVE’.
SELECT SINGLE MAX( acno ) FROM ZFARMER INTO zfarmer-acno.
IF zfarmer-acno EQ 0.
zfarmer-acno = ‘9000000’.
ELSE.
zfarmer-acno = zfarmer-acno + 1.
ENDIF.
INSERT ZFARMER.
IF SY-SUBRC EQ 0.
MESSAGE S000(ZMESS_CLS) WITH zfarmer-acno.
ENDIF.
ENDCASE.
Back (F3)
Activate
Back (F3)
Activate screen
Back
Step-6:
Right click on ZFARMGR
Create
Screen
Screen Number: 120
Enter
Short Description: Sub Screen 120
Screen Type: Sub Screen
Layout
Place a Box on top left corner of the screen
Double click on frame of box
Text: Farmer Loan
Close
F6
Table Name: ZLOAN
Enter
Select Acno, Fname, Lamount fields
Enter
Place fields on the box
Place a check box (starting from 4th option) on the box
Double click on check box
Name: APPROVE
Text: Approve
Close
Place a push button on the box
Double click on push button
Text: Save
FCT Code: SAVE
Close
Double click on Fname I/O field
*** at bottom select Program tab
Input: Not Possible
Close
Flow Logic
Place cursor under PROCESS AFTER INPUT
Rohini kumar
SAP-ABAP 194
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
Rohini kumar
SAP-ABAP 195
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.
FIELD: zpayment-acno MODULE CHECK1 ON INPUT,
zpayment-lamount.
Rohini kumar
SAP-ABAP 196
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.
INSERT ZPAYMENT.
ENDIF.
Rohini kumar
SAP-ABAP 197
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)
Rohini kumar
SAP-ABAP 198
01-10-2014
Mail Coding:
* for mail address
T_receiver_rec_type = ‘U’.
T_receiver_receiver = ‘satya@[Link]’.
* fill subject
T_doc_obj_name = ‘TEXT’.
T_doc_obj_descr = ‘Payment Details’.
T_doc_obj_langu = SY-LANGU.
*fill contents
V_paid = zpayment-lpaid.
V_due = zpayment-due.
V_interest = zpayment-iamount.
Activate
Rohini kumar
SAP-ABAP 199
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
Rohini kumar
SAP-ABAP 200
Go to SE11
Database Table: LFA1
Display
Contents
Lifnr: 9872
F8
Rohini kumar
SAP-ABAP 201
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
Rohini kumar
SAP-ABAP 202
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
Rohini kumar
SAP-ABAP 203
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
Delivery Class: A
Table View Maint: Display / Maint Allowed with Restrictions
Rohini kumar
SAP-ABAP 204
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
Size Category: 0
Currency Quantity Fields tab
Rohini kumar
SAP-ABAP 205
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’.
IF SSCRFIELDS-UCOMM EQ ‘BUT1’.
CALL SCREEN 100.
Rohini kumar
SAP-ABAP 206
ENDIF.
Step-3:
Double click on 100
Yes
Yes
Rohini kumar
SAP-ABAP 207
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.
MESSAGE ‘Record saved’ TYPE ‘S’.
ENDIF.
Rohini kumar
SAP-ABAP 208
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.
ENDIF.
ENDLOOP.
Rohini kumar
SAP-ABAP 209
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.
ENDCASE.
Activate
Rohini kumar
SAP-ABAP 210
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
Rohini kumar
SAP-ABAP 211
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’.
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
Yes
Short Text: BACK
Rohini kumar
SAP-ABAP 213
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.
Rohini kumar
SAP-ABAP 214
------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
Blue
Green Total
Rohini kumar
SAP-ABAP 215
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.
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.
IF wa3-red IS INITIAL.
v1 = v1 + 1.
Rohini kumar
SAP-ABAP 217
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
Back
Remove comment for MODULE STATUS_100
Rohini kumar
SAP-ABAP 218
Rohini kumar
SAP-ABAP 219
Assignments:
1. Log sheet Temperature Details
Input:
Furnance
Date
Screen 100
Log Sheet Temparature Details
Average
Rohini kumar
SAP-ABAP 220
ZLOGSHEET Table:
Furnance
Date
Shift
T1
T2
T3
T4
T5
T6
E1
E2
E3
E4
E5
E6
Solution:
Rohini kumar
SAP-ABAP 221
Input:
Cheque No
Cheque Date
Cheque No Cheq Date Issue Date Dep Date Reliza Date Cust No Che Status Cheq Amt
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.
Rohini kumar
SAP-ABAP 223
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.
IF SCREEN-NAME EQ ‘wa-cheqno’
OR SCREEN-NAME EQ ‘wa-cheqdate’
Rohini kumar
SAP-ABAP 224
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’.
LEAVE TO SCREEN 0.
ENDCASE.
Rohini kumar
SAP-ABAP 225
3. Simple calculator
Simple Calculator
1 2 3 C
4 5 6 /
7 8 9 *
0 = + -
Solution:
Rohini kumar
SAP-ABAP 226
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
Databa
se
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
Rohini kumar
SAP-ABAP 227
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
AT SELECTION-SCREEN ON VALUE-REQUEST:
It triggers when you apply F4 function key on selection-screen fields
Rohini kumar
SAP-ABAP 228
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:
Use this event for maintaining footers in ABAP reports
Rohini kumar
SAP-ABAP 229
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.
Rohini kumar
SAP-ABAP 230
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.
SELECT ebeln matnr menge netpr FROM EKPO INTO TABLE it_ekpo WHERE
matnr IN s_matnr AND werks IN s_werks.
Rohini kumar
SAP-ABAP 231
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
Rohini kumar
SAP-ABAP 232
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:
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.
FORM get_ekko.
SELECT ekko~ebeln ekko~bedat ekko~knumv ekko~lifnr
Rohini kumar
SAP-ABAP 235
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.
wa_final-ebelp = wa_ekko-ebelp.
wa_final-lifnr = wa_ekko-lifnr.
Rohini kumar
SAP-ABAP 236
FORM get_konv.
SORT it_final BY knumv ebelp.
FORM displaly_data.
LOOP AT it_final INTO wa_final.
WRITE:/10 wa_final-ebeln,
20 wa_final-bedat,
30 wa_final-lifnr,
Rohini kumar
SAP-ABAP 237
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.
Rohini kumar
SAP-ABAP 238
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
Rohini kumar
SAP-ABAP 239
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
Rohini kumar
SAP-ABAP 240
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>.
Rohini kumar
SAP-ABAP 241
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.
Rohini kumar
SAP-ABAP 242
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 code Bill quantity Bill amount
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
Invoice number:
Rohini kumar
SAP-ABAP 243
Solution:
Go to SE38
Program: ZSD_CUSTOMER_INVOICE_DETAILS
Create
Title: Customer Invoice Details Report
Type: Executable Program
Enter
Packge: ZABAP
Enter
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.
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.
Rohini kumar
SAP-ABAP 247
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
Rohini kumar
SAP-ABAP 248
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
Rohini kumar
SAP-ABAP 249
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
Rohini kumar
SAP-ABAP 250
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.
Rohini kumar
SAP-ABAP 251
PERFORM get_ekko.
PERFORM get_lfa1.
PERFORM get_eket.
PERFORM fill_cat.
PERFORM combine_data.
PERFORM layout.
PERFORM display_data.
Rohini kumar
SAP-ABAP 252
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’.
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.
Rohini kumar
SAP-ABAP 254
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.
Rohini kumar
SAP-ABAP 255
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:
A type group is a group of similar structures & table types
Rohini kumar
SAP-ABAP 256
It you want to use type group types in your program it is mandatory to declare respective
type group with TYPE-POOLS keyword
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
[Link] ------ 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
[Link] ------------------- by default the field catalogs in a layout are in display mode. Using
this option a field should be converted into change mode
[Link] ------------ 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
Rohini kumar
SAP-ABAP 257
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
Enter
Rohini kumar
SAP-ABAP 258
TYPE-POOLS SLIS.
Rohini kumar
SAP-ABAP 260
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
Rohini kumar
SAP-ABAP 261
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
Rohini kumar
SAP-ABAP 262
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:
Rohini kumar
SAP-ABAP 263
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:
Rohini kumar
SAP-ABAP 264
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
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
Rohini kumar
SAP-ABAP 265
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.
Rohini kumar
SAP-ABAP 266
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.
ENDFORM.
FORM get_t151t.
ENDFORM.
FORM get_t005u.
ENDFORM.
FORM get_adrc.
ENDFORM.
FORM combine_data.
LOOP AT it_kna1 INTO wa_kna1.
wa_final-kunnr = wa_kna1-kunnr.
Rohini kumar
SAP-ABAP 269
wa_final-name1 = wa_kna1-name1.
wa_final-regio = wa_kna1-regio.
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.
WA_FCAT-FIELDNAME = ‘REGIO’.
WA_FCAT-SELTEXT_M = ‘region’.
Rohini kumar
SAP-ABAP 270
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.
Rohini kumar
SAP-ABAP 271
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.
Rohini kumar
SAP-ABAP 272
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.
Rohini kumar
SAP-ABAP 273
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
Material description
Division
Rohini kumar
SAP-ABAP 274
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.
END OF ty_mara.
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.
Rohini kumar
SAP-ABAP 277
ENDFORM.
FORM get_mseg.
ENDFORM.
FORM get_tspat.
ENDFORM.
FORM combine_data.
ENDFORM.
FORM combine_data1.
Rohini kumar
SAP-ABAP 278
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’.
wa_final-return = wa_mara-return + wa_mseg-menge.
ENDIF.
Rohini kumar
SAP-ABAP 279
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.
WA_FCAT-FIELDNAME = ‘PROD’.
WA_FCAT-TABNAME = ‘it_final’.
Rohini kumar
SAP-ABAP 280
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’.
WA_FCAT-SELTEXT_M = ‘Sale’.
APPEND WA_FCAT TO IT_FCAT1.
Rohini kumar
SAP-ABAP 281
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’.
APPEND WA_FCAT TO IT_FCAT2.
Rohini kumar
SAP-ABAP 282
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.
Rohini kumar
SAP-ABAP 283
ENDIF.
ENDFORM.
Rohini kumar
SAP-ABAP 284
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.
Rohini kumar
SAP-ABAP 285
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
2. Get kunnr name from kna1 by processing kunrg of vbrk
3. Get matnr maktx from makt by passing matnr of vbrk
Rohini kumar
SAP-ABAP 286
Solution:
ZSD_SALES_REGISTER_SJU
Rohini kumar
SAP-ABAP 287
SD Flow:
Inquiry
Sales order
Delivery
Invoice
Rohini kumar
SAP-ABAP 288
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
[Link] --------- special excise duty
[Link] -------- additional excise duty
[Link] ----------- cess amount
[Link] --------- 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
Rohini kumar
SAP-ABAP 289
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:
Rohini kumar
SAP-ABAP 290
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
Rohini kumar
SAP-ABAP 291
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
Rohini kumar
SAP-ABAP 292
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
Rohini kumar
SAP-ABAP 293
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.
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.
Rohini kumar
SAP-ABAP 296
FORM get_ekko.
ENDFORM.
FORM get_lfa1.
ENDFORM.
FORM combine_data.
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 = ‘[Link]’.
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’.
WA_FCAT-TABNAME = ‘it_final’.
Rohini kumar
SAP-ABAP 298
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.
Rohini kumar
SAP-ABAP 299
FORM layout.
WA_LAYOUT-ZEBRA = ‘X’.
WA_LAYOUT-COLWIDTH_OPTIMIZE = ‘X’.
ENDFORM.
FORM display-hierseq.
it_final1[ ] = it_final[ ].
ENDFORM.
Rohini kumar
SAP-ABAP 300
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
[Link] internal table
[Link] internal table
Rohini kumar
SAP-ABAP 301
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
2. FB02
Rohini kumar
SAP-ABAP 302
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
2. SKB1
Rohini kumar
SAP-ABAP 303
3. BSIS
4. BSAS
Key field: HKONT, SAKNR
Rohini kumar
SAP-ABAP 304
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
Rohini kumar
SAP-ABAP 305
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
[Link] -------- 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
6. LAND1 --------- country
Rohini kumar
SAP-ABAP 306
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
Rohini kumar
SAP-ABAP 307
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)
Rohini kumar
SAP-ABAP 309
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
Rohini kumar
SAP-ABAP 310
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)
Enter
Rohini kumar
SAP-ABAP 311
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
START-OF-SELECTION.
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.
wa_final-ename = p0002-nachn.
wa_final-doj = hdate.
Rohini kumar
SAP-ABAP 313
wa_final-gbdat = p0002-gbdat.
wa_final-dept = dept.
wa_final-age = age.
ENDFORM.
FORM display_data.
ENDFORM.
24-10-2014
Rohini kumar
SAP-ABAP 314
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:
Rohini kumar
SAP-ABAP 315
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
Rohini kumar
SAP-ABAP 316
Note:
1. You can create SAP Query directly in Production Server in real time
2. Selection screen number is 1000
Rohini kumar
SAP-ABAP 317
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
Rohini kumar
SAP-ABAP 318
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
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
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)
Rohini kumar
SAP-ABAP 320
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
Double click on Object Name ---------- it will show the table details specified in data dictionary
(number of records, type of table…………….etc)
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
Rohini kumar
SAP-ABAP 322
It always Green
APPLICATION SERVER
Always Green DATABASE SERVER
It may Red (or)
Green ABAP PROGRAM
0 1 2 3 4 5
Back
Tips & Tricks
Expand SQL Interface option
Double click on Select With Select List
Select Measure Run Time option
Rohini kumar
SAP-ABAP 323
Rohini kumar
SAP-ABAP 324
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
Rohini kumar
SAP-ABAP 325
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)
Rohini kumar
SAP-ABAP 326
Example:
DATA t1 TYPE I.
DO 10 TIMES.
GET RUN TIME FIELD t1.
WRITE:/ t1.
ENDDO.
Activate
Execute
Example:
Rohini kumar
SAP-ABAP 327
Performance Tuning:
Rohini kumar
SAP-ABAP 328
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
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
Rohini kumar
SAP-ABAP 330
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:
Rohini kumar
SAP-ABAP 331
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:
Rohini kumar
SAP-ABAP 332
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
Rohini kumar
SAP-ABAP 333
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.
Encapsulation is achieved from abstraction
Rohini kumar
SAP-ABAP 334
Class:
Class is a template based on which objects are created
All the features (Methods) of an object is encapsulated within a class
As class is a template memory is not allocated by system to a class
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
Rohini kumar
SAP-ABAP 335
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.
------------
------------
ENDMETHOD.
Rohini kumar
SAP-ABAP 336
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.
Rohini kumar
SAP-ABAP 337
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,
combine_data,
combine_data1,
Rohini kumar
SAP-ABAP 338
fill_cat,
layout,
display_data.
PRIVATE SECTION.
Rohini kumar
SAP-ABAP 339
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.
METHOD combine_data1.
Rohini kumar
SAP-ABAP 340
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’.
Rohini kumar
SAP-ABAP 341
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’.
Wa_fcat-seltext_m = ‘Over Due’.
APPEND wa_fcat TO it_fcat.
Rohini kumar
SAP-ABAP 342
ENDMETHOD.
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.
Rohini kumar
SAP-ABAP 343
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
[Link] --------- document type
[Link] --------- debit (s) / credit (h) indicator
12.**DMBTR ----- amount in local currency
[Link] -------- G/L amount
14.**ZFBDT ------ base line date for due date calculation
[Link] -------- payment terms
Rohini kumar
SAP-ABAP 344
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.
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.
ENDLOOP.
Rohini kumar
SAP-ABAP 348
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’.
APPEND wa_fcat TO it_fcat.
Rohini kumar
SAP-ABAP 349
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
I_CALLBACK_PROGRAM = ‘X’
IS_LAYOUT = wa_layout
Rohini kumar
SAP-ABAP 350
IT_FIELDCAT = it_fcat
I_SAVE = ‘X’
TABLES
T_OUTTAB = it_final.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA obj TYPE REF TO cl_derived.
Rohini kumar
SAP-ABAP 351
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
[Link] --------- reference document number
[Link] --------- document type
[Link] --------- debit (s) / credit (h) indicator
13.**DMBTR ----- amount in local currency
[Link] -------- G/L amount
15.**ZFBDT ------ base line date for due date calculation
[Link] -------- payment terms
Rohini kumar
SAP-ABAP 352
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
Pernr
Rohini kumar
SAP-ABAP 353
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.
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.
CALL FUNCTION ‘HR_FORMS_TIM_GET_B2_RESULTS’
Rohini kumar
SAP-ABAP 355
EXPORTING
Pernr = pernr
Begda = s_date-low
Endda = s_date-high
IMPORTING
Tim_b2 = gwa_tim.
Wrk = wrk + 1.
IF wa_psp-trprog = ‘OFF’.
Rest = rest + 1.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD display_data.
CALL FUNCTION ‘REUSE_ALV_LIST_DISPLAY’
Rohini kumar
SAP-ABAP 356
EXPORTING
I_STRUCTURE_NAME = ‘YHR_ATTEN’
TABLES
T_OUTTAB = it_atten.
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.
CALL FUNCTION ‘REUSE_ALV_LIST_DISPALY’
Rohini kumar
SAP-ABAP 357
EXPORTING
I_STRUCTURE_NAME = ‘YHR_SAL’
TABLES
T_OUTTAB = it_sal.
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.
Rohini kumar
SAP-ABAP 359
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:
Rohini kumar
SAP-ABAP 360
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:
Rohini kumar
SAP-ABAP 361
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
Activate
Rohini kumar
SAP-ABAP 362
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
Rohini kumar
SAP-ABAP 363
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.
WA_FCAT-FIELDNAME = ‘ANLN2’.
WA_FCAT-SELTEXT_M = ‘Sub Asset Number’.
Rohini kumar
SAP-ABAP 364
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.
Pattern
ABAP object patterns
Enter
Create Object
Instance: obj
Class: ZCL_ASSET_CLASS
Enter
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
Rohini kumar
SAP-ABAP 366
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
Rohini kumar
SAP-ABAP 367
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:
Rohini kumar
SAP-ABAP 368
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:
Rohini kumar
SAP-ABAP 369
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
** Table Type
Enter
Rohini kumar
SAP-ABAP 370
Activate
Back
Data Type: ZSD_VBRKTAB
Create
** Table Type
Enter
Short Description: Table Type for VBRK
** Line Type: ZSD_VBRK
Activate
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
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
Rohini kumar
SAP-ABAP 375
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
Rohini kumar
SAP-ABAP 376
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:
In order to produce finished goods sales department have to give (or) raise production order to
production department
Rohini kumar
SAP-ABAP 377
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
Rohini kumar
SAP-ABAP 378
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
Rohini kumar
SAP-ABAP 379
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
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
Method level visibility description
NO_DATA INSTANCE PUBLIC method for event
Rohini kumar
SAP-ABAP 381
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
Activate
Back
Rohini kumar
SAP-ABAP 382
Activate
Back
ENDLOOP.
Activate
Back
WA_LAYOUT-ZEBRA = ‘X’.
WA_LAYOUT-COWIDTH_OPTIMIZE = ‘X’.
Activate
Back
Activate
Back
Activate
TABLES AFRU.
Rohini kumar
SAP-ABAP 385
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.
Rohini kumar
SAP-ABAP 386
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
Rohini kumar
SAP-ABAP 387
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.
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
Layout
Place Custom Control on the screen
Rohini kumar
SAP-ABAP 389
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
Rohini kumar
SAP-ABAP 391
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.
Rohini kumar
SAP-ABAP 392
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.
PERFORM sort.
PERFORM layout.
Rohini kumar
SAP-ABAP 394
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.
ENDFORM.
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.
wa_fcat-fieldname = ‘IDNRK’.
Rohini kumar
SAP-ABAP 396
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.
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.
CASE SY-UCOMM.
WHEN ‘&F03’.
LEAVE TO SCREEN 0.
ENDCASE.
Rohini kumar
SAP-ABAP 399
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
Rohini kumar
SAP-ABAP 400
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
Rohini kumar
SAP-ABAP 401
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
Activate
Back
Rohini kumar
SAP-ABAP 402
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.
Rohini kumar
SAP-ABAP 403
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.
Rohini kumar
SAP-ABAP 404
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.
Rohini kumar
SAP-ABAP 405
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.
ENDFORM.
Rohini kumar
SAP-ABAP 406
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.
ENDMODULE.
Rohini kumar
SAP-ABAP 407
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)
Rohini kumar
SAP-ABAP 408
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
Rohini kumar
SAP-ABAP 409
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
Rohini kumar
SAP-ABAP 410
Rohini kumar
SAP-ABAP 411
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
Rohini kumar
SAP-ABAP 412
Rohini kumar
SAP-ABAP 413
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
Rohini kumar
SAP-ABAP 414
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
Rohini kumar
SAP-ABAP 415
Syntax:
GET CURSOR FIELD <field name> VALUE <value>.
Rohini kumar
SAP-ABAP 416
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
Append field catalogs & data with layout
Rohini kumar
SAP-ABAP 417
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
Rohini kumar
SAP-ABAP 418
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
Rohini kumar
SAP-ABAP 419
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.
16.I_CALLBACK_USER_COMMAND
It is for interactive purpose
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
Rohini kumar
SAP-ABAP 421
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:
Rohini kumar
SAP-ABAP 422
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:
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
[Link] by zero exception
[Link] convert number exception
[Link] conflict exception
[Link] 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?
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
Rohini kumar
SAP-ABAP 425
Rohini kumar
SAP-ABAP 426
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.
Rohini kumar
SAP-ABAP 427
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.
Rohini kumar
SAP-ABAP 428
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
The user can, for example, call a transaction from within a list of change the database
table whose data is displayed in the list
Rohini kumar
SAP-ABAP 429
Rohini kumar
SAP-ABAP 430
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.
Rohini kumar
SAP-ABAP 431
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.
Rohini kumar
SAP-ABAP 432
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.
Rohini kumar
SAP-ABAP 433
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.
Rohini kumar
SAP-ABAP 434
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.
Rohini kumar
SAP-ABAP 435
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.
Rohini kumar
SAP-ABAP 436
Rohini kumar
SAP-ABAP 437
2. AT USER-COMMAND
Moment at which the user presses a function key
Rohini kumar
SAP-ABAP 438
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.
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.
Rohini kumar
SAP-ABAP 440
Ans:
Rohini kumar
SAP-ABAP 441
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.
Rohini kumar
SAP-ABAP 442
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
Rohini kumar
SAP-ABAP 443
OOABAP:
1Q: Principles of oops?
Ans:
5. Inheritance
6. Polymorphism
7. Abstraction
8. Encapsulation
8Q: Can we put non declarative statement e.g. START-OF-SELECTION within a class
Ans:
Rohini kumar
SAP-ABAP 444
25Q: Can we implement abstract method in abstract class? If not then where it can be
implemented?
Ans:
33Q: What is alias? Instead of specifying full name of interface methods we can assign it a
name which can directly trigger.
Ans:
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:
Rohini kumar
SAP-ABAP 448
SAP-ADV ABAP
Rohini kumar
SAP-ABAP 450
INDEX
1 BDC 5
2 Data Transfer Techniques (Inbound & Outbound) 5
3 Steps in BDC Data Transfer Technique 6
4 Methods in BDC (Session, Call Transaction, LSMW & Direct Input methods) 7
5 1. Session Method 8
6 Upload bank data from Notepad using session method 10
7 Uploading data from XL Sheet using Session Method 15
8 2. Call Transaction Method 21
9 Upload pricing data using Call Transaction Method 23
10 3. LSMW 29
11 SKIP Functionality 35
12 . Upload material master data with MM01 using flat file with headings & logo 35
13 BDC with Table Control 36
14 Upload vendor master data using XK01 using Table Control 37
15 File Handling 38
16 Opening a File in Application Server in Output Mode (Write Mode) 38
17 Opening a File in Input Mode (Read Mode) 40
18 Upload asset master data with AS02 using Call Transaction Method 43
(Assignment)
19 Upload employee payroll for infotype 14 with PA30 using Call Transaction 44
Method (Assignment)
20 SAP Scripts 45
21 Flow of Creating Form (Steps) 47
22 Goods receipt form using Scripts 48
23 Function Modules for Print Program 56
24 PO Form using Scripts(Assignment) 57
25 Standard Forms 58
26 Smart Forms 61
27 Steps in Working of Smart Forms 63
28 PO Form using Smart Forms 64
29 SAP Enhancements (Userexits, Customerexits, BADI, Enhancement Frame 81
Work & BTE)
30 1. Userexits 81
31 Validate sales order application using Userexits 81
32 2. Customerexits (Function Exits, Menu Exits, Screen Exits & Field Exits) 83
33 a) Function Exits 83
34 Validate vendor master application for postal code 83
35 b) Menu Exits 86
36 c) Screen Exits 88
Rohini kumar
SAP-ABAP 451
37 d) Fieldexits 92
38 3. BADI(Standard, Custom &Filter BADIs) 93
39 i) Standard BADI 94
40 Watch Point 96
41 Navigation for Finding BADI (3 Methods) 97
42 Validate BOM application (CS01) for alternate Bom using Standard BADI 98
43 Add a menu in FBL5N application using Standard BADI 100
44 . Add a screen in XD01, XD02 with field Sales Manager using Standard BADI 102
45 ii) Custom BADI 107
46 iii) Filter BADI 107
47 Determine tax code for sales organization using Filter BADI 107
48 4. Enhancement Framework 111
49 Provide Profit center as obligatory in F-28 application 113
50 In MB31 provide Document date & Posting date as previous date 114
51 Add fields in FB03 application ( Dmbtr, Hlcont ) 115
52 Add screen in VF01, VF02, VF03 with ZZBOXNO, ZZSIZE, ZZTEXT 117
53 5. BTE 120
54 Add indicator field in FBL5N application 120
55 Cross Applications (ALE & IDOC) 125
56 Records (Control, Data & Status) 126
57 ALE Architecture 128
58 Message Type 130
59 Types of IDOCs (Standard IDOC, Custom IDOC &Extended IDOC) 131
60 a) Standard IDOC 131
61 Distributing material master data 131
62 Sending Changes to Inbound System 137
63 IDOC Filtering(Segment Filtering, IDOC Filtering &Reduced IDOC Filtering) 139
64 1. Segment Filtering 139
65 2. IDOC Filtering 140
66 3. Reduced IDOC Type 146
67 Distributing Transactional Data 148
68 b) Custom IDOC 154
69 c) Extended IDOC 160
70 Trouble Shooting & Recovery 167
71 Debugging IDOCs 168
72 EDI 169
73 Steps in EDI Process Flow 171
74 BAPI 174
75 BOR 176
76 Types of BAPIs (Standard BAPI, Custom BAPI & Extended BAPI) 177
Rohini kumar
SAP-ABAP 452
Rohini kumar
SAP-ABAP 453
BDC:
Batch Data Communication
BDC is a data transfer technique from one system to another system
In all above examples manually clients have to process application data & there is no
guaranty that data is 100% consistent
SAP is providing a technique called BDC for data transfer
Outbound:
SAP
SAP
(source system) Non-SAP
Inbound:
SAP
SAP (target system)
Non-SAP
Note:
BDC is an Inbound data transfer technique
Rohini kumar
SAP-ABAP 454
Step-2:
Functional Consultant will analyses Flat File & there only he will converts Non-SAP data
into SAP format
Functional Consultant will prepare Functional Document & provide it to Technical
Consultant
Step-3:
Technical Consultant will write an interface program (BDC program) in SAP system & he will
upload the data from Flat File to Internal table (created based on Flat File)
Step-4:
In real time some data might be in SAP format (or) Non-SAP format
All Non-SAP format data is converted into SAP format using validations in application
Step-5:
Before validation we have to perform mapping logic
**For that we have to create mapping logic internal table based on BDC Data Structure
Step-6:
From mapping logic internal table (it_bdcdata) data will goes to respective application
where LUW is performed
With LUW data is finally transferred to database tables
Note:
BDC is a part of conversion technique
Flat File:
In real time Flat File (mainly XL Sheet) is provided by end user
Rohini kumar
SAP-ABAP 455
Mapping Logic:
BDC Data (structure)
Methods in BDC:
1. ** Session method
2. ** Call Transaction method
3. LSMW (this job is done by Functional Consultant)
4. Direct Input method (it is out dated)
Rohini kumar
SAP-ABAP 456
Session Method:
Features:
1. Use session method for uploading large amount of data (more than 10000 records)
2. Data can be processed in Foreground as well as Background
3. *** In BDC in session method error records are captured using Log File
4. In session method respective Log File is already given by SAP
5. *** Multiple applications can be processed at one time
6. Asynchronous processing
7. Synchronous updating
8. It is a slower method but consistent
BDC_OPEN_GROUP:
It will open a session in SM35
BDC_INSERT:
It transfers mapped data from mapping logic internal table to session
BDC_CLOSE_GROUP:
It closes a session which is already opened.
Flow of Data in Session Method:
Flat File
(using function module)
It_data
(using LOOP………ENDLOOP)
Wa_data
(using APPEND keyword)
It_bdcdata
(using BDC_INSERT function module)
Session
Screens
LUW
Database Tables
Rohini kumar
SAP-ABAP 457
Processing:
Transferring the data from Flat File (Presentation Server) ultimately to Session
(Application Server) is called processing
In session method processing is asynchronous (all records from Flat File are ultimately
broad to session)
Updating:
Transferring the data from Application Server to Database Server is called updating
In session method updating is synchronous
In session method if a record is correctly committed to database then only next record is
updated (next transaction can be processed only when the previous record is correctly
written to the database)
** Recording:
Using recording you can map Program name, Screen number, Field names………….etc
You can map Screen Sequences
You can map FCT values for different function codes (BACK, SAVE,
ENTER………etc)
Note:
T Code for recording is SHDB
Rohini kumar
SAP-ABAP 458
Requirement:
Upload bank data from Notepad using session method
Solution:
Step-1:
Go to SHDB
New Recording
Recording: ZBANK_RECO
Transaction Code: FI01
Start Recording
Bank Country: IN
Bank Key: SR Nagar
Enter
Bank Name: state bank on Hyderabad
Street: SR nagar
City: Hyderabad
Bank Branch: SR nagar branch
Save
Save
Back
Note:
In real time, Functional Consultants perform recording. As a Technical Consultant based on
recording we have to create a program
Step-2:
Go to SHDB
Select your recording name (ZBANK_RECO)
Program
Program Name: ZFI_BANK_UPLOAD
Transaction For Recording
Enter
Title: BDC for FI01
Type: Executable Program
Source Code
Local Object
You will find a program
Remove starting 3 lines
i.e. INCLUDE BDCRECXL
START-OF-SELECTION
……………………….
Rohini kumar
SAP-ABAP 459
Step-3:
Write your program from begging of given program
* mapping objects
DATA: wa_bdcdata TYPE BDCDATA,
it_bdcdata TYPE BDCDATA.
* F4 functionality
AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file.
PERFORM open_file.
START-OF-SELECTION.
PERFORM upload.
PERFORM open_session.
PERFORM process_data.
PERFORM close_session.
Rohini kumar
SAP-ABAP 460
FORM open_file.
ENDFORM.
FORM upload.
fnam = p_file.
ENDFORM.
FORM open_session.
** FORM process_data.
LOOP AT it_fi01 INTO wa_fi01.
REFRESH it_bdcdata.
wa_fi01-banka.
wa_fi01-stras.
wa_fi01-ort01.
wa_fi01-brnch.
ENDLOOP.
ENDFORM.
FORM close_session.
CALL FUNCTION ‘BDC_CLOSE_GROUP’.
ENDFORM.
* screen mapping
FORM BDC_DYNPRO USING PROG SCREEN.
CLEAR wa_bdcdata.
wa_bdcdata-program = prog.
wa_bdcdata-dynpro = screen.
wa_bdcdata-dynbegin = ‘X’.
ENDFORM.
* field mapping
FORM BDC_FIELD USING FIELD VALUE.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = field.
wa_bdcdata-fval = value.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
Rohini kumar
SAP-ABAP 462
Step-4:
Create a Flat File with Note pad
IN SBI009 STATEBANKOFINDIA LBNAGAR HYDERABAD
IN SBH008 STATEBANKOFHYD AMEERPET HYDERABAD
Step-5:
Go to SE38
Execute
Apply F4
Select your Flat File
Open
Execute
Go to SM35
Select your Session name
Process
Background
Process
07-11-2014
Question-1:
Assume my Session has been processed & after processing, I want my Session to be displayed
in SM35 for status check. How you can achieve this task?
Answer:
By providing exporting parameter KEEP = ‘X’ you can get your processed session back in
SM35
Question-2:
How you can maintain Logs (or) Error records in Session method?
Answer:
In Session method SAP is providing a Log file by default
No need to create a Log file for handling error records
You can find Log file by using SM35
Go to SM35
Select your session
Select Log option (F7)
Select your session
Select Display button
Rohini kumar
SAP-ABAP 463
Requirement:
Upload bank data from XL Sheet using session method
Solution:
Step-1:
Go to SHDB
New Recording
Recording: ZBANK_RECO
Transaction Code: FI01
Start Recording
Bank Country: IN
Bank Key: SR Nagar
Enter
Bank Name: state bank on Hyderabad
Street: SR nagar
City: Hyderabad
Bank Branch: SR nagar branch
Save
Save
Back
Note:
In real time, Functional Consultants perform recording. As a Technical Consultant based on
recording we have to create a program
Step-2:
Go to SHDB
Select your recording name (ZBANK_RECO)
Program
Program Name: ZFI_BANK_UPLOAD
Transaction For Recording
Enter
Title: BDC for FI01
Type: Executable Program
Source Code
Local Object
You will find a program
Remove starting 3 lines
Rohini kumar
SAP-ABAP 464
Step-3:
Write your program from begging of given program
** TYPE-POOLS TRUXS.
* mapping objects
DATA: wa_bdcdata TYPE BDCDATA,
it_bdcdata TYPE BDCDATA.
* F4 functionality
AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file.
PERFORM open_file.
START-OF-SELECTION.
PERFORM upload.
Rohini kumar
SAP-ABAP 465
PERFORM open_session.
PERFORM process_data.
PERFORM close_session.
FORM open_file.
ENDFORM.
FORM upload.
ENDFORM.
FORM open_session.
ENDFORM.
** FORM process_data.
LOOP AT it_fi01 INTO wa_fi01.
REFRESH it_bdcdata.
Rohini kumar
SAP-ABAP 466
ENDLOOP.
ENDFORM.
FORM close_session.
CALL FUNCTION ‘BDC_CLOSE_GROUP’.
ENDFORM.
* screen mapping
FORM BDC_DYNPRO USING PROG SCREEN.
CLEAR wa_bdcdata.
wa_bdcdata-program = prog.
wa_bdcdata-dynpro = screen.
wa_bdcdata-dynbegin = ‘X’.
ENDFORM.
* field mapping
FORM BDC_FIELD USING FIELD VALUE.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = field.
Rohini kumar
SAP-ABAP 467
wa_bdcdata-fval = value.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
Step-4:
Create a Flat File MS-XL
IN SBI009 STATEBANKOFINDIA LBNAGAR HYDERABAD
IN SBH008 STATEBANKOFHYD AMEERPET HYDERABAD
Step-5:
Go to SE38
Execute
Apply F4
Select your Flat File
Open
Execute
Go to SM35
Select your Session name
Process
Background
Process
Question-1:
How you can perform background processing in Session method?
Answer:
Using program RSBDCSUB you can execute session in background
Example:
In above program modify subroutine PERFORM close_session.
FORM close_session.
ENDFORM.
Execute
F4
Select your Flat File
Rohini kumar
SAP-ABAP 468
Execute
You will find a selection screen
Session: RGS
Execute
Question-2:
Suppose I’m having a Flat File with 50000 records. It happened that the system crashed while
uploading data. How I know the number of records exactly uploaded?
Answer:
I will go to respective database table & copy the key values to the table & execute it
Question-3:
Assume there are 1000 records out of which I uploaded 500 records & remaining I want to
upload next day. How you will, you perform this job.
Answer:
I will check the status of the records uploaded & I will delete the records from Flat File which
are correctly uploaded & remaining I will execute once again on next day
Question-4:
I’m having 2 Flat Files with 500 records & 50000 records. Which method will you prefer for
both Flat Files?
Answer:
For 500 records Call Transaction Method
For 50000 records Session Method
Rohini kumar
SAP-ABAP 469
Note:
In Call Transaction Method session function modules are not required
Rohini kumar
SAP-ABAP 470
Update Parameter:
Using this parameter, you can switch the control from asynchronous to synchronous
Message Parameter:
It is for error handling in Call Transaction Method
LUW
Database Tables
Rohini kumar
SAP-ABAP 471
Requirement:
Upload pricing data using Call Transaction Method
Every company will increases the prices of their finished products using VK11 application
Solution:
Step-1:
Go to SHDB
New Recording
Recording: ZVK11_RECO
Transaction Code: VK11
Start Recording
Condition Type: ZZ01
Enter
Sales Organization: 1000
Distribution Channel: 10
Material: 100-100
Amount: 500
Unit: INR
Valid From: 01.07.2014
Valid To: 31.12.2014
Save
Save
Back
Step-2:
Go to SHDB
Select your recording name (ZVK11_RECO)
Program
Program Name: ZMM_VK11_UPLOAD
Transaction For Recording
Enter
Title: BDC for VK11
Type: Executable Program
Source Code
Local Object
You will find a program
Remove starting 3 lines
i.e. INCLUDE BDCRECXL
START-OF-SELECTION
……………………….
Rohini kumar
SAP-ABAP 472
Step-3:
Write your program from begging of given program
** TYPE-POOLS TRUXS.
* mapping objects
DATA: wa_bdcdata TYPE BDCDATA,
it_bdcdata TYPE BDCDATA.
* F4 functionality
AT SELECTION-SCREEN ON VALUE_REQUEST FOR p_file.
PERFORM open_file.
START-OF-SELECTION.
PERFORM upload.
PERFORM process_data.
PERFORM fill_cat.
PERFORM display_data.
Rohini kumar
SAP-ABAP 473
FORM open_file.
ENDFORM.
FORM upload.
ENDFORM.
** FORM process_data.
LOOP AT it_fi01 INTO wa_fi01.
REFRESH it_bdcdata.
Rohini kumar
SAP-ABAP 474
ENDLOOP.
ENDFORM.
* screen mapping
FORM BDC_DYNPRO USING PROG SCREEN.
CLEAR wa_bdcdata.
wa_bdcdata-program = prog.
wa_bdcdata-dynpro = screen.
wa_bdcdata-dynbegin = ‘X’.
ENDFORM.
* field mapping
FORM BDC_FIELD USING FIELD VALUE.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = field.
wa_bdcdata-fval = value.
APPEND wa_bdcdata TO it_bdcdata.
ENDFORM.
Step-4:
Create a Flat File MS-XL
IN SBI009 STATEBANKOFINDIA LBNAGAR HYDERABAD
IN SBH008 STATEBANKOFHYD AMEERPET HYDERABAD
Step-5:
Go to SE38
Execute
Apply F4
Select your Flat File
Open
Execute
Go to SM35
Select your Session name
Rohini kumar
SAP-ABAP 475
Process
Background
Process
Rohini kumar
SAP-ABAP 476
08-11-2014
Question:
What is the difference between Session Method & Call Transaction Method?
Answer:
Session Method Call Transaciton Method
1. It for uploading large amount of data 1. It for uploading small amount of data
2. Multiple applications can be processed 2. Only single application can be processed
at one time with one BDC program at one time with one BDC program
3. In this method respective Log File is 3. In this method we have to create Log file
already given by SAP explicitly using structure BDCMSGCOLL
4. Asynchronous processing 4. Synchronous processing
5. Synchronous updating 5. Asynchronous updating
6. It is a slower method but consistent 6. Faster than Session method
Question:
How will you handle error records BDC?
Answer:
In real time client will ask error records during BDC upload
For that we have to provide him Logs in the form of error file
In Session Method Log file you can find directly in SM35
In Call Transaction Method as processing synchronous we have to create a Log file
internal table based on structure BDCMSGCOLL which holds log details during
processing of application
The error records are looped to respective work area which further exported to Funtion
Module FORMAT_MESSAGE
It returns a Message ID which I will capture by using a dummy internal table
Rohini kumar
SAP-ABAP 477
LSMW:
Legacy System Migration Work bench
It is convenient tool for migrating Non-SAP (or) Legacy data from one system to another
system
Method in LSMW:
1. Batch Input Recording (Session Method)
2. IDOC Method
3. BAPI Method
4. Direct Input Method
Note:
The T code for working with LSMW is LSMW
In real time LSMW is mostly performed by Functional Consultant
Example:
Go to LSMW
Project: ZFI_LSMW
Sub Project: ZFI_SUBPRO
Project: ZFI_SESSION
Create Entry
Description: LWMW Project
Enter
Description: Sub Project
Enter
Name: Session name
F8
If Numbering Off is selected get it into Numbering On
If Double Click = Display get it into Double Click = Change
Rohini kumar
SAP-ABAP 478
****
Step-1: Maintain object attributes
With this step you can maintain attributes for your method
i.e. Method name, Recording details……………etc
Select F8
Option
Recording Overview
Create Recording (Ctrl + F1)
Recording: FILSMW
Description: Recording
Enter
Transaction Code: FI01
Enter
Bank Country: IN
Bank Key: B0001
Enter
Bank Name: SBH
Street: LBNagar
City: Hyderabad
Bank Branch: LBNagarBranch
Save
Double click on BNKA-BANKS
Name: BANKS
Name: Bank Country
Default Value: ____________
Enter
Double click on BNKA-BANKL
Name: BANKL
Name: Bank Key
Default Value: ____________
Enter
Repeat the same procedure with BNKA-STRAS, BNKA-ORT01, BNKA-BRNCH
Save
Back
Back
Batch Input Recording
Recording: FILSMW
Enter
Save
Back
Rohini kumar
SAP-ABAP 479
Save
Back
Save
Back
Note:
This step is not required ignore it
Select Step-7
F8
Double click Legacy Data On The PC (Frontend)
Apply F4 on File
Select your flat file from required path
Name: Flat file
Delimitor
Tablator
Note:
If headings are maintained in Flat file it is mandatory to select check Fields Names At Start Of
File
Enter
Save
Note:
Sometimes you may find an error ‘Field names at start of File………….up to 45
charectors…..remaing data saved’. If you get this error
Doublce click on Convert Data
File: your flat file path
Save
Back
Rohini kumar
SAP-ABAP 481
Process
Enter
Enter
Enter
Rohini kumar
SAP-ABAP 483
09-11-2014
SKIP Functionality:
Requirement:
Upload material master data with MM01 using flat file with headings & logo
Flat File:
A-922 M ROH Sodaash Kg R1111 1000 Kg 800
A-923 M ROH Sodaash Kg R1111 1000 Kg 800
Solution:
ZMM_MM01_BDC1
Rohini kumar
SAP-ABAP 484
Flat File:
9444 1000 1000 0001 MR Satya Google
LBNagar Hyderabad IN, IN, IN, IN, IN, IN SBI001,SBH001, ICICI001,
HDFC001, CANARA001, AXIS001 30941209294, 30941209295, 30941209296,
30941209297, 30941209298, 30941209299 31000 A1 INR
Solution:
Go to SHDB
New Recording
Transaction Code: XK01
Start Recording
Vendor: 8733
Company Code: 1000
Purchase Org: 1000
Account Group: 0001
Title: MR
Name: Satya
Search Term: Google
Postal Code: 500074
City: Hyderabad
Country: IN
Enter
No data in this screen
Enter
Country: IN
Bank Key: SBH001
Bank Account: 30941209294
Enter
Enter
Recoun. Amount: 31000
Cash Mng Group: A1
Enter
No data in this screen
Enter
No data in this screen
Enter
Order Currency: INR
Enter
Rohini kumar
SAP-ABAP 485
Save
Save
Back
Select your recording
Program
Program Name: ZVENDOR_UPLOAD
Transfer For Recording
Enter
Title: BDC for recording
Type: Executable Program
Source Code
Remove starting 3 lines
Remove last 3 lines
Write your program
ZXK01_UPLOAD
Rohini kumar
SAP-ABAP 486
File Handling:
If flat file is maintaining in presentation server then any-body can manipulated it
Even flat files can be maintained in application server also where data is more secure as it
is managed by administrator
If the flat file is maintained in presentation server then it is a part of Physical File
Handling
If the flat file is maintained in application server then it is a part of Logical File Handling
Example:
Go to SE38
Program: ZSD_OPEN_DATASET
Create
Title: Opening dataset
Type: Executable Program
Enter
Local Object
INCLUDE ZCUSTOM.
Rohini kumar
SAP-ABAP 487
Local Object
Activate
Back
Activate
Execute
P_file: D:\[Link]
Execute
Rohini kumar
SAP-ABAP 488
Example:
Go to SE38
Program: ZSD_CUSTOMER
Create
Title: BDC for customer master data
Type: Module Pool
Save
Local Object
Go to SE51
Program: ZSD_CUSTOMER
Screen: 100
Create
F6
Table: KNA1
Enter
Select required fields (kunnr, land1, name1, ort01, pstlz, stras)
Enter
Place the fields on the screen
Place two buttons (INSERT, EXIT) on the screen
Provide Text & FCT code of buttons
Flow Logic
Remove comment for MODULE USER_COMMAND_100
Double click on USER_COMMAND_100
Yes
Main Program
Enter
TABLES KNA1.
CASE SY-UCOMM.
WHEN ‘INSERT’.
INSERT KNA1.
Rohini kumar
SAP-ABAP 489
IF SY-SUBRC EQ 0.
MESSAGE ‘Record inserted’ TYPE ‘I’.
ELSE.
MESSAGE ‘Inserting failed’ TYPE ‘E’.
ENDIF.
WHEN ‘EXIT’.
LEAVE TO SCREEN 0.
ENDCASE.
Activate
Back
Activate
Go to SE93
Transaction Code: ZCUST
Screen: 100
Save
Go to SE38
Program: ZSD_CUSTOMER_BDC
Create
Title: BDC for customer data
Type: Executable Program
Enter
Enter
INCLUDE ZCUSTOM.
ENDIF.
ENDDO.
Execute
P_file: D:\[Link]
Rohini kumar
SAP-ABAP 491
Assignment-1:
Upload asset master data with AS02 using Call Transaction Method
Flat File:
Asset number Sub asset number Company code Qunatity
3000006 0 0005 300
Recording:
Go to SHDB
New Recording
Recording: ZREC_AS02
Transaction Code: AS02
Start Recording
Asset: 3000003
Sub Number: 0
Company Code: 0005
Enter
Quantity: 200
Save
Back
Save
Solution:
Go to SHDB
Select your recording
Program
Title: BDC for AS02
Type: Executable Program
Source Code
Remove first 3 lines
Remove last 2 lines & write your program
Rohini kumar
SAP-ABAP 492
Assignment-2:
Upload employee payroll for infotype 14 with PA30 using Call Transaction Method
Flat File:
Employee number Amount
1000 3000
1001 5000
1002 7000
Recording:
Go to SHDB
New Recording
Recording: ZREC_PA30
Transaction Code: Pa30
Start Recording
Employee number: 1000
Infotype: 14
Sty: M110
F6
Start: 01.04.2013
To: 31.03.2014
Wage Type: M110
Amount: 3000
Save
Back
Save
Solution:
Go to SHDB
Select your recording
Program
Title: BDC for PA30
Type: Executable Program
Source Code
Remove first 3 lines
Remove last 2 lines & write your program
Rohini kumar
SAP-ABAP 493
SAP Scripts:
Using Scripts you can design Forms & send the data for print outs
Components of Scripts:
1. Form
2. Page
3. Window
4. Page Window
5. Layout
6. Paragraph Formats
7. Character Formats
8. Header
Form:
It is a collection of pages
Page:
It is a collection of windows
Window:
It is the smallest element of a form, which holds actual data
Page Window:
Using this option windows are maintained in a page in SAP Scripts
Layout:
All windows are adjusted in a page using layout
Paragraph Formats:
With this option you can maintain Font size, Style, Color, Underline……….etc for text on a
form
Character Formats:
Using this option you can maintain Font size, Style, Color…….etc for text (for special
characters in a form)
Header:
Using header administrative data (client number, date of creation, date of change, user
id……..etch) is maintained
Rohini kumar
SAP-ABAP 494
Main Window:
It is a default window in forms
Use this window for maintaining dynamic length data (transactional data)
In one page you can maintain 99 Main Windows (Main 00 to Main 98)
Note:
Without Main Window you cannot work with Scripts
Constant Window:
It is reflected to all the pages of a form
Note:
Maintain Logos, Headers, Footers……….etc using this window
Variable Window:
It is restricted to a specific page
SAPLD SE38
Database
Rohini kumar
SAP-ABAP 495
Note:
SAPLD provides interface between Form Painter & External Devices
Note:
T code for working with Scripts is SE71
Rohini kumar
SAP-ABAP 496
Requirement:
Goods receipt form
Heading Logo
User: Page: 3 of 60
Date:
Page Total:
Heading Logo
User: Page: 3 of 60
Date:
Carry forward amount:
Heading Logo
Page Total:
User: Page: 3 of 60
Date:
Carry forward amount:
Grand Total:
Solution:
Step-1: Form
Go to SE71
Form: ZFORM_GRN
Rohini kumar
SAP-ABAP 497
Create
You will find a message, Enter
Meaning: GRN Form
Step-2:
Select Pages
Page: PAGE1
Next Page: PAGE1
Enter
Meaning: page1
Step-3:
Select Paragraph Formats
Paragraph: P1
Enter
Meaning: p1
Font
Family: COURIER
Font Size: 12
BOLD ON
Step-4:
Select Character Formats
Char. Format: C1
Enter
Meaning: c1
Family: HELVE
Size: 10
BOLD ON
Step-5:
Select Header (F5)
Basic Settings
First Page: PAGE1
Default Paragraph: P1
Step-6:
Select Windows
Edit ------ Create Element
Window: LOGO
Meaning: window
Enter
Rohini kumar
SAP-ABAP 498
Step-7:
Select Page Windows
Edit ----- Create Element
You will find a pop-up, Double click on HEADER
Window Width: 5
Window Height: 5
Edit ----- Create Element
Double click on HEADER1
Window Width: 5
Window Height: 5
Edit ----- Create Element
Repeat the same procedure for USER, PAGE, MAIN, CONST, LOGO windows
Note:
When you maintain MAIN window using Page Windows you will get MAIN window again in
the pop-up (as we can maintain 99 MAIN windows in a Page). So next time you don’t select it
Step-8:
Double click on MAIN window
Edit ----- Text Elements
Goto ----- Change Editor
*
/E GRAND_TOTAL
* &uline(60)&
* ,,,,,,,,,,<C1>Grand total: &wa_sum&</>
Back
Step-9:
Double click HEADER window
Edit ----- Text Elements
Goto ----- Change Editor
Step-10:
Double click on HEADER1 window
Edit ----- Text Elements
Goto ----- Change Editor
* &uline(60)&
*
* Sno,,,,Material,,,,Material Type,,,,Quantity,,,,Amount
* &uline(60)&
Back
Step-11:
Double click on LOGO window
Edit ----- Text Elements
Goto ----- Change Editor
Step-12:
Double click on PAGE window
Edit ----- Text Elements
Goto ----- Change Editor
Rohini kumar
SAP-ABAP 500
Step-13:
Double click on USER window
Edit ----- Text Elements
Goto ----- Change Editor
Step-14:
Select Settings
Form Painter
By default graphical pc editor selected, Deselect it
Select Graphical Form Painter
Enter
Adjust all the windows according to the size of data
Select Minimize
Settings ------ Form Painter
Deselect Graphical Form Painter check box
Select Graphical PC Editor check box
Select Utilities -------- Printing Text
You will find a pop-up
Output Device: LP01
Print Preview
Form
Activate
Local Object
Step-15:
Go to SE38
Program: ZGRN_FORM
Create
Title: Forms for GRN details
Type: Executable Program
Enter
Local Object
Write driver program
Rohini kumar
SAP-ABAP 501
ZGRN_COL_FORM
PERFORM get_mseg.
PERFORM open_form.
PERFORM start_form.
PERFORM process_form.
PERFORM end_form.
PERFORM close_form.
FORM get_mseg.
SELECT mseg~matnr mseg~bwart mseg~menge mseg~dmbtr INTO TABLE it_mseg
FROM MKPF INNER JOIN MSEG
ON mkpf~mblnr = mseg~mblnr
WHERE mkpf~mblnr IN s_mblnr
AND mseg~werks IN s_werks
AND mseg~bukrs IN s_bukrs
AND mseg~budat IN s_budat.
ENDFORM.
FORM open_form.
Rohini kumar
SAP-ABAP 502
FORM start_form.
CALL FUNCTION ‘START_FORM’
EXPORTING
STARTPAGE = ‘PAGE1’
LANGUAGE = SY-LANGU
FORM = ‘ZFORM_GRN’.
ENDFORM.
FORM process_form.
LOOP AT it_mseg INTO wa_mseg.
sno = sno + 1.
CALL FUNCTION ‘WRITE_FORM’
EXPORTING
ELEMENT = ‘ELE1’
WINDOW = ‘MAIN’.
IF sno = 8.
CALL FUNCTION ‘WRITE_FORM’
EXPORTING
ELEMENT = ‘PAGE_TOTAL’
WINDOW = ‘MAIN’.
sno = 0.
ENDIF.
AT LAST.
CALL FUNCTION ‘WRITE_FORM’
EXPORTING
ELEMENT = ‘GRAND_TOTAL’
WINDOW = ‘MAIN’.
ENDAT.
Rohini kumar
SAP-ABAP 503
ENDLOOP.
ENDFORM.
FORM end_form.
CALL FUNCTION ‘END_FORM’.
ENDFORM.
FORM close_form.
CALL FUNCTION ‘CLOSE_FORM’.
ENDFORM.
Rohini kumar
SAP-ABAP 504
2. STRAT_FORM:
It opens a form from a specific page (pass Form name & Page name)
3. WRITE_FORM:
It is for calling text elements in SAP Scripts (pass Text element name & Window name)
4. END_FORM:
It is for closing START_FORM
5. CLOSE_FORM:
It is for closing OPEN_FORM
Script Symbols:
1. * ----- default paragraph
2. ----- continous text
3. = ------- extended line
4. / ------- line field (one line gap)
5. /= ------ line field & extended line
6. /: ------ command line (it is for script commands i.e. BOX, BITMAP)
7. /* ------ comment line
8. /E ------ text element
9. TW ---- twip
1 TW = 1/20 PT (points)
1 PT = 1/72 inches
Go to SE38
Program: ZGRN_COL_FORM
Debugging
Rohini kumar
SAP-ABAP 505
Assignment:
PO Form
Heading Logo
Address:
Total Amount:
PO Quantity:
Pending Quantity:
Delivery Quantity:
Logic:
* Item number &space(5)&Item description &space(30)& Unit of measurement &space(5)&
PO Quantity &space(5)& Unit price &space(5)& Total price &space(5)&
/ BOX FORM 4 TW
/ BOX HIEGHT 2 LN FRAME 4 TW INTENSIVILY 8
/ BOX WIDTH ‘15’ CH HIEGHT ‘15’ LN FRAME 4 TW
/ BOX WIDTH ‘30’ CH HIEGHT ‘15’ LN FRAME 4 TW
Solution:
ZGRN_FORM
Rohini kumar
SAP-ABAP 506
10-11-2014
Standard Forms:
SAP is providing standard forms which are stored in a table TNAPR
In these standard forms we have to make our own modifications based on requirement &
customize the same in NACE T-code
Example:
Step-1: coping a standard form into user defined form
Go to SE71
Utilities ----- Copy From Client
Form Name: MEDRUCK
Source Client: 800
Target Form: ZPO_MEDO
Execute
Package: YABAP
Enter
Create Request
Go to SE78
Expand Graphics-General Graphics
Double click on BMAP-Bit Map Images
Graphics ---- Input
Apply F4 on File Name
Select your logo
Name: SCRIPTLOGO
Description: script logo
Color Bit Map Image
Enter
Graphic
Transport
Enter
Go to SE71
Form: ZPO_MEDD
Change
Page Windows
Try to find HEADER window by selecting Next Page option
Rohini kumar
SAP-ABAP 507
Back
Form ----- Activate
Go to NACE
Application EF
Output Types
Position
Output Type: NEU
Enter
Select NEU
On left side double click on processing Routines
Rohini kumar
SAP-ABAP 508
Display / Change
Form: ZPO_MEDD
Save
Enter
Go to SE10
Display
Expand Main request number
Select sub request number
Select Truck symbol Relase
Select main request number
Select Truck symbol Relase
Go to SE38
Program: RSTXR3TR
Execute
Transport Request: LID0001
Export
File Name: ‘ZPO_MEDD’
Execute
**Smart Forms:
It is a smartest way of working with forms
Form:
It is a collection of Pages
Style:
It is for Paragraph Formats & Character Formats
Text Module:
Maintains conditional data
Types of Windows:
1. Main Window
2. Secondary Window
3. Final Window
4. Copies Window
Main Window:
Use this for holding dynamic length data (transactional data)
Rohini kumar
SAP-ABAP 510
Note:
Without Main window also you can work with Smart Forms
Secondary Window:
Use this for holding fixed length data (master data)
Final Window:
Use this for holding final data (totals, grand totals)
Copies Window:
Use this for copy (or) original format data
**Components of Window:
1. Text (maintains logic)
2. Template (static tables can be created)
3. Folder (holds different components together)
4. Address (maintains address)
5. ** Program Lines (create program)
6. Command (maintains page breaks)
7. Alternate (flip flop logic (if condition))
8. Loop (maintains loops)
9. Table Line (different cells logic)
[Link] (holds data dynamically)
[Link] (maintains logo)
(Unique Function
Module)
Database
Rohini kumar
SAP-ABAP 511
Note:
T code for working with Smart Forms is SMARTFORMS
Rohini kumar
SAP-ABAP 512
Requirement:
PO Form
Heading Logo
Address:
Total Amount:
PO Quantity:
Pending Quantity:
Delivery Quantity:
Page Number
Solution:
Step-0: creating structure
Go to SE11
Data Type: ZPO_STRUC
Create
Structure
Enter
Short Description: structure for PO details
Component Compenent type
EBELP EBELP
MAKTX MAKTX
MENGE MENGE
NETPR NETPR
NETWR NETWR
Currency / Quantity
Rohini kumar
SAP-ABAP 513
P1 -Paragraph Format:
Right click on Paragraph Formats
Create Node
Paragraph Formats: P1
Enter
Description: p1
Font
Font Family: COURIER
Font Size: 12
Font Style: BOLD
P2 -Paragraph Format:
Right click on Paragraph Formats
Create Node
Paragraph Formats: P2
Enter
Description: p2
Indents and Spacing
Alignment: CENTER
Font
Font Family: HELVE
Font Size: 15
Font Style: BOLD
Alignment: CENTER
Font
Font Family: HELVE
Font Size: 12
Font Style: BOLD
Import parameters:
Double click on Form Interface
By default Import tab is selected, provide
Parameter name Type assignment Associated type
EBELN TYPE EBELN
BEDAT TYPE BEDAT
LIFNR TYPE LIFNR
Table parameters:
Tables
Parameter name Type assignment Associated type
IT_EKPO LIKE ZPO_STRUC
Rohini kumar
SAP-ABAP 515
Types
Global Data
Variable name Type assignment Associated type
WA_LFA1 TYPE TY_LFA1
WA_ADRC TYPE TY_ADRC
Form Routines
Currency / Quantity Fields
Field name Reference table Data type
Wa_ekpo-menge wa_ekpo-menge quan
Wa_ekpo-netpr wa_ekpo-netpr curr
Wa_ekpo-netwr wa_ekpo-netwr curr
Rohini kumar
SAP-ABAP 516
You will find a pop-up Color Bit Map Image check box & Deselect Block and White
Image check box
Execute
Select any one Logo based on your requirement
Note:
1. In real time logo is provided by client
2. While creating logo you can adjust the size of the logo using Resolution option
3. Double click on PAGE1 on maintaince screen you will find Background Picture option
with this you can maintain background pictures in Smart Forms
4. Select Output Options tab under that you will find Print Mode. If Print Mode is D you
can provide double side printing
5. By default Page Format is Potrate Format which is for form with less fields. If form
contains more fields (say 15, 20,…….etc) use Landscape Format
PO window:
Right click on LOGO window
Create ------- Window
Window: PO
Meaning: template for po
Enter
Right click on PO window
Create ------ Template
To increase the Width & Height of a template, double click on PO window
On maintaince screen select Output Options tab
Width: 10
Height: 10
Note:
Only upto 25 only we can provide for Height & Width
Enter
Double click on Template 1
Select Template tab
Increase the width of a template based on your requirement
Right click on C1
Split ------ Line
Right click on C1
Split ------ Cell
Right click on C2
Split ------ Cell
Under Template tab, select Pattern option (1st button)
Rohini kumar
SAP-ABAP 517
By default all the patterns are deselected, select Display Framed Patterns option
Double click on 2nd pattern
Right click on Template 1
Create ----- Folder 1
Right click on Folder 1
Create ------ Text
Right click on Text 1
Create ------ Text
Similarly create 3 more texts (Text2, Text3, Text4)
Double click on Text1
On maintaince screen, select Output Options tab
Scroll down to bottom
Line: 1
Coloumn: 1
Double click on Text2
On maintaince screen, select Output Options tab
Scroll down to bottom
Line: 1
Coloumn: 2
Double click on Text3
On maintaince screen, select Output Options tab
Scroll down to bottom
Line: 2
Coloumn: 1
Double click on Text4
On maintaince screen, select Output Options tab
Scroll down to bottom
Line: 2
Coloumn: 2
Double click on Text1
Select Conditions
Output Options
Web Properties
General Attributes
Select Edit option
PO Number
(or)
Goto ----- Change Editor
* PO Number
Back
PAGE window:
Right click on PO window
Create ------ Window
Window: PAGE
Meaning: page number
Enter
Right click on PAGE window
Create ---- Text
At bottom expand System Fields
Drag & drop PAGE on Editor (&SFSYT-PAGE&)
Note:
SFSY-is a standard structure for Smart Forms sytem fields
HEADER window:
Right click on PAGE window
Create ----- Window
Window: HEADER
Meaning: widow for header text
Enter
Right click on HEADER window
Create ----- Text
Double click on Text5
Select Editor option
Goto ------ Change Editor
Rohini kumar
SAP-ABAP 519
P2 REDDY LABS
P2 <C1>,,,,,,An Anji Reddy group </>
P2 <C1>,,,,,, Ameerpet-10 </>
Back
VENDOR window:
Right click on HEADER window
Create ------ Window
Window: VENDOR
Meaning: window for vendor details
Enter
Right click on VENDOR window
Create ----Flow Logic -----Program Lines
Input parameters Output parameters
LIFNR WA_LFA1
WA_ADRC
SELECT SINGLE name1 FROM LFA1 INTO wa_lfa1 WHERE lifnr = lifnr.
IF NOT wa_lfa1 IS INITIAL.
SELECT SINGLE city1 street FROM ADRC INTO wa_adrc
WHERE addrnumber = wa_lfa1-kunnr.
Execute
Right click on CODE1
Create ----- Text
Expand Global Data option
Expand WA_LFA1
Editor option
Goto ---- Change Editor
* Vendor Number: &WA_LFA1-LIFNR&
* Vendor Name: &WA_LFA1-NAME1&
* City: &WA_LFA1-CITY1&
* Street: &WA_LFA1-STREET&
MAIN window:
Right click on MAIN window
Create ----- Table
On maintaince screen you will find %LTYPE1
Split %LTYPE1 into 5 equal parts
Right click on %LTYPE1
Insert ------ Empty Line Underneath
Split %LTYPE2 into 2 parts
Rohini kumar
SAP-ABAP 521
Back
Right click on CELL12
Create ----- Text
Editor
Goto ---- Change Editor
P3 &TOTAL&
Back
Rohini kumar
SAP-ABAP 523
12-11-2014
Note:
SSF_FUNCTION_MODULE_NAME:
This function module returns a smart form function module generated on activation of smart
form
Ques-1:
Why we should call SSF_FUNCTION_MODULE_NAME instead of hard coding the function
module name itself?
Answer:
We know that in real time we have to transport the objects from one client to another
client
If the form is in Quality Server the system may assign a different version of function
module name to respective form & the same happen in Production Server also
So therefore it always advisable to call SSF_FUNCTION_MODULE_NAME which
returns the function module currently which system you are working
Ques-2:
What are the common errors you are facing while working with smart forms?
Answer:
1. Incorrect parameter with call function
This exception you will get if you not pass all the parameters which you maintained in smart
form
Rohini kumar
SAP-ABAP 524
Ques-3:
How do you work with Alternate option in smart form?
Answer:
Righ click on any one Window (say LOGO)
Create ----- Window Alternate
Right click on Alternate Window
Create ----- Flow Logic ------- Alternate
Conditions option
Field name Relational Operator
LIFNR double click
Form Painter
Adjust Alternate window
Activate form
Ques-4:
How you can work with more than one Page in smart form?
Answer:
Right click on PAGE1
Create ------ Page
Right click on PAGE2
Rohini kumar
SAP-ABAP 525
Back
Double click on MAIN window
Window Type: Secondary Window
Double click on PAGE1
Next Page: PAGE2
Double click on PAGE2
Next Page:______
Activate form
*** Ques-5:
How you can convert a smart form into PDF format?
Answer:
Run your print program
Provide input
Execute
Select Print option (Ctrl + P)
At bottom you will find a print request number note down it (say 11,5716)
Go to SE38
Program: RSTXPDFT4
Execute
Spool Request: 11,5716
Execute
Save
Ques-6:
How you can debug a smart form?
Answer:
Go to SMARTFORMS
Form: ZPO_FORM
Change
Rohini kumar
SAP-ABAP 526
Note:
In smart forms you can set only Static Break Point. You cannot set Dynamic Break Point
Ques-7:
How you can work with Excel Sheet in smart forms?
Answer:
DATA fnam TYPE STRING.
Ques-8:
How you can print multiple records in smart forms?
Answer:
ZMM_CALL_SMART_FORMN
CONTROL-NO_OPEN = ‘X’.
CONTROL-PREVIEW = ‘X’.
CONTROL-NO_DIALOG = ‘X’.
CONTROL-NO_CLOSE = ‘X’.
START-OF-SELECTION.
LOOP AT S_EBELN.
PERFORM get_data USING s_ebeln-low.
Ques-9:
How you can migrate SAP Script to smart form?
Answer:
Go to SMARTFORMS
Utilities ---- Migration ----- Import SAP Script Form
Form: ZPO_MEDD
Name: ZPO_MEDD
Enter
Ques-10:
How you can generate smart form into PDF format during runtime of print program?
Answer:
Ques-11:
How you can send of a form in the form of mail?
Answer:
Ques-12:
How you can write code in smart forms?
Answer:
Ques-13:
How you can maintain Page Breaks in smart forms?
Answer:
Rohini kumar
SAP-ABAP 529
13-11-2014
SAP Enhancements:
SAP is highly customizable
Using SAP Enhancements you can add additional functionalitites in existing once
without disturbing the same
Userexits:
Userexits are empty code blocks within subroutines
Object:
Validate sales order application using Userexits
Business Requirements:
In real time using VA01 application sales order is created which is again modified by
using VA02
Write an enhancement to validate VA02 such that one user created sales order is allowed
to modify is by same user only
Solution:
Go to SE38
Program: MV45AFZB
Display
Select Enhance option
Edit ---- Enhancement Operations ----- Show Implicit Enhancement Options
Try to search for USEREXIT_CHECK_VBAK subroutine
Right click on spot under form USEREXIT_CHECK_VBAK
Enhancement Implementation ----Create Implementation
You will find a message, select Code option
You will find a pop-up, select Create option
Again you will find a pop-up, provide
Enhancement Implementation: ZENC_VA02
Short Text: enhancement for VA02 implementation
Enter
Enter
Rohini kumar
SAP-ABAP 530
Enter
Again you will find that pop-up, select your Enhancement name i.e. ZENC_VA02
Enter
IF SY-TCODE EQ ‘VA02’.
IF VBAK-ERNAM NE SY-UNAME.
MESSAGE ‘Access denied’ TYPE ‘E’.
ENDIF.
ENDIF.
Activate
Note:
MV45AFZB & MV45AFZZ are the very important Userexits for VA01, VA02
application which we are working in real time
Currently Userexits are outdated except above
Rohini kumar
SAP-ABAP 531
Customerexits:
Customerexits are advanced to Userexits
Instead of adding customization in existing code it is always better to provide your own
customization using a T code which is done by Customerexits
Note:
Customerexits is based on Fucntional Consultant
Types of Customerexits:
1. Function Exits
2. Menu Exits
3. Screen Exits
4. Field Exits
Function Exits:
Object:
Validate vendor master application for postal code
Business Requirement:
Some times users will not enter Postal code, City, Tax code……..etc in an application
which are optional but important for clients
Provide validation such that without entering Postal code the transaction should not be
created
Note:
** The T code for working Customerexits is CMOD
** The T code for identifying Customerexits for an application is SMOD
Solution:
Step-1: identifying Package name of an application
Go to XK01
System -----Status
Double click on Program Name
Goto ---- Attributes
Note down package name (FBK)
Rohini kumar
SAP-ABAP 532
Enter
Note down Customerexits (SAPMF02K)
Note:
In real time Customerexits for an application is provided by Functional Consultant
Note:
** In Customerexits you cannot reuse the same exit in more than one project
Back
Back
Activate project
Rohini kumar
SAP-ABAP 534
Menu Exits:
Add a menu in MC94 application
Solution:
Step-1: identifying Package name of an application
Go to MC94
System -----Status
Double click on Program Name
Goto ---- Attributes
Note down package name (MCP2)
Activate
Back
Back
Back
Activate project
Rohini kumar
SAP-ABAP 536
Screen Exits:
Object:
Add a screen with following fields in CS01, CS02, CS03 applications
ZZORDER PO number
ZZDATE PO date
ZZVENDOR vendor number
Solution:
Step-1: adding fields to table
Go to SE11
Database Table: STKO
Display
Append Structure
You will find a message, Enter
Append Name: ZSTKO_APP
Enter
Short Description: Additional fields for stko table
Component Component Type
ZZORDER EBELN
ZZDATE BEDAT
ZZVENDOR LIFNR
Activate
Create
Short Text: customerexits for cs01
Save
Enhancement Assignments button
Select your enhancement PCSP0003
Enter
Select Components option
Yes
Double click on 0114
You find a message, select Maintain in Original Language option
You should find a message ‘for program SAPLXCSA is been created’, Enter
If you are not getting such message you have to delete the old enhancement
Activate
Back
Back
Scroll down to bottom
Double click on INCLUDE ZXCSAU04
Display / Change option
TABLES STKO.
STKO-ZZEBELN = USERDATA-ZZORDER.
STKO-ZZDATE = USERDATA-ZZDATE.
STKO-LIFNR = USERDATA-ZZLIFNR.
Activate
Back
Back
Double click EXIT_SAPLSOI_005
Double click on INCLUDE
Display / Change option
USERDATA-ZZORDER = STKO-ZZEBELN.
USERDATA-ZZDATE = STKO-ZZBEDAT.
USERDATA-ZZLIFNR = STKO-ZZLIFNR.
Activate
Back
Back
Back
Activate project
Rohini kumar
SAP-ABAP 539
14-11-2014
Assignment:
Add following fields in ME21N, ME22N, ME23N
ZZDEL Delivery priority
Customerexit: MM06C005
Solution:
Rohini kumar
SAP-ABAP 540
Fieldexits:
Using fieldexits you can modify field labels of data elements in data dictionary
Example:
Go to CMOD
Goto ----- Text Enhancements ------Keywords ----Change
Data Element: REGIO
Enter
Shot Field Lable: State
Medium Field Lable: State
Long Field Lable: State
Heading: State
Short Description: State
Save
Note:
SAP is not recommending Fieldexits in real time
Rohini kumar
SAP-ABAP 541
BADI:
Bussines Addins
It is based on object oriented programming
In Userexits (Customerexits) the same exit cannot be reuse in other projects
In BADIs the same BADI definition can be implemented in N number of
implementations
BADI concept is purly designed based on object oriented programming
For implementing BADI, SAP will provide you an interactive & respective
implementation class
Here interface is a collection of methods where you have to implement the additional
code
Note:
T codes for working with BADIs are
1. SE18 -------- for BADI definition
2. SE19 -------- for BADI implementation
Types of BADI:
1. Standard BADI
2. Custom BADI
3. Filter BADI
Rohini kumar
SAP-ABAP 542
***Standard BADI:
In Standard BADI, BADI definitions are predefined (given by SAP)
In Standard BADI we have to provide only implementation section
Object-1:
Validate customer master application for postal code
Solution:
Go to SE19
Classic BADI
BADI Name: CUSTOMER_ADD_DATA
Create Impl
Enter
Implementation Name: ZXD01_IMPL
Enter
Short Text: implementation for xd01 application
Interface tab
Double click on CHECK_ALL_DATA
Yes
Enter
You may find a message ‘implementation ZXD01_IMPL migrated’, Enter
You will find a pop-up, Select Create option
Again you will find a pop-up, provide
Enhancement Implementation: ZCUSTOMER_IMPL
Short Text: implementation for xd01 application
Enter
Select your implementation (ZXD01_IMPL)
Enter
You may find a wrong method
Back
Again double click on CHECK_ALL_DATA
Place cursor between METHOD………..ENDMETHOD
IF S_KNA1-PSTLZ IS INITIAL.
MESSAGE ‘Enter postal code’ TYPE ‘E’.
ENDIF.
Activate
Back
Activate
Rohini kumar
SAP-ABAP 543
Rohini kumar
SAP-ABAP 544
Watch Point:
Watch point is a cleaver break point
Use watch point for watching the errors in standard applications
The another purpose of watch point is to watch a specific record in an internal table
during debugging
Note:
You can keep maximum 5 wach points in ABAP for a specific report
Example:
Go to XD01
Provide required input
Save
Apply /H in Command prompt (/H is a T code for debugging)
Enter
Enter
Watch point button
You will find a pop-up, provide
***Variable: SY-MSGTY (system field for capturing messages)
Enter
You will find a message ‘watch point created’
F7
Rohini kumar
SAP-ABAP 545
2nd Method:
Go to SE80
Select Package
Provide CS
Enter
Expand Enhancements
Expand Classic BADIs Def
Go to CS01
Variable: EXIT_NAME
F7………….
Material: 100-101
Plant: 1000
Bom: 1
Enter
Rohini kumar
SAP-ABAP 546
Object-2:
Validate BOM application (CS01) for alternate Bom
Business Requirement:
In real time every material is having an alternate Bom
But some materials alternate Bom not possible
Provide to control on such materials such that user try to create alternate Bom system
through an error
Solution:
Go to SE19
Classic BADI
BADI Name: BOM_UPDATE
Create Impl
Enter
Implementation Name: ZBOM_IMPL
Enter
Short Text: implementation for BOM application
Interface tab
Double click on CHANGE_AT_SAVE
Yes
Enter
You may find a wrong method
Back
Again double click on CHANCE_AT_SAVE
Place cursor between METHOD………..ENDMETHOD
Activate
Rohini kumar
SAP-ABAP 547
***Assignment:
In MIRO (or) MIGO you will find posting date & document date
Posting date never be less than document date
Provide control such that if user provides document date greather than posting date gives
error
Solution:
Rohini kumar
SAP-ABAP 548
Object-3:
Add a menu in FBL5N application
Solution:
Go to SE90
Expand Enhancements
Expand Bussiness Addins
Double click on Definitions
Package: FREP
Execute
Note down BADI name
Go to SE19
Classic BADI
BADI Name: F5_ITEMS_MENUE01
Create Impl
Enter
Implementation Name: ZFI_ITEM
Enter
Short Text: implementation for FBL5N application
Interface tab
Double click on LIST_ITEMS01
You may find a wrong method
Back
Again double click on LIST_ITEMS01
Place cursor between METHOD………..ENDMETHOD
Activate
Back
Double click on LIST_ITEMS02
Place cursor between METHOD………..ENDMETHOD
Activate
Back
Activate
Rohini kumar
SAP-ABAP 549
Rohini kumar
SAP-ABAP 550
Object-4:
Add a screen in XD01, XD02 with following field
Sales Manager
Solution:
Go to SE11
Database Table: KNA1
Display
Append Structure
Create Append
Append Name: ZKNA1_APP
Enter
Short Text: Additional fields
Component Component Type
ZZSM ZSM
Activate
Go to SPRO
Select SAP Reference Img option
Expand Logistic General
Expand Bussiness Partner
Expand Customers
Expand Control
Expand Adaption of Customers Own Master Data Fields
Select Prepare Modification- Free Enhancement of Customer Master Record
You will find a message, Enter
New Entries
Screen Grp Description
Z5 Sales manager
Save
On left side double click on Label Tab Pages by selecting Screen Grp Z5
You will find another screen
Select New Entries button
Number Function Code Description
5000 TAB1 Sales manager
Save
Back
Back
Back
Back
Rohini kumar
SAP-ABAP 551
IF I_SCREEN_GROUP EQ Z5.
E_ADD_ON_ACTIVE = ‘X’.
ENDIF.
Activate
Back
Activate
Back
Select 3rd option Bussiness Addin Customer Sub screen
You will find a pop-up, at bottom select Create option
You will find a pop-up, provide
Implementation Name: ZCUST_CS_DATA
Enter
Implementation Short Text: Badi implementation
Attributes tab
Scroll down to bottom
Select ‘+’ Insert Row
Screen Grp
Z5
Save
You may find a message, Enter
You will find pop-up, at bottom select Create option
Enhancement Implementation: ZSM_IMPL_SM
Short Text: Badi implementation
Enter
Rohini kumar
SAP-ABAP 552
CASE I_TAXI_FCODE.
WHEN ‘TAB1’.
E_SCREEN = ‘5000’.
E_PROGRAM = ‘ZBADI_SM’.
ENDCASE.
Activate
Back
Activate
Go to SE38
Program: ZBADI_SM
Create
Title: Sales manager
Type: Module Pool
Enter
Go to SE51
Program: ZBADI_SM
Screen Number: 5000
Create
Short Description: Sub Screen 5000
Sub Screen
Layout
F6
Table Name: KNA1
Enter
Scroll down to bottom, select your field name ZZSM
Enter
Place the field on the screen
Flow Logic
Remove comment for MODULE STATUS_5000
Double click on STATUS_5000
Yes
Main Program
Rohini kumar
SAP-ABAP 553
Enter
Yes
TABLES KNA1.
IF SY-TCODE EQ ‘XD03’.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘KNA1-ZZSM’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
Activate
Back
Activate
Rohini kumar
SAP-ABAP 554
***Assignment:
Add following fields in VL01N, VL02N
Order number
Order date
Delivery challana number
Delivery challana date
Driver
Hint:
Add fields in LIKP table
BADI name is LE_SHP_TAB_CUST_HEAD
Solution:
Rohini kumar
SAP-ABAP 555
Custom BADI:
In Custom BADI, BADI definition is custom defined
Filter BADI:
It is a part of Custom BADI
In Filter BADI, the same definition can be called in different implementations
Object:
Determine tax code for sales organization
Solution:
Go to SE18
Utilities --- Create Classic BADI
Definition Name: ZBADI_CUST_FILTER
Enter
Scroll down to bottom, select Filter Depend check box
Filter Type: VKORG
Save
Interface tab
Note:
Based on your definition name system will create an interface ZIF_EX_BADI_CUST_FILTER
Activate
During activation you will find a message, Enter
Once your interface is activated system will add additional parameter FLT_VAL based
on your filter type VKORG
Go to SE19
Classic BADI
BADI Name: ZBADI_CUST_FILTER
Rohini kumar
SAP-ABAP 556
Create Impl
Enter
Implementation Name: ZBADI_FIL
Enter
Short Text: implementation for filter badi
Scroll down to bottom
Select ‘+’ Insert Row
Sales org
1000
Save
Interface tab
Double click on GET_TAX
Place cursor between METHOD………..ENDMETHOD
IF FLT_VAL = ‘1000’.
P_TAX = 10.
ENDIF.
Activate
Back
Activate
Back
Classic BADI
BADI Name: ZBADI_CUST_FILTER
Create Impl
Enter
Implementation Name: ZBADI_FIL
Enter
Short Text: implementation for filter badi
Attributes
Scroll down to bottom
Select ‘+’ Insert Row
Sales org
1020
Save
Interface tab
Double click on GET_TAX
Rohini kumar
SAP-ABAP 557
IF FLT_VAL = ‘1020’.
P_TAX = 12.
ENDIF.
Activate
Back
Activate
Back
Classic BADI
BADI Name: ZBADI_CUST_FILTER
Create Impl
Enter
Implementation Name: ZBADI_FIL
Enter
Short Text: implementation for filter badi
Scroll down to bottom
Select ‘+’ Insert Row
Sales org
1030
Save
Interface tab
Double click on GET_TAX
Place cursor between METHOD………..ENDMETHOD
IF FLT_VAL = ‘1030’.
P_TAX = 8.
ENDIF.
Activate
Back
Activate
Go to SE38
Program: ZCAL_CUSTOM_FILTER_BADI
Create
Title: Method of filter badi
Type: Executable Program
Rohini kumar
SAP-ABAP 558
Save
IF SY-SUBRC NE 0.
MESSAGE ‘Error in calling BADI’ TYPE ‘E’.
ELSE.
CALL METHOD obj->get_tax
EXPORTING
FLT_VAL = V_VKORG
CHANGING
P_TAX = V_TAX.
ENDIF.
ENDIF.
Rohini kumar
SAP-ABAP 559
Enhancement Framework:
BADIs are based on object oriented programming
But SAP is not providing BADIs for all requirements
Restricted to specific applications & only for specific requirements
Using Framework you can enhance all types of SAP objects
Object-1:
In VA01 you will find a field called Sales office, which is meant for sales office data
Generally clients are instructed not to enter Sales office data as it pickup automatically
from master data (KNVV table)
Some times clients will enter wrong data into Sales office, which is wrongly updated to
transactional tables
Provide an enhancement to deselect Sales office field
Solution:
Go to VA01
Apply F1 on Sales office
You will find a pop-up, select 4th option Technical Information
Double click on Screen 101
Double click on FELDAUSWAHL-101
Double click on subroutine FELDAUSWAHL-101
Enhance
Edit ---- Enhancement Operations ----Show Implicit Enhancement Options
Right click under spot under FORM FELDAUSWAHL-101
Enhancement Implementation ----Create Implementation
Code
Create
Enhancement Implementation: ZVA01_IMPL
Enter
Select your implementation name ZVA01_IMPL
Enter
IF SY-TCODE EQ ‘VA01’.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘VBAK-VKBUR’.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
Rohini kumar
SAP-ABAP 560
ENDLOOP.
ENDIF.
Activate
Rohini kumar
SAP-ABAP 561
Object-2:
Provide Profit center as obligatory in F-28 application
Solution:
Go to F-28
Apply F1 on Profit Center
Technical Information
Double click on Screen 103
Double click on DYNPRO_KOPF_MODIF
Double click on subroutine DYNPRO_KOPF_MODIF
Enhance
Edit ---- Enhancement Operations ----Show Implicit Enhancement Options
Right click under spot under FORM DYNPRO_KOPF_MODIF
Enhancement Implementation ----Create Implementation
Code
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘BSEG-PRCTR’.
SCREEN-REQUIRED = 1.
MODIFY SCREEN.
ENDIF.
Activate
Rohini kumar
SAP-ABAP 562
Object-3:
In MB31 you will find Document date & Posting date as current date
Provide an enhancement such that I want both the dates by default as previous dates
Solution;
Go to MB31
Apply F1 on Document date
Technical Information
Double click on Screen 300
Double click on MODULE BELEGKOPF_VORGSCHLOG
You will find a subroutine, Double click on it
Enhance
Edit ---- Enhancement Operations ----Show Implicit Enhancement Options
Right click on spot above ENDFORM
Enhancement Implementation ----Create Implementation
Code
Create
Enhancement Implementation: ZMB_MB31
Short Text: Implementation for MB51 application
Enter
Select your implementation ZMB_MB31
Enter
MKPF-BUDAT = SY-DATLO - 1.
MKPF-BLDAT = SY-DATLO - 1.
Activate
Rohini kumar
SAP-ABAP 563
*** Object-4:
Add following fields in FB03 application
Dmbtr, Hlcont
Solution:
Go to SE11
Data Type: BKPF_ALV
Display
Append Structure
Enter
Append Name: ZBKPF_APP
Enter
Short Description: Additional fields
Component Component Type
HKONT HKONT
DMBTR DMBTR
Activate
Go to FB03
Document List
Apply F1 on Document number
Technical Information
Double click on Program name
Go to REUSE_ALV_GRID_DISPLAY
Find internal table
Enhance
Edit ---- Enhancement Operations ----Show Implicit Enhancement Options
Right click on spot under FORM GRID_DISPLAY
Enhancement Implementation ----Create Implementation
Code
Create
Enhancement Implementation: ZENC_FB03
Short Text: Implementation for FB03 application
Enter
Select your implementation ZENC_FB03
Enter
Rohini kumar
SAP-ABAP 564
REFRESH GT_YBKPF_ALV.
Rohini kumar
SAP-ABAP 565
Object-5:
Add screen in VF01, VF02, VF03 with ZZBOXNO, ZZSIZE, ZZTEXT
Solution;
Go to SE11
Database Table: VBRK
Display
Append Structure
Create Append
Append Name: ZVBRK_APP
Enter
Short Description: Additional fields
Component Component Type
ZZBOXNO ZBOXNO
ZZSIZE ZSIZE
ZZTEXT ZTEXT
Activate
Go to SE80
Program: SAPMV60A
At bottom, expand Screens option
Find 6001 screen & double click on it
Double click on MODULE CUST_HEAD_ACTIVATE
You will find a subroutine, double click on it
Enhance
Right click under FORM CUST_HEAD_ACTIVATE
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘TABSTRIP_TAB06’.
GS_CUST_TAB_HEAD_OPTION = ‘invocice’.
GS_CUST_TAB_HEAD_PROGRAM = ‘ZSD_INVV’.
GS_CUST_TAB_HEAD_DYNPRO = ‘100’.
IF SCREEN-ACTIVE = 1.
SCREEN-INVISIBLE = 0.
MODIFY SCREEN.
ENDIF.
TABSTRIP_TAB06 = GS_CUST_TAB_HEAD_CAPTION.
ENDIF.
Rohini kumar
SAP-ABAP 566
ENDLOOP.
Activate
Go to SE38
Program: ZSD_INVV
Create
Title: Invoice details
Type: Modulpe Pool
Save
Go to SE51
Program: ZSD_INVV
Screen: 100
Create
Short Description: Sub screen 100
Sub Screen
Layout
F6
Table Name: VBRK
Enter
Scroll down to bottom, select your fields
Enter
Place the fields on screen
Flow Logic
Remove comment for MODULE STATUS_100
Double click on STATUS_100
Yes
Main Program
Enter
Yes
IF SY-TCODE EQ ‘VF03’.
LOOP AT SCREEN.
IF SCREEN-NAME EQ ‘VBRK-ZZBOXNO’
OR SCREEN-NAME EQ ‘VBRK-ZZSIZE’
OR SCREEN-NAME EQ ‘VBRK-ZZTEXT’.
SCREEN-INPUT = 0.
ENDIF.
ENDLOOP.
ENDIF.
Rohini kumar
SAP-ABAP 567
Activate
Back
Activate
Assignment-1:
Add fields Purchase requisition number & Requisitioner name in MB51 application
EBAN-BOMFN,
EBAN-AFNAM
Solution:
Assignment-2:
Add fields storage bin (MARD-LGPBE) in MB5B
Solution:
***Assignment-3:
Validate Sales order quantity (VBAP-KWMENG) with PO quantity (EKPO-MENGE)
If Sales order quantity is > PO quantity provide a control on VA01 application
Solution:
Rohini kumar
SAP-ABAP 568
BTE:
Business Framework
Business Transaction Events
For standard applications SAP is providing BTE
For BTE a specific function module is attached
When BTE triggers respective function module is called
Note:
BTE is mostly for finance transactions
T code for BTE is FIBF
Rohini kumar
SAP-ABAP 569
Object:
Add indicator field in FBL5N application
Solution:
Go to SE11
Database Table: RFPOS
Display
Append Structure
Create Append
Append Name: ZFI_FBL5N
Enter
Short Text: indicator field
Component Component Type
ZZIND ZIND
Go to SE11
Database Table: RFPOSX
Display
Append Structure
Create Append
Append Name: ZFI_FBL5N1
Enter
Short Text: indicator field
Component Component Type
ZZIND ZIND
Go to BERE
Execute
Select Event 1650
Sample Function Module option
Rohini kumar
SAP-ABAP 570
Copy button
To: ZSAMPLE_INTERFACE_0001650
Function Group: F4
Enter
Enter
Function Module: ZSAMPLE_INTERFACE_0001650
Change
Remove comment for E_POSTAB = I_POSTAB
IF I_POSTAB-SHKZG = ‘H’.
I_POSTAB-ZZIND = ‘Credit’.
ELSE.
E_POSTAB-ZZIND = ‘Debit’.
ENDIF.
Activate
Go to FIBF
Settings ----- Products ---- Of a Customer
New Entries
Products A
ZFBL5N _/
Save
Back
Back
Settings ---- PS Modules ---- Of a Customer
New Entries
Event Product Function Module
1650 ZFBL5N ZSAMPLE_INTERFACE_0001650
Save
Go to SE38
Program: RFPOSXEXTEND
Activate
Yes
Enter
Testing Application:
Go to FBL5N
Customer Account: 1000
Rohini kumar
SAP-ABAP 571
Rohini kumar
SAP-ABAP 572
Example:
Go to SE93
Transaction Code: VA01
Display
Double click on Program Name
You will find a spot given by SAP
Enhance
Right click ES_SAPMV45A
Enhancement Implementation ----Create Implementation
Ques-3: What is the difference between Enhancement spot (point) & Enhancement section?
Answer:
In enhancement spot both customized & standard code will be executed
In enhancement section only customized code will be executed
Rohini kumar
SAP-ABAP 573
ALE:
Application Linking Enabling
ALE is SAP’s distributed technology for distributing (or) exchanging business process
between two systems (SAP (or) Non-SAP)
In real time if two companies are having same SAP systems (Servers) & if they want to
exchange their business data
Similarly, if two (or) more than two systems are working with different systems (other
than SAP) & they want to interact with SAP system we have to work with tool called
ALE
IDOC:
Intermediate Document
IDOC is a container with which business data can be exchanged between two systems
Components of IDOC:
1. IDOC Type
2. Segment Type
3. Records
IDOC Type:
It specifies the structure & format of an IDOC
It is simply collection of Segments
Standard IDOC Types have a suffix with 01, 02, 03…………. Which is known as
Version Number
Segment Type:
It is a collection of fields
Standard starts with prefix ‘E1’
Example:
E1KNA1M
E1MARA1M
Rohini kumar
SAP-ABAP 574
Records:
Records are classified into
1. Control Record
2. Data Record
3. Status Record
Control Record:
It holds control level information (IP address of both Sender & Receiver, Message Type
information, Segment Type information…………..etc)
Only one Control Record exists in an IDOC
The structure & format of Control Record is same for all IDOCs
Control Record information is finally updated to a table EDIDC
Data Record:
It holds actual data
Data Record information is finally updated to a table EDIDU (the structure related to it is
EDIDD)
Status Record:
IDOC have to travel through different layers (Application layer, ALE Service layer,
Communication layer)
At each layer the status information of an IDOC can be gathered from Status Record
Status Record information is updated to EDIDS
Sender Receiver
Outbound Inbound
Note:
1. There exists only one Control Record in an IDOC
2. Status Records & Data Records can be many
3. In real time as an ALE Consultant we have to work with only IDOCs
Rohini kumar
SAP-ABAP 575
Rohini kumar
SAP-ABAP 576
ALE Architecture:
MASTER_IDOC_DISTRIBUTED
Master IDOC
Syntax Checks
Communication Layer
IDOC Port created
ARFC_DEST_SHIP
Outbound System
Integration Layer
RFC
Rohini kumar
SAP-ABAP 577
Database
IDOC
Syntax Checks
IDOCs
INBOUND_IDOC_SYNCHRONOUS
Inbound System
Rohini kumar
SAP-ABAP 578
Message Type:
These are unique application identities
SAP is providing an unique identity for all application data to identify the same
Note:
T code for Message Type is WE81 & WE82
Model View
Sender
Receiver
Message Type
Partner Profile:
Using Partner Profiles Ports can be created
T codes are WE21 & BD64
Process Flow:
Master Data Material MATMAS MATMAS05 Master IDOC Process codes Communication IDOC
(WE81) (WE30) (WE41) (WE021 & WE03)
Transactional data PO orders ORDERS ORDERS05 Master IDOC Process codes Communication IDOC
Rohini kumar
SAP-ABAP 579
Types of IDOCs:
1. Standard IDOC
2. Custom IDOC
3. Extended IDOC
Standard IDOC:
In this all IDOC options (Message Type, IDOC Type, Segment Type…………etc) are already
provided by SAP
Object:
Distributing material master data
Message Type: MATMAS
IDOC Type: MATMAS05
Logical Systems:
These are unique client identities
In real time for each client Logical Systems needs to be created
Solution:
Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients
Note:
Logical systems are client independent
New Entries
Logical System Name
MATT800 SENDER
MATT810 RECEIVER
Save
Back
Back
Step-2:
Creating RFC destinations in 800 client:
Go to SM59
Select ABAP Connections
Rohini kumar
SAP-ABAP 581
Create
RFC Destination: MATT810
Description: RFC for Client 810
Target Host: SAPLID
Logon & Security tab
Scroll down to bottom
Language: EN
Client: 810
User: user1
PW Status: rgsabap
Enter
Enter
Save
Enter
Remote Logon button
Working under client 810
Note:
In real time the above 2 steps are done by Basis Consultant
Note:
Sometimes you may find an error message in red color. In such case
Go back
Again, execute
Back
Step-5:
Distributing Model View:
Edit --- Model View ---- Distribute
Enter
You should find a message ‘model view has been created’
Creating Ports:
Select client 810 session
Go to BD64
Select your model view name
Environment ---- Generate Partner Profiles
Rohini kumar
SAP-ABAP 583
Step-6:
Creating process codes in 810 client:
Go to WE20
Expand Partner Type LS
Select Sender logical system name (MATT800)
Right side scroll down to bottom
Under Inbound Parameters
Double click on MATMAS
By default you will find Process Code: AFSA which is wrong one, provide
Process Code: MATN
Save
Note:
The above material is created by end user
Step-7:
Running Outbound program:
Go to BD10
Material: u-883
Message Type: MATMAS
Rohini kumar
SAP-ABAP 584
Step-8:
Displaying IDOC List:
Go to WE05
Execute
Note:
In real time we should work with only outbound system. In outbound system you should always
get status as Green (or) Yellow
Step-9:
Working with MM03:
Go to MM03
Material: u-883
Enter
Enter
Rohini kumar
SAP-ABAP 585
Step-1:
Go to BD50
In real time sometimes all the Message Types may be selected, first you Deselect them &
then
Select your Message Type MATMAS
Save
Step-2:
Go to BD52
Message Type: MATMAS
Enter
Here we have to add additional tables & fields related to material
Step-3:
Go to BD61
Select Change Pointer Activated Generally check box
Save
Step-4:
Go to SE38
Program: RBDMIDOC
Execute
Message Type: MATMAS
Execute
You will find a message, Enter
Enter
Go to MM02
Material: u-883
Enter
Select Basic Data1, Basic Data2
Enter
Make some changes i.e. material: soda bottle, Gross wt: 800………etc
Rohini kumar
SAP-ABAP 586
Save
Go to SE38
Program: RBDMIDOC
Execute
Message Type: MATMAS
Execute
You will find a message ‘1 master IDOC generated’, Enter
Again, you will find a message ‘1 communication IDOC generated’, Enter
Step-5:
Go to WE05
Execute
Scroll down to bottom, Double click on your IDOC Number
Rohini kumar
SAP-ABAP 587
IDOC Filtering:
1. Segment Filtering
2. IDOC Filtering
3. Reduced IDOC Filtering
Segment Filtering:
Unnecessary Segments can be filtered using Segment Filtering
Steps:
1. Work with BD56
2. Work with BD10
3. Work with BE05
Step-1:
Go to BD56
Message Type: MATMAS
Enter
New Entries
Ty Sender Ty Receiver Segment Type
LS MATT810 LS MATT800 E1MARMM
Save
Step-2:
Go to BD10
Material: u-883
Message Type: MATMAS
Logical System: MATT800
Execute
Step-3:
Go to WE05
Execute
Note:
Mandatory Segments cannot be deleted
Rohini kumar
SAP-ABAP 588
IDOC Filtering:
Assume a company is having N number of Company Codes operating in different
countries
Assume a customer is approaching to Company Code 1000 for business
His customer master data will be available not only to 1000 Company Code but also to
other Company Code which is not required from 1000 Company Code perspective
Whenever a customer is created for 1000 Company Code, it should be allowed by the
system
It the same is done for other Company Codes it should be filtered out
In customer distribution model you should create a Filter Set based on Company
Code…….etc
Whenever Master IDOC is created then system will check whether the Company Code is
matching with Filter Set (or) not
If not matching respective Segment is filtered out
Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients
Step-1:
Creating logical systems:
Go to SALE
Expand Basic Settings
Expand Logical Systems
Select Define Logical System option
Enter
Note:
Logical systems are client independent
New Entries
Logical System Name
CUST800 SENDER
CUST810 RECEIVER
Save
Back
Back
Step-2:
Creating RFC destinations in 800 client:
Go to SM59
Select ABAP Connections
Create
RFC Destination: CUST810
Description: RFC for Client 810
Target Host: SAPLID
Logon & Security tab
Rohini kumar
SAP-ABAP 590
Note:
In real time the above 2 steps are done by Basis Consultant
Step-3:
Creating Model View:
Select client 800 session
Go to BD64
By default Create Model View button is deselected
Select F9
Select Create Model View button
Short Text: Model view for customer master
Technical Name: CUSTOM ORDER
Enter
Rohini kumar
SAP-ABAP 591
Enter
Enter
Save
Step-5:
Distributing Model View:
Edit --- Model View ---- Distribute
Enter
You should find a message ‘model view has been created’
Note:
On distributing Model View, model view will became client independent
Creating Ports:
Select client 810 session
Go to BD64
Select your model view name
Environment ---- Generate Partner Profiles
Partner System: CUST800
Execute
You will find a message ‘port has been created’
Step-6:
Creating process codes in 810 client:
Go to WE20
Expand Partner Type LS
Select Sender logical system name (CUST800)
Right side scroll down to bottom
Under Inbound Parameters
Double click on DEBMAS
By default you will find Process Code: DEB2 which is wrong one, provide
Process Code: DEBM
Save
City: Hyderabad
Country: IN
Save
Step-7:
Running Outbound program:
Go to BD12
Customer: 7856
Output Type: DEBMAS
Execute
Step-8:
Displaying IDOC List:
Go to WE05
Execute
Select DEBMAS
Execute
Double click on IDOC Number
Expand Data Records
Go to XD01
Customer: 7856
Company Code: 3000
Enter
Title: Mr
Name: Satya
City: Hyderabad
Country: IN
Save
Go to BD12
Customer: 7856
Output Type: DEBMAS
Execute
Rohini kumar
SAP-ABAP 594
Steps:
1. Work with BD53
2. Work with BD64
3. Work with BD10
4. Work with WE05
Step-1:
Go to BD53
Reduced Message Type: ZRED_MATMAS
Create
Message Type Ref: MATMAS
Enter
Description: Reduced message type for material type
Enter
Place cursor on E1MARMM
Select button
You will find a white color change instead of red color to the segment
Double click on that segment
Select the fields which you want to filter
Select button
Enter
Save
Step-2:
Creating Model View:
Select client 800 session
Go to BD64
By default Create Model View button is deselected
Select F9
Select Create Model View button
Short Text: Model view for customer master
Technical Name: CUSTOM ORDER
Enter
Scroll down to bottom
Select short description of your model view
Select Add Message Type
Sender: CUST810
Receiver: CUST800
Message Type: DEBMAS
Rohini kumar
SAP-ABAP 595
Enter
Again, select Add Message Type
Sender: CUST800
Receiver: CUST810
Message Type: DEBMAS
Enter
Save
Step-3:
Go to BD10
Material: u-883
Message Type: MATMAS
Logical System: MATT800
Execute
Step-4:
Go to WE05
Execute
Note:
In real time we are not working with Reduced IDOC Filtering
Rohini kumar
SAP-ABAP 596
***Object:
Distribute Purchase Order Data using Message Control Technique
Message Type: ORDERS
IDOC Type: ORDERS05
Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients
Note:
Conditional Records are maintained by Functional Consultant
Note:
Purchase Order creation is done by end user. Once ME21N is executed IDOC is created &
dispatched to Inbound system
Solution:
Step-1:
Creating logical systems:
Go to SALE
Expand Basic Settings
Expand Logical Systems
Select Define Logical System option
Enter
Note:
Logical systems are client independent
New Entries
Logical System Name
MATT800 SENDER
MATT810 RECEIVER
Save
Back
Back
Rohini kumar
SAP-ABAP 598
Step-2:
Creating RFC destinations in 800 client:
Go to SM59
Select ABAP Connections
Create
RFC Destination: MATT810
Description: RFC for Client 810
Target Host: SAPLID
Logon & Security tab
Scroll down to bottom
Language: EN
Client: 810
User: user1
PW Status: rgsabap
Enter
Enter
Save
Enter
Remote Logon button
Working under client 810
Note:
In real time the above 2 steps are done by Basis Consultant
Rohini kumar
SAP-ABAP 599
Note:
Sometimes you may find an error message in red color. In such case
Go back
Again, execute
Back
Step-5:
Distributing Model View:
Edit --- Model View ---- Distribute
Enter
You should find a message ‘model view has been created’
Rohini kumar
SAP-ABAP 600
Creating Ports:
Select client 810 session
Go to BD64
Select your model view name
Environment ---- Generate Partner Profiles
Partner System: MATT800
Execute
You will find a message ‘port has been created’, Enter
Note:
With the above navigation we should provide
1. Whom to transfer (Receiver address)
2. What to transfer (Message Type & IDOC Type)
3. Mode of dispatch (Transfer Immediately & Collect IDOCs)
4. Medium of data transfer (Port)
Rohini kumar
SAP-ABAP 601
Save
Rohini kumar
SAP-ABAP 602
Custom IDOC:
In Custom IDOC all IDOC options are customized
Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients
Solution:
Step-1:
Creating logical systems:
Go to SALE
Rohini kumar
SAP-ABAP 603
Note:
Logical systems are client independent
New Entries
Logical System Name
MATT800 SENDER
MATT810 RECEIVER
Save
Back
Back
Step-2:
Creating RFC destinations in 800 client:
Go to SM59
Select ABAP Connections
Create
RFC Destination: MATT810
Description: RFC for Client 810
Target Host: SAPLID
Logon & Security tab
Scroll down to bottom
Language: EN
Client: 810
Rohini kumar
SAP-ABAP 604
User: user1
PW Status: rgsabap
Enter
Enter
Save
Enter
Remote Logon button
Working under client 810
Note:
In real time the above 2 steps are done by Basis Consultant
Save
Save
Save
Rohini kumar
SAP-ABAP 608
17-11-2014
Extended IDOC:
Extended IDOC = Predefined IDOC Type + Additional Segment
Steps:
Client 800 Client 810
1. Work with SALE
Create Logical Systems
Assign Logical Systems to Clients
Rohini kumar
SAP-ABAP 609
Solution:
Step-1:
Creating logical systems:
Go to SALE
Expand Basic Settings
Expand Logical Systems
Select Define Logical System option
Enter
Note:
Logical systems are client independent
New Entries
Logical System Name
EXT1800 SENDER
EXT1810 RECEIVER
Save
Back
Back
Step-2:
Creating RFC destinations in 800 client:
Go to SM59
Select ABAP Connections
Create
RFC Destination: EXT1810
Rohini kumar
SAP-ABAP 610
Note:
In real time the above 2 steps are done by Basis Consultant
KUNNR KUNNR
NAME1 NAME1
LAND1 LAND1
ORT01 ORT01
PSTLZ PSTLZ
STRAS STRAS
Save
Save
CASE SEGMENT_NAME.
WHEN ‘E1KNA1M’.
READ TABLE IDOC_DATA INTO WA_DATA WITH KEY SEGNAM =
‘E1KNA1M’.
WA_MAPPING = WA_DATA + SDATA.
SELECT SINGLE KUNNR NAME1 ORT01 PSTLZ STRAS FROM KNA1 INTO
WA_KNA1 WHERE KUNNR = WA_MAPPING-KUNNR.
WA_DATA-SDATA = WA_KNA1.
WA_DATA-SEGNAM = ‘Z1SEG’.
ENDCASE.
City: Hyderabad
Country: In
Save
Rohini kumar
SAP-ABAP 615
3. Status 29
Error in ALE Service Layer (or)
Error in Custom (or) Extended program
4. Status 26
Error in Syntax Check (or)
If Segment is wrong (or)
Mandatory Segments are deleted (or)
If Partner Profiles are not maintained in WE20
Example:
Go to WE19
IDOC Number: 8110 (it is wrong)
Execute
Double click on IDOC Number
Standard Inbound option
You will find a pop-up with error message
2. BD20
It is for processing partial IDOCs
3. WE09
It is for searching IDOCs which are being processed as on date
Rohini kumar
SAP-ABAP 616
Debugging IDOCs:
1st Method:
Go to BD20
IDOC Number: 801120
Command Prompt: /H
Enter
Enter
F6………………..
2nd Method:
Go to SE37
Function Module: IDOC_INPUT
Display
Place Dynamic Break Point at DESCRIBLE TABLE IDOC_DATA LINES
Go to BD20
IDOC Number: 801120
Execute
Rohini kumar
SAP-ABAP 617
EDI:
Electronic Data Interchange
Paperless work
EDI is computer to computer exchange of routine business data (Purchase Orders,
Invoices, Sales Orders………..etc) in standard format
Advantages of EDI:
Availability of data in electronic forms
Reduced data entry errors
Paperless work
Better competitive advantage
Accuracy of data
Speed
Security
EDI Architecture:
MM SD
IDOC IDOC
Rohini kumar
SAP-ABAP 618
Middle Wares:
1. EAI
Enterprise Application Integration
1.1. MA Series
1.2. Web Methods
2. EDI Systems
2.1. Gentian
2.2. Mercator
3. SAP XI
Exchange infrastructure
Rohini kumar
SAP-ABAP 619
Solution:
Step-1: Creating File Port
Go to WE21
File
Create
Port: IDOCPORT
Description: Port creation
Scroll down to bottom
Function Module: EDI_PATH_CREATE_USERNAME
Inbound File tab
Function Module: EDI_PATH_CREATE_USERNAME
Save
Outbound Trigger tab
RFC Destination: SERVER_EXEC
Save
Note:
SERVER_EXEC will transfer the IDOC file to Web methods
Save
Save
Step-5:
Go to ME21N
Vendor: 9347
Enter
Purchase Organization: 1000
Purchase Group: 001
Company Code: 1000
Enter
Rohini kumar
SAP-ABAP 621
Currency: INR
Material: 100-101
PO Quantity: 10
Net Price: 3000
Plant: 1000
Save
Once you save the application you will get a message ‘Purchase Order ……… created’
Rohini kumar
SAP-ABAP 622
BAPI:
Business Application Programming Interface
It is an interface programming across business applications
Features of BAPI:
1. BAPI is an interface programming
2. It is based on Object Oriented Programming
3. It supports all types of Languages (.Net, Java, VC++………etc)
4. It supports all type of Communication interfaces (RFC, COM, DCOM, CORBA,
TIBCO………….etc)
5. In BAPI, RFC function module converted to method & the same method is accessed by
3rd party communication interfaces
6. BAPI is synchronous
Business Object:
The entire business objected oriented programming is designed based on business objects
Every business object holds business data & does not allow it to access by outside world
Kernel:
It holds inherent data
Rohini kumar
SAP-ABAP 623
Integration Layer:
In this layer methods are defined for accessing Kernel data
Interface Layer:
Here interfaces (BAPIs) are maintained for integrating with methods
Communication Layer:
All communication interfaces (RFC, CORBA……..etc) can access this layer
Object Type:
Business Objects are created based on Object Type
It acts as a blue print (or) template for creating business objects
Key Fields:
Using this option key fields are maintained (Customer Number, Sales Order………etc)
Methods:
The main logic for extracting business data is maintained using Methods
Attributes:
These are the parameters which are passed & returns from Methods
These are actually part of Methods
Rohini kumar
SAP-ABAP 624
BOR:
Business Object Repository
It is the central repository for all business object types & their BAPIs
Features of BOR:
1. It acts as central access point (or) repository for all Business Objects, Object Types, Their
Key Fields, Methods …………..etc
2. All 3rd party Communication interfaces can access Business Objects stored in BOR
3. Business Objects maintained in BOR remains stable for a long time
Note:
The T code for working with BOR is BAPI & SW01
Rohini kumar
SAP-ABAP 625
***Types of BAPIs:
1. Standard BAPI
2. Custom BAPI
3. Extended BAPI
Standard BAPI:
In standard BAPI, all BAPI function modules are predefined
Object:
Create a bank in client database
Solution:
Go to SE38
Program: ZFI_BAPI_BANK
Create
Title: Uploading bank data using BAPI
Type: Executable Program
Save
wa_bank_address-bank_name = ‘Sbi’.
wa_bank_address-street = ‘Lbnagar’.
wa_bank_address-city = ‘Hyderabad’.
wa_bank_address-bank_brnch = ‘Lbnagarbranch’.
IF SY-SUBRC EQ 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
Rohini kumar
SAP-ABAP 626
EXPORTING
WAIT = ‘X’.
ENDIF.
Rohini kumar
SAP-ABAP 627
Object-2:
Create interface program for update bank data
Solution:
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.
PARAMETERS: p_banks TYPE banks,
p_bankl TYPE bankl.
SELECTION-SCREEN: END OF BLOCK b1.
wa_bank_address-bank_name = ‘Sbi’.
wa_bank_address-street = ‘Tnagar’.
wa_bank_address-city = ‘Chennai’.
wa_bank_address-bank_brnch = ‘Tnagarbranch’.
wa_bank_addressx-street = ‘X’.
wa_bank_addressx-city = ‘X’.
wa_bank_addressx-bank_brnch = ‘X’.
IF SY-SUBRC EQ 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
WAIT = ‘X’.
ENDIF.
Rohini kumar
SAP-ABAP 628
*** Assignment:
Create BAPI interface program for creating sales order using
BAPI_SALEORDER_CRETEDAT2
Solution:
Rohini kumar
SAP-ABAP 629
23-11-2014
Custom BAPI:
In Custom BAPI, BAPI function modules are custom defined
Object:
Create customized BAPI for invoice object
Phases:
1. Analysis Phase
2. Design Phase
3. Implementation Phase
4. Test & Release Phase
Analysis Phase:
During this phase Project Managers will analyze which BAPI project should be implemented
for current project
Design Phase:
During this phase BAPI Structures & Tables are designed
Implementation Phase:
During this phase BAPI project will be implemented
It is further having following sub phases
1. Working with SE11 (DDIC)
2. Working with SE37 (Create RFC Form)
3. Working with SWo1 (create Business Object)
4. Working with SE38 (create Interface program)
Solution:
Step-1:
Creating Structure:
Go to SE11
Data Type: ZBAPI_INVSTR
Create
Structure
Short Description: Invoice details
Component Component Type
VBELN VBELN_VF
FKDAT FKDAT
Rohini kumar
SAP-ABAP 630
MATNR MATNR
ARKTX ARKTX
FKIMG FKIMG
NETWR NETWR
Activate
Creating Table:
Go to SE11
Database Table: ZBAPI_INVTABLE
Create
Short Description: Invoice table
Delivery Class: A
Table View Maintenance: Display / Maintenance View Allowed
Fields
Field Data Element
MANDT _/ MANDT
VBELN _/ VBELN_VF
FKDAT FKDAT
MATNR MATNR
ARKTX ARKTX
FKIMG FKIMG
NETWR NETWR
Technical Settings
Data Class: APPL0
Size Category: 0
Save
Back
Activate
Utilities ----- Table Contents ----- Create Entries
Provide input & Save
Rohini kumar
SAP-ABAP 631
Export tab
Parameter Name Typing Associated Type Pass Value
RETURN TYPE BAPIRET2 _/
Tables tab
Parameter Name Typing Associated Type
IT_INV LIKE ZBAPI_INVTABLE
IF SY-SUBRC NE 0.
RAISE INVALID-INPUT.
ENDIF.
Activate
Back
Function Module --- Release----- Release
Rohini kumar
SAP-ABAP 632
Note:
In real time if your testing is not fine go to SE37 & solve the issue
Rohini kumar
SAP-ABAP 633
Note:
In real time as a ABAP Consultant we should create business objects in BOR
Assignment-1:
Create standard BAPI for creation of material using BAPI_MATERIAL_SAVEDATA
Assignment-2:
Create standard BAPI for creating purchase order using BAPI_PO_CREATE
Rohini kumar
SAP-ABAP 634
Adobe Forms:
Using Adobe Forms you can design interactive forms with various interactive actions
In Smart Forms we can design only Paper Forms
But using Adobe Forms you can design PDF (or) Online Forms
Note:
T code for working with Adobe Forms is SFP
Adobe forms can be exploited using
ABAP knowledge
Web Dynpro
Java Script
Object:
Develop an invoice form using Adobe forms
Solution:
Go to SFP
Interface: ZBILL_INT
Create
Description: Invoice interface
Enter
By default Import option is selected
On right side select Append Row option
VBELN TYPE VBELN_VF
Rohini kumar
SAP-ABAP 635
Activate
Back
Form: ZBILL_FORM
Create
Description: Invoice form
Interface: ZBILL_INT
Enter
Expand Import
Drag & drop VBELN under ZBILL_FORM
Expand Global Data option
Drag & drop IT_VBRP under ZBILL_FORM
Expand System Fields
Expand SFPSY
Drag & drop DATE, USER NAME under ZBILL_FORM
Layout
Palettes ---- Library
Place Text Icon on Design view
Place Image Icon on design view
Double click on Image
Ok
Select any Logo, Open
Right click on image
Palettes ----- Object
Embed Image Data
Close
Place VBELN, DATE, USER NAME on design view
Place IT_VBRP on design window
Save
Close
Rohini kumar
SAP-ABAP 636
Activate
Go to SE38
Program: ZSD_ADOBE_FORM
Create
Title: Adobe form
Type: Executable Program
Save
PERFORM open_form.
PERFORM call_form.
PERFORM close_form.
FORM open_form.
CALL FUNCTION ‘FP_JOB_OPEN’
CHANGING
IE_OUTPUTPARAMS = output.
ENDFORM.
FORM call_form.
CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’
EXPORTING
I_NAME = ‘ZBILL_FORM’
IMPORTING
E_FUNCNAME = fname.
FORM close_form.
CALL FUNCTION ‘FP_JOB_CLOSE’.
ENDFORM.
Activate
Execute
Provide input
Execute
Rohini kumar
SAP-ABAP 637
Debugging Techniques:
Table Level Debugging:
Using table level debugging you can manipulate data directly from table level
Example:
Go to SE11
Database Table: KNA1
Display
Contents
Kunnr: 1000 to 1005
Execute
Select Select All option (F9)
Display (F7)
Command Prompt: /H
Enter
Enter
Debugging ----Switch to New ABAP Debugger
Variable
CODE
Enter
Scroll horizontally
Click on Change Field
Remove SHOW & provide EDIT
Note:
For delete ------ DELE
For modify ---- EDIT
For insert ------ INSR
Enter
F6 ……………….
F8
Provide input (which you want to modify)
Save
Next Entry
Provide input (which you want to modify)
Save
Rohini kumar
SAP-ABAP 638
Rohini kumar
SAP-ABAP 639
Rohini kumar
SAP-ABAP 640
Lock Object:
Using lock object you can maintain data integrity between applications
Example:
Go to SE11
Database Table: YCUSTOM
Create
Short Description: custom table
Delivery Class: A
Table View Maintained: Display / view allowed
Fields tab
Field name Data element
MANDT MANDT
KUNNR KUNNR
NAME1 NAME1
Technical Settings
Data Class: APPL0
Size Category: 0
Save
Back
Activate
Utilities ---- Table Contents ---- Create Entries
Kunnr: 1000
Name1: satya
Save
Go to SE38
Program: ZLOCK
Create
Title: lock object program
Type: Executable Program
Save
TABLES YCUSTOM.
START-OF-SELECTION.
CALL SCREEN 100.
Yes
Short Description: main screen
Layout
F6
Table: YCUTOM
Enter
Select all fields, Enter
Place the fields on screen
Flow Logic
Remove comment for MODULE STATUS_100
Double click on STATUS_100
Yes
Main Program
Enter
Go to /OSE11
Lock Object: EZLCK1
Create
Short Description: lock object
Tables
Name: YCUSTOM
Lock Mode: WRITE LOCK
Activate
Note:
Once your lock object is activated system will create 2 function modules
One for applying lock &
Another for releasing lock
KUNNR = p_cust.
Activate
Activate
Back
Activate
Testing:
Go to SE38
Execute your program
Done
Go to /OSE38
Execute your program
Not Done
Note:
In real time locks are released manually using T code SM12
o Go to SM12
o List
o Select locks
o Lock Entry ----- Delete All
Rohini kumar
SAP-ABAP 643
Technical Settings
Data Class: APPL0
Size Category: 0
Save
Back
Activate
Insert the following records into table
1000 satya
1001 satya
1002 satya
1003 pruthvi
Go to SE37
Function Module: F4IF_SHLP_EXIT_EXAMPLE
Copy
To: ZSEARCH_MOD
Function Group: ZFGR
Enter
Enter
Function Module: ZSEARCH_MOD
Change
Scroll down to bottom, before EXIT
SORT RECORD_TAB.
Activate
Rohini kumar
SAP-ABAP 644
Go to SE11
Search Help: ZSEAR_HELP
Create
Enter
Short Description: elementary search help
Selection Method: ZCUST1
Search Help Exit: ZSEAR_HELP
Scroll down to bottom, provide
Search Help Parameter Export Import LPOS SPOS
NAME1 _/ _/ 1 1
Activate
Go to SE38
Program: ZCALL_SEARCH
Create
Title: search help exit program
Type: Executable Program
Save
Activate
Execute
Apply F4 on field
You will find only sorted list
i.e. 1000 satya
1004 pruthvi
Rohini kumar
SAP-ABAP 645
Question-2:
How you can maintain Logs (or) Error records in Session method?
Answer:
In Session method SAP is providing a Log file by default
No need to create a Log file for handling error records
You can find Log file by using SM35
Go to SM35
Select your session
Select Log option (F7)
Select your session
Select Display button
Question-3:
How you can perform background processing in Session method?
Answer:
Using program RSBDCSUB you can execute session in background
Example:
In above program modify subroutine PERFORM close_session.
FORM close_session.
ENDFORM.
Execute
F4
Select your Flat File
Rohini kumar
SAP-ABAP 646
Execute
You will find a selection screen
Session: RGS
Execute
Question-4:
Suppose I’m having a Flat File with 50000 records. It happened that the system crashed while
uploading data. How I know the number of records exactly uploaded?
Answer:
I will go to respective database table & copy the key values to the table & execute it
Question-5:
Assume there are 1000 records out of which I uploaded 500 records & remaining I want to
upload next day. How you will you perform this job?
Answer:
I will check the status of the records uploaded & I will delete the records from Flat File which
are correctly uploaded & remaining I will execute once again on next day
Question-6:
I’m having 2 Flat Files with 500 records & 50000 records. Which method will you prefer for
both Flat Files?
Answer:
For 500 records Call Transaction Method
For 50000 records Session Method
Question-7:
What is the difference between Session Method & Call Transaction Method?
Answer:
Session Method Call Transaciton Method
7. It for uploading large amount of data 1. It for uploading small amount of data
8. Multiple applications can be processed 2. Only single application can be processed
at one time with one BDC program at one time with one BDC program
9. In this method respective Log File is 3. In this method we have to create Log file
already given by SAP explicitly using structure BDCMSGCOLL
[Link] processing 4. Synchronous processing
[Link] updating 5. Asynchronous updating
[Link] is a slower method but consistent 6. Faster than Session method
Question-8:
How will you handle error records BDC?
Answer:
In real time client will ask error records during BDC upload
Rohini kumar
SAP-ABAP 647
For that we have to provide him Logs in the form of error file
In Session Method Log file you can find directly in SM35
In Call Transaction Method as processing synchronous we have to create a Log file
internal tabld based on structure BDCMSGCOLL which holds log details during
processing of application
The error records are looped to respective work area which further exported to Funtion
Module FORMAT_MESSAGE
It returns a Message ID which I will capture by using a dummy internal table
7.) What are the commands for sequential file and their syntax?
Ans:
1. Read dataset file <file> into <wa>.
2. Open dataset file <filename> in binary mode
3. Close dataset <file>.
4. Transfer <file> to <wa>.
5. Delete dataset <file>.
Rohini kumar
SAP-ABAP 648
13.) Write down the coding example of filling the data into bdc table ?
Ans:
Ans: The last entry is to save data using BDC_OKCODE and the value is ‘/11’.
25.) An index is added to the fieldname to indicate which line is to be populated by bdc
session?
Ans:
27.) A situation: an abap program creates a batch input session. We need to submit the Program
and batch input session in background. How will u do it?
Ans:
Go to SM36 and create a background job by giving job name, job class and job steps
(background scheduling steps).
Rohini kumar
SAP-ABAP 651
36.) Suppose there are 1000 records and there is an error at 66 record. How will u identify and
send it to end user?
Ans: Using BDCMSGCOLL u can capture error records and using T code SLG1 u can find it.
37.) I am uploading 1000 records using session method. I have an error at 950 record. What will
happen in both ctm and session method?
Ans:
Up to 949 records are updated using session method.
Except 950 remaining all records are update using ctm.
39.) How will generate and processing the session in the same program?
Ans: In ur program using SUBMIT RSBDCSUB VIA SELECTION-SCREEN
41.) I want to upload 10 lakh records and each record is taking 1 minute for processing. How
will solve this issue?
Ans:
Break the records into 100/1000 sessions and process ur session it will take same time as
it take for single sessions.
We can go through lsmw direct input method.
Use bapi run in background.
Ans:
Using BDCMSGCOLL u can find the errors
In session method go to SM35 see the status (the green shows successful & red with
errors)
45.) After running a bdc program with session, I found few errors next morning. What will u
do?
Ans:
Correct the error records (ur flat file) and run bdc program.
If problem is not in session then I will check the bdc program.
46.) U are given FD for bdc, how will u decide which method to use?
Ans:
It depends on client requirement
If it is large data use session method.
Small amount of data use ctm.
49.) What is the difference between batch input and direct input?
Ans:
Batch Input Direct Input
1. Validations are done based on predefined 1. Validations are done by applications
Function Module
2. We cannot send the fields according to 2. Fields can be send (our requirement)
Our requirement
Rohini kumar
SAP-ABAP 653
50.) How do u write a program in session such that it will run the program without going to
SM35 and creates a session?
Ans: SUBMIT RSBDCSUB VIA SELECTION-SCREEN AND RETURN.
Rohini kumar
SAP-ABAP 654
62.) What are the commands available for controlling batch input session?
Ans:
1. /bbeg------- restart transaction
2. /bbdel------ delete transaction from from batch input session
3. /n ----------- terminate current transaction
4. /bda--------- foreground processing
5. /bde--------- display mode to error mode
6. /bend------- end current batch input session
Rohini kumar
SAP-ABAP 655
Rohini kumar
SAP-ABAP 656
Rohini kumar
SAP-ABAP 657
BDC FAQS:
4Q: What are the problems in processing batch input sessions? How is batch input process
different from processing on line?
Ans: Sessions cannot be run in parallel and not fast.
5Q: What do you do when the system crashes in the middle of a BDC batch session?
Ans:
Check no. of records already updated and
Delete them from input file and
Run BDC again.
7Q: What are the commands that allow you to process sequential file? What is their syntax?
Ans :-
1. READ DATASET (reading) and
2. TRANSFER (writing)
Syntax:
Rohini kumar
SAP-ABAP 658
OPEN DATASET for < appending=" " output=" "> in mode at POSITION
MESSAGE.
READ DATASET INTO.
CLOSE DATASET.
DELETE DATASET.
TRANSFER to
8Q: What is the process for transferring data from legacy system to SAP?
Ans:
FTP file transfer,
Manufacturer –specific field transfer NFS (network file system) (or) BDC.
9Q: How many types of tables exists and what are they in data dictionary?
Ans:
11Q: Can a transparent table exist in data dictionary but not in the data base physically?
Ans: NO
13Q: Can you create a table with fields not referring to data elements?
Ans: NO.
14Q: What is the advantage of structures? How do you use them in the ABAP programs?
Ans:
Rohini kumar
SAP-ABAP 659
When the first EXTRACT statement occurs in a program, the system creates the extract
dataset and adds the first extract record to it.
In each subsequent EXTRACT statement, the new extract record is added to the dataset.
EXEC SQL.
ENDEXEC.
19Q: What is the meaning of ABAP editor integrated with ABAP data dictionary?
Ans: Area menu
Rohini kumar
SAP-ABAP 660
20Q: What is an interactive report? What is the obvious differences of such report compared
with classical type reports?
Ans:
Interactive reporting allows the user to participate in retrieving and presenting data at
each level during the session.
Gives a basic list form, which the user can call detailed information by positioning the
cursor and entering the commands
Classical reports consists of one program the creates a single list which contains
clustered data requested, regardless of the details the user wants to see.
25Q: How are the date and time field values stored in SAP?
Ans: SY-DATUM & SY-UZEIT
4. FNAM
5. FVAL
31Q: What are the function modules associated with batch input?
Ans :-
1. BDC_OPEN_GROUP ,
2. BDC_CLOSE_GROUP ,
3. BDC_INSERT
Rohini kumar
SAP-ABAP 662
34Q: How do you find the transaction number, program number and field names?
Ans :-
Transaction no., Program no –
System -> status
Field names - F1,
Technical help
36Q: What are the available OK Codes that can be utilized during batch input processing?
Ans :-
/n –-------- terminates current batch input transaction and marks as incorrect.
/bdel –---- delete current batch input transaction from session.
/bend –----- terminate batch input processing and mark session as incorrect.
/bda –------ change display mode to process the session on screen instead of displaying only
errors.
/bde –------ change display mode to display only errors instead of processing the session on the
screen.
37Q: What is the effect of the BDC_CURSOR field name in the BDC table?
Ans :-
You can set the cursor and enter as a corresponding field value the name of the field on which
the cursor is to be positioned
Rohini kumar
SAP-ABAP 663
43Q: Give real time work done by u in BDC ? Transactions used ? parameters passed with
functions?
Ans:
44Q: Will ask u for screen no's and dynpro names for BDC that u say u have done?
Ans:
45Q: Which technical field in the BDCDATA table holds the last cursor position?
Ans:
48Q: How do you send the BDCDATA table in a Call Transaction statement?
Ans:
Rohini kumar
SAP-ABAP 664
Rohini kumar
SAP-ABAP 665
Ques-2:
What are the common errors you are facing while working with smart forms?
Answer:
9. Incorrect parameter with call function
This exception you will get if you not pass all the parameters which you maintained in smart
form
Rohini kumar
SAP-ABAP 666
Ques-3:
How do you work with Alternate option in smart form?
Answer:
Righ click on any one Window (say LOGO)
Create ----- Window Alternate
Right click on Alternate Window
Create ----- Flow Logic ------- Alternate
Conditions option
Field name Relational Operator
LIFNR double click
Form Painter
Adjust Alternate window
Activate form
Ques-4:
How you can work with more than one Page in smart form?
Answer:
Right click on PAGE1
Create ------ Page
Right click on PAGE2
Create ---- Window
Window: LETTER
Meaning: Window for letter description
Save
Right click on LETTER window
Rohini kumar
SAP-ABAP 667
Back
Double click on MAIN window
Window Type: Secondary Window
Double click on PAGE1
Next Page: PAGE2
Double click on PAGE2
Next Page:______
Activate form
*** Ques-5:
How you can convert a smart form into PDF format?
Answer:
Run your print program
Provide input
Execute
Select Print option (Ctrl + P)
At bottom you will find a print request number note down it (say 11716)
Go to SE38
Program: RSTXPDFT4
Execute
Spool Request: 11716
Execute
Save
Ques-6:
How you can debug a smart form?
Answer:
Go to SMARTFORMS
Form: ZPO_FORM
Change
Expand VENDOR window
Double click on CODE1
Provide BREAK-POINT
Activate form
Go to SE38
Rohini kumar
SAP-ABAP 668
Note:
In smart forms you can set only Static Break Point. You cannot set Dynamic Break Point
Ques-7:
How you can work with Excel Sheet in smart forms?
Answer:
DATA fnam TYPE STRING.
Ques-8:
How you can print multiple records in smart forms?
Answer:
ZMM_CALL_SMART_FORMN
Rohini kumar
SAP-ABAP 669
START-OF-SELECTION.
LOOP AT S_EBELN.
PERFORM get_data USING s_ebeln-low.
Rohini kumar
SAP-ABAP 670
Ques-9:
How you can migrate SAP Script to smart form?
Answer:
Go to SMARTFORMS
Utilities ---- Migration ----- Import SAP Script Form
Form: ZPO_MEDD
Name: ZPO_MEDD
Enter
Ques-10:
How you can generate smart form into PDF format during runtime of print program?
Answer:
Ques-11:
How you can send of a form in the form of mail?
Answer:
Ques-12:
How you can write code in smart forms?
Answer:
Ques-13:
How you can maintain Page Breaks in smart forms?
Answer:
2.) Difference between 'form interface' and 'global definitions' in global settings of smart
forms?
Ans:
Form Interface is where you declare what must be passed in and out of the smart form (in
from the print program to the smart form and out from the smart form to the print
program).
Global definition is where you declare data to be used within the smart form on a global
scope.
Rohini kumar
SAP-ABAP 671
ie: anything you declare here can be used in any other node in the form.
6.) How do you make sure that both, the SMARTFORM & it's function module gets
transported? (or) Does the FM with same name gets generated automatically in the transported
client?
Ans:
A smart form is transported no differently than any other object.
If it is assigned to a development class that is attached to a transport layer, it will be
transported.
The definition is transported, and when called, the function module is regenerated.
This leads to an interesting situation.
On the new machine, it is very likely the function module name will be different than the
name on the source system.
Make sure, before you call the function module, you resolve the external name to the
internal name using the 'SSF_FUNCTION_MODULE_NAME' function module.
Typically, generate the SF, then use the pattern to being in the interface.
Rohini kumar
SAP-ABAP 672
Then change the call function to use the name you get back from the above function
module.
7.)How to protect lines in the main window from splitting between pages?
Ans:
It was easy with SAP script, but how to do it with SFs
For 4.7 version if you are using tables there are two options for protection against line break
1. You can protect a line type against page break.
2. You can protect several table lines against page break for output in the main area.
8.) What are the differences between SAP Scripts and Smart forms?
Ans:
SAP Scripts are client dependent whereas Smart forms are client independent.
SAP Scripts require a driver program to display the output whereas in smart forms the
form routines can be written so that it is standalone.
An integrated Form Builder helps to design Smart forms more easily than SAP Scripts
A Table Painter and Smart styles to assist in building up the smart forms
On activation a function module is generated for Smart forms
Rohini kumar
SAP-ABAP 673
11.) I have a smart form which works fine in DEV. After transporting it to PROD, there is no
Function module generated for this smart form. As a result my program dumps in PROD?
Ans:
The Smart form that is created in the Development may not have the same name in the
Production server.
So it is always advised to use the Function Module
SSF_FUNCTION_MODULE_NAME
12.) How u write Function Module name by passing the Smart form name?
Ans:
13.) How can I make the Smart forms to choose a printer name by default?
Ans:
16.) Where can I provide the input parameters to the smart form?
Ans:
The input parameters for the smart form can be defined in Global Settings->Form
Interface.
The Associated Type must be defined in the ABAP Dictionary.
17.) Where can I define my own global types for the smart form?
Ans:
The global types (within the smart form) can be defined in
Global Settings->Global Definitions->Types
The types defined here will be global through the entire smart form.
Also the form routines can be defined Global Settings->Global Definitions->Form
Routines
18.)I have defined my own Program Lines, where I have used a global variable G_TEXT. I get
an error G_TEXT is not defined?
Ans:
Whenever using the global variables in the Program Lines, enter the variable name in
Input Parameters if you are going to use (read) the variable.
If you are going to both read/write the variable value enter the same in Output
Parameters.
19.) I have created a table node for display. Where can I check the condition which must satisfy
to display the table?
Ans:
The conditions can be defined in the Conditions tab.
In smart forms all the nodes have a condition tab where you can specify the condition to
be satisfied to access the node.
20.) How can I define Page Protect in Smart forms?
Ans:
To define Page Protect for a node go to the Output options and check the Page Protection
checkbox.
Rohini kumar
SAP-ABAP 675
21.) What is the difference between Template and Table in Smart forms?
Ans:
The Template contains a fixed number of rows and columns, where the output is fixed.
The Table can have variable number of rows
22.) Where can I define the paragraph and character format for the smart forms?
Ans:
The paragraph and character format for the smart forms can be defined in the transaction
SMARTSTYLES
23.) How to add buttons and radio buttons etc in smart forms?
Ans:
Buttons is not possible in smart forms (only in adobe forms it is possible).
But you can insert checkboxes and radio buttons in smart forms.
You can print a check box in different ways..
By inserting symbols and making window as check box..
Once go through the thread u will get to k now different ways
Rohini kumar
SAP-ABAP 676
Faqs in Smartforms:
Rohini kumar
SAP-ABAP 677
Example:
Go to SE93
Transaction Code: VA01
Display
Double click on Program Name
You will find a spot given by SAP
Enhance
Right click ES_SAPMV45A
Enhancement Implementation ----Create Implementation
Ques-3: What is the difference between Enhancement spot (point) & Enhancement section?
Answer:
In enhancement spot both customized & standard code will be executed
In enhancement section only customized code will be executed
Rohini kumar
SAP-ABAP 678
Rohini kumar
Pool tables and cluster tables are types of SAP database tables used to optimize data storage. Pool tables are used when many small tables with a matching structure are gathered and stored in a single table in the database known as a table pool. This conserves space in the database as all rows from different tables that belong to one pool are stored as a single row in the pool table. Cluster tables, similar to pool tables, group several logical tables into a single database table, but they are used mainly for storing data belonging together, often with a hierarchical relationship, in a compressed form. The primary use of cluster tables is to store control data like system configuration settings or temporary data such as session-specific data. Both types optimize database storage and performance but are used in different scenarios based on data organization needs .
The use of Table Maintenance Generator (TMG) significantly impacts data management for both client-specific and cross-client tables within SAP ABAP. For client-specific tables, TMG allows data manipulation directly from the database, providing an efficient and user-friendly interface for managing data updates while ensuring client-specific isolation and security. However, for cross-client tables, TMG usage can be more complex due to the need to maintain consistent data across multiple client environments. TMG facilitates structured and controlled data operations, reducing redundant data entry errors but requires careful configuration to ensure data integrity across all connected instances. Well-designed authorizations and clear understanding of table settings are crucial when dealing with cross-client data to prevent unwarranted data exposure or errors, thus highlighting the importance of TMG in managing SAP table security and data integrity .
Checkboxes in TMG operations enhance functionality by providing visual cues and interactive elements that allow users to quickly select and modify records within database tables. They simplify the process of enabling or disabling options and make the interface intuitive by allowing batch operations on selected records. In TMG, adding checkboxes involves defining a field with a domain representing checkbox states, which usually have fixed values like 'X' or space to indicate checked or unchecked statuses. This approach improves user interaction with the data entry interface, offering an easy way to manage boolean attributes or facilitate selection processes for batch updates within the table maintenance view .
Extended IDOCs are used in SAP to accommodate additional data fields that are not present in standard IDOCs, thereby allowing for customized data exchange tailored to specific business needs. Configuring extended IDOCs involves several steps: creating logical systems and assigning them to clients, defining new segment types in WE31, and creating the extended IDOC type in WE30. Once created, the modified IDOC type is linked to a message type in WE82. Partner profiles are then maintained or modified to include the extended capabilities in WE20, and appropriate ports and processing rules are established. These configurations ensure that the extended IDOCs can be generated, sent, and processed efficiently across different systems, enhancing the integration and data handling capabilities within SAP landscapes .
SELECT-OPTIONS and PARAMETERS enhance data retrieval in SAP ABAP reports by allowing users to define flexible and dynamic input criteria for report selection screens. SELECT-OPTIONS allow for multiple selections and ranges for a field, making data retrieval more specific and tailored to user needs. PARAMETERS, on the other hand, enable the definition of single fields where users can input or select single values. The integration of these elements in a report offers users more control over the data retrieved, providing a refined and precise output according to the specified conditions, thereby improving the interactivity and specificity of reports compared to static reporting .
Interactive reports in SAP ABAP offer substantial benefits over classical reports by allowing users to dynamically interact with the data presentation layer. Unlike classical reports, which create a static list, interactive reports give users the ability to drill down into more detailed data with real-time participation via user-driven commands at different levels. This means users can click on displayed items to view further granular details or execute additional functions directly from the report. This capability makes interactive reports more user-friendly and flexible, particularly for decision-making contexts where specific insights or detailed information retrieval is crucial. Such real-time data interactions support better business intelligence and responsiveness within the organization .
The purpose of creating a Table Maintenance Generator (TMG) in SAP ABAP is to enable direct insertion, updating, and deletion of data in database tables when data is not linked with other tables, allowing for efficient manipulation at the table level. The process involves creating the database table using SE11, defining the table's delivery class, allowing the display and creation of entries, and specifying technical settings with appropriate data class and size category. Once the table is activated, you go to SE80, select Function Group, and create a maintenance screen. This setup enables supporting operations like creating, updating, and deleting records directly on the table .
Using Native SQL in ABAP programming presents several challenges and considerations, mainly related to its independence from the ABAP Dictionary. Native SQL allows the use of database-specific SQL statements, providing flexibility to access external data not managed by the ABAP Dictionary. However, this can lead to potential maintainability and portability issues since it may not be compatible across different database systems. Additionally, unlike ABAP's Open SQL, Native SQL lacks automatic client handling and security checks, requiring more meticulous control and error handling by the developer. Furthermore, improper use of Native SQL can jeopardize system integrity through bypassing of ABAP security protocols .
Assigning Logical Systems to clients in SAP is crucial for establishing unique identifiers that handle data exchange within and between SAP systems. A logical system facilitates communication and data transfer processes by designating specific partners in scenarios like ALE (Application Link Enabling), IDocs, or RFCs (Remote Function Calls). Execution involves defining these logical systems globally by navigating to the SALE transaction and configuring them under Basic Settings. Logical systems are created and assigned in a client-independent manner, enhancing seamless integration across different business units or external partners. This structure supports robust data management and efficient system interactions essential for distributed environments .
Batch Input Sessions in SAP play a crucial role in mass data processing, allowing for the automated input of high volumes of data into the SAP system. These sessions create an intermediate step between internal tables and the database, storing data along with necessary actions for screen fields. The sessions facilitate the batch input method by queuing data in a controlled manner, which can then be processed to update the database with minimal manual intervention. This method ensures consistent data entry processes while providing options for error handling and data validation throughout the session execution. Additionally, this processing can be run in different modes, such as foreground or background, with display options for errors to enhance data reliability and integrity .