You are on page 1of 170

31/05/2010

ABAP TUTORIAL
SAP (Systems Applications and Products in Data Processing)

Production
Purchasing
Ware house
FI/CO

Manufacturing
Company

Shipping
HR
Sales &
Distribution

ERP:Enterprise
Big Company

Resource
Money
Men
Machine
Material
Marketing

Some Non ERP: VB/JAVA Front end


ORACLE Back end

Some ERP Products: BAAN

Planning
Well utilization of resources

RAMCO
PEOPLE SOFT
ORACLE APPS
SAP
ERP: It provides predefined tables.
It provides predefined application programs.
No need to creating & maintaining tables.
No need to write the programs for fetches the data from database.
BAAN:Nearly 90% of database tables & source code are related to customers &
vendors, so it is suitable for small size & mid size companies.
E.g.: Vijaya Electronics.

RAMCO:Nearly 80% of database tables & source code are related to the
finance. Hence it is suitable for financial companies. So, it is also suitable for small
size and mid size companies.
E.g.: Any automobile company.

People soft:This is good for HR department but weak in relationship with other
departments (like Production, Purchasing, Warehouse, FI/CO, Shipping, Sales
and Distribution).

ORACLE APPS:This is good for Finance department but weak in integration


with other departments (like Production, Purchasing, Warehouse, Shipping, HR,
Sales and Distribution).

SAP:SAP is good for all modules but weak in FI/CO and HR departments
when compared with PEOPLE SOFT and ORACLE APPS.
Enterprise Portal: - It is used for integrating with one module to another module.
SAP can integrate with People Soft and Oracle Apps and so on.

ADVANTAGES OF SAP: It is tightly (or) closely integrated across all the modules (or) departments.
SAP is platform independent irrespective of all Operating System
(Windows, Linux, UNIX etc...)

SAP is developed in multi languages as well as multicurrencies.It is


used to communicate with international customers and vendors.

SAP is a ready made product, which is developed in 1972 with five IBM
employees in Germany. Customization is done within a minimum effort.

SAP contains Cross Applications, so that exchange the data from one
system to another system.

CROSS APPLICATION (CA): ALE (Application Link Enabling) is an SAP technology to support cross
application.
ALE uses Idoc to support the transformation.

Note:
Before coming the ALE, SAP uses the EDI (Electronic Data
Interchange).
Idoc is Intermediate Document to carry the data.

SAP
System
Idoc

SAP
System

Idoc
Idoc
XI

Non SAP
System

Xml

TIBCO
Middleware Converters

XI - Exchange Infrastructure. It is the SAP Enterprise Application Integration


(EAI).
TIBCO The information bus company.

INTRODUCTION

01/06/10

ABAP: Advanced Business Application Programming Language.


It is a 4th generation language.
ABAP is not a case sensitive.
Based on this language they developed remaining modules (MM, SD,
FI).
ABAP is not a syntax language; it is a business oriented language.
Source code of an ABAP consists of statements as well as comment.
A statement is a combination of Operators, Operands, and Variables &
Keywords.

In ABAP we have 3 types of operators. They are:


1.
2.
3.

Mathematical Operators.
Comparative Operators.
Relational & Logical Operators.

Mathematical Operators:Operator
+
-

Description
Addition
Subtraction

Example
2+3=5
3-2=1

*
**
/
Mod (%)

Multiplication
Exponential
Division
Remainder

2*3=6
2**3=2^3=8
4/2=2
3%2=1

Comparative Operators:Operator
< Or LT
<= Or LE

Description
Less than
Less than or
Equal to
> Or GT
Greater than
>= Or GE
Greater than or
Equal to
= Or EQ
Equal to
<> Or NE
Not equal
Relational & Logical Operators:Operator
AND
OR
NOT

Description
and
or
not

Example
a < b or a LT b
a <= b or a LE b
a > b or a GT b
a >= b or a GE b
a = b or a EQ b
a<>b or a NE b
Example
a<b and a<c
a<b or a<c

Operands:Operands are the variables which we need to perform particular


operation.
C=a+b
Operands
Variable:Variable is the name given to memory location.
Keywords:Keywords are used to identify the type of statements.
Keywords are (C^2 D^3 E O)
1. Calling Keywords.
2. Controlling Keywords.
3. Definition Keywords.
4. Declarative Keywords.
5. Database Keywords.
6. Event Keywords.
7. Operational Keywords.

Declarative Keywords are used to declare the variable.


Some of them are DATA, PARAMETERS, TABLES and TYPES.
Comments:Comments are non executable statements. These are used to
improve the readability of the program.

If you want to comment the entire line then we place * at the first
Column of the line.
E.g.: * Addition of two numbers.

If you want to comment the part of the line then we use .


E.g.: c = a + b Logic
Data types:There are two types of Data types. They are:
1. Numeric Data types.
2. Character Data types.
Numeric Data types
Integer I
Float F
Packed decimal P

Character Data types


Char C (Alpha numeric)
Numeric Char N
Dates D
Times T
Here I, F, Date (D), Time (T) are fixed length Data types & P, N & D
are variable length data type.
Syntax of Integer I:DATA <variable name> Type I
E.g.: DATA A Type I
The initial value of integer is 0.
Syntax of Float F:DATA <variable name> Type F
E.g.: DATA A Type F
The initial value of float is 0.00.

Syntax of Packed decimal P:-

DATA <variable name> (<length>) Type P decimals (no of 0s)


E.g.: DATA A (5) Type P decimals 3.
The initial value of packed decimal is after . Num of decimals.
0.000
Syntax of Char C:DATA <variable name> (<length>) Type C
E.g.: DATA A (5) Type C
The initial value of char is space/empty.
Syntax of Numeric Char N:DATA <variable name> (<length>) Type N
E.g.: DATA A (3) Type N
The initial value of numeric char is 000 (based on length).
Syntax of Dates D:DATA <variable name> Type D
E.g.: DATA A Type D
The initial value of date is 00000000.
The initial format is YYYYMMDD.
Syntax of Time T:DATA <variable name> Type T
E.g.: DATA A Type T
The initial value of date is 000000.
The initial format is HHMMSS.
In c:
Int a, b, c;
a=10;
b=20;
c=a+b;
Printf (%d, c);

In ABAP:
DATA A Type I.
DATA B Type I.
DATA C Type I.
A=10.
B=20.
C=A+B.
Write C.

DATA: A Type I,
B Type I,
C Type I.
A=10.
B=20.
C=A+B.
Write:Total is, C.

NOTE:In ABAP each statement ends with dot ..


Write is the operational keyword, used to display the output.
3. If more than one variable having a same keyword instead of maintaining
the same keyword we use chain operator : & variables are separated by
,.
4. We must leave single space between each operator & operand.
Technical Requirements to create a program: Name of the program
In ABAP name of the program always starts with Y &
Z, because A to X are reserved for SAP.
Provide place/folder where we save the program.
The place/folder is called Development Class up to 4.6 versions.
Now it is called as Package.

Steps to create the program:

02/06/10

Execute SE38 (ABAP Editor).


Provide program name starts with Y or Z.
E.g.: YSAI_7:30pm_ADDITION
Click on create
Provide title type is executable i.e., we can execute the program without
depends on any other program.
Click on save (enter).
Click on local object (it means our program will be saved on $TMP
Development Class or Package which is created by SAP.
Steps to Execute the program:

Save the program (ctrl+s).


Check the program (ctrl+F2).
Activate the program (ctrl+F3).
Test the program (F8).
Back (F3).

NOTE:Parameter is the keyword which accepts the value/input from the


keyboard at the runtime.

In C
Int a, b, c;
Scanf (%d, %d, &a, &b);
C=a+b;
Printf (%d, c);

in ABAP
Parameter: A Type I,
B Type I.
DATA C Type I.
C = A + B.
Write C.

NOTE:1. The name of the parameter should not exceed 8 character length.
2. The parameter cannot accept data type F.
3. DEFAULT is the keyword which is used to assign the default values to the
parameter variables.
Syntax:Parameter <variable name> Type <DT> default <value>.
E.g.: parameter A Type I default 10. ( is your wish for integers).
4. OBLIGATORY is the keyword which is used to provide the input field as
mandatory field.
Syntax:Parameter <variable name> Type <DT> obligatory.
E.g.: parameter A Type I obligatory.
Structure of an ABAP program:-

Header
Declarations
Business Logic
Definition of Reusable Blocks

Header:- (only in real time)


***************************************************
* Program
: ZVEN_730PM_ADDITION
*
* Author
: VENKATESH
*
* Purpose
: Addition of two numbers
*
* Start date
: 02/06/10
*
* Finish date
: 02/06/10
*
* Modified by
:
*
* Modified date
:
*
* Copied from
: NA (not applicable)
*
* Supplier
: TVS Technologies
*
* Package
:
*
* Request number
:
*
***************************************************
Declarations:Declarations
Variables
*. DATA is the keyword to
variables.
Syntax: DATA <vn> Type <DT>
E.g.: Data A Type I
*.with in the program the
of variable can change.

Constants
*. CONSTANTS is the declare
Keyword to declare the Variables.
Syntax:Constants <vn> Type <DT>value<value>
E.g.: Constants A Type I value 10.
*.constants variables values never value
Change with in the program.

Business Logic:In ABAP business logic is retrieving/to get the data from a
database & display it in a predefined format.
Reusable Blocks:<procedure/functions>
Common terminology
SQL: Structured Query Language.

<subroutines>
In ABAP

SQL
DDL
(Data Definition Lang)
It is used to create the
table as well as alter
the tables.

DML
(Data manipulation Lang)
1. Insert
2. Update
3. Modify
4. Delete

DCL
(Data Control Lang)
1.Commit work
2.Rollback work

SQL is the database dependent where as SAP is the database independent. So


that, SQL does not support SAP.
Open sql support SAP, because open sql is database independent.
Open sql does not support DDL, so that we cant create tables with simple
statements like oracle.
Open sql supports DDIC (Data Dictionary) which is used to create the tables as
well as alter the tables in SAP.
DDIC:03/06/10
Data Dictionary is the central source of the database management
system.
The main functionality of the data dictionary is to create the tables as
well as altering the tables.
There are two ways of creating the tables by using DDIC. They are :
1. Direct method/Built in method/Predefined method.
2. Data element method.
Technical requirements to create the table:1. Name of the table: In ABAP the name of the table must be starts with Y or Z
because A to X are reserved for SAP.
2. Provide the list of fields, data types & length.
3. Provide delivery class: Delivery class defines the owner of the table, as well as
controls the transport of the data from one table to another.
4. Provide the technical settings.
Technical settings are:
1. Data class.
2. Size category.
Data Class:It defines the physical area of the database in which our table is
logically stored. Some of the important data classes are
1. APPL0 Master data class.
2. APPL1 Transactional data class.

3. APPL2 Organizational data class.


Master Data class:Master data is the data in which the data is accessed
frequently & updated rarely.
E.g.: Vendor master data.
Customer master data.
Material master data.
Transactional Data class:Transactional data is the data in which the data is
accessed frequently & updated frequently.
E.g.: Purchase order data.
Sales order data.
Organizational Data class:Organizational data is created when the system is
implemented.
E.g.: Company data
Plant data
There are some more data classes like
USER
USER1
these are reserved for
USER2
custom developments.
Size Category:Size category determines the probable space required for the
table.
Steps to create the table by using Direct method or Predefined type:

E.g.:

Execute SE11 (DDIC).


Make sure select the radio button database table.
Provide table name.
Click on create.
Provide short description.
Provide delivery class A.
Select the table maintenance allowed.
Click on fields tab click on predefined type.
Provide the field names, data type, length & short description.
Field name

Data type

Length

Short description

E_ID
E_Name
E_Add

char
char
char

10
25
35

Employee Id.
Employee name.
Employee address.

NOTE: Each table must have atleast one field as a primary field that should be the
character data type & that should be first field in the table.
Save the table. (Ctrl + s).
Check the table (ctrl + F3).
Click on technical settings
1. Provide data class (APPL0, APPL1 ).
2. Select the size category (0).
3. Save the technical settings.
4. Come back.
Activate the table.
Steps to provide the data to the table:

In the menu bar click on utilities table contents create entries.


E_ID
1
E_Name SPRAO
E_Add Sanath nagar.
Save back.

Steps to display the data: In the menu bar utilities table contents display.
Click on execute (F8).
NOTE:1. If you want to provide the data to the table manually then we must
select table maintenance allowed.
2. We can provide up to 16 primary keys per a table.
Field
E_ID

Key Data element

Data type
char

Length
10

Short description

Domain
Data element
Domain:-

Domain is the combination of data type & length.


Data Element:It is the combination of domain & short description.
Creation of a table by using data element type:-

04/06/10

There are two types for creating tables.

Place the data element in


the table

Place the data


element

Create the data


element

Create the data


element

Create the domain

Create the domain

Bottom-up Approach
Bottom-up Approach:-

Top-down Approach
Eid

Ename

Eadd

YSPRAO_730_EMP
Field name
Eid

Domain
C
10

Data element
YSPRAO_730_Eid
Employee id

YSPRAO_730_Eid YYSPRAO_730_EMP
Ename

C
25

YSPRAO_730_Ename
Employee name

YSPRAO_730_Ename YYSPRAO_730_Ename
C
35

YSPRAO_730_Eadd
Employee address

Eadd
YSPRAO_730_Eadd

YYSPRAO_730_Eadd

Steps to create Domain: Execute SE11.


Select the radio button domain.
Provide your domain name (YSPRAO_730_Eid).
Click on create.
Provide any short description (domain).
Provide data type & length.
Save the domain.
Check the domain.
Activate the domain.
Repeat the same steps to all the domains.
Steps to create Data element: Execute SE11.
Select the radio button data type.
Provide your data element name (YYSPRAO_730_Eid).
Click on create enter.
Provide any short meaningful description (id of the emp).
Provide domain name which is already created enter.
Save the data element.
Check the data element.
Activate the data element.
Repeat the same procedure for all the data elements.
Steps to create the table by using data element type:- (Bottom-up approach)
Execute SE11.
Select the radio button database table.
Provide your table name (YSPRAO_730_Emp1).
Click on create enter.
Provide any short meaningful description (Emp table by using bottom-up
approach).
Provide delivery class (a).
Select the maintenance allowed.
Click on the fields tab.
Provide the field names, data elements.
Save the table.
Check the table.

Click on technical settings.


Provide data class & size category.
Save the technical settings.
Come back.
Activate the table.

Steps to create the Emp table by using Top-down approach data type
element: Execute SE11.
Select the radio button database table.
Provide your table name (YSPRAO_730_Emp1).
Click on create enter.
Provide any short meaningful description (Emp table by using Top-down
approach).
Provide delivery class (a).
Select the maintenance allowed.
Click on the fields tab.
Provide the field name (Eid) & data element name which is not there
(ZZSPRAO_730_Eid).]
Double click on the data element save before editing yes local object
cerate the data element yes.
Provide a meaningful description.
Provide domain name which is not created (ZSPRAO_730_Eid).
Double click on domain save before editing yes local object yes.
Provide a short description, data type & length.
Eid
ZZSPRAO_730_Eid
Data element ZZSPRAO_730_Eid
Short description Employee id
Domain ZSPRAO_730-Eid
Domain
Short description
Data type Char
Length
10

Save the domain.


Check the domain.
Activate the domain.
Come back.

Save the data element.


Check the data element.
Activate the data element.
Come back.
Repeat the same for all the fields.

NOTE:1. In the real time always create the table by using data element type,
because if we want to establish the relationship between any two
tables we need common domain name in both the tables.
2. In the Direct/built-in type there is no domain concept.
Foreign Key Relationship:-

05/06/10
Foreign key is a field in one table i.e., connected
with another table via, foreign key relationship. The purpose is to validate the data
being entered in one table (foreign key table) by checking against list of possible
values in another table i.e., check table.

Check table

Eid

Ename

1.
2.
3.
4.

Sai
Raj
Tej
Ram

Eid

Esal

Foreign key table

Technical requirements to establish the primary & foreign key relationship: The domain name of the both the fields in both the tables must be the same.
The check table field must be the primary field.
Steps to establish the Foreign key relationship: Execute SE11.
Select the radio button database table.
Provide your foreign key table name.
Click on change mode.
Select the field (for which field we want to establish foreign key
relationship).
Click on foreign key icon.
Provide your check table name.
Click on generate proposal.
Enter.
Save the table.
Check the table.

Activate the table.


Some of the standard database tables:1. T001 Company code table.
2. KNA1 Customer master table.
3. LFA1 Vendor master table.
4. MARA Material master table.
Some of the fields in T001:1. BUKRS Company code.
2. BUTXT Company name.
3. ORT01 City of the company.
4. LAND1 Country.
5. SPRAS Language.
Some of the fields in KNA1:1. KUNNR Customer number.
2. NAME1 Name of the customer.
3. ORT01 City of the company.
4. LAND1 Country.
5. SPRAS Language.
Some of the fields in LFA1:1. LIFNR Vendor number.
2. NAME1 Name of the vendor.
3. ORT01 City.
4. LAND1 Country.
5. SPRAS Language.
Working with reference fields: When ever we are working with amount field then we must provide
reference as Currency field.
When ever we are working with quantity field then we must provide
reference as Unit field.
Field name
Data type
Amount
CURR
Currency
CUKY
Quantity
QUAN
Units
UNIT fields:Steps to establish the link to the reference

Select the quantity or amount field.


Click on currency/quantity fields tab.
Provide your reference field name & reference table.

NOTE:1. T006 is the standard database table which contains all the unit of
measurement (UOM).
2. TCURC is the standard database table which contains all the
currencies.
3. If you want to display the particular filed information click on
contents in the menu bar settings format list choose fields
select your required fields enter execute.
INTERNAL TABLES

07/06/10

Internal tables are collection of records.


Internal tables are temporary tables, i.e., the data in the internal table will not
save any where in the sap.
Internal tables are dynamic memory allocation, i.e., we need not to provide
size of the internal table.
The scope of the internal table is up to that program.
Placing the data in to the internal table or reading the data from the internal
table is always record by record i.e., through work area.
Syntax of declaring the internal table:DATA <Internal table name> like table of <Work area name>.
Syntax of accessing fields from work area:<Wok area name>-<field name>.
NOTE:APPEND is the keyword to transfer the data from work area to internal
table.

Program:Eid

C
DATA: Begin of Emp,
Eid (10) Type C,
Ename (25) Type C,
Eadd (35) Type C,
End of Emp.

Emp
Ename

10 C 25

Eadd

C 35

DATA Emp1 like table of Emp.


Emp-Eid = 1.
Emp-Ename = SPRAO.
Emp-Eadd = SANATH NAGAR.
Append Emp to Emp1.
Emp-Eid = 2.
Emp-Ename = RAJ.
Emp-Eadd = KPHB.
Append Emp to Emp1.
Emp-Eid = 3.
Emp-Ename = SANDEEP.
Emp-Eadd = BEGUMPET.
Append Emp to Emp1.
Loop at Emp1 to Emp.
Write: / Emp-Eid,
Emp-Ename,
Emp-Eadd.
End Loop.
Syntax:-

BUKRS (4) Type C


Or
BUKRS Type BUKRS
Or
BUKRS like T001-BUKRS.

Type is used to refer the data types or data elements.


Like is used to refer the variables or fields.
Object:To display the company codes, company names & cities.
WA BUKRS BUTXT ORT01
DATA: Begin of WA,
BUKRS like T001-BUKRS,
BUTXT like T001-BUTXT,
ORT01 like T001-ORT01,
End of WA.
DATA IT like table of WA.

Select BUKRS BUTXT ORT01 from T001 into table IT.


Loop at IT into WA.
Write: / WA-BUKRS, WA-BUTXT, WA-ORT01.
EndLoop.
NOTE:The order of the fields in the work area as well as the order of the fields in
select query must be same.
Object:To display the Vendor numbers, Vendor names, & Countries.
WA LIFNR NAME1 LAND1
DATA: Begin of WA,
LIFNR like LFA1-LIFNR,
NAME1 like LFA1-NAME1,
LAND1 like LFA1-LAND1,
End of WA.
DATA IT like table of WA.
Select LIFNR NAME1 LAND1 from LFA1 into table IT.
Loop at IT into WA.
Write: / WA-LIFNR, WA-NAME1, WA-LAND1.
EndLoop.
Differences between Database tables & Internal tables:Database table
Internal table
Database tables are global,
Internal tables are local, i.e., we can i.e.,
we can access the dataaccess the internal table with in the
base tables from anywhere
program only.
in
the sap.
Database tables are permanent Internal tables are temporary storage
storage location.
Location.
We must provide the size of
Internal tables is dynamic memory the
database table.
allocation.
Object:To display the customer numbers, customer names, cities & countries.
WA KUNNR NAME1 ORT01 LAND1

DATA: Begin of WA, /*work area started*/


KUNNR like KNA1-KUNNR,
NAME1 like KNA1-NAME1,
ORT01 like KNA1-ORT01,
LAND1 like KNA1-LAND1,
End of WA. /*work area ended*/.
DATA IT like table of WA. /*Internal table created*/.
Select KUNNR NAME1 ORT01 LAND1 from KNA1 into IT.
Loop at IT into WA.
Write: / WA-KUNNR, WA-NAME1, WA-ORT01, WA-LAND1.
EndLoop.

Types of Internal Tables:Two Types

Indexed

Standard

Hashed

Sorted

Standard Internal Table:-

08/06/10

It accepts duplicate records.


Here all fields are non-unique fields.
Pushing data from work area to internal table is always through APPEND
keyword.
Searching of a record is through LINEAR search.
Syntax:DATA <Internal Table name> like standard table of <work area name>.
E.g.: DATA IT like standard table of WA.
Sorted Internal Table: It wont accept duplicate records.

Here we must specify at least one field as unique or non-unique fields.


Pushing data from work area to internal table is always through INSERT
keyword.
Searching of a record is through BINARY search.
Syntax:DATA <Internal Table name> like sorted table of <work area name> with
unique/non unique key <field1> <field2>.
E.g.: DATA IT like sorted table of EMP with unique key EID.

Hashed Internal Table: It wont accept duplicate records.


Here we must specify at least one field as unique field.
Pushing data from work area to internal table is always through COLLECT
keyword.
Searching of a record is through HASHED ALGORITHM i.e., Midpoint
algorithm.
Syntax:DATA <Internal Table name> like hashed table of <work area name> with
unique/non unique key <field1> <field2>.
E.g.: DATA IT like hashed table of EMP with unique key EID.
NOTE:In the real time we always work with standard internal tables because, we
are working with the data in the database. In the database there will be no
duplicates.
Types of Declaring the Internal Tables:If you want to declare some of the fields from any one of the database.
Syntax:DATA: Begin of <WA name>,
List of fields,
End of <WA name>.
DATA <IT name> like table of <WA name>.
E.g.:
WA_T001 BUKRS BUTXT ORT01
DATA: Begin of WA_T001,

BUKRS like T001-BUKRS,


BUTXT like T001-BUTXT,
ORT01 like T001-ORT01,
End of WA_T001.
DATA IT_T001 like table of WA_T001.
IT_T001

If you want to declare all the fields from any one of the
database table.
Syntax:DATA: Begin of <WA name>.
Include Structure <Db table name>.
DATA End of <WA name>.
DATA <IT name> like table of <WA name>.
E.g.:
WA_T001 BUKRS BUTXT ORT01
DATA: Begin of WA_T001.
Include Structure T001.
DATA End of WA_T001.
DATA IT_T001 like table of WA_T001.
IT_T001 BUKRS BUTXT ORT01

Declaring the internal tables by referring database tables.


Syntax:DATA <WA name> like <Db table name>.
DATA <IT name> like table of <WA/Db name>.
E.g.:
WA_T001 BUKRS BUTXT ORT01
DATA WA_T001 like T001.
DATA IT_T001 like table of T001.
Or
DATA IT_T001 like table of T001.
DATA WA_T001 like line of IT_T001/T001.
IT_T001 BUKRS BUTXT ORT01

Declaring the work area by using TABLES keyword.


Syntax:E.g.:

Tables < Db table name >.


Tables T001.
WA_T001 BUKRS BUTXT ORT01

By default TABLES keyword creates one WA with the name of database table
name & also contains all the fields in database table.

Declaring the internal table by using TYPES keyword.


Syntax:Types: Begin of < type name >,
List of fields,
End of < type name>.
DATA <WA name> Type <type name>.
DATA <IT name> like table of <WA name>.
E.g.:
Ty_T001 BUKRS BUTXT ORT01
Types: Begin of Ty_T001,
BUKRS like T001_BUKRS,
BUTXT like T001-BUTXT,
ORT01 like T001-ORT01,
End of Ty_T001.
DATA WA_T001 Type Ty_T001.
DATA IT_T001 like table of WA_T001.
IT_T001 BUKRS BUTXT ORT01

Object:To display the all the fields from LFA1 table.


Program:

* Data begin of WA_LFA1.

* Include structure LFA1.


* Data end of WA_LFA1.
* Data IT_LFA1 like table of WA_LFA1.
* Data WA_LFA1 like LFA1.
* Data IT_lfa1 like table of WA_LFA1.
* Data IT_LFA1 like table of LFA1.
* Data WA_LFA1 like line of IT_LFA1.
Types begin of Ty_LFA1.
Include structure LFA1.
Types end of Ty_LFA1.
Data WA_LFA1 Type Ty_LFA1.
Data IT_LFA1 like table of WA_LFA1.
Select * from LFA1 into table IT_LFA1.
Loop at IT_LFA1 into WA_LFA1.
Write: / WA-LFA1.
Endloop.

Declaring the internal tables with Header line.


By default header line creates one work area with the name of internal table
i.e., the name of the work area as well as the name of the internal table is
same.

Declaring the internal table with header line by using OCCURS keyword.
Syntax:DATA: Begin of <IT name> occurs 0,
List of fields/ internal structure,
End of <IT name>.
E.g.:
DATA: Begin of IT_T001 occurs 0,
BUKRS like T001-BUKRS,
BUTXT like T001-BUTXT,
ORT01 LIKE T001-ORT01,
End of IT-T001.
Here IT_T001 acts as an internal table with header line, i.e., it creates one
work area with the name of internal table name i.e., IT_T001.

NOTE:1. Here OCCURS 0 allocates 8KB of memory for internal table.


2. If the data in the internal table exceeds 8KB then it brings one more
8KB of memory up to 2GB.
3. OCCURS N allocates N records of memory for the internal table; if
the data in internal table exceeds N records of memory then it brings
one more N records of memory up to 2GB.

Declaring the internal table with header line by using Types keyword.
Syntax:Types: Begin of <Type name>,
List of fields,
End of <Type name>.
Data <IT name > Type table of <Type name> with header line.
E.g.:
IT_T001 BUKRS BUTXT ORT01

Types: Begin of Ty_T001,


BUKRS like T001-BUKRS,
BUTXT like T001-BUTXT,
ORT01 like T001-ORT01,
End of Ty_T001.
Data IT_T001 Type table of Ty_T001 with header line.
IT_T001 BUKRS BUTXT ORT01
Initializing Techniques of Internal Table:-

09/06/10.

1. Clear.
2. Refresh.
3. Free.
Clear:Clear always used to clear the contents of the work area only.
Syntax:Clear < work area name >.
E.g.:
Clear WA_T001.
WA_T001 BUKRS BUTXT ORT01
1000
TCS
HYD
After Clear

WA_T001 BUKRS BUTXT ORT01

Clear also clears the contents of the internal table.


Syntax:Clear < Internal table name>.
Clear IT_T001.

E.g.:

IT_T001 BUKRS BUTXT ORT01

NOTE:-

E.g.:

1. In the real time, we never use clear to clear the contents of internal
table.
2. If we are working with internal table with header line then the name of
he work area as well as the name of the internal table are same, in this
situation also clear clears the contents of the work area.
3. If you want to clear the contents of the internal table then we use []
to the internal table.
Clear IT_T001.
IT_T001 BUKRS BUTXT ORT01
Clear IT_T001 [].
IT_T001 BUKRS BUTXT ORT01

Refresh:Refresh always clears the contents of the internal table only.


Syntax:E.g.:

Refresh < Internal table name>.


Refresh IT_T001.
WA_T001 BUKRS BUTXT ORT01

1000
TCS
2000
IBM
3000
HCL
After Refresh

HYD
CHE
BAN

WA_T001 BUKRS BUTXT ORT01

NOTE:If we are working with internal table with header line then the name of
work area as well as the name of the internal table are same, in this situation also
refresh clears the contents of the internal table only.

Free: Free acts like Refresh.


Refresh clears the contents of the internal table only not the memory which
is allocated for that internal table, where as free clears the contents of the
internal table as well as the memory which is allocated for that internal table.
Syntax:Free < Internal table name>.
Attributes of Internal Table:Two types

Type of the internal table

KIND

T
(Standard)

Num of records
available in the
internal table.
LINES

S
(Sorted)

H
(Hashed)

Kind:Kind is the keyword which returns the type of the internal table.
If it is a standard internal table then it returns T.

If it is a sorted internal table then it returns S.


If it is a hashed internal table then it returns H.
Lines:Lines is the keyword which returns number of records available in the
internal table.
Syntax:Describe table < IT name> kind <variable1> lines <variable2>.
E.g.:
Data: V1 type C,
V2 type I.
Data: Begin of WA_T001,
BUKRS like T001-BUKRS,
BUTXT like T001-BUTXT,
ORT01 like T001-ORT01,
End of WA_T001.
Data IT_T001 like table of WA_T001.
Select BUKRS BUTXT ORT01 from T001 into table IT_T001.
Describe table IT_T001 kind V1 lines V2.
Write: / V1, V2.
Operations on internal tables:

Pushing the data from work area to internal table by using


1. Append.
2. Insert.
3. Collect.
Retrieving the data from database table & placing it into internal table.
If we are working with
all fields.
Select *

Reading the data from internal table.

Single record

Some of the fields.


Select <F1>, <F2>.

Multiple record

READ
LOOP AT
Modify the internal table by using MODIFY keyword.
Delete the data from the internal table by using DELETE keyword (other than
clear, refresh).

Sort the data in the internal table, by using SORT keyword.

Append:Append is the keyword which is used to append/transfers the data from


work area to at the last record of internal table.
Syntax:Append <WA name> to <IT name>.
Append WA_T001 to IT_T001.

E.g.:

WA_T001 BUKRS BUTXT ORT01


3000
HCL
BAN
Append
IT_T001 BUKRS BUTXT ORT01
1000
TCS
HYD
2000
IBM
CHE
4000
HP
MUM
Insert:Insert inserts the data from work area to internal table based on the key
field.
Syntax:E.g.:

Insert <WA name> into table <IT name>.


Insert WA_T001 into table IT_T001.

Collect:Collect checks the internal table if the inserted record is there/available or


not. If not, it acts like insert keyword; otherwise it adds the numeric fields from
work area to nu8meric fields in the internal table.
Syntax:E.g.:

Collect <WA name> into <IT name>.


Collect WA_T001 into IT_T001.

Retrieving the data from database table & placing it into internal table:10/0610.

1.

If we are working with all fields.


Syntax:Select * from <DB table name> into table <IT name> where <condition>.

2.

If we are working with some of the fields.


Syntax:Select <field1>, <field2>. From <DB table name> into table <IT table
name> where <condition>.
Reading a single record from internal table based on Index:Syntax:Read table <IT name> into <WA name> index <num>.
E.g.:
Read table IT_T001 into WA_T001 index 3.
IT_T001 BUKRS BUTXT
1000
TCS
2000
IBM
3000
HP
4000
5000

HCL
CAPTAMI
NI

ORT01
HYD
CHE
MUM
BAN
PUN

WA_T001 BUKRS BUTXT ORT01


3000
HP
MUM
Reading a single record from the internal table based on condition:Syntax:E.g.:

Read table <IT name> into <WA name> with key <condition>.
Read table IT_T001 into WA_T001 with key BUKRS=4000.

Reading multiple records from the internal table by using loop at keyword:Syntax:-

E.g.:

Loop at <IT name> into <WA name> where <condition>.


Write .
Endloop.
Loop at IT_T001 into WA_T001 where ORT01=HYD.
Write: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.

Endloop.
Modify the internal table by using MODIFY keyword:

This is the two step procedure.


1. Fill the latest data into work area.
2. Modify the internal table.
Syntax:E.g.:

Modify <IT name> from <WA name> transporting <field1>


<field2>. Where <condition>.
WA_T001-BUTXT = IBM.
WA_T001-ORT01 = BAN.
Modify IT_T001 from WA_T001 transporting ORT01 where
BUKRS = 2000.

Delete the data from internal table based on Index:Syntax:E.g.:

Delete <IT name> where <condition>.


Delete IT_T001 where BUKRS =5000.

If you are not mentioning any condition then it deletes the data entirely in the
internal table.
Sort the data in the internal table:Syntax:

Sort <IT name> by <field name1>..


E.g.:
Sort IT_T001 by BUKRS
By default sorting will be ascending.
If you want to display the data in descending.
Syntax:E.g.:

Sort <IT name> by <field name> descending.


Sort IT_T001 by BUKRS descending.

If we have two similar internal tables, if you want to move the data from one
internal table to another.
Syntax:<IT2> = <IT1>.

If you want to append the data from first internal table to second.
Syntax:-

Append <WA> to <IT name>.

Append lines of <1st IT> to <2nd IT>.


E.g.: Append lines of IT_T001 to IT_T0011.
Insert <WA> into table <IT>.
E.g.: Insert lines of <IT1> into table <IT2>.
Checking the internal table:If <internal table> is initial.
Empty.
If not <internal table> is initial.
Having some information.

Control structures:Control structures are used to control the execution sequence


of a program.
There are two types of control structures.
Branching

If

Case

Looping

Conditional looping Unconditional looping


While

If:Syntax:If <condition>.
Block of statements.
Else/elseif <condition>.
Block of statements.

Do

Endif.
E.g.:

parameter day type I.


If day= 1.
Write sun.
Elseif day= 2.
Write mon.
Elseif day= 3.
Write tue.
.
.
Elseif day=7.
Write sat.
Else
Write invalid day.
Endif.

Case:Syntax:-

E.g.:

Note:-

Case < statement >.


When < result 1>.
Block of statements.
When < result 2>.
Block of statements.
.
.
When others.
Block of statements.
Endcase.
parameter day type I.
Case day.
When 1.
Write sun.
When 2.
Write mon.
.
.
When others.
Write invalid day.
Endcase.

In the real time we always use case instead of nestedif, because case is
faster as well as clear than if.
While:Syntax:While <condition>.
Block of statements.
Endwhile.
Do:Syntax:Do <num of times>.
Block of statements.
Enddo.
Note:In the real time we always use while instead of do, because while is faster
than do.
Open SQL:-

11/06/10.
Open SQL

DDIC
DML
DCL
(Data Dictionary) (Data manipulation language) (Data control language)
This is used to
1. Insert.
1. Commit work.
create the tables as
2. Update.
2. Rollback work.
well as alter the tables.
3. Modify.
4. Delete.
Note:1. Open SQL is used to work with databases not with internal tables.
2. Insert, Update, Modify & Delete a single record in to the database table is
always through work area & multiple records through internal table.
3. When ever we are working with database tables then we must declare the
structure of work area as well as structure of the internal table as similar as
database.
Insert single record:Insert inserts a record in to the database table if there is no
match found in the database based on the key field. Otherwise it ignores the
records.
Syntax:Insert < DB table name > from < WA name >.

Note:SY-SUBRC is the system variable which contains 0 if the above statement


executed successfully. Otherwise it contains non-zero (mot of times it contains 4).

E.g.:
Data WA_T001 like T001.
WA_T001-BUKRS = 0786.
WA_T001-BUTXT = SP RAO TECH.
WA_T001-ORT01 = CHE.
WA_T001-LAND1=IN.
Insert T001 from WA_T001.
If sy-subrc= 0.
Write: / inserted successfully.
Else.
Write: / nit inserted.
Endif.
Insert (multiple records):Insert inserts the multiple records in to the database
table if there is no match found in the database table for all records in the internal
table based on the key field. If at least one record is matched then it ignores all the
records in the internal table as well as terminates the entire transaction.
Syntax:Insert < DB table name > from table < IT name >.
E.g.:
Data WA_T001 like T001.
Data IT_T001 like table of WA_T001.
WA_T001-BUKRS = 0998.
WA_T001-BUTXT = RAM TECH.
WA_T001-ORT01 = CHE.
Append WA_T001 to IT_T001.
WA_T001-BUKRS = 1000.
WA_T001-BUTXT = RAGHU TECH.
WA_T001-ORT01 = MUM.
Append WA_T001 to IT_T001.
Insert T001 from table IT_T001.
Note:If you want to avoid the termination of the program then we use accepting
duplicate keys in the syntax of insert.

Syntax:Insert <DB table name> from table <IT name> accepting duplicate
keys.
The above statement avoids the termination of the program as well as inserts the
non-duplicate records & ignores the duplicate records.
Note:SY-DBCNT is the system variable which returns number of records
successfully inserted in to the database table.
Update (single record / over write):Update updates the data in to the database;
if there is a match found in the database based on the key field otherwise it ignores
the record.
Syntax:Update <DB table name> from <WA name >.
Note:In this case, we must pass changed information along with old information
in the work area.
E.g.:
Data WA_T001 like T001.
WA_T001-BUKRS =0786.
WA_T001-BUTXT = SPRAO TECH.
WA_T001-ORT01 = MUM.
Update T001 from WA_T001.

Update multiple records:It is similar as update single record.


Syntax:Update <DB table name> from table <IT name>.

Update particular column:Syntax:Update <DB table name> set <field1> = <value> <field2> = <value>
.. Where <condition>.

E.g.:
Update T001 set ORT01 =CHE where BUKRS= 0786.
Modify: Modify acts like update if there is a match found in the database based on the
key field otherwise it acts like insert.
Modify never fails.
Syntax:1.
2.

Modify <DB table name> from <WA name>.


Modify <DB table name> from table <IT name>.

E.g.:
Data: WA_T001 like T001,
IT_T001 like table of T001.
WA_T001-BUKRS = 1000.
WA_T001-BUTXT = TCS.
WA_T001-ORT01 = CHE.
Append WA_T001 to IT_T001.
WA_T001-BUKRS = 0999.
WA_T001-BUTXT = VENKI.
WA_T001-ORT01 = HYD.
Append WA_T001 to IT_T001.
Modify T001 from table IT_T001.
Delete:Delete deletes the data from the database based on condition.
Syntax:E.g.:

Delete from <DB table name> where <condition>.


Delete from T001 where BUKRS = 0786.

Commit work:-

12/06/10.
This command is used to commit the database after changed
happen in the database.
Syntax:Commit work.
Rollback work:This command is used to undo the database operations.

Syntax:Rollback work.
Select-options:Select-options is a keyword which accepts single value,
multiple single values, single range, multiple single ranges.
Syntax:Select-options <name of the select-options> for <variable name>.
E.g.:
Data V1 like T001-BUKRS.
Select-options S_BUKRS fro V1.
S_BUKRS

to

Note:The name of the select-options acts as an internal table with header line. i.e.,
the name of the work area as well as the name pf the internal table is the similar
name of the select-options.
Components/ fields of the select-options:1. Low the low value of the select-options.
2. High the high value of the select-options.
3. Sign include (I) or exclude (E).
4. Option between (BT) or not between (NB)
Equal (EQ) or not equal (NE).
Note:The name of the select-options should not exceed 8 character length.
Sign=I
Sign=I
Option=BT
Option=N
1000<=x<=2000
x<=1000
x=>2000
1000---------2000
Sign=E
Option=BT
1000<x<2000

Sign=E
Option=N
x<1000
x<2000

----1000-----2000
----1000-----2000----Note:By default select-options contain sign is include option is between.

Object:Based on the given company codes to display the company codes,


company names, and cities.
Program:Data V1 like T001_BUKRS.
Select-options S_BUKRS for V1.
Data: Begin of WA_T001,
BUKRS like T001_BUKRS,
BUTXT like T001_BUTXT,
ORT01 like T001_ORT01,
End of WA_T001.
Data IT_T001 like table of WA_T001.
Select BUKRS BUTXT ORT01 from T001 into
IT_T001 where BUKRS in S_BUKRS.

table

Loop at IT_T001 into WA_T001.


Write: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
Endloop.
Note: In the real time when ever we are working with plants, storage
locations then we remove the intervals.
Syntax:Select-options <name of the select-options> for <variable name> no
intervals.
E.g.:
Select-options S_BUKRS for v1 no intervals.
In the real time when ever we are working with dates then we remove the
extension.
Syntax:Select-options <name of the select-options> for <variable name> Noextension.
If you want remove the both extensions and intervals.
Syntax:Select-options <name of the select option> for <variable> noextension no interval.

Note:In the real time when ever we are working with company code, if it is only
one company then we remove the extension and the interval.
Some of the standard database tables:MARA:- Material master table
1. MATNR Material number.
2. MTART Material type. (Material type means raw material, semi material,
finished material)
3. MATKL Material group.
4. BISMT Old Material.
5. MEINS UOM.

KNB1: Customers under company


1. BUKRS Company code.
2. KUNNR Customer number.
3. AKONT Recon account.
4. PERNR Personal number.
LFB1: Vendors under company
1. BUKRS Company code.
2. LIFNR Vendor number.
3. AKONT Recon account.
4. PERNR Personal number.
MARC: Material and plant table
1. MATNR Material number.
2. WERKS Plant.
JOINS:Joins are used to retrieving the data from more than one table. There
are two types of joins
1. Inner join
2. Left outer join
Inner join:-

Inner join pick the data from both the tables if and only if there is one
or more than one entry is available in right hand side table with corresponding left
hand side table.
E.g.:
T001 BUKRS

Output:-

1000
3000
4000
4000
4000

BUTXT
1000
1000
3000
4000
4000
4000

KNB1 BUKRS
116
241
171
991
997
1020

KUNNR

TCS
116
HCL 171
HP
991
HP
997
HP
1020

Syntax:Select <DB table1>~<field1> <DB table1>~field2---- <DB


table2>~<field1> <DB table2>~<field2>----- into table <IT> from
<DB table1> inner join <DB table2> on <DB table1>~<field> =<DB
table>~<field> where <condition>.
Object:To display the company codes, company names, and customer number
under company.
Program:Data: Begin of WA_ FINAL,
BUKRS like T001_BUKRS,
BUTXT like T001_BUTXT,
ORT01 like T001_ORT01,
End of WA_ FINAL.
Data IT_ FINAL like table of WA_ FINAL.
Select T001~BUKRS T001~BUTXT KNB1~KUNNR into
table IT_FINAL from T001 Inner join KNB1 on
T001~BUKRS=KNB1~BUKRS.
Loop at IT_FINAL into WA_FINAL.

Write: / WA_FINAL-BUKRS, WA_FINAL-BUTXT,


WA_FINAL-KUNNR.
Endloop.

Some of the database tables:-

14/06/10.

EKKO:- purchasing document header table


EBELN purchasing document number.
BSART document type.
EKORG purchasing organization.
LIFNR vendor number.
BUKRS company code.

EKPO:- purchasing document item table


EBELN purchasing document number.
EBELP item number.
MENGE quantity.
MEINS UOM (unit of measurement).
NETPR net price.
MATNR material number.
MAKT:- material description table
MATNR material number.
SPRAS language.
MAKTX material description.
T001W:- plant description table
WERKS plant number.
NAME1 name of the plant.
Object:Based on the given material to display the material number, material type
& material description.
MATNR
MTART
MAKTX

MARA
MATNR
MTART

MAKT
MATNR
MAKTX

Program:Data V1 like MARA-MATNR.


Select-options S_MATNR for V1.
Data: Begin of WA_final,
MATNR like MARA-MATNR,
MTART like MARA-MTART,
MAKTX like MAKT-MAKTX,
End of WA_final.
Data IT_final like table of WA_final.
Select MARA~MATNR MARA~MTART MAKT~MAKTX into table
IT_final from MARA inner join MAKT on
MARA~MATNR=MAKT~MATNR where MARA~MATNR in
S_MATNR and SPRAS=SY-LANGU.
Loop at IT_final into WA_final.
Write: / WA_final-MATNR, WA_final-MTART, WA_final-MAKTX.
Endloop.
NOTE:1. SY-LANGU is the system variable which contains current language.
2. If any table contains SPRAS as a primary field then we must consider the
language in the where condition at the time of retrieving the data from
that table.
Object:- Based on the given vendor number to display the vendor number, vendor
type, purchasing document number, document type, item number, quantity, UOM
& net price.
LIFNR NAME1 EBELN BSART EBELP MNGE MEINS NETPR
LFA1
LIFNR
NAME1

EKKO
EBELN
LIFNR
BSART

EKPO
EBELN
EBELP
MENGE
MEINS
NETPR

Program:Data V1 like LFA1-LIFNR.


Select-options S_LIFNR for V1.

Data: Begin of WA_FINAL,


LIFNR like LFA1-LIFNR,
NAME1 like LFA1-NAME1,
EBELN like EKKO-EBELN,
BSART like EKKO-BSART,
EBELP like EKPO-EBELP,
MENGE like EKPO-MENGE,
MEINS like EKPO-MEINS,
NETPR like EKPO-NETPR,
End of WA_FINAL.
Data IT_FINAL like table of WA_FINAL.
Select LFA1~LIFNR LFA1~NAME1 EKKO~EBELN
EKKO~BSART EKPO~EBELP EKPO~MENGE EKPO~MEINS
EKPO~NETPR into table IT_FINAL from LFA1 inner join EKKO on
LFA1~LIFNR = EKKO~LIFNR inner join EKPO on EKKO~EBELN
= EKPO~EBELN where LFA1~LIFNR in S_LIFNR.
Loop at IT_FINAL into WA_ FINAL.
Write: / WA_ FINAL-LIFNR, WA_ FINAL-NAME1, WA_ FINALEBELN, WA_ FINAL-BSART, WA_ FINAL-EBELP, WA_ FINALMENGE, WA_ FINAL-MEINS, WA_ FINAL-NETPR.
Endloop.
Some other database tables:LFBK:- vendor bank table
LIFNR vendor number.
BANKS bank country key.
BANKL bank key.
BANKN account number.
KNBK:- Customer bank table
KUNNR customer number.
BANKS bank country key.
BANKL bank key.
BANKN account number.

Assignment:-

Based on the given customer to display the customer numbers,


names, recon accounts, bank country key, bank key & account number.
KUNNR

NAME1

AKONT

BANKS

KNA1
KUNNR
NAME1

KNB1
AKONT
KUNNR
BUKRS

KNBK
KUNNR
BANKS
BANKL
BANKN

BANKL

BANKN

Program:Data V1 like KNA1-KUNNR.


Select-options S_KUNNR for V1.
Data: Begin of WA_FINAL,
KUNNR like KNA1-KUNNR,
NAME1 like KNA1-NAME1,
AKONT like KNB1-AKONT,
BANKS like KNBK-BANKS,
BANKL like KNBK-BANKL,
BANKN like KNBK-BANKN,
End of WA_FINAL.
Data IT_FINAL like table of WA_FINAL.
Select KNA1~KUNNR KNA~NAME1 KNB1~AKONT
KNBK~BANKS KNBK~BANKL KNBK~BANKN into table
IT_FINAL from KNA1 inner join KNB1 on KNA1~KUNNR =
KNB1~KUNNR inner join KNBK on KNB1~KUNNR =
KNBK~KUNNR where KNA1~KUNNR in S_KUNNR.
Loop at IT_FINAL into WA_FINAL.
Write: / WA_FINAL-KUNNR, WA_FINAL-NAME1, WA_FINALAKONT, WA_FINAL-BANKS, WA_FINAL-BANKL, WA_FINALBANKN.
Endloop.

Left outer join:Left outer join pick the data from left-hand side table even
though there is no match found in the right-hand side table.
E.g.:
T001 BUKRS BUTXT KNA1 BUKRS KUNNR

1000
TCS
2000
IBM
3000 1000HCL 116
4000 1000HP 241
5000 3000CSE 761
4000
991
4000
997
Output:4000
1020
1000
TCS
116
1000
TCS
241
2000
IBM
..
3000
HCL
761
4000
HP
991
4000
HP
997
4000
HP
1020
5000
CSE
..
In the above examples remove the inner join & place the left outer join.

Reports:

15/06/10.

Report:Report is a combination of giving inputs through the selection-screen,


retrieving the data from the database based on the given input & displays it in a
free defined format.
Syntax of Selection-screen:Selection-screen begin of block <block name> with frame title text-<no>.
Input fields.
Selection-screen end of block <block name>.

Syntax of Check box:Parameter <name of the check box> as check box.


E.g.:
Parameter P_Dis as check box.
Syntax of Radio button:-

Parameter <name of the radio button> radio button group <group name>.
E.g.:
Parameter: P_MALE radio button group G,
P_FEMALE radio button group G.
Selection-screen Design:Data V1 like T001_BUKRS.
Selection-screen begin of block B with frame title text-001.
Select-options S_BUKRS for V1.
Parameter: P_Dis as check box,
P_Non Dis as check box.
Selection-screen end of block B.
Output:Selection-criteria

S_BUKRS

to

Display
Non Display

Note: If you want to provide the meaningful txt to the input variable, then you
go to; menu bar go to text elements selection texts.
Select the check box, if the field is coming from data dictionary,
otherwise we pass the input manually.
Save the text.
Activate the text.
Back.
Note:If we are working with Begin of line & End of line then the name of the
parameters will disappear, at that time we must provide comment before or after
the check box or radio button.
Syntax of providing a comment:Selection-screen comment X(Y) text-<no>.
Starting num of
Position characters
Note:-

Skip is the keyword to provide the space in between any two input
variables.
Syntax:Selection-screen skip <no>.

By default skip is one line, we can skip maximum 9 lines at a time.


Program:Data V1 like T001_BUKRS.
Selection-screen begin of block A with frame.
Select-options S_BUKRS for V1.
Selection-screen skip 1.
Selection-screen begin of line.
Parameter P_Dis as check box.
Selection-screen comment 2(7) text-001.
Parameter P_Non Dis as check box.
Selection-screen comment 11(11) text-002.
Selection-screen end of line.
Selection-screen end of block A.
Output:S_BUKRS
Display

to
Non Display

Note:The value of the active check box or active radio button is X.

Types of Reports:There are two types of reports. They are:


1. Classical reports.
2. Interactive reports.
Classical reports:A classical report is nothing but to display the entire
information in to a single list.
E.g.:
SPRAO
..
RAJ
.

Interactive reports:An Interactive report is nothing but to display the summarized


information in the basic list & next level information in the secondary lists.
E.g.:
SPRAO
0 RAJ
1

SPRAO EDU

RAJ EDU
..

Note:We can have only one basic list & up to 20 secondary lists.
SY-LSIND is the system variable which contains the current list index
number.
Events in Classical reports:-

16/06/10.
Events in classical reports are

1.
2.
3.
4.
5.
6.
7.

Initialization.
At selection-screen.
At selection-screen on.
Start-of-selection.
Top-of-page.
End-of-page.
End-of-selection.

Initialization:Initialization is an event which is triggered before displaying the


selection-screen.
Advantage:This is used to assign the default values to the selection-screen.
At selection-screen:At selection-screen is an event which is triggered at after
providing the input to the selection-screen & before leaving the selection-screen.
Advantage:This is used to validate the given input.
At selection-screen on:At selection-screen on is an event which is triggered at
the selection-screen based on the given field.
Advantage:This is used to validate the given input.
Start-of-selection:-

Start-of-selection is an event which is triggered after leaving


the selection-screen & before displaying the output.
Advantage:This is used to retrieving the data from the database & placed in to
internal tables.
Note:Start-of-selection is a default event in the classical reports.
Top-of-page:Top-of-page is an event which is triggered at the Top of each page.
Advantage:This is used to display the header information.
End-of-page:End-of-page is an event which is triggered at the End of each page.
Advantage:This is used to display the footer information.
End-of-selection:End-of-selection is an event which is triggered after
manipulating the data.
Advantage:This is used to display the output.
Order of the Events:At selection-screen on
2
SelectionInitialization
1 screen
2
At selection-screen
Initialization:Initialization.
S_BUKRS-low = 1000.

3
start-ofSelection

Top-of-page
5

End-ofselection
4
6

End-of-page

S_BUKRS-high = 2000.
S_BUKRS-sign = I.
S_BUKRS-option = BT.
Append S_BUKRS.
S_BUKRS-low = 3000.
S_BUKRS-high = .
S_BUKRS-sign = I.
S_BUKRS-option = EQ.
Append S_BUKRS.
Message:1.
2.
3.
4.
5.

We have five different types of messages. They are:


ABEND (A).
WARNING (W).
ERROR (E).
INFORMATION (I).
SUCCESS (S).

Abend Message:- (A)


The system displays a message of this message type in a
dialogue window/box, after the user conform this message by using enter key, then
the system terminates entire transaction.
Syntax:Message <message type><message number> (<message class).
3 digit number
E.g.:
Message A000(YSMSG).

Message class is the collection of all the messages, their numbers.

Note:SE91 is the transaction code to create the message class.


Steps to create Message class:

Execute SE91.
Provide your message class.
Click on create.
Provide short description.

Click on save local object.


Click on messages-tab.
Provide the descriptions against numbers.
Click on save.
E.g.:
Parameter P_NO type I.
If P_NO < 10.
Message A000(ZSMSG).
Endif.
Warning or Error messages:The system displays a message of this message
type in the status bar, after the user conform this message by using enter key then
the following things will be happened.
1. If we are in the basic list then it goes to program.
2. If we are in the secondary list then it goes to previous list.
Syntax:E.g.:

Message E/W <message no> (message class).


Message E000(ZSPMSG).

Information (I):The system displays a message of this message type in a


dialogue window/box, after the user conform this message by using enter key, then
it goes to selection-screen.
Syntax:Message I <message no> (message class).
E.g.:
Message I000(ZSPMSG).
Success (S):The system displays a message of this message type in a status bar.
Syntax:E.g.:

Message S <message no> (message class).


Message S000(ZSPMSG).

Generalized message syntax:Message <message type><message no> (message class) with


<description>.
E.g.:
Message I000(ZSPMSG) with less than 10.
Note:In the message class against the message number you place the place
holders (&&&).

Differences between single select &select up to 1 rows:Select single


Select up to 1 rows
1. It always retrieves only one record 1. It always retrieves only one
at a time.
record.
2. Here we must pass entire primary 2. Enough to pass a part of key
key combination in the where
combination in the where condition.
condition.
It always picks the first record
3. This is used to retrieve particular
among the matched records.
record.
3. This is used for validation.
Syntax:E.g.:
DATA: BEGIN OF WA_KNB1,
KUNNR LIKE KNB1-KUNNR,
BUKRS LIKE KNB1-BUKRS,
END OF WA_KNB1.
SELECT SINGLE KUNNR BUKRS FROM KNB1 INTO WA_KNB1 WHERE
KUNNR = 0000001991 AND KUNNR = '3000'.
WRITE: / WA_KNB1-KUNNR, WA_KNB1-BUKRS.
ULINE.
SELECT KUNNR BUKRS FROM KNB1 INTO WA_KNB1 UP TO 1 ROWS
WHERE KUNNR = '0000001991'.
ENDSELECT.
WRITE: / WA_KNB1-KUNNR, WA_KNB1-BUKRS.
Some of the database tables:VBAK:- sales document header table.
1.
2.
3.
4.
5.
6.

VBELN Sales document number.


VBTYP Sales document entry.
VKORG Sales organization.
KUNNR Customer number.
BUKRS Company code.
AUART Sales document type.

VBAP:- Sales document item table.


1. VBELN Sales document number,
2. POSNR item number.
3. MATNR Material number.

17/06/10.

4. ZMENG quantity.
5. MEINS UOM.
6. NETWR Net value.
At selection-screen:Validation:E.g.:1.

DATA V1 LIKE MARA-MATNR.


AT SELECTION-SCREEN.
SELECT MATNR FORM MARA INTO V1 UP TO 1 ROWS
WHERE MATNR IN S_MATNR.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000(YSMSG) WITH INVALID MATERIAL.
ENDIF.

2.

DATA: V1 LIKE MARA-MATNR,


V2 LIKE T001W-WERKS.
AT SELECTION-SCREEN.
SELECT MATNR FORM MARA INTO V1 UP TO 1 ROWS
WHERE MATNR = P_MATNR.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000(YSMSG) WITH INVALID MATERIAL.
ENDIF.
SELECT WERKS FROM T001W INTO V2 UP TO 1 ROWS
WHERE WERKS = P_WERKS.
IF SY-SUBRC <> 0.
MESSAGE E000(YSMSG) WITH INVALID PLANT.
ENDIF.
SELECT MATNR WERKS FROM MARC INTO (V1,V2) UP TO 1
ROWS WHERE MATNR = P_MATNR AND WERKS = P_WERKS.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000(YSMG) WITH MATERIAL IS NOT UNDER
PLANT.
ENDIF.

At selection-screen on:DATA V1 LIKE T001W-WERKS.


AT SELECTION-SCREEN ON P_WERKS.

SELECT WERKS FORM T001W INTO V1 UP TO 1 ROWS


WHERE WERKS = P_WERKS.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000(YSMSG) WITH INVALID PLANT.
ENDIF.
Start-of-selection:START-OF-SELECTION.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE
IT_T001 WHERE BUKRS IN S_BUKRS.
Top-of-page:TOP-OF-PAGE.
WRITE SPRAO TECHNOLOGIES.
End-of-page:END-OF-PAGE.
WRITE THANK YOU.
End-of-selection:END-OF-SELECTION.
LOOP AT IT_T001 INTO WA_T001.
WRITE: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001ORT01.
ENDLOOP.
Note:1. In the reports one event ends with another event.
2. When ever we are working with END-OF-PAGE event then we must
provide line-count in the name of the report.
Syntax:Line-count X(Y).
X- Num of lines per page.
Y- Num of lines for footer.
Variant:Variant is used to save the selection-screen input.
Steps to create a variant: Execute the program.
Provide the sample input.

Click on save.
Provide the variant name & description.
Save.
Note:If you want to avoid the title in the displayed output then we must NO
STANDARD PAGE HEADING in the name of the report.
Object:Based on the given company codes to display the company codes,
company names, names & cities by using events, in the top always display
the welcome to sprao technologies in the bottom to display thank you.
Program:DATA V1 LIKE T001-BUKRS.
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME
TITLE TEXT-001.
SELECT-OPTIONS S_BUKRS FOR V1.
SELECTION-SCREEN END OF BLOCK A.
DATA: BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
AT SELECTION-SCREEN.
SELECT BUKRS FROM T001 INTO V1 UP TO 1 ROWS WHERE
BUKRS IN S_BUKRS.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E000(YSMSG) WITH 'INVALID COMPANY'.
ENDIF.
START-OF-SELECTION.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE
IT_T001 WHERE BUKRS IN S_BUKRS.
TOP-OF-PAGE.
WRITE 'WELCOME TO SAP'.

END-OF-PAGE.
WRITE 'THANK YOU'.
END-OF-SELECTION.
LOOP AT IT_T001 INTO WA_T001.
WRITE :/ WA_T001-BUKRS, WA_T001-BUTXT, WA_T001ORT01.
ENDLOOP.
Events in interactive reports:1. At line-selection.
2. At user-command.
3. Top-of-page during line-selection.
4. At PF<N>.
5. SET PF-STATUS.
At line-selection:At line-selection is an event which is triggered at the time of
user clicks on any record of any list.
At user-command:It is an event which is triggered at the time of user clicks on
any menu item.
Top-of-page during line-selection:It is an event which is triggered at the top of
each secondary list.
At PF<N>:It is an event which is triggered at the time of user clicks on any
function keys (F1 to F12).
Set PF-Status:It is an event which is used to attach the own GUI to the program.

Some of the system variables related to interactive reports:1. SY-LISEL.


2. SY-LILLI.
3. SY-UCOMM.
4. SY-LINNO.

5. SY-LSIND.
SY-LISEL:It is the system variable which contains the contents of the selected
record.
SY-LILLI:It is the system variable which contains the exact line number of the
selected record by the user.
SY-UCOMM:It is the system variable which contains the function code of the
selected menu item.
SY-LINNO:It is the system variable which contains the line number of the last
record displayed.
SY-LSIND:It is the system variable which contains the current list index number.
Interactive reports supports the user interaction is always through double
click or F2.
When ever the user double clicks on any record of any list at line-selection
event will be triggered & list index will be incremented by one.
If you want to retrieve the data for this list we should know the record which
is clicked by the user in the previous list.

Hide:Hide is the keyword which maintains the copy of the previous list with
output line numbers & their contents. When ever the user double clicks on any
record of any list at that time at line-selection event will be triggered & list index is
incremented by one & that particular record will be moving from hide area to work
area.
Based on the work area we retrieve the data for the
next list.
Note:Hide always maintain after the write statement.

Object:To display the company codes, company names & cities in the basic
list, when ever the user clicks on any record then we display the customer
under that company in the first secondary list. When ever the user clicks on
any record in the first secondary list then we display the customer list in the
second secondary list.
Program:DATA: BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
DATA: BEGIN OF WA_KNB1,
BUKRS LIKE KNB1-BUKRS,
KUNNR LIKE KNB1-KUNNR,
AKONT LIKE KNB1-AKONT,
END OF WA_KNB1.
DATA IT_KNA1 LIKE TABLE OF WA_KNA1.
DATA: BEGIN OF WA_KNA1,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
ORT01 LIKE KNA1-ORT01,
END OF WA_KNA1.
DATA IT_KNA1 LIKE TABLE OF WA_KNA1.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE
IT_T001.
LOOP AT IT_T001 INTO WA_T001.
WRITE: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001ORT01.
HIDE: WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
ENDLOOP.
AT LINE-SELECTION.
IF SY-LSIND = '1'.

SELECT BUKRS KUNNR AKONT FROM KNB1 INTO TABLE


IT_KNB1 WHERE BUKRS =
WA_T001-BUKRS.
LOOP AT IT_KNB1 INTO WA_KNB1.
WRITE: / WA_KNB1-BUKRS, WA_KNB1-KUNNR, WA_KNB1AKONT.
HIDE: WA_KNB1-BUKRS, WA_KNB1-KUNNR, WA_KNB1AKONT.
ENDLOOP.
ELSEIF SY-LSIND = '2'.
SELECT KUNNR NAME1 ORT01 FROM KNA1 INTO TABLE
IT_KNA1 WHERE KUNNR = WA_KNB1-KUNNR.
LOOP AT IT_KNA1 INTO WA_KNA1.
WRITE: / WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1ORT01.
ENDLOOP.
ENDIF.

Assignment:To display the purchasing document numbers, document types,


vendor numbers in the basic list, when ever the user clicks on any record then we
display the item details (EBELN, EBELP, MENGE, MEINS & NETPR) in the first
secondary list.
Program:DATA: BEGIN OF WA_EKKO,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
DATA: BEGIN OF WA_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF WA_EKPO.

DATA IT_EKPO LIKE TABLE OF WA_EKPO.


SELECT EBELN BSART LIFNR FROM EKKO INTO TABLE
IT_EKKO.
LOOP AT IT_EKKO INTO WA_EKKO.
WRITE: / WA_EKKO-EBELN, WA_EKKO-BSART, WA_EKKOLIFNR.
HIDE: / WA_EKKO-EBELN, WA_EKKO-BSART, WA_EKKOLIFNR.
ENDLOOP.
AT LINE-SELECTION.
IF SY-LSIND = 1.
SELECT EBELN EBELP MENGE MEINS NETPR INTO TABLE
IT_EKPO WHERE EBELN IN WA_EKKO-EBELN.
LOOP AT IT_EKPO INTO WA_EKPO.
WRITE: / WA_EKPO-EBELN, WA_EKPO-EBELP, WA_EKPOMENGE, WA_EKPO-MEINS, WA_EKPO-NETPR.
ENDLOOP.
ENDIF.
Note:-

18/06/10.
CONVERSION_EXIT_ALPHA_INPUT is the functional module which
is used to append zeros to the input variable based on the length of the input
variable.
E.g.:
DATA A (5) TYPE C.
A=231.
CONVERSION_EXIT_ALPHA_INPUT
INPUT = A.
OUTPUT = A.
A 00231.
Steps to call the function module: Open the program.
Place the cursor where we want to call the function module.
Click on pattern.
Provide your function module name.
CONVERSION_EXIT_ALPHA_INPUT
Enter

Give input & output.


Object:Based on the given company codes to display the company codes, company
names & cities in the basic list, when ever the user clicks on any record then
we display the vendors under that company in the first secondary list. When
ever the user clicks on any record in the first secondary list then we display
the vendor details in the second secondary list by using SY-LISEL.

Program:DATA V1 LIKE T001-BUKRS.


SELECT-OPTIONS S_BUKRS FOR V1.
DATA: BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
DATA: BEGIN OF WA_LFB1,
LIFNR LIKE LFB1-LIFNR,
BUKRS LIKE LFB1-BUKRS,
AKONT LIKE LFB1-AKONT,
END OF WA_LFB1.
DATA IT_LFB1 LIKE TABLE OF WA_LFB1.
DATA: BEGIN OF WA_LFA1,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
ORT01 LIKE LFA1-ORT01,
END OF WA_LFA1.
DATA IT_LFA1 LIKE TABLE OF WA_LFA1.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE
IT_T001 WHERE BUKRS IN S_BUKRS.
LOOP AT IT_T001 INTO WA_T001.
WRITE: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001ORT01.

ENDLOOP.
AT LINE-SELECTION.

IF SY-LSIND = '1'.
SELECT LIFNR BUKRS AKONT FROM LFB1 INTO TABLE
IT_LFB1 WHERE BUKRS =SY-LISEL+0(4).
LOOP AT IT_LFB1 INTO WA_LFB1.
WRITE: / WA_LFB1-LIFNR, WA_LFB1-BUKRS, WA_LFB1AKONT.
ENDLOOP.
ELSEIF SY-LSIND = '2'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT
= SY-LISEL+5(10)
IMPORTING
OUTPUT
= SY-LISEL+5(10).
SELECT LIFNR NAME1 ORT01 FROM LFA1 INTO TABLE
IT_LFA1 WHERE LIFNR = SY-LISEL+5(10).
LOOP AT IT_LFA1 INTO WA_LFA1.
WRITE: / WA_LFA1-LIFNR, WA_LFA1-NAME1, WA_LFA1ORT01.
ENDLOOP.
ENDIF.
19/06/10.
In the above two techniques generates the next list based on the lineselection, not based on field-selection.
If you want to generate the next list based on the field selection then we go
for Get cursor technique.
Syntax:Get cursor field <variable 1> value <variable 2>.
Note:Get cursor technique returns the field name as well as field value which is
selected by the user.

Assignment:Based on the given company codes to display the company codes,


company names, cities in the basic list, if the user clicks on company code then we
display the purchasing document header details in the first secondary list. If the
user clicks on any record then we display the item details (EBELN, EBELP,
MENGE, MEINS & NETPR) in the first secondary list by using get cursor
technique.
Program:DATA V1 LIKE T001-BUKRS.
SELECT-OPTIONS S_BUKRS FOR V1.
DATA: V2 (15),
V3 LIKE T001-BUKRS.
DATA: BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,/O SE38
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
DATA: BEGIN OF WA_EKKO,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
BUKRS LIKE EKKO-BUKRS,
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
DATA: BEGIN OF WA_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF WA_EKPO.
DATA IT_EKPO LIKE TABLE OF WA_EKPO.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE
IT_T001 WHERE BUKRS IN S_BUKRS.

LOOP AT IT_T001 INTO WA_T001.


WRITE: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001ORT01.
ENDLOOP.
AT LINE-SELECTION.
IF SY-LSIND = '1'.
GET CURSOR FIELD V2 VALUE V3.
IF V2 = 'WA_T001-BUKRS'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V3
IMPORTING
OUTPUT = V3.
SELECT EBELN BSART BUKRS FROM EKKO INTO TABLE
IT_EKKO WHERE BUKRS = V3.
LOOP AT IT_EKKO INTO WA_EKKO.
WRITE: / WA_EKKO-EBELN, WA_EKKO-BSART, WA_EKKOBUKRS.
ENDLOOP.
ELSEIF SY-LSIND = 2.
GET CURSOR FIELD V2 VALUE V3.
ELSEIF V2 = 'WA_EKKO-EBELN'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V3
IMPORTING
OUTPUT = V3.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO
INTO TABLE IT_EKPO WHERE EBELN = V3.
LOOP AT IT_EKPO INTO WA_EKPO.
WRITE: / WA_EKPO-EBELN, WA_EKPO-EBELP, WA_EKPOMENGE, WA_EKPO-MEINS,
WA_EKPO-NETPR.
ENDLOOP.
ENDIF.
ENDIF.
Working with GUI:- [menu painter]

Menu painter is a tool design the user interface to the program.


The transaction code for menu painter is SE41.
GUI

GUI title

GUI status

Title bar

Menu bar
STD tool bar
Function keys
Application tool bar

Steps to design our own GUI to the program: Execute SE41.


Provide your program name for which we want to design the our own GUI.
Provide status name e.g. STAT.
Click on create.
Provide short description function text enter.
Select the short cut key enter.
Save.
Check.
Activate.

Note:1.
2.
3.
4.

We can design up to 6 menu items in the menu bar.


System & help are the default menu items in the menu bar.
We can design up to 35 push buttons in the application tool bar.
Set PF-status is the event which is used to attach the own GUI to the
program.
Syntax:Set PF-Status is the event which is used to attach the own GUI
to the program.
Download is the function module which is used to download the data from
internal table to presentation server (C drive, D drive).
The input for the above function module is file type=DAT & internal table.
E.g.:
DATA V1 LIKE T001-BUKRS.

SELECT-OPTIONS S_BUKRS FOR V1.


DATA: BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE
IT_T001 WHERE BUKRS IN S_BUKRS.
LOOP AT IT_T001 INTO WA_T001.
WRITE: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001ORT01.
ENDLOOP.
SET PF-STATUS 'STAT'.
AT USER-COMMAND.
IF SY-UCOMM = 'DOWN'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA-TAB = IT_T001.
ENDIF.
For All Entries:-

21/06/10.
Inner join pick the data based on the ON condition first, next it
based on WHERE condition.
In the real time the maximum program execution tome in fore-ground is
600sec.
More than two tables join, some times leads to timeout, so we go for FOR
ALL ENTRIES.
For all entries pick the data based on WHERE condition first, next it based
on ON condition.
Object:Based on the given company codes to display the company codes,
company names, customer numbers.
Program:-

DATA V1 LIKE T001-BUKRS.


SELECT-OPTIONS S_BUKRS FOR V1.
DATA: BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
DATA: BEGIN OF WA_KNB1,
BUKRS LIKE KNB1-BUKRS,
KUNNR LIKE KNB1-KUNNR,
END OF WA_KNB1.
DATA IT_KNB1 LIKE TABLE OF WA_KNB1.

DATA: BEGIN OF WA_FINAL,


BUKRS LIKE T001-BUKRS,
KUNNR LIKE KNB1-KUNNR,
BUTXT LIKE T001-BUTXT,
END OF WA_FINAL.
DATA IT_FINAL LIKE TABLE OF WA_FINAL.
SELECT BUKRS BUTXT FROM T001 INTO TABLE IT_T001
WHERE BUKRS IN S_BUKRS.
IF NOT IT_T001 IS INITIAL.
SELECT BUKRS KUNNR FROM KNB1 INTO TABLE IT_KNB1
FOR ALL ENTRIES IN
IT_T001 WHERE BUKRS = IT_T001-BUKRS.
ENDIF.
LOOP AT IT_KNB1 INTO WA_KNB1.
WA_FINAL-BUKRS = WA_KNB1-BUKRS.
WA_FINAL-KUNNR = WA_KNB1-KUNNR.
READ TABLE IT_T001 INTO WA_T001 WITH KEY BUKRS =
WA_KNB1-BUKRS.

WA_FINAL-BUTXT = WA_T001-BUTXT.
APPEND WA_FINAL TO IT_FINAL.
CLEAR: WA_FINAL, WA_T001, WA_KNB1.
ENDLOOP.
WRITE: 1(5)'BUKRS', 7(28)'BUTXT', 25(5)'KUNNR'.
SKIP.
LOOP AT IT_FINAL INTO WA_FINAL.
WRITE: / WA_FINAL-BUKRS, WA_FINAL-BUTXT, WA_FINALKUNNR.
ENDLOOP.
Object:Based on the given purchasing document number to display the
document number, document type, vendor number, item number & price.
Program:DATA V1 LIKE EKKO-EBELN.
SELECT-OPTIONS S_EBELN FOR V1.
DATA: BEGIN OF WA_EKKO,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
DATA: BEGIN OF WA_LFA1,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF WA_LFA1.
DATA IT_LFA1 LIKE TABLE OF WA_LFA1.
DATA: BEGIN OF WA_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
NETPR LIKE EKPO-NETPR,
END OF WA_EKPO.
DATA IT_EKPO LIKE TABLE OF WA_EKPO.

DATA: BEGIN OF WA_FINAL,


EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
EBELP LIKE EKPO-EBELP,
NETPR LIKE EKPO-NETPR,
END OF WA_FINAL.
DATA IT_FINAL LIKE TABLE OF WA_FINAL.
SELECT EBELN BSART LIFNR FROM EKKO INTO TABLE
IT_EKKO WHERE EBELN IN S_EBELN.
IF NOT IT_EKKO IS INITIAL.
SELECT LIFNR NAME1 FROM LFA1 INTO TABLE IT_LFA1 FOR
ALL ENTRIES IN
IT_EKKO WHERE LIFNR = IT_EKKO-LIFNR.
SELECT EBELN EBELP NETPR FROM EKPO INTO TABLE
IT_EKPO FOR ALL ENTRIES IN
IT_EKKO WHERE EBELN = IT_EKKO-EBELN.
ENDIF.
LOOP AT IT_EKPO INTO WA_EKPO.
WA_FINAL-EBELN = WA_EKPO-EBELN.
WA_FINAL-EBELP = WA_EKPO-EBELP.
WA_FINAL-NETPR = WA_EKPO-NETPR.
READ TABLE IT_EKKO INTO WA_EKKO WITH KEY EBELN =
WA_EKPO-EBELN.
WA_FINAL-BSART = WA_EKKO-BSART.
WA_FINAL-LIFNR = WA_EKKO-LIFNR.
READ TABLE IT_LFA1 INTO WA_LFA1 WITH KEY LIFNR =
WA_EKKO-LIFNR.
WA_FINAL-LIFNR = WA_LFA1-LIFNR.
WA_FINAL-NAME1 = WA_LFA1-NAME1.
APPEND WA_FINAL TO IT_FINAL.
CLEAR: WA_FINAL, WA_EKKO, WA_EKPO, WA_LFA1.

ENDLOOP.
LOOP AT IT_FINAL INTO WA_FINAL.
WRITE: / WA_FINAL-EBELN, WA_FINAL-BSART, WA_FINALLIFNR, WA_FINAL-NAME1,
WA_FINAL-EBELP, WA_FINAL-NETPR.
ENDLOOP.
Object:-

22/06/10.
Based on the given sales document number to display the sales
document number, document type, customer number, customer name, item number,
material number, material description & net value.
Program:INCLUDE YSAI_INCLUDE1.
DATA: BEGIN OF WA_VBAK,
VBELN LIKE VBAK-VBELN,
AUART LIKE VBAK-AUART,
KUNNR LIKE VBAK-KUNNR,
END OF WA_VBAK.
DATA IT_VBAK LIKE TABLE OF WA_VBAK.
DATA: BEGIN OF WA_KNA1,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
END OF WA_KNA1.
DATA IT_KNA1 LIKE TABLE OF WA_KNA1.
DATA: BEGIN OF WA_VBAP,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
NETWR LIKE VBAP-NETWR,
MATNR LIKE VBAP-MATNR,
END OF WA_VBAP.
DATA IT_VBAP LIKE TABLE OF WA_VBAP.
DATA: BEGIN OF WA_MAKT,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF WA_MAKT.

DATA IT_MAKT LIKE TABLE OF WA_MAKT.


DATA: BEGIN OF WA_FINAL,
VBELN LIKE VBAK-VBELN,
AUART LIKE VBAK-AUART,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
POSNR LIKE VBAP-POSNR,
NETWR LIKE VBAP-NETWR,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF WA_FINAL.
DATA IT_FINAL LIKE TABLE OF WA_FINAL.
.
DATA V1 LIKE VBAK-VBELN.
SELECT-OPTIONS S_VBELN FOR V1.
INCLUDE YSAI_INCLUDE1.
SELECT VBELN AUART KUNNR FROM VBAK INTO TABLE
IT_VBAK WHERE VBELN IN S_VBELN.
IF NOT IT_VBAK IS INITIAL.
SELECT KUNNR NAME1 FROM KNA1 INTO TABLE IT_KNA1
FOR ALL ENTRIES IN
IT_VBAK WHERE KUNNR = IT_VBAK-KUNNR.
SELECT VBELN POSNR NETWR MATNR FROM VBAP INTO
TABLE IT_VBAP
FOR ALL ENTRIES IN IT_VBAK WHERE VBELN = IT_VBAKVBELN.
ENDIF.
IF NOT IT_VBAP IS INITIAL.
SELECT MATNR MAKTX FROM MAKT INTO TABLE IT_MAKT
FOR ALL ENTRIES IN
IT_VBAP WHERE MATNR = IT_VBAP-MATNR.
ENDIF.

LOOP AT IT_VBAP INTO WA_VBAP.


WA_FINAL-VBELN = WA_VBAP-VBELN.
WA_FINAL-POSNR = WA_VBAP-POSNR.
WA_FINAL-NETWR = WA_VBAP-NETWR.
WA_FINAL-MATNR = WA_VBAP-MATNR.
READ TABLE IT_VBAK INTO WA_VBAK WITH KEY VBELN =
WA_VBAK-VBELN.
WA_FINAL-VBELN = WA_VBAK-VBELN.
WA_FINAL-AUART = WA_VBAK-AUART.
WA_FINAL-KUNNR = WA_VBAK-KUNNR.
READ TABLE IT_KNA1 INTO WA_KNA1 WITH KEY KUNNR =
WA_VBAK-KUNNR.
WA_FINAL-KUNNR = WA_KNA1-KUNNR.
WA_FINAL-NAME1 = WA_KNA1-NAME1.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR =
WA_VBAP-MATNR.
WA_FINAL-MATNR = WA_MAKT-MATNR.
WA_FINAL-MAKTX = WA_MAKT-MAKTX.
APPEND WA_FINAL TO IT_FINAL.
CLEAR: WA_VBAK, WA_VBAP, WA_KNA1, WA_MAKT,
WA_FINAL.
ENDLOOP.
LOOP AT IT_FINAL INTO WA_FINAL.
WRITE: / WA_FINAL-VBELN, WA_FINAL-AUART, WA_FINALKUNNR, WA_FINAL-NAME1, WA_FINAL-POSNR, WA_FINALNETWR, WA_FINAL-MATNR, WA_FINAL-MAKTX.
ENDLOOP.
Object:Based on the given materials to display the material number, material
type, plant number, plant name & material description by using FOR ALL
ENTRIES.
Program:DATA: BEGIN OF WA_MARA,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
END OF WA_MARA.
DATA IT_MARA LIKE TABLE OF WA_MARA.

DATA: BEGIN OF WA_MARC,


MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,
END OF WA_MARC.
DATA IT_MARC LIKE TABLE OF WA_MARC.
DATA: BEGIN OF WA_T001W,
WERKS LIKE T001W-WERKS,
NAME1 LIKE T001W-NAME1,
END OF WA_T001W.
DATA IT_T001W LIKE TABLE OF WA_T001W.
DATA: BEGIN OF WA_MAKT,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF WA_MAKT.
DATA IT_MAKT LIKE TABLE OF WA_MAKT.
DATA: BEGIN OF WA_FINAL,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
WERKS LIKE MARC-WERKS,
NAME1 LIKE T001W-NAME1,
MAKTX LIKE MAKT-MAKTX,
END OF WA_FINAL.
DATA IT_FINAL LIKE TABLE OF WA_FINAL.
..
DATA V1 LIKE MARA-MATNR.
SELECT-OPTIONS S_MATNR FOR V1.
INCLUDE YSAI_INCLUDE2_1.
SELECT MATNR MTART FROM MARA INTO TABLE IT_MARA
WHERE MATNR IN S_MATNR.
IF NOT IT_MARA IS INITIAL.
SELECT MATNR WERKS FROM MARC INTO TABLE IT_MARC
FOR ALL ENTRIES IN
IT_MARA WHERE MATNR = IT_MARA-MATNR.

SELECT WERKS NAME1 FROM T001W INTO TABLE IT_T001W


FOR ALL ENTRIES IN
IT_MARC WHERE WERKS = IT_MARC-WERKS.
SELECT MATNR MAKTX FROM MAKT INTO TABLE IT_MAKT
FOR ALL ENTRIES IN
IT_MARC WHERE MATNR = IT_MARC-MATNR.
ENDIF.
LOOP AT IT_MARC INTO WA_MARC.
WA_FINAL-MATNR = WA_MARC-MATNR.
WA_FINAL-WERKS = WA_MARC-WERKS.
READ TABLE IT_MARA INTO WA_MARA WITH KEY MATNR =
WA_MARC-MATNR.
WA_FINAL-MTART = WA_MARA-MTART.
READ TABLE IT_T001W INTO WA_T001W WITH KEY WERKS
= WA_T001W-WERKS.
WA_FINAL-NAME1 = WA_T001W-NAME1.
READ TABLE IT_MAKT INTO WA_MAKT WITH KEY MATNR =
WA_MARC-MATNR.
WA_FINAL-MAKTX = WA_MAKT-MAKTX.
APPEND WA_FINAL TO IT_FINAL.
ENDLOOP.
LOOP AT IT_FINAL INTO WA_FINAL.
WRITE: / WA_FINAL-MATNR, , WA_FINAL-MTART, ,
WA_FINAL-WERKS, , WA_FINAL-NAME1, , WA_FINALMAKTX.
ENDLOOP.
Modularization techniques:Modularization techniques are used to divide the
business processing logic in to reusable block of statements.
Modularization techniques are two step procedure
1. Defining the reusable block.
2. Calling the reusable block.

There are two types of modularizing techniques. They are:


Modularization techniques
Source code
Include

Macros

Functionality
Subroutines Function module

Include:We cannot execute an include program independently, where as the same


include program can be included in any number of executable program.
Advantage:This is used to improve the readability of the program.
Note:In the real time we use include programs for declarations.
Steps to create/define the include program: Execute SE38.
Provide your include program name.
Click on create.
Provide title.
Provide type as include.
Save local object.
E.g.:
DATA: BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
Save.
Check.
Activate.
Syntax of calling the include program in any executable program:Include <include name>.
E.g.:
Include YSAI_INCLUDE.

SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE


IT_T001.
LOOP AT IT_T001 INTO WA_T001.
WRITE: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001ORT01.
ENDLOOP.

Macros:-

23/06/10.
If you want to access the block of statements more than once in a
program, then we place those statements in the definition of the macro.
Macros are used to perform the arithmetical operations.
Macros can take up to 9 place holders. (&1, &2. &9).
Syntax of defining the Macro:Define <name of the macro>.
----------Business logic.
-----End-Of-Definition.
Syntax of calling the Macro:<Macro name> <list of place holders>.
Note:In the macros, definition should be the first & the calling should be the next.
E.g.:
1.

2.

DATA RESULT TYPE I.


DEFINE ZADD SUBROUTINE.
RESULT = &1 + &2.
END-OF-DEFINITION.
ADD 5 20.
WRITE RESULT.
DATA RESULT TYPE I.
DEFINE ZCAL.
RESULT = &1 &2 &3.

END-OF-DEFINITION.
ZCAL 15 * 10.
WRITE RESULT.
ZCAL 15 + 10.
WRITE RESULT.
Multiple records using macros:DATA: BEGIN OF EMP,
EID (10) TYPE C,
ENAME (25) TYPE C,
EADD (35) TYPE C,
END OF EMP.
DATA EMP1 LIKE TABLE OF EMP.
DEFINE FILL.
EMP-EID = &1.
EMP-ENAME = &2.
EMP-EADD = &3.
APPEND EMP TO EMP1.
END-OF-DEFINITION.
FILL 1 SPRAO SANATH NAGAR.
FILL 2 RAJ BEGUMPET.
FILL 1 SANDEEP BEGUMPET.
LOOP AT EMP1 INTO EMP.
WRITE: / EMP-EID, EMP-ENAME, EMP-EADD.
ENDLOOP.
Note:We cannot nest the definition of the macro (with in a macro we cant write
another macro).
In the real time macros are used in HR ABAP (HR ABAP use INFOTYPE).
Sub-Routine:Sub-routines are procedures that can be defined in any ABAP
program and call from the same/other ABAP program.

Syntax of defining the Subroutine:Form <name of the subroutine> using <IV1> type <DT> <IV2> type
<DT>. Changing <OV1> type <DT> <OV2> type <DT>.
----------Business logic
-----End form.
IV- input variable, OB- output variable, DT- data type.
Syntax of calling the Subroutine:Perform <name of the subroutine> using <input1><input2>. Changing
<output1><output2>..
Note:1. In the subroutine calling should be the first & definition should be the next.
2. We cannot place any executable statement after the definition of the
subroutine.
DATA RESULT TYPE I.
PARAMTER: P_INPUT1 TYPE I,
P_INPUT2 TYPE I.
PERFORM ADD USING P_INPUT1 P_INPUT2 CHANGING
RESULT.
WRITE RESULT.
FORM ADD USING A TYPE I B TYPE I CHANGING C TYPE I.
C = A + B.
ENDFORM.
E.g.:
DATA: BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE
IT_T001.
PERFORM READ-DATA USING IT_T001 4 CHANGING
WA_T001.
WRITE: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001ORT01.

FORM READ-DATA USING A LIKE IT_T001 B TYPE I


CHANGING C LIKE WA_T001.
READ TABLE A INTO C INDEX B.
ENDFORM.
Note:There are two types of Subroutines. They are:
1. Internal subroutines.
2. External subroutines.
Internal subroutine is nothing but the definition of subroutine as well as the
calling of subroutine in the same program.
External subroutine is nothing but the definition of subroutine in one program &
the calling of subroutine in another program.
Syntax of calling the external subroutines:Perform <name of the subroutine> in program <program name> using
<input variable 1><input variable 2>. Changing <output variable 1><output
variable 2>..
E.g.:
DATA RESULT TYPE I.
PERFORM ADD IN PROGRAM SAI USING 10 15 CHANGING
RESULT.
WRITE RESULT.
FORM ADD USING A TYPE I B TYPE I CHANGING C TYPE I.
C = A+ B.
ENDFORM.

Termination of the subroutine:-

24/06/10.
Subroutine normally ends with ENDFORM if
we want to terminate the subroutine earlier then we use EXIT or CHECK
commands.
EXIT is used to terminate the subroutine unconditionally.
CHECK is used to terminate the subroutine conditionally.
E.g.:
DATA R TYPE I.
PERFORM ZDIV USING P_INPUT1 P_INPUT2 CHANGING R.
WRITE R.
FORM ZDIV USING A TYPE I B TYPE I COMING C TYPE I.
CHECK B <> 0.

C = A + B.
ENDFORM.
Differences between Macros & Subroutines:Macros
1. In macro definition should be the
first & the calling should be the next.
2. The definition of the macro as
well as the calling of the macro in
the same program.
3. Macros can take up to 9 place
holders.
4. We can place any executable
statements after the definition of the
macro.
5. Macros are used in HR ABAP.

Subroutines
1. In subroutine calling should be the
first & definition should be the next.
2. The definition of the subroutine as
well as the calling of the subroutine
may or may not be in the same
program.
3. Subroutines can take any number
of place holders.
4. We cant place any executable
statements after the definition of the
macro.
5. Subroutines are used in both
ABAP & HR ABAP.

Global data:Subroutines can access the global declarations in which they are
defined.
When ever the changes occurred in the subroutine those changes will be reflected
to global declarations.
Note:LOCAL is the keyword to avoid the changes in subroutines.
E.g.:
TABLES T001.
T001-BUKRS = 1000.
T001-BUTXT = TCS.
T001-ORT01 = HYD.
PERFORM ZGLOBAL.
WRITE: / T001-BUKRS, T001-BUTXT, T001-ORT01.
FORM ZGLOBAL.
LOCAL T001.
T001-BUKRS = 2000.
T001-BUTXT = IBM.
T001-ORT01 = MUM.
WRITE: / T001-BUKRS, T001-BUTXT, T001-ORT01.
ENDFORM.
Function module:-

Function modules are reusable components that are defined in


functional library.
Each Function module must be attached with one Function group which
contains two include programs by default, one is for common subroutines, and
another one is for global declarations.
All the function modules under that function group can access the both the
include programs.
When ever we are calling the any function module then all the function modules
under that group will be loaded n to the memory of the calling program, so that
its better to group the related function modules in to one function group.
Global declarations

Subroutines
FM1
FM2
FM3

FG
Note:We can test the function module independently without calling the function
module.
Steps to create Function group: Execute SE37.
In the menu bar goto function groups create group.
Provide your function group name.
Provide short description.
Save local object.
Steps to activate the function group: Execute SE37.
In the menu bar environment inactive objects.
Expand your function group.
Select your function group.
Click on activate (in ECC 6.0 select function group right click activate).
Components of the function module:1.
2.
3.
4.
5.

Attributes.
Import.
Export.
Changing.
Tables.

6. Exception.
7. Source code.
1.Attributes:Attributes specify the type of the function module, normal or remote.
We can access the normal function module with in the server only, where as we can
access remote function modules with in the server as well as outside the server
also.
2. Import acts like using in the subroutine.
3. Export acts like changing the subroutine.
4. Changing acts like both import & export.
5. Tables acts like both import & export only for internal tables.
6. Exception use to handle the errors.
7. Source code the logic related to function module.
Differences between function module & subroutine:Function module
1. Function modules are global, i.e.,
we can access the function module
with in the server as well as outside
the server also.
2. We can test the function module
independently.
3. We can handle the errors in
function module.
4. Function modules are defined by
using SE37 transaction code.

Subroutine
1. Subroutines are local, i.e., we can
access the subroutine with in the
server only.
2. We cant test the subroutine
independently without calling the
subroutine.
3. We cant handle the errors in
subroutine.
4. Subroutines are defined by using
SE38 transaction code.

Steps to create function module:

Execute SE37.
Provide your function module name.
Create.
Provide function group name & short description.
Save.

Note:Function modules return single values, multiple single values so that we no


need to write any display statement.

Object:Develop a function module to calculate the addition of two numbers.


Program:IMPORT.
A TYPE I.
B TYPE I.
EXPORT.
C TYPE I.
SOURCE CODE.
C = A+ B.
Object:To develop the function module, to display the customers under given
company code.
Program:IMPORT.
P_BUKRS LIKE T001-BUKRS.
TABLES.
IT LIKE KNB1.
SOURCE CODE.
SELECT * FROM KNB1 INTO TABLE IT WHER BUKRS =
P_BUKRS.
Object:-

25/06/10.
To develop the function module, to display the material details, based on
the given material number.
Program:IMPORT.
P_MATNR LIKE MARA-MATNR.

EXPORT.
WA LIKE MARA.
EXCEPTIONS.
NO_DATA.
SOURCE CODE.
SELECT SINGLE * FROM MARA INTO TABLE WA WHER
MATNR = P_ MATNR.
IF SY-SUBRC <> 0.
RAISE NO_DATA.
ENDIF.
Steps to call a function module: Open the program.
Place the cursor where you want to call the function module & click on the
pattern.
Provide your FM name.
E.g.:
DATA X TYPE I.
PARAMETER: P_INPUT1 TYPE I,
P_INPUT2 TYPE I.
CALL FUNCTION 'YSAI_FM'
EXPORTING
A = P_INPUT1
B = P_INPUT2
IMPORTING
C = X.
WRITE X.

ALV (ABAP LIST VIEWER):ALV is used to display the output with predefined functionalities such as
1. Sort the list in ascending order
2. Sort the list in descending order
3. Filtering
4. Down the list
5. Change the layout
6. Send as attachment
7. Word processing
8. Excel sheet
9. Graphics
STEPS TO WORK WITH ALV:
1. Declare the final internal table and fill the data in internal table (the data we want display)
2. Prepare the field catalogue internal table (about the fields) i.e. .column position, column
heading, hotspot, emphasize, edit.
3. Call the REUSE_ALV_LIST__DISPLAY or REUSE_ALV_GRID_DISPLAY function
module
REUSE_ALV_GRID_DISPLAY:
It is function module which displays output in grid format.
REUSE_ALV_LIST_DISPLAY:
It is function module which used to display in list format.
The input for the above two function module is two internal tables
1. DATA INTERNAL TABLE
2. FIELD CATALOGUE INTERNAL TABLE
Program: to view the all data in the table.
DATA: IT_T001 LIKE TABLE OF T001.
SELECT * FROM T001 INTO TABLE IT_T001.
CALL FUNCTION REUSE_ALV_GRID_DISPLAY
EXPORTING
I_STRUCTURE_NAME = T001
TABLES
T_OUTTAB = IT_T001.
NOTE:

Whenever we working with all the fields form any one of the database table at that time
we no need to prepare field catalogue we simply pass I_STRUCTURE _NAME as Database
table name.
In this scenario function module picks the column headings from the data element of each
field and display fields in the similar order of the fields in the table.
PREPARE THE FIELD CATALOGUE:
Methode1: Whenever working with all the fields from any one of the database tables then we no
need prepare field catalogue we simply pass I_STRUCTURE_NAME as database table name.
Methode2: Manually filling field catalogue.
Metohde3: By using REUSE_ALV_FIELDCATALOG_MERGE function module.
REUSE_ALV_FIELDCATALOG_MERGE:
It is the function module which is used to prepare the field catalogue the input for the
above function module is data work area. If we are working with internal table with header line
then we pass internal table name
The output for the above function module is field catalogue internal table.
Some of the fields in Field Catalogue Internal Table:
FIELD NAME ---- Name of the field
COL_POS -------- Column Position
SELTEXT_S
SELTEXT_M
Column Heading
SELTEXT_L
HOTSPOT ---------Handle Symbol
EDIT----------------Change Mode
EMPHASIZE------ Colour
NO_OUT ---------- Hide the field
NO_ZERO -------- Remove the leading zeros
NO_SIGN -------- Internal table name
TABNAME ------- Remove the leading sign
OUTPUTLEN ---- Length of the field

S --- small
M --- medium
L --- long

NOTE:
In SLIS we have one type that is SLIS_T_FIELDCAT_ALV which contains the entire
fields related to field catalogue. So we simply declare field catalogue internal table by referring
SLIS_T_FIELDCAT_ALV.
NOTE:
SLIS is the type group which contains all the types related to ALV.
STEPS TO CREATE TYPE GROUP:

Execute SE80 (In ECC 6.0. SE 11).


Edit object in application toolbar.
Click on dictionary table
Select the radio button TYPE GROUP
Provide your Type Group Name, Click on Create.
Provide short text

SAVE

PROGRAM:
TYPE-POOL YSPRAO.
TYPES: BEGIN OF YSPRAO-T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF YSPRAO-T001.
SAVE, CHECK, ACTIVATE
NOTE: Whenever we are referring any type under any type group then we must include type
group name in the report (not in the report name)
Type-pools:
It is the key word which is used to include the any type group.
PROGRAM:
DATA WA_T001 TYPE YSPRRAO-T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001.
LOOP AT IT_T001 INTO WA_T001.
WRITE: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
ENDLOOP.
NOTE: EMPHASIZE = CXYZ
Where C = Colour
X = Colour Number
Y = Intensity
Z = Foreground/Background
1 Foreground, 2 Back ground.
NOTE: SY-CPROG is system variable which contains current program name.
OBJECT:
To display the purchasing document numbers, document type, vendor number by using
ALV.
REPORT YRAKESH_ALV_FCATMANUAL
.
TYPE-POOLS SLIS.
*** DECLARE IT.
DATA : BEGIN OF WA_EKKO,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
***FILL IT.
SELECT EBELN BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
*** DECLARE FIELDCATLOG.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FCAT LIKE LINE OF IT_FCAT.


*** FILLING THE FIELD CATALOG INT TABLE.
WA_FCAT-FIELDNAME = 'EBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_M ='PUR.DOC'.
WA_FCAT-HOTSPOT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
WA_FCAT-EMPHASIZE
APPEND WA_FCAT TO
CLEAR WA_FCAT.

= 'BSART'.
'2'.
='DOC.TYPE'.
= 'C110'.
IT_FCAT.

WA_FCAT-FIELDNAME = 'LIFNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M ='VENDOR'.
WA_FCAT-EDIT = 'X'.
WA_FCAT-NO_OUT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
***DISPLAY OUTPUT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
*
IS_LAYOUT
=
IT_FIELDCAT
= IT_FCAT
TABLES
T_OUTTAB
= IT_EKKO.

OBJECT:
To display customer numbers, names and cities by using
REUSE_ALV_FIELDCATLOG_MERGE in ALV.
Program:
REPORT

YRAKESH_ALV_FCAT_FM

TYPE-POOLS SLIS.
*** DECLARING IT
DATA: BEGIN OF WA_KNA1,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
ORT01 LIKE KNA1-ORT01,
END OF WA_KNA1.
DATA IT_KNA1 LIKE TABLE OF WA_KNA1.

***FILLING IT
SELECT KUNNR NAME1 ORT01 FROM KNA1 INTO TABLE IT_KNA1.
*** DECALRING FILE CAT IT
DATA IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.
***FILLING FIELD CATLOG
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_KNA1'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT.
***DISPLAY THE DATA
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= SY-CPROG
IT_FIELDCAT
= IT_FCAT
TABLES
T_OUTTAB
= IT_KNA1.
WORKING WITH EVENTS:
In ALV events are handled through SUB ROUTINES only whenever we working with
events then we must declare an internal table which contains two fields i.e. Event Name(NAME)
which form handle that event (FORM) .
NOTE:
In SLIS we have one type that is SLIS_T_EVENT which contains the above two fields
so that we simply declare our Event Internal Table by referring SLIS_T_EVENT.
NOTE:
REUSE_ALV_COMMENTARY_WRITE is the function module which is used to
display the text or comment in the TOP_OF_ PAGE or END_ OF_ LIST events. The input for
the above function module is an internal table which contains two fields that is
1. What to display (INFO)
2. How to display (TYP).
NOTE:
In SLIS we have one type that is SLIS_T_LISTHEADER which contains the above two
fields so that we simply declare the above two fields, so that simply declare internal tables by
referring SLIS_T_LISTHEADER.
STEPS TO UPLOAD LOGO IN ALV:
Execute OAER.
Provide CLASS NAME : Pictures
CLASS TYPE: OT
OBJECT KEY: YSPRAO (Any Name)
Execute or F8.
In Bottom Window

Expand Standard.Doc.Type
Double Click on SCREEN

Provide your Logo path


Enter

NOTE:
Whenever we are working with Events then we must pass I_CALLBACK_PROGRAM
as current program name in the Grid Display.
PROGRAM:
*&-----------------------------------------------------------*
*& Program to print TOP_OF_PAGE and END_OF_LIST Events
*
*------------------------------------------------------------*
REPORT YRAKESH_ALV_EVENTS
.
TYPE-POOLS SLIS.
*** DECLARING IT
DATA :BEGIN OF WA_FINAL,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
KUNNR LIKE KNB1-KUNNR,
AKONT LIKE KNB1-AKONT,
END OF WA_FINAL.
DATA IT_FINAL LIKE TABLE OF WA_FINAL.
***FILLING IT
SELECT T001~BUKRS T001~BUTXT KNB1~KUNNR KNB1~AKONT INTO TABLE
IT_FINAL
FROM T001 INNER JOIN KNB1 ON T001~BUKRS = KNB1~BUKRS.
*** DECALRING FILE CAT IT
DATA IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.
***FILLING FIELD CATLOG
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_FINAL'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT.
***DECLARE EVENT IT
DATA : IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF IT_EVENT.
***FILLING THE EVENT IT
WA_EVENT-NAME = 'TOP_OF_PAGE'.
WA_EVENT-FORM = 'ZTOP'.
APPEND WA_EVENT TO IT_EVENT.
WA_EVENT-NAME = 'END_OF_LIST'.
WA_EVENT-FORM = 'ZEOL'.
APPEND WA_EVENT TO IT_EVENT.
***DISPLAY THE DATA
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= SY-CPROG

IT_FIELDCAT
= IT_FCAT
IT_EVENTS
= IT_EVENT
TABLES
T_OUTTAB
= IT_FINAL.
**** DEFINING SUB ROUTINE
FORM ZTOP.
DATA : IT_LIST TYPE SLIS_T_LISTHEADER,
WA_LIST LIKE LINE OF IT_LIST.
WA_LIST-INFO = 'These r Customer under Company'.
WA_LIST-TYP = 'S'. " H->header, S->selection, A->action
APPEND WA_LIST TO IT_LIST.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY
= IT_LIST
I_LOGO
='YRAKESH'.
ENDFORM.
FORM ZEOL.
DATA : IT_LIST1 TYPE SLIS_T_LISTHEADER,
WA_LIST1 LIKE LINE OF IT_LIST1.
WA_LIST1-INFO = 'THAN Q'.
WA_LIST1-TYP = 'A'.
APPEND WA_LIST1 TO IT_LIST1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY
= IT_LIST1
I_END_OF_LIST_GRID
= 'X'.
ENDFORM.
USER_COMMAND:
It is an event which acts like both AT LINE SELCTION as well as AT USER
COMMAND in the ordinary reports.
It is Event which is triggered at the time of user click on any record of any list as well as
any menu item.
OBJECT:
Based on the given company codes to display the company code to display the
company codes, company names and cities by using ALV, whenever user clicks on company
code then We display the all the customers information under that company.
REPORT YRAKESH_ALV_IREP
TYPE-POOLS SLIS.
DATA V1 LIKE T001-BUKRS.
SELECT-OPTIONS S_BUKRS FOR V1 .
***DECLARE IT_TOO1.
DATA : BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
***DECLARE IT_KNB1.

DATA : BEGIN OF WA_KNB1,


KUNNR LIKE KNB1-KUNNR,
BUKRS LIKE KNB1-BUKRS,
AKONT LIKE KNB1-AKONT,
PERNR LIKE KNB1-PERNR,
END OF WA_KNB1.
DATA IT_KNB1 LIKE TABLE OF WA_KNB1.
***FILLING IT_T001.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001 WHERE BUKRS
IN
S_BUKRS.
***DECLARE IT_FCAT.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
***FILLING FIELD CATALOG.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_T001'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT.
******************************************
***DECLARE IT_FCAT FOR SECOND LIST.
DATA : IT_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT1 LIKE LINE OF IT_FCAT1.
***FILLING FIELD CATALOG FOR SECONDLIST.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_KNB1'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT1.
***DECLARING IT_EVENT.
DATA : IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF IT_EVENT.
***FILLING IT_EVENT.
WA_EVENT-NAME = 'TOP_OF_PAGE'.
WA_EVENT-FORM = 'ZTOP'.
APPEND WA_EVENT TO IT_EVENT.
WA_EVENT-NAME = 'END_OF_LIST'.
WA_EVENT-FORM = 'ZEOL'.
APPEND WA_EVENT TO IT_EVENT.
WA_EVENT-NAME = 'USER_COMMAND'.
WA_EVENT-FORM = 'ZUC'.
APPEND WA_EVENT TO IT_EVENT.

*** DISPLAY DATA


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= SY-CPROG
IT_FIELDCAT
= IT_FCAT
IT_EVENTS
= IT_EVENT
TABLES
T_OUTTAB
REFRESH IT_FCAT.
*** CALLING FORMS.
***DEF OF FORM ZTOP.

= IT_T001.

FORM ZTOP.
DATA : IT_LIST TYPE SLIS_T_LISTHEADER,
WA_LIST LIKE LINE OF IT_LIST.
WA_LIST-INFO = 'COMPANY DETAILS'.
WA_LIST-TYP = 'S'.
APPEND WA_LIST TO IT_LIST.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY
= IT_LIST
I_LOGO
= 'YRAKESH'.
ENDFORM.
***DEF OF FORM ZEOL.
FORM ZEOL.
DATA

: IT_LIST1 TYPE SLIS_T_LISTHEADER,


WA_LIST1 LIKE LINE OF IT_LIST1.
WA_LIST1-INFO = 'THAN Q'.
WA_LIST1-TYP = 'S'.
APPEND WA_LIST1 TO IT_LIST1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY
= IT_LIST1
I_END_OF_LIST_GRID
= 'X'

ENDFORM.
*** DEF OF FORM ZUC.
FORM ZUC USING A LIKE SY-UCOMM B TYPE SLIS_SELFIELD.
IF B-FIELDNAME = 'BUKRS'.
SELECT KUNNR BUKRS AKONT PERNR FROM KNB1 INTO TABLE IT_KNB1 WHERE
BUKRS = B-VALUE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING
IT_FIELDCAT
TABLES
T_OUTTAB

= IT_FCAT1
= IT_KNB1.

ENDIF.
ENDFORM.
Date: 28.06.2010.
SOME OF THE IMPORTANT TRANSACTION CODES.
XD03 ------Display Customer
XK03 ------ Display Vendor
MM03 ----Display Material
ME23N --- Display Purchase Order.
VA03 ----- Display Sales Order
MB03 ---- Display Material Document
FB03 ----- Display Accounting Document.
SYNTAX OF CALLING TRANSACTION:
CALL TRANSACTION <T-CODE>.
E.g. Call Transaction XK03.
SYNTAX OF SET THE VALUE TO THE TRANSACTION
SET PARAMETER ID <ID Name> FIELD <Value>.
E.g. SET Parameter ID LIF Field P5602.

STEPS TO IDENTIFY THE PARAMETER ID:

Execute the Transaction


Place Cursor on the field
Click on F1 and Click Technical Information (Hammer Symbol)
Identify the Parameter ID

OBJECT:
Based on the given Purchasing document number to display Purchasing Document
number, Document type, Vendor Number, Item Number and Quantity by using ALV. If user
clicks on any Purchasing Document Number (PO) then we display the Purchase Order details by
using ME23N transaction. If the user clicks on any Vendor then we display the vendor details by
using XK03 transaction.
HINT: EBELN, BSART, LIFNR, EBELP, MENGE
EKKO
EKPO
EBELN
EBELN
BSART
EBELP
LIFNR
MENGE
REPORT

YRAKESH_ALV_TRANS

TYPE-POOLS SLIS.
DATA V1 LIKE EKKO-EBELN.
SELECT-OPTIONS S_EBELN FOR V1 .
***DECLARE ITs
DATA : BEGIN OF WA_EKKO,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
DATA: BEGIN OF WA_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
COL(4) TYPE C,
END OF WA_EKPO.
DATA IT_EKPO LIKE TABLE OF WA_EKPO.
DATA : BEGIN OF WA_FINAL,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
END OF WA_FINAL.
DATA IT_FINAL LIKE TABLE OF WA_FINAL.
***FILLING DATA INTO ITS USING FOR ALL ENTRIES.
SELECT EBELN BSART LIFNR FROM EKKO INTO TABLE IT_EKKO WHERE EBELN
IN
S_EBELN.
IF NOT IT_EKKO IS INITIAL.
SELECT EBELN EBELP MENGE FROM EKPO INTO TABLE IT_EKPO FOR ALL
ENTRIES IN
IT_EKKO WHERE EBELN = IT_EKKO-EBELN.
ENDIF.
LOOP AT IT_EKPO INTO WA_EKPO.
WA_FINAL-EBELN = WA_EKPO-EBELN.
WA_FINAL-EBELP = WA_EKPO-EBELP.
WA_FINAL-MENGE = WA_EKPO-MENGE.
READ TABLE IT_EKKO INTO WA_EKKO WITH KEY EBELN = WA_EKPO-EBELN.
WA_FINAL-BSART = WA_EKKO-BSART.
WA_FINAL-LIFNR = WA_EKKO-LIFNR.
APPEND WA_FINAL TO IT_FINAL.
ENDLOOP.
***DECLARE CATALOG

DATA IT_FCAT TYPE SLIS_T_FIELDCAT_ALV.


DATA WA_FCAT LIKE LINE OF IT_FCAT.
***FILLING CATALOG
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_FINAL'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT.
***DECLARE IT EVENTS TAB.
DATA : IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF IT_EVENT.
*** FILLING IT EVENT
WA_EVENT-NAME = 'USER_COMMAND'.
WA_EVENT-FORM = 'ZUC'.
APPEND WA_EVENT TO IT_EVENT.
*** DISPLAY OUTPUT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= SY-CPROG
IT_FIELDCAT
= IT_FCAT
IT_EVENTS
= IT_EVENT
TABLES
T_OUTTAB
= IT_FINAL.
*** DEF OF ZUC.
FORM ZUC USING A LIKE SY-UCOMM B TYPE SLIS_SELFIELD.
IF B-FIELDNAME = 'LIFNR'.
SET PARAMETER ID 'LIF' FIELD B-VALUE.
CALL TRANSACTION 'XK03' AND SKIP FIRST SCREEN.
ELSEIF B-FIELDNAME = 'EBELN'.
SET PARAMETER ID 'BES' FIELD B-VALUE.
CALL TRANSACTION 'ME23N'.
ENDIF.
ENDFORM.
OBJECT:
To display the Material Numbers, Material types and Material Group by using ALV and
also provide the HOTSPOT to the Material and Red Colour to Material Group.
REPORT YRAKESH_ALV_MATARIAL
.
TYPE-POOLS SLIS.

***DECLARING IT
DATA: BEGIN OF WA_MARA,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
END OF WA_MARA.
DATA IT_MARA LIKE TABLE OF WA_MARA.
***FILLING IT_MARA
SELECT MATNR MTART MATKL FROM MARA INTO TABLE IT_MARA .
***DECLARING IT_FCAT.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
***FILLING IT_FCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_MARA'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT.
***CUSTOMIZING
WA_FCAT-HOTSPOT = 'X'.
MODIFY IT_FCAT FROM WA_FCAT TRANSPORTING HOTSPOT
WHERE FIELDNAME = 'MATNR'.
WA_FCAT-EMPHASIZE = 'C610'.
MODIFY IT_FCAT FROM WA_FCAT TRANSPORTING EMPHASIZE
WHERE FIELDNAME = 'MATKL'.
****DISPLAY OUT PUT
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT
= IT_FCAT
TABLES
T_OUTTAB
= IT_MARA.
Date: 29.06.2010

BLOCKED ALV:
Blocked ALV is used to display the output in Block wise.
STEPS TO WORK WITH BLOCKED ALV:
1. Intialize the Blocked ALV using REUSE_ALV_BLOCK_LIST_INIT function module.
The input for above function module is CURRENT PROGRAM NAME.
2. Append the each block/Internal table to blocked ALV by using
REUSE_ALV_BLOCK_LIST_APPEND
Function module
The input for the above function module is
1. Data Internal Table

2. Filed Catalogue Internal Table


3. Event Internal Table
4. Layout Work Area
o Repeat the same STEP 2 for all the internal tables.
3. Display the blocked ALV by Using REUSE_ALV_BLOCK_LIST_DISPLAY function
module.
OBJECT:
Based on given Purchasing Document numbers to display the Document Header Details
(EBELN,BSART,LIFNR,BUKRS) and Item Details
(EBELN,EBELP,MENGE,MEINS,NERPR) By using Blocked ALV.
REPORT YRAKESH_BALV_PODETAILS
.
TYPE-POOLS SLIS.
DATA V1 LIKE EKKO-EBELN.
SELECT-OPTIONS S_EBELN FOR V1.
***DECLARE IT TABLES.
DATA : BEGIN OF WA_EKKO,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
BUKRS LIKE EKKO-BUKRS,
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
DATA: BEGIN OF WA_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF WA_EKPO.
DATA IT_EKPO LIKE TABLE OF WA_EKPO.
***FILL THE IT TABLES.
SELECT EBELN BSART LIFNR BUKRS FROM EKKO INTO TABLE IT_EKKO
WHERE
EBELN IN S_EBELN.
IF NOT IT_EKKO IS INITIAL.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE
IT_EKPO FOR
ALL ENTRIES IN IT_EKKO WHERE EBELN = IT_EKKO-EBELN.
ENDIF.
***DECLARE IT_FCAT.
DATA : IT_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,
IT_FCAT2 TYPE SLIS_T_FIELDCAT_ALV.
***FILL IT_FCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING

I_PROGRAM_NAME
I_INTERNAL_TABNAME
I_INCLNAME
CHANGING
CT_FIELDCAT

= SY-CPROG
= 'WA_EKKO'
= SY-CPROG
= IT_FCAT1.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'


EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_EKPO'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT2.
***DECLARE IT_EVENT.
DATA: IT_EVENT1 TYPE SLIS_T_EVENT,
IT_EVENT2 TYPE SLIS_T_EVENT.
*** DECLARE WA_LAYOUT.
DATA: WA_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
WA_LAYOUT2 TYPE SLIS_LAYOUT_ALV.
***INTIALIZE BLOCKED ALV.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM
= SY-CPROG.
***APPENDING BLOCK LIST.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT
= WA_LAYOUT1
IT_FIELDCAT
= IT_FCAT1
I_TABNAME
= 'IT_EKKO'
IT_EVENTS
= IT_EVENT1
TABLES
T_OUTTAB
= IT_EKKO.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT
= WA_LAYOUT2
IT_FIELDCAT
= IT_FCAT2
I_TABNAME
= 'IT_EKPO'
IT_EVENTS
= IT_EVENT2
TABLES
T_OUTTAB
= IT_EKPO.
***DISPLAY OUTPUT.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
OBJECT: (ASSIGNMENT):
Based on given Company codes to display the company details
(BUKRS,BUTXT,ORT01) & Customers details under Company (BUKRS,KUNNR,AKONT)
and display Customer Bank Details (KUNNR,BANKS,BANKL,BANKN) by using Blocked
ALV.

REPORT

YRAKESH_BALV_3TAB

TYPE-POOLS SLIS.
DATA V1 LIKE T001-BUKRS.
SELECT-OPTIONS S_BUKRS FOR V1.
***DECLARE IT TABLES.
DATA : BEGIN OF WA_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
DATA : BEGIN OF WA_KNB1,
KUNNR LIKE KNB1-KUNNR,
BUKRS LIKE KNB1-BUKRS,
AKONT LIKE KNB1-AKONT,
PERNR LIKE KNB1-PERNR,
END OF WA_KNB1.
DATA IT_KNB1 LIKE TABLE OF WA_KNB1.
DATA: BEGIN OF WA_KNBK,
KUNNR LIKE KNBK-KUNNR,
BANKS LIKE KNBK-BANKS,
BANKL LIKE KNBK-BANKL,
BANKN LIKE KNBK-BANKN,
END OF WA_KNBK.
DATA IT_KNBK LIKE TABLE OF WA_KNBK.
***FILL THE IT TABLES.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001 WHERE BUKRS
IN
S_BUKRS.
IF NOT IT_T001 IS INITIAL.
SELECT KUNNR BUKRS AKONT PERNR FROM KNB1 INTO TABLE IT_KNB1
FOR ALL
ENTRIES IN IT_T001 WHERE BUKRS = IT_T001-BUKRS.
ENDIF.
IF NOT IT_KNB1 IS INITIAL.
SELECT KUNNR BANKS BANKL BANKN FROM KNBK INTO TABLE IT_KNBK
FOR ALL
ENTRIES IN IT_KNB1 WHERE KUNNR = IT_KNB1-KUNNR.
ENDIF.
***DECLARE IT_FCAT.
DATA : IT_FCAT1 TYPE SLIS_T_FIELDCAT_ALV,
IT_FCAT2 TYPE SLIS_T_FIELDCAT_ALV,
IT_FCAT3 TYPE SLIS_T_FIELDCAT_ALV.
***FILL IT_FCAT.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'


EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_T001'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT1.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_KNB1'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT2.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME
= SY-CPROG
I_INTERNAL_TABNAME
= 'WA_KNBK'
I_INCLNAME
= SY-CPROG
CHANGING
CT_FIELDCAT
= IT_FCAT3.
***DECLARE IT_EVENT.
DATA: IT_EVENT1 TYPE SLIS_T_EVENT,
IT_EVENT2 TYPE SLIS_T_EVENT,
IT_EVENT3 TYPE SLIS_T_EVENT.
*** DECLARE WA_LAYOUT.
DATA: WA_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
WA_LAYOUT2 TYPE SLIS_LAYOUT_ALV,
WA_LAYOUT3 TYPE SLIS_LAYOUT_ALV.
***INTIALIZE BLOCKED ALV.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM
= SY-CPROG.
***APPENDING BLOCK LIST.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT
= WA_LAYOUT1
IT_FIELDCAT
= IT_FCAT1
I_TABNAME
= 'IT_T001'
IT_EVENTS
= IT_EVENT1
TABLES
T_OUTTAB
= IT_T001.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT
= WA_LAYOUT2
IT_FIELDCAT
= IT_FCAT2

I_TABNAME
IT_EVENTS
TABLES
T_OUTTAB

= 'IT_KNB1'
= IT_EVENT2
= IT_KNB1.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'


EXPORTING
IS_LAYOUT
= WA_LAYOUT3
IT_FIELDCAT
= IT_FCAT3
I_TABNAME
= 'IT_KNBK'
IT_EVENTS
= IT_EVENT3
TABLES
T_OUTTAB
= IT_KNBK.
***DISPLAY OUTPUT.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

HIERARCHICAL ALV:
This is used to display the Header and Item Details in Hierarchical Manner.
REUSE_ALV_HIERSEQ_ LIST_DISPLAY:
It is function module which is used to display the output in hierarchical manner the input
for the above function module is two Data Internal Tables (Header, Item), Field Catalogue
Internal Table, Key Information (linking fields of Header and Item)
*&--------------------------------------------------------------------*
* To display Purchasing Document header and item details by using
* heirarchical ALV Based on Purchasing document No.
*&--------------------------------------------------------------------*
REPORT

YRAKESH_ALV_HIER_EKKOEKPO

TYPE-POOLS SLIS.
DATA V1 LIKE EKKO-EBELN.
SELECT-OPTIONS S_EBELN FOR V1.
***Declaring Data ITs.
DATA : BEGIN OF WA_EKKO,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
BUKRS LIKE EKKO-BUKRS,
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
DATA : BEGIN
EBELN
EBELP
MENGE
MEINS
NETPR

OF WA_EKPO,
LIKE EKPO-EBELN,
LIKE EKPO-EBELP,
LIKE EKPO-MENGE,
LIKE EKPO-MEINS,
LIKE EKPO-NETPR,

COL(4) TYPE C,
END OF WA_EKPO.
DATA IT_EKPO LIKE TABLE OF WA_EKPO.
***Filing Data ITs.
SELECT EBELN BSART LIFNR BUKRS FROM EKKO INTO TABLE IT_EKKO WHERE
EBELN
IN S_EBELN.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO
WHERE
EBELN IN S_EBELN.
WA_EKPO-COL = 'C910'.
MODIFY IT_EKPO FROM WA_EKPO TRANSPORTING COL WHERE NETPR > 1000.
***Declaring Field Catalogue IT.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
*** Filling Field Catalogue IT.
WA_FCAT-FIELDNAME = 'EBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_M = 'PUR.DOC'.
WA_FCAT-TABNAME = 'IT_EKKO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'BSART'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'DOC.TYP'.
WA_FCAT-TABNAME = 'IT_EKKO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'LIFNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'VEN.NUM'.
WA_FCAT-TABNAME = 'IT_EKKO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'BUKRS'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_M = 'CO.CODE'.
WA_FCAT-TABNAME = 'IT_EKKO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
WA_FCAT-TABNAME =

= 'EBELN'.
'1'.
= 'PUR.DOC'.
'IT_EKPO'.

APPEND WA_FCAT TO IT_FCAT.


CLEAR WA_FCAT.
WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
WA_FCAT-TABNAME =

= 'EBELP'.
'2'.
= 'DOC.TYP'.
'IT_EKPO'.

APPEND WA_FCAT TO IT_FCAT.


CLEAR WA_FCAT.
WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
WA_FCAT-TABNAME =

= 'MENGE'.
'3'.
= 'QTY'.
'IT_EKPO'.

APPEND WA_FCAT TO IT_FCAT.


CLEAR WA_FCAT.
WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
WA_FCAT-TABNAME =

= 'MEINS'.
'4'.
= 'UOM'.
'IT_EKPO'.

APPEND WA_FCAT TO IT_FCAT.


CLEAR WA_FCAT.
WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
WA_FCAT-TABNAME =

= 'NETPR'.
'5'.
= 'PRICE'.
'IT_EKPO'.

APPEND WA_FCAT TO IT_FCAT.


CLEAR WA_FCAT.
*** Declaring WA for key
DATA : WA_KEY TYPE SLIS_KEYINFO_ALV.
***Filling the Key Info.
WA_KEY-HEADER01 = 'EBELN'.
WA_KEY-ITEM01 = 'EBELN'.
***Displaying Output.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= SY-CPROG
IT_FIELDCAT
= IT_FCAT

I_TABNAME_HEADER
I_TABNAME_ITEM
IS_KEYINFO
TABLES
T_OUTTAB_HEADER
T_OUTTAB_ITEM

= 'IT_EKKO'
= 'IT_EKPO'
= WA_KEY
= IT_EKKO
= IT_EKPO.

BKPF (Accounting Document Header Table)\


BELNR ---Accounting Document Number
GJAHR ---Fiscal Year
BUKRS --- Company Code
BLART --- Document Type
BUDAT --- Posting Date
BLDAT ---Document Date
BSEG (Accounting Document Item Table)
BELNR ---Accounting Document Number
GJAHR ---Fiscal Year
BUKRS --- Company Code
BUZEI --- Item
DMBTR --- Amount in Local Currency
WRBTR --- Amount in Document Currency
OBJECT: ASSIGNMENT
To display the Accounting Document Header and Item details by Using
Hierarchical ALV based given financial year.

REPORT

YRAKESH_HIRARCHICAL_ALV1

TYPE-POOLS SLIS.
DATA V1 LIKE BKPF-GJAHR.
SELECT-OPTIONS S_GJAHR FOR V1.
DATA V2 LIKE BKPF-BUKRS.
SELECT-OPTIONS S_BUKRS FOR V2.
***DECLARING IT TABLES.
DATA : BEGIN OF WA_BKPF,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
BUKRS LIKE BKPF-BUKRS,
BLART LIKE BKPF-BLART,
BUDAT LIKE BKPF-BUDAT,
BLDAT LIKE BKPF-BLDAT,
END OF WA_BKPF.
DATA IT_BKPF LIKE TABLE OF WA_BKPF.
DATA : BEGIN OF WA_BSEG,
BELNR LIKE BSEG-BELNR,

GJAHR LIKE BSEG-GJAHR,


BUKRS LIKE BSEG-BUKRS,
BUZEI LIKE BSEG-BUZEI,
DMBTR LIKE BSEG-DMBTR,
WRBTR LIKE BSEG-WRBTR,
END OF WA_BSEG.
DATA IT_BSEG LIKE TABLE OF WA_BSEG.INCLUDE YRAKESH_IT_BKPF.
INCLUDE YRAKESH_IT_BSEG.
***FILLING IT
SELECT BELNR GJAHR BUKRS BLART BUDAT BLDAT FROM BKPF INTO TABLE
IT_BKPF
WHERE GJAHR IN S_GJAHR AND BUKRS IN S_BUKRS.
SELECT BELNR GJAHR BUKRS BUZEI DMBTR WRBTR FROM BSEG INTO TABLE
IT_BSEG
WHERE GJAHR IN S_GJAHR AND BUKRS IN S_BUKRS.
***DECLARE IT_FCAT.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
***FILLING FIELD CATALOG
*** FILLING FOR BKPF(ACCOUNT DOCUMENT HEADER)
WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'BELNR'.
'1'.
= 'ACC.DOC.NO'.
'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'GJAHR'.
'2'.
= 'FISCAL YR'.
'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'BUKRS'.
'3'.
= 'COMPANY CODE'.
'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-OUTPUTLEN

= 'BLART'.
'4'.
= 'A/C_DOC_TY'.
= '8'.

WA_FCAT-TABNAME = 'IT_BKPF'.
APPEND WA_FCAT TO IT_FCAT.
WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'BUDAT'.
'5'.
= 'POST_DATE'.
'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'BLDAT'.
'6'.
= 'DOC_DATE'.
'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.


***FILLING FOR BSEG(ACCOUNTING ITEM TABLE)
WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'BELNR'.
'1'.
= 'ACC.DOC.NO'.
'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'GJAHR'.
'2'.
= 'FISCAL YR'.
'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'BUKRS'.
'3'.
= 'COMPANY CODE'.
'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'BUZEI'.
'4'.
= 'ITEM'.
'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'DMBTR'.
'5'.
= 'LOCAL_CURR.'.
'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.


WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_S
WA_FCAT-TABNAME =

= 'WRBTR'.
'6'.
= 'DOC_CURR.'.
'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.


DATA WA_KEY TYPE SLIS_KEYINFO_ALV.
*DATA WA_KEY LIKE LINE OF IT_KEY.
***FILING THE KEY INFO .
WA_KEY-HEADER01 = 'BELNR'.
WA_KEY-ITEM01 = 'BELNR'.
WA_KEY-HEADER02 = 'GJAHR'.
WA_KEY-ITEM02 = 'GJAHR'.
WA_KEY-HEADER03 = 'BUKRS'.
WA_KEY-ITEM03 = 'BUKRS'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
IT_FIELDCAT
= IT_FCAT
I_TABNAME_HEADER
= 'IT_BKPF'
I_TABNAME_ITEM
= 'IT_BSEG'
IS_KEYINFO
= WA_KEY
TABLES
T_OUTTAB_HEADER
= IT_BKPF
T_OUTTAB_ITEM
= IT_BSEG.
<write prog here>
Date: 30.06.2010
WORKING WITH GUI IN ALV:
In the real time we always copy existing GUI and add the additional menu
items to that GUI.
NOTE: SAPLKKBL is the standard program which contains Standard GUI.
NOTE: PF_STATUS_SET is the event which is used to attach our own GUI to the
program in ALV.
SOME OF THE FIELDS OF LAYOUT WORK AREA:
1. COLWIDTH_OPTIMIZE ---------------Compress the field width Active = x, Inactive
=
2. ZEBRA
---------------Stripped Pattern
3. INFO_FIELDNAME
---------------Colour
STEPS TO WORK WITH ROW COLOUR:
1. Add one colour field in Data internal table which is of Data type CHAR
length 4.
2. After filling the data internal table, we modify the colour field based on
condition.
3. Pass the colour field name in the lay work area. 135,000

STEPS TO COPY THE EXISTING GUI:


Execute SE 41
Click on STATUS in Application tool bar.
Provide FROM
PROGRAM: SAPLKKBL
STATUS: Standard- FullScreen.
To
PROGRAM: YSPRAO_GUI (Your program name)
STATUS: STAT (Your program Status).
Click on COPY
OBJECT:

*&--------------------------------------------------------------------*
*To display Purchasing doc no.,Item no's,Quantity,UOM and
Netprice by
*using ALV and also diplay the purchase documents no.in RED color
if the
* amount is more than thousand and also add one menu item
(DOWNLOAD) in
*application tool bar if we are clicking on Download Button the
we
*download data into Desktop .
*&--------------------------------------------------------------------*
REPORT

YRAKESH_ALV_GUI

TYPE-POOLS SLIS.
DATA V1 LIKE EKPO-EBELN.
SELECT-OPTIONS S_EBELN FOR V1.
***DECLARE DATA IT.
INCLUDE YRAKESH_IT_EKPO.
***FILLING DATA IT.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE
IT_EKPO WHERE
EBELN IN S_EBELN.
WA_EKPO-COL = 'C610'.
MODIFY IT_EKPO FROM WA_EKPO TRANSPORTING COL WHERE NETPR > 1000.
***DECLARE FIELDCATALOG IT.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
***FILLING FIELDCATLOG IT.

WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
APPEND WA_FCAT TO
CLEAR WA_FCAT.

= 'EBELN'.
'1'.
= 'PUR_DOC_NO'.
IT_FCAT.

WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
APPEND WA_FCAT TO
CLEAR WA_FCAT.

= 'EBELP'.
'2'.
= 'ITEM NO'.
IT_FCAT.

WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
APPEND WA_FCAT TO
CLEAR WA_FCAT.

= 'MENGE'.
'3'.
= 'Quantity'.
IT_FCAT.

WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
APPEND WA_FCAT TO
CLEAR WA_FCAT.

= 'MEINS'.
'4'.
= 'UOM'.
IT_FCAT.

WA_FCAT-FIELDNAME
WA_FCAT-COL_POS =
WA_FCAT-SELTEXT_M
APPEND WA_FCAT TO
CLEAR WA_FCAT.

= 'NETPR'.
'5'.
= 'PRICE'.
IT_FCAT.

***DECLARE WORK AREA FOR

LAY OUT.

DATA WA_LAYOUT TYPE SLIS_LAYOUT_ALV.


***FILLING LAYOUT WA.
WA_LAYOUT-INFO_FIELDNAME = 'COL'.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
WA_LAYOUT-ZEBRA = 'X'.
***DECLARE IT EVENT.
DATA : IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF IT_EVENT.
***FILL THE IT EVENT.
WA_EVENT-NAME = 'PF_STATUS_SET'.
WA_EVENT-FORM = 'ZPSS'.
APPEND WA_EVENT TO IT_EVENT.
CLEAR WA_EVENT.

WA_EVENT-NAME = 'USER_COMMAND'.
WA_EVENT-FORM = 'ZUC'.
APPEND WA_EVENT TO IT_EVENT.
CLEAR WA_EVENT.
***DISPLAY O/P.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM
= SY-CPROG
IS_LAYOUT
= WA_LAYOUT
IT_FIELDCAT
= IT_FCAT
IT_EVENTS
= IT_EVENT
TABLES
T_OUTTAB
= IT_EKPO.
***FILLING THE FORMS
FORM ZPSS USING A TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STAT'.
ENDFORM.
FORM ZUC USING B LIKE SY-UCOMM C TYPE SLIS_SELFIELD.
IF B = 'DOWN'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILETYPE
TABLES
DATA_TAB

= 'DAT'
= IT_EKPO.

ENDIF.
ENDFORM.
To display the Purchasing Document , items
<write Questions Here>

2/7/10

MODULE POOL PROGRAMMING

Transaction /Dialog pool programming /Module pool programming


A transaction is the collection of sequential screen which accept the input and display the
output.
Screen 1000
Screen 2000
Module pool program
SE38

DB
SE11

Screen painter SE51

Screen painter SE41


-This is also called dialog pool programming since we have an interaction b/n screen.
-It is also called module programming because the flow logic of each screen acts as module.
-A transaction contains either executable program or module pool program.
Difference between executable program and module pool program
Executable
Module pool
-we can execute an executable program
independently without depends on an other
program

We cant execute a module pool program


independently through transaction code only
we can execute the module pool program

The type of the executable program is 1


All the standard reports are executable
programs

Type of the module pool program is M


All the standard transactions are module pool
program.
(xd01, xk01.)

Steps to create the transaction code for executable program


-execute SE93
-provide the any transaction code
-click on create
-provide short description
-select on selection screen
Program and selection screen
-Enter
-provide the program name
(Ex: our program zven_alv)

Note:
In the real time we always create the transaction code for any executable program
Steps to work with module pool program
1.
Create a module pool program and implement the retrieving logic
2.
Design the required screen and attach to the program
3.
Design the required menus and attach to the screen
4.
Design the database table based on client requirement
Note:
-the above four transaction codes we can work with in a single transaction i.e. SE80
Steps to create a module pool program
-Execute SE80
-click on edit object
-select the program tab
-provide your program
click on create
-remove top include
with top incl
-enter
-select on type is module pool
Type Module pool
-save
-local object
-in the left panel select the program.
-Provide your program
-save
Working with screen painter
-Screen painter is a tool which contain both graphical as well as alpha numerical mode.
Components of Screen painter
1. Attribute
2. Layout
3. Element list
4. Flowlogic editor
1. Attrivbute: Attribute specify the type of the screen either normal or sub screen or dialog screen
2. Layout: Layout is the collection of screen element that input/output screen, push button, radio
button, check box, table control.
3. Element list: Elements list contains the entire screen element which design in the current
screen and this data types and length.
4. Flow logic editor: Flow logic editor contains logic related to the screen.
- The linking or communication b/n flow logic editor to abap editor is always through
screen element that is each element in the screen that should be an equalent declaration is
available in abap editor.
Event in flow logic editor
1. PBO (Process before Output)
2. PAI (Process after Input)
3. POV (Process on Value Request)
4. POH (Process on Help request)
1. PBO: It is an event which is trigger before displaying the screen.
-this is used to provide the default values to the screen.
2. PAI: It is an event which is triggers often providing the input to the screen.
-this is used to implement the logic.
3. POV: is an event which is trigger at the time of user clicks on f4 button.
-this is used to provide the list of possible values to the given input variable.

4. POH: is an event which trigger at the time of user clicks on F1 button.


-this is used to provide the help (F1) documentation.
Steps to Design the screen
-select the program in the left panel.
-right click
-create
Screen
-provide the screen number
-provide short description
-save
-click on Layout
-Design the screen as per the client requirement

Input1
Input2
Result

BAC

FCOD-BAK

ADDITIO

FCOD-ADD

-Save
-Back.
Steps to activate the program
-Double click on program in the left panel
-Right click
-Activate
Steps to execute transaction code
-select the program in left panel
-right click
-create
Transaction
-provide your transaction code
-provide short description
-enter
-select first radio button.
-Provide program name
-screen no
Step to execute the program
-select the transaction code in the left panel
-right click
-execute
Direct processing
Source code:

-save.

5/7/10
Program

Screen 1

Leave program

Screen 2

leave to screen 0

Screen 3

leave to screen 0

Obi

ccode
cname
city

INSERT

BACK

FCOD-BAK

TOO1

FCOD-ADD

-Save
-Back.
Note:
-if we want to design the screen with db fields then open the screen (layout) click on F4
(dictionary program field)
-provide your db table name
-enter
-select your require fields
-enter.
Source code:
Obi
-create table
ZVENEQF
ENO

10

25

15

EMAIL

C
C

25
10

COURSE

10

NAME
PHONE NO

ZTIME

SCREEN 1000
ENO
Name
PHONE
NEXT

BACK

SCREEN 2000

COURSE
TIMING
SAVE

BACK

VRM-SETT-VALUES:
-Is the function module which is used to provide dropdown list to the any input variable.
-The input for the above function module is field name for which field we want to
provide dropdown list.
-An internal table of which contains two fields that are key and text
NOTE:
-In VRM we have type that is VRM_VALUES which contains the above two fields. So, that
we simple declare our internal table by referring VRM-VALUES.
-If we want to provide mask double click on field (in the Layout)
-In the attribute
Program
Input Not possible
If we want to provide field as a mandatory

-double click on field


-In the attribute
Program
Input

Required

If we want to provide the password


-double click on field
-in the attribute click on display tab
Invisible

CODE
Working with table control
-table control is used to display the multiple records in a tabular format.

Syntax of declaring the table control in the abap editor


CONTROLS <TABLE CONTROL NAME> TYPE TABLEVIEW USING SCREEN
<SCREEN >
EX:
CONTROLS TBC TYPE TABLEVIEW USING SCREEN 2000.
Syntax of transfer data from internal table of table control
LOOP AT <INTERNALTABLE NAME> INTO <WORKAREA> WITH CONTROL
<TABLE CONTROL> CURSOR <TABLE CONTOLSANME> CURSOR
<TABLECONTROLNAME>-CUUREN_LINE.
//MOVE THE DATA FROM <WA> TO <TABLE CONTROL>.
ENDLOOP.
NOTE:
- whenever we are maintaining the table control field like work area field name then we
no need to move the data from work area to the control.
-whenever we are working with loop and end loop in any one of the event then we
must declare a dummy loop and end loop in another event .
-the loop and end loop in the event PAI loops the information of table control.
Ranges:
- is the keyword which accept single value multiple single values, single range and
multiple ranges.
Syntax:
RANGES <NAMEOF THE RANGE> FOR <VARIABLE NAME>
EX:
DATA V1 LIKE T001-BUKRS.
RANGES R-BUKRS FOR V1.
-The name of range acts as internal table with header line.
-That mean the name of the work area and name of the internal table is same as the
ranges.
For multiple inputs

Ranges

selection-option

Low, high,
Sign, option
It wont provide any screen
To enter the input.

There is no default values

it provide a screen to enter the


Input values.

by default sign = I
Option = BT

Both are used in where condition.

7/7/10
SCREEN 1000
CCODE

TO
DISPL
AY

SE
L

CCODE

BACK

CUSTOME RECON
R

Download

Attribute

Line sel

Back

multiple and selcol

Code
WORKING WITH SUBSCREEN ARES
-Sub screen area must be placed in normal screen only.

SE
L

-each sub screen area can call only one sub screen at a time.
Syntax of include or calling the sub screen into sub screen areas
Call subsreen <sub screen area name> including <program name> <screen no>
EX:
CALL SUBSCREEN SA1 INCLUDING SY-REPID 100.
NOTE:
SY-REPID: Is the system variable which contains the current program name.
-if we want to enable the PAI of sub screens then we must call the sub screen area name
in the PAI of normal screen.
Screen
Code
Working with tab strip control
-tab strip is the strip of tab each tab contains only one sub screens area.
-each sub screen area can call only one sub screen at a time.
- By default tab strip contains 2 tabs.
-only one tab is always active.
Declaring the tab strip in the ABAP editor
CONTROLS <TAB STRIP NAME> TYPE TABSTRIP.
EX: CONTROLS TBC TYPE TABSTRIP.
By default the PBO of each screen contains GUI title and GUI status
Syntax of active the tab
<TAB STRIP NAME>-ACTIVE TAB = <TAB NAME> .
EX:
TBC-ACTIVETAB = TAB1.
SCREEN
CODE
Working with process on value request (POV)
Note
-F4IF_INT-_TABLE_VALUE_REQUEST is the function is module which is used to
provide the list of possible values to the input variable.
- The input for the above function module is
-data internal table
-return field of data internal table
-field name (for which field we want to provide list of possible
value)
-screen no (the field is available in which screen)
-program name (screen is attached to which program)

Obi
Screen
Code

Note
-leave to list-processing: is used to display the output like in ordinary reports

9/9/10
Working with validation
-there are three type of validation
1. System validation

2. Validation at flow logic editor


3. Validation at abap editor
1. System validation:
-whenever we are working with date and range of input then the system perform
validation.
That is the given data is valid format or not.
-the lower limit is less then upper limit or not.
-system automatically perform this validation.
2. Validation at flow logic editor
Note: validation always done at PAI event.
Syntax:
FIELD <FIELDNAME> VALUES (VALUES1, VALUES2-----).
For which field we want to validate
Ex:
FIELD VALUES (1000,2000).
3. Validation at abap editor
Syntax:
FIELD <FIELDNAME > MODULE <MODULE NAME>
For which field we want to validate
Chain and end chain
-is used to validate the related field.
-if we no using chain and end chain then if display the only; error field in enable mode
other field in disable mode, it means we cant change the other then error field information.
-if we are using chain and end chain then it display all the fields (error and non error fields) in
enable mode.
Note
-when ever we are working with validation then back button is not working if you pass invalid
input.
-if we want enable the back button functionality or exit button functionality then we must
provide function type is E at the time of funcode.
-and we also implement the logic in the module of at EXIT-COMMAND.
OBJ
SCREEN
CODE
-Syntax of calling the executable program from module pool program.
SUBMIT <EXECUTABLE PROGRAM NAME> VIA SELECTION-SCREEN.
OBJ
SCREEN
CODES

SAP SCRIPT

If you want to print the business document such as invoice. purchase order. sales order etc... We
need LAYOUTs. Layouts are designed through FORMS.
SAP-SCRIPT is a tool used to design the business documents. The SAP provides layouts for
almost all the applications. Most of the time ABAPer job is changes the layout or adding some addition
logic to the STANDARD DRIVER PROGRAM. Driver program is used to retrieving the data from the
database and transferred to the LAYOUT SET.
Components of SAP-SCRIPT:
1. LAYOUT
2. DRIVER PROGARM
Component of LAYOUT:
1. HEADER
2. PAGES
3. WINDOWS
4. PAGE WINDOWS
5. PARAGRAPH FORMATS
6. CHARACTER FORMATS
7. DOCUMENTATION
1.
HEADER:
Header is used to maintain the administrative information. i.e.. FORM NAME, LANGUAGE,
PAGE FORMAT, FIRST PAGE and DEFAULT PARAGRAPH (Default Settings).
2.
PAGES:
Page is the physical area where we can place the window. We can not print the text on page.
3.
WINDOWS:
We can place the same window in multiple pages. We can not print the text on window.
4.
PAGE WINDOWS:
Page window is nothing but placing the window on the page with co-ordinates (Left. Upper.
Width and Height). We can print text only on the page windows.
5.
PARAGRAPH FORMATS:
Paragraph format is used to align the entire PARAGRAPH with same font and same font type.
6.
CHARACTER FORMATS:
Character format is used to align the particular text with same font and same font type.
7.
DOCUMENTATION:
This is used to maintain the documentation related to FORM.
NOTE: The transaction code for form painter is SE71.
Steps to design the LAYOUT/FORM:
1. Execute SE71, Provide your form name, Click on CREATE. ENETER. Provide short description.
2. Click on PAGES (Application tool bar). In the MENU BAR click on EDIT -> Create Element.
Provide your page name and Description.
3. Click on WINDOWS (Application tool bar). In the MENU BAR click on EDIT -> Create
Element. Provide your window name and Description.
4. Click on Page Windows (Application tool bar). In the MENU BAR click on EDIT -> Create
Element. Select the required window provide left. upper margins. width and height.
Repeat for all the WINDOWS.

MAIN WINDOW is the default window in SAP-SCRIPT. We can place the main Window up to 99
times per page (00 to 98).
5. Click on PARAGRAPH FORMAT (Application tool bar). Provide paragraph format name (any
name) Enter. Provide short description provide FONT. TABS. etc save.
6. Click on HEADER, Click on basic settings provide your first page and default paragraph. save.
Steps to open the LAYOUT:
1. In the menu bar click on settings -> form painter. select the check box graphic form painter. Enter.
2. In the application tool bar click on layout. align the layout activate.
NOTE: Printing the DATA on the page window is always through SYMBOLS. Each symbol start with &
and ends with &.
There are four types of symbols.
1. PROGRAM SYMBOLS
2. SYSTEM SYMBOLS
3. STANDARD SYMBOLS
4. TEXT SYMBOLS
1.
PROGRAM SYMBOLS:
These are the program variables. i.e.. &WA_T001-BUKRS&
&WA_MCHA-CHARG&
2.
SYSTEM SYMBOLS:
These are the system variables. i.e.. &DATA& &TIME&
3.
STANDARD SYMBOLS:
These are coming from the TTDTG Standard Table.
Example:
&Mr.& &Mrs.&
4.
TEXT SYMBOLS:
These are the variables which are defined in page window. Example:
DEFINE &a&.
Steps to transfers the data from driver program to LAYOUT:
1. Create an executable program and implement all the retrieving logic.
2. Access the layout from the DRIVER PROGRAM by using OPEN_FORM function module. The
input for this function module is FORM NAME.
3. Transfers the DATA from the DRIVER PROGRAM to PARTICULAR WINDOW by using
WRITE_FROM function module. The input for this function module is WINDOW NAME.
Repeat the same step for all the WINDOWs.
4. Close the form by using CLOSE_FORM function module. No input for this function module.
Steps to place the SYMBOLS on the PAGE WINDOW:
1. Execute SE71. Provide your form name and click on change mode.
2. Click on PAGE WINDOWS. Double click on your WINDOW. Click on text element (left side of
header tab).
COCODE:
&WA_T001-BUKRS&
CNAME:
& WA_T001-BUTXT&
CCITY:
& WA_T001-ORTO1&
Come back. Save and activate (form activate).
Text Element:
Text element is the name given to the black of elements in the page window. The text element
name is followed by /E.
If we pass text element name in the WRITE_FORM function module then WRITE_FORM
transfers the data from driver program to all the statements which are defined under text element.
/E
*
*
*

SURYA
COCODE:
&WA_T001-BUKRS&
CNAME:
& WA_T001-BUTXT&
CCITY:& WA_T001-ORTO1&

CALL FUNCTION WRITE_FORM


Exporting
ELEMENT
:
SURYA
WINDOW
:
ADDRESS.

Working with LOGO:


We can work with .tiff or .BMP image only.
NOTE:
1. When ever we are working with .tiff image then convert .tiff image into TEXT image.
2. RSTXPDFT4 is the standard program which converts tiff to TEXT image.
3. When ever we are working with .BMP image then convert .BMP image into GRAPHICS image.
4. SE78 is the Transaction code to convert .BMP image to GRAPHICS image.

Steps to convert .BMP to GRAPHICS:


1. Execute SE78. Expand graphics in the left panel. Double click on BMAP.
2. Provide your graphics name. select the radio cotton color. click on import (F5) in the application
tool bar.
3. Provide your image path. ENTER.
Steps to include the LOGO in the PAGE WINDOW:
1. Execute SE71, Open the FORM in change mode. double click on LOGO WINDOW and click on
text element.
2. In the menu bar click on insert -> graphics, Select tab stored on document server.
3. Provide your graphics name (which is created in SE78). Select the radio button color grid. Come
back. save activate.

When ever we are working with main window then we must pass text element name in the page
window. otherwise the first record will be printed twice.
LOOP AT IT_KNB1 INTO WA_KNB1.
CALL FUNCTION WRITE_FORM
/E
MAIN
EXPORTING
*
&WA_KNB1-BUKRS& &WA_KNB1ELEMENT
= MAIN
KUNNR& &WA_KNB1-AKONT&
WINDOW
= MAIN
.
ENDLOOP.
Footer:
PAGE NUMBER:
PAGE &PAGE& OF &SAPSCRIPT-FORMPAGES&
Current page
total no. of pages
Sign:
/:
IF &NEXTPAGE& EQ 0.
*
SURYA
/:
ELSE
*
PAGE &PAGE& OF &SAPSCRIPT-FORMPAGES&
/:
ENDIF
SAP-SCRIPT (FORM/LAYOUT) is client dependent. where as program is client independent.
Steps to COPY the FORM from one client to another client:
If the form is available in 800 client in $TMP package, if you want to copy into 810 client:
1. Execute SE71. in the menu bar click on utilities -> copy from client.
2. Provide your source form name. source client (800) and provide target form name (same as
source form name or different form name) execute.
If the form is available in 800 client in your own package (DEVK901449), if you want to copy in to
810 client:
1. Execute SCC1. Provide your source client (800). Provide your transport request
(DEVK901449). select check box INCL TASKS FOR REQUEST.
2. Click on Start immediately (F5) in the Application.
Steps to change the OBJECT PACKAGE (Development Class):
1. Execute SM30. provide the table/view as TADIR. click on maintain.
2. Select the check box of your request object and object name. execute.
3. Double click on object remove the old package and provide your new package ENTER.
Steps to maintain the BACK UP of SAP-SCRIPT layout or DOWNLOAD:
NOTE: RSTXSCRP is the standard program which is used to download as well as upload the SAPSCRIPT to PRESENTATION SERVER.
1. Execute SE38. provide program name RSTXSCRP. click on execute.
2. Provide your form name. mode is EXPORT (DOWNLOAD to local drivers). click on execute
provide your path. Execute.
Steps to UPLOAD or RE-LOAD the SAP-SCRIPT:
1. Execute SE38. provide program name RSTXSCRP. click on execute.

2. Provide your form name. mode is IMPORT (UPLOAD from local drivers). click on execute
provide your path name. ENTER (Transfer).
Steps to convert SAP-SCRIPT OUTPUT to PDF format:
This is the two step procedure.
1. Create SPOOL Request
2. Convert SPOOL to PDF
NOTE: RSTXPDFT4 is the standard report which is used to convert SPOOL TO PDF.
Steps to create SPOOL:
Execute Driver Program. provide input. click on execute. provide output device LP01. select the
Check box NEW SPOOL REQUEST. click on print.
Steps to identify the SPOOL:
Execute SP02. identify the SPOOL number.
Or
In Menu bar Click on SYSTEM ->
OWN SPOOL REQUEST.
Steps to convert SPOOL to PDF:
Execute SE38. Provide program RSTXPDFT4. Execute. provide your path and click on transfer.
Control Commands:
1. INCLUDE
2. DEFINE
3. ADDRESS..ENDADDRESS
4. PROTECT..ENDPROTECT
5. TOPENDTOP
6. BOTTOM...ENDBOTTOM
7. IF.ENDIF
8. CASE..ENDCASE
9. NEW-PAGE
10. SET DATE/TIME MASK
11. PERFORM.ENDPERFORM
12. NEW-WINDOW
1.
INCLUDE:
Include command is used to include the standard text which is defined in the SO10 transaction.
Steps to define Standard Text:
Execute SO10 transaction. Provide your standard text name. click on create and provide your text
information save.
Steps to include the Standard Text in the PAGE WINDOW:
Execute SE71. Open the Form in Change mode. Click on page window. click on text element.
place the cursor where you want place the standard text. click on Insert-> Activate.
Syntax:
/:
INCLUDE <std text name> OBJECT <obj name> ID <idname>.
2.
DEFINE:
Define command is used to declare the variables in the page window.
Syntax:
/:
DEFINE &<variable name>&
Example:
/:
DEFINE &dob& = feb21
3.
ADDRESS..ENDADDRESS:
AddressEndaddress is used to print the Address in the format of Target country.
/:
ADDRESS
*
&WA_KNB1-NAME1&
*
&WA_KNB1-ORT01&
*
&WA_KNB1-STRAS&
Street
*
&WA_KNB1-ORT02&
*
&WA_KNB1-PSTLZ&
Postal code
*
&WA_KNB1-LAND1&
/:
ENDADDRESS
4.
PROTECT..ENDPROTECT:
ProtectEndprotect is used to print the continuous text with out any page break.
First it checks the each and every page to print the continuous text. if there is no space is available
for all the pages then the system breaks the text and prints it.
/:
PROTECT
*
SURYA

*
PRAVEEN
*
SRI
/:
ENDPROTECT
5.
TOPENDTOP:
TopENDTOP is used to print the heading in the main window.
/:
TOP
*
SURYAPRAVEEN
SRI
/:
ENDTOP
6.
BOTTOM...ENDBOTTOM:
BOTTOMENDBOTTOM is used to print the footer information in the main window.
/:
BOTTOM
*
PRAVEENASURYA
/:
ENDBOTTOM
NOTE: TOPENDTOP & BOTTOMENDBOTTOM are works with in the main window only.
7.
IF.ENDIF:
IfEndif functionality is similar as in the ordinary ABAP (Reports).
8.
CASEENDCASE:
Case...Endcase functionality is similar as in the ordinary ABAP (Reports).
9.
NEW-PAGE:
New page command is used to break the page.
/:
IF
&WA_KNB1-KUNNR& = 218
*
NEW-PAGE
/:
ENDIF
10.
SET DATE/TIME MASK:
Set date/time mask command are used to display the data and time in different formats.
Syntax:
/:
SET DATE MASK = MMDDYYYY
*
DATE &DATE&
/:
SET TIME MASK = HHMMSS
*
TIME &TIME&
11.
PERFORMENDPERFORM:
This command is used to adding some additional logic to the standard driver program without
disturbing the standard driver program.
Syntax:
/:
PERFORM <FORM NAME> IN PROGRAM <PROGRAM NAME>
/:
USING &INPUT1&
/:
USING &INPUT2&
/:

/:

/:
CHANGING &OUTPUT1&
/:
CHANGING &OUTPUT2&
/:

/:

/:
ENDPERFORM
12.
NEW-WINDOW:
NEW-WINDOW is used to call the next window.
*
NEW-WINDOW
Difference between MAIN WINDOW and VARIABLE WINDOW:
MAIN WINDOW
3.
TOPENDTOP
&
BOTTOM
1.
Main window is the default window in
ENDBOTTOM are works in the main
SAP-SCRIPT. we cant create the main
window only.
window.
4.
Without main Window we cant create
2.
We can print the continuous text on the
SAP-SCRIPT.
main window.
5.
We can place the SAME MAIN
WINDOW up to 99 times per page.
6.
We can SPLIT the main window into
smaller windows.

1.

VARIABLE WINDOW
We cant create the variable window.

2.

4.

Without variable Window we cant


create SAP-SCRIPT.
5.
Variable window we can place only one
time in a page.
6.
We cant SPLIT the variable window
into smaller windows.

We cant print the continuous text on the


variable window. based on the window size
only it will print the data.
3.
TOPENDTOP
&
BOTTOM
ENDBOTTOM are not work in the variable
window.
Working with boxes and lines:
BOX is a command is used to draw the table vertical lines and horizontal lines.
Syntax: /:
BOX XPOS <value> <cm> YPOS <value> <cm> WIDTH <value> <cm>
HEIGHT <value> <cm> INTESITY <value> <cm> FRAME <value> <cm>
UNITS:
CM
Centimeter.
MM Millimeter.
IN
Inch.
PT
Point. TW
TWIP (1/20 point)
For HORIZONTAL LINE HEIGHT ZERO

For VERTICAL LINE WIDTH ZERO.

Steps to Create Paragraph format:


1. Click on paragraph format in the application tool bar. provide paragraph format name <sp>. Enter.
Enter.
2. Provide short description. provide left margin. alignment.
3. Provide FONT size. FONT position and TAB POSITIONS.
Objective:

ABAP Editor Logic:


PARAMETER : P_EBELN LIKE EKKO-EBELN.
DATA : BEGIN OF WA_EKKO.
EBELN LIKE EKKO-EBELN.
LIFNR LIKE EKKO-LIFNR.
BUKRS LIKE EKKO-BUKRS.
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
DATA : BEGIN OF WA_LFA1.
LIFNR LIKE LFA1-LIFNR.
NAME1 LIKE LFA1-NAME1.
ORT01 LIKE LFA1-ORT01.
STRAS LIKE LFA1-STRAS.
LAND1 LIKE LFA1-LAND1.
END OF WA_LFA1.
DATA IT_LFA1 LIKE TABLE OF WA_LFA1.
DATA : BEGIN OF WA_T001.
BUKRS LIKE T001-BUKRS.
BUTXT LIKE T001-BUTXT.
ORT01 LIKE T001-ORT01.
LAND1 LIKE T001-LAND1.
END OF WA_T001.
DATA IT_T001 LIKE TABLE OF WA_T001.
DATA : BEGIN OF WA_EKPO.
EBELN LIKE EKPO-EBELN.
EBELP LIKE EKPO-EBELP.
MENGE LIKE EKPO-MENGE.
MEINS LIKE EKPO-MEINS.
NETPR LIKE EKPO-NETPR.
END OF WA_EKPO.

DATA IT_EKPO LIKE TABLE OF WA_EKPO.


DATA W_TOTAL LIKE EKPO-NETPR.
SELECT SINGLE EBELN LIFNR BUKRS FROM EKKO INTO WA_EKKO WHERE EBELN =
P_EBELN.
SELECT SINGLE LIFNR NAME1 ORT01 STRAS LAND1 FROM LFA1 INTO WA_LFA1 WHERE
LIFNR = WA_EKKO-LIFNR.
SELECT SINGLE BUKRS BUTXT ORT01 LAND1 FROM T001 INTO WA_T001 WHERE
BUKRS = WA_EKKO-BUKRS.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO WHERE
EBELN = WA_EKKO-EBELN.
LOOP AT IT_EKPO INTO WA_EKPO.
W_TOTAL = W_TOTAL + WA_EKPO-NETPR.
ENDLOOP.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM
= 'YANUSHA_FORM5'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW
= 'TITLE'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW
= 'VENDOR'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW
= 'COMPANY'.
LOOP AT IT_EKPO INTO WA_EKPO.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT
= 'MAIN'
WINDOW
= 'MAIN'.
ENDLOOP.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW
= 'FOOTER'.
CALL FUNCTION 'CLOSE_FORM'.

SAP-SCRIPFORM:
PAGEWINDOWS
WINDOW
DESCRIPTION
LEFT
RIGHT
WIDTH
HEIGHT
MAIN 00
Main Window
1.00 CM
6.50 CM
18.50 CM
10.00 CM
COMPANY
Company Address
10.50 CM
2.50 CM
9.00 CM
3.00 CM
FOOTER
Total Amount
1.00 CM
17.50 CM
18.50 CM
1.00 CM
TITLE
Title Window
1.00 CM
0.50 CM
18.50 CM
1.00 CM
VENDOR
Vendor Address
1.00 CM
2.50 CM
9.00 CM
3.00 CM
TEXT ELEMENTS:
FOR TITLE WINDOW
/:
BOX FRAME '20' TW
T
PURCHASE DOCUMENT
FOR MAIN WINDOW
/:
BOX FRAME 20TW.
/:
BOX XPOS '0' CM YPOS '1' CM WIDTH '185' MM HEIGHT '0' CM FRAME '20' TW
/:
BOX XPOS '4' CM YPOS '0' CM WIDTH '0' CM HEIGHT '101' MM FRAME '20'TW
/:
BOX XPOS '7.5' CM YPOS '0' CM WIDTH '0' CM HEIGHT '101' MM FRAME '20'TW
/:
BOX XPOS '11.5' CM YPOS '0' CM WIDTH '0' CM HEIGHT '101' MM FRAME '20'TW
/:
BOX XPOS '14.5' CM YPOS '0' CM WIDTH '0' CM HEIGHT '101' MM FRAME '20'TW
/:
TOP
M
..PURC.DOC ..ITEM..QTY..UOM..PRICE
/:
ENDTOP

/E

MAIN

M1
&WA_EKPO-EBELN&..&WA_EKPO-EBELP&..&WA_EKPO MENGE & ..
=
&WA_EKPO-MEINS&..&WA_EKPO-NETPR&
FOR COMPANY ADDRESS WINDOW
/:
BOX FRAME '20' TW
T
COMPANY ADDRESS
*
&WA_T001-BUKRS&
*
&WA_T001-BUTXT&
*
&WA_T001-ORT01&
*
&WA_T001-LAND1&
FOR VENDOR ADDRESS WINDOW
/:
BOX FRAME '20' TW
T
VENDOR ADDRESS
/:
ADDRESS
*
&WA_LFA1-LIFNR&
*
&WA_LFA1-NAME1&
*
&WA_LFA1-ORT01&
*
&WA_LFA1-STRAS&
*
&WA_LFA1-LAND1&
/:
ENDADDRESS
FOR FOOTER WINDOW
/:
BOX FRAME '20' TW
M1
TOTAL........&W_TOTAL&

NOTE: SPELL_AMOUNT is the function module which is used to print the amount in words.
The inputs for this function module are AMOUNT and CURRENCY.
The output for this function module is AMOUNT in WORDS.
NOTE: In the Real time based on the page. BASIS people create the page format as well as output device.
Based on these two things we develop the LAYOUT.
NOTE: In real time when ever we are working with LABELS we split the MAIN window depends on
label size.
Steps to Print The Output In Both Sides:
1. Execute SE71 Transaction, Provide your form name, Click on change mode.
2. Click on pages in the application tool bar.
3. Print attributes, Print mode D.
Steps to Access Multiple Layouts or Forms In The Same Driver Program (Or) Print Program:
1. Create an executable program and implement all the retrieving logic.
2. Access the layouts from the driver program by using OREN_FORM function module. Input for
the above function module FORM NAME (Optional).
3.
I. Start the each form by using START_FORM function module. Input is FORM NAME.
II. Transfer the data from driver program to particular page window by using
WRITE_FORM function module. Input is WINDOW NAME. Repeat the same step II for
all the page windows.
III. End each form by using END_FORM function module. Repeat the same step 3 for each
form.
4. Close the form by using CLOSE_FORM function module.
OPEN_FORM
START_FORM
WRITE_FORM
WRITE_FORM
END_FORM
START_FORM
WRITE_FORM
WRITE_FORM
END_FORM
START_FORM
WRITE_FORM
WRITE_FORM
WRITE_FORM
END_FORM

CLOSEFORM

NOTE:
Without a CLOSE_FORM we cant print the output.
Steps to Debug The Sap-Script:
METHOD1:
1. Execute SE71 Transaction. Provide form name.
2. In the menu bar -> UTILITIES -> ACTIVE DEBUGGER (Here only current form is in
debugging mode).
3. Execute the program. Provide sample input. Execute. ENTER.
4. Press F5 and identify the values.
METHOD2:
1. Execute SE38
2. Provide program name RSTXDBUG.
3. Execute the program. Provide sample input. Execute. ENETR.
4. Press F5 and identify the values.
NOTE:
TTXFP is the standard database table which contains form names as well as their driver
programs (Here sub programs are available).
NOTE:
TNAPR is the standard database table which contains applications, layouts and driver
programs (Main program).
Working With Standard Scripts:
The function of this standard script is
1. Change the layout
2. Adding some additional logic to the driver program.
NOTE:
NACE is the Transaction which contains all the applications, output types, their forms
and Driver Programs.
The output type is designed by the functional people. Each application having number of output
types depending on the document type.
Each output contains
a. Driver program
b. Layout
Steps to Change The Existing Layout:
STEP1: Identify the standard layout.
STEP2: Copy the standard form into Z form.
STEP3: Convert the original language to our required language.
STEP4: Change the layout as per client requirement.
STEP5: Place the new layout in the NACE Transaction.
STEP1 Steps to Identify the Standard Layout:
1. Execute NACE transaction
2. Select your application
3. Click on output types in the application toolbar.
4. Select your output type which is given by functional people (NEU-New PO Print out).
5. Double click on processing routines in the left panel and identify the standard form (Example:
MEDRUCK).
STEP2 Steps to Copy the Standard Form Into Z Form:
1. Execute SE71.
2. In the menu bar click on utilities -> COPY FROM CLIENT.
3. Provide your form name which is identified by the Standard form.
4. Provide
Source client : 000
Target form : <z-form>
5. Click on execute, Local object.
STEP3 Steps to Convert the Original Language to Our Required Language:
1. Execute SE71.
2. Provide your Z form name (created form in step2). Provide language DE, Click on change mode.
3. In the menu bar click on UTILITIES -> CONVERT ORIGINAL LANGUAGE.
From language
DE (German)
To language
EN (English)
4. ENTER.

STEP4 Steps to Change the Layout as Per Client Requirement:


1. Execute SE71.
2. Provide your form name, Language-EN, click on change mode.
3. In the application toolbar click on window tab.
4. Go to menu bar -> EDIT -> CREATE ELEMENT. Provide window name. Short description.
5. Click on page windows tab. In the menu bar click on EDIT -> CREATE ELEMENT.
6. Double click on your window. Provide Coordinates.
7. SAVE CHECK ACTIVATE the form
STEP5 Steps to Place the new layout in the NACE Transaction:
1. Execute the NACE Transaction.
2. Select your application. Click on output types in the application toolbar.
3. Select the output type NEU(NEW PO printout)
4. Double click on PROCESSING in the left panel. Click on change mode (display). Remove the
old form. Place the new form. SAVE.
In ME23N texts -> Header text -> Click on print preview
Steps to Provide Message In The Purchase Order:
1. Execute ME22N.
2. Provide your PO (purchase order) number.
3. Click on messages in the application toolbar.
a. Provide output type
b. Select the medium printout
ENTER
4. Click on communication method in the application toolbar
Printing the Information:
Provide the logical destination LP01, BACK, SAVE.
Format Options:
1. Offset
2. Output length
3. Omitting leading zeros
4. Omitting leading sign
5. Leading sign at right
6. Leading sign at left
7. Compress the text
8. Number of decimal places
9. Remove the separators in thousand
10. Avoid the conversions.
OFFSET:
Syntax:
&SYMBOL + OFFSET&
Example:
&a& = ABCDEFGHI
&a+3& = DEFGHI
OUTPUTLENGTH:
Syntax:
&symbol (length) &
Example:
&a& = ABCDEFGH
&a(2)& =AB

SMARTFORM:
Smart forms are used to design the business documents such as purchase order, sales order,
invoice, Performa etc.
Smart forms are introduced from 4.6c version onwards. It also supports output mode as EMAIL.
Components of Smart forms:
1. Smart form layout.
2. Function module.
3. Print layout.
Components of the smart forms layout:
1. Global settings.
2. Pages and windows.
Components of Global settings:
1. Form attributes
2. Form interface
3. Global definition
Form attributes:
Form attributes contain header information i.e.
Form name
Language
Page format
Created by..
Form interface: this is used to declare the variables, work area and internal tables which we need to
transfer the data from print program to layout.
Global definition: this is used to declare the variables, work-area and internal table which are used to
implement the logic in the layout.
PAGES: page is the physical area where we place the window. We cant print the text in the page.
WINDOWS: we can place the same window in n number of pages but we cant print the data directly
on the window.
Procedure of Smart Form:
1. Based on the client requirement we design the smart form layout by using SMARTFORMS tcode.
2. After activating the smart form it generates a function module.
3. Based on the function module we develop the print program.
NOTE: Printing the data on the page window is always through symbols.
There are four types of symbols.
1. Program symbols
2. System symbols
3. Standard symbols
4. Text symbols.
Each symbol starts with & ends with &.
Differences between Sap scripts and Smart forms:
SAPSCRIPTS
6.
We cant use the same paragraph and
1.
Multiple page formats are not possible In
character formats more than once in a script.
SAPSCRIPTS.
SMARTFORMS
2.
SAPSCRIPT is client dependent i.e., that
1.
Multiple page formats are possible in
means if you create the form in one client that
SMARTFORMS.
is not available in all clients.
2.
SMARTFORMS are client independent.
3.
Without a main window we cant design
That means form is available in all the clients
SAPSCRIPT.
under the server if you create in any client.
4.
Colors are not possible in SAPSCRIPTS.
3.
Without a main window we can design the
5.
For complex coding we select the
smart form.
SAPSCRIPTS

4.
5.

Colors are possible in SMARTFORMS.


For complex design we use the
SMARTFORMS

7.
8.

Labels are possible here.


SAPSCRIPTS doesnt support all the
printers.
By using OPEN_FORM,
WRITE_FORM, CLOSE_FORM we
transfer the data from driver program to
layout.
Coding is not possible in the
SAPSCRIPT layout.
By using RSTXDBUG we DEBUG the
SAP-SCRIPT.
In SAP-SCRIPT downloaded file is .txt
format.

9.

10.
11.
12.

6.

We can use the same paragraph and


character formats for multiple MARTFORMS
layouts.
7.
8.
9.

Labels are not possible here.


SMARTFOR support all the printers.
When ever we activate the smart form
then it generates a function module. Through
this function module only we can transfer
the data from program to layout.
10.
Coding is possible in SMARTFORM
layout.
11.
By using STATIC BREAK POINTS we
can debug the SMARTFORMS.
12.
In SAP-SMARTFORMS downloaded
file is .xml format.

13.
1.
2.
3.
4.

5.
6.
25.
7.
8.
29.

9.

Steps To Create Te Smart Form:


Execute SMARTFORMS transaction.
Provide smart form name, Click on create, Provide short description.
In the left panel double click on form interface, under the import tab, Declare your
requirement.
14. P_BUKRS
LIKE
T001-BUKRS
In the left panel double click on global definitions, in the right panel click on types tab.
(declare what ever you want to print)
15.
TYPES: BEGIN OF TY_T001,
16.
BUKRS LIKE T001-BUKRS,
17.
BUTXT LIKE T001-BUTXT,
18.
ORT01 LIKE T001-ORT01,
19.
LAND1 LIKE T001-LAND1,
20.
END OF TY_T001.
Click on global data tab (provide variables, type assignment and associated type)
21.
Variable name
Type assignment
Associated type
22.
WA_T001
TYPE
TY_T001
Under initialization tab provide logic, input/output parameters.
23.
Input parameters
Output parameters
24.
P_BUKRS
WA_T001
Logic:
26.
SELECT SINGLE BUKRS BUTXT ORT01 LAND1 FROM T001 INTO WA_T001
WHERE BUKRS = P_BUKRS.
Under pages and windows in the left panel
27.
Select the main window right click -> create -> text.
28.
(Text window is provided under main window)
Double click on the text.
In the general attributes tab click on Editor, provide the data.
30. * &WA_T001-BUKRS&
31. * &WA_T001-BUTXT&
32. * &WA_T001-ORT01&
33. * &WA_T001-LAND1&
34.
COME BACK, SAVE, CHECK, ACTIVATE THE FORM.
In the menu bar click on environment -> Function Module Name. Function module is
generated (/1BCDWB/SF00000188).
35.
Based on this function module develop the program in the ABAP editor, by calling
this function module.

36. ABAP Editor:


37. PARAMETER: PR_BUKRS LIKE T001-BUKRS.
38. CALL FUNCTION /1BCDWB/SF00000188
39.
EXPORTING
40.
P_BUKRS = PR_BUKRS
.
41. NOTE: ADRC is the database table which provides entire address information.
42. Steps to Work with Address Window:
1. Execute SMARTFORMS.
2. Provide smart form name, click on create, provide short description
3. In the left panel double click on form interface,
43.
Under import tab,
44.
P-BUKRS
LIKE
T001-BUKRS
4. Double click on global definitions in the left panel
45.
Under types tab declare TYPES.
46.
TYPES: BEGIN OF TY_T001,
47.
BUKRS LIKE T001-BUKRS,
48.
ADRNR LIKE T001-ADRNR,
49.
END OF TY_T001.
5. Under global data tab provide
50.
WA-T001
TYPE
TY_T001
6. Under initialization tab, implement logic, provide input and output parameters
51. Input parameters
Output parameters
52.
P_BUKRS
WA_T001
53. Logic:
54.
SELECT SINGLE BUKRS ADRNR FROM T001 INTO WA_T001 WHERE
BUKRS = P_BUKRS.
7. Select the page under pages and windows in the left panel.
55.
Page -> right click -> create -> address.
8. Double click on address provide address number.
56. Address number &WA_T001-ADRNR&
57. SAVE, CHECK And ACTIVATE.
9. In the menu bar click on environment -> Function Module Name. Function module is
generated (/1BCDWB/SF00000189).
58.
Based on this function module develop the program in the ABAP editor, by
calling this function module.
59. ABAP Editor:
60. PARAMETER: PR_BUKRS LIKE T001-BUKRS.
61. CALL FUNCTION /1BCDWB/SF000001189
62.
EXPORTING
63.
P_BUKRS = PR_BUKRS
.
64. Working with Logo:
65.
We can work with .tiff or .BMP image only.
66. NOTE:
5. When ever we are working with .tiff image then convert .tiff image into TEXT image.
6. RSTXPDFT4 is the standard program which converts tiff to TEXT image.
7. When ever we are working with .BMP image then convert .BMP image into GRAPHICS
image.
8. SE78 is the Transaction code to convert .BMP image to GRAPHICS image.
67. Steps to convert .BMP to GRAPHICS:
4. Execute SE78, Expand graphics in the left panel, Double click on BMAP.
5. Provide your graphics name, select the radio cotton color, and click on import (F5) in the
application tool bar.
6. Provide your image path, ENTER.

68. Steps to Provide Ms-Word as Text Editor in Smart form Or Sap script:
1. Execute I18N t-code.
2. Expand I18N customizing. Double click on MS-WORD as editor.
3. select the checkboxes
69.
SAPSCRIPT
SMARTFORMS
70. 4. Click on activate.
71.
(This is possible only after configuring the system).
72. Steps to Maintain the Backup (Or) Download the Smart form Layout:
1. Execute SMARTFORMS t-code
2. Provide your smart form name which you want to download.
3. In the menu bar click on utilities -> download form, ENTER
4. Provide file name, SAVE.
73. Steps to Reload the Smart forms (Or) Upload the Smart forms:
1. Execute SMARTFORMS t-code
2. Provide your smart form name and click on delete, yes.
3. In the menu bar click on utilities -> upload form, Provide your form name, ENTER.
4. Browse the file, click on LOCAL OBJECT.
74. NOTE:
75.
Whenever the smart form is transported from development server to quality server
and production server the function module name never transport.
76.
77.
78.
79.
80.
81. NOTE:
82.
SSF_FUNCTION_MODULE_NAME is the function module which is used to
generate the function module based on the smart form.
83. Input for this function module is Smart form name.
84. Output for this function module is function module name.
85. NOTE:
86.
If you want to declare the select-options in the SMART-FORMS then we must create
a structure with four fields.
1. SIGN (c,1)
2. OPTION (c,2)
3. LOW
Depends on
4. HIGH
input fields.
87.
After creating the structure we refer it to the smart form.
88. Steps to Create The Structure:
1. Execute SE11.
2. Select the radio button data type, Provide your structure name, click on create.
3. Select the radio button structure, Provide short description.
4. Click on predefined type (built-in-type), Provide the components.
89.
Component
data type
length
short description
90.
SIGN
CHAR
1
SIGN
91.
OPTIONS
CHAR
2
OPTIONS
92.
LOW
CHAR
4
LOW
93.
HIGH
CHAR
4
HIGH
94.
The length varies with the type like for P.O. Length is (C, 10).
95.
SAVE, CHECK, ACTIVATE structure.
96.
97.

98. OBJECT:
Based on the company code displaying the customers under company
99. Steps to Create Smart form:
1. Execute SMARTFORMS t-code
2. Provide your SMARTFORM name, click on create, Provide short description.
3. In the left panel click on form interface, under tables tab, Declare the select option
100.
S_BUKRS LIKE <STRUCTURE NAME>
4. Double click on global definitions in left panel, under types tab declare TYPES.
101.
TYPES: BEGIN OF TY_FINAL,
102.
BUKRS LIKE T001-BUKRS,
103.
BUTXT LIKE T001-BUTXT,
104.
KUNNR LIKE KNB1-KUNNR,
105.
END OF TY_FINAL.
5. Click on global definitions, under global data tab, declare the WA and IT.
106.
WA_FINAL TYPE TY_FINAL
107.
IT_FINAL TYPE TABLE OF TY_FINAL
6. Click on INITIALISATION tab, Provide input and output parameters and implement the logic.
108.
Input
output
109.
S_BUKRS
IT_FINAL
110. Logic:
111. SELECT T001~BUKRS T001~BUTXT KNB1~KUNNR INTO TABLE IT_FINAL FROM
T001 INNER JOIN KNB1 ON T001~BUKRS = KNB1~BUKRS WHERE T001~BUKRS IN
S_BUKRS.
7. Select the main window in the left panel, Right click -> create -> low logic -> loop.
112.
Double click on loop icon, in data tab provide
113.
IT_FINAL
INTO
WA_FINAL
8. Select the loop in the left panel -> right click -> create -> text.
114.
Text icon is created under main window.
115.
Double click on text icon, click on text editor -> Provide the data.
116.
&WA_FINAL-BUKRS& &WA_FINAL-BUTXT& &WA_FINAL-KUNNR&
117.
SAVE, CHECK, ACTIVATE the form.
9. In the menu bar click on environment -> function module name.
10. Based on the function module develop the print program in ABAP editor
118. ABAP Editor:
119.
DATA: FN_MODULE TYPE RS38L_FNAM.
120.
DATA V1 LIKE T001-BUKRS.
121.
SELECT-OPTIONS SO_BUKRS FOR V1.
122.
CALL FUNCTION SSF_FUNCTION_MODULE_NAME
123.
EXPORTING
124.
FORM NAME = <FORM NAME>
125.
IMPORTING
126.
FM_NAME = FN_MODULE .
127.
CALL FUNCTION FM_MODULE
128.
TABLES
129.
S_BUKRS
= SO_BUKRS .
130. (Here RS38L_FNAM is structure name of the function module
SSF_FUNCTION_MODULE_NAME, this is obtained by providing the function module name in
SE37 t-code. under export tab, you can get the structure name. you have to provide this because you
are creating structure for select-options.]
131. Steps To Convert Sap script Layout to Smart Form:
132. METHOD-1:
1. Execute SMARTFORMS t-code; provide your smart form name.
2. In the menu bar click on utilities -> migration -> import sap script form.
3. Provide your script form name, ENTER.
4. SAVE, CHECK, ACTIVATE the form.
133.

134.
METHOD-2:
135.
FB_MIGRATE_FORM is the function module which is used to convert script layout
to smart form.
136.
Here provide the function module name in SE37 and click on display and execute
and provide your script and target smart form name and execute and save. The script will
converted into smart form.
137.
Steps to convert SAP-SCRIPT OUTPUT to PDF format:
138.
This is the two step procedure.
3. Create SPOOL Request
4. Convert SPOOL to PDF
139.
NOTE: RSTXPDFT4 is the standard report which is used to convert SPOOL TO
PDF.
140.
Steps to create SPOOL:
141.
Execute Driver Program, provide input, click on execute, provide output
device LP01, select the Check box NEW SPOOL REQUEST, click on print.
142.
Steps to identify the SPOOL:
143.
Execute SP02, identify the SPOOL number.
Or
In Menu bar Click
on SYSTEM -> OWN SPOOL REQUEST.
144.
Steps to convert SPOOL to PDF:
145.
Execute SE38, Provide program RSTXPDFT4, Execute, provide your path
and click on transfer.
146.
Working With Smart Styles:
1. Smart styles are used to design the paragraph and character formats.
2. The T-code is SMARTSTYLES.
147.
Steps To Create Paragraph & Character Format:
148.
Paragraph Format:
1. Execute smart style T-code.
2. Provide your style name, click on create, Provide short description.
3. In the left panel select the paragraph formats. Right click -> create node, Provide
paragraph format name <P1>, ENTER.
4. Provide short description, under font tab provide
149.
Font family
ELVE
150.
Font size
6.0 pt
151.
Font style
OLD
152.
COLOR
5. Under tabs tab, Provide tab positions
153.
Repeat the same for all the paragraph formats.
154.
Character Formats:
6. In the left panel select character formats right click -> create node, provide your
character format name <C1>.
7. Provide short description, Under font tab provide
155.
Font family
ELVE
156.
Font size
6.0 pt
157.
Font style
OLD
158.
COLOR
159.
Repeat the same for all the character formats
8. In the left panel double click on the header data
160.
Standard settings
161.
Standard paragraph P1
162.
SAVE, CHECK, ACTIVATE the SMARTSTYLES.

163.
OBJECT:
Based on
the purchasing document number
display the vendor address and
purchasing document details.
164.
Steps to Design:
1. Execute SMARTFORMS.
2. Provide the smart form name, Click
on CREATE, provide short
description.
3. In the left panel click on form
interface, Under import tab
165. P_EBELN
LIKE EKKOEBELN
4. In the left panel click on global
definitions, Under types tab provide
types
166.
TYPES: BEGIN OF TY_EKKO,
167.
EBELN LIKE EKKO-EBELN,
168.
LIFNR LIKE EKKO-LIFNR,
169.
END OF TY_EKKO.
170.
TYPES: BEGIN OF TY_LFA1,
171.
LIFNR LIKE LFA1-LIFNR,
172.
ADRNR LIKE LFA1-ADRNR,
173.
END OF TY_LFA1.
174.
TYPES: BEGIN OF TY_EBELN,
175.
EBELN LIKE EKPO-EBELN,
176. EBELP LIKE EKPO-EBELP,
177.
MENGE LIKE EKPO-MENGE,
178. MEINS LIKE EKPO-MEINS,
179.
NETPR LIKE EKPO-NETPR,
180. END OF TY_EKPO.
181.
Under on global data tab,
182.
WA_EKKO
TYPE
TY_EKKO
183.
WA_LFA1
TYPE
TY_LFA1
184.
WA_EKPO
TYPE
TY_EKPO
185.
IT_EKPO
TYPE TABLE OF
TY_EKPO
186.
W_TOTAL
LIKE
EKPO-NETPR
187.
Under initialization tab
188.
Input
output
189.
P_EBELN
WA_EKKO
190.
WA_EKKO
WA_LFA1
191.
IT_EKPO
192.
Logic:
193.
SELECT SINGLE EBELN LIFNR FROM EKKO INTO WA_EKKO WHERE
EBELN = P_EBELN.
194.
SELECT SINGLE LIFNR ADRNR FROM LFA1 INTO WA_LFA1 WHERE
LIFNR= WA_EKKO-LIFNR.
195.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE
IT_EKPO WHERE EBELN = P_EBELN.
5. Under main window in the left panel select the page right click -> create -> address.
6. Double click on address, Provide address number.
196.
&WA_LFA1_ADRNR&
7. In the left panel select address Right click -> create -> graphics.
197.
In the left panel double click on the graphics

198.
NAME
<SURYA>
199.
OBJECT
GRAPHICS
200.
ID
BMAP
201.
Select the radio button bitmap image
8. Select the main window in the left panel, right click -> create -> table.
202. Under the tables tab, select the line right click -> rename the line -> provide new
name, ENTER.
203.
In the left panel select double click on pages and windows, in the left most
corner you will find details, double click and provide cell widths as required.
204.
Click on the data tab.
205. LOOP:
206.
Internal table
IT_EKPO
INTO
WA_EKPO
9. Select the header in the table left panel Right click -> create -> table line. Select the line type
as LINE1 which name you have given in the 8th step.
207. In the left panel you can see cells under header
208.
Click on 1st cell -> right click -> create -> text.
209. Double click on the text Click on general attributes tab, Click on text editor. P1 PUR.DOC
210.
Provide your first column cell name (Repeat the same for all the cells).
10. elect the Main area in the left panel, Right click -> create -> table line (this is for providing
data in the columns in the main area 6 more cells will be provide under main area)
11. Select the first cell right click -> create -> text.
211.
Double click on text, click on text editor, Provide data.
212.
P2
&WA_EKPO-EBELN&
213.
Repeat the same step 12 for all the cells.
214. In the left panel select the net price. Right click -> create -> flow logic -> program lines.
215.
Double click on the code in the left panel.
216. Input
output
217.
EKPO-NETPR
W_TOTAL
218.
W_TOTAL = W_TOTAL + WA_EKPO-NETPR
219.
Under main window in the left panel, select the table in the left panel select the first
line, Right click -> insert -> empty line underneath (creates empty space for footer)
12. Select the new line right click -> rename line -> provide new name, ENTER.
13. Click on table Select the pattern, by clicking on the top most right corner.
220.
Click on display framed patterns Select your pattern.
14. Select the footer in the left panel right click -> create -> table line. Select the line.
221.
Select the cell -> create -> text.
222.
Click on text editor provide data with its paragraph.
223.
P3
TOTAL &W-TOTAL(C) & Here C refers to COMPRESS i.e. no space is
provided.
15. SAVE ,CHECK ACTIVATE the form
16. In the menu bar -> click on environment -> function module.
17. Based on the function module develop the print program in ABAP editor.
224. ABAP Editor:
225.
DATA FN_MODULE TYPE RS38L_FNAM.
226.
PARAMETER PR_EBELN LIKE EKKO-EBELN.
227.
CALL FUNCTION SSF_FUNCTION_MODULE_NAME
228.
EXPORTING
229.
FORM NAME = <FORM NAME>
230.
IMPORTING
231.
FM_NAME = FN_MODULE .
232.
CALL FUNCTION FM_MODULE
233.
TABLES
234.
P_EBELN
= PR_EBELN .
235. Events in Internal Table or Control Break Statements:

1.
2.
3.
4.

AT FIRST
AT LAST
AT NEW <field name>
AT END OF <field name>
236.
These events are work with in the LOOPENDLOOP of the internal table. Each
event ends with ENDAT.
237.
NOTE: Before using these events we must sort the internal table based on the new
field.
238. AT FIRST: This is the event which is
triggered at the first record of the internal table
239. Advantage: This is used to print the heading.
240. AT LAST:
This is the event which is
triggered at the last record of the internal table.
241. Advantage: This is used to print the grand
totals.
242. AT NEW:
This is the event which is
triggered at the new record of each block.
243. Advantage: This is used to print the individual
heading of each record.
244. AT END OF: This is the event which is triggered at the last record of each block.
245.
Advantage:
This is used to print the subtotals.
246.
247. REQUIREMENT:
248.
Logic:
249.
LOOP AT IT_EKPO INTO
WA_EKPO.
250.
AT FIRST.
251.
WRITE /PURCHASING
DOCUMENTS.
252.
ENDAT
253.
AT NEW EBELN.
254.
WRITE /WA_EKPO-EBELN.
255.
ENDAT
256.
WRITE : / WA_EKPOEBELP,WA_EKPO-MENGE,WA_EKPOMEINS, WA_EKPO-NETPR.
257.
S_TOTAL = S_TOTAL +
WA_EKPO-NETPR.
258.
G_TOTAL = G_TOTAL +
WA_EKPO-NETPR.
259.
AT END OF EBELN.
260.
WRITE: /SUBTOTAL, S_TOTAL.
261.
CLEAR W_STOTAL.
262.
ENDAT.
263.
ATLAST
264.
WRITE: / GRANDTOTAL IS
G_TOTAL.
265.
ENDAT.
266.
ENDLOOP.
267.

268.
269.

270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.

288. BDC
289.
(Batch Data
Conversions/Communication)
290.
291. BDC is used to upload the data from the flat file to their particular Database table.
292. Writing a BDC Program is nothing but automate existing transaction code.
293. Each transaction can create only one record at time. If we want to create
thousands of records one way execute the same transaction thousand thousands of
time, another way is develop BDC Program to automate the existing Transaction
code.
294.
295. Some of the Important Transaction code:
1. XK01/MK01/FK01 Create Vendor.
14.
ME22N Change Purchasing
2. XK01 Central
Order
3. MK01 Material wise
15.
ME23N Display Purchasing
4. FK01 - Finance
Order
5. XK02/MK02/FK02 Change
16. VA01 Create Sales Order
Vendor.
17.
VA02 Change Sales Order
6. XK03/MK03/FK03 Display
18.
VA03 Display Sales Order
Vendor.
19. KS01 Create Cost Centre
7. XD01/VD01/FD01 Create Customer
20.
KS02 Change Cost Centre
8. XD02/VD02/FD02 Change
21.
KS03 Display Cost Centre
Customer
22. KE51 Create Profit Centre
9. XD03/VD03/FD03 Display
23.
KE52 Change Profit Centre
Customer
24.
KE53 Display Profit Centre
10. MM01 Create Material

25. CS01 Create BOM

11.
12.

26.
27.

MM02 Change Material


MM03 Display Material

13. ME21N Create Purchasing Order

CS02 Change BOM


CS03 Display BOM

28. VL01 Create Delivery

29.
30.

VL02 Change Delivery


VL03 Display Delivery

31. VF01 Create Billing


32. ME51N Create Purchase
Requisition

33.

ME52N Change Purchase


Req.
34.
ME53N Display Purchase
Requisition
35. MB01 Create Material Delivered

36.

MB02 Change Material


Delivered
37.
MB03 Display Material
Delivered
38. COR1 Create Process Order

44. C201 Create Recipe

45.
46.

C202 Change Recipe


C203 Display Recipe

47. MSC1N Create Batches

48.
49.

MSC2N Change Batches


MSC3N Display Batches

50. FB01 Create Accounting Document

51.

FB02 Change Accounting


Document
52.
FB03 Display Accounting
Document
53. FI01 Create Bank

54.
55.

FI02 Change Bank


FI03 Display Bank

56. KSH1 Create Cost Centre Group

39.

COR2 Change Process


Order
40.
COR3 Display Process
Order

57.

41. CO01 Create Production Order

59. CL01 Create Class

42.

CO02 Change Production


Order
43.
CO03 Display Production
Order

KSH2 Change Cost Centre


Group
58.
KSH3 Display Cost Centre
Group
60.
61.

CL02 Change Class


CL03 Display Class

62.
VF03 Display Billing
63.
64.
65.
66. STEPS TO DEVELOP THE BDC PROGRAM
1. Analyse the transaction code that means analyse the each and every screen and their field
information.
2. Extract the data from Non SAP to Flat file.
3. Upload the data from flat file to Internal Table /BDC Program.
4. For Each record in the internal table, we collect the screen and field details to automate the
existing transaction.
5. Call the transaction for each and every record in internal table.

67. STEPS IN DETAIL:


68. STEP 1: Analyse the Each and Every screen and their fields Information is
nothing but collect the Technical information of each screen and field.
69. If you want identify the technical information of field then go to transaction place
the cursor on the field, click on F1, and click on Technical Information. It is
very difficult to identify the technical information entire transaction, so we go for
SHDB.
70. Note:
71. SHDB transaction code which collects technical information of the entire
transaction (RECORDING).
72. STEPS TO THE RECORDING:
Execute SHDB
Click on NEW RECORDING in the application tool bar
Provide
RECORDING: YRAKESH_XK01.

73.

TRANSACTION CODE: XK01.


Click on START RECORDING
Provide details in XK01

74.
75.

Vendor: _______
Account: ______
Provide

Name:________

76.
Search term: ___
77.
Country: _______
78. Note: Whenever we click on SAVE button record will be stopped.
79. Note: BDC_OKCODE is the last entry of any screen.
80. STEP2: Extract data from NON-SAP to Flat File
81.
Note: This is End user or Functional people job.
82.
83. Fig .1
84.
85. STEP 3:
86.

87. Date: 29.07.2010


88. UPLOAD:
147

89. It is function module which is used to browse the file and as well as upload the
data to internal table. The input for above function module is FILE TYPE =
DAT the output for the function module is an internal table which is similar as
Flat File.
90.
91. Program:
92. *---------------------------------------------------------------------*
93. *WORKING WITH FILES USING UPLOAD FM
*
94. *---------------------------------------------------------------------*
95. REPORT YRAKESH_FILE1_UPLOAD.
96.
97. DATA: BEGIN OF WA_FILE,
98.
BUKRS LIKE T001-BUKRS,
99.
BUTXT LIKE T001-BUTXT,
100.
ORT01 LIKE T001-ORT01,
101.
END OF WA_FILE.
102. DATA IT_FILE LIKE TABLE OF WA_FILE.
103. CALL FUNCTION 'UPLOAD'
104.
EXPORTING
105.
FILETYPE
= 'DAT'
106.
TABLES
107.
DATA_TAB
= IT_FILE
108.
.
109. LOOP AT IT_FILE INTO WA_FILE.
110.
WRITE: / WA_FILE-BUKRS, WA_FILE-BUTXT, WA_FILE-ORT01.
111. ENDLOOP.
112. GUI_UPLOAD:
113.
It is function module which uploads data from Flat File to Internal
Table. The input for the above function module is File Name. The output above
function module is Internal Table which similar as Flat File.
114. F4_FILENAME:
115.
It is function module is used to browse the file the output for the function
module is filename.
116. AT SELECTION-SCREEN ON VALUE-REQUEST:
117.
It is an Event which is triggered at the time of user clicks F4 button.
118. Program 2:
119. *---------------------------------------------------------------------*
120. *PROG TO UPLOAD DATA FROM FLAT FILE TO INTRENAL TABLE
USING GUI_UPLOAD
121. *FM
122. *---------------------------------------------------------------------*
123. REPORT YRAKESH_FILE2_GUI_UPLOAD.
124. DATA: BEGIN OF WA_FILE,
125.
BUKRS LIKE T001-BUKRS,
126.
BUTXT LIKE T001-BUTXT,
127.
ORT01 LIKE T001-ORT01,

148

128.
END OF WA_FILE.
129. DATA IT_FILE LIKE TABLE OF WA_FILE.
130. DATA V1 TYPE STRING.
131. PARAMETER P_FILE LIKE IBIPPARMS-PATH.
132.
133. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
134. CALL FUNCTION 'F4_FILENAME'
135. IMPORTING
136.
FILE_NAME
= P_FILE
137.
.
138. START-OF-SELECTION.
139. V1 = P_FILE.
140. CALL FUNCTION 'GUI_UPLOAD'
141.
EXPORTING
142.
FILENAME
= V1
143.
HAS_FIELD_SEPARATOR
= 'X'
144.
TABLES
145.
DATA_TAB
= IT_FILE
146.
.
147. LOOP AT IT_FILE INTO WA_FILE.
148.
WRITE: / WA_FILE-BUKRS, WA_FILE-BUTXT, WA_FILE-ORT01.
149. ENDLOOP.
150. ALSM_EXCEL_TO_INTERNAL _TABLE:
151. It is function module which is used to upload the data from Excel sheet to
Internal Table. The input for above function module is File Name, Begin Column,
Begin Row, End Column, and End Row. The output for above function module is
an Internal table which contains 3 fields Row, Column, Value
152. Program 3
153.
154. *---------------------------------------------------------------------*
155. *PROG TO UPLOAD DATA FROM EXCEL SHEET TO INTRENAL TABLE
USING
156. *ALSM_EXCEL_TO_INTERNAL_TABLE FM
157. *---------------------------------------------------------------------*
158. REPORT YRAKESH_FILE3_XSEL_FM.
159. ***DECLARE IT TABLE****
160. DATA: BEGIN OF WA_FILE,
161.
BUKRS LIKE T001-BUKRS,
162.
BUTXT LIKE T001-BUTXT,
163.
ORT01 LIKE T001-ORT01,
164.
END OF WA_FILE.
165. DATA IT_FILE LIKE TABLE OF WA_FILE.
166.
167. ***DECLARING IT FOR CONVERTING FM IT TO DATA IT.
168. DATA: WA LIKE ALSMEX_TABLINE, XCEL FM O/P IT TYPE
169.
IT LIKE TABLE OF WA.

149

170. ***DECLARATIONS
171. DATA V1 TYPE RLGRAP-FILENAME. "XCEL I/P FILENAME TYPE
172. PARAMETER: P_FILE LIKE IBIPPARMS-PATH. " F4_FILENAME FM
FILE_NAME TYPE
173. PARAMETER:
P_BC TYPE I,
174.
P_BR TYPE I,
175.
P_EC TYPE I,
176.
P_ER TYPE I.
177. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
178.
CALL FUNCTION 'F4_FILENAME'
179.
IMPORTING
180.
FILE_NAME
= P_FILE
181.
.
182. START-OF-SELECTION.
183.
V1 = P_FILE.
184.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
185.
EXPORTING
186.
FILENAME
= V1
187.
I_BEGIN_COL
= P_BC
188.
I_BEGIN_ROW
= P_BR
189.
I_END_COL
= P_EC
190.
I_END_ROW
= P_ER
191.
TABLES
192.
INTERN
= IT
193.
.
194. ***LOGIC TO CONVERT XCEL FM TO OUR DATA IT.
195. LOOP AT IT INTO WA.
196.
CASE WA-COL.
197.
WHEN '0001'.
198.
WA_FILE-BUKRS = WA-VALUE.
199.
WHEN '0002'.
200.
WA_FILE-BUTXT = WA-VALUE.
201.
WHEN '0003'.
202.
WA_FILE-ORT01 = WA-VALUE.
203.
ENDCASE.
204. AT END OF ROW.
205.
APPEND WA_FILE TO IT_FILE.
206. ENDAT.
207. ENDLOOP.
208. ***DISPLAYING OUT PUT.
209. LOOP AT IT_FILE INTO WA_FILE.
210.
WRITE: / WA_FILE-BUKRS, WA_FILE-BUTXT, WA_FILE-ORT01.
211.
ENDLOOP.
212. DOWN LOAD:
213. It is function module which is used to browse the file as well as download the
data into Internal table from File.

150

214. The input for above function module is file type = DAT and Data Internal
Table which data you want download.
215. GUI_DOWNLOAD:
216. It is function module which is used to download data from Internal table to
Present Server.
217. The input for the above function module is File Name with Extension, an
Internal table which contains the data.
218.
219. APPLICATION SERVER:
220. It is SAP Directory the transaction code for SAP Directory AL11.
221. Steps to Download the data into Application Server:
222. 1. Open the file <Data set> in write mode.
223. 2. Loop at <Data Internal Table > Into <Work Area>.
224.
Transfer the data From <Work Area> to <File>.
225.
End loop.
226. 3. Close the file <data set>.
227. SYNTAX of Open Data Set:
228.
OPEN DATASET <file name> IN BINARY/TEXT FOR
OUTPUT/INPUT.
229. SYNTAX of Close Data Set:
230.
CLOSE DATASET<file name>.
231. SYNTAX of Transfer Data set:
232.
TRANSFER <Work Area Name> TO <File Name>.
233. Note: . (Dot) directory default directory in AL11.
234.
235. *---------------------------------------------------------------------*
236. *PROG TO DOWN LOAD DATA TO APPLICATION SERVER. (IN ECC 4.7)
*
237. *---------------------------------------------------------------------*
238. REPORT YRAKESH_FILE4_APP_SER_DOWN.
239. DATA : BEGIN OF WA_T001,
240.
BUKRS LIKE T001-BUKRS,
241.
BUTXT LIKE T001-BUTXT,
242.
ORT01 LIKE T001-ORT01,
243.
END OF WA_T001.
244. DATA IT_T001 LIKE TABLE OF WA_T001.
245. SELECT BUKRS BUTXT FROM T001 INTO TABLE IT_T001.
246. OPEN DATASET 'RAKESH' IN TEXT MODE ENCODING DEFAULT
FOR OUTPUT.
247.
LOOP AT IT_T001 INTO WA_T001.
248.
TRANSFER WA_T001 TO 'RAKESH'.
249.
ENDLOOP.
250. CLOSE DATASET 'RAKESH'.

251.

Date: 30.07.2010
151

252. Steps to upload the data from Application Server:


253. 1. Open the file (Data set) in Read mode.
254. 2. Do
255.
READ THE File (Data set) INTO <Work Area>.
256.
IF SY-SUBRC = O.
257.
APPEND <Work Area> TO <Internal Table>
258.
ELSE
259.
EXIT
260.
ENDIF.
261.
ENDO.
262. 3. CLOSE THE File (Data Set)
263. PROGRAM:
264. <TO READ DATA SET>
265.
266. STEP4:
267. Collect the screen and field elements nothing but fill Internal table contains
five fields that is
1.
2.
3.
4.
5.

PROGRAM -- Program name


DYNPRO Screen number
DYNBEGIN Starting Position
FNAM Field Name
FVAL Field Value

268.
In Data Dictionary we have one Structure BDCDATA which contains
above five fields, so that we simply declare our internal table by referring
BDCDATA structure.
269. STEP5:
270. Calling the transaction is of two types
1. Call Transaction Method
2. Session Method

271.

272. Call Transaction Method:


273. SYNTAX:
274.
CALL TRANSACTION <Transaction Code> USING <BDC Data Int.
Table> MODE A/N/E.
275.
Here A All Screens
276.
N NO Screens
277.
E Error Screens
278. Program 1:
279.
280. Differences between Call transaction method and Session transaction
method:
281. Call Transaction Method
282. Session Method
1.
2.
3.
4.

We can process only one transaction at time


We manually handle the errors
Call transaction faster than session method
This is suitable of Flat file contains less

1. We can process any no. Of transaction at a


time
2. It generates an Error Log that handles the
errors

152

amount of data
5. Call transaction is immediate Database
update.
6. Call transaction returns SY-SUBRC
7. Back schedule is not possible
8. This Synchronous update, Asynchronous
process

3. Session method is slower than Call


transaction.
4. This is suitable for the Flat files contain more
amounts of data.
5. After processing Session (By using SM35) the
data will be updated into database.
6. Session method never returns SY-SUBRC
7. Back ground scheduling possible
8. Asynchronous update, Synchronous process.

283.

284. Date: 31.07.2010


285.
286. Steps to work with Session Method
1. Create the Session by using BDC_OPEN_GROUP function module.
287.
The input for above function module is
I.
GROUP The Session name, which is used to processing the session.
II.
KEEP The session name is remained after processing the session
288.
For Active = X and Inactive = .
III.
HOLDDATE the Session is locked until it reaches hold date
IV.
USER Valid user name.

289.
290.
291.
2. LOOP AT <Data Internal Table>
292. ----293. ----Collect the Screen and Field details
294. ----295. CALL FUNCTION BDC_INSERT.
296. The input for function module is
1. Transaction code.
2. BDC Data Internal Table.

297.

ENDLOOP.

Repeat Step 2 for each and every transaction.


3. Close the Session by using BDC_CLOSE_GROUP.

298. OBJECT:
299.
Develop a conversion program to upload the vendor master data by
using Session method the Flat file contains Vendor number, Company code, Name,
Search term , recon account , Cash management group.
300. Steps to Process the Session
:
Execute SM35
Select Session name.
Click on Process application tool bar.

301.

OBJECT:

153

302.
Upload the vendor as well as customer master data by using BDC
session method the Vendor flat file contains vendor number, name, search term and
city. The customer flat file contains customer name, Search term and city.
303. HINTS:
304. IT_VENDOR
305. IT_CUSTOMER
306. CALL FUNCTION BDC_OPEN_GROUP
307.
I/P : GROUP = MTCODE.
308.
USER = RAKESH
309. LOOP AT IT_VENDOR INTO WA_VENDOR.

310.
311.
Vendor.
312.

-----------------------

Collect the screen and field details of

-------------

313. CALL FUNTION BDC_INSERT.


314. I/P: TRANSACTION CODE = XK01.
315.
BDC DATA INTERNAL TABLE = IT_BDCDATA
316. ENDLOOP.
317. LOOP AT IT_CUSTOMER INTO WA_CUSTOMER.

318.
319.
Customer.
320.

-----------------------

Collect the screen and field details of

-------------

321. ENDLOOP.
322. CALL FUNTION BDC_INSERT.
323. I/P: TRANSACTION CODE = XD01.
324.
BDC DATA INTERNAL TABLE = IT_BDCDATA.
325. ENDLOOP.
326. CALL FUNCTION BDC_CLOSE_GROUP.
327.

328. Error handling in Call transaction:


329. 1. By using FORMAT_MESSAGE Function module.
330. 2. Whenever we get the errors in call transaction method the we simply pass
errors into Session method
331. 3. By using BDCMSGCOLL and T100 Database tables.
332. FORMAT_MESSAGE:
333. It is function module which is used to handle the errors in call transaction the
input for the function module is message number,message id,language ,message
1,message2,message3,message4 .
334. The output for the function module is a meaningful description .

335. SYNTAX of CALL TRANSACTION:


336. CALL TRANSACTION < Transaction code> USING<BDC Internal Table>
MODE N MESSAGES INTO <Message Internal Table Name>
337. Note: In DDIC we have one structure BDCMSGCOLL which contains the above
fields so we simply declare Internal Table by referring BDCMSGCOLL structure.

154

338. Some thing missed here


339.

340.
341.
342.

343. Date: 01.08.2010


344. Some code is there
345.
346. SESSION OVERVIEW:
347. Analysis:
348. It is used to identify the transactions as well as their status and each screen of
the transaction and their fields (Fields Information)
349. Process:
350. There are 3 types of processing modes
351.
1.process in Foreground Mode A.
352.
2.Display Errors only Mode E
353.
3.Process in Back ground N.
354. Statistics:
355. It is used display quick information about session that is how many records
are successfully processed ,deleted or still to be processed .
356. Log:
357. This is used to identify the each and every step of entire session processing .
358. Recording:
359. This is used to open the transaction SHDB
360. Delete:
361. This is used to delete the session from overview.
362. Lock:
363. This is used to lock the session
364. Unlock:
365. This is used to unlock the session.
366.
367. /BEND: This command is used skip the entire processing of the session
368. /N: this command is used to skip the current transaction from the session
processing
369. /DDEL: this command is used to delete the current transaction from session
processing
370.
371. Steps to run the Session in Back ground:
372. METHODE 1:
373. Execute SM35.
374. Select the Session tool bar.
375. Select the Radio button
376.
Back ground.
377. Click on process.
378. METHODE 2:

155

379. Execute SE38.


380. Provide program name RSBDCSUB.
381. Execute.
382. Provide Session name
383. Execute.
384.
385. Filling screen elements using subroutines
386.
387. Steps to develop BDC program from Recording:
388. Execute SHDB.
389. Select Recording name
390. Click on PROGRAM in application toolbar
391.
Provide PROGRAM NAME:
392. Select Radio button
393.
Transfer from Recording.
394. Enter.
395. Provide TITLE:
396. Click on SOURCE CODE:

397. Date: 02.08.2010


398. SYNTAX OF CONCATENATE:
399. CONCATNATE <Variable 1> <Variable 2> <Variable 3>......<Variable N>
INTO < Variable> SEPARATED BY < Delimiter >
400.
401. E.g: DATA: A (10) TYPE C,
402.
B (10) TYPE C,
403.
C (10) TYPE C,
404.
A = RAKESH.
405.
B = MAMIDIPELLY.
406.
CONCATNATE A B INTO C SEPARATED BY .
407. RESULT: RAKESH MAMIDIPELLY
408. Note: Concatenate is only possible for CHAR Data types.
409. SYNTAX OF SPLIT:
410. SPLIT < Variable> AT < Delimiter > INTO <Variable 1> <Variable 2>
<Variable 3>......<Variable N>.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
156

423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.

436.
437.
438.
439.
440.
441.
442.
443.
444.
-

IDOC
7/8/10
Different types of distributing the data
1. Send entire copy
2. Send changes only (change pointer technique)
3. Get entire copy
Send change only (change pointer technique)

Whenever the changes occurred in the master data the standard sap
itself prepare one change document.
SMD (shared master data) is a tool which reads the distribution model
and indentifies the interested receiver.
If any receiver is available then it generates the change pointer for
the change document.
The change pointer technique reads the change pointer and
generates as well as dispatch the communication IDOC to their
particular receiver system.

445.
446.

Changes occurred in master data

447.

CDHDR

CDPOS

448.
(CHANGE DOCUMENT HEADER TABLE)
DOCUMENT ITEM TABLE)
449.
450.
451.
452.
453.

(CHANGE

ALE SERVICE LAYER


SMD
1. SENDER
4. LS800_S
AP1

2. RECEIV
ER
5. LS810_S
AP1

3. MSG
TYPE
6. CREMA
S
157

454.
IF ANY RECEIVER IS AVAILABE
455.
IF GENERATE CHANGE POINTER THE
CHANGE DOCUMENT
456.
DCP TABLE
457.
CHANGE POINTER TECHIQUE GENERATE
AS WELL AS
DISPATCH THE IDOC AS
RECEIVER
458.
459.
NOTE
-

Open the CDHDR the pass the obj ID as our vendor no, customer no,
and identify the obj class, changeneres.
Open the CDPOS table and pass the obj class ,obj ID and changes
which is identified in the CDHDR and get the old and new values of
object.

460.
461.
462.
463.
464.
systems.
465.
466.
467.
468.
generally.
469.
470.
471.
472.
473.
474.
475.
receiver system.
476.
477.
478.
479.
480.
481.
482.
483.
484. SENDER
485.
486.
487.

ALE configuration steps for change pointer technique


-Active the change pointer technique (BD61)
-Active the msg type (BD50)
-Generate as well as dispatch the idoc to the receiver
steps to activate the change pointer technique
-execute BD61
- Select the check box of change pointer activate
-click on save
-enter
steps to activate the msg type
-execute BD50
- identify the message type and activate select it
-click on save
steps to generate as well as dispatch the idoc to the
-execute SE38
- provide program name RBDMIDOC
-click on execute
-provide your msg type CREMAS
-execute
Get entire copy
RECEIVE
R
Application
message type
Requesting msg type

158

488.
CREFET
489.
490.

VENDOR

CREMAS

CUSTOMER
DEBFET
MATERIAL
MATFET

DEBMAS
MATMAS

491.

492.
NOTE :
493.
-EDIMSG is the standard data base table which contains
msg types and requesting msg types and idoc types.
494.
-ALEREQ01 is the idoc type for any requesting msg type.
495.
496.
497.
498.
499.
500.
501.
502.
503.
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
524.
525.
526.
527.
528.
529.
159

530.
531.
532.
533.

534.
800 CLIENT)
535.

536.
537.
538.
tool bar
539.
540.
541.
542.
543.
bar
544.
545.
546.
547.
548.
549.
550.
551.
552.
553.
554.
555.
556.
557.
558.
559.
560.
561.
562.
563.
564.
565.
566.
567.
568.
569.
570.
571.
572.

Step to maintain the RFC destination details (IN


Steps to create distribution model

-execute BD64
-click on change mode
-click on create model view on application
-provide short description
-provide technique name
-enter
-select the distribute model
-click on add msg type in the application tool
-provide
Sender
Receiver
Msg type
-enter
-repeat the same for all the receiver and msg type
-click on save
Steps to create port
-Execute WE21
-Select the transactional RFC
-Click on create in application tool bar
-Enter
-It automatically generate on port number
-provide short description
RTF destination
-Save
Steps to create outbound partner profile
-Execute WE20
-Select your partner in the left panel
-click on create outbound parameter
-provide your msg type
Port number
Basic type
-Save
Steps to send the quest

160

573.
574.
575.
576.
577.
578.
579.
580.
581.
582.
583.
584.
585.
586.
587.
588.
589.
590.
591.
592.
593.
594.
595.
596.
598.
599.
600.
601.
602.
603.
604.
605.
606.
607.
608.
609.
610.
611.
612.
613.
614.
615.
616.

-Execute BD15
COPY THE FORM
-Click execute
test idoc by using the WE05 (or) WE02
Steps to create the INBOUND PARTNER PROFILE
-Execute WE 20
-select the partner LS810-SAP1
-Provide msg type
Process code
-Save
test the idoc by using the WE05 (or ) WE02
Reprocess the idoc by using the BD81

IDOC FILTERING

Filter techniques
SEGMENT FILTERING

REDUCED IDOC

IDOC FILTERING
-Idoc filtering is always placed at the distribution model
597.
-Before generating the communication idoc the ALE service layer
reads the
distribution model and identify the interesting receiver.
-If any receivers available then it check the filtering condition
whether the given input satisfy
The filter condition or not.
-If it satisfies then only it generate communication IDOC.
Steps to create IDOC Filtering
Creating distribution model
-Execute BD64
-Expand your distribution model
-Expand msg type
-Double click no filter set
-Double click on create filter group
-Expand data filtering
-Expand filter group
-Double click on material type
-Click on insert line
-provide your material type
-Enter
-Enter
-Save

161

617.
618.
Create partner profile by using the WE 20
619.
620.
NOTE : IDOC filtering is used to drop the IDOC at run time.
621.
622.
623.
9/8/10 - 10/8/10
624.
SEGMENT FILTERING
625.
-Segment filtering is used to drop the segment permanently
626.
-The transaction code for segment filtering is BD56
627.
Steps to work with segment filtering
628.
After executing the WE05 (test the idoc)
629.
Execute BD56
630.
-Provide msg type
631.
-Click on new entries in the application tool bar
632.
-Provide your
633.
Segment Type
Sender
Type
Receiver
E1LFA1
LS
LS800_SAP1
LS
LS810_SAP1
634.
-Save
635.
-Enter
636.
Test the idoc by using the WE05
637.
638.
REDUCED IDOC
639.
-Reduced idoc is used to drop the segment as well as fields
permanently.
640.
-The transaction code for reduced idoc is BD53
641.
-Here we create a new msg type with the existing msg type.
642.
-Based on the new msg type configure the ALE.
643.
(Create distribution model , create output partner profile)
644.
Steps to work with Reduced IDOC
645.
-Execute BD53
646.
-Provide new msg type
647.
-Click on create
648.
-Provide your reference msg type
649.
-Provide short description
650.
-Enter
651.
Note :
652.
*We cant drop the mandatory segment which are in light green color
653.
-Select the required segment
654.
-Click on select the option in the application tool bar.
655.
-Double click on the segment select the fields click on select.
656.
-Repeat the same for all the segment .
657.
-Click on save.
658.
-With this new msg type we create the distribution model and out bound
partner profile

162

659.
660.
Difference b/w Segment filtering & Reduced idoc
661.
662.
SEGMENT FILTERING
663.
REDUCED IDOC
664.
In the segment filtering is used
665.
This is used to drop the
to drop the segment permanently.
segment as well as fields permanently.
666.
Here we no need to change the
667.
It generates the new msg type
ALE configuration.
based on this we configure the ALE.
668.
Here selected segment will be
669.
Here selected segment only
drop.
transformed.
670.
The transaction code is BD56
671.
The transaction code is BD53
672.
673.
674.
NOTE:
675.
-In the real time when ever we executing ABAP related transaction
code , if we get the error (your not authorized for the Transaction code and
transaction name) in the status bar , then we must execute SU53 transaction and
take the print screen and sends to basis (or) security people.
676.
677.
678.
679.
CUSTOM IDOC
680.
ALE configuration settings for the custom idoc outbound .
1. Create segment (WE31)
2. Create idoc (WE30)
3. Create message type (WE81)
4. Link the message type to idoc type (WE82)
5. Create the port number (WE21)
6. Create the outbound partner profile (WE20)
7. Distribution model is not required if we pass control record information
in the program.
681.
Steps to create Segment
682.
-Execute WE31
683.
-provide your segment name with z1
ex:
Z1VEN_SEG
684.
-Click on create.
685.
-Provide short description
686.
-provide
687.
FIELD NAME
DATA ELEMENT
688.
EID
ZZEID
689.
ENAME
ZZENAME
690.
691.
692.
-Click on save.
693.
NOTE
163

694.
-When ever we create the segment at the time an equal ant
structure is create in the DDIC as well as create segment definition.
695.
696.
Steps to create IDOC
697.
-Execute WE30
698.
-Provide your object name
699.
Ex: Zven_idoc
700.
-Click on create
701.
-provide short description
702.
-Enter
703.
-Select the idoc
704.
-Click on create segment
705.
-provide your segment name
706.
-Provide Max and Min values
707.
Max val
708.
Min val
709.
710.
-Save
711.
Save
712.
713.
Steps to create msg type
714.
-Execute WE 81
715.
-Click on change mode in application tool
716.
-Enter
717.
-Click in new entries in application tool bar.
718.
-Provide your msg type and short description
719.
-Click on save.
720.
721.
Steps to link the msg type to idoc type
722.
-Execute WE82
723.
-Click on change mode
724.
-Click new entries in the application tool bar
725.
-Provide your msg type basic type extension type
726.
-Save
727.
728.
Steps to Identify the release
729.
-Execute SE11
730.
-Open the table EDIMSG
731.
-Click on content
732.
-Click on execute
733.
-Select the Release field
734.
-Click on descending
735.
736.
Steps to create port number
737.
-Execute the WE21
738.
-Select transaction RFC

164

739.
740.
741.
742.
743.
744.
745.
746.
747.
748.
749.
750.
751.
752.
753.
754.
755.
756.
757.
758.
759.
760.
761.
762.
763.
764.
765.
766.
767.
768.
769.
770.
771.
772.
773.
774.
775.
776.
777.
778.
779.
780.
781.
782.
783.
784.

-Click on create
-Select the radio button own port
-provide your partner name
-Enter
-provide short description
- Provide RFC destination
-Click on save
Steps to create outbound partner profile
-Execute WE20
-Select the partner type LS
-Click on create
-Provide partner number
-Save
-Click on create outbound parameters
-provide msg type
-port number
-Select the radio button transfer IDOC
Immediate
-IDoc basic type
-Save

OUT BOUND PROCESS


STEP 1. PROVIDE THE IN PUT VALUES
VENDOR
MSG TYPE

TO

165

785.
786.
787.
788.
STEP 2 . BASED ON THE INPUT THE PREPARE THE MASTER
DATA
789.
790.
OUTBOUND
DISTRIBUTED MODELPROGRAM
791.
7. SEN
8. RE
9. MS
792.
APPLICATION
LAYER
MASTER
DATA
DE
CEI
G
793.
R
VE
TYP
794.
ALV
R
E
SERVICE
LAYER
10.
11.
12.
795.
IDOC1
IDOC2
796.
797.
798.
799.
ALE COMUNICATION LAYER
DISPATCH TO RECEIVER
800.
801.
STEP 3.
IDENTIFY THE RECEIVER
802.
STEP 4.
DISPATCH THE IDOC TO THEIR PARTICULAR RECEIVER
803.
804.
805.
Steps to
develop the custom idoc outbound program
1. Design the selection screen as fallows
806.
VENDOR
807.
MSG TYPE
808.
LOCAL SYS
809.
2. Generate the master idoc

TO

810.
(Based on the
given input we fetch the data base and place it into an in internal table)
3. Collect the control records information
811.
Receiver ,msg type , idoc --- )

(Sender ,

812.
4.Generate
as well as dispatch the communication idoc to their particular receivers.
813.
Design the
selection screen
814.
DATA V1 LIKE ZVEN_EMPDET-EID.
166

815.
SELECTION-SCREEN : BEGIN OF BLOCK B WITH FRAME
TITLE TEXT-001.
816.
SELECT-OPTIONS S_EID FOR V1.
817.
PARAMETER : P_MSG TYPE EDI_MESTYP OBLIGATORY ,
818.
P_LSYS TYPE LOGSYS.
819.
820.
SELECTION-SCREEN END OF BLOCK B.
821.
822.
Steps to
identify the data element of msg type and logical system
823.
-Execute
BD14 or BD16 or BD12
824.
-Place the
cursor msg type
825.
-Click on
F1
826.
-Click on
technical setting
827.
-Identify
the data data element
828.
829.
Generate the
master idoc
830.
NOTE :
Whenever we are working with custom idoc then we must declare one internal
table one internal table for data , one internal table for control record , one
internal table for communication idoc .
831.
832.
833.
SOURCE CODE FOR OUTBOUND PROCEE :
834.
835.
DATA : IT_DATA LIKE TABLE OF EDIDD,
836.
WA_DATA LIKE LINE OF IT_DATA.
837.
838.
DATA : IT_CONT LIKE TABLE OF EDIDC,
839.
WA_CONT LIKE LINE OF IT_CONT.
840.
841.
DATA : IT_COMM LIKE TABLE OF EDIDC,
842.
WA_COMM LIKE LINE OF IT_COMM.
843.
844.
DATA : WA_SEG LIKE Z1MADHU_SEG,
845.
IT_SEG LIKE TABLE OF WA_SEG.
846.
847.
SELECT EID ENAME EWMD ETRT FROM ZVEN_EMPDET INTO
TABLE IT_SEG WHERE
848.
EID IN S_EID.
849.
167

850.
LOOP AT IT_SEG INTO WA_SEG.
851.
WA_DATA-SEGNAM = 'Z1V_CS'.
852.
WA_DATA-SDATA = WA_SEG.
853.
854.
APPEND WA_DATA TO IT_DATA.
855.
CLEAR WA_DATA.
856.
857.
ENDLOOP.
858.
859.
WA_CONT-MESTYP = 'ZV_CMSG'.
860.
WA_CONT-RCVPOR = 'ZV_PORT'.
861.
WA_CONT-RCVPRT = 'LS' .
862.
WA_CONT-DOCTYP = 'Z1V_CID'.
863.
WA_CONT-RCVPRN = 'LS810-SAP1'.
864.
APPEND WA_CONT TO IT_CONT.
865.
CLEAR WA_CONT.
866.
867.
LOOP AT IT_CONT INTO WA_CONT.
868.
869.
870.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
871.
EXPORTING
872.
MASTER_IDOC_CONTROL
= WA_CONT
873.
TABLES
874.
COMMUNICATION_IDOC_CONTROL
=
IT_COMM
875.
MASTER_IDOC_DATA
=
IT_DATA.
876.
877.
commit WORK.
878.
ENDLOOP.
879.
880.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
881.
EXPORTING
882.
I_CALLBACK_PROGRAM
= SY-CPROG
883.
I_STRUCTURE_NAME
= 'EDIDC'
884.
*
IMPORTING
885.
TABLES
886.
T_OUTTAB
= IT_COMM.
887.
888.
Collect the
control records information is nothing but fill an internal table which contains the
fallowing fields
889.
RCVPOR RECEIVER PORT
890.
RCVPRT RECEIVER PARTNER TYPE
168

891.
RCVPRN - RECEIVER PARTNER NUMBER
892.
DOCTYP- IDOC TYPE
893.
MESTYP MESSAGE TYPE
894.
895.
SAMPLE
CODE :
896.
897.
WA_CONT-MESTYP = 'ZV_CMSG'.
898. WA_CONT-RCVPOR = 'ZV_PORT'.
899. WA_CONT-RCVPRT = 'LS' .
900. WA_CONT-DOCTYP = 'Z1V_CID'.
901. WA_CONT-RCVPRN = 'LS810-SAP1'.
902. APPEND WA_CONT TO IT_CONT.
903.
-Repeat the
same for all the receiver
904.
905.
MASTER_IDOC _DISTRIBUTE is function model which is used generate
as well as dispatch
906.
the
communication idoc to their particular receiver system.
907.
-This
function model acts like both ALE service layer as well as ALE communication
idoc to
908.
their
particular receiver system.
909.
-This
function model acts like both ALE service layer as well as ALE communication
layer.
910.
-The input
for the above function model control records work area and data internal table.
911.
-The output
for the function model is communication idoc internal table .
912.
913.
914.
SAMPLE
CODE
915.
916.
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
917.
EXPORTING
918.
MASTER_IDOC_CONTROL
= WA_CONT
919.
TABLES
920.
COMMUNICATION_IDOC_CONTROL
=
IT_COMM
169

921.
MASTER_IDOC_DATA
IT_DATA.
922.
923.
924.
by using the WEO5.
925.
926.
927.
928.
929.
930.
931.
932.
933.
934.
935.
936.
937.
938.
939.
940.
941.
942.
943.
944.
945.

Test the idoc

170

You might also like