ABAP Tutorial 1
ABAP Tutorial 1
ABAP Tutorial 1
ABAP TUTORIAL
Production
Purchasing
Ware house
FI/CO
Manufacturing
Company
Shipping
HR
Sales &
Distribution
ERP:-
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 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.
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
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.
1. Mathematical Operators.
2. Comparative Operators.
3. Relational & Logical Operators.
Mathematical Operators:-
Comparative Operators:-
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.
Data types:-
There are two types of Data types. They are:
1. Numeric Data types.
2. Character Data types.
In c: In ABAP:
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.
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.
Header
Declarations
Business Logic
***************************************************
* 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>
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.
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.
Size Category:-
Size category determines the probable space required for the
table.
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.
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.
Domain
Data element
Domain:-
Domain is the combination of data type & length.
Data Element:-
It is the combination of domain & short description.
YSPRAO_730_EMP
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 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
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.
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.
Write: / Emp-Eid,
Emp-Ename,
Emp-Eadd.
End Loop.
Object:-
To display the company codes, company names & cities.
Object:-
To display the Vendor numbers, Vendor names, & Countries.
Object:-
To display the customer numbers, customer names, cities & countries.
Indexed Hashed
Standard Sorted
Syntax:-
DATA <Internal Table name> like standard table of <work area name>.
E.g.: DATA IT like standard table of WA.
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.
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.
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
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
Syntax:-
DATA <WA name> like <Db table name>.
DATA <IT name> like table of <WA/Db name>.
E.g.:
Syntax:-
Tables < Db table name >.
E.g.: Tables T001.
By default TABLES keyword creates one WA with the name of database table
name & also contains all the fields in database table.
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
Object:-
To display the all the fields from LFA1 table.
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
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.
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.
Refresh:-
Refresh always clears the contents of the internal table only.
Syntax:-
Refresh < Internal table name>.
E.g.: Refresh IT_T001.
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>.
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:-
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.
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.
Syntax:-
Read table <IT name> into <WA name> index <num>.
E.g.: Read table IT_T001 into WA_T001 index 3.
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.
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‘.
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.
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>.
Empty.
Control structures:-
Control structures are used to control the execution sequence
of a program.
There are two types of control structures.
Branching Looping
While Do
If:-
Syntax:-
If <condition>.
Block of statements.
Else/elseif <condition>.
Block of statements.
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.
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‘.
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.
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.
Syntax:-
Update <DB table name> from table <IT name>.
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‘.
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.
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.
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.
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.
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.:
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.
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.
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.
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:-
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:-
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.
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>.
Program:-
Output:-
S_BUKRS to
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.
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.
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).
Syntax:-
Message <message type><message number> (<message class).
3 digit number
E.g.:
Message A000(YSMSG).
Note:-
SE91 is the transaction code to create the 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.
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).
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.
At selection-screen:-
Validation:-
At selection-screen on:-
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.
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.
AT SELECTION-SCREEN.
IF SY-SUBRC <> 0.
MESSAGE E000(YSMSG) WITH 'INVALID COMPANY'.
ENDIF.
START-OF-SELECTION.
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.
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.
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.
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.
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.
AT LINE-SELECTION.
IF SY-LSIND = '1'.
SELECT BUKRS KUNNR AKONT FROM KNB1 INTO TABLE
IT_KNB1 WHERE BUKRS =
WA_T001-BUKRS.
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.
AT LINE-SELECTION.
IF SY-LSIND = 1.
SELECT EBELN EBELP MENGE MEINS NETPR INTO TABLE
IT_EKPO WHERE EBELN IN WA_EKKO-EBELN.
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.
Program:-
DATA V1 LIKE T001-BUKRS.
SELECT-OPTIONS S_BUKRS FOR V1.
IF SY-LSIND = '1'.
SELECT LIFNR BUKRS AKONT FROM LFB1 INTO TABLE
IT_LFB1 WHERE BUKRS =SY-LISEL+0(4).
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.
AT LINE-SELECTION.
IF SY-LSIND = '1'.
ELSEIF SY-LSIND = 2.
GUI
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.
AT USER-COMMAND.
IF SY-UCOMM = 'DOWN'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA-TAB = IT_T001.
ENDIF.
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.
WA_FINAL-BUKRS = WA_KNB1-BUKRS.
WA_FINAL-KUNNR = WA_KNB1-KUNNR.
WA_FINAL-BUTXT = WA_T001-BUTXT.
APPEND WA_FINAL TO IT_FINAL.
CLEAR: WA_FINAL, WA_T001, WA_KNB1.
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.
WA_FINAL-EBELN = WA_EKPO-EBELN.
WA_FINAL-EBELP = WA_EKPO-EBELP.
WA_FINAL-NETPR = WA_EKPO-NETPR.
WA_FINAL-BSART = WA_EKKO-BSART.
WA_FINAL-LIFNR = WA_EKKO-LIFNR.
WA_FINAL-LIFNR = WA_LFA1-LIFNR.
WA_FINAL-NAME1 = WA_LFA1-NAME1.
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.
INCLUDE YSAI_INCLUDE1.
ENDIF.
ENDIF.
Program:-
DATA: BEGIN OF WA_MARA,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
END OF WA_MARA.
…………………………………………………..
DATA V1 LIKE MARA-MATNR.
SELECT-OPTIONS S_MATNR FOR V1.
INCLUDE YSAI_INCLUDE2_1.
ENDIF.
WA_FINAL-MATNR = WA_MARC-MATNR.
WA_FINAL-WERKS = WA_MARC-WERKS.
Modularization techniques:-
Modularization techniques are used to divide the
business processing logic in to reusable block of statements.
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.
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.
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.
DEFINE FILL.
EMP-EID = &1.
EMP-ENAME = &2.
EMP-EADD = &3.
APPEND EMP TO EMP1.
END-OF-DEFINITION.
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.
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.
Note:-
There are two types of Subroutines. They are:
1. Internal subroutines.
2. External subroutines.
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.
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.
5. Tables acts like both import & export only for internal tables.
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.
E.g.:
DATA X TYPE I.
PARAMETER: P_INPUT1 TYPE I,
P_INPUT2 TYPE I.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
***DECLARE IT_FCAT.
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
***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.
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.
IF B-FIELDNAME = 'BUKRS'.
SELECT KUNNR BUKRS AKONT PERNR FROM KNB1 INTO TABLE IT_KNB1 WHERE
BUKRS = B-VALUE.
ENDIF.
ENDFORM.
Date: 28.06.2010.
SOME OF THE IMPORTANT TRANSACTION CODES.
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.
SELECT EBELN BSART LIFNR FROM EKKO INTO TABLE IT_EKKO WHERE EBELN
IN
S_EBELN.
IF B-FIELDNAME = 'LIFNR'.
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
***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'.
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.
***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.
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.
***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.
***DECLARE IT_EVENT.
DATA: IT_EVENT1 TYPE SLIS_T_EVENT,
IT_EVENT2 TYPE SLIS_T_EVENT,
IT_EVENT3 TYPE SLIS_T_EVENT.
***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.
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.
WA_FCAT-FIELDNAME = 'BSART'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'DOC.TYP'.
WA_FCAT-TABNAME = 'IT_EKKO'.
WA_FCAT-FIELDNAME = 'LIFNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'VEN.NUM'.
WA_FCAT-TABNAME = 'IT_EKKO'.
WA_FCAT-FIELDNAME = 'BUKRS'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_M = 'CO.CODE'.
WA_FCAT-TABNAME = 'IT_EKKO'.
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'.
WA_FCAT-FIELDNAME = 'MENGE'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'QTY'.
WA_FCAT-TABNAME = 'IT_EKPO'.
WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_M = 'UOM'.
WA_FCAT-TABNAME = 'IT_EKPO'.
WA_FCAT-FIELDNAME = 'NETPR'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-SELTEXT_M = 'PRICE'.
WA_FCAT-TABNAME = 'IT_EKPO'.
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.
***DECLARING IT TABLES.
***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.
WA_FCAT-FIELDNAME = 'BELNR'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_S = 'ACC.DOC.NO'.
WA_FCAT-TABNAME = 'IT_BKPF'.
WA_FCAT-FIELDNAME = 'GJAHR'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_S = 'FISCAL YR'.
WA_FCAT-TABNAME = 'IT_BKPF'.
WA_FCAT-FIELDNAME = 'BUKRS'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_S = 'COMPANY CODE'.
WA_FCAT-TABNAME = 'IT_BKPF'.
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'.
WA_FCAT-FIELDNAME = 'BUDAT'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-SELTEXT_S = 'POST_DATE'.
WA_FCAT-TABNAME = 'IT_BKPF'.
WA_FCAT-FIELDNAME = 'BLDAT'.
WA_FCAT-COL_POS = '6'.
WA_FCAT-SELTEXT_S = 'DOC_DATE'.
WA_FCAT-TABNAME = 'IT_BKPF'.
WA_FCAT-FIELDNAME = 'BELNR'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_S = 'ACC.DOC.NO'.
WA_FCAT-TABNAME = 'IT_BSEG'.
WA_FCAT-FIELDNAME = 'GJAHR'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_S = 'FISCAL YR'.
WA_FCAT-TABNAME = 'IT_BSEG'.
WA_FCAT-FIELDNAME = 'BUKRS'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_S = 'COMPANY CODE'.
WA_FCAT-TABNAME = 'IT_BSEG'.
WA_FCAT-FIELDNAME = 'BUZEI'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_S = 'ITEM'.
WA_FCAT-TABNAME = 'IT_BSEG'.
WA_FCAT-FIELDNAME = 'DMBTR'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-SELTEXT_S = 'LOCAL_CURR.'.
WA_FCAT-TABNAME = 'IT_BSEG'.
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.
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.
INCLUDE YRAKESH_IT_EKPO.
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.
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.
WA_LAYOUT-INFO_FIELDNAME = 'COL'.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
WA_LAYOUT-ZEBRA = 'X'.
***DECLARE 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.
ENDFORM.
IF B = 'DOWN'.
ENDIF.
ENDFORM.
To display the Purchasing Document , items
<write Questions Here>
2/7/10 MODULE POOL PROGRAMMING
-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….)
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.
5/7/10
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
CODE
Working with table control
-table control is used to display the multiple records in a tabular format.
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.
Ranges selection-option
Low, high,
Sign, option
Option = ‗BT‘
Both are used in where condition.
7/7/10
SCREEN 1000
CCODE TO
DISPL BACK
AY
SE
Download Back L
Code
Screen
Code
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
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:
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.
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.
149
DATA IT_FILE LIKE TABLE OF WA_FILE.
DATA V1 TYPE STRING.
PARAMETER P_FILE LIKE IBIPPARMS-PATH.
*---------------------------------------------------------------------*
*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.
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
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.
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‘.
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
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 >
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.
CDHDR CDPOS
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.
158
-Active the change pointer technique (BD61)
-Active the msg type (BD50)
-Generate as well as dispatch the idoc to the receiver systems.
SENDER RECEIVE
R
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
-Execute BD15
COPY THE FORM
-Click execute
Filter techniques
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.
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
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.
-Save
Save
164
-Click on change mode
-Click new entries in the application tool bar
-Provide your msg type basic type extension type
-Save
165
OUT BOUND PROCESS
STEP 1. PROVIDE THE IN PUT VALUES
VENDOR TO
MSG TYPE
OUTBOUND DISTRIBUTED
MODEL PROGRAM
IDOC1 IDOC2
DISPATCH TO RECEIVER
ALE COMUNICATION LAYER
STEP 3. IDENTIFY THE RECEIVER
STEP 4. DISPATCH THE IDOC TO THEIR PARTICULAR RECEIVER
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
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
167
LOOP AT IT_SEG INTO WA_SEG.
WA_DATA-SEGNAM = 'Z1V_CS'.
WA_DATA-SDATA = WA_SEG.
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.
commit WORK.
ENDLOOP.
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
SAMPLE CODE
169
170