Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

ABAP Tutorial 1

Download as pdf or txt
Download as pdf or txt
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 Resource Planning


Money
Men
Big Company Machine Well utilization of resources
Material
Marketing

Some Non ERP:-


 VB/JAVA – Front end
 ORACLE – Back end
Some ERP Products:-
 BAAN
 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

Non SAP
XI Xml System
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. Mathematical Operators.
2. Comparative Operators.
3. Relational & Logical Operators.

Mathematical Operators:-

Operator Description Example


+ Addition 2+3=5
- Subtraction 3-2=1
* Multiplication 2*3=6
** Exponential 2**3=2^3=8
/ Division 4/2=2
Mod (%) Remainder 3%2=1

Comparative Operators:-

Operator Description Example


< Or LT Less than a < b or a LT b
<= Or LE Less than or a <= b or a LE b
Equal to
> Or GT Greater than a > b or a GT b
>= Or GE Greater than or a >= b or a GE b
Equal to
= Or EQ Equal to a = b or a EQ b
<> Or NE Not equal a<>b or a NE b
Relational & Logical Operators:-

Operator Description Example


AND and a<b and a<c
OR or a<b or a<c
NOT not

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 Character Data types


Integer I Char C (Alpha numeric)
Float F Numeric Char N
Packed decimal P 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 0‘s)
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: In ABAP:

Int a, b, c; DATA A Type I. DATA: A Type I,


a=10; DATA B Type I. B Type I,
b=20; DATA C Type I. C Type I.
c=a+b; A=10. A=10.
Printf (―%d‖, c); B=20. B=20.
C=A+B. C=A+B.
Write C. Write:‘Total is‘, C.

NOTE:-
1. In ABAP each statement ends with dot ‗.‘.
2. ‗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 in ABAP
Int a, b, c; Parameter: A Type I,
Scanf (―%d, %d‖, &a, &b); B Type I.
C=a+b; DATA C Type I.
Printf (―%d‖, c); 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 Constants
*. DATA is the keyword to *. CONSTANTS is the declare
variables. Keyword to declare the Variables.
Syntax: - Syntax:-
DATA <vn> Type <DT> Constants <vn> Type <DT>value<value>
E.g.: Data A Type I E.g.: Constants A Type I value ‗10‘.
*.with in the program the *.constants variables values never value
of variable can change. 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> <subroutines>

Common terminology In ABAP


SQL:-
 Structured Query Language.
SQL

DDL DML DCL


(Data Definition Lang) (Data manipulation Lang) (Data Control Lang)
It is used to create the 1. Insert 1.Commit work
table as well as alter 2. Update 2.Rollback work
the tables. 3. Modify
4. Delete

 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 can‘t 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:-

 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.
E.g.:
Field name Data type Length Short description
E_ID char 10 Employee Id.
E_Name char 25 Employee name.
E_Add char 35 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 Key Data element Data type Length Short description


E_ID char 10

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 Place the data


element in the table element

Create the data Create the data


element element

Create the domain Create the domain

Bottom-up Approach Top-down Approach


Bottom-up Approach:-
Eid Ename Eadd

YSPRAO_730_EMP

Field name Domain Data element

Eid C YSPRAO_730_Eid
Employee id
10

YSPRAO_730_Eid YYSPRAO_730_EMP

Ename C YSPRAO_730_Ename
Employee name
25

YSPRAO_730_Ename YYSPRAO_730_Ename

C
YSPRAO_730_Eadd
Eadd
Employee address
35
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.

Eid Ename Eid Esal


1. Sai
Check table 2. Raj
3. Tej
4. Ram Foreign key table

Technical requirements to establish the primary & foreign key relationship:-


 The domain name of 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:- Emp
Eid Ename Eadd

C 10 C 25 C 35
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.

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 data- access 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 Hashed

Standard 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 won‘t 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 won‘t 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:-
Tables < Db table name >.
E.g.: 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 table‘s 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>.
E.g.: Clear IT_T001.

IT_T001 BUKRS BUTXT ORT01

NOTE:-
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.
E.g.: 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:-
Refresh < Internal table name>.
E.g.: Refresh IT_T001.

WA_T001 BUKRS BUTXT ORT01


1000 TCS HYD
2000 IBM CHE
3000 HCL BAN
After Refresh
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 Num of records


available in the
internal table.

KIND LINES

T S H
(Standard) (Sorted) (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 Some of the fields.


all fields. Select <F1>, <F2>….
Select *

 Reading the data from internal table.

Single record 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>.
E.g.: Append WA_T001 to IT_T001.

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:-
Insert <WA name> into table <IT name>.
E.g.: 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:-
Collect <WA name> into <IT name>.
E.g.: 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 ORT01


1000 TCS HYD
2000 IBM CHE
3000 HP MUM
4000 HCL BAN
5000 CAPTAMINI PUN

WA_T001 BUKRS BUTXT ORT01


3000 HP MUM

Reading a single record from the internal table based on condition:-

Syntax:-
Read table <IT name> into <WA name> with key <condition>.
E.g.: Read table IT_T001 into WA_T001 with key BUKRS=‘4000‘.

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

Syntax:-
Loop at <IT name> into <WA name> where <condition>.
Write ……….
Endloop.
E.g.: 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:-
Modify <IT name> from <WA name> transporting <field1>
<field2>……. Where <condition>.
E.g.: 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:-
Delete <IT name> where <condition>.
E.g.: 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:-
Sort <IT name> by <field name> descending.
E.g.: 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 Looping

If Case Conditional looping Unconditional looping

While Do

If:-
Syntax:-
If <condition>.
Block of statements.
Else/elseif <condition>.
Block of statements.
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:-
Case < statement > .
When < result 1>.
Block of statements.
When < result 2>.
Block of statements.
.
.
When others.
Block of statements.
Endcase.
E.g.: parameter day type I.
Case day.
When ‗1‘.
Write ‗sun‘.
When ‗2‘.
Write ‗mon‘.
.
.
When others.
Write ‗invalid day‘.
Endcase.

Note:-
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. Modify <DB table name> from <WA name>.
2. 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:-
Delete from <DB table name> where <condition>.
E.g.: 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 Sign=E
Option=BT Option=N
1000<x<2000 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 table
IT_T001 where BUKRS in S_BUKRS.

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> No-
extension.

 If you want remove the both extensions and intervals.

Syntax:-
Select-options <name of the select option> for <variable> no-
extension 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 BUTXT KNB1 BUKRS KUNNR


1000 TCS 1000 116
2000 IBM 1000 241
3000 HCL 3000 171
4000 HP 4000 991
5000 CAPGEMINI 4000 997
4000 1020
Output:- 1000 TCS 116
3000 HCL 171
4000 HP 991
4000 HP 997
4000 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 MAKT
MATNR MATNR
MTART 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 EKKO EKPO


LIFNR EBELN EBELN
NAME1 LIFNR EBELP
BSART 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_ FINAL-
EBELN, WA_ FINAL-BSART, WA_ FINAL-EBELP, WA_ FINAL-
MENGE, 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 BANKL BANKN

KNA1 KNB1 KNBK


KUNNR AKONT KUNNR
NAME1 KUNNR BANKS
BUKRS 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_FINAL-
AKONT, WA_FINAL-BANKS, WA_FINAL-BANKL, WA_FINAL-
BANKN.
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 1000 116
2000 IBM 1000 241
3000 HCL 3000 761
4000 HP
4000 991
5000 CSE
4000 997
4000 1020
Output:-
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 to

Display 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 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. Initialization.
2. At selection-screen.
3. At selection-screen on.
4. Start-of-selection.
5. Top-of-page.
6. End-of-page.
7. 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 Top-of-page
5
Initialization Selection- 3 End-of-
1 screen start-of- selection
2 Selection 4
At selection-screen 6 7
End-of-page

Initialization:-

Initialization.

S_BUKRS-low = ‗1000‘.
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:-
We have five different types of messages. They are:
1. ABEND (A).
2. WARNING (W).
3. ERROR (E).
4. INFORMATION (I).
5. 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:-
Message E/W <message no> (message class).
E.g.: 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:-
Message S <message no> (message class).
E.g.: 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:- 17/06/10.

VBAK:- sales document header table.

1. VBELN – Sales document number.


2. VBTYP – Sales document entry.
3. VKORG – Sales organization.
4. KUNNR – Customer number.
5. BUKRS – Company code.
6. AUART – Sales document type.

VBAP:- Sales document item table.

1. VBELN – Sales document number,


2. POSNR – item number.
3. MATNR – Material number.
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_T001-
ORT01.
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_T001-
ORT01.
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_T001-
ORT01.
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_KNB1-
AKONT.
HIDE: WA_KNB1-BUKRS, WA_KNB1-KUNNR, WA_KNB1-
AKONT.
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_KNA1-
ORT01.
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_EKKO-
LIFNR.
HIDE: / WA_EKKO-EBELN, WA_EKKO-BSART, WA_EKKO-
LIFNR.
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_EKPO-
MENGE, 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_T001-
ORT01.
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_LFB1-
AKONT.
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_LFA1-
ORT01.
ENDLOOP.
ENDIF.

19/06/10.
 In the above two techniques generates the next list based on the line-
selection, 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_T001-
ORT01.
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_EKKO-
BUKRS.
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_EKPO-
MENGE, 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. We can design up to 6 menu items in the menu bar.
2. System & help are the default menu items in the menu bar.
3. We can design up to 35 push buttons in the application tool bar.
4. 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_T001-
ORT01.
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_FINAL-
KUNNR.
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_FINAL-
LIFNR, 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_VBAK-
VBELN.

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_FINAL-
KUNNR, WA_FINAL-NAME1, WA_FINAL-POSNR, WA_FINAL-
NETWR, 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_FINAL-
MAKTX.
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 Functionality

Include Macros 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_T001-
ORT01.
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. DATA RESULT TYPE I.
DEFINE ZADD SUBROUTINE.
RESULT = &1 + &2.
END-OF-DEFINITION.
ADD 5 20.
WRITE RESULT.

2. 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 can‘t 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_T001-
ORT01.
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 Subroutines
1. In macro definition should be the 1. In subroutine calling should be the
first & the calling should be the next. first & definition should be the next.
2. The definition of the macro as 2. The definition of the subroutine as
well as the calling of the macro in well as the calling of the subroutine
the same program. may or may not be in the same
3. Macros can take up to 9 place program.
holders. 3. Subroutines can take any number
of place holders.
4. We can place any executable 4. We can‘t place any executable
statements after the definition of the statements after the definition of the
macro. macro.
5. Macros are used in HR ABAP. 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
it‘s 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. Attributes.
2. Import.
3. Export.
4. Changing.
5. 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 Subroutine


1. Function modules are global, i.e., 1. Subroutines are local, i.e., we can
we can access the function module access the subroutine with in the
with in the server as well as outside server only.
the server also.
2. We can test the function module 2. We can‘t test the subroutine
independently. independently without calling the
subroutine.
3. We can handle the errors in 3. We can‘t handle the errors in
function module. subroutine.
4. Function modules are defined by 4. Subroutines are defined by using
using SE37 transaction code. 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 S --- small
SELTEXT_M Column Heading M --- medium
SELTEXT_L L --- long
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

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 = 'BSART'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M ='DOC.TYPE'.
WA_FCAT-EMPHASIZE = 'C110'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_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 = IT_T001.
REFRESH IT_FCAT.
*** CALLING FORMS.
***DEF OF FORM ZTOP.

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 = IT_FCAT1
TABLES
T_OUTTAB = 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 = SY-CPROG
I_INTERNAL_TABNAME = 'WA_EKKO'
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_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_KNB1'
IT_EVENTS = IT_EVENT2
TABLES
T_OUTTAB = 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 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.

***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 = 'EBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_M = 'PUR.DOC'.
WA_FCAT-TABNAME = 'IT_EKPO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = 'EBELP'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'DOC.TYP'.
WA_FCAT-TABNAME = 'IT_EKPO'.

APPEND WA_FCAT TO IT_FCAT.


CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = 'MENGE'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'QTY'.
WA_FCAT-TABNAME = 'IT_EKPO'.

APPEND WA_FCAT TO IT_FCAT.


CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_M = 'UOM'.
WA_FCAT-TABNAME = 'IT_EKPO'.

APPEND WA_FCAT TO IT_FCAT.


CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = 'NETPR'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-SELTEXT_M = 'PRICE'.
WA_FCAT-TABNAME = '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 = 'IT_EKKO'
I_TABNAME_ITEM = 'IT_EKPO'
IS_KEYINFO = WA_KEY
TABLES
T_OUTTAB_HEADER = IT_EKKO
T_OUTTAB_ITEM = 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 = 'BELNR'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_S = 'ACC.DOC.NO'.
WA_FCAT-TABNAME = 'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'GJAHR'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_S = 'FISCAL YR'.
WA_FCAT-TABNAME = 'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'BUKRS'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_S = 'COMPANY CODE'.
WA_FCAT-TABNAME = 'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'BLART'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_S = 'A/C_DOC_TY'.
WA_FCAT-OUTPUTLEN = '8'.
WA_FCAT-TABNAME = 'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'BUDAT'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-SELTEXT_S = 'POST_DATE'.
WA_FCAT-TABNAME = 'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'BLDAT'.
WA_FCAT-COL_POS = '6'.
WA_FCAT-SELTEXT_S = 'DOC_DATE'.
WA_FCAT-TABNAME = 'IT_BKPF'.

APPEND WA_FCAT TO IT_FCAT.

***FILLING FOR BSEG(ACCOUNTING ITEM TABLE)

WA_FCAT-FIELDNAME = 'BELNR'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_S = 'ACC.DOC.NO'.
WA_FCAT-TABNAME = 'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'GJAHR'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_S = 'FISCAL YR'.
WA_FCAT-TABNAME = 'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'BUKRS'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_S = 'COMPANY CODE'.
WA_FCAT-TABNAME = 'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'BUZEI'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_S = 'ITEM'.
WA_FCAT-TABNAME = 'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'DMBTR'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-SELTEXT_S = 'LOCAL_CURR.'.
WA_FCAT-TABNAME = 'IT_BSEG'.

APPEND WA_FCAT TO IT_FCAT.

WA_FCAT-FIELDNAME = 'WRBTR'.
WA_FCAT-COL_POS = '6'.
WA_FCAT-SELTEXT_S = 'DOC_CURR.'.
WA_FCAT-TABNAME = '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 = 'EBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_M = 'PUR_DOC_NO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = 'EBELP'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'ITEM NO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = 'MENGE'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'Quantity'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_M = 'UOM'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.

WA_FCAT-FIELDNAME = 'NETPR'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_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 = 'DAT'
TABLES
DATA_TAB = 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 We can‘t execute a module pool program
independently without depends on an other independently through transaction code only
program we can execute the module pool program

The type of the executable program is 1 Type of the module pool program is M
All the standard reports are executable All the standard transactions are module pool
programs 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 ADDITIO
K N

FCOD-BAK 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 -save.

Step to execute the program


-select the transaction code in the left panel
-right click
-execute
Direct processing
Source code:

5/7/10

Program Screen 1 Screen 2 Screen 3

Leave program leave to screen 0 leave to screen 0


Obi

ccode

cname

city

INSERT BACK
TOO1

FCOD-BAK 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 C 10

C 25
NAME
C 15
PHONE NO
C 25
EMAIL C 10

COURSE C 10

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 won‘t provide any screen it provide a screen to enter the


To enter the input. Input values.
There is no default values by default sign = ‗I‘

Option = ‗BT‘
Both are used in where condition.

7/7/10
SCREEN 1000

CCODE TO

DISPL BACK
AY

SEL CCODE CUSTOMER RECON

SE
Download Back L

Attribute Line sel multiple and selcol

Code

WORKING WITH SUBSCREEN ARES


-Sub screen area must be placed in normal screen only.
-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)

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

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 can‘t 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 CALL FUNCTION ‗WRITE_FORM‘
* COCODE: &WA_T001-BUKRS& Exporting
* CNAME: & WA_T001-BUTXT& ELEMENT : ‗SURYA‘
* CCITY: & WA_T001-ORTO1& 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_KNB1-
ELEMENT = ‗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 SAP-
SCRIPT 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. TOP………………ENDTOP
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:
Address…Endaddress 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:
Protect…Endprotect 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. TOP………………ENDTOP:
Top…ENDTOP is used to print the heading in the main window.
/: TOP
* SURYA PRAVEEN SRI
/: ENDTOP
6. BOTTOM………...ENDBOTTOM:
BOTTOM…ENDBOTTOM is used to print the footer information in the main window.
/: BOTTOM
* PRAVEENASURYA
/: ENDBOTTOM
NOTE: TOP…ENDTOP & BOTTOM…ENDBOTTOM are works with in the main window only.
7. IF………………….ENDIF:
If…Endif functionality is similar as in the ordinary ABAP (Reports).
8. CASE…………ENDCASE:
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. PERFORM…ENDPERFORM:
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 VARIABLE WINDOW
1. Main window is the default window in SAP- 1. We can‘t create the variable window.
SCRIPT. we can‘t create the main window.
2. We can print the continuous text on the main 2. We can‘t print the continuous text on the
window. variable window. based on the window size
only it will print the data.
3. TOP…ENDTOP & 3. TOP…ENDTOP &
BOTTOM…ENDBOTTOM are works in BOTTOM…ENDBOTTOM are not work in
the main window only. the variable window.
4. Without main Window we can‘t create SAP- 4. Without variable Window we can‘t create
SCRIPT. SAP-SCRIPT.
5. We can place the SAME MAIN WINDOW 5. Variable window we can place only one
up to 99 times per page. time in a page.
6. We can SPLIT the main window into 6. We can‘t SPLIT the variable window into
smaller windows. smaller windows.
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 ‗20‘TW.
/: 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 can‘t 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 can‘t print the text in the page.
WINDOWS: we can place the same window in ‗n‘ number of pages but we can‘t 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 t-
code.
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 can‘t use the same paragraph and character
1. Multiple page formats are not possible In 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. That
3. Without a main window we can‘t design means form is available in all the clients under
SAPSCRIPT. 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. Colors are possible in SMARTFORMS.
5. For complex design we use the 6. We can use the same paragraph and character
SMARTFORMS formats for multiple MARTFORMS layouts.
7. Labels are possible here.
8. SAPSCRIPTS doesn‘t support all the
printers.
9. By using OPEN_FORM,
WRITE_FORM, CLOSE_FORM we
transfer the data from driver program to
layout.
10. Coding is not possible in the
SAPSCRIPT layout.
11. By using RSTXDBUG we DEBUG the
SAP-SCRIPT.
12. In SAP-SCRIPT downloaded file is .txt
format.
7. Labels are not possible here.
8. SMARTFOR support all the printers.
9. 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.
Steps To Create Te Smart Form:
1. Execute SMARTFORMS transaction.
2. Provide smart form name, Click on create, Provide short description.
3. In the left panel double click on form interface, under the import tab, Declare your
requirement.
P_BUKRS LIKE T001-BUKRS
4. In the left panel double click on global definitions, in the right panel click on types
tab.(declare what ever you want to print)
TYPES: BEGIN OF TY_T001,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
LAND1 LIKE T001-LAND1,
END OF TY_T001.
5. Click on global data tab (provide variables, type assignment and associated type)
Variable name Type assignment Associated type
WA_T001 TYPE TY_T001
6. Under initialization tab provide logic, input/output parameters.
Input parameters Output parameters
P_BUKRS WA_T001
Logic:
SELECT SINGLE BUKRS BUTXT ORT01 LAND1 FROM T001 INTO WA_T001
WHERE BUKRS = P_BUKRS.
7. Under pages and windows in the left panel
Select the main window right click -> create -> text.
(Text window is provided under main window)
8. Double click on the text.
In the general attributes tab click on Editor, provide the data.
* &WA_T001-BUKRS&
* &WA_T001-BUTXT&
* &WA_T001-ORT01&
* &WA_T001-LAND1&
COME BACK, SAVE, CHECK, ACTIVATE THE FORM.
9. In the menu bar click on environment -> Function Module Name. Function module is
generated (/1BCDWB/SF00000188).
Based on this function module develop the program in the ABAP editor, by calling this
function module.
ABAP Editor:
PARAMETER: PR_BUKRS LIKE T001-BUKRS.
CALL FUNCTION ‗/1BCDWB/SF00000188‘
EXPORTING
P_BUKRS = PR_BUKRS .
NOTE: ADRC is the database table which provides entire address information.
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,
Under import tab,
P-BUKRS LIKE T001-BUKRS
4. Double click on global definitions in the left panel
Under types tab declare TYPES.
TYPES: BEGIN OF TY_T001,
BUKRS LIKE T001-BUKRS,
ADRNR LIKE T001-ADRNR,
END OF TY_T001.
5. Under global data tab provide
WA-T001 TYPE TY_T001
6. Under initialization tab, implement logic, provide input and output parameters
Input parameters Output parameters
P_BUKRS WA_T001
Logic:
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.
Page -> right click -> create -> address.
8. Double click on address provide address number.
Address number &WA_T001-ADRNR&
SAVE, CHECK And ACTIVATE.
9. In the menu bar click on environment -> Function Module Name. Function module is
generated (/1BCDWB/SF00000189).
Based on this function module develop the program in the ABAP editor, by calling
this function module.
ABAP Editor:
PARAMETER: PR_BUKRS LIKE T001-BUKRS.
CALL FUNCTION ‗/1BCDWB/SF000001189‘
EXPORTING
P_BUKRS = PR_BUKRS .
Working with Logo:
We can work with .tiff or .BMP image only.
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.
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.
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
SAPSCRIPT SMARTFORMS
4. Click on activate.
(This is possible only after configuring the system).
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.
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.
NOTE:
Whenever the smart form is transported from development server to quality server and
production server the function module name never transport.

NOTE:
SSF_FUNCTION_MODULE_NAME is the function module which is used to generate the
function module based on the smart form.
Input for this function module is Smart form name.
Output for this function module is function module name.
NOTE:
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.
After creating the structure we refer it to the smart form.
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.
Component data type length short description
SIGN CHAR 1 SIGN
OPTIONS CHAR 2 OPTIONS
LOW CHAR 4 LOW
HIGH CHAR 4 HIGH
The length varies with the type like for P.O. Length is (C, 10).
SAVE, CHECK, ACTIVATE structure.
OBJECT: Based on the company code displaying the customers under company
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
S_BUKRS LIKE <STRUCTURE NAME>
4. Double click on global definitions in left panel, under types tab declare TYPES.
TYPES: BEGIN OF TY_FINAL,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
KUNNR LIKE KNB1-KUNNR,
END OF TY_FINAL.
5. Click on global definitions, under global data tab, declare the WA and IT.
WA_FINAL TYPE TY_FINAL
IT_FINAL TYPE TABLE OF TY_FINAL
6. Click on INITIALISATION tab, Provide input and output parameters and implement the logic.
Input output
S_BUKRS IT_FINAL
Logic:
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.
Double click on loop icon, in data tab provide
IT_FINAL INTO WA_FINAL
8. Select the loop in the left panel -> right click -> create -> text.
Text icon is created under main window.
Double click on text icon, click on text editor -> Provide the data.
&WA_FINAL-BUKRS& &WA_FINAL-BUTXT& &WA_FINAL-KUNNR&
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
ABAP Editor:
DATA: FN_MODULE TYPE RS38L_FNAM.
DATA V1 LIKE T001-BUKRS.
SELECT-OPTIONS SO_BUKRS FOR V1.
CALL FUNCTION ‗SSF_FUNCTION_MODULE_NAME‘
EXPORTING
FORM NAME = <FORM NAME>
IMPORTING
FM_NAME = FN_MODULE .
CALL FUNCTION FM_MODULE
TABLES
S_BUKRS = SO_BUKRS .
(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.]
Steps To Convert Sap script Layout to Smart Form:
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.

METHOD-2:
FB_MIGRATE_FORM is the function module which is used to convert script layout to smart
form.
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.
Steps to convert SAP-SCRIPT OUTPUT to PDF format:
This is the two step procedure.
3. Create SPOOL Request
4. 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.
Working With Smart Styles:
1. Smart styles are used to design the paragraph and character formats.
2. The T-code is SMARTSTYLES.
Steps To Create Paragraph & Character Format:
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
Font family ELVE
Font size 6.0 pt
Font style OLD
COLOR
5. Under tabs tab, Provide tab positions
Repeat the same for all the paragraph formats.
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
Font family ELVE
Font size 6.0 pt
Font style OLD
COLOR
Repeat the same for all the character formats
8. In the left panel double click on the header data
Standard settings
Standard paragraph P1
SAVE, CHECK, ACTIVATE the SMARTSTYLES.
OBJECT: Based on the purchasing
document number display the vendor
address and purchasing document
details.
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
P_EBELN LIKE EKKO-EBELN
4. In the left panel click on global
definitions, Under types tab provide
types
TYPES: BEGIN OF TY_EKKO,
EBELN LIKE EKKO-EBELN,
LIFNR LIKE EKKO-LIFNR,
END OF TY_EKKO.
TYPES: BEGIN OF TY_LFA1,
LIFNR LIKE LFA1-LIFNR,
ADRNR LIKE LFA1-ADRNR,
END OF TY_LFA1.
TYPES: BEGIN OF TY_EBELN,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF TY_EKPO.
Under on global data tab,
WA_EKKO TYPE TY_EKKO
WA_LFA1 TYPE TY_LFA1
WA_EKPO TYPE TY_EKPO
IT_EKPO TYPE TABLE OF TY_EKPO
W_TOTAL LIKE EKPO-NETPR
Under initialization tab
Input output
P_EBELN WA_EKKO
WA_EKKO WA_LFA1
IT_EKPO
Logic:
SELECT SINGLE EBELN LIFNR FROM EKKO INTO WA_EKKO WHERE EBELN =
P_EBELN.
SELECT SINGLE LIFNR ADRNR FROM LFA1 INTO WA_LFA1 WHERE LIFNR=
WA_EKKO-LIFNR.
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.
&WA_LFA1_ADRNR&
7. In the left panel select address Right click -> create -> graphics.
In the left panel double click on the graphics
NAME <SURYA>
OBJECT GRAPHICS
ID BMAP
Select the radio button bitmap image
8. Select the main window in the left panel, right click -> create -> table.
Under the tables tab, select the line right click -> rename the line -> provide new name,
ENTER.
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.
Click on the data tab.
LOOP:
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.
In the left panel you can see cells under header
Click on 1st cell -> right click -> create -> text.
Double click on the text Click on general attributes tab, Click on text editor. P1 PUR.DOC
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.
Double click on text, click on text editor, Provide data.
P2 &WA_EKPO-EBELN&
Repeat the same step 12 for all the cells.
In the left panel select the net price. Right click -> create -> flow logic -> program lines.
Double click on the code in the left panel.
Input output
EKPO-NETPR W_TOTAL
W_TOTAL = W_TOTAL + WA_EKPO-NETPR
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.
Click on display framed patterns Select your pattern.
14. Select the footer in the left panel right click -> create -> table line. Select the line.
Select the cell -> create -> text.
Click on text editor provide data with its paragraph.
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.
ABAP Editor:
DATA FN_MODULE TYPE RS38L_FNAM.
PARAMETER PR_EBELN LIKE EKKO-EBELN.
CALL FUNCTION ‗SSF_FUNCTION_MODULE_NAME‘
EXPORTING
FORM NAME = <FORM NAME>
IMPORTING
FM_NAME = FN_MODULE .
CALL FUNCTION FM_MODULE
TABLES
P_EBELN = PR_EBELN .
Events in Internal Table or Control Break Statements:
1. AT FIRST
2. AT LAST
3. AT NEW <field name>
4. AT END OF <field name>
These events are work with in the LOOP…ENDLOOP of the internal table. Each event ends with
ENDAT.
NOTE: Before using these events we must sort the internal table based on the new field.
AT FIRST: This is the event which is triggered at the
first record of the internal table
Advantage: This is used to print the heading.
AT LAST: This is the event which is triggered at the
last record of the internal table.
Advantage: This is used to print the grand totals.
AT NEW: This is the event which is triggered at the
new record of each block.
Advantage: This is used to print the individual heading
of each record.
AT END OF: This is the event which is triggered at the
last record of each block.
Advantage: This is used to print the subtotals.

REQUIREMENT:
Logic:
LOOP AT IT_EKPO INTO WA_EKPO.
AT FIRST.
WRITE /‘PURCHASING DOCUMENTS‘.
ENDAT
AT NEW EBELN.
WRITE /WA_EKPO-EBELN.
ENDAT
WRITE : / WA_EKPO-EBELP,WA_EKPO-
MENGE,WA_EKPO-MEINS, WA_EKPO-
NETPR.
S_TOTAL = S_TOTAL + WA_EKPO-
NETPR.
G_TOTAL = G_TOTAL + WA_EKPO-
NETPR.
AT END OF EBELN.
WRITE: /‘SUBTOTAL‘, S_TOTAL.
CLEAR W_STOTAL.
ENDAT.
ATLAST
WRITE: / „GRANDTOTAL IS‘ G_TOTAL.
ENDAT.
ENDLOOP.
BDC
(Batch Data Conversions/Communication)
BDC is used to upload the data from the flat file to their particular Database table.
Writing a BDC Program is nothing but automate existing transaction code.
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.

Some of the Important Transaction code:


1. XK01/MK01/FK01 – Create Vendor. KS03 – Display Cost Centre
XK01 – Central 7. KE51 – Create Profit Centre
MK01 –Material wise KE52 – Change Profit Centre
FK01 - Finance KE53 – Display Profit Centre
XK02/MK02/FK02 – Change 8. CS01 – Create BOM
Vendor. CS02 – Change BOM
XK03/MK03/FK03 – Display CS03 – Display BOM
Vendor. 9. VL01 – Create Delivery
2. XD01/VD01/FD01 – Create Customer VL02 – Change Delivery
XD02/VD02/FD02 – Change VL03 – Display Delivery
Customer 10. VF01 – Create Billing
XD03/VD03/FD03 – Display 11. ME51N – Create Purchase
Customer Requisition
3. MM01 – Create Material ME52N – Change Purchase Req.
MM02 –Change Material ME53N – Display Purchase
MM03 – Display Material Requisition
4. ME21N – Create Purchasing Order 12. MB01 – Create Material Delivered
ME22N – Change Purchasing Order MB02 – Change Material
ME23N – Display Purchasing Order Delivered
5. VA01 – Create Sales Order MB03 – Display Material
VA02 – Change Sales Order Delivered
VA03 – Display Sales Order 13. COR1 – Create Process Order
6. KS01 – Create Cost Centre COR2 – Change Process Order
KS02 – Change Cost Centre COR3 – Display Process Order
14. CO01 – Create Production Order
CO02 – Change Production Order
CO03 – Display Production Order
15. C201 – Create Recipe
C202 – Change Recipe
C203 – Display Recipe
16. MSC1N – Create Batches
MSC2N – Change Batches
MSC3N – Display Batches
17. FB01 – Create Accounting Document
FB02 – Change Accounting
Document
FB03 – Display Accounting
Document
18. FI01 – Create Bank
FI02 – Change Bank
FI03 – Display Bank
19. KSH1 – Create Cost Centre Group
KSH2 – Change Cost Centre
Group
KSH3 – Display Cost Centre
Group
20. CL01 – Create Class
CL02 – Change Class
CL03 – Display Class
VF03 – Display Billing

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.
STEPS IN DETAIL:
STEP 1: Analyse the Each and Every screen and their fields Information is nothing but
collect the Technical information of each screen and field.
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.
Note:
SHDB transaction code which collects technical information of the entire transaction
(RECORDING).
STEPS TO THE RECORDING:
 Execute SHDB
 Click on NEW RECORDING in the application tool bar
 Provide RECORDING: YRAKESH_XK01.
TRANSACTION CODE: XK01.
 Click on START RECORDING
 Provide details in XK01
Vendor: _______
Account: ______
 Provide Name:________
Search term: ___
Country: _______
Note: Whenever we click on SAVE button record will be stopped.
Note: BDC_OKCODE is the last entry of any screen.
STEP2: Extract data from NON-SAP to Flat File
Note: This is End user or Functional people job.

Fig .1

STEP 3:

Date: 29.07.2010
UPLOAD:

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

Program:
*---------------------------------------------------------------------*
*WORKING WITH FILES USING UPLOAD FM *
*---------------------------------------------------------------------*
REPORT YRAKESH_FILE1_UPLOAD.

DATA: BEGIN OF WA_FILE,


BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_FILE.
DATA IT_FILE LIKE TABLE OF WA_FILE.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_FILE
.
LOOP AT IT_FILE INTO WA_FILE.
WRITE: / WA_FILE-BUKRS, WA_FILE-BUTXT, WA_FILE-ORT01.
ENDLOOP.
GUI_UPLOAD:
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.
F4_FILENAME:
It is function module is used to browse the file the output for the function module is
filename.
AT SELECTION-SCREEN ON VALUE-REQUEST:
It is an Event which is triggered at the time of user clicks F4 button.
Program 2:
*---------------------------------------------------------------------*
*PROG TO UPLOAD DATA FROM FLAT FILE TO INTRENAL TABLE USING
GUI_UPLOAD
*FM
*---------------------------------------------------------------------*
REPORT YRAKESH_FILE2_GUI_UPLOAD.
DATA: BEGIN OF WA_FILE,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_FILE.

149
DATA IT_FILE LIKE TABLE OF WA_FILE.
DATA V1 TYPE STRING.
PARAMETER P_FILE LIKE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE
.
START-OF-SELECTION.
V1 = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V1
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_FILE
.
LOOP AT IT_FILE INTO WA_FILE.
WRITE: / WA_FILE-BUKRS, WA_FILE-BUTXT, WA_FILE-ORT01.
ENDLOOP.
ALSM_EXCEL_TO_INTERNAL _TABLE:
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
Program 3

*---------------------------------------------------------------------*
*PROG TO UPLOAD DATA FROM EXCEL SHEET TO INTRENAL TABLE USING
*ALSM_EXCEL_TO_INTERNAL_TABLE FM
*---------------------------------------------------------------------*
REPORT YRAKESH_FILE3_XSEL_FM.
***DECLARE IT TABLE****
DATA: BEGIN OF WA_FILE,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
ORT01 LIKE T001-ORT01,
END OF WA_FILE.
DATA IT_FILE LIKE TABLE OF WA_FILE.

***DECLARING IT FOR CONVERTING FM IT TO DATA IT.


DATA: WA LIKE ALSMEX_TABLINE, ―XCEL FM O/P IT TYPE
IT LIKE TABLE OF WA.
***DECLARATIONS
DATA V1 TYPE RLGRAP-FILENAME. "XCEL I/P FILENAME TYPE

150
PARAMETER: P_FILE LIKE IBIPPARMS-PATH. " F4_FILENAME FM
FILE_NAME TYPE
PARAMETER: P_BC TYPE I,
P_BR TYPE I,
P_EC TYPE I,
P_ER TYPE I.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE
.
START-OF-SELECTION.
V1 = P_FILE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = V1
I_BEGIN_COL = P_BC
I_BEGIN_ROW = P_BR
I_END_COL = P_EC
I_END_ROW = P_ER
TABLES
INTERN = IT
.
***LOGIC TO CONVERT XCEL FM TO OUR DATA IT.
LOOP AT IT INTO WA.
CASE WA-COL.
WHEN '0001'.
WA_FILE-BUKRS = WA-VALUE.
WHEN '0002'.
WA_FILE-BUTXT = WA-VALUE.
WHEN '0003'.
WA_FILE-ORT01 = WA-VALUE.
ENDCASE.
AT END OF ROW.
APPEND WA_FILE TO IT_FILE.
ENDAT.
ENDLOOP.
***DISPLAYING OUT PUT.
LOOP AT IT_FILE INTO WA_FILE.
WRITE: / WA_FILE-BUKRS, WA_FILE-BUTXT, WA_FILE-ORT01.
ENDLOOP.
DOWN LOAD:
It is function module which is used to browse the file as well as download the data into
Internal table from File.
The input for above function module is file type = ‘DAT’ and Data Internal Table
which data you want download.

151
GUI_DOWNLOAD:
It is function module which is used to download data from Internal table to Present
Server.
The input for the above function module is File Name with Extension, an Internal table
which contains the data.

APPLICATION SERVER:
It is SAP Directory the transaction code for SAP Directory AL11.
Steps to Download the data into Application Server:
1. Open the file <Data set> in write mode.
2. Loop at <Data Internal Table > Into <Work Area>.
Transfer the data From <Work Area> to <File>.
End loop.
3. Close the file ‗<data set>‘.
SYNTAX of Open Data Set:
OPEN DATASET ‗<file name>‘ IN BINARY/TEXT FOR OUTPUT/INPUT.
SYNTAX of Close Data Set:
CLOSE DATASET‘<file name>‘.
SYNTAX of Transfer Data set:
TRANSFER <Work Area Name> TO ‗<File Name>‘.
Note: “.” (Dot) directory default directory in AL11.

*---------------------------------------------------------------------*
*PROG TO DOWN LOAD DATA TO APPLICATION SERVER. (IN ECC 4.7) *
*---------------------------------------------------------------------*
REPORT YRAKESH_FILE4_APP_SER_DOWN.
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 FROM T001 INTO TABLE IT_T001.
OPEN DATASET 'RAKESH' IN TEXT MODE ENCODING DEFAULT FOR
OUTPUT.
LOOP AT IT_T001 INTO WA_T001.
TRANSFER WA_T001 TO 'RAKESH'.
ENDLOOP.
CLOSE DATASET 'RAKESH'.
Date: 30.07.2010
Steps to upload the data from Application Server:
1. Open the file (Data set) in Read mode.
2. Do
READ THE File (Data set) INTO <Work Area>.
IF SY-SUBRC = O.
APPEND <Work Area> TO <Internal Table>

152
ELSE
EXIT
ENDIF.
ENDO.
3. CLOSE THE File (Data Set)
PROGRAM:
<TO READ DATA SET>

STEP4:
Collect the screen and field elements nothing but fill Internal table contains five fields
that is
1. PROGRAM -- Program name
2. DYNPRO – Screen number
3. DYNBEGIN – Starting Position
4. FNAM – Field Name
5. FVAL – Field Value
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.
STEP5:
Calling the transaction is of two types
1. Call Transaction Method
2. Session Method

Call Transaction Method:


SYNTAX:
CALL TRANSACTION <Transaction Code> USING <BDC Data Int. Table>
MODE A/N/E.
Here A  All Screens
N  NO Screens
E  Error Screens
Program 1:

Differences between Call transaction method and Session transaction method:


Call Transaction Method Session Method
1. We can process only one transaction at time 1. We can process any no. Of transaction at a
2. We manually handle the errors time
3. Call transaction faster than session method 2. It generates an Error Log that handles the
4. This is suitable of Flat file contains less errors
amount of data 3. Session method is slower than Call
5. Call transaction is immediate Database transaction.
update. 4. This is suitable for the Flat files contain
6. Call transaction returns SY-SUBRC more amounts of data.
7. Back schedule is not possible 5. After processing Session (By using SM35)
8. This Synchronous update, Asynchronous the data will be updated into database.
process 6. Session method never returns SY-SUBRC
7. Back ground scheduling possible
8. Asynchronous update, Synchronous

153
process.

Date: 31.07.2010
Steps to work with Session Method
1. Create the Session by using ‗BDC_OPEN_GROUP‘ function module.
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
For Active = ‗X‘ and Inactive = ‗‘.
III. HOLDDATE – the Session is locked until it reaches hold date
IV. USER – Valid user name.

2. LOOP AT <Data Internal Table>


-----
----- Collect the Screen and Field details
-----
CALL FUNCTION ‗BDC_INSERT‘.
The input for function module is
1. Transaction code.
2. BDC Data Internal Table.
ENDLOOP.
 Repeat Step 2 for each and every transaction.
3. Close the Session by using ‗BDC_CLOSE_GROUP‘.
OBJECT:
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.
Steps to Process the Session :
 Execute SM35
 Select Session name.
 Click on Process application tool bar.
OBJECT:
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.
HINTS:
IT_VENDOR
IT_CUSTOMER
CALL FUNCTION ‗BDC_OPEN_GROUP‘
I/P : GROUP = ‗MTCODE‘.
USER = ‗RAKESH‘

154
LOOP AT IT_VENDOR INTO WA_VENDOR.
------------
------------ Collect the screen and field details of Vendor.
-------------
CALL FUNTION ‗BDC_INSERT‘.
I/P: TRANSACTION CODE = ‗XK01‘.
BDC DATA INTERNAL TABLE = ‗IT_BDCDATA‘
ENDLOOP.
LOOP AT IT_CUSTOMER INTO WA_CUSTOMER.
------------
------------ Collect the screen and field details of Customer.
-------------
ENDLOOP.
CALL FUNTION ‗BDC_INSERT‘.
I/P: TRANSACTION CODE = ‗XD01‘.
BDC DATA INTERNAL TABLE = ‗IT_BDCDATA‘.
ENDLOOP.
CALL FUNCTION ‗BDC_CLOSE_GROUP‘.

Error handling in Call transaction:


1. By using ‗FORMAT_MESSAGE‘ Function module.
2. Whenever we get the errors in call transaction method the we simply pass errors
into Session method
3. By using BDCMSGCOLL and T100 Database tables.
FORMAT_MESSAGE:
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 .
The output for the function module is a meaningful description .
SYNTAX of CALL TRANSACTION:
CALL TRANSACTION ‗< Transaction code>‘ USING<BDC Internal Table> MODE
‗N‘ MESSAGES INTO <Message Internal Table Name>
Note: In DDIC we have one structure BDCMSGCOLL which contains the above fields
so we simply declare Internal Table by referring BDCMSGCOLL structure.
Some thing missed here

Date: 01.08.2010
Some code is there

SESSION OVERVIEW:
Analysis:

155
It is used to identify the transactions as well as their status and each screen of the
transaction and their fields (Fields Information)
Process:
There are 3 types of processing modes
1.process in Foreground Mode ‗A‘.
2.Display Errors only Mode ‗E‘
3.Process in Back ground ‗N‘.
Statistics:
It is used display quick information about session that is how many records are
successfully processed ,deleted or still to be processed .
Log:
This is used to identify the each and every step of entire session processing .
Recording:
This is used to open the transaction SHDB
Delete:
This is used to delete the session from overview.
Lock:
This is used to lock the session
Unlock:
This is used to unlock the session.

/BEND: This command is used skip the entire processing of the session
/N: this command is used to skip the current transaction from the session processing
/DDEL: this command is used to delete the current transaction from session processing

Steps to run the Session in Back ground:


METHODE 1:
Execute SM35.
Select the Session tool bar.
Select the Radio button
Back ground.
Click on process.
METHODE 2:
Execute SE38.
Provide program name RSBDCSUB.
Execute.
Provide Session name
Execute.

Filling screen elements using subroutines

Steps to develop BDC program from Recording:


Execute SHDB.
Select Recording name
Click on PROGRAM in application toolbar
Provide PROGRAM NAME:

156
Select Radio button
Transfer from Recording.
Enter.
Provide TITLE:
Click on SOURCE CODE:
Date: 02.08.2010
SYNTAX OF CONCATENATE:
CONCATNATE <Variable 1> <Variable 2> <Variable 3>......<Variable N> INTO <
Variable> SEPARATED BY < Delimiter >

E.g: DATA: A (10) TYPE C,


B (10) TYPE C,
C (10) TYPE C,
A = ‗RAKESH‘.
B = ‗MAMIDIPELLY‘.
CONCATNATE A B INTO C SEPARATED BY ‗ ‗.
RESULT: RAKESH MAMIDIPELLY
Note: Concatenate is only possible for ‗CHAR‘ Data types.
SYNTAX OF SPLIT:
SPLIT < Variable> AT < Delimiter > INTO <Variable 1> <Variable 2> <Variable
3>......<Variable N>.

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

Changes occurred in master data

CDHDR CDPOS

(CHANGE DOCUMENT HEADER TABLE) (CHANGE DOCUMENT


ITEM TABLE)

ALE SERVICE LAYER


SMD

SENDER RECEIVER MSG TYPE


IF ANY RECEIVER IS AVAILABE LS800_SAP1 LS810_SAP1 CREMAS
IF GENERATE
CHANGE POINTER THE CHANGE DOCUMENT
DCP TABLE
CHANGE POINTER TECHIQUE GENERATE AS WELL AS
DISPATCH THE IDOC AS RECEIVER

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.

ALE configuration steps for change pointer technique

158
-Active the change pointer technique (BD61)
-Active the msg type (BD50)
-Generate as well as dispatch the idoc to the receiver systems.

steps to activate the change pointer technique


-execute BD61
- Select the check box of change pointer activate generally.
-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 receiver system.
-execute SE38
- provide program name RBDMIDOC
-click on execute
-provide your msg type CREMAS
-execute
Get entire copy

SENDER RECEIVE
R

Application message type Requesting msg type


VENDOR CREMAS CREFET
CUSTOMER DEBMAS DEBFET
MATERIAL MATMAS MATFET

NOTE :
-EDIMSG is the standard data base table which contains msg types and requesting msg
types and idoc types.
-ALEREQ01 is the idoc type for any requesting msg type.

159
Step to maintain the RFC destination details (IN 800 CLIENT)
Steps to create distribution model
-execute BD64
-click on change mode
-click on create model view on application tool bar
-provide short description
-provide technique name
-enter
-select the distribute model
-click on add msg type in the application tool bar
-provide
Sender

Receiver

Msg type
-enter
-repeat the same for all the receiver and msg type
-click on save

160
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

-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

 Filter techniques

IDOC FILTERING SEGMENT FILTERING REDUCED IDOC

 IDOC FILTERING
-Idoc filtering is always placed at the distribution model
-Before generating the communication idoc the ALE service layer reads the
distribution model and identify the interesting receiver.

161
-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

Create partner profile by using the WE 20

NOTE : IDOC filtering is used to drop the IDOC at run time.

9/8/10 - 10/8/10
SEGMENT FILTERING
-Segment filtering is used to drop the segment permanently
-The transaction code for segment filtering is BD56
Steps to work with segment filtering
After executing the WE05 (test the idoc)
Execute BD56
-Provide msg type
-Click on new entries in the application tool bar
-Provide your
Segment Type Sender Type Receiver
E1LFA1 LS LS800_SAP1 LS LS810_SAP1
-Save
-Enter
Test the idoc by using the WE05

REDUCED IDOC
-Reduced idoc is used to drop the segment as well as fields permanently.
-The transaction code for reduced idoc is BD53
-Here we create a new msg type with the existing msg type.

162
-Based on the new msg type configure the ALE.
(Create distribution model , create output partner profile)
Steps to work with Reduced IDOC
-Execute BD53
-Provide new msg type
-Click on create
-Provide your reference msg type
-Provide short description
-Enter
Note :
*We can‘t drop the mandatory segment which are in light green color
-Select the required segment
-Click on select the option in the application tool bar.
-Double click on the segment select the fields click on select.
-Repeat the same for all the segment .
-Click on save.
-With this new msg type we create the distribution model and out bound partner
profile

Difference b/w Segment filtering & Reduced idoc

SEGMENT FILTERING REDUCED IDOC


In the segment filtering is used to drop the This is used to drop the segment as well
segment permanently. as fields permanently.
Here we no need to change the ALE It generates the new msg type based on this
configuration. we configure the ALE.
Here selected segment will be drop. Here selected segment only transformed.
The transaction code is BD56 The transaction code is BD53

NOTE:
-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.

CUSTOM IDOC
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)

163
6.Create the outbound partner profile (WE20)
7.Distribution model is not required if we pass control record information in
the program.
Steps to create Segment
-Execute WE31
-provide your segment name with z1 ex: Z1VEN_SEG
-Click on create.
-Provide short description
-provide
FIELD NAME DATA ELEMENT
EID ZZEID
ENAME ZZENAME
- -
- -
-Click on save.
NOTE
-When ever we create the segment at the time an equal ant structure is create
in the DDIC as well as create segment definition.

Steps to create IDOC


-Execute WE30
-Provide your object name
Ex: Zven_idoc
-Click on create
-provide short description
-Enter
-Select the idoc
-Click on create segment
-provide your segment name
-Provide Max and Min values
Max val
Min val

-Save
Save

Steps to create msg type


-Execute WE 81
-Click on change mode in application tool
-Enter
-Click in new entries in application tool bar.
-Provide your msg type and short description
-Click on save.

 Steps to link the msg type to idoc type


-Execute WE82

164
-Click on change mode
-Click new entries in the application tool bar
-Provide your msg type basic type extension type
-Save

Steps to Identify the release


-Execute SE11
-Open the table EDIMSG
-Click on content
-Click on execute
-Select the Release field
-Click on descending

Steps to create port number


-Execute the WE21
-Select transaction RFC
-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

165
OUT BOUND PROCESS
STEP 1. PROVIDE THE IN PUT VALUES

VENDOR TO
MSG TYPE

STEP 2 . BASED ON THE INPUT THE PREPARE THE MASTER DATA

OUTBOUND DISTRIBUTED
MODEL PROGRAM

SENDER RECEIVER MSG TYPE


APPLICATION LAYER MASTER DATA
ALV SERVICE
LAYER

IDOC1 IDOC2

DISPATCH TO RECEIVER
ALE COMUNICATION LAYER
STEP 3. IDENTIFY THE RECEIVER
STEP 4. DISPATCH THE IDOC TO THEIR PARTICULAR RECEIVER

Steps to develop the custom idoc outbound program


1. Design the selection screen as fallows

VENDOR TO
MSG TYPE
LOCAL SYS
2. Generate the master idoc

166
(Based on the given input we fetch the data base and place it into an in internal
table)
3. Collect the control records information

(Sender , Receiver ,msg type , idoc --- )


4.Generate as well as dispatch the communication idoc to their particular receivers.
Design the selection screen
DATA V1 LIKE ZVEN_EMPDET-EID.
SELECTION-SCREEN : BEGIN OF BLOCK B WITH FRAME TITLE TEXT-
001.
SELECT-OPTIONS S_EID FOR V1.
PARAMETER : P_MSG TYPE EDI_MESTYP OBLIGATORY ,
P_LSYS TYPE LOGSYS.

SELECTION-SCREEN END OF BLOCK B.

Steps to identify the data element of msg type and logical system
-Execute BD14 or BD16 or BD12
-Place the cursor msg type
-Click on F1
-Click on technical setting
-Identify the data data element

Generate the master idoc


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 .

SOURCE CODE FOR OUTBOUND PROCEE :

DATA : IT_DATA LIKE TABLE OF EDIDD,


WA_DATA LIKE LINE OF IT_DATA.

DATA : IT_CONT LIKE TABLE OF EDIDC,


WA_CONT LIKE LINE OF IT_CONT.

DATA : IT_COMM LIKE TABLE OF EDIDC,


WA_COMM LIKE LINE OF IT_COMM.

DATA : WA_SEG LIKE Z1MADHU_SEG,


IT_SEG LIKE TABLE OF WA_SEG.

SELECT EID ENAME EWMD ETRT FROM ZVEN_EMPDET INTO TABLE


IT_SEG WHERE
EID IN S_EID.

167
LOOP AT IT_SEG INTO WA_SEG.
WA_DATA-SEGNAM = 'Z1V_CS'.
WA_DATA-SDATA = WA_SEG.

APPEND WA_DATA TO IT_DATA.


CLEAR WA_DATA.

ENDLOOP.

WA_CONT-MESTYP = 'ZV_CMSG'.
WA_CONT-RCVPOR = 'ZV_PORT'.
WA_CONT-RCVPRT = 'LS' .
WA_CONT-DOCTYP = 'Z1V_CID'.
WA_CONT-RCVPRN = 'LS810-SAP1'.
APPEND WA_CONT TO IT_CONT.
CLEAR WA_CONT.

LOOP AT IT_CONT INTO WA_CONT.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'


EXPORTING
MASTER_IDOC_CONTROL = WA_CONT
TABLES
COMMUNICATION_IDOC_CONTROL = IT_COMM
MASTER_IDOC_DATA = IT_DATA.

commit WORK.
ENDLOOP.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
I_STRUCTURE_NAME = 'EDIDC'
* IMPORTING
TABLES
T_OUTTAB = IT_COMM.

Collect the control records information is nothing but fill an internal table which
contains the fallowing fields
RCVPOR –RECEIVER PORT
RCVPRT –RECEIVER PARTNER TYPE
RCVPRN - RECEIVER PARTNER NUMBER
DOCTYP- IDOC TYPE
MESTYP – MESSAGE TYPE

SAMPLE CODE :

168
WA_CONT-MESTYP = 'ZV_CMSG'.
WA_CONT-RCVPOR = 'ZV_PORT'.
WA_CONT-RCVPRT = 'LS' .
WA_CONT-DOCTYP = 'Z1V_CID'.
WA_CONT-RCVPRN = 'LS810-SAP1'.
APPEND WA_CONT TO IT_CONT.
-Repeat the same for all the receiver

MASTER_IDOC _DISTRIBUTE is function model which is used generate as


well as dispatch
the communication idoc to their particular receiver system.
-This function model acts like both ALE service layer as well as ALE
communication idoc to
their particular receiver system.
-This function model acts like both ALE service layer as well as ALE
communication layer.
-The input for the above function model control records work area and data internal
table.
-The output for the function model is communication idoc internal table .

SAMPLE CODE

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'


EXPORTING
MASTER_IDOC_CONTROL = WA_CONT
TABLES
COMMUNICATION_IDOC_CONTROL = IT_COMM
MASTER_IDOC_DATA = IT_DATA.

Test the idoc by using the WEO5.

169
170

You might also like