Beruflich Dokumente
Kultur Dokumente
SAP – R/3
SYSTEM APPLICATIONS PRODUCTS INDATA
PROCESSING
ABAP/4
1
Sun Shine Technologies
Contents
Introduction to sap 5
ABAP introduction and role of an abap consultant 6
Tcodes 8
Data Dictionary
Tables 9
• Creation 13
• Structure 30
• Search help 20
Views 33
• Data Base View 33
• Projection View 38
• Maintenance View 40
• Help View 48
Lock Objects 51
Performance Factors 53
• Buffering
• Indexes
• Log Data Changes
Packages 56
Introduction to programming with keywords 60
Internal Tables 65
• Types of Internal tables 75
• Operations of Internal tables 77
• For all entries 99
• Inner joins 104
Messages 79
2
Sun Shine Technologies
Open Sql 80
Modularization Techniques 105
• Includes 105
• Macros 109
• Subrourines 108
• Function Modules 111
Control Break Statements 120
Classical Reports 123
Interactive Reports 127
• Hide 128
• Getcursor 131
ALV Reports 135
• Filedcatalog 136
• Events 140
• Blocked 143
• Hierarical 146
• Interacive 149
Variant 157
Performance Issues 161
Debugging 165
Module Pool Programming 169
• Screen Design 169
• Events 170
• Table Control 171
• Tab Strip 171
• Validations 172
Scripts 173
Smartforms 206
3
Sun Shine Technologies
BDC 263
• Call Transaction 263
• Session 280
LSMW 294
Enhancements and Modifications 311
• Exits -- UserExits, Customer Exits
BAdI 338
Cross Applications 347
BAPI 381
4
Sun Shine Technologies
SAP –R/3
System Applications and Products Indata
Processing
Introduction to SAP
It stands for System ApplicationProduct In Data Processing over the year it grows
and evolved to becomes the world premier provider for client/server business
solutions for which it is so well today.
It is an Erp Product.
1) Technical : a) Basis
b) Abap
5
Sun Shine Technologies
ABAP/4.
Advance Business Application Programming.
• ABAP is a programming language developed by SAP for the interactive
development of application programming.
• IT is tightly integrated across all the modules viz like SD, MM, HR etc..
• All application programs, along with parts of the R/3 Basis system, are
written in the ABAP Workbench using ABAP, SAP’s programming language.
The individual components of application programs are stored in a special
section of the database called the R/3 Repository. The R/3 Repository
serves as a central store for all of the development objects in the R/3
System
• It contains the Cross application concept to exchange the data from one
system to another system
• EX: SAP to VB
JAVA to SAP
Characteristics of ABAP/4
• ABAP allows you to define and call subroutines. You can even call
subroutines of other programs. There are different ways of how to pass
parameters to and from the subroutines.
6
Sun Shine Technologies
• ABAP contains an SQL subset called OPEN SQL. OPEN SQL allows you to
read and change database tables independent of the underlying database
system.
• ABAP allows you to define and process internal tables that exist only for the
execution period of the program. Internal tables most efficiently support
the usage of database tables and allow you to implement complex data
structures in a program.
• ABAP allows you to store data not only in databases but also as sequential
files on application and presentation servers.
RICEF/FRICE
R – REPORTS: Fetching data from database based on the given input and
display in a particular format.
7
Sun Shine Technologies
Tables
Tables
Kna1 Vbak
Knb1 Vbap
Knc1 Likp
Lfa1 Lips
Lfb1 Vbrk
Lfc1 Vbrp
Mara T001
Marc T001w
8
Sun Shine Technologies
Mard
Makt
Ekko
Ekpo
Eban
Ebkn
Data Dictionary
Tcode: SE11
Definition:
- Data dictionary describes the logical structures of the objects used in
application development and shows how they are mapped to the underlying
relational database in tables/views.
- It is a central repository, which is a collection of repository objects like
database tables, views, and structures….etc.
- We can create, change and display any table.
- We can also know the table definition and global types.
- It is closely integrated (linked) with ABAP Development Workbench.
- Transaction code – SE11
- It is a virtual database, which consists of metadata (definition of underlying
database)
Functionality:
- Data integrated (linked with other table), maintains data security
(authorization) and data consistency (accuracy).
- It avoids data redundancy (duplication or repetition).
9
Sun Shine Technologies
Classification:
1. BASIS (table can be client dependent & client independent)
2. Technical (tables can be transparent tables, cluster tables & pooled tables)
3. Functional (table can be master tables, transaction tables, configuration
tables & system tables)
1. BASIS Classification:
Client dependent Client independent
Also called as Client specific Also called as cross client
Consists of client (MANDT) as key Doesn’t consist of client (MANDT) as
field key field.
MANDT as data element NOTE: table data is dependent on
CLNT as data type client.
3 as length. Table structure is common in all the
clients.
10
Sun Shine Technologies
Cluster Table: Cluster tables are logical tables that must be assigned to a table
cluster when they are defined. Cluster tables can be used to store control data.
They can be also used to store temporary data or texts, such as documentation.
DATA CLASSES:
a. Master Data: are used to maintain master data. Master data is the data
which is almost constant and rarely changed. E.g. Customer master data,
vendor master data, material master data, and HR master data.
b. Transactional Data: are used to maintain transactional data. Transactional
data is the data which changes frequently and rarely constant. E.g. sales
document item data, purchase document item data, billing document item
data, delivery document item data.
c. Customizing Data (or) configuration data: maintains organization data.
Organization data is the data which is entered initially while setting up a
new organization. E.g. clients – T000, company codes – T001, country –
T005.
d. System data: maintains system data (or) control data system data is the
data which is maintained and controlled by SAP. E.g. language key – T002,
currency keys – TCURC, unit of measurement – T006.
DELIVERY CLASS:
- Specifies the data to be transferred between clients, while client copy or
upgrade.
- It specifies the owner of the table. e.g. A-application table (master &
transactional data)
- Data can be master and transactional data, customizing data, temporary data,
etc.
11
Sun Shine Technologies
Save
Technical Settings
DATA CLASS:
- Specifies the logical storage area (table space) occupied by current table in the
underlying database. The table space depends on type of data.
Ex: (types of data)
APPL0: master data – transactional tables
APPL1: transactional data – transparent tables
APPl2: organization data – customizing tables
USER1: customer data class
USER2: customer data class
SIZE CATEGORY:
- Specifies the number of records expected in the database table.
- Using technical settings tab we can maintain data class, size category, and
buffer options.
Notes:
- We can modify standard table technical settings.
- In kna1, you can enter 10,000 records – but if the requirement is to enter
more than 10,000 records then you can change the data class and increase the
number of records.
12
Sun Shine Technologies
13
Sun Shine Technologies
Se11
Select the radio button domain
Short description
Provide data type and length
Save, check and activate.
14
Sun Shine Technologies
15
Sun Shine Technologies
Se11
Select the data type radio button
Select data element
Provide short description
Provide the domain and enter – automatically data type and length are copied
since domain is already created and activated.
Come to fields tab
Provide field labels (i.e. short descriptions).
Save, check and activate.
Create table
Provide field name
Provide data element
Double click on data element
Save
Yes
Provide short description for data element
Provide domain
Double click on domain
Save
Yes
16
Sun Shine Technologies
Click on utilities
Table contents
Create entries
17
Sun Shine Technologies
By Taking Data types as ‘DATS’ and ‘TIMS’ for Date and time fields
By taking fixed values in Domain
18
Sun Shine Technologies
FOREIGN KEY:
DEFINATION:
- Foreign key is a key field of other table.
- Foreign key serves like interface between two tables.
- Using foreign keys we can establish relationship between two tables.
- While defining foreign key relationship cardinality has to be specified.
Cardinality mentions how many dependent records or how referenced
records are possible.
ADVANTAGES:
- It generates F4 help.
- In F4 help, check table keyfield values are populated automatically.
- F4 help is useful while maintaining data into current table with the help of
other table entries.
- Foreign key performs field validation (if the user provides a value from the F4
list, only then the entry is valid).
REQUIREMENT:
Whenever we want to fetch the data from two database tables and display
output, two tables must have relationship.
- Tables can be connected using foreign key.
- To create foreign key common field is required in both tables.
PRE-REQUISITIES:
19
Sun Shine Technologies
PROCEDURE:
- Open the foreign key table in change mode.
- Click on entry help/check tab.
- Place the cursor on foreign key field and click on foreign key icon.
- In dialogue box, provide short description, check table name, and (e.g. check
table name is the other program from where you want to get the field).
- Click on generate proposal tab and continue (do not check any boxes there).
- Click on Check and copy.
- Notice the status message and check table name.
- Activate table.
TESTING/ CHECKING:
UTILITIES -> TABLE CONTENTS -> CREATE ENTRIES.
Place the cursor on foreign key field input field notice that system generated F4
help.
System enables “check table tab” on successful creation of foreign key.
Check table tab is useful to cross check the check table entries.
20
Sun Shine Technologies
- Wherever this domain is used, system proposes this value table name as
check table while creating foreign key.
ADVANTAGES of specifying value table, it automatically proposes check table
name while creating foreign key.
SEARCH HELP:
- In the previous versions, it was called as MATCH CODE OBJECT (4.6c).
- Search help replaces match code objects.
- It is also called as F4 help, possible values help, possible entries help, input
help and hit list.
- Search help can be attached to….
1. Table field.
2. Structure component
3. Data element
4. Screen field
- Search help is also independent repository object. There are a lot of built in
search helps.
- Search help can be classified into two.
1. Elementary search help
It can be created using selection method as:
Database table (fields from single table)
Database view (fields from two tables with inner join)
Projection view (fields from single table)
Help view (fields from two tables with left inner join).
It provides F4 help for the table field.
It fetches the data related tables and displays as hit list.
2. Collective search help
It is a collection of more than one elementary search helps.
PRE-REQUISITE:
- Table status must be active.
- Table field must have data element.
21
Sun Shine Technologies
- Table must contain some data/entries which can be displayed in the hit list
to the end user.
PROCEDURE:
Go to SE11.
Select search help radio-button.
Provide search help name starting with Y or Z.
Click on create -> elementary -> continue.
- Provide short description.
- Specify data collection – selection method as (table name zb3_empmaster).
- Under dialogue behavior – display values immediately.
- Provide search help parameter as empno or hit F4 and select one.
Check import and export and LPOS AND SPOS as 1 and 1. Here, data
element comes by default.
Do the same things for EMP name.With LPOS AND SPOS as 2 and 2.
Save -> check -> activate and test it.
USAGE:
This is attaching the search help to table field
- Open the table
- Click on entry/check tab.
- Place the cursor on field name and click on search help tab.
- In dialogue box, provide the search help name which was created
(zb3_shelp).
- Continue.
- Dialogue box, click on copy.
- You will notice message in the bottom and you will find search help name
under search help tab also origin of the input (explicit – created outside and
implicit – created inside).
- Save -> check -> activate ->
- Utilities -> contents -> create entries (you find f4 help to EMP no and f4
help to EMP name as well).
-------&--------
22
Sun Shine Technologies
23
Sun Shine Technologies
24
Sun Shine Technologies
25
Sun Shine Technologies
26
Sun Shine Technologies
ZZSHELP
ZESHELP1 ZESHELP2
ZHELPVIEW1 ZHELPVIEW2
27
Sun Shine Technologies
ZZSHELP
ZESHELP1 ZESHELP2
ZHELPVIEW1 ZHELPVIEW2
PRE-REQUISITIES:
- At least 2 elementary search helps.
- Procedure:
o In the definition add the fields from both elementary search helps
(no duplicate field names).
o Under included search help tab add elementary search help.
o Select elementary search help and click on parameter assignment
(system proposing respective elementary search help parameters to
collective search help parameters),
ADDITIONAL OPTIONS:
o Using hidden option, we can hide any elementary search help tab in
the final display.
o After activation, we can attach collective search help to table field or
data element.
- Creating (Collective Search Help)Search Help
28
Sun Shine Technologies
29
Sun Shine Technologies
Then go to Data base table for which you want to assign the collective search
help.
30
Sun Shine Technologies
STRUCTURES:
- Structure is a data type defined in ABAP Dictionary.
- Structure is a collection of components with different data types.
- Structure is an independent repository object.
- Structure is included into data base table.
- One structure can be included into multiple database tables (reusability).
- Structure does not contain data.
- When structure components are included in table, it becomes table fields
(data maintenance is possible).
- We can attach check table or search help to structure component.
- It is a combination of fields.
- Structure can hold only one record at a time.
31
Sun Shine Technologies
- Go to SE11 -> data type -> provide structure name starting with Y or Z -> click
on create -> select structure and continue.
- Provide short description.
- Under COMPONENTS TAB -> provide components name and components
type.
- Save -> Check -> Activate.
Now the structure is ready to be used.
-----------------------------------------------------------------&-----------------------------------------
-----------------------
INCLUDING THE STRUCTURE INTO TABLE:
- Under database table, open the table in which you want to use this structure.
- Provide .include in field column and provide structure name in data element
tab and press enter.
STRUCTURE TYPES:
1. FLAT STRUCTURE: is a collection of many components. It does not consist
of reference types/structures by using .include.
2. NESTED STRUCTURE: one of the structure components is reference to
another structure.
o Including a structure while creating a structure by using .include is
called nested structure.
3. DEEP STRUCTURE: one of the structures is referring to table type.
Notes:
1. In standard table, if you find any field in blue color, then it means that the
particular field belongs to include. And that field does not belong to that
table.
APPEND STRUCTURE:
- For a standard table, we cannot open in change mode if we want to add some
fields but the solution for this is Append Structure.
o It is used to add additional fields to standard table (table
enhancement).
o Without modifying the existing table structure, we can add additional
fields to standard table at the bottom.
32
Sun Shine Technologies
33
Sun Shine Technologies
Views :
Is a virtual table where we can store the data from multiple tables.
DATABASE VIEW:
- It is a collection of data from more than 1 logically related database tables.
- DB view implements inner join while fetching the data.
- Selection conditions are possible.
- Maintenance status – read only.
- Are used to find out table relationship.
- Are used alternative for inner join.
34
Sun Shine Technologies
Extra:
We don’t have to enter join conditions here, system will propose it.
Click on selection condition:
Kna1 – kunnr - <= ‘0000000200’
If you want to add one more condition then last tab enter AND
Kna1 – land1 – EQ – ‘US’ (case-sensitive – should be capital letters only)
Note:
- There would be relationship even if the date element name is same or domain
name is same.
- Field name might be different even then there would be some relationship
and that is why is shows the relationship.
- Field name should not be same under view fields tab.
- We should not select similar fields under views.
- Case sensitive, if its capital letters in database table then even in selection
condition, it should be capitals.
- And comparison value values must be in single quotes.
- Extra – create statement - generates system ********
- Extra – change view type – used to change the view type to another type.
- Database view can be created on using single table also and maintenance is
also possible for standard table but we don’t do that.
35
Sun Shine Technologies
36
Sun Shine Technologies
37
Sun Shine Technologies
PROJECTION VIEW:
- It is used to hide some data of single table and in turn display other data.
- It is always created on single table only.
- Selection conditions are not possible.
- Maintenance status – read only. (it is possible but we don’t do it)
- It is used in the programs whenever we require single table particular field’s
data.
38
Sun Shine Technologies
39
Sun Shine Technologies
40
Sun Shine Technologies
MAINTAINENCE VIEW:
- It is used to fetch the data from more than one logically related table.
- It also used to maintain data (insert, change, delete) into several tables.
- It implements left outer join.
- Working with maintenance view is a 2 step procedure:
1. View creation
2. Table maintenance generator
- Selection conditions are possible.
- Maintenance status is: read, change, insert, delete.
MAKT MARA
- In the above picture, in first page which is overview page, the user can fetch
data from more than one table and he also has access to read, change and
delete data from database permanently.
- And in the second page which is single screen page, he can insert new entries.
- Table maintenance generator is used to create table maintenance program to
add, modify or delete records in the database table. This can be accessed
41
Sun Shine Technologies
using transaction SM30, SE54 or in SE11 -> menu – utilities -> table
maintenance generator.
1. Maintenance type:
a. One step – if it is one step then it is single step. Read, change, insert,
delete operations are possible from overview screen only. All
possible in one screen.
b. Step Two – uses overview screen for read, change, and delete
operations. It uses single screen for insert.
2. In SAP, every screen is identified by unique number.
3. Screen number consists of 4 digits.
a. Valid screen number range – 0001 to 9999.
b. Out of these, SAP reserved screen numbers are 1000 to 1010.
c. Customer screen number range 1 to 999 and 1011 to 9999.
42
Sun Shine Technologies
T.Codes:
SE55: table maintenance generator.
SM30: maintain table views.
that in the 'Delivery & Maintenance' tab, the 'Table View Maint.' should have the
"Maintenance allowed" property defined.
Transaction Codes
SE54: Generate Table Maintenance Dialog
SE55: Table view maintenance DDIC call
SE56: Table view display DDIC call
SE57: Deletion of Table Maintenance
SM30: Maintenance Table Views:
Implementation of table maintenance generator for a custom table
Go to SE11 and create a table with the fields as per the requirement.
In table change mode, click on Utilities and then click on Table maintenance
generator.
44
Sun Shine Technologies
45
Sun Shine Technologies
46
Sun Shine Technologies
After the above settings click on the create button in the Table maintenance
generator.
47
Sun Shine Technologies
If we found any deviations in the headers like fields then we can change those
settings from structure level of table only. At that time we have to delete the
Table maintenance generator. Otherwise we can get previous Skelton only in
SM30 (Maintain Table Views.)
48
Sun Shine Technologies
HELP VIEW:
- Also used to fetch data from more than one table and display output.
- It implements left outer join.
- Selection conditions are possible.
- Maintenance status is read only.
- It is used as selection method while creating elementary search help.
49
Sun Shine Technologies
50
Sun Shine Technologies
51
Sun Shine Technologies
LOCK OBJECT:
- Lock object is used to restrict the simultaneous access of database table
entry by multiple users at a time.
- SAP supports record level or row level locking.
- Lock object can be defined in ABAP dictionary initial screen as a repository
object.
- User defined lock object names begin with EY or EZ.
- We can lock primary table entry as well as dependent table (secondary
table) entry also.
- Lock happens by default on key fields.
- Lock modes (or) lock types:
o E – exclusive/write lock – if we set lock mode as ‘E’ only that
particular user can perform all operations. Other shared or exclusive
locks are rejected. Others, it will not be visible.
52
Sun Shine Technologies
o S – shared/read lock – if the user sets lock type S, then all the users
can access the table entry. Modification by any user is not allowed.
o X – Exclusive not cumulative lock – this is exclusive lock only but it is
used to perform the lock for one time only.
o Optimistic Lock -
Once the lock object is defined centrally and activated it generates two function
modules.
1. Enqueue_<lock object name> : this function module sets the lock on
particular table only.
2. Dequeue_<lock object name> : this function module release the lock.
PROCEDURE:
1. Define lock in ABAP dictionary.
2. Go to SE38, create ABAP executable program and call Enqueue function
module and execute it.
3. Perform the operation like update, modify, delete.
4. Check locks entry using T.code: SM12.
5. Release the lock by calling function module Dequeue.
PRE-REQUISITIES:
- Lock happens on key field only.
PROCEDURE:
1. Go to SE11, select lock object name starting with EY or EZ.
2. Click on create.
3. Provide short description.
4. Under TABLES – PRIMARY TABLE – NAME – zb3_empmaster.
5. LOCK MODE – E WRITE LOCK.
6. Under LOCK PARAMETER TAB – save – check – activate.
7. Go to MENU – LOCK MODULES –
8. Go to SE38, provide the program name starting with Y or Z.
9. Create – short description – type as executable program – save as local
object.
10.Click on PATTERN (CTRL+F6) -> CALL FUNCTION ENQUEUE_EZLOCK_OBJ.
53
Sun Shine Technologies
11.Uncomment: exporting
12.Mode = ‘E’. (Exclusive, shared or exclusive not cumulative).
13.Mandt = sy-mandt
14.Empno = ‘0001’.
15.Other parameters are not required, you can comment them.
16.Go to SM12, click on list – to check.
17.Now to unlock it -> call function module ‘dequeue_ezlock_obj’.
---------------&---------------
BUFFERING:
1. It is available under TECHNICAL SETTINGS TAB.
2. Every application servers consists of local buffer.
3. Buffer stores temporary data, volatile data.
4. By using buffering, it picks the data from buffer directly so it saves lot of
time. And buffering will be provided for master data/tables because there
is a chance of losing data. (In one way it is useful but there is also a chance
of losing data).
5. TABLE -> TECHNICAL SETTINGS ->BUFFERING TAB -> under this:
a. BUFFERING NOT ALLOWED: if we select this option table entries are
not buffered.
b. BUFFERING ALLOWED BUT SWITCHED OFF: table entries are
buffered, select this option if we don’t know the number of entries
loaded into buffer.
c. BUFFERING SWITCHED ON: select this option, if we are aware of
expected entries into buffer. Under this, you also have to specify the
buffering type also.
i. FULLY BUFFERED: picks all the data and stores in buffer. All the
table entries are loaded into buffer even if we select for single
record also.
ii. SINGLE RECORD BUFFER: picks only one data and stores in
buffer (the result of select single statement is single record).
54
Sun Shine Technologies
iii. GENERIC AREA BUFFER: picks only specified data and stores in
buffer.
1. By specifying key fields, we are defining the generic key.
2. Only generic key matching entries are loaded into
buffer.
3. Generic key is a combination of left justified key fields.
Note: “BY PASS BUFFERING” is used to skip buffering and go to database table.
INDEX:
- Primary index is created by SAP.
- It is used to improve performance. It is a data base management system
(DBMS) concept for faster retrieval of data. And it is of two types:
o Primary key – provide uniqueness and avoid duplication of records.
And we don’t create primary key, it is already created in database
tables. All the key fields in a table are called primary key.
o Secondary indexes or secondary key – to improve the performance of
a query while searching for records. We create secondary key in SE11
and inform BASIS TEAM.
Note:
SAP recommends taking indexes as the last option to increase the performance
and even if you use this, then make sure that you are not using not more than 4-5
indexes maximum. And in real time, if you need to create indexes then write an
email to the basis people regarding the same.
55
Sun Shine Technologies
ONLY CONTENTS: is used to remove include and display all the fields in it.
E.g. Under fields, for address, we can use include and give the address under
include. So there you will see only include and you will not find the components
under include but include has a drop down/expand option there. Once you click
on expand, you will see the entire address. And here, if you click on ONLY
CONTENTS, then you will not see the include field but directly you will see the
entire address/components under include.
IMPORTANT: if you make some changes to the key fields here, then it will impact
the data in database. And you will not be able to activate it. In certain cases, you
need to follow below path.
UTILITIES -> DATABASE OBJECTS -> DATABASE UTILITY -> click on activate and
adjust records.Or, you can go to SE14.
56
Sun Shine Technologies
PACKAGE (SE21)
- It is a collection of objects (repository objects). It was also called as
development class (old version).
- SAP defined objects belongs to SAP defined packages.
- User defined objects belongs to either $tmp (or) custom package.
- Custom package can be created by BASIS consultants using package builder.
- $tmp is a default package defined by SAP.
- $tmp stores all the local objects.
- $tmp objects are never transportable.
- Zpackage - Custom packages only can be transportable.
57
Sun Shine Technologies
TRANSPORT ORGANIZER:
Create request (or) change request:
It is generated by the system automatically, based on system internal
sequence number.
It is useful to identify the object.
It records the username, client number, project name, object status,
timestamp.
It is useful in the project management.
- Request number:
<Instance or SID> K <9nnnn>.
Ex: DEVK900504
- Instance is always 3 characters ex: ECC, DEV, QAS, DMO and PRD.
- K – Specifies constant.
- Request number is always begins with 9 maximum it consists of 6 digits.
Note:
Whenever you save in package, it always shows previous request number and
short description so be careful.
58
Sun Shine Technologies
Workbench request:
- System always proposes the list operation concern request number and
description in the dialogue box.
User can perform 3 operations:
a. If we want to save the current object under the same request
number and click on continue.
b. If you want to maintain new request number then click on create
request option.
c. If you want to assign the current object to previous request number
then click on own request then choose the existing request.
Note:
We need to release the Task first and make sure the objects are active.
Then the request is released by leads.
Request – task – package.
In golden client, always ‘keep a copy’.
Procedure:
Place the cursor on task and click on release icon in tool bar (truck symbol).
Place the cursor on request and click on release (generally leads do this).
Version management:
- Object concern changes can be maintained as different versions.
59
Sun Shine Technologies
- Object along with different versions are permanently stored under version
database.
- We can retrieve any version and view is possible.
- We can compare any two versions of the object is also possible.
- For script and smartforms, version management is not possible.
Note:
- There are no versions in the version database default.
- Menu path to create version: utilities menu -> version -> generate version.
- Menu path to view the version: utilities menu -> version -> version
management.
-------------------------------------------------------------------------------------------------------------
-------------------------------- PROGRAMMING --------------------------------
-------------------------------------------------------------------------------------------------------------
60
Sun Shine Technologies
Sample program
1. Go to SE38.
2. Provide the program name starting with Y or Z.
3. Provide short description with some meaningful tittle.
4. Specify the ATTRIBUTE -> TYPE -> EXECUTABLE PROGRAM.
5. Save it as local object.
6. Type some write statement in single quotes (e.g. write ‘PRAVEEN’.)
Save -> check -> activate -> execute.
Output – PRAVEEN
PROGRAM TYPE:
1. TYPE 1 - EXECUTABLE PROGRAM (self-executable program)
2. TYPE I – include program
3. Type M - module pool program
4. Type S – subroutine pool
5. Type F – function pool
6. Type K – class pool
7. Type J – interface pool
8. Type T – type pool
9. Type X – XSLT program (used to convert ABAP program to XML and vice
versa).
ARTHMATIC OPERATION:
61
Sun Shine Technologies
o Addition +
o Subtraction –
o Multiplication *
o General Division /
o Modules mod (provides remainder)
o Division div
o Power **
LOGICAL OPERATORS:
o AND
o OR
o NOT
RELATIONAL OPERATORS:
o EQ =
o NE <> >< (here both are valid)
o GT >
o GE >=
o LT <
o LE <=
o LIKE
o NOT LIKE
o IS INITIAL
o BETWEEN…..AND
BASICS:
Write….. (This is used for output statement)
Write / ‘jai’. (/ - provide new line)
Write / ‘jai’ color 2. (Color 2 – provides colors and the range is from 1 to 7)
Write / 10 ‘jai’. (10 - <col_pos>)
‘Jai’ (Strings are placed with in single quotes)
ULINE. (One complete horizontal line)
ULINE /5(7). (<col_pos>, length)
ULINE AT /5(4).
SKIP. (This keyword/statement is to skip one blank line).
SKIP 2. (SKIP <n> provides number of blank lines.
SKIP TO LINE 15. (SKIP TO LINE <N> : it skips first 15 lines from the top.
62
Sun Shine Technologies
COMMENTS:
- These are used to describe some tables or variables as documentation.
- It increases the readability of source code.
- Single line comment
o Place * in the first column position (*write /’jai’.)
- Multiple write comment
o Select multiple lines press ctrl + < for comment and press ctrl + > to
uncomment.
o Or select the line and right click and comment or uncomment.
- In line comment:
o Within the line partial string can be commented using Double quotes.
KEYWORD’s:
DATA – is used to declare variables, work areas, internal tables.
TYPES – is used to define USER DEFINED (custom) elementary data types,
structure types, internal
Table types.
VARIABLE: e.g. Kunnr is a variable, but its value changes. It is not constant.
CONSTANTS – is used to define constant variable.
FIELD-SYMBOLS – is used to declare field symbols.
WRITE – is used to display output.
2) Select-options:
Select-options are a keyword which accepts single value,
multiple range, multiple single values, single ranges and multiple ranges.
3) Selection-screen.
Selection-screen is also used to design the selection screen
with a frame.
Sy: selection-screen: begin of block <block name> with frame title text-
<no>.
-----.
64
Sun Shine Technologies
-----.
Selection-screen: end of block <block name>.
Text no is a three digit number where we can enter the title for the title
for the text.
65
Sun Shine Technologies
66
Sun Shine Technologies
itab-cname = 'gsr'.
itab-city = 'sec'.
itab-qty = '15.2'.
append itab.
*//display oput
loop at itab.
write: / itab-custno,itab-cname,itab-city,itab-qty.
endloop.
Note:
In the internal table we are storing more than one record so if we want to print all
the records the we will write the WRITE statement in between the
LOOP…………..ENDLOOP.
Nested structures:
Structure with in the another structure is called nested structure
We can declare the nested structure in 3 ways
Way1:
*&---------------------------------------------------------------------*
*& Report ZEBRA7
*&---------------------------------------------------------------------*
67
Sun Shine Technologies
68
Sun Shine Technologies
*//output
write: emp-empno, emp-empname, emp-lc_stuct-stuno, emp-lc_stuct-stuname.
Output:
100 REDDY 20 ram
Way 3:
*&---------------------------------------------------------------------*
*& Report ZEBRA7
*&---------------------------------------------------------------------*
*//output
write: emp-empno, emp-empname, emp-stru1-stuno, emp-stru1-stuname.
Output: 100 REDDY 20 ram
New way to create the structure and internal table:
Bu using TYPES keyword we are declare the structure and the internal table
TYPES: is keyword is used to declare the user define data types
Syntax for creating our own data types:
69
Sun Shine Technologies
70
Sun Shine Technologies
*//declaring types
types : begin of ty_emp,
number(10) type n,
name(10) type c,
street(10) type c,
city(10) type c,
amount(10) type p decimals 2,
end of ty_emp.
71
Sun Shine Technologies
*//desplay output
write : / 'number', 20 'name', 40 'street', 60 'city', 80 'amount'.
uline.
loop at lt_emp into ls_emp.
write : / ls_emp-number, 20 ls_emp-name, 40 ls_emp-street, 60 ls_emp-
city, 75 ls_emp-amount.
endloop.
Output:
Some other way Declare the work area and the internal tables :
Way1:
1.if we want to declare some of the fields from any one of the database tables
Syntax:
DATA : Begin of <work area>,
List of fields,
End of <work are>.
Ex : data : begin of wa_t001,
Bukrs like t001-bukrs,
End of wa_t001.
Declaring the internal table:
Ex : Data : lt_too1 like table of wa_t001.
72
Sun Shine Technologies
Way 2:
If we want to declare the internal table with all the fields of any database table
Syntax for declare the work area:
Data: Begin of <Work area name>.
Include structure <DB table name>.
Data : End of <work area name>.
Ex:
Data : Begin of wa_T001.
Include structure T001.
Data : end of wa_T001.
Syntax for declare the internal :
Data : <Itab> like table of <work area>.
Ex : lt_t001 like table of wa_t001.
Way 3:
Declaring the work area and internal table by referencing the DB table:
Data : wa_T001 type T001.
Data : lt_T001 type table of T001.
(or)
Data: lt_t001 type table of T001.
Data: Wa_T001 like line of lt_T001.
Way 4:
Declaring the work area by using the TABLES keywords
Syntax: TABLES <Table name>.
73
Sun Shine Technologies
Note: By default the TABLES keyword create one work area with the name of
database table name and also contains all the fields of DB table
Ex: TABLES T001.
Internal table and work area by referencing the Global structure :
Syntax for declare the work are by referring global structure :
Data : <Work area name> Type <Global structure name>.
Syntax for declare the internal table by referring global structure :
Data : <Internal table> Type table of <Global structure name>.
Syntax for declare the internal table by referring global table type:
Data : <Internal table> Type <Global Table type>.
Note: while creating the internal table by referring the global internal table no
need to use the TYPE TABLE OF key word
Syntax for declare the work are by referring global table type :
Data : <Work area > like line of <Internal table name>.
Initializing techniques:
1.Clear
2.Refresh
3.Free
Clear:it clears the content of the work area as well as internal table
Syntax: clear <Work area>.
Clear <Itab>.
Note:
in real time we never use CLEAR to clear the content of the internal table. If we
are working with internal table with header line then name of work area as well
74
Sun Shine Technologies
as the name of the internal table are same in this case also CLEAR clears the
content of the work area only.
If we want to clear the content of the internal table then we use [] for internal
table
Syntax: clear Itab[].
Refresh:
Always clears the content of the internal table only
Syntax : Refresh <Itab>.
Free: Act like refresh
Note:
1.Refresh clears the content of the internal table not the memory which is
allocated for that
Whereas FREE clears the content of the internal table as well as memory which is
allocated for that
Syntax: Free <Itab>.
Types of internal table:
There are 3 types of internal tables are there
1.Standard internal table
2.Sorted internal table
3.Hased internal table
Standard internal table:
1.It accept the duplicate records
2.Here all the fields non-unique fields
3.Pushing data from work area to internal table is always through APPEND
keyword
75
Sun Shine Technologies
76
Sun Shine Technologies
Syntax:
Data: <internal table> like/type hashed table of <work area> with unique key
<field1><field2>…….
Collect:
It checks the internal table whether the inserted record is available or not, if not
it act like a insert otherwise it adds the numeric fields from work area to numeric
fields in the internal table
Syntax:
Collect <work area> into table <internal table>.
Syntax: Modify <itab> from <work area> transporting <field name> where
<condition>.
Ex:
MODIFY lt_item FROM wa_item TRANSPORTING itemprice WHERE itemno = wa_it
em-itemno.
78
Sun Shine Technologies
79
Sun Shine Technologies
Itab2[] = itab1[].
Note : if the internal table contains the data then
Syntax : Append <work area> to <Itab>.
Append lines of <itab1> to <itab2>.
Messages:
Tcode for message class is SE91.
We have 5 types of messages:
Sy: message <message type><message no.> (message class).
Message type is the type of message in the five types.
Message no is 3 digits no.
Message class is the collection of message no’s and their short description.
ABEND Messages (A): The system displays this type of message in a dialog
window/box and after the user conforms this message by using enter key then
the system terminates the entire transaction.
Ex: message A000 (zmsg).
Error and warning Message (E & W): The system displays this type of message in
a status bar. Ex: message E/W000 (zmsg).
Information Message (I): The system displays this type of message in a dialog
window. After user conforms by entering enter key then it goes to selection
screen. Ex: message I000 (zmsg).
Success Message(S): The system displays this type of message in the status bar.
Ex: message s000 (zmsg).
Generalized syntax of message:
Message <message type><message no>(message class) with ‘message’.
Open sql:
1.open sql is used to working with the database tables not with the internal tables
80
Sun Shine Technologies
2.Inser, Update, Modify a single record always through the work area and
multiple records through the internal table
3.whenever we are working with the database table then the structure of the
work area and the internal table must be similar through the database table
The open sql statements are
1.select
2.Insert
3.Delete
4.Modify
5.update
Select :
Select is used to retrieve the data from the database table
By using the select query we can retrieve the single record 6 ways
Syntax :
Way1:
Select * from <DB table> into <work area> where <condition>.
Endselect.
*&---------------------------------------------------------------------*
*& Report ZVISHNU_DATA_RETRIEVE
*&---------------------------------------------------------------------*
Note: Zcaddress is the custom table if you double click on the table name the we
can see the table
Example2:
***LAST RECORD******************
**// work area declaration
data : wa_marc type marc.
**// retrieve data from marc table
82
Sun Shine Technologies
83
Sun Shine Technologies
Note: In real time we never use the select…………endselect to retrieve the single
record from the data base table we always used select single to retrieve the single
record
Way3:
Select single * from <DB table> into <work area> where <condition>.
REPORT zvishnu_data_retrieve NO STANDARD PAGE HEADING.
******FIRST RECORD*******************************
*// work area declaration
data : wa_mara type mara.
*// retrieve data from marc table
select single * from mara into wa_mara.
*// display output
write : / wa_mara-matnr, wa_mara-ersda, wa_mara-ernam, wa_mara-mtart.
Output:
Note: if we use the select single then it will display the output immediately after
satisfying the condition
84
Sun Shine Technologies
If we are not use the where condition then it displayed first record as the output
Way4.
Select single <field1><field2>……….<field n> from <DB table> where <condition>.
REPORT zvishnu_data_retrieve NO STANDARD PAGE HEADING.
*************SELECTED FIELDS FROM MARA****************
*// types declaration for marc
types : begin of ty_mara,
matnr type matnr,
ersda type ersda,
ernam type ernam,
end of ty_mara.
Way5.
Select * from <DB table> into <work area> up to N rows where <condition>.
Endselect.
85
Sun Shine Technologies
Way6
Select <field1><field2>……….<field n> from <DB table> up to N rows where
<condition>.
Endselect.
REPORT zvishnu_data_retrieve NO STANDARD PAGE HEADING.
86
Sun Shine Technologies
*//table declaration.
tables : mara.
*//types declaration for mara table.
types : begin of ty_mara,
MATNR type MATNR,
ERSDA type ERSDA,
ERNAM type ERNAM,
LAEDA type LAEDA,
AENAM type AENAM,
87
Sun Shine Technologies
end of ty_mara.
*//internal table declaration.
data : lt_mara type table of ty_mara.
*//work area declaration.
data : wa_mara type ty_mara.
*//selection screen design.
selection-screen : begin of block blk1 with frame title text-100.
select-options : s_matnr for mara-matnr.
selection-screen : end of block blk1.
if s_matnr is not initial.
*//retriving data from mara.
select matnr ersda ernam laeda aenam from mara
into table lt_mara
where matnr in s_matnr.
else.
message 'plz fill selection screen fields' type 'I'.
endif.
*//DISPLAY OUTPUT.
loop at lt_mara into wa_mara.
write : / WA_MARA-MATNR,wa_mara-ersda,wa_mara-ernam,wa_mara-
laeda,wa_mara-aenam.
endloop.
Output:
88
Sun Shine Technologies
89
Sun Shine Technologies
90
Sun Shine Technologies
Endloop.
Example:
*&---------------------------------------------------------------------*
*& Report ZVISHNU_DATA_RETRIEVE
*&---------------------------------------------------------------------*
wa_makt-maktx = 'MESAGE'.
wa_makt-maktg = 'MESSAGE'.
APPEND wa_makt TO lt_makt.
CLEAR wa_makt.
93
Sun Shine Technologies
Sy-bbcnt – is the system field which contains the number of records successfully
processed into the database table
Delete:
delete the data from the database based on the condition
syntax:
Delete from <db table> where <condition>.
Deleing the single record
REPORT zvishnu_data_retrieve NO STANDARD PAGE HEADING.
94
Sun Shine Technologies
else.
WRITE:/ 'delete operation failed'.
endif.
Output: deleted success fully
95
Sun Shine Technologies
Deleted successfully
Deleted all the records from the table:
Syntax:
Delete from <table name>.
Modify:
Modify act like update if there is a match found otherwise it act like insert.
Syntax:
Modify <db table> from <work area>.
Modify <DB table> from table <Itab>.
Commit work: is a abap key word is used for the database not for the internal
table
Commit work is used to immediate database update
*// Tables declaration
TABLES : zitem.
**********************************
*// Retrieve data from ZITEM table
SELECT * FROM zitem
INTO TABLE lt_item
WHERE itemno IN s_itemno.
If Record is exist
96
Sun Shine Technologies
IF sy-subrc EQ 0.
READ TABLE lt_item INTO wa_item WITH KEY itemno = p_itemno.
IF sy-subrc EQ 0.
wa_item-itemname = 'PEARS'.
wa_item-itemprice = 40.
ENDIF.
*// Modify Data
IF wa_item IS NOT INITIAL.
MODIFY zitem FROM wa_item.
IF sy-subrc EQ 0.
COMMIT WORK.
MESSAGE 'Successfully Modified' TYPE 'I'.
EXIT.
ELSE.
MESSAGE 'Modification is Failed' TYPE 'E'.
EXIT.
ENDIF.
ENDIF.
ENDIF.
*******************************************************************
*// Record does not exist
wa_item-itemno = 4.
wa_item-itemname = 'LIRIL'.
wa_item-itemprice = 400.
*// Modify Data
IF wa_item IS NOT INITIAL.
MODIFY zitem FROM wa_item.
IF sy-subrc EQ 0.
COMMIT WORK.
MESSAGE 'Successfully Modified' TYPE 'I'.
EXIT.
ELSE.
MESSAGE 'Modification is Failed' TYPE 'E'.
EXIT.
ENDIF.
ENDIF.
*****************************************************************
97
Sun Shine Technologies
98
Sun Shine Technologies
<field2> = <value2>
Where <condition>.
REPORT zupdate NO STANDARD PAGE HEADING.
*//table declaration
TABLES :zitem.
if sy-subrc eq 0.
ELSE.
WRITE : / 'update fail'.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
endif.
100
Sun Shine Technologies
We always used the for all entries instead of inner join because inner join some
time leads the time out
Note: Inner join is not possible for cluster and pooled tables
whenever we are using the for all entries we must consider the header level
internal table having the data or not
Note: suppose if you not consider header level internal table is having the data or
not if the header level internal table contains no data then it will fetch entire data
from next level database
Example:
Retrieve data from 2 tables (VBAK, VBAP) by using for all entries
REPORT zselect_multiple NO STANDARD PAGE HEADING.
101
Sun Shine Technologies
102
Sun Shine Technologies
103
Sun Shine Technologies
ULINE.
SKIP 1.
Inner joins
Inner joins are used to retrieve the data from multiple tables.
104
Sun Shine Technologies
Whenever we are working with the inner joins then not need to declare the types
for each and every table only declare the final types
Inner join fetch the data based on ON condition first next is based on WHERE
condition.
Retrieve the data from Mara, marc
REPORT zinnerjoin_mara NO STANDARD PAGE HEADING.
TABLES:mara.
105
Sun Shine Technologies
Modularization techniques:
Modularization techniques are used to divided the business processing logic into
reusable block of statements
This is two step processing
1. Define the reusable block
2. Calling the reusable block
In Abap we have 4 modularization techniques
1. Includes
2. Subroutines
3. Function modules
4. Macros
Includes:
Include programs are can’t executed directly (non executable programs). One
include program can be used in any number of programs
Steps to create the include program:
106
Sun Shine Technologies
Click on create. One window will be triggered. Where we can enter the title and
select the TYPE as INCLUDE program. Click on save. Then one window will be
trigger where we can write our code.
After writing the code click on save and activate.
By using INCLUDE key word we can call subroutine into include program
Syntax: INCLUDE <Include name>.
107
Sun Shine Technologies
Click on yes. Enter the title. By default system will select the program type as
INCLUDE program.Click on save.
108
Sun Shine Technologies
Subroutines:
Subroutines are program modules which can be called from ABAP/4 programs.
Frequently used parts of program can be put into subroutines and these
subroutines can be called explicitly from the program.
Defining Subroutines
109
Sun Shine Technologies
110
Sun Shine Technologies
REPORT ZMACRO.
data : begin of wa,
bukrs like t001-bukrs,
butxt like t001-butxt,
ort01 like t001-ort01,
end of wa,
it like table of wa.
define zfill.
wa-bukrs = &1.
wa-butxt = &2.
wa-ort01 = &3.
append wa to it.
end-of-definition.
zfill '1000' 'tcs' 'hyd'.
zfill '2000' 'cts' 'bag'.
111
Sun Shine Technologies
112
Sun Shine Technologies
113
Sun Shine Technologies
Then the function builder window will be open in that window we have we have
seven tabs
Under the attributes tab we have the properties of the particular program
And the import tab we will enter the parameter variables in the import tab we
have parameter name (importing parameter name) and the type is we give type
for work area and associated tab we will give the field data element name and
click on enter and select the pass value (not mandatory) and export tab we give
the export parameter the import and export is used if we retrieve the single
record.
To retrieve multiple fields we use tables
114
Sun Shine Technologies
115
Sun Shine Technologies
*"----------------------------------------------------------------------
116
Sun Shine Technologies
117
Sun Shine Technologies
118
Sun Shine Technologies
After writing source code save and activate the code then we use this function
module any program. if we want to use this program in the SE38
Go to SE38
Enter the program name click on create and save Ur program in ur package
And enter the source code
To call the function module in to Ur program. place the courser where we want
and click on pattern tab on top of the window, and select the CALL FUNCTION
radio button enter the function module name click on enter then it will exported
in to ur program.
119
Sun Shine Technologies
SE38 code
REPORT zmaterial_data NO STANDARD PAGE HEADING MESSAGE-
ID zmymessage.
120
Sun Shine Technologies
3) AT END OF <FIELD>_____ENDAT:
It executes at the end of field values. It provides subtotal for the
field.
4) AT LAST______ENDAT:
It terminates the loop. It is used to provide grand total for the field.
5) SUM:
121
Sun Shine Technologies
6) ON CHANGE OF <FIELD>_______ENDON:
It is alternative for at new. It executes whenever the field value
changes. It can be used in any loop where as at new is used in loop and
Endloop.
*&---------------------------------------------------------------------*
*& Report ZCONTROL
*&---------------------------------------------------------------------*
REPORT ZCONTROL.
DATA v1 like vbap-vbeln.
select-OPTIONS :s_vbeln for v1.
Data : begin of ty,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
netwr like vbap-netwr,
end OF ty,
122
Sun Shine Technologies
123
Sun Shine Technologies
WRITE: / wa1-vbeln,
wa1-posnr,
wa1-matnr,
wa1-netwr.
at END OF vbeln.
sum.
WRITE : /30 'Subtotal',wa1-netwr COLOR 3.
skip 2.
ENDAT.
at LAST.
sum.
write : /30 'Grandtotal', wa1-netwr COLOR 4.
ENDAT.
ENDLOOP.
Classical Reports
Classical report is nothing but to display the entire information in a single list.
Events:
1) Initialization :
Initialization is an event which is triggered before displaying
the selection-screen. This is used to provide the default values
to the selection screen.
Ex: initialization.
S_bukrs-low = ‘1000’.
S_bukrs-high = ‘2000’.
S_bukrs-sign = ‘I’.
S_bukrs –option = ‘BT’.
124
Sun Shine Technologies
Ex: At Selection-screen.
Select Burks
from t001
Into v1 up to
1 rows where
Bukrs in s_bukrs.
Endselect.
If sy-subrc <> 0.
Message e000 (zmsg) with ‘invalid company’.
Endif.
3) At Selection-screen on <field> :
It is an event which is triggered at the selection screen
Based on the given input field.
It is used to validate the given input of the particular
Field.
Ex: At Selection-screen on s_lifnr.
Select lifnr
From
Lfa1
Into v1
Up to 1 rows
Where lifnr in s_lifnr.
Endselect.
If sy-subrc <> 0.
Message e000(zmsg) with ‘invalid vendor’.
Endif.
4) Start-of-selection:
It is an event which is triggered after leaving the selection
Screen and before displaying the output.
125
Sun Shine Technologies
This is used for retiring the data from the data base and
Place in the internal table.
It is the default event in the classical report.
5) Top-of-page :
It is an event which is triggered at the top of the page.
It is used to display the heading for the report.
Ex: top-of-page.
Write: / ‘Company Details’.
6) End-of-page :
It is an event which is triggered at the end of each page.
This is used to display the footer information to the report.
Ex: end-of-page.
Write: / ‘footer details’.
7) End-of-selection :
It is an event which is triggered after fetching the data from
the database.
It is used for displaying the output.
At selection screen on |
End-of-page
Based on the given purchasing document no. to display the document item
details.
*&---------------------------------------------------------------------*
126
Sun Shine Technologies
*&---------------------------------------------------------------------*
Select ebeln
from ekpo
into v1 up to
1 rows where
ebeln in s_ebeln.
Endselect.
If sy-subrc <> 0.
Message e000 (zmsg) with 'invalid po number'.
Endif.
Start-of-selection.
Select ebeln
ebelp
matnr from ekpo
127
Sun Shine Technologies
into table it
where ebeln in s_ebeln.
End-of-selection.
Loop at it into WA.
Write: / wa-ebeln,
wa-ebelp,
wa-matnr.
Endloop.
Top-of-page.
Write: / 'Purchase order Details'.
End-of-page.
Write: / sy-datum.
Interactive Reports:
128
Sun Shine Technologies
1) Sy-lsind:
It is the system variable which contains the current list index no.
2) Sy-lisel:
It is the system variable which contains the contents of
The selected record.
3) Sy-Lilli:
It is the system variable which contains the exact line no.
Of the selected record.
4) Sy-ucomm :
It is the system variable which contains the function
Code of the selected menu item.
5) Sy-linno:
It is the system variable which contains the exact line no.
Of the last record displayed.
Events in Interactive Reports:
1) At line-selection:
It is an event which is triggered at the time of user
Clicks on any record of any list.
2) At User-command:
It is an event which is triggered at the time of user
Clicks on any menu items.
3) Top-of-page during line-selection.
It is an event which is triggered at the top of each secondary list.
4) At Pf <no.> :
It is an event which is triggered at the time of user clicks
On f1 to f12 buttons.
5) Set pf-status :
It is an event which is used to attach our own GUI to the program.
Interactive reports supports the user, interaction is always through double click.
Whenever the user clicks on any record on any list then “at line-selection” event
is triggered and list index is incremented by 1 “Sy-lsind” If we want to generate
the data for this list then we should know the record which is clicked by the user
in the previous list.
129
Sun Shine Technologies
HIDE:
It is the keyword which maintains the copy of the previous list with output
line no’s and their contents. Whenever user clicks on any record of any list then at
line-selection event will be triggered and list index will be incremented by 1 and
that particular record will be transfer from hide area to workarea.
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
REPORT ZHIDE.
end of ty.
end of ty1.
130
Sun Shine Technologies
v1 like ekko-ebeln.
select ebeln
bstyp
bsart
from ekko
into table it
write :/ wa-ebeln,
wa-bstyp,
wa-bsart.
hide : wa-ebeln,
wa-bstyp,
wa-bsart.
endloop.
at LINE-SELECTION.
if sy-lsind = '1'.
select ebeln
131
Sun Shine Technologies
ebelp
matnr
menge
meins
from ekpo
into wa1
endselect.
WRITE :/ wa1-ebeln,
wa1-ebelp,
wa1-matnr,
wa1-menge,
wa1-meins.
* endloop.
endif.
Uline.
GET CURSOR:
132
Sun Shine Technologies
Hide technique generates the next list based on the line selection.
If we want to generate the next list based on the field selection then we go for
“get cursor” technique. Get Cursor technique returns the field name as well as
field value which is selected by the user.
*&---------------------------------------------------------------------*
*& Report ZGETCURSOR
*&---------------------------------------------------------------------*
REPORT ZGETCURSOR.
types : begin of ty_ekko,
ebeln type ekko-ebeln,
bsart type ekko-bsart,
lifnr type ekko-lifnr,
end of ty_ekko,
begin of ty_ekpo,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
matnr type ekpo-matnr,
end of ty_ekpo,
BEGIN OF TY_LFA1,
LIFNR TYPE LFA1-LIFNR,
NAME1 TYPE LFA1-NAME1,
ORT01 TYPE LFA1-ORT01,
END OF TY_LFA1.
v1 like ekko-ebeln.
SELECT ebeln
bsart
lifnr
from ekko
into table
it_ekko where ebeln in s_ebeln.
at LINE-SELECTION.
if sy-lsind = '1'.
if v2 = 'WA_EKKO-EBELN'.
SELECT EBELN
EBELP
MATNR
INTO TABLE IT_EKPO
FROM EKPO
WHERE EBELN = V3.
LOOP AT IT_EKPO INTO WA_EKPO.
WRITE : / WA_EKPO-EBELN,
WA_EKPO-EBELP,
WA_EKPO-MATNR.
ENDLOOP.
134
Sun Shine Technologies
ELSEIF V2 = 'WA_EKKO-LIFNR'.
SELECT LIFNR
NAME1
ORT01
FROM LFA1
INTO TABLE IT_LFA1
WHERE LIFNR = V3.
135
Sun Shine Technologies
Select vbeln
posnr
kwmeng
meins
from vbap into
table it_vbap
where vbeln in s_vbeln.
Loop at it_vbap into wa_vbap.
Write: / wa_vbap-vbeln,
wa_vbap-posnr,
wa_vbap-kwmeng,
wa_vbap-meins.
Endloop.
Set pf-status ‘STATUS’.
AT USER-COMMAND.
If sy-ucomm = ‘DOWNLOAD’.
Call function ‘DOWNLOAD’
exporting
filetype = ‘DAT’
tables
Data_tab = it_vbap.
Endif.
136
Sun Shine Technologies
9) XL sheet
10) Graphics
Slis is a standard type group which contains all types related to alv.
Whenever we are referring any type under any type group then we must
call the type group name in the program.
Type-pool is the keyword which is used to call or include the type group
name in the program.
1) Declare the final Data internal table and implement the Retrieving logics.
2) Prepare the fieldcatalog (about the displayed fields)
3) Display the output using function modules like
Reuse_Alv_Grid_Display:
It is the Function module which is used to
Display the output in a grid format.
Or
Reuse_Alv_List_Display:
It is the Function module which is used to
display the output in a list format.
1) Whenever we are working with all the fields from any one of the database
table, then we no need to prepare fieldcatalog internal table. Here we
simply pass I_structure_name as database table name.
Here the function module picks the column headings from the data
element of each field and also display the output in the similar order of the
fields in the table.
137
Sun Shine Technologies
*&---------------------------------------------------------------------*
*& Report ZALV1
*&---------------------------------------------------------------------*
REPORT ZALV1.
tables kna1.
Data : it type table of kna1.
select * from kna1 into table it.
TABLES
T_OUTTAB = it.
If we want to display in list format then we use first function module and if we
want to display in grid then we use second function module.
138
Sun Shine Technologies
In slis we have one type i.e. ‘slis_t_fieldcat_alv’. This contains all the
fields related to fieldcatlog so we simply declare our fieldcatlog internal
table by referring this type in the program.
REPORT ZALV2.
type-pools : slis.
Types : begin of ty,
kunnr type kna1-kunnr,
name1 type kna1-name1,
ort01 type kna1-ort01,
end of ty.
139
Sun Shine Technologies
V1 LIKE KNA1-KUNNR.
SELECT-OPTIONS : S_KUNNR FOR V1.
SELECT KUNNR
NAME1
ORT01
FROM KNA1
INTO TABLE IT
WHERE KUNNR IN S_KUNNR.
WA_FIELDCAT-COL_POS = '1'.
WA_FIELDCAT-FIELDNAME = 'KUNNR'.
WA_FIELDCAT-SELTEXT_M = 'CUSTOMER NO.'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '2'.
WA_FIELDCAT-FIELDNAME = 'NAME1'.
WA_FIELDCAT-SELTEXT_M = 'NAME OF CUST'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '3'.
WA_FIELDCAT-FIELDNAME = 'ORT01'.
WA_FIELDCAT-SELTEXT_M = 'CITY'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
TABLES
T_OUTTAB = IT.
140
Sun Shine Technologies
*&---------------------------------------------------------------------*
*& Report ZALV3
*&---------------------------------------------------------------------*
REPORT ZALV3.
TYPE-POOLS: SLIS.
SELECT KNA1~KUNNR
KNA1~NAME1
KNA1~ORT01
VBAK~VBELN
VBAK~ERDAT
VBAK~ERNAM
INTO TABLE IT
FROM KNA1 INNER JOIN VBAK
ON KNA1~KUNNR = VBAK~KUNNR
WHERE KNA1~KUNNR IN S_KUNNR.
141
Sun Shine Technologies
Events :
In alv all the events are handled through subroutines only.
Whenever we are working with events then we must declare
an internal table which contains 2 fields like
1) Name : Name of the event
2) Form: Form which handle the event.
Events in alv:
1) Top_of_list :
It is an event which triggers at the top of the displayed
output.
2) Top_of_page :
It is an event which triggers at the top of each page.
3) End_of_page :
It is an event which is triggered at the end of each page.
4) End_of_list :
It is an event which is triggered at the end of displayed
output.
5) User_command :
It is an event which is triggered at the time of user
Clicks on any menu items as well as clicks on any
record of any list.
This event acts like At line-selection, as well as
142
Sun Shine Technologies
*&---------------------------------------------------------------------*
*& Report ZALV3
*&
*&---------------------------------------------------------------------*
REPORT ZALV3.
TYPE-POOLS : SLIS.
SELECT KNA1~KUNNR
KNA1~NAME1
KNA1~ORT01
VBAK~VBELN
VBAK~ERDAT
VBAK~ERNAM
INTO TABLE IT
143
Sun Shine Technologies
WA_EVENT-NAME = 'TOP_OF_PAGE'.
WA_EVENT-FORM = 'ZTOP'.
APPEND WA_EVENT TO IT_EVENT.
CLEAR WA_EVENT.
wa_layout-colwidth_optimize = 'X'.
wa_layout-zebra = 'X'.
FORM ZTOP.
144
Sun Shine Technologies
BLOCKED ALV:
*&---------------------------------------------------------------------*
*& Report ZBLOCK
*&
*&---------------------------------------------------------------------*
145
Sun Shine Technologies
REPORT ZBLOCK.
TYPE-POOLS: SLIS.
Select vbeln
vbtyp
auart
FROM VBAK
INTO TABLE IT1
WHERE VBELN IN S_VBELN.
Select
posnr
matnr
matwa
matkl
from vbap
into table it2
where vbeln in s_vbeln.
146
Sun Shine Technologies
I_STRUCTURE_NAME = 'ZBLOCK1'
CHANGING
CT_FIELDCAT = it_fcat1.
147
Sun Shine Technologies
I_TABNAME = 'IT2'
IT_EVENTS = IT_EVENT2
TABLES
T_OUTTAB = IT2.
HIERARCHAL ALV:
It is used to display the header and item details in a hierarchal
manner.
*&---------------------------------------------------------------------*
*& Report ZHIER
*&---------------------------------------------------------------------*
REPORT ZHIER.
TYPE-POOLS: SLIS.
DATA: V1 LIKE VBAK-VBELN.
SELECT-OPTIONS: S_VBELN FOR V1.
BEGIN OF WA2,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
MATWA LIKE VBAP-MATWA,
MATKL LIKE VBAP-MATKL,
148
Sun Shine Technologies
END OF WA2,
Select vbeln
vbtyp
auart
FROM VBAK
INTO TABLE IT1
WHERE VBELN IN S_VBELN.
Select
VBELN
posnr
matnr
matwa
matkl
from vbap
into table it2
where vbeln in s_vbeln.
WA_FCAT-COL_POS = '1'.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-SELTEXT_M = 'SALES dOC'.
WA_FCAT-TABNAME = 'IT1'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '2'.
WA_FCAT-FIELDNAME = 'VBTYP'.
WA_FCAT-SELTEXT_M = 'DOC TYPE'.
WA_FCAT-TABNAME = 'IT1'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
149
Sun Shine Technologies
WA_FCAT-COL_POS = '3'.
WA_FCAT-FIELDNAME = 'AUART'.
WA_FCAT-SELTEXT_M = 'ORDER TYPE'.
WA_FCAT-TABNAME = 'IT1'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '1'.
WA_FCAT-FIELDNAME = 'POSNR'.
WA_FCAT-SELTEXT_M = 'ITEM NO'.
WA_FCAT-TABNAME = 'IT2'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '2'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-SELTEXT_M = 'MATERIAL'.
WA_FCAT-TABNAME = 'IT2'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '3'.
WA_FCAT-FIELDNAME = 'MATWA'.
WA_FCAT-SELTEXT_M = 'MATERIAL ENTERED'.
WA_FCAT-TABNAME = 'IT2'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '4'.
WA_FCAT-FIELDNAME = 'MATKL'.
WA_FCAT-SELTEXT_M = 'MATERIAL '.
WA_FCAT-TABNAME = 'IT2'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
150
Sun Shine Technologies
WA_KEY-HEADER01 = 'VBELN'.
WA_KEY-ITEM01 = 'VBELN'.
INITIALIZATION.
151
Sun Shine Technologies
START-OF-SELECTION.
*// Retrieve data from EKKO
SELECT ebeln bukrs bstyp bsart
152
Sun Shine Technologies
FROM ekko
INTO TABLE lt_ekko
WHERE ebeln IN s_ebeln.
END-OF-SELECTION.
*// Populating Fieldcatlog Structure
wa_filedcat-col_pos = 1.
wa_filedcat-fieldname = 'EBELN'.
wa_filedcat-outputlen = 10.
wa_filedcat-seltext_m = 'PO Number'.
APPEND wa_filedcat TO lt_fieldcat.
CLEAR wa_filedcat.
wa_filedcat-col_pos = 2.
wa_filedcat-fieldname = 'BUKRS'.
wa_filedcat-outputlen = 15.
wa_filedcat-seltext_m = 'Company Code'.
APPEND wa_filedcat TO lt_fieldcat.
CLEAR wa_filedcat.
wa_filedcat-col_pos = 3.
wa_filedcat-fieldname = 'BSTYP'.
wa_filedcat-outputlen = 25.
wa_filedcat-seltext_m = 'Document Category'.
APPEND wa_filedcat TO lt_fieldcat.
CLEAR wa_filedcat.
wa_filedcat-col_pos = 4.
wa_filedcat-fieldname = 'BSART'.
wa_filedcat-outputlen = 13.
wa_filedcat-seltext_m = 'Document Type'.
APPEND wa_filedcat TO lt_fieldcat.
CLEAR wa_filedcat.
153
Sun Shine Technologies
ENDIF.
*&---------------------------------------------------------------------*
*& Form intaractive
*&---------------------------------------------------------------------
* -->UCOMM text
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM intaractive USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm.
WHEN '&IC1'.
SET PARAMETER ID 'BES' FIELD selfield-value.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "INTARACTIVE
Output:
Click on execute button
154
Sun Shine Technologies
If the user interact with the output list then it call the ME23N transaction code
155
Sun Shine Technologies
Like that we will get the output for both list and grid.
Transaction code creation for Reports
Go to SE93 Tcode
Enter the transaction code
Click on create
Enter the short text
156
Sun Shine Technologies
157
Sun Shine Technologies
158
Sun Shine Technologies
VARIANT
Variant is a place where we can store the selection screen field values.
VARIANT CREATION:
First enter the data in selection screen
159
Sun Shine Technologies
3) Click on display
160
Sun Shine Technologies
Default it displays the some request number . if you want save then click on
continue othervise click on new request number.
161
Sun Shine Technologies
Click on continue.
162
Sun Shine Technologies
Performance Issues
In real time after completion of the program then we can do
1.Extend program check
2.Runtime Analysis
3.Sql trace
Extend program check:
This is used to avoid the unnecessary declarations of the program
Transaction code for the extended program check is SLIN
After completion of program
Go to menu bar
Program -> check -> extend program check
Execute
Double click on error and warnings
Identify the unnecessary declarations
Runtime analysis:
This is used to identify the total executable time of a program and also identify
the tips and tricks
Transaction code for the runtime analysis is SE30
Select the radio button PROGRAM
Provide the program name
Click on execute
Provide the sample input
Execute
Click on back button twice
163
Sun Shine Technologies
164
Sun Shine Technologies
Click on yes(continue)
Click on immediate and save
Note: execute the program in background then we get the output as a pool
request
The Tcode for identify spool request is SP01/sp02
coding standards :
1.Always use the binary search in the read statement
Ex: Read table Itab into work_area with key bukrs = ‘5000’ binary search.
Before writing the above statement we must sort the internal table based on
condition
2. Always use the select single instead of select up to 1 rows
3.We never write the select query without where condition
4.We never write select *
5.we never write the select query with in a select query or with in loop
6.Always avoid the select……….endselect
7.Always avoid loop with in loop
8.We always used the for all entries instead of inner join because inner join some
time leads the time out
Note: Inner join is not possible for cluster and pooled tables
9.whenever we are using the for all entries we must consider the header level
internal table having the data or not
Note: suppose if you not consider header level internal table is having the data or
not if the header level internal table contains no data then it will fetch entire data
from next level database
10.In real time we always use the CASE instead of IF because CASE is faster than
the IF
165
Sun Shine Technologies
ABAP DEBUGGER
It is useful to check the program execution flow behind the screen.
- We can check select statement result, population of internal tables.
- In detail checking is possible.
- It is useful to resolve runtime error.
Menu path:
From any screen:
- System menu -> utilities -> debug abap/screen/system
From ABAP Editor initial screen:
- SE38 -> debugger tab
- Program menu -> execute -> debugger
From ABAP Editor Program Screen:
- Program menu -> test -> debugger
- BREAK-POINT – this system also takes us to debug mode.
- /h - this system is also used to debug the program.
166
Sun Shine Technologies
Before ECC 6 it was called as R/3. And in R/3 there was only one debugger which
was called as CLASSICAL DEBUGGER. But after R/3 that means from ECC we have
2 ways to debugger and they are
1. BREAK-POINT (also known as hard break)
2. /H or Click on the break-point icon (also known as soft break)
167
Sun Shine Technologies
CLASSICAL DEBUGGING:
- Common options available for all the tabs.
- F5 – single step:
It is used to debug program line by line or step by step.
- F6 – execute:
It is used to execute set of statements logically belongs together.
It is used to debug subroutine, function module, method of time.
- F7 – Return:
It is used to return the control back to main program.
- F8 – Run:
It stops debugging, and control transfer to output screen.
WATCHPOINT:
- It is used to create watch point.
- These can be set only in debugging mode.
- Maximum 10 watch points allowed per program.
- Consists of field name, whenever field value changes, system prompts with
message “watch point reached”.
- Watch point may consist of condition, and whenever system meets the
condition, system prompts with message “watch point reached”.
- We can create multiple conditions using OR (or) AND.
- Watch points are very useful when we have a huge record (eg.10, 000
records) and if something is wrong with a particular record then we can use
watchpoint.
FIELD TAB: is used to analyze variable values, work area values and system fields.
TABLE TAB: is used to analyze internal tables. We can append, insert, change and
delete internal table’s entries.
Procedure to change internal table value: place the cursor on value
Using F7 we can switch from one break point to another break point.
STATIC BREAK POINT DYNAMIC BREAK POINT
Can be set by coding, as hard coded Can be set by highlighting the row or
line (place the cursor on any row, click
on stop icon available in the application
tool bar)
168
Sun Shine Technologies
CALL STACK TAB: displays all the active calls as stack in chronological order
(events, modules list)
While debugging on the top left you will find some function keys like F5, F6, F7 &
F8.
1. F5 – step by step execution.
2. F6 – if it is gone into include program and if it’s already checked and if there
are no errors. Then to skip the include with just one button then you can
use this button so that it will not debug the include program again.
3. F7 – (also known as RETURN) - if you have gone inside the include program
and to come out of it then use this button.
4. F8 – (also known as “RUN TO CURSOR”) – It will go to next breakpoint or
click on any line and hit F8, it will go to that line wherever you have clicked
(even if the breakpoint is not set also). And if there are not breakpoints the
program will be directly executed.
New Debugger: Apart from this, there are many more advanced features like find
table, scroll up and down, delete table, search record, drag and drop, go to row,
etc. And we can also change the program/coding while debugging.
Desktop 1,2,3 tabs: displays source code section and analyze section.
Database table
170
Sun Shine Technologies
171
Sun Shine Technologies
172
Sun Shine Technologies
Subscreen area must be placed in normal screen only. Each subscreen can call
only 1 subscreen at a time.
Syntax for calling the subscreen area:
Call subscreen <subscreen area> including sy-repid <screen no.>.
Sy-Repid is a system variable which contains the current program name.
Working with Tabstrip:
Tabstrip is the strip of tabs. Each tab contains 1 subscreen area. Each subscreen
area can call only 1 subscreen at a time. By default tabstrip contains 2 tabs only
and 1 tab is always active.
Syntax for declaring :
Controls <tabstrip name> type tabstrip.
Syntax for activating the Tab:
<tabstrip name>-Activetab = <tabname>.
Working with Validations:
Validations are used to identify the given input field is valid or not.
We can perform the validations always in the PAI of screen.
There are 3 types of validations:
1) System validations
2) Validation at flow logic editor
3) Validation at Abap editor.
System validation:
whenever we are working with date and times then the
system itself verify the date and time format. If it is an invalid
format then it throws an error.
Validation at flow logic editor:
Here the logic is maintained in the flow logic editor only
and also provide the list of possible inputs.
Syntax: field <fieldname> values(<v1>,<v2>,<v3>).
173
Sun Shine Technologies
Layout
Database Driver program
Address Logo
Main
174
Sun Shine Technologies
Footer
Components of layout:
1) Header: Header is used to maintain all page settings and administrative data.
2) Pages: page is the physical area where we can place the windows.
We can’t print the text on the page.
3) Windows: we can’t print the data in this window.
In the script without main window we can’t create the page. In script minimum
one main window and maximum 99 main windows can be created.
4) Page window: In this we provide the coordinates for the window to print on
the layout. We can print the text in this page window.
5) Paragraph format: paragraph formats are used to print the entire paragraph
with same font.
6) Character format: It is used to print the particular text with required font &
style.
7) Documentation: These are used to maintain the document related to form.
Ex: &wa-bukrs&
2) System symbols: system symbols are the system variables
Ex: &date&
3) Standard symbols: Standard symbols are coming from ‘TTDTG’ standard
database table. Ex: &Mr.&
4) Text symbols: These are window specific.
Text symbols are the variables which are defined in page
window. Ex: define &a& = 10.
Creating page: Click on page button on the top of window then one window will
be open then that window we will give the ”page, meaning and next page”
If u want to create the another page then go to menu and click on Edit ----
Create element
176
Sun Shine Technologies
And here give the next page as page2 and click on save and go to page1 and
change the next page as page2.
After creating the pages then we will create the all the windows.
Creating windows:
Click on window tab.
But we used only main and variable window in the real time
If we click on the window tab then the system will generate one main window
automatically .
If u click on the window button on the top of window then it will give like this
177
Sun Shine Technologies
Then if u want to create the new window the go to edit- create element.
Give the window name and meaning like that we can create any number of
windows.
178
Sun Shine Technologies
After placing the window then it will ask left margin , window width , upper
margin , window height
Fill all the requirements .
179
Sun Shine Technologies
In the second page if u change the upper margin and window height then it will
not reflect to other pages.
But if u change the left margin and window width it will reflect the other pages
also.
180
Sun Shine Technologies
Then enter the paragraph name(2 char) like p1 enter the meaning and click on
font button. Then we will select the font family , size, and other options and click
on save
Click on continue like that we can create any number of paragraph formats
Creating character formats:.
Click on character formats button
Give the chr. formats (2chars) like c1 and give the meaning click on font button
and select the font family, size same as paragraph formats
In the script we are creating the paragraph and character formats which are form
dependent.
After creating all the go to the header (Basic Settings) give the first page as page1
and default paragraph name as p1 or p2 or p3.
Click on save and activate.
And go to utilities -printing test then one pop up window will be trigger and
give the output device as “lp01”
181
Sun Shine Technologies
If u click on the text element one window will be occurred like this
Instead of this window some times ms word will be opened on that time go to
menu and click on change editor then this window will be open
182
Sun Shine Technologies
If u click on this button in that window then one popup window will be
open like this
Where we can see our paragraph formats and character formats some other
options select any one option based on your requirement.
183
Sun Shine Technologies
And click on (back button) and click on save and activate then if u want to
see the output
Steps to transfer the data from driver program to layout:
1) Create an executable program and implement the retrieving logic.
2) Access the layout from the driver program by using ‘open_form’ function
module.
3) Transfer the data from driver program to particular page window by using
‘write_form’ function module.
Repeat the same step for each which contains program symbols.
4) Close the form by using ‘close_form’ function module.
Then expand the graphics general graphics then double click on the BMAP
BITMAP IMAGES then on window will be open where we can see name,and 2
radio buttons (1.black and white bitmap 2.color bitmap image) if u want to select
the color image then select the 2nd radio button
184
Sun Shine Technologies
Here we can upload the BMP(Bit map Image) images. First we create the bit map
image on our system and place the cursor in the name and click on import(F5)
button.
Then on popup window will be opened then give the file name (where we will
give the file path in you system), name(name of image), description and select the
image type and click on continue.
185
Sun Shine Technologies
Then the image will be imported and it display some information about image
like this
186
Sun Shine Technologies
Then another window will be opened then go to insert - graphics on menu bar
187
Sun Shine Technologies
188
Sun Shine Technologies
If u click on the execute then one window will be occurred then double click on
the image name
If u double click on the image name then it will be include in you script click on
continur(enter)
189
Sun Shine Technologies
Note: whenever we are working with the .TIFF images then we must convert the
.TIFF to text image by using the RSTXLDMC standard program
Displaying the footer data:
Select the window page button and it will open the page with all windows
Select one window to upload the footer data (like time , date, pagno)
Note: In the real time most of the times we will use the footer window to display
the page numbers (or) sign in last page
Syntax of printing the page numbers:
Page &page& of &sap script-form pages&.
Then we will get page number like this “page 1 of 10”
Then on window will be open where we enter the system fields to generate the
date time and page number dynamically.
Here we give the system fields in between the &
190
Sun Shine Technologies
Enter the system fields and click on back button save and activate.
Uploading customer address vendor address and main window data:
In the script we can’t write the code directly
We write the code in the print program (SE38) and call the script in to print
program by using function module
Script is nothing but print program (SE38) plus form
Under the SE38 program we declare all the types, work area ,internal tables and
selection screen design
Like
Zprint_program:(SE38)
*&---------------------------------------------------------------------*
*& Report ZPRINT_PROGRAM
*&---------------------------------------------------------------------*
REPORT zprint_program.
191
Sun Shine Technologies
192
Sun Shine Technologies
193
Sun Shine Technologies
4.window – window name by default system will give mainas the window name
here we will give your own window name
For each and every window we call the write_form.
3.close_form
Each and every open_form we call corresponding close_form )
CALL FUNCTION 'OPEN_FORM'
EXPORTING
application = 'TX'
device = 'PRINTER'
dialog = 'X'
form = 'ZVISHNU_FORM'
language = sy-langu.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'VENDOR'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'WINDOW4'.
(go to SE71 select the page window button then select the WINDOW4click on
text element
194
Sun Shine Technologies
Then enter the same name that are used in the element parameter in write_form
Here we used /E( Text Element)
Then enter the vendor table(LFA1) field names that in between the &
195
Sun Shine Technologies
Enter the fields in the customer table (KNA1) in between the &
196
Sun Shine Technologies
EXPORTING
ELEMENT = 'MARERIAL'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'.
ENDLOOP.
(go to SE71 select the page window button then select the MAIN windowclick on
text element
Then enter the same name that are used in the element parameter in write_form
Then enter the field names that material table(MARA) in between the &
197
Sun Shine Technologies
198
Sun Shine Technologies
1.we can print continuous text 1.based on the window size we can
print the text
2.we can split the main window into
small windows 2.we can’t split the variable window
3.Without main window we can’t
design the SAP script
3.without a variable window we can
4.Main window is default window in design SAP script
SAP script we can’t design the main
4.we can create the variable windows
window
5.Top and bottom commands only work
in main window 5. .Top and bottom commands not
work in variable window
6.we can provide the text element
name in the main window 6.we no need to maintain/ provide the
text element name in variable window
7.next page = 0 is not possible
7. next page = 0 is possible
8.we can place main windows up to 99
times for page 8.we can place only once the variable
window in page
199
Sun Shine Technologies
Control commands:
Control commands are used to control the displayed output
Control commands always start with /:
Total we have different control commands in scripts
1. Include
200
Sun Shine Technologies
This command is used to include the standard text which is defined in SO10
Tcode.
Creating standard text: - The standard text is client dependent.
Go to SO10 TX code enter the text name and click on create
Then one window will be open like this then enter the data
201
Sun Shine Technologies
Then one window will be open to insert the standard data go to insert->text-
>standard
Then on window will be open in that window enter the text name and click on
continue (enter)
202
Sun Shine Technologies
If u click on the continue button then standard will include in your script
203
Sun Shine Technologies
/:endaddress.
4.protect…………….endprotect
This command is used to print the continuous with out any page breaks
Ex: /:Protect
*Sun Shine Technologies
* Lingampally
* Hyd
/:endprotect.
5.Top……………endtop
This command is used print the header information only on main window
Ex: /:Top
* Pur.doc item quantity
/:endtop.
6.Bottom…………endbottom
This command is used to display the footer information in the main window only
Ex: /:Bottom
* Total is &wa_total&
/:endbottom
7. If……..endif.
It is like ordinary if and endif.
8. Case…………endcase
It is like ordinary case and endcase
9. New-page
204
Sun Shine Technologies
NACE is the standard transaction code which contains all the applications and
their forms and programs.
Whenever we click on print preview then it goes to ‘NACE’ tcode and identify the
application.
Against application it identifies the output types and against the output type it
triggers the driver program and form. Based on the form it will print the output.
STEPS TO CHANGE THE LAYOUT:
1) Identify the standard layout.
2) Copy the standard form to ‘z’ form.
3) Convert the language
4) Change the ‘z’ layout as per client requirement.
5) Place the new layout in the ‘nace’ transaction.
SMARTFORMS
Go to smartforms tx code
207
Sun Shine Technologies
Under the smartforms the system will generate two main tasks
1.global settings
2.page and windows
208
Sun Shine Technologies
Form attributes:
Form attributes contains the two tabs like
1.General attributes
2.Output options
General attributes:
Nothing but properties of that particular form, here we have
209
Sun Shine Technologies
Output options:
Under the output option tab we select the page formats and style
Form interface:
It is the interface between the form and driver program where we can see the
tabs like
Global definition:
Is a place where we can declare all the global data types, it contains 6 tabs
Global data:
210
Sun Shine Technologies
Where we can declare the work area, internal tables and variables.
Types: here we declare the user defined types
Field symbols : under the field symbols tab we can declare the field symbols
Field symbol means is a data type where we can store ant type of data
Initialization : where we can implements the subroutines
Form routines: where we can declare the subroutines
Currency / Quant. Fields : where we declare the currency and quality fields
2.pages and windows:
Under the pages and windows system will generate one page and one window by
default
Page: page we can contain 3 tabs
1.General attributes: here we give the next page
2.output options: here we select the page display either portrait or landscape
211
Sun Shine Technologies
212
Sun Shine Technologies
2.output options: where we need to provide the window size and color for that
particular window
System will generate one page and one main down by default and we will create
another page like this. After creating the second page we will give the next page
in page in page1 as page2.
213
Sun Shine Technologies
After creating the page we will create the windows under the page
We have 4 types of windows
1.Main window
2.Secondary window
3.Copied window
4.Final window .
But in real time we used only main and secondary windows
214
Sun Shine Technologies
Like the u will create any number of windows under one page.
For each and every window we will give the position and size under output
options tab.
After entering the all the windows position by using form painter option we can
see the page layout and we can adjust the windows.
After creating the windows in the page1 no need to create the windows for page2
we simply copy the windows from page1 and past in page2. select which window
215
Sun Shine Technologies
we want and copy from page1 and copy that window and past in page2.intially
page2 we don’t have any windows.
After entering the all the windows position by using form painter option we can
see the page layout and we can adjust the windows.
After creating the windows and we need to create the text in each and every
page.
216
Sun Shine Technologies
Creating style:
Go to smartforms tx code select the style radio button and enter the style name.
Click on create
Then one window will be trigger like this.
217
Sun Shine Technologies
Creating the paragraph formats: right click on paragraph formats and click on
create node
Then one window will trigger where we can enter our paragraph name
click on continue.
One window will trigger where we can enter the description. And give the font
family size style under the font tab
218
Sun Shine Technologies
One window will trigger where we can enter the character formats name.
Like that we can create any character formats . if we want to create character
formats for the bar code then we need to specify the barcode type at standard
settings tab.
219
Sun Shine Technologies
and we go to the
font and select the font style, size and family.
At last we specify the standard paragraph at header data
220
Sun Shine Technologies
Click on save . and click on text tab where we can enter our standard data.
Click on general attributes and enter the company name click on save and
activate .
221
Sun Shine Technologies
Then expand the graphics general graphics then double click on the BMAP
BITMAP IMAGES then on window will be open where we can see name,and 2
radio buttons (1.black and white bitmap 2.color bitmap image) if u want to select
the color image then select the 2nd radio button
Here we can upload the BMP(Bit map Image) images. First we create the bit map
image on our system and place the cursor in the name and click on import(F5)
button.
222
Sun Shine Technologies
Then on popup window will be opened then give the file name (where we will
give the file path in you system), name(name of image), description and select the
image type and click on continue.
Then the image will be imported and it display some information about image
like this
223
Sun Shine Technologies
224
Sun Shine Technologies
Click on execute .
Then the system will generate list of logos that are available select your logo and
double click on it.
225
Sun Shine Technologies
Then on window will be open like this then enter the data
226
Sun Shine Technologies
click on yes
227
Sun Shine Technologies
click on F4.
Then one window will open like this
228
Sun Shine Technologies
Calling text module in to smartform: calling text module select the any text
under window
Select the text type as text module and click on enter the system will ask
click on yes.
Then one window will be open like this
229
Sun Shine Technologies
Under the general attributes give the name and click on enter then the window
like this
Then we will see like this under the system fields we have all the system fields just
select the field and drag and drop.
230
Sun Shine Technologies
231
Sun Shine Technologies
Here under the output parameters we give data storage name(work area (or)
internal table name)
Under the input parameter we give that parameters that are used in where
conditions in select query .
After writing the code we need to define the types declaration for lfa1 under the
global definition
232
Sun Shine Technologies
Select the global definition under global definition we have sex tabs under the
types tab we can declare the types.
Global data:
Where we can declare the variables and work area internal tables
Under the global data we can declare the work area
233
Sun Shine Technologies
In the form interface we declare the lifnr and click on save and activate. And click
on text under that window where we can display the values dynamically.
under global data we have the fields just drag and drop
If u want to apply the style go to output tab give the style name
234
Sun Shine Technologies
236
Sun Shine Technologies
237
Sun Shine Technologies
238
Sun Shine Technologies
239
Sun Shine Technologies
Here we can’t provide the form name directly first we store the form name in
constant variable and give that constant variable name as form name
*// Constants declaration
CONSTANTS con_sform TYPE tdsfname VALUE 'ZVISHNU_SMARTFORMS1'.
This con_sform is given as formname
Here the form name is of the type tdsfname.
If u want to see the type double click on the function module name under the
import parameter we can see the type of form name
Importing parameters we give the function module name we can’t give the
function module name first we store the function module name in local variable
and give the local variable name as the fm_name
*// Local variable declaration
DATA : lv_fname TYPE rs38l_fnam.
The function module is of the type rs38l_fnam.
If u want to see the type of function module double click on function module
name under the export parameters we can see the name
Next we call the function module that are created by the system while executing
the smart forms
240
Sun Shine Technologies
System will give the function module of that particular smart form
Copy the function module name and go to SE38 we call that function module
under SE38
CALL FUNCTION '/1BCDWB/SF00000214'
EXPORTING
i_lifnr = p_lifnr
wa_kna1 = wa_kna1.
tables
gt_ekpo = lt_ekpo.
the local variable tack the function module name at runtime so first we call the
function module by using function module name later we give the local variable
name
CALL FUNCTION lv_fname
EXPORTING
i_lifnr = p_lifnr
wa_kna1 = wa_kna1
tables
gt_ekpo = lt_ekpo.
Click on save and activate the program.
241
Sun Shine Technologies
Click on general attributes tab and go to utilities -> field list on/off
242
Sun Shine Technologies
243
Sun Shine Technologies
Click on details
244
Sun Shine Technologies
245
Sun Shine Technologies
Then select the frame by pressing shift + mouse left click and select the outer
frame to give the frame to outer frame
Like that we create the frames after right click on header create -> line type
One window will open where we need to enter the line type and style
246
Sun Shine Technologies
Like that we select the line type for main area and footer
247
Sun Shine Technologies
Click on save
Under main window we can see like this
248
Sun Shine Technologies
Click on save
After creating all the windows then double click on the table
then we get like this
Go to Data tab
Under the data tab we loop the internal table
249
Sun Shine Technologies
And declare the wa_ekpo under global data under global definition
250
Sun Shine Technologies
251
Sun Shine Technologies
Like that we display the data dynamically in each and every text in the main area.
Displaying the purchase order number:
Right click on window create -> flow logic -> program lines
252
Sun Shine Technologies
253
Sun Shine Technologies
254
Sun Shine Technologies
Select the text under the barcode window (window9) and enter the style name
Go to general attributes
255
Sun Shine Technologies
Under the global data we have lv_ebeln fields drag and drop and select the
character type as C2 14pt bar code
256
Sun Shine Technologies
Click on execute
Then it display list of images that are available
Select one picture and double click on it and select the resolution and output
mode and position click on save and activate then in the output mode we can see
the background picture
257
Sun Shine Technologies
SE38 code:
END OF ty_ekpo.
*// Types declaration for KNA1
TYPES : BEGIN OF ty_kna1,
kunnr TYPE kunnr,
land1 TYPE land1_gp,
name1 TYPE name1_gp,
ort01 TYPE ort01_gp,
pstlz TYPE pstlz,
stras TYPE stras_gp,
telf1 TYPE telf1,
END OF ty_kna1.
*// Internal table declaration
DATA : lt_ekpo TYPE TABLE OF ty_ekpo.
259
Sun Shine Technologies
260
Sun Shine Technologies
261
Sun Shine Technologies
262
Sun Shine Technologies
Click on change
263
Sun Shine Technologies
Click on
Then one window will be trigger where we can enter the
Transm.Medium(Telex), layout module(Function Module name), program(Print
program name), form routine(NEU) , form(smart from name)
Click on save
While saving it ask the transport request number
Here we create the customizing request instead of workbench request
Difference between the script and smart from:
Script Smart form
1.Script is client dependent 1.Smart form is the client independent
2.in script we can’t design the page 2.where as smart form we can design
without main window the page without main window
3.In the script minimum one main 3.whereas in smart form minimum 0
window and maximum 99 main main windows maximum 1 main
windows we can place one page window we can place on one page
4.In script we can creating paragraph 4.whereas in smart form by using smart
and character formats which are from style option we can design the
dependent paragraph and character format which
are program independent
264
Sun Shine Technologies
5.In script for displaying the static text 5. whereas in smart from we can use
we are using standard text option the same options for displaying static
(so10) standard text is client dependent text and in smartform they introduced
text module concept for displaying
static text .text module is the client
6.In script we can’t display the independent
background pictures 6. In smart from we can display the
7. In script we can’t write the code back ground pictures
8.For calling the script into the driver 7.In smart form we can write the code
program we are using the below 8. .For calling the smartform into the
function modules driver we are using the below function
1.open_form module
2.Write_form Ssf_function_module_name
3.Close_form
9.For giving the page breaks in the
script we are using the function 9.In the smart form we have the option
modules like page breaks
10.In script we have 4 types of windows 10.In smart form we have 4 types of
1.Varible window windows
2.Main window 1.Secondary window
3.Constant window 2.main window
4.Graphical window 3.copies window
11.In the script we don’t have the drag 4.final window
and drop options in windows 11.In smart form we can drag and drop
option
The data input data file will come in the form of a flat file which the user save as
file type txt file or prn file from the Microsoft Excel program. An Abaper will
create a program to read the text file and upload into the SAP system.
265
Sun Shine Technologies
BDC TYPES:
There are 3 types
1.Call Transaction Method
2.Session Method
3.Direct Input Method
NOTE: Both the session and call transaction method we call BATCH INPUT method
Where the direct inputs are the standard programs to posted the data in to SAP.
266
Sun Shine Technologies
267
Sun Shine Technologies
BDCMSGCOLL: By using this structure we are populating the error records in BDC
call transaction method
This structure contains
1.TCODE - BDC Transaction code
2.DYNAME - Batch input module name
3.DYNUMB - Batch input screen number
4.MSGTYP- Batch input message type
5.MSGSPRA - Language ID of a message
6.MSGID - Batch input message ID
7.MSGNR - Batch input message number
8.MSGV1 - Variable part of a message
9.MSGV2 - Variable part of a message
10.MSGV3 - Variable part of a message
11.MSGV4 - Variable part of a message
12.ENV - Batch input monitoring activity
13.FLDNAME – Field Name
NOTE: the above 2,3,4,5 steps we are applying at call transaction syntax(6th step)
Syntax: call transaction <TCODE> using <BDCDATA Structure>
MODE <Screen Display Mode>
Update <Update Mode>
Messages into <BDCMSGCOLL Structure >.
1.Recording (Transaction code SHDB)
Recording is a process that is provided by the SAP system to generate the
SAP data structure for batch data communication.
268
Sun Shine Technologies
Step2: Then one popup window will trigger where we can give the recording
name and Tcode
269
Sun Shine Technologies
Click on enter
Then another screen will trigger then enter the fields we want then click on enter
like that we give the field for each and every screen
Then we will get screen like this
270
Sun Shine Technologies
Then one window will trigger where we will give the program name
click on enter
And another window will trigger where we will give the short description and
click on source code then system will create the program
271
Sun Shine Technologies
*&---------------------------------------------------------------------*
*& Report ZVSIHNU_BDC_VENDOR_CREAT
*&---------------------------------------------------------------------*
INITIALIZATION.
272
Sun Shine Technologies
START-OF-SELECTION.
con_path = p_path.
*//Uploading Data from Prsenetation Server
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = con_path
filetype = 'ASC'
TABLES
data_tab = lt_final.
LOOP AT lt_final INTO wa_final.
PERFORM bdc_dynpro USING 'SAPMF02K' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-KTOKK'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'RF02K-BUKRS'
273
Sun Shine Technologies
wa_final-bukrs.
PERFORM bdc_field USING 'RF02K-EKORG'
wa_final-ekorg.
PERFORM bdc_field USING 'RF02K-KTOKK'
wa_final-ktokk.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-LAND1'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-ANRED'
wa_final-anred.
PERFORM bdc_field USING 'LFA1-NAME1'
wa_final-name1.
PERFORM bdc_field USING 'LFA1-SORTL'
wa_final-sortl.
PERFORM bdc_field USING 'LFA1-NAME2'
wa_final-name2.
PERFORM bdc_field USING 'LFA1-STRAS'
wa_final-stras.
PERFORM bdc_field USING 'LFA1-ORT01'
wa_final-ort01.
PERFORM bdc_field USING 'LFA1-PSTLZ'
wa_final-pstlz.
PERFORM bdc_field USING 'LFA1-LAND1'
wa_final-land1.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
274
Sun Shine Technologies
275
Sun Shine Technologies
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO bdcdata.
CLEAR : wa_bdcdata.
ENDFORM. "BDC_DYNPRO
276
Sun Shine Technologies
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO bdcdata.
CLEAR : wa_bdcdata.
ENDFORM. "BDC_FIELD
Call transaction for XK02:
*&---------------------------------------------------------------------*
*& Report ZVISHNU_BDC_UPLOAD
*&
*&---------------------------------------------------------------------*
INITIALIZATION.
277
Sun Shine Technologies
278
Sun Shine Technologies
wa_final-bukrs.
PERFORM bdc_field USING 'RF02K-EKORG'
wa_final-ekorg.
PERFORM bdc_field USING 'RF02K-D0110'
'X'.
PERFORM bdc_field USING 'RF02K-D0120'
'X'.
PERFORM bdc_field USING 'RF02K-D0130'
'X'.
PERFORM bdc_field USING 'RF02K-D0210'
'X'.
PERFORM bdc_field USING 'RF02K-D0310'
'X'.
PERFORM bdc_field USING 'WRF02K-D0320'
'X'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-ANRED'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-ANRED'
wa_final-anred.
PERFORM bdc_field USING 'LFA1-NAME1'
wa_final-name1.
PERFORM bdc_field USING 'LFA1-SORTL'
wa_final-sortl.
PERFORM bdc_field USING 'LFA1-STRAS'
wa_final-stras.
PERFORM bdc_field USING 'LFA1-PFACH'
wa_final-pfach.
PERFORM bdc_field USING 'LFA1-ORT01'
wa_final-ort01.
PERFORM bdc_field USING 'LFA1-PSTLZ'
wa_final-pstlz.
PERFORM bdc_field USING 'LFA1-PSTL2'
wa_final-pstl2.
PERFORM bdc_field USING 'LFA1-LAND1'
279
Sun Shine Technologies
wa_final-land1.
PERFORM bdc_field USING 'LFA1-SPRAS'
wa_final-spras.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-BRSCH'
wa_final-brsch.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=BANK'.
PERFORM bdc_dynpro USING 'SAPLBANK' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BNKA-BANKA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'BNKA-BANKA'
wa_final-banka.
PERFORM bdc_field USING 'BNKA-STRAS'
wa_final-stras.
PERFORM bdc_field USING 'BNKA-ORT01'
wa_final-ort01.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-ZINRT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFB1-AKONT'
280
Sun Shine Technologies
wa_final-akont.
PERFORM bdc_field USING 'LFB1-FDGRV'
wa_final-fdgrv.
PERFORM bdc_field USING 'LFB1-ZINRT'
wa_final-zinrt.
PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFM1-KZAUT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFM1-WAERS'
wa_final-waers.
PERFORM bdc_field USING 'LFM1-INCO1'
wa_final-inco1.
PERFORM bdc_field USING 'LFM1-INCO2'
wa_final-inco2.
PERFORM bdc_field USING 'LFM1-KZAUT'
'X'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-LIFNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
281
Sun Shine Technologies
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
* CLEAR bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO bdcdata.
CLEAR : wa_bdcdata.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
* CLEAR bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
282
Sun Shine Technologies
Session method:
Flat File Itab Session Tcode SAP DB
It is a bdc method which we are using for updating large amount of data into
SAP/R3 database, the data may be the master or transaction data
In the bdc session method while running the program the system will generate
one session which we can see in SM35 Tcode
In the session method the system will capture the error records it maintain the
error records in SM35 Tcode
In the BDC session and call transaction methods we need not do more
validations for the data because the transaction code will track all validations
Session method steps:
1.recording(SHDB)
2.Call the function module BDC_OPEN_GROUP
3.Loop at Itab
4.Subroutines copy from recording
5.call the function module BDC_INSERT
6.endloop
7. Call the function module BDC_CLOSE_GROUP
8.Go to SM35 Tcode and run the session
9.see the error records in SM35 error log.
BDC_OPEN_GROUP:
283
Sun Shine Technologies
BDC_INSERT:
Here we pass 2 parameters
TCODE – transaction code
Dynprotab – BDCDATA
In the session method if we run the SE38 Program then system will generate one
session in SM35 Tcode. Here we have All Screen and No Screen
Session method for XK01:
*&---------------------------------------------------------------------*
*& Report ZVSIHNU_BDC_VENDOR_CREATE
*&---------------------------------------------------------------------*
284
Sun Shine Technologies
START-OF-SELECTION.
con_path = p_path.
*//Uploading Data from Prsenetation Server
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = con_path
filetype = 'ASC'
TABLES
data_tab = lt_final.
285
Sun Shine Technologies
286
Sun Shine Technologies
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-FDGRV'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFB1-AKONT'
wa_final-akont.
PERFORM bdc_field USING 'LFB1-FDGRV'
wa_final-fdgrv.
PERFORM bdc_dynpro USING 'SAPMF02K' '0215'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-ZTERM'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFB1-ZTERM'
wa_final-zterm.
PERFORM bdc_dynpro USING 'SAPMF02K' '0220'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB5-MAHNA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFM1-WAERS'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFM1-WAERS'
wa_final-waers.
PERFORM bdc_dynpro USING 'SAPMF02K' '0320'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RF02K-LIFNR'.
287
Sun Shine Technologies
if sy-subrc eq 0.
write:/10 'SUCCESS'.
ENDIF.
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO bdcdata.
CLEAR : wa_bdcdata.
ENDFORM. "BDC_DYNPRO
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO bdcdata.
288
Sun Shine Technologies
CLEAR : wa_bdcdata.
ENDFORM. "BDC_FIELD
OUTPUT:
Give the file path
Click on execute
In the session method after execute the program the go to SM35 Tcode . in the
SM35 the system will create one session
289
Sun Shine Technologies
Then system will ask which mode we execute the session select any mode and
click on enter
After completion of execution then it will show how many record are updated
successfully if there is any error records then it will displayed all error records in a
log
If we want to see the error records then select the session and click on ANALYSIS
button.
If we click on the analysis button there it will displayed list of all the records then
double click on incorrect record and click on LOG CREATION button where it will
displayed all the error records
Session method for XK02:
*&---------------------------------------------------------------------*
*& Report ZVISHNU_BDC_UPLOAD
*&
*&---------------------------------------------------------------------*
INITIALIZATION.
290
Sun Shine Technologies
291
Sun Shine Technologies
filetype = 'ASC'
has_field_separator = '|'
TABLES
data_tab = lt_final.
292
Sun Shine Technologies
'X'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0110'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-ANRED'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-ANRED'
wa_final-anred.
PERFORM bdc_field USING 'LFA1-NAME1'
wa_final-name1.
PERFORM bdc_field USING 'LFA1-SORTL'
wa_final-sortl.
PERFORM bdc_field USING 'LFA1-STRAS'
wa_final-stras.
PERFORM bdc_field USING 'LFA1-PFACH'
wa_final-pfach.
PERFORM bdc_field USING 'LFA1-ORT01'
wa_final-ort01.
PERFORM bdc_field USING 'LFA1-PSTLZ'
wa_final-pstlz.
PERFORM bdc_field USING 'LFA1-PSTL2'
wa_final-pstl2.
PERFORM bdc_field USING 'LFA1-LAND1'
wa_final-land1.
PERFORM bdc_field USING 'LFA1-SPRAS'
wa_final-spras.
PERFORM bdc_dynpro USING 'SAPMF02K' '0120'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFA1-KUNNR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFA1-BRSCH'
wa_final-brsch.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
293
Sun Shine Technologies
'=BANK'.
PERFORM bdc_dynpro USING 'SAPLBANK' '0100'.
PERFORM bdc_field USING 'BDC_CURSOR'
'BNKA-BANKA'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_field USING 'BNKA-BANKA'
wa_final-banka.
PERFORM bdc_field USING 'BNKA-STRAS'
wa_final-stras.
PERFORM bdc_field USING 'BNKA-ORT01'
wa_final-ort01.
PERFORM bdc_dynpro USING 'SAPMF02K' '0130'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFBK-BANKS(01)'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ENTR'.
PERFORM bdc_dynpro USING 'SAPMF02K' '0210'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFB1-ZINRT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFB1-AKONT'
wa_final-akont.
PERFORM bdc_field USING 'LFB1-FDGRV'
wa_final-fdgrv.
PERFORM bdc_field USING 'LFB1-ZINRT'
wa_final-zinrt.
PERFORM bdc_dynpro USING 'SAPMF02K' '0310'.
PERFORM bdc_field USING 'BDC_CURSOR'
'LFM1-KZAUT'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'LFM1-WAERS'
wa_final-waers.
PERFORM bdc_field USING 'LFM1-INCO1'
wa_final-inco1.
294
Sun Shine Technologies
*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
* CLEAR bdcdata.
wa_bdcdata-program = program.
wa_bdcdata-dynpro = dynpro.
wa_bdcdata-dynbegin = 'X'.
APPEND wa_bdcdata TO bdcdata.
CLEAR : wa_bdcdata.
ENDFORM. "BDC_DYNPRO
295
Sun Shine Technologies
*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
* CLEAR bdcdata.
wa_bdcdata-fnam = fnam.
wa_bdcdata-fval = fval.
APPEND wa_bdcdata TO bdcdata.
CLEAR : wa_bdcdata.
ENDFORM. "BDC_FIELD
296
Sun Shine Technologies
LSMW
Legacy System Migration Workbench
Tcode: Lsmw
Step-by-Step Guide for using LSMW to Update Customer Master Records
297
Sun Shine Technologies
298
Sun Shine Technologies
Default
Values
Field Names
299
Sun Shine Technologies
300
Sun Shine Technologies
Save your changes. When you go back to the initial screen, you will see that the
initial screen steps have changed. Since you want to import data via the BDC
method, the Direct Input and IDoc-related steps are hidden, as they are not
relevant.
301
Sun Shine Technologies
Note that your input file will have four fields as key fields and you need to update
three fields in the system.
302
Sun Shine Technologies
Field RF02D-D0310 represents that you chose ‘Sales view’ for the customer
Master screen accordingly its value should be set to X. Keep your cursor on field
RF02D-D0310 and click on Constant rule icon to choose the constant value of ‘X’.
If your source file already has the field value, you choose rule ‘Source Field’.
Keep cursor on field ‘KUNNR’ and click on ‘Assign Source field’ icon to choose
source field CUSTOMER from structure XD02S as shown in Figure 11.
Similarly, assign ‘Source Field’ rules to the remaining fields. Once all the fields are
mapped, you should have an overview screen as shown in Figure 12.
303
Sun Shine Technologies
304
Sun Shine Technologies
305
Sun Shine Technologies
306
Sun Shine Technologies
Note! Browsing thru these 14 steps, you may get a feeling that this is a very
lengthy and time-consuming activity. However, for the purposes of
307
Sun Shine Technologies
Demo Example 2
308
Sun Shine Technologies
Even though you don’t want to update any fields in these structures, you need to
create a relationship with source structures. In all, you need to create relationship
for four target structures.
Create relationship between source structures XD02S with these target structures
with icon ‘Create Relationship’ .
Keep Cursor on these four target structures and click on icon ‘Create Relation’ and
structure relations are maintained as shown in Figure 22.
309
Sun Shine Technologies
-- Keep your cursor on ‘TCODE’ field and click on ‘Insert Rule’ icon
310
Sun Shine Technologies
Choose source field ‘Customer’ from source structure ‘XD02S’. (See Figure 24.)
311
Sun Shine Technologies
-- Similarly, choose source fields for Sales Organization, Distribution Channel, and
Division. (See Figure 25.)
312
Sun Shine Technologies
313
Sun Shine Technologies
Earlier, creating this input file, so that the standard interface program can read it,
was a big nightmare, the primary reason being that it could have multiple record
layouts. Even for a simple conversion with one input record, you would have to
create this complex file with many record layouts. The advantage of LSMW is that
it prepares these multi-layout files automatically.
314
Sun Shine Technologies
1. Personalisation :
Transaction variants are created to personalize any standard SAP transaction. A
transaction variant simplifies the usage of a transaction by tailoring some of the
features as per the business need. It can be used to hide fields, menu functions,
screens, to supply individual fields with default values or to change the ready for
input status of one or more fields.
This document describes the step by step process to create a transaction variant
for standard SAP transaction CO01 - create production order. The transaction
variant should have the following restriction:
There are two steps, first create the transaction variant and then attach the
transaction variant to a transaction.
315
Sun Shine Technologies
3. In the "Confirm Screen Entries" pop-up screen we can customize the fields.
Enter the screen variant name (say YCO01_0100) and short text (Test screen
variant) here. Also for the field "Order type" check the Invisible checkbox to hide
316
Sun Shine Technologies
4. To deactivate some of the menu function click the button "Menu functions". A
pop-up screen will appear. In the pop-up select the menu item "Order-> Create
317
Sun Shine Technologies
318
Sun Shine Technologies
5. The menu item will be deactivated (it will be highlighted in yellow). Click
"Enter" to come back to the original screen entries pop-up.
6. Click "Exit and Save" button to save the Transaction variant. System will pop-up
for a transport request. We can save it as a local transport or save it in some
transport request.
319
Sun Shine Technologies
7. We can test the transaction variant by clicking the "Test" button in the initial
screen.
320
Sun Shine Technologies
2. In the next pop-up screen enter the short text, select the radio button variant
transaction and click enter.
3. In the next screen enter the transaction (CO01) and transaction variant (YCO01)
created in the previous step. Click the "save" button to save the variant
321
Sun Shine Technologies
transaction.
The variant transaction (YCO01_TCODE) is now ready and it can be used to get the
tailored version of the original production order creation (CO01) transaction code.
322
Sun Shine Technologies
Result:
Initial Screen: Field "Order type" is not visible
323
Sun Shine Technologies
2.Enhancement,Modification
Enhancements are the means by which we add our own/ modify existing
functionality to SAP's standard business applications.
If you try to modify any SAP standard program, it will ask you for access key which
you can get from SAP market place by requesting SAP.
But enhancements normally don’t require any special access key and can be
implemented directly
EXITS:
Adding the new functionality to the existing object
They are two types of exits are there
1.User Exit
2.Customer Exit
USER EXITS: For Implementing the user exit we need the access key.
CUSTOMER EXIT:
1. By using the customer exit we can add new functionality to the exiting
object
2. For customer exit first we need to find out the exit name. we get the exit
name in ‘SMOD’ Tcode and find out what type of enhancement is possible.
3. After getting the exit we need to go ‘CMOD’ Tcode where we need to
create the project and assigning the enhancement to the project and
implement it.
We can do enhancements in 4 ways.
1.Function Exit
2.Screen Exit
3.Menu Exit
4. Table Exit
Steps :
324
Sun Shine Technologies
Then one window will be trigger then double click on the program name
325
Sun Shine Technologies
Go to menu bar
Go to -> attributes
326
Sun Shine Technologies
Then one window will be trigger where we can see the package name
What are the ways we can find out the user exit:
1.If you know the Tcode then find the package for that Tcode
327
Sun Shine Technologies
328
Sun Shine Technologies
click on Ctrl+F
Then one window will be trigger where we can enter the package name
Click on execute
Where we can see the Exit name
329
Sun Shine Technologies
3. Go to SE84
Select the enhancement and enter the package name
Click on execute
Where we can see the Exit name
330
Sun Shine Technologies
331
Sun Shine Technologies
Click on Ctrl + F
Enter the package name
Click on create
Then it will display the list of user exits
Find your exit based on the description
Copy the exit name
And go to SMOD Tcode initial screen
Enter the exit name and click on display
332
Sun Shine Technologies
333
Sun Shine Technologies
334
Sun Shine Technologies
Double click and click on enter on the include name at the same time
Note: While double click on the include program if the include program is not
implemented then we are getting some warring message where we need to pass
the enter button
Then system will ask do you want to create
Click on yes
Then it will ask the package name
Enter the package name and click on save
Then one window will open like this
335
Sun Shine Technologies
Where we can develop your code and click on save and activate
And click on back button activate the function module
Click on back button twice then we come to SMOD initial screen
Assigning enhancement to the project:
Go to CMOD Tcode
Enter the project name
Click on create
Enter the short text
336
Sun Shine Technologies
Click on save
Click on enhancement assignment button
Add the enhancement name and press enter
Note:
When we deactivate the project?
337
Sun Shine Technologies
For example 6 months back some one as implemented some exit for ME21N
Tcode for adding new validations then now client is come back he asked us to
remove those validations then we are following the below steps
Go to CMOD Tcode
Enter the project name
Click on deactivate button
Then transport the new transport request number to the another system
TEXT ENHANCEMENT:
FIELD ENHANCMENT:
CHANGING THE FIELD LABEL:
- Change F1 help documentation of any field.
Go to mm01.
Place the cursor on material and press F1.
click on technical information (4th option)
Notice the data element (matnr).
- Goto cmod
- Go to MENU – text enhancmenent – keywords – change
- Provide data element as matnr – continue – change field label and save.
- Create request.
- Provide description.
- Continue
- Note-here again data element will come – just close the dialog box and
check after 2-3 minutes.
Note:
Dialogue screen uses long text (field label).
TEXT ENHANCMENET
Go to mm01.
Place the cursor on material and press F1.
Click on technical information (4th option)
Notice the data element (matnr).
Go to CMOD – GOTO menu - > text enhancement - > data element-> new de cust
338
Sun Shine Technologies
Enhancement Framework
Adding new functionality to the exiting object without editing exiting code
Steps to implement the enhancement sport
Go to Tcode
EX: go to VA01
Go to menu bar
System -> status
339
Sun Shine Technologies
341
Sun Shine Technologies
……………………..
Endenhancement.
In this between enhancement and endenhancement we are going to write the
logic for the functionality.
Path from SAP Easy Access -> Tools – abap workbench – utilities – BAdis and
customer exits.
BAdi Enhancement:
- BAdi’s are defined using BAdi builder.
- BAdi builder is closely integrated with ABAP Workbench.
- BAdi’s are used to add custom business functionality to standard SAP
(without changing SAP).
- BAdi supports:
o Program enhancement, menu enhancement, screen enhancement
but it does not support text enhancement. (text means field
enhancement)
o For program, menu and screen enhancement – SAP permission is
required.
- T.code: SE18 – SAP defined BAdi list (to define BAdi)
- T.code – SE19 - to implement BAdi.
BAdi – types:
1. Classic BAdi (doesn’t have enhancement spot)
2. Kernal-based BAdi (new BAdi – have enhancement spot)
ATTRIBUTES (tab):
Consists of package, username, data, language, name of Add-in class)
- BAdi’s are again divided into:
o Multiple Use BAdi’s:
343
Sun Shine Technologies
INTERFACE (tab):
- Consists of interface name, and its possible methods.
- In general interface name begins with IF_EX_<BAdi name>.
F.Codes (tab):
- It consists of Menu enhancement concern FCT Codes.
SUBSCREEN (tab):
- It consists of Screen enhancement concern calling program name, screen
number, subscreen area.
DOCUMENTATION (tab):
- It provides in detail functionality of BAdi and implementation procedure.
BAdi interface
Methods M1, M2
C1 C2
Interface : IF Interface: IF
Search Criteria:
- Standard procedure - T.code wise searching:
o Execute T.code.
o System menu -> status -> double click on program -> goto menu ->
attribute -> notice the package name.
- Go to T.code SE18, search for BAdi using Package.
- In SE18 – information system tab -
o Application and component wise searching: (search in SE18).
o Enhancement spot wise searching:
o Short description wise searching:
- T.code SPRO – click on saP reference IMG – CTRL+F - searching with
keyword - BADI.
o
o Click on execute
Implementation name and short text
It will take you to
- SE84 – search for repository information system
o enhancements – definition –
- Search with string ‘cl_exithandler=>get_instance (BAdi’s are defined here)
o VA01 – find - Find/replace – 1st option –
cl_exithandler=>get_instance - Double click on instance – double
click on interface – this interface is BAdi interface.
- Go to SE81 – search in the application hierarchy.
345
Sun Shine Technologies
Naming conventioons:
Interface name: zif_ex_<BAdi_name>.
Implementation class: zcl_im_<BAdi_implementation>.
Add in class: cl_ex_
Built in service class: cl_exithandler
- This service class is used to create instance for reference variable.
Once the BAdi interface is defined and activated, it generates three classes.
1. Adopter class
2. Service class
3. Implement class
ADOPTER CLASS:
- It performs two activities.
o Control
It calls and controls all the implementations.
o Filter:
It implemets using filter type condition.
SERVICE CLASS:
- It is default which is automatically created for all BAdi’s.
- It is used while creating instance.
o Cl_exithandler=>get_instance
346
Sun Shine Technologies
NAMING CONVENTIONS:
Interface name begins with: if_ex_<BAdi_definition>
Implementation class name begins with ZCL_IM_<BAdi_implementation>
IMPLEMENTATION: (imagine you found the right BAdi then to implement it.
SE18 enhancment – open in display mode.
Notice:
- the enhancement spot
- Attributes tab:
o Multiple use check box:
Single implementation (if checkbox is not checked
Multiple implementation (if check box is checked – multiple
users message will come)
o Filter checkbox:
If this checkbox is check then it is filter dependant badi.
This can be implemented using filter type.
- Interface tab:
o It provides interface name and possible methods.
- FCodes tab:
o Provides menu enhancement
- Subsccreen tab: provides screen enhancement.
- Documentation push button:
o Provides functionality of enhancement and implementation
procedure.
347
Sun Shine Technologies
Zinterface
o M1, M2.
BAdi name and spot name can be same or can be different.
Spot name can be same for more than one BAdi also.
PROCEDURE:
Step1:
- Se18 – enhancement spot – zen_spot – create (without creating the enh.
Spot we cannot create BAdi).
- Short des – enhancement spot creation
- Technology comes by default.
- Composite enhancement spot – leave it blank - continue – save as local
object.
o Notice there are no spots, you can create, delete, etc
- Click on create BAdi – name – zBAdi_def1.
- Short description – defining custom BAdi – continue.
o BAdi definition is created, by default it is multiple use BAdi.
- Expand BAdi - Double click on interface.
o On right side – provide interface name - yif_ex_BAdi_def1 – hit enter
– create – yes.
o Save as package.
o This will take you to class builder.
o Under methods - Create methods - create two methods – M1 and M2
with level - instance (don’t double click on methods).
o save - Activate interface – come back – activate enhancement spot –
come back.
- SE18 is over.
- Under enchancement menu - create - to go to SE19 directly.
- Under create imp.
- New BAdi – zen_spot – create imp.
- Enh. Imp – zen_spot_implementation.
- Short text – enhamcement implementation – continue – save as loca
object.
- Under BAdi implementation – provide the implementation name -
zBAdi_impl– continue.
o Interface are implemented under class – so creating class is the next
step.
348
Sun Shine Technologies
349
Sun Shine Technologies
---------3rd method
Class cl_exithandler definition load. (cl_exithandler is called as service class)
Data iref type ref to zif_ex_BAdi_def.
Start of selection.
Call method iref – c_exithandler – get_instance.
Exporting
Chanign
Instance= iref
Call method
CROSS APPLICATIONS
Cross application deals with data transfer techniques.
- We can send or receive data between SAP to SAP.
- In enterprise, data can be maintained in central server or distributed
servers.
- If data is maintained centrally,
o Adv:
Access to complete data is possible
o DIS-ADV:
Maintaining large amount of data.
We can’t upgrade individual modules from one version to
another.
- If data is maintained in several servers:
o Adv:
Easy maintenance
We can upgrade independent servers
o Limitations of distributed systems:
Servers are places geographically in different places.
Online updating is not possible.
Data transfer: data can be sent or received from SAP to SAP. (2 way
communication)
SAP r/3 <-> SAP r/3
DBMS:
1. ORDBMS:
- Data available centrally and all modules are connected to that central
server.
o Advantage:
Any module can access any data.
o Disadvantage:
Upgrade cannot happen just for one module, all the modules
needs to be updated.
351
Sun Shine Technologies
If server crashes then entire data is lost for all the modules.
2. DDBMS:
- Database is distributed for different countries.
o advantage:
easy maintainence
If updagrade happens then it will not affect the other
countries.
If india server crashers then it will not affect other countries.
In distributed environment:
- Data is available in several systems or servers.
- There is requirement data transfer between servers.
- Cross application technologies provides data transfer technologies
o R.F.C – remote function call
o IDoc – intermediate document
o EDI – electronic data interchange
o ALE – application link enabled
o BAPI – business application programming interface
o WORKFLOW
DATA TRANSFER:
ABAP CROSS APPLICATION (C.A) Replacement of C.A.
DATA MIGRATION DATA TRANSFER SAP NETWEAVER XI, (EAI
BDC, LSMW, BAPI RFC, IDOC, ALE, EDI, BAPI tool)
352
Sun Shine Technologies
NOTES:
- Internal system – within one desktop/laptop.
- External system – two different systems.
- Gateway servers provide connection between two external servers.
R.F.C:
- In general RFC can be configured by BASIS consultant.
- RFC destination name can be alpha numeric and upper case.
- connection type:
2- connecting to r/2 system
3- connecting to r/3 system
- We have to specify IP address (or) host name, system number
- Gateway server and host details required if we are connecting to external
server.
o Gateway server is responsible to connect external server).
- We have to specify partner system client.
o Username, password, language, details…etc.
- Save RFC connection:
o Connection test tab is used to check the connection.
o While checking connection system may lead to two types of errors.
Communication failure: if IP address, system number is wrong.
System failure: if client number, username details are
- SAP system uses R.F.C, TCP/IP, CPI-C protocols, while exchanging data.
o TCP/IP: Transmission control protocol and internet protocol
o CPI-C: common programming interface/communication
- R.F.C uses Gateway Server Details.
o Gateway server provides gateway service.
o Gateway service is used to establish connection between two
external servers.
Types of R.F.C:
- tR.F.C – transactional R.F.C
353
Sun Shine Technologies
STEP-BY-STEP PROCEDURE:
- Go to SM59 (from 800 client)
- Place the cursor on ABAP Connection – click on Create.
R.F.C Destination - RFCALL810 (should me in capital letters.
Connection type – 3 (automatically pops-up)
And hit enter twice.
Description 1 – RFC destination creation
Under technical settings tab,
o load balance – NO (when source system is connection to external
system can the system hold the load – BASIS people will
decide this)
o Target host - (system – status – host name – in the bottom, if you
click on other kernel info tab in the bottom – you can see IP
address)
o System number – 01 (under SAP logon screen – right click on the
server name – properties – instance number.
o Under save as – (just click on IP Address or follow the above
procedure for IP Address)
o Gateway host – (provide this if we are connecting to external server)
o Gateway service – (provide this if we are connecting to external
server)
Logon & Security tab
o Trusted system – Yes (this will take you to SAP easy access screen)
and (if you click on logon screen then it will take you to the initial
screen where you need to enter userid and password).
o Logon
Language – EN
Client – 810
User – SAPUSER
PW status –
354
Sun Shine Technologies
Password –
o Unicode test
Click on connection test tab – system displays the time taken to
establish the connection to the partner system/target system.
Time is displayed in the micro seconds.
Sometimes it leads to system failure or communication failure.
For communication failure – it can IP wrong, system failure – in
the targer system 810 must exists and user must exist.
o Save – continue – click on connection test (push button on
application tool bar) – come back.
Click on remote logon:
- SAP easy access screen will come automatically.
SQL Trace:
Go to ST05
Select RFC trace
Click on Activate trace
Come to SM59
- Special options tab consists of RFC trace.
o If this check box is activated, system displays the trace list while
establishing connection.
o Using ST05 – Rfc trace – trace can be captured and displayed.
Click on connection test or remote logon
Come back to ST05 – deactivate trace
Click on Display Trace – continue
355
Sun Shine Technologies
Under attributes tab – remote enabled Data: it_kna1 type table of kna1.
function module creation. Wa_kna1 type kna1.
Tables tab – it like kna1. *---calling remote enabled function
Source code – data: wa type kna1. module---
Select * from kna1 into table it up to 10 Call function zrefmodule destination
rows order by kunnr. ‘RFCALL810’. (destination – will display
810 clients information)
*----display output
Loop at it_kna1 into wa_kna1.
Write:/ wa_kna1-kunnr,
Endloop.
Note:
In RFC – if you don’t mention ‘destination’, then output will be of 800’s client and
if you mention destination with 810 clients name then 810 clients information will
be displayed.
Non-SAP to SAP – data migration – BDC or LSMW or BAPI (cut and paste)
SAP to SAP – data transfer – copy and paste – ALE, EDI, BAPI, workflow, RFC
(connection) IDOC.
RFC is maintained by Basis people.
SCC4 – to check all the servers in our own system.
Call function <> destination <rfc destination name>
Bapi_companycode_getlist – it gives list of company codes – 165 company codes
are available
- Se37 – bapi_companycode_getlist – display – rfc target sys –rfc810 – then it
will display 6 company codes available in 810 client.
--------------------------------------------------------------------&--------------------------------------
------------------------
Creating user in 810 client: (If you are not able to login to 810 client then follow
this procedure).
811
SAP*
06071992 (SAP launch date)
Hit enter
Su01 (to create user)
User – SAPUSER
356
Sun Shine Technologies
Note:
SAP_ALL – for accessing all screens, tables, etc.
SAP_NEW – for creating new screens, new tables, etc.
357
Sun Shine Technologies
DATA ELEMENT:
- It describes the field related semantic and technical properties.
While IDoc transfer at every milestone, IDoc generates status codes and status
messages.
If the status code is 01 to 50 then error happened at outbound process.
If the status code is 51 to 75 then error happened at inbound process.
- Every IDoc must be added with message type.
- Message type specifies the type of information/data used in IDoc.
358
Sun Shine Technologies
IDoc Types:
o Basic IDoc: it is built from the scratch. (it does not exist)
o Extended IDoc: It is extension to Basic IDoc. (adding addional
segments/fields to exising IDoc)
359
Sun Shine Technologies
NOTE:
All the segments must be released before releasing the IDoc.
Once the IDoc is released then modifications are not allowed.
IDoc type is message type.
------------------------------------------------------------------&----------------------------------------
------------------------
CUSTOM IDoc CREATION:
Step 1: Create segment
WE31 – Segment creation
Step 2: IDoc creation
WE30 – IDoc creation
Step 3: message creation
WE81 – Logical message creation
WE82 – Assign logical message to IDoc
WE31 – Release segment
WE30 – Release IDoc
Business Scenario:
Creating custom material IDoc.
360
Sun Shine Technologies
Save – person responsible – don’t make any changes – continue – save as package
– own request.
You will notice segment definition automatically updated with transport request –
but not yet released.
361
Sun Shine Technologies
Save
Come back.
It will contain some warnings.
Go to Development menu -> object -> check – you will observe all the information
messages.
362
Sun Shine Technologies
Note:
documentation can be saved on desktop also.
WE60 and WE61 both are same but WE61 gives more information compared to
WE60.
-----------------------------------------------------------------&-----------------------------------------
------------------------
STANDARD IDoc CREATION:
WE31 – click on F4.
Click on any standard IDoc. (standard IDoc begins with E1)
Open in display mode. (you can view any IDoc from here)
WE30 – click on F4.
(IDoc can be created, changed, deleted)
e.g: open cremas – notice all the segments and fields in it.
Debmas –
------------------------------------------------------------------&----------------------------------------
------------------------
Extended IDoc’s:
- It is used to add additional fields to existing/basic IDoc (without changing
standard IDoc).
- It is also called as IDoc extension or IDoc Enhancement.
- Adding additional fields can be added to standard IDoc by adding additional
segments.
Business scenario:
Extending DEBMAS06 IDoc.
Pre-requisities:
Go towe31 z1kna1_segment
Short des
Kunnr – kunnr –
Land1 - land1
Name1 – name1
Save as package
Short description
363
Sun Shine Technologies
Edit- release
Segment is ready
We30
Debamas06
Link to basic type – debmas06 – continue
Notice by default Debmas fields.
Now adding additional fields.
Place the curson on E1kna11 – click on create segment.
Information message – continue
Segm. Type z1kna1_sgement
1
99
Continue
Save as package.
Notice additional fields are added to e1kna11.
Save under package.
Short description.
------------------------------------------------------------------&----------------------------------------
------------------------
CREATING IDoc Enhancement – (Adding additional functionality to SAP Standard
IDoc)
It can be done in two ways:
o Adding custom segmen
o Using customer enhancement (IDoc programming)
Pre-requisite:
Go to WE31 – create custom segment with required additional fields.
WE30
Zext_debmas
Select extenstion.
Create
364
Sun Shine Technologies
------------------
IDoc also can be enhanced using customer exit or BAdi.
--------------------------------------------------------------------&--------------------------------------
------------------------
IDoc REDUCTION (also known as reduced IDoc)
- It is also called as reduced IDoc (It is exactly opposite to enhancement).
- Using this scenario, we can deactivate the unwanted fields/segments while
data transfer.
- We can deactivate standard IDoc concern complete segment or segment
concern few fields.
o As a result while processing IDoc, system does not read the
deactivated segment or field values from the source system.
- T.code BD53 to deactivate.
o Specify reduced message type name – zdebmas06 – click on create.
365
Sun Shine Technologies
EDI
Electronic data interchange
- It is an old technology used for data transfer.
- It is common technology used by ERP application.
- It is not SAP proprietary technology.
- It is also called as paperless technology.
- EDI supports to exchange data between:
o NON-SAP -> NON-SAP
o NON-SAP -> SAP
o SAP -> NON-SAP
o SAP -> SAP
- It is mainly used for SAP -> NON-SAP communication.
- SAP implemented companies also uses EDI to exchange data between
international business partners.
NOTE - FYI:
- Very less implementations of EDI.
- Costly to implement EDI.
- Even the partner should have EDI.
366
Sun Shine Technologies
NOTE:
- Edi subsystem and EDI document process happens in OS level.
EDI Subsystem:
367
Sun Shine Technologies
VAN:
- Value added network.
- It is used in EDI Process.
- It is a mail box, which maintains all the EDI documents as a stack and it
sends the document to respective recipient.
PROCESS CODE:
- SAP defined processed codes are of two types:
o outbound and inbound process codes
- Every process code consists of one function module.
o Using function module, it updates data to target system.
- Process code is used to update data to target database.
Message control:
- It is mechanism used by ALE to transfer transaction data.
- MC specifies application type, message type, output type, process code,
time of data transfer, medium of data transfer.
Output type:
- It specifies type of output printer (hard copy), fax, mail, ALE, EDI.
368
Sun Shine Technologies
Note:
O/S -> D.B -> SAP
o/s can be C drive, D drive.
d.b -> database.
Every IDoc identified by unique number.
CONFIGURATION STEPS:
Steps 1 – defining port
- WE21 – used for port creation – defining - edipartner.
- We21 – place the cursor in FILE and click on create.
- Provide port name (need not start with Y or Z)
o Description (need not start with Y or Z)
- IDoc release 4.x.
Check - Unicode format
Outbound file (tab):
Logical directory – alias name – (not the actual name but alias name, ( desktop
short cut ))
Physical – accurate path - c/user/desktop/file.doc
Select logical/physical directory.
Function module – select one from the drop down (hit F4) –
edit_path_create_username (select the required one)
command file – outfile
Click on outbound trigger (tab):
- RFC destination – server_exec (hit F4 and select the required one)
- Directory - xxxxxxxouttrig
Click on inbound file (tab):
Other things automatically popsup.
Inbound file – infile.
Click on status file (tab).
- Directory – status
- Enter function module name
- Status file – in file.
Save.
369
Sun Shine Technologies
EDI partner profiles (inbound and outbound) are maintained in EDPP1 database
table.
EDP13 is another transparent table maintaining outbound partner profile details.
EDP21 is another transparent table maintaining inbound partner profile details.
370
Sun Shine Technologies
ALE:
- It supports following scenarios:
o To distribute master data
o To distribute transaction data
o Distribute only changes (change pointers)
o IDoc extension (extended IDoc)
o IDoc reduction (reduced IDoc)
o IDoc filter
o IDoc conversion
o IDoc serialization
ALE EDI
It is mainly used to exchange data It is used to exchange data between
371
Sun Shine Technologies
EDI:
1. Data stored in files.
2. Uses TCP/IP connections.
3. Uses EDI subsystems to transfer data.
DISTRIBUTION MODEL:
- It specifies which data is transferring across system.
- It consists of model view.
o Model view specifies sender name, receiver name and message type.
- Using BD64 we can create custom distribution model.
MODEL VIEW:
- It specifies sender, receiver and message type information.
- We can add message type or business object to model view.
- Model view can be added to message type or Bapi.
- Its name can be MVIEW or MODEL VIEW.
- We have to configure both system, must use common model view.
- It is called as ALE service layer.
372
Sun Shine Technologies
MASTER IDoc:
- It is temporary IDoc which holds the data temporarily.
- It is generated by outbound process.
COMMUNICATION IDoc:
- It is permanent IDoc, which stores/maintains data permanently.
- It is generated immediately after master IDoc.
- It carries data from one system to another system.
- It initiates inbound process.
MESSAGE CONTROL:
- It is the mechanism used to transfer transaction data using ALE.
- It specifies application type, message type, medium, time of data
distribution.
373
Sun Shine Technologies
Source system database -> sending system (Outbound system), master idoc, ALE
service layer (distribution model) - Communication idoc -> (till here it comes
under outbound process) ->
Receiving system -> filter (conversion) (version change) -> posting module
program -> transaction screen -> targer system database – till here it comes under
inbound process.
PROCESS FLOW:
374
Sun Shine Technologies
800 810
1 - Go to t.code – SALE 2 - Go to t.code – SALE
-Define logical system (LS800) -Define logical system (LS810)
-Assign logical system to client (LS800- -Assign logical system to client (LS810-
>800) >810)
-Create RFC destination (LS810) -Create RFC destination (LS800)
3 - WE21 – define port 4 - WE21 – define port
5 - WE20 – partner profile creation 6 - WE20 – partner profile creation
7 - BD64 – distribution model 8 - BD64 – distribution model
- Model view creation - Model view creation
- Add message type to M.view - Add message type to M.view
- Generate partner profile - Generate partner profile
9 - BD10 - send material master data 12 - BD11 – get material master data
BD12 – send customer master data BD13 – get customer master data
BD14 – send vendor master data BD15 – get vendor master data
BD16 – send cost center master data BD17 – get cost center master
10 - WE05 – check IDoc status and data
collect IDoc number 13-WE05 – check IDoc status and
11 - WE19 – test tool for outbound collect IDoc
process (or) test IDoc status by entering number
375
Sun Shine Technologies
IDoc number. (this is optional step) 14-WE19 – enter IDoc number and
execute posting module program
15-Check the target system data t.code
level and table level.
376
Sun Shine Technologies
- t.code – sale
- follow the above procedure
Under 800
WE21 – transaction rfc
Create generate Port name
Descritiop -
Rfc destination- Ale810 and hit enter and you will see
Save and after saving it comes to ********list
Under 810
Create generate Port name
Descritiop - receiver port creation
Rfc destination- Ale810 and hit enter and you will see
Save and after saving it comes to ********list
WE20 - 800
Keep the cursor on US - Click on create
Partner no – partner1
Partner type - US
Post.process
- Typ: us
- SAPuser
- En
o Save it.it comes under partner list
- Click on Create outbound parameter.
o Partner role – $1
o Message type – Debmas
o Reciver port – a0000000015
o Collect idocs
o Basic type Debmas
o Package size – 100
o Save – data is saved – come back
Click on create inbound parameters.
- Partner role – ls
- Messag etype Debmas
- Process code –debm
377
Sun Shine Technologies
- Trigger immediately
- Save it
------Partner details are ready in 800-------
WE20 – 810
Partner tye ls – click on create
Partner no ale800
Partner type ls
Typ us
Agent SAPuser
Land en
Save
It come sunder type ls
Click on create outbound parameter
Role ls
Messag etype debmas
Receiver port a00000002
Output mode – collect idoc
Basic type debmas – latest one
Package size – 1000
Save
BD64 – 800
- Click on change mode
- Click on create model view
o Short text
o Technical name – alemodelview – it will add at the bottom
- Select our model view and click on add message type
o Model view – alemodelview
o Sender – LS800
o Receiver – LS810
o Message – Debmas
o Continue
- Now expand our alemodelview – to check
- Save
- Go to Environment menu – generate partner profile –
- Model view – alemodelview
378
Sun Shine Technologies
BD64 – 810
Change mode
Create model view
Short text – modelview creation
Technical name – alemodelview (same as in 800)
Continue
Select our m.view and click on Add message type
Ale810
Ale8000
Debmas
Save
Environment – generate partner profile
Partyen system – ale800
Ty us
Id SAPuser
---follow above procedure
If you see in green color then it is correct, here you should not get any error
message.
----tilll here consultant work is over---- remainitn steops are for the urser.
379
Sun Shine Technologies
you will receive 2 information message with the status. (if it mentions 1 then it is
correct if 0 then wrong)
To check go to WE05 800
Partner number as LS810 - execute
Collect the IDoc no
- Click on control rec – F2 - it should be in green color
- Status record – F2 – you will notice IDoc generated.
Go to we19
Specify the existing - collected idoc no and execute.
Place the cursor on segment.
Click on standard outbound - continue – information message with status.
810
Bd13 customer 2000 to 2001
- Message type Debmas
- Execute.
- Information message.
We05 – partner number as LS800 – execute
- Under selected IDocs – you will notice traffic lights in red color.
- Copy the IDoc number and go to WE19
- Execute
- Place the cursor on segemtn and click on inbound function module.
o Select the function module - idoc_input_debitor (hit F4)
o In foreground
Continue
- Information message – continue.
- Continue, continue, continue.
- Information message
- Go to SE16 under KNA1 – enter
- Now go to XD02 and check if updated or not.
Note:
TRFC used by ale
File used by port
If you receive any error then double click on status.
380
Sun Shine Technologies
BAPI
Business application programming interface:
- It is used to distribute data with third party.
- It is a good interface which provides non-SAP to SAP/vice-versa
communication.
- Bapi’s are widely used in SAP.
MATERIAL BUS1001
PURCHASE ORDER BUS2012
382
Sun Shine Technologies
BAPI
Se38 – title – executable –save as local.
*----declaration
Paratmeters p_sdocno like vbak-vbeln.
Data return_status type bapireturn. (observe associated types, go to fm under
exporting)
Data it_statusinfo type bapisdstat (go to fm under tables)
BAPI STRUCTURES:
- SAP defined Bapi structures are available in ABAP dictionary.
- All BAPI structure names begin with BAPI.
- BAPI structures are used while creating BAPI FM.
- BAPI structures are used while Data migration (non-SAP to SAP).
- Go to SE11 – data type – bapi* - F4 – search for structures – delete number
of hits.
- There are two special BAPI structures:
o BAPIRETURN – it provides return status of any operation.
o BAPIRET2 – it provides in detail status of any BAPI operation.
- Go to SE11 - bapireturn
383
Sun Shine Technologies
BAPI – enhancements:
384
Sun Shine Technologies
385