ABAP Notes Reddy
ABAP Notes Reddy
EX:-
Interactive Reports: - It’s nothing but to display the summarized information in the basic list and
detailed information in further lists.
EX:-
ALV Reports: - This is used to display the data with additional futures i.e. Borders, colors, shades, lines
etc.
The real time reports are internal purpose.
Interfaces: - Interfaces are used to connecting from SAP to SAP as well as SAP to non-SAP.
Interfaces are ALE/IDOCS, BAPI
Page No : 1
Conversion: - Conversion programs are used to transverse the data
from file to SAP system.
Conversion programs are BDC,LSMW
Types of project:-
1. Implementation project
2. Up gradation project
3. Maintenance / Support project
4. Roll out project
Implementation project: - When ever we want to develop the SAP from fundamental on wards then
we go for implementation project. Implementation project takes 1 year to 3 years.
In the implementation project the ABAPer must start from Realization phase.
Up gradation project: - When ever the version is changed if you want to implement the new
technologies into existing system then you go for up gradation project. Up gradation project takes 30 days
to 3 months.
Maintenance / Support project: - After go level support phase each and every company requires
24*7 supports. Then they go for support project.
Page No : 2
Real time system landscape:-
Mathematical Operator:-
Operator Description Example
+ Addition 3+2=5
- Subtraction 3–2=1
* Multiplication 3*2=6
** Exponent ional 3 * * 3 = 32 = 9
/ Division 4/2=2
Mod Reminder of division 5 mod 2 = 1
Of two numbers
Comparative Operator:-
Operator Description Example
< or LT Less than a < b or a LT b
<= or LE Less than or equal a <= b or a LE b
> or GT Grater than a > b or a GT b
>= or GE Grater than or equal a >= b or a GE b
= or EQ Equal a = b or a EQ b
<> or NE Not equal a <> b or a NE b
Page No : 3
Declaration keyword: - This keyword is used to declare the variables in ABAP. Some of the
declarative keywords are Data, Parameters, Tables, and Types etc.
Comment: - Comments are non executable statements. These are used to improve the readability of the
program. If you want to comment the entire line then you must place ‘*’ in first column of the line.
Ex: - * a b c ---
If you want to comment the part of the line then you must place in “(double quotations) from
double quotation onwards it treats as a comment.
Data types
Numeric Data types Character data types
Integer I char C
Float F numeric char N
Packed Decimal P Date D
Time T
Note: - Char is alpha numeric. That means it accept the integer and character.
Note: - Here Integer, Float, Date and Time are fixed length data types & rest of the data types are
variable length data types.
Page No : 4
Syntax of Time (T):-
Data <variable name> type T.
Ex: - data A type T.
The initial value of time is ‘000000’. format is ‘HHMMSS’
In ABAP each statement ends with dot (.). ‘WRITE’ is the operational keyword to display the output in
ABAP.
If more than one variable having the same keyword list of same keyword every time, we use chain
operators & variables are separated by camas (,). And statements end with dot (.).
Data: A type I, B type I, C type I.
A = 10.
B = 20.
C = A + B.
Write c.
Technical requirements to create the program
1. Name of the program
In ABAP the name of the program must be starts with ‘y’ or ‘z’ because ax reserved for SAP.
2. Provide the place / folder where we save the program. The place / folder is called development class up
to 4.6c version. Now it’s calling as package.
Note: - $TMP is the default package which is provided by SAP. The latest version is ECC6.0
(Enterprise Central Component).
Page No : 5
Note: - Default is the keyword to provide the default value to the input variable.
Syntax: -
Parameter <name> type <data type> default <value>
Ex: - parameter A type I default 10.
A 10
Note: - Parameter can’t accept float data type. Only it accept packed decimal.
SQL is the database dependent & SAP is the database independent. So SAP doesn’t support SQL.
Open SQL support SAP, because open SQL is the database independent.
Open SQL doesn’t support DDL. So we can’t create the tables by using simple statements like oracle.
Open SQL support DDIC (Data Dictionary) which is used to create or alter the tables.
Page No : 6
DATA DICTIONARY
Data dictionary is the central source of the database management system. The main functionality of the
DDIC is to create or alter the tables.
Delivery class: - It defines the owner of the table as well as it controls the transport of the data from one
table to another table.
Technical setting is nothing but combination of DATA CLASS & SIZE OF THE CATAGERY.
Data class: - Data class defines the physical area of the database in where our table is logically stored.
Some of the important data classes are
Master data class: - Master data class is the data, which data we can access frequently as well as
update rarely.
Ex: - customer master data, employee master data
Transaction data: - It’s the data, which data we can access frequently as well as updated frequently.
Ex: - Sales order data, purchase order data
Transactional data is dependent data.
Organizational data: - It’s the data, which data we can access frequently & updated rarely.
Organizational data is created at the time system configures.
Ex: - Company data, branches data
Each table must have at least one field as primary field that
should be the character data type that should be in the first field
in the table.
Page No : 7
Field Key Data type Length Short Description
Save the table (CTRL + S). Check the table (CTRL + F2). Click on technical settings. Select the data class
as APPL 0 & size category as zero. Save the technical settings. Click on back. Then activate table (CTRL
+ F3).
Page No : 8
Create the employee table by using data element type bottom up approach.
Steps to create the domain: - Execute SE11. Select the radio button domain. Provide the domain
name by click on create. Provide short description. Provide the data type & length. Save the domain.
Check the domain. Activate the domain. Repeat the same steps for all domains.
Steps to create the data element: - Execute the SE11. Select the radio button data type. Provide
the data element name. Click on create. Click on enter. Provide short description. Provide domain which is
already created. Save the data element. Check the data element. Activate the data element. Repeat the
same steps for all the data elements.
Steps to create the table by using data element type (bottom up approach): - Execute
SE11. Select the radio button database table. Provide the table name. Click on create. Provide short
description. Provide delivery class is ‘A’. Select Display / Maintenance allowed. Click on field tab.
Provide the field name, data elements.
Field Key Data Element
Eid zskr_9_eid
Ename zskr_9_ename
Eadd zskr_9_eadd
Save the table. Check the table. Before activate, click on technical settings. Select the data class, size
category. Save the technical settings. Click on back. Activate the table.
Create the following employee table by using bottom up approach.
Page No : 9
Note: - If you get the warning message enhancement category for table missing then in menu bar click
on extras enhancement category enter select the radio button can be enhancement (char type or
numeric) enter.
Note: - If you want to provide the data directly to the table then you must select the display maintenance
allowed.
Note: - If you select the display maintenance allow with restrictions, then display only possible. Create
records not possible.
Note: - If you select the display maintenance not allowed then display & create integer not possible.
Page No : 10
Note: - If you want to display the particular field information, click on utilities on menu bar. Select the
table contents, display. In the menu bar click on settings format list choose list. Select our required
field check box. Enter. Execute.
Foreign key: -
Foreign key is a field in one table. This is connected to another table via foreign key relationship. The
purpose is to validate the data being entered in one table (foreign key table) by checking against list of
possible values in another table.
Technical requirement to establish the foreign key relationship: -
1. The domain of the both fields in both the tables must be the same.
2. The check table field must be the primary.
Establish the foreign key relation between employee & salary tables.
In real time when ever we are working with quantity field then you must provide reference as unit
of measurement field.
Page No : 11
Create the following material table.
In the real time when ever we create the data base table then you must provide the MANDT client field.
The table contains MANDT fields then the table is client dependent. That is the data in the table can not
reflected to all other clients in the same server. If the table doesn’t contain MANDT field then the table is
client independent that is the data in data base table automatically reflected to all other clients in the same
server.
Select the amount / price field. Click as currency / quantity fields tab. Provide the reference table,
reference field.
Note: - T006 is the standard data base table which contains all the unit of measurements.
Note: - In the real time when ever we are working with unit of measurement field then we must
establish the foreign key relations with T006 as a check table. If you want to establish the foreign key
relation then you must maintain the SAP domain “MEINS” into our field domain.
Note: - “TCURC” is the standard data base table which contains all the currencies.
In the real time when ever we are working with currency field then we must establish the foreign key
relation with TCURC as check table. If you want to establish the foreign key relation then we must
maintain the SAP domain “WAERS” into our table field domain.
Select the currency field in our table. Click on foreign key icon under the fields tab. Then the system
automatically gives a proposal with TCURC as check table. Click on yes. Enter. Save, check, activate the
table.
Page No : 12
Types of tables: -
1. Transaparent tables
2. Cluster tables
3. Pool tables
Transaparent tables: - Transaparent tables are one to one relationship. That is if you create one
transaparent table in the data dictionary, then it’ll store like only one data base table in the data base.
Pooled tables are suitable when we fetch the large amount of data from fewer fields.
Create the table pool. Create pooled table & attached to the table pool.
Steps to create table pool: -
Execute SE11. In the menu bar click on utilities other dictionary objects. Select the radio button table
pool. Provide the table pool name. Click on create. Select the radio button table pool. Enter. Provide short
description. Click on save. In the menu bar click on go to technical settings. Select the size category.
Save. Back. Check & activate the table pool.
Page No : 13
Steps to create pooled table: -
Execute SE11. Select the radio button data base table. Provide the pooled table name. Click on create.
Provide short description. Provide delivery class is ‘A’. Click on fields tab. Provide the field names, data
element. Save the table. In the menu bar, click on extras change table category. Select the radio button
pooled table. Enter. Click on delivery & maintenance tab. Provide the table pool. Save, check the table.
Click on technical settings. Select the data class size category. Save the technical settings. Click on back.
Activate the table.
Create the table cluster. Create clustered table & attached to the table clustered.
When ever we create the clustered table then we must maintain the primary fields in the table
clustered. When ever we create the clustered table then we must maintain at least one non primary
key.
Steps to create table cluster: -
Execute SE11. In the menu bar click on utilities other dictionary objects. Select the radio button table
pool / cluster. Provide the table cluster. Click on create. Select the radio button table cluster. Enter.
Provide short description. Click on save. Select the VARKEY & click on minus. Click on + button.
Provide the mandatory field of clustered table.
Click on save. Click on go to on menu bar technical settings. Click on back. Check, activate.
Steps to create clustered table: -
Execute SE11. Select the radio button data base table. Provide the table name. Click on create. Provide
short description. Provide deliver class is ‘A’. Click on field tab. Provide field names, data element.
Field Key Initial Data element
MANDT MANDT
LIFNR LIFNR
NAME1 NAME1
Click on save. In the menu bar click on extras change category. Select the radio button clustered table.
Enter. Click on delivery & maintenance tab. Provide the table clustered. Save, check the table. Click on
technical settings. Provide data class, size category, save the technical settings. Click on back. Activate the
table.
Note: - In the real time we never create cluster & pool tables. Only we can create transparent tables.
Note: - In the real time when ever we’re altering the table we get the error structure change of field
error. Then we must adjust the data base.
Index: -
Indexes are used to improve the performance of the select query. There are two types of indexes.
1. Primary index
2. Secondary index
Page No : 14
Primary index: - Primary index is the primary fields. Without a primary index we can’t create the data
base table. We can place up to 16 primary indexes per table. We can create the primary index only for
custom tables. Not for standard tables.
Secondary index: -Secondary index is possible for other than primary fields. Without a secondary
index we can create the data base table. We can create up to 9 secondary indexes per a table. We can
create secondary index for both standard & custom tables.
Note: -We can’t delete the domain which is already assigned to data element. We can’t delete the data
element which is already assigned to data base table. We can create the data base table with out a data
element by using direct method or predefined type.
Page No : 15
Note: - Adding the following fields to the custom tables ZSKR_9_EMP1 and ZSKR_9_STU by using
include structure.
ORT01 City
LAND1 Country
SPRAS Language
If you want to add block of fields or set of fields into more than one custom table instead of maintaining
those fields in each and every table it’s better to create one structure with those fields & later we include
the same structure in all tables.
ZSKR_9_EMP ZSKR_9_STU
Eid Sid
Ename Sname
Eadd Sadd
ORT01 ORT01
LAND1 LAND1
SPRAS SPRAS
In this object or task we must create one structure with ORT01, LAND1, SPRAS & later we include this
structure in the ZSKR_9_EMP & ZSKR_9_STU custom data base tables.
Note:
‘/O’ is used to opens a new session without terminating the current session.
‘/N’ is used to opens a new session with terminating the current session.
Note: In the real time packages are created by BASIS people. Based on the module or based on the object
category & request number is created by ABAPer.
Page No : 16
Add the CMM level field which is CHAR & length ‘1’ to the T001 data base table through
APPEND structure.
Steps to add some additional fields to the standard data base table: -
Execute SE11. Select the radio button data base table. Provide the table name for which table we want to
add some additional fields. Click on display. Click on append structure on application tool bar. Click on
create append. Provide the append structure name. Enter. Provide short description. Provide component,
component type, double click on component type or data element. Click on yes. Click on yes. Save in our
package. Enter. Enter. Provide short description. Provide the domain which isn’t created. Double click on
domain. Click on yes. Save in our own package. Enter. Click on yes. Provide the short description.
Provide data type, size. Save, check, activate domain. Click on back. Save, check, activate the data
element. Repeat the same steps for all components. Save the structure, check, activate.
Note: In the real time when ever we develop any task then we must save in our own package & request
number not in $TMP.
Syntax of declaring the structure / table in ABAP editor: -
Ex: -
Data: Begin of emp,
Eid(10) type c,
Ename(25) type c, Work area
Eadd(35) type c,
End of emp.
Work area always holds only one record at a time. So we go for internal tables.
Internal table: -
1. Internal table is the collection of records.
2. Internal tables are temporary tables. That means the data in internal table won’t save any where in
SAP.
3. Internal tables are dynamic memory location. That means we no need to provide the size of the
internal table.
4. The scope of the internal table is up to that program.
5. Placing the data to the internal table as well as getting the data from internal table is always record
by record.
Page No : 17
Differences between data base table & internal tables: -
Data base table Internal table
1. Data base tables are permanent storage 1. Internal tables are temporary storage
location. location.
2. We can access the data base table from any 2. We can access the internal table with in the
where in SAP. program only.
3. We must provide the size of the data base 3. Internal tables are dynamic. So we no need to
tables. provide the size.
Syntax of declaring the internal table : -
Note: - Append is the key word to transfer the data from work area to internal table.
Select <field1> <field2> …. from <data base table> into table <internal table> where <condition>
Display the company codes company names & cities
Data: Begin of WA,
BUKRS(4) type C,
BUTXT(25) type C,
Page No : 18
ORT01(25) type C,
End of WA.
Data IT like table of WA.
Select BUKRS BUTXT ORT01 from T001 into table IT.
Loop at IT into WA.
Write:/ WA-BUKRS, WA-BUTXT, WA-ORT01.
Endloop.
Select-options is the keyword which accepts the single value, multiple single values, single range &
multiple ranges.
Syntax of select-options: -
Select-options <name of the select-options> for <variable name>.
Ex: -
Data v1 type T001-BUKRS.
Page No : 19
Select-options S_BUKRS for v1.
S_BUKRS to
(c,4)
Data v1 type KNA1-KUNNR.
Select-options S_KUNNR for v1.
Syntax of select-options in select query: -
Select <field1> <field2> ---- from <database table> into table <Internal Table> where <field> in
<select-options>.
Based on given company codes, display the company codes, company names & cities.
Data v1 type T001-Bukrs.
Select-options S_BUKRS for v1.
Data: Begin of WA_T001,
BUKRS type T001-BUKRS,
BUTXT type T001-BUTXT,
ORT01 type T001-ORT01,
End of WA_T001.
Data IT_T001 like table of WA_T001.
Select BUKRS BUTXT ORT01 from T001 into table IT_T001 where BUKRS in
S_BUKRS.
Loop at IT_T001 into WA_T001.
Write: / WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
Endloop.
Based on given country display the customer numbers, customer names & countries.
Data v1 type KNA1-LAND1.
Select-options S_LAND1 for v1.
Data: Begin of WA_KNA1,
KUNNR type KNA1-KUNNR,
NAME1 type KNA1-NAME1,
LAND1 type KNA1-LAND1,
End of WA_KNA1.
Data IT_KNA1 like table of WA_KNA1.
Select KUNNR NAME1 LAND1 from KNA1 into table IT_KNA1 where LAND1 in
S_LAND1.
Loop at IT_KNA1 into WA_KNA1.
Write: / WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1-LAND1.
Endloop.
Parameter: -
It’s the keyword which accepts the single value at run time.
Syntax:-
Parameter <name of the parameter> type <data type>
Ex: - parameter P_BUKRS type T001-BUKRS.
P_BUKRS
Syntax of parameter in select query: -
Select <field1> <field2> ---- from <database table> into table <Internal Table> where field = <parameter>
Page No : 20
Ex: -
Select BUKRS BUTXT LAND1 from T001 into table IT_T001 where BUKRS = P_BUKRS.
Differences between parameter & select-options: -
Page No : 21
Kind is the keyword which returns the type of internal table. If the internal table type is standard then writes
T. Sorted writes S. Hashed writes H. Lines is the keyword which returns the number of records in internal
table.
Syntax: -
Syntax:-
Data: begin of <work area>,
------------
------------
End of <work area>.
Data <IT> like table of <work area>.
Ex: -
Data: Begin of wa_t001,
Bukrs type t001-bukrs,
Ort01 type t001-ort01,
end of wa_t001.
Data IT like table of wa_t001.
2. Declaring the internal table with all fields from any one of data base tables:
Syntax: -
Data begin of <work area>.
Include structure <data base table>.
Data end of <work area>.
Data <internal table> like table of <work area>.
Page No : 22
Ex:-
Data begin of wa_t001.
Include structure t001.
Data end of wa_t001.
Data IT like table of wa_t001.
3. Declaring the internal table by referring database table: -
Syntax: -
Data <work area> like <data base table>.
Data <Internal Table> like table of <work area / database table>
Ex:-
Data wa like t001.
Data IT like table of wa.
(OR)
Data IT like table of t001.
Data wa like line of IT.
Note: - Type is used to refer the data types, data elements, fields in the table & types. Where as like is
used to refer the variable or fields in the table.
Types is used to assign the data type
to the data object directly while
declaration. Like is used to assign
the data type of another object to
declare the data object. The data type
is referred indirectly.
Ex: -
Types: begin of ty_t001,
Bukrs type t001-bukrs,
Ort01 type t001-ort01,
End of ty_t001.
Data wa_t001 type ty_t001.
Data IT type table of ty_t001.
(Or)
Data IT like table of wa_t001.
Page No : 23
Note: - If you want to comment the multiple lines then select the all lines. Click on CTRL + Less
than. If you want to uncomment then select all lines, click on CTRL + Grater than.
Ex: -
Data: begin of IT_t001 occurs 0,
Bukrs type t001-bukrs,
Ort01 type t001-ort01,
End of IT_t001.
Here occurs 0 by default allocates 8 kb of memory for the internal table. If the data in the internal table
exceeds 8 kb, then it’ll provide one more 8 kb of memory … up to 2 GB.
Occurs ‘n’: - By default it allocates ‘n’ records of memory for internal table. If the data in the internal
table exceeds 10 records. Then it’ll be allocates one more ‘n’ records of memory ---- up to 2 GB.
Declaring the internal table with header line by using types keyword: -
Types: begin of <type name>.
--------
-------
End of <type name>.
Data <internal table> type table of <type name> with header line.
Page No : 24
Ex:
Types: begin of ty_t001,
Bukrs type t001-bukrs,
Ort01 type t001-ort01,
End of ty_t001.
Data it_t001 type table of ty_t001 with header line.
Note: - By default tables keyword creates one work area with the name of database table name and
also it contains all the fields of data base table.
Syntax: -
Tables<database table name>.
Tables t001.
Initializing techniques: -
1. Clear
2. Refresh
3. Free
Clear: - clear clears the contents of the work area & also clear is used to clear the contents of the
internal table.
Syntax: -
Clear <work area>
Clear <internal table>
Ex:-
Clear WA_t001.
Clear IT_t001.
If we are working with internal table with header line then the name of the
work area as well as name of the internal table is similar name. In this case
also clear clears the contents of the work area only. If you want to clear
the contents of internal table then we place open & close ([ ]) brackets to the internal table.
Ex:-
Data A type I.
Data B(5) type C.
A = 10.
B = 20.
Clear: A, B.
Write:/ A, B.
Page No : 25
Refresh:-
Refresh always clears the contents at the internal table only.
Syntax: -
Refresh <internal table>.
Note: - If you’re working with internal table with header line also refresh always clear the content of the
internal table.
Free: -
Free acts like refresh.
1. Refresh clears the contents of internal table only. Not the memory which is allocated for that.
2. Free clears the contents of the internal table as well as memory which is allocated for that.
Syntax: -
Append <work area> to <internal table>.
Syntax: -
Insert <work area> into table <internal table>.
Ex: -
Insert WA into table IT.
Note: - If we use insert keyword to standard internal table then it acts like append.
Collect: - Collect checks the internal table whether the record is available or not based on the key field.
If not it acts like append (record adds last). Other wise it adds the numeric fields from work area to
number field in the internal table.
Syntax: -
Collect <WA> into <IT>.
Ex: -
Read table IT into WA index 2.
We never use 1st condition in real time.
Reading a single record from the internal table based on condition
Syntax: -
Read table <internal table> into <work area> with key condition.
Ex: -
Read table IT into WA with key BUKRS = ‘2000’.
OP: - 1000 IBM Chennai
Reading multiple records from the internal table based on index.
Syntax: -
Loop at <internal table> into <work area> from <index no> to <index no>.
-------
------- optional
-------
Endloop.
Ex: -
Loop at IT into WA from 2 to 3.
Write: / WA_t001-BUKRS, WA_t001-BUTXT, WA_t001-ORT01.
Endloop.
OP: - 200 IBM Chennai
300 HCL Hyderabad
Page No : 27
Reading multiple records from the internal table based on condition
Syntax: -
Loop at <internal table> into <work area> where <condition>.
--------
--------
--------
Endloop.
Ex: -
Loop at IT_t001 into WA_t001 where ORT01 = ‘Hyderabad’.
Write: / WA_t001-BUKRS, WA_t001-BUTXT, WA_t001-ORT01.
Endloop.
OP: - 100 TCS Hyderabad
300 HCL Hyderabad
Syntax:-
Modify <internal table> from <work area> transporting <field1> <field2> where <condition>.
Ex: -
WA_t001-ORT01 = ‘BAN’.
Modify IT_t001 from WA_t001 transporting ORT01 where BUKRS = ‘2000’.
If we are maintaining all the fields information in the work area (key field)
Ex: -
Delete IT_t001 index 3.
Based on condition: -
Syntax: -
Delete <internal table> where <condition>.
Ex: -
Delete IT_t001 where ORT01 = ‘Hyderabad’.
Sort the data in an internal table
Syntax: -
Sort <internal table> by <field1> <field2>.
Ex: -
Sort IT_t001 by BUKRS.
OP: -
Page No : 28
By default sort is ascending order. If you want to descending order
Transferring the data from one internal table to another table which are similar
structure
If the second internal table is empty
Syntax: -
<internal table 2> = <internal table 1>.
Ex: -
IT = IT_t001.
Ex: -
Append lines of IT_t001 to IT.
Syntax: -
Insert lines of <internal table 1> into table <internal table 2>.
Ex: -
Insert lines of IT_t001 into table IT.
WA-Eid = '3'.
WA-Esal = '30000'.
Collect WA into IT.
Page No : 30
Data IT_Emp like table of WA_Emp.
Data: begin of WA_Sal,
Eid(10) type C,
Esal(10) type C,
End of WA_Sal.
Data IT_Sal like table of WA_sal.
WA_Emp-Eid = '1'.
WA_Emp-Ename = 'Vidya'.
Append WA_Emp to IT_Emp.
WA_Emp-Eid = '2'.
WA_Emp-Ename = 'Satish'.
Append WA_Emp to IT_Emp.
WA_Emp-Eid = '3'.
WA_Emp-Ename = 'Latha'.
Append WA_Emp to IT_Emp.
WA_Emp-Eid = '4'.
WA_Emp-Ename = 'Sanjay'.
Append WA_Emp to IT_Emp.
Page No : 31
* Based on emp and salary table fill the final table
Loop at IT_Emp into WA_Emp.
WA-Eid = WA_Emp-Eid.
WA-Ename = WA_Emp-Ename.
Read table IT_Sal into WA_Sal with key Eid = WA_Emp-Eid.
WA-Esal = WA_Sal-Esal.
Append WA to IT.
Clear WA.
Endloop.
Loop at IT into WA.
Write: / WA-Eid, WA-Ename, WA-Esal.
Endloop.
Update the rank field in the student internal table based on rank internal table
data.
Data: begin of WA_Stu,
Sid(5) type C,
Sname(25) type C,
Srank(5) type C,
End of WA_Stu.
Data IT_Stu like table of WA_Stu.
Data: begin of WA_rank,
Sid(5) type C,
Srank(5) type C,
End of WA_rank.
Data IT_rank like table of WA_rank.
* Filling the student internal table
WA_Stu-Sid = '1'.
WA_Stu-Sname = 'Vidya'.
Append WA_Stu to IT_Stu.
WA_Stu-Sid = '2'.
WA_Stu-Sname = 'Satish'.
Append WA_Stu to IT_Stu.
WA_Stu-Sid = '3'.
WA_Stu-Sname = 'Latha'.
Append WA_Stu to IT_Stu.
WA_Stu-Sid = '4'.
WA_Stu-Sname = 'Sharadha'.
Append WA_Stu to IT_Stu.
Page No : 33
Collective search help: - Collective search help is the collection of elementary search help.
Create the collective search help to identify the company code based on company name &
identify the company code based on vendor number.
Execute SE11. Select the radio button search help. Provide the collective search help name (zsashi3).
Click on create. Select the radio button collective search help. Enter. Provide short description. Provide
the search help parameter (BUKRS) & data element (BUKRS). Import, export, click on include search
help tab. Provide the all the elementary search helps. Select the each elementary search help. Click on
parameter assignment. Click on yes. Enter. Save, check, activate the collective search help.
Execute SE11. Select the radio button data type. Provide the data element name. Click on create. Enter.
Provide short description. Provide the domain name. Click on further characteristic tab. Provide the
collective search help name, parameter. Save, check, activate.
Execute /OSE38.
Parameter P_BUKRS type ZSPT_9_BUKRS.
Hot key: -
The Hot key permits the user to select an elementary search help from the collective search help directly
in the input field with the short notation.
After executing the program we provide the input as equal to hot key (=A) & click on F4. Then we
get the elementary search help, which contains the specified hot key as default.
Letters & digits are allowed as a hot key.
Lock Objects: -
Lock object is used to avoid the concurrent access of multiple users on the same data base. When ever we
create & activate the lock object it generates two function modules. 1. Enqueue (locking) 2. Dequeue
(unlock). The lock object name must be start with EZ or EY.
Page No : 34
Buffering: -
Buffering is the temporary place in the application server. When ever we execute any object then the
system goes to application server and check the required data is available or not in buffer area. If the data
is available then it gets from buffer area & displays it. If the data isn’t available in the buffer area then it
goes to data base & picks the data from data base server & placed into buffer area & displays it.
Types of buffering: -
Single record buffering: -
In this kind of buffering the selected data will be stored into buffered area.
Generic area buffering: -
In this kind of buffering the key information stored in the buffered area.
Fully buffered: -
In this type of buffering the entire data of database is load into the buffering.
Note: - If you want to display the data in a single line then you must provide the
line-size.
Ex: - Report <Report name> Line-size 1023.
Page No : 35
EKPO (Purchasing document item table): -
EBELN Purchasing document number
EBELP Item number
MATNR Material number
MENGE Quantity
MEINS Unit of measurement
NETPR Net price
Page No : 36
TMG (Table Maintaince Generator)
Table Maintaince Generator is used to insert, update and delete the data of data base table with out any
code (with out DML Commands). Table Maintaince Generator is only possible for custom tables. The
transaction code for TMG is SM30.
Click on save.
Now we execute this table name as a transaction code then we get the screen and perform the operations.
There are two types of Maintaince. One step and two step.
Page No : 37
Table type: - Table type is the collection of structure records or structure fields. By using table type we
declare the internal table in the ABAP editor. Creation of table type is two step procedures. 1. Create the
structure, 2. Create the table type based on the structure.
Page No : 38
Views: -
Each application has its own data base tables. If you want to display the part of data from each table then
we pick the data from each table & merge the data & display the data. If it’s regular activity then it’s
better to create a view.
Views are logical databases. It doesn’t contain the data permanently. At run time only view
contains the data.
Projection view: -
If you want to display the part of data from single database table, if it’s a regular activity then it’s better to
create projection view.
Projection view is always involving single database table.
Note: - Fetching the data from view is faster than fetching the data from database table.
Ex: -
Select BUKRS BUTXT LIFNR from ZSPT_9AM_DV into table IT_Final.
Page No : 39
Database view picks the data from both the tables. If and only if there is one or more entries is available in
the right hand side table with corresponding left hand side table.
Help view: -
Help view pick the data from left
hand side table. Even though there
is no match in the right hand side
table.
Help view always involve in two
data base tables.
Maintenance view: Maintaince view is defined to maintain multiple tables data using the transaction
code SM30.
Page No : 40
Control break statement / events in internal table: -
Control break statements are worked with in the loop of internal table. Before using the control break
statements, we must sort the internal table based on At new field. Control break statements are 1> At First
2> At New <field name> 3> At End of <field name> 4> At last
Each control break statement ends with Endat.
AT FIRST: -
This is an event which is triggered at the first record of internal table.
Advantage: - This is used to display the header information for internal table.
AT NEW <field name>: -
It’s an event which is triggered at the first record of each block.
Advantage: - It’s used to display the individual fields.
AT END OF <field name>: -
This event triggered at the last record of each block.
Advantage: -This is used to display the sub total.
AT LAST: -
This is an event which is triggered at the last record of internal table.
Advantage: - It’s used to display the grand total.
Based on the given purchasing document numbers display the purchasing item details as shown
in the figure.
Page No : 41
Note: - When ever we are working with at new & at end of the right side fields of mention field values
display as stars if it’s a character data type & displayed as zeros if it’s a numeric data type.
DATA V1 TYPE EKKO-EBELN.
SELECT-OPTIONS S_EBELN FOR V1.
DATA: V2 TYPE EKPO-NETPR, V3 TYPE EKPO-NETPR.
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
END OF TY_EKPO.
DATA WA_EKPO TYPE TY_EKPO.
DATA IT_EKPO TYPE TABLE OF TY_EKPO.
DATA WA LIKE WA_EKPO.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO WHERE
EBELN IN S_EBELN.
SORT IT_EKPO BY EBELN.
LOOP AT IT_EKPO INTO WA_EKPO.
WA = WA_EKPO.
AT FIRST.
WRITE / 'THESE ARE PO DETAILS'.
ENDAT.
AT NEW EBELN.
WRITE: / WA_EKPO-EBELN, WA-EBELP, WA-MENGE.
ENDAT.
WRITE: / WA_EKPO-EBELP, WA_EKPO-MENGE, WA_EKPO-MEINS,
WA_EKPO-NETPR.
V2 = V2 + WA_EKPO-NETPR.
V3 = V3 + WA_EKPO-NETPR.
AT END OF EBELN.
WRITE: / 'SUB TOTAL', V2.
CLEAR V2.
ENDAT.
AT LAST.
WRITE:/ 'GRAND TOTAL', V3.
ENDAT.
ENDLOOP.
Working with ON CHANGE OF: -
Ex: -
Loop at IT_EKPO into WA_EKPO.
ON CHANGE OF WA_EKPO-EBELN.
Write:/ WA_EKPO-EBELN, WA_EKPO-EBELP, WA_EKPO-MENGE.
Endon.
Endloop.
Page No : 42
Write the program by using control break statements to know difference between at new and on
change of.
Data: BEGIN OF wa,
code type i,
name(4) type c,
city(4) type c,
end of wa.
data it like table of wa.
wa-code = '100'.
wa-name = 'TCS'. At new NAME
wa-city = 'HYD'.
APPEND WA TO IT.
CLEAR WA.
wa-code = '100'.
wa-name = 'IBM'.
wa-city = 'CHE'.
APPEND WA TO IT.
CLEAR WA.
wa-code = '200'.
wa-name = 'IBM'. At new CODE
wa-city = 'BAN'.
APPEND WA TO IT.
CLEAR WA.
wa-code = '200'.
wa-name = 'HCL'.
wa-city = 'PUNE'.
APPEND WA TO IT.
CLEAR WA.
LOOP AT IT INTO WA.
AT NEW NAME.
WRITE:/ WA-CODE, WA-NAME,WA-CITY.
ENDAT.
ENDLOOP.
Explanation :-
First we have to sort the internal table based on at new field. If I take AT NEW CODE , then first record,
third record only display. Because second and forth records are duplicate. If I use AT NEW NAME, then
all records will display. Because first it will display 1st record. After, name is different. That’s why 2nd
record also display. Next, 3rd record also display. Because name is same but code is different. It’ll check
left side fields also. If there is a new data then it’ll display. If the data is same as 2nd record, then it’ll not
display. Next it’ll display the 4th record. Because name is different. By using on change of it’s not
possible. Here 3rd record isn’t display by using on change of. It’ll check that column only. 2nd recod name,
3rd record name same. So on change of don’t allow to display 3rd record. On change of will allow to
display 4th record. Becase name is dirrent. But code is same. In this situation on change of don’t check left
side data.
Page No : 43
Differences between AT NEW, ON CHANGE OF
SY-ULINE is the system variable which is used to draw the horizontal line. SY-VLINE is the system
variable which is used to draw the vertical line.
Page No : 44
Continue: -
The continue statement only used in loop if it’s used the current loop pass is ended immediately & the
program flow is continues. continue will go to next index of the loop.
Based on the given purchasing document numbers, display the item numbers, quantity, units of
measurements & price if the amount is more than 20 by using continue statement.
Ex: -
Loop at IT_EKPO into WA_EKPO.
If WA_EKPO-NETPR < 20.
Continue.
Endif.
Write:/ WA_EKPO-EBELN, WA_EKPO-EBELP, WA_EKPO-MENGE, WA_EKPO-MEINS,
WA_EKPO-NETPR.
Endloop.
Exit: -
Exit statement is used within a loop. It leaves the loop by ending the current loop process. EXIT will
completely go out of the LOOP statement or DO statement.
Based on the given purchasing document numbers to display the first 5 item details by using exit
command
Select EBELN EBELP MENGE MEINS NETPR from EKPO into IT_EKPO where EBELN in
S_EBELN.
Loop at IT_EKPO into WA_EKPO.
Write:/ WA_EKPO-EBELP, WA_EKPO-EBELN, WA_EKPO-MENGE, WA_EKPO-MEINS,
WA_EKPO-NETPR.
V2 = V2 + 1.
IF V2 = 5.
Exit.
Endif.
Endloop.
Check: -
Check statement is used to terminate the sub routine conditional.
Page No : 45
Stop:-
This is used in at selection-screen & start-of-selection events. This is used to stop the process of these
event code.
Note: - Insert, update, modify a single record into the data base
table is always through work area & multiple records through
internal table.
Note: - When ever we are working with data base tables then we
must maintain the structure of the work area as well as structure of
the internal table must be the similar structure of data base table.
Note: - SY-SUBRC is the system variable which contains zero with the above statement executed
successfully otherwise it contains non zero. Most of the times it contains ‘4’.
Data wa_T001 like T001.
WA_T001-BUKRS = '0786'.
WA_T001-BUTXT = 'SATISH INFO'.
WA_T001-ORT01 = 'HYD'.
Page No : 46
WA_T001-LAND1 = 'IN'.
Insert T001 from WA_T001.
If SY-SUBRC = 0.
Write 'Inserted'.
Else.
Write 'Not inserted'.
Endif.
Here ‘0777’ company already exists in the data base. So it ignores all other records in internal table as
well as it terminates the entire transaction.
If you want avoid the termination of the program then you must place accepting duplicate keys in
the syntax of inserting.
Syntax:-
Insert <data base table> from table <internal table> accepting duplicate keys.
The above syntax 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 contains the number of records as successfully
processed into the data base.
Ex: -
Insert T001 from table IT_T001 accepting duplicate keys.
Write SY-DBCNT.
Here 0888 & 0999 companies are inserted & 0777 is ignored.
Page No : 47
Update (single record) / over write: -
Update updates a record into the data base table if there is a match found into the data base base on the
key field. Otherwise it ignores the record.
Syntax: -
Update <data base table> from <work area>.
Note: - when ever we are working with update then we must maintain change field information & also
non change field information. Other wise non change field information may be lost.
Ex: -
Data WA_T001 like T001.
WA_T001-BUKRS = '0777'.
WA_T001-BUTXT = 'SATISH INFO'.
Update T001 from WA_T001.
If SY-SUBRC = 0.
Write 'UPDATED'.
Else.
Write 'NOT UPDATED'.
Endif.
Update (Multiple records): -
This functionality is similar as update single record functionality.
Syntax:-
Update <data base table> from table <internal table>.
Syntax: -
Update <data base table> set <field 1> = <value 1> <field 2> = <value 2> ….. where <condition>
Ex: -
Update T001 set ORT01 = 'MUM' LAND1 = 'IN' where BUKRS = '0777'.
If SY-SUBRC = 0.
Write 'updated'.
Else.
Write 'not updated'.
Endif.
Note: - Modify acts like update if there is a match found in data base based on the key field otherwise it
acts like insert. Modify never failed.
Syntax: -
Modify <data base table> from <work area>.
Modify <data base table> from table <internal table>.
Page No : 48
Append WA to IT.
Clear WA.
WA-BUKRS = '0787'.
WA-BUTXT = 'SPRAO INFO'.
WA-ORT01 = 'BAN'.
Append WA to IT.
Clear WA.
Modify T001 from table IT.
In this example ‘0786’ company already exist in the data base. So it acts like update or over write &
‘0787’ company details aren’t available in data base. So it acts as insert.
Delete: -
Delete deletes the data from data base based on condition.
Syntax: -
Delete from <data base table> where <condition>.
Ex: -
Delete from T001 where BUKRS = '0787'.
If SY-SUBRC = 0.
Write 'deleted'.
Else.
Write 'not deleted'.
Endif.
Commit work: -
This command is used to commit the data base changes.
Ex: -
Delete from T001 where BUKRS = ‘0786’.
Commit work.
Rollback work: -
This command is used to reverse the data base changes.
Ex: -
Delete from T001 where BUKRS = ‘0787’.
Rollback work.
Page No : 49
Joins
Joins are used to fetch 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 & only if there is one or more than one entry is available in
the right hand side table with corresponding left hand side table.
Syntax: -
Select <data base table 1> ~ <field 1> <data base table 1> ~ <field 2> -------
<data base table 2> ~ <field 1> <data base table 2> ~ <field 2> --------
| |
| |
Where <condition>.
Note: - The link field must be primary fields in at least one data base table.
Display the company codes, company names & vendor numbers of the company details by using
inner join.
Based on the given material numbers display the material numbers, material types, plant
numbers, plant names by using inner join.
Data V1 type MARA-MATNR.
Select-options s_matnr for V1.
Types: begin of ty_final,
MATNR type MARA-MATNR,
MTART type MARA-MTART,
WERKS type MARC-WERKS,
NAME1 type T001W-NAME1,
End of ty_final.
Data: wa_final type ty_final,
it_final type table of ty_final.
Select MARA~MATNR MARA~MTART MARC~WERKS T001W~NAME1 into table it_final
from MARA inner join MARC on MARA~MATNR = MARC~MATNR inner join T001W
on MARC~WERKS = T001W~WERKS where MARA~MATNR in S_matnr.
Loop at it_final into wa_final.
Write:/ wa_final-MATNR, wa_final-MTART, wa_final-WERKS, wa_final-
NAME1.
Endloop.
Based on the given customer numbers display the customer numbers, customer names,
sales document numbers, document date, item number, material number, material description,
quantity, unit of measurement, net price by using inner join.
Page No : 51
Data V1 type KNA1-kunnr.
Select-options s_kunnr for V1.
Types: begin of ty_final,
KUNNR type KNA1-KUNNR,
NAME1 type KNA1-NAME1,
VBELN type VBAK-VBELN,
AUDAT type VBAK-AUDAT,
POSNR type VBAP-POSNR,
MATNR type VBAP-MATNR,
MAKTX type MAKT-MAKTX,
KWMENG type VBAP-KWMENG,
MEINS type VBAP-MEINS,
NETWR TYPE VBAP-NETWR,
End of ty_final.
Data: wa_final type ty_final,
it_final type table of ty_final.
Select KNA1~KUNNR KNA1~NAME1 VBAK~VBELN VBAK~AUDAT VBAP~POSNR
VBAP~MATNR MAKT~MAKTX VBAP~KWMENG VBAP~MEINS VBAP~NETWR into table
it_final from KNA1 inner join VBAK on KNA1~KUNNR = VBAK~KUNNR inner
join VBAP on VBAK~VBELN = VBAP~VBELN inner join MAKT on VBAP~MATNR =
MAKT~MATNR where KNA1~KUNNR in s_kunnr.
Loop at it_final into wa_final.
Write:/ wa_final-KUNNR, wa_final-NAME1, wa_final-VBELN, wa_final-
AUDAT, wa_final-POSNR, wa_final-MATNR, wa_final-MAKTX, wa_final-KWMENG,
wa_final-MEINS, wa_final-NETWR.
Endloop.
After implementation
After no of years rotation time
10 days 5*6 20ms
1 year 10*200 2min
2 years 20*5000 4min
4 years 50*200000 6min
6 years 70*800000 11min
In the real time the maximum program execution time in four grounds [when you press F8 it’s called four
ground] 600 seconds are max time. In the program execution time exceeds 600 seconds then it goes to
dump [time up]. Some times more than two tables join leads to time out. So we go for ‘for all entries’.
‘For all entries’ pick the data based on the where condition first, next it based on on-condition.
At the time of implementing the SAP performance of the inner join & ‘For all entries’ are same. Day by
day, day by day the data base sizes are increased then the performance of the inner join is decreased the
‘For all entries’ is same. So we go for ‘For all entries’.
Note: - Inner join isn’t possible for pooled & clustered tables. Only possible for transparent tables.
Note: - when ever we are working with for all entries then you must consider higher level internal table
having the data. Suppose if you’re not consider & higher level internal table having no data. Then it’ll
pick the entire data from next level.
Page No : 53
* if not IT_T001 is initial.
Select BUKRS KUNNR from KNB1 into table IT_KNB1 for all entries in IT_T001 where BUKRS =
IT_T001-BUKRS.
* endif.
Suppose IT_T001 internal table having no data then it’ll fetch entire data from KNB1 data base table &
placed into IT_KNB1.
Based on the given company codes display the company codes, company names & customers
under the company based on for all entries.
Data V1 type T001-BUKRS.
Select-options s_bukrs for V1.
Types : begin of ty_final,
BUKRS type T001-BUKRS,
BUTXT type T001-BUTXT,
KUNNR type KNB1-KUNNR,
End of ty_final.
Select BUKRS BUTXT from T001 into table it_t001 where BUKRS in s_bukrs.
If not it_t001 is initial.
Select BUKRS KUNNR from KNB1 into table it_knb1 for all entries in
it_t001 where BUKRS = it_t001-BUKRS.
Endif.
Page No : 56
Modularization techniques:
Modularization techniques are used to divide the business processing logic into reusable block of
statements. This is two step procedure. 1. Define the reusable block, 2. Calling the reusable block.
2 types of modularization techniques
Include: -
We can’t execute an include independently where as the same include program can be include to any
number of executable programs. Include programs are used to improve the readability of the program. In the
real time include programs are used to maintain the all declarations of the program.
---------
---------
---------
Ex: -
Types: begin of ty_t001,
Bukrs type t001-bukrs,
Butxt type t001-butxt,
Ort01 type t001-ort01,
End of ty_t001.
Data: wa_t001 type ty_t001,
it_t001 type table of ty_t001.
Save, check, Activate it.
Syntax of calling the include program: -
Include <include program name>.
Ex: -
Include ZWASTE101.
Select bukrs butxt ort01 from t001 into table it_t001.
Loop at it_t001 into wa_t001.
Write: wa_t001-bukrs, wa_t001-ort01, wa_t001-butxt.
Endloop.
Macros: -
Macros are used to perform the arithmetical operations. Macros can take up to 9 place holders. (&1, &2, ---
&9). If you want to maintain the same set of statements more than one location of the same program instead
of this we maintain those statements in macro definition later we call the same macro definition from
different locations of the same program.
Page No : 57
Syntax of calling the macro: -
<macro name> <place holder1 value> <place holder 2 value>.
Note: - In macros definition should be the first and calling should be the next.
Page No : 58
Note: - In subroutine calling is the first & definition is the next. In subroutines all the using parameters
are called input parameters. All the changing parameters are called as output parameters.
We can’t place the any executable statement after the definition of the subroutine.
Internal subroutines: -
It’s nothing but the definition of the subroutine as well as calling of the subroutine must be in the same
program.
External subroutine: -
It’s nothing but the definition of the subroutines taken from one program & the calling of the subroutine is is
taken from some other ABAP program.
Syntax of calling the external subroutine: -
Perform <form name> in program <program name> using <IP 1> <IP 2> ---- changing <OP 1> <OP2> ---
Page No : 59
Termination of subroutine: -
Subroutines are normally ends with endform. If you want to terminate the subroutine so earlier then we use
exit or check command. Exit command is used to terminate the subroutine unconditionally. Check command
is used to terminate the subroutine conditionally.
Perform spexit.
Form spexit. Working with central data:-
Write 'SPRAO Technologies'. Data A type i.
Write / 'SR Nagar'. A = 10.
Exit. Perform hai.
Write / 'HYD'. Write / A.
Endform. Form hai.
A = 20.
Write / A. 20
OP: - SPRAO Technologies
Endform.
SR Nagar
Data A type i.
A = 10.
Parameter P_BSART type EKKO-BSART.
Perform hello.
Perform spcheck using P_BSART.
Write A.
Form spcheck using A type EKKO-BSART.
Form hello.
Check A = ‘DOM’.
Local A.
------- A = 20.
------- Write A.
Endform. Endform.
Function module: -
Function modules are reusable components that are defined in functional library.
Each function module must be attached to one function group. Each function group contains two include
programs by default. One is for global declaration another one is for common subroutines. All the function
modules can access the both the include programs.
When ever we are calling any one of the function module then all other function modules will be loaded into
the memory of calling program. So it’s better to group related function module into one function group.
Import: -
Import acts like input parameters [using in the server].
Export: -
Export acts like output parameters [changing in the server].
Changing: -
Changing acts like both import & export. Tables parameters are currently replaced by CHANGING.
Tables: -
Tables acts like both import & export only for internal tables.
Exceptions: -
These are used to handle the errors in function module.
Source code: -
It contains the logic related function module.
Develop a function module to display the all the purchasing order header details based on the
given purchasing document number.
Ex: -
Select single * from EKKO into E_WA where EBELN = I_EBELN.
Endfunction.
Save, check, activate the function.
Note: - Function module writes single value & multiple values. So we need to maintain any display
statement (write) in the function module definition.
Note: - We can test the function module independently without calling the function module.
Page No : 61
Function module definition Function module calling
Import -------------------------------------------- Export
Export -------------------------------------------- Import
Changing ---------------------------------------- Changing
Tables ------------------------------------------- Tables
Steps to call the function module: -
Place the cursor where you want to call the function module. Click on pattern in the application tool bar.
Provide the function module name.
Develop a function module to display the company codes company name & city based on the given
company.
If you want to declare the work area with some of the fields in function module then we must create
one structure with those fields in the data dictionary & later we refer the structure in the function module
[export tab].
In this object we must create the structure with bukrs, butxt, ort01.
Steps to create structure: -
Execute SE11. Select the radio button data type. Provide the structure name. Click on create. Select the
radio button structure. Enter. Provide the short description. Provide component, component type.
Bukrs bukrs
Butxt butxt
Ort01 ort01
Save, check, activate.
Page No : 62
Function module ZSPT_930_FM1.
Import
Parameter name type associated type
i_bukrs type t001-bukrs
Export
parameter name type associated type
e_wa like ZSPT_930_FS1.
Source code
Select single bukrs butxt ort01 from t001 into e_wa where bukrs = i_bukrs.
Endfunction.
Based on the given vendor number display the vendor number, purchasing document numbers,
document types by using function module.
If you want to declare the internal table with some of the fields in the function module then we must create
one structure with those fields & later we refer the structure in the tables tab of function module.
In this object we must create one structure with lifnr, ebeln, bsart after we refer the structure in the
tables tab of function module.
Structure – ZSPT_930_FS2
Source code
Select lifnr ebeln bsart from ekko into table IT where lifnr = i_lifnr.
Raise NODATA.
Page No : 63
Endif.
Execute SE38.
Parameter p_lifnr type ekko-lifnr.
Data IT_ekko type ZSPT_930_FS2.
Data wa_ekko like line of it_ekko.
Call function ‘ZSPT_930_FM3’.
Exporting.
i_lifnr = p_lifnr.
Tables
IT = IT_ekko.
Exporting
NODATA = 1
OTHERS = 2.
If SY-SUBRC = 0.
Write: ‘INVALID INPUT’.
Else.
Loop at IT_ekko into wa_ekko.
Write: / wa_ekko-lifnr, wa_ekko-ebeln, wa_ekko-bsart.
Endloop.
Endif.
Note: - In the function module all parameters are either pass by value or pass by reference. By default all
parameters are pass by reference. Pass by reference means from calling to definition & definition to calling
all parameter values are passing along with the memory. Pass by value means from calling to definition &
definition to calling only parameters values are passed.
Note: - In the remote enable function module all parameters are pass by value only.
Select-options: -
The name of the select options acts like an internal table with header line that means the name of the work
area as well as the name of the internal table is the similar name of the select options.
Syntax: -
Select-options <select-options name> for <variable>.
Ex: -
Data v1 type t001-bukrs.
Select-options s_bukrs for v1.
Note: - If you want to declare the work area with the some of the fields in the function module then we
must create one structure with those fields in the data dictionary & later we refer the structure in the import,
export, changing tab.
Note: - If you want to declare the internal table with some of the fields in the function module then we
must create one structure with those fields & later we refer the structure in the tables tab (or) Create one
table type with those fields in the data dictionary later we refer the table type in the import, export or
changing tab.
Note: - If you want to declare the select-options in the function module then we must create one structure
with the following fields later we refer the structure in the tables tab of function module.
Components of select-options: -
Page No : 64
1. Sign Include (I) / Exclude (E).
2. Option between (BE) / Not Between (NB) / Equals (EQ) ….
3. Low The low value of the select-options.
4. High the high value of the select-options.
Sign = I
Option = BT
Sign = I
Options = NB. Opetion
Sign = E
Option = BE
Sign = E
Option = NB
Based on the given company code, display the company codes, names, cities by using function
module.
If you want to declare the select-option the function module then we must create one structure with the
following fields in the data dictionary & later we refer the structure in the tables tab.
Sign (C,1)
Option (C,2)
Low
High Depends of fields
In this object we must create two structures one is for input parameter (sign option low, high). One is for
output (bukrs, butxt, ort01) both structures are referred in tables tab only.
Page No : 65
SIGN CHAR 1
OPTION CHAR 2
LOW CHAR 4
HIGH CHAR 4
Save, check, activate the structure.
source code
select bukrs butxt ort01 from t001 into table e_it where bukrs in i_bukrs.
Endfunction.
Based on the given vendor numbers display the vendor numbers, vendor names, purchasing
document numbers by using function module.
Structure ystr5
Lifnr lifnr char 10
Name1 name1 char 30
Ebeln ebeln char 10
Structure ystr6
Sign char 1
Option char 2
Low char 10
High char 10
Page No : 66
Data v1 type LFA1-LIFNR.
Select-options s_lifnr for v1.
Data it_final like table of ystr5.
Data wa_final like line of it_final.
Call function ‘yfm5’
Tables
i_lifnr = s_lifnr
e_it = it_final.
Page No : 67
Note: - In Pass by value only values are passed from calling to definition part. Both actual & formal
parameters will share different memory locations. Any changes made in formal parameters, will not be
effected to actual ones.
Note: - In Pass by reference a reference of actual parameters is passed to formal parameters. Any
changes made in formal parameters are automatically reflected to actual ones.
Here Actual parameters are nothing but which parameters are in Defination part. Formal parameters are
nothing but the parameters which are in calling part.
Actually function modules are 4 types. Those are Normal FM, Remote Enable FM, ALV FM, Update
FM.
Normal, Remote Enable function modules are already explained at the time of beginning of Function
modules.
ALV Function Module: - ALV’s are normal function modules. As they improves performance of a
program (by avoiding loop ---- endloop). So they are separated from normal ones.
Note: - Exporting & Importing parameters work based on ‘Pass By Value’. Tables & Changing
parameters work based on ‘Pass By Reference’.
Note: - Field symbols hold the reference of other variables and writens value stored in the reference.
Page No : 68
FIELD-SYMBOLS <FS>.
DATA A TYPE I VALUE 10.
DATA B TYPE I.
B = A.
ASSIGN B TO <FS>.
IF <FS> IS ASSIGNED.
WRITE:/ <FS>.
ENDIF.
Note: - The difference between ordinary variable and field symbol is ordinary variables memory
allocated during at runtime. Field symbols memory is allocated when ever assign keyword is executed.
Find the time taking between work area performance and field symbol performance.
Page No : 69
REPORTS
Report is the combination of given inputs to the selection-screen retrieving the data from data base based
on the given input & display the output in a predefined format.
Syntax of selection-screen: -
Selection-screen begin of block <block name> with frame title text-<no>.
Optional Optional
Selection screen
-------
------- S_BUJKRS to
------- Display
Selection-screen end of block Non display
<block name>.
Syntax of check box: -
Parameter <name of the check box> as check box.
If you want to provide the meaningful descriptions to the input variables then in the menu bar click on go
to text elements selection texts. It displays the all available inputs. If the field is coming from
dictionary then select the dictionary check box otherwise we manually provide the text.
Page No : 70
Save, activate, back.
When ever we are working with begin of line & end of line then the name of the parameter is
disable. So we must provide comment before, after block of a checkbox or radiobutton.
Syntax: -
Selection-screen comment x(y) text-<no>. 3 digit number
Starting position
Design the selection-screen as shown in the figure.
Skip is the keyword to provide the space in between any two input variables in the selections name. By
default skip is one line. Maximum we can skip up to 9 lines at a line.
Types of Reports:-
1. Classical Reports
2. Interactive Reports
3. ALV Reports
Classical Reports: - It’s nothing but to display the entire information in a single list
Page No : 72
At selection-screen: -
It’s an event which is triggered after provide the input to the screen & before leaving the selection-
screen.
ADV: - This is used to validate the given input.
At selection-screen on: -
It’s an event which is triggered at the selection-screen based on particular input field.
ADV: - This is used to validate the particular input field.
Start-of-selection: -
It’s an event which is triggered after leaving the selection-screen & before display the output.
ADV: - This is used to fetch the data from data base & place into internal table.
End-of-selection: -
It’s an event which is triggered after completion of the logic.
ADV: - This is used to display the output.
Top-of-page: -
It’s an event which is triggered at the top of the each page.
ADV: - It’s used to display the header information.
End-of-page: -
It’s an event which is triggered of the end of each page.
ADV: - It’s used to display the footer information.
At selection-screen output: -
It’s an event which is triggered at the selection-screen based on the user action.
ADV: - This is used to modify the selection-screen.
At selection-screen on value-request: -
It’s an event which is triggered at the time of click on F4 button.
ADV: - This is used to provide the list of possible values to the input variables.
Page No : 73
At selection-screen on help-request: -
It’s an event which is triggered at the time of click on F1 button.
ADV: - This is used to provide the help document to the input variable
At selection-screen output is the first triggering event in the selection-screen.
Note: - When ever the program is loaded into the ABAP editor then automatically load-of-program
event will be triggered. We never write any code on load-of-program event.
Design as well as provide the default values in the selection-screen as shown in the figure.
Data v1 type vbak-vbeln.
Selection-screen begin of block A with frame.
Select-options s_vbeln for v1.
Parameter p_dis as checkbox.
Parameter p_nondis as checkbox.
Selection-screen end of block A.
Initialization.
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '4975'.
Append s_vbeln.
Clear s_vbeln.
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4980'.
s_vbeln-high = '4988'.
Append s_vbeln.
Clear s_vbeln.
s_vbeln-sign = 'I'.
s_vbeln-option = 'EQ'.
s_vbeln-low = '4990'.
Append s_vbeln.
Clear s_vbeln.
p_dis = 'X'.
Design as well as assigned the default values
to the selection screen as shown in the figure.
Data v1 type ekko-bukrs.
Data v2 type ekko-ebeln.
Selection-screen begin of block A
with Frame title text-001.
Select-options s_bukrs for v1.
Select-options s_ebeln for v2.
Selection-screen begin of line.
Parameter p_dis as checkbox.
Selection-screen comment 2(11) text-002.
Parameter p_nondis as checkbox.
Selection-screen comment 15(11) text-003.
Page No : 74
Selection-screen end of line.
Selection-screen end of block A.
Initialization.
s_bukrs-sign = 'I'.
s_bukrs-option = 'BT'.
s_bukrs-low = '1000'.
s_bukrs-high = '3000'.
Append s_bukrs.
Clear s_bukrs.
s_bukrs-sign = 'I'.
s_bukrs-option = 'BT'.
s_bukrs-low = '5000'.
s_bukrs-high = '7000'.
Append s_bukrs.
Clear s_bukrs.
s_ebeln-sign = 'I'.
s_ebeln-option = 'BT'.
s_ebeln-low = '3000000004'.
s_ebeln-high = '3000000008'.
Append s_ebeln.
Clear s_ebeln.
s_ebeln-sign = 'I'.
s_ebeln-option = 'EQ'.
s_ebeln-low = '3000000010'.
Append s_ebeln.
Clear s_ebeln.
p_dis = 'X'.
Message: -
We’ve 4 different types messages.
2. Warning message (W) Status bar i. If you are in the basic list then it
Error message (E) goes to program.
ii. If you are in the secondary list
then it goes to previous list.
Syntax: -
Message <message type><message number> (<message class).
3 digit number
Note: - The transaction code for message class creation is ‘SE91’
Steps to create the message class: -
Execute SE91. Provide the message class name. Click on create. Provide short description. Click
on save. Click on messages tab. Provide messages against the messages.
000 Less than 10
001 Grater than 10
002 Equal to 10
Click on save.
Ex: -
Parameter P type I.
If P < 10.
Message I000(zmessage1).
Elseif p > 10.
Message I001(zmessage1).
Else
Message I002(zmessage1).
Endif.
Page No : 76
Note: - In the real time we always use only one message class only one message number against that
number we maintain the place holders.
Syntax: -
Message <message type><message number> (<message class>) with ‘<message>’.
Zmessage2
000 & & &
Parameter p type I.
If p < 10.
Message I000(zmessage2) with ‘less than 10’.
Elseif p > 10.
Message I000(zmessage2) with ‘grater than 10’.
Else
Message I000(zmessage2) with ‘equal to 10’.
Endif.
Note: - When ever the system execute any message then the further statements are not executed.
(Execution is stopped.)
BUKRS T001
KUNNR KNA1
LIFNR LFA1
EBELN EKKO
VBELN VBAK
MATNR MARA
WERKS T001W
LGORT T001L
tables kna1.
select-options s_kunnr for kna1-kunnr.
data v type kna1-kunnr.
At selection-screen.
Select kunnr from kna1 into V up to 1 rows where kunnr in s_kunnr.
Endselect.
If sy-subrc <> 0.
Message E000(zmessage2) with 'Invalid customer'.
Endif.
Note: - All inputs are wrong then only SY-SUBRC value is not equal to zero.
Note: - Now-a-days in the real time we always use select single to validate the input. Because select
single is faster than up to 1 rows (select single hit the data once. Up to 1 rows hit the data twice.)
At selection-screen on s_lifnr.
Select single lifnr from lfa1 into V1 where lifnr in s_lifnr.
If sy-subrc <> 0.
Message E000(zmessage3) with 'Invalid vendor'.
Endif.
Note: - If you want to validate the entire selection-screen then we use at selection-screen event. If you
want to validate a particular field then we go for ‘at selection-screen on’. In this case also at selection-
screen work but performance wise poor compare to ‘at selection-screen on’.
tables t001.
selection-screen begin of block a with frame.
select-options s_bukrs for t001-bukrs.
parameter p_dis as checkbox.
parameter p_nondis as checkbox.
selection-screen end of block a.
types: begin of ty_t001,
bukrs type t001-bukrs,
butxt type t001-butxt,
ort01 type t001-ort01,
end of ty_t001.
data: wa_t001 type ty_t001,
it_t001 type table of ty_t001.
Start-of-selection.
Select bukrs butxt ort01 from t001 into table it_t001 where bukrs
in s_bukrs.
End-of-selection.
If p_dis = 'X'.
Loop at it_t001 into wa_t001.
Write: / wa_t001-bukrs, wa_t001-butxt, wa_t001-ort01.
Endloop.
Else.
message I000(zmessage1) with 'select the display checkbox'.
endif.
Top-of-page.
Write: 'SATISH TECHNOLOGIES'.
End-of-page.
Write '301, Tirumalagiri complex, SR Nagar'.
Note: - One event is always ends with another event.
Note: - When ever we are working with events then we no need to follow the order of the events.
Note: - When ever we are working with end-of-page then we must provide the LINE-COUNT in the
name of the report. Other wise the footer information is not printed.
Page No : 78
Syntax: -
Report <report name> line-count X(Y). Number of footer lines
Number of lines per page
Note: - If you want to avoid the title in the output then we must provide NO STANDARD PAGE
HEADING in the name of the report.
Based on the given purchasing document numbers display the purchasing document numbers,
document dates & vendor numbers by using classical event reports & also display the top-of-page as
‘DHAWAN TECHNOLOGIES’ & end of page as ‘SR Nagar’
REPORT ZWASTE102 line-count 10(1).
Data v1 type ekko-ebeln.
Selection-screen begin of block A with frame.
Select-options s_ebeln for v1.
Selection-screen end of block A.
Page No : 79
Ort01 type kna1-ort01,
End of ty_kna1.
Data: wa type ty_kna1,
it type table of ty_kna1.
At selection-screen.
Data v type kna1-kunnr.
Select single kunnr from kna1 into v where kunnr in s_kunnr.
If sy-subrc <> 0.
Message E000(zmessage3) with 'Invalid customer number'.
Endif.
Start-of-selection.
Select kunnr name1 ort01 from kna1 into table it where kunnr in
s_kunnr.
End-of-selection.
Loop at it into wa.
Write: / wa-kunnr, wa-name1, wa-ort01.
Endloop.
Top-of-page.
Write / 'THESE ARE CUSTOMER DETAILS'.
End-of-page.
Write / 'SATISH TECHNOLOGIES'.
When ever we are working with at selection-screen output event then we must provide <MODIF
ID> <ID NAME> for each modified field & also provide user-command based on which field you want to
modify.
Note: - We can have only one basic list & up to 20 secondary lists (1-20).
Page No : 82
At line selection: -
It’s an event which is triggered at the time of user clicks on any record of any list.
At user-command: -
It’s an event which is triggered at the time of user clicks on any menu item.
At PF (N): -
It’s an event which is triggered at the time of user clicks on F1 to F12 function keys.
Set PF-status: -
It’s an event which
is triggered at the time of
attaching our own GUI to
the program.
Page No : 83
Note: - Interactive reports support the user interaction is always through double click. When ever the
user double clicks on any record at any list then at line selection event will be triggered & list index is
incremented by 1. If you want to retrieve the data for current list then we should know the record which is
clicked by the user in the previous list.
The following techniques are used to identify the records which are clicked by the user in the
previous list.
1. Hide technique.
2. SY-LISEL technique.
3. Get cursor technique.
Hide technique: -
Hide maintain the copy of the previous list with output line numbers & their contents. When ever
the user clicks on any record of any list then at line-selection event will be triggered & list index is
increased by ‘1’ & that particular record will move from hide area to work area. Based on the work area
we fetch the data for current list.
Note: - Hide is always maintain after write statement.
Based on the given purchasing document numbers display the purchasing document number,
document dates & vendor numbers. In the basic list. If the user clicks on any record then we display
the purchasing document item details (EBELN, EBELP, MENGE, MEINS, NETPR) in the first
secondary list by using hide technique.
Select EBELN BEDAT LIFNR from EKKO into table it_ekko where EBELN in
S_EBELN.
Loop at it_ekko into wa_ekko.
Write: / wa_ekko-EBELN, wa_ekko-BEDAT, wa_ekko-LIFNR.
Hide : wa_ekko-EBELN, wa_ekko-BEDAT, wa_ekko-LIFNR.
Endloop.
At line-selection.
If SY-LSIND = '1'.
Select EBELN EBELP MENGE MEINS NETPR from EKPO into table it_ekpo
where EBELN = wa_ekko-EBELN.
Loop at it_ekpo into wa_ekpo.
Write: / wa_ekpo-EBELN, wa_ekpo-EBELP, wa_ekpo-MENGE, wa_ekpo-
MEINS, wa_ekpo-NETPR.
Endloop.
ENDIF.
Based on the given company codes display the company codes, company name & cities in the
basic list. If the user clicks on
any record then we display
the customers under
company details (BUKRS,
KUNNR, AKONT) in the
first secondary list. If the
user clicks on any record
then we display the
customers details (KUNNR,
NAME1, ORT01) in the
second secondary list by
using hide technique.
AT LINE-SELECTION.
IF SY-LSIND = '1'.
SELECT BUKRS LIFNR AKONT FROM LFB1 INTO TABLE IT_LFB1 WHERE BUKRS =
SY-LISEL+0(4).
LOOP AT IT_LFB1 INTO WA_LFB1.
WRITE:/ WA_LFB1-BUKRS, WA_LFB1-LIFNR, WA_LFB1-AKONT.
ENDLOOP.
ELSEIF SY-LSIND = '2'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = SY-LISEL+5(10)
IMPORTING
OUTPUT = SY-LISEL+5(10).
SELECT LIFNR NAME1 ORT01 FROM LFA1 INTO TABLE IT_LFA1 WHERE LIFNR =
SY-LISEL+5(10).
LOOP AT IT_LFA1 INTO WA_LFA1.
WRITE:/ WA_LFA1-LIFNR, WA_LFA1-NAME1, WA_LFA1-ORT01.
ENDLOOP.
ENDIF.
AT SELECTION-SCREEN.
SELECT SINGLE KUNNR FROM KNA1 INTO V WHERE KUNNR IN S_KUNNR.
IF SY-SUBRC <> 0.
MESSAGE E000(ZMESSAGE1) WITH 'INVALID CUSTOMER NUMBER'.
ENDIF.
START-OF-SELECTION.
SELECT KUNNR NAME1 ORT01 FROM KNA1 INTO TABLE IT_KNA1 WHERE KUNNR IN
S_KUNNR.
END-OF-SELECTION.
LOOP AT IT_KNA1 INTO WA_KNA1.
WRITE:/ WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1-ORT01.
HIDE: WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1-ORT01.
ENDLOOP.
Page No : 89
AT LINE-SELECTION.
IF SY-LSIND = '1'.
SELECT VBELN AUDAT KUNNR FROM VBAK INTO TABLE IT_VBAK WHERE KUNNR =
WA_KNA1-KUNNR.
LOOP AT IT_VBAK INTO WA_VBAK.
WRITE:/ WA_VBAK-VBELN, WA_VBAK-AUDAT, WA_VBAK-KUNNR.
HIDE: WA_VBAK-VBELN, WA_VBAK-AUDAT, WA_VBAK-KUNNR.
ENDLOOP.
Get-cursor technique: - Get-cursor technique writes the field name as well as field value which is clicked
by the user.
Syntax: -
Get-cursor field1 <variable1> value <variable2>
Based on the given sales document numbers display the sales document numbers, document
dates & customer numbers in the basic list. If the user clicks on the any sales document number
only then we display the sales document item details [VBELN POSNR KWMENG MEINS
NETWR] in the first secondary list if the user clicks on any customer number only then we display
the customer details [KUNNR NAME1 ORT01] in the first secondary list by using get-cursor
technique.
Page No : 90
netwr type vbap-netwr,
end of ty_vbap.
select vbeln audat kunnr from vbak into table it_vbak where vbeln in
s_vbeln.
loop at it_vbak into wa_vbak.
write:/ wa_vbak-vbeln, wa_vbak-audat, wa_vbak-kunnr.
endloop.
at line-selection.
if sy-lsind = '1'.
get cursor field v2 value v3.
IF V2 = 'WA_VBAK-VBELN'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V3
IMPORTING
OUTPUT = V3.
SELECT VBELN POSNR KWMENG MEINS NETWR FROM VBAP INTO TABLE
IT_VBAP WHERE VBELN = V3.
LOOP AT IT_VBAP INTO WA_VBAP.
WRITE:/ WA_VBAP-VBELN, WA_VBAP-POSNR, WA_VBAP-MEINS, WA_VBAP-
KWMENG, WA_VBAP-NETWR.
ENDLOOP.
ELSEIF V2 = 'WA_VBAK-KUNNR'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V3
IMPORTING
OUTPUT = V3.
SELECT KUNNR NAME1 ORT01 FROM KNA1 INTO TABLE IT_KNA1 WHERE KUNNR
= V3.
LOOP AT IT_KNA1 INTO WA_KNA1.
WRITE:/ WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1-ORT01.
ENDLOOP.
ENDIF.
ENDIF.
Page No : 91
Note: - If you click on most of the records, if the output isn’t coming then we open the table in SE11 &
pass the values. If the data is available then you must check the any conversion routine is available or not.
Based on the given purchasing document numbers display the purchasing document numbers,
document dates, company codes & vendor numbers if the user clicks on any purchasing document
number only then we display the purchasing document item details. [EBELN, EBELP, MENGE,
MEINS, NETPR] in the first secondary list if the user click on any vendor number then display the
vendor details [LIFNR, NAME1, ORT01] in the first secondary list & also validate the given
purchasing document number.
Page No : 92
select EBELN BEDAT BUKRS LIFNR from EKKO into table IT_EKKO where
EBELN IN S_EBELN.
LOOP AT IT_EKKO INTO WA_EKKO.
WRITE: WA_EKKO-EBELN, WA_EKKO-BEDAT, WA_EKKO-BUKRS, WA_EKKO-
LIFNR.
ENDLOOP.
AT LINE-SELECTION.
IF SY-LSIND = '1'.
GET CURSOR FIELD V2 VALUE V3.
IF V2 = 'WA_EKKO-EBELN'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V3
IMPORTING
OUTPUT = V3.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE
IT_EKPO WHERE EBELN = V3.
LOOP AT IT_EKPO INTO WA_EKPO.
WRITE:/ WA_EKPO-EBELN, WA_EKPO-EBELP, WA_EKPO-MENGE,
WA_EKPO-MEINS, WA_EKPO-NETPR.
ENDLOOP.
ELSEIF V2 = 'WA_EKKO-LIFNR'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V3
IMPORTING
OUTPUT = V3.
SELECT LIFNR NAME1 ORT01 FROM LFA1 INTO TABLE IT_LFA1 WHERE
LIFNR = V3.
LOOP AT IT_LFA1 INTO WA_LFA1.
WRITE:/ WA_LFA1-LIFNR, WA_LFA1-ORT01, WA_LFA1-NAME1.
ENDLOOP.
ENDIF.
ENDIF.
Page No : 93
GUI Components: -
COMPONENTS OF GUI
GUI title
| GUI Status
Title bar Menu bar
Standard tool bar
Application tool bar
File Edit Goto Utilities ---- System Help Function keys
Menu bar
Standard tool bar
Title bar
Note: - In the menu bar system & help are default menu items & we can create up to 6 menu items
[total 8 items].
Note: - We can design up to 35 buttons in the application tool bar.
Based on the given purchasing document numbers display the purchasing document numbers
document dates & vendor numbers as shown in the below & also design one download button in the
application tool bar. If the user clicks on download button then we download the display records
into presentation server.
Note: - Download is the function module which is used to browse the file as well as download the data
from internal table to file. The input for the above function module is
Page No : 94
1. File type ‘DAT’.
2. Data internal table.
Data V1 type EKKO-EBELN.
Select-options S_EBELN for V1.
Types: Begin of TY_EKKO,
EBELN type EKKO-EBELN,
BEDAT type EKKO-BEDAT,
LIFNR type EKKO-LIFNR,
End of TY_EKKO.
At user-command.
If SY-UCOMM = 'DOWN'.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_EKKO.
Endif.
Syntax of reading the displayed records:-
Read line <line number> field value <Displayed field name1> into <variable1>
<displayed field name2> into <variable2> ----.
Ex: -
Read line 3 field value WA_EKKO-EBELN into V1
WA_EKKO-BEDAT into V2
WA_EKKO-LIFNR into V3.
Based on the given sales document numbers display the sales document number, document dates
& customer numbers as shown in below. If the user click on download button then we download the
selected records into presentation server. If the user click on display button then we display the sales
order details through VA03 transaction. If the user click on ‘Selt all’ then select the all check boxes.
Page No : 95
Ex: -
Call transaction ‘VA03’.
Before call the transaction we must set the value set parameter ID ‘<ID name>’ field ‘<value>’.
Steps to identify the parameter ID:-
Execute the transaction code place the cursor on input field. Click on F1. Click on technical information
identify the parameter id.
Ex: -
Parameter P_VBELN type VBAK-VBELN.
Set parameter ID ‘AUN’ field P_VBELN.
CALL TRANSACTION ‘VA03’.
Note: - If you want to get the current document value which is opened.
Syntax: -
Get parameter ID ‘<ID Name>’ field <Variable>.
Ex: -
Data v1 type vbak-vbeln.
Get parameter ID ‘AUN’ field v1.
Write v1.
Note: - Set & get are called SAP memory & import, export, changing - - - are called ABAP memory.
Note: - SY-INDEX is the system variable which contains the current loop pass.
Note: - SY-TABIX is the system variable which contains the exact line number of the record which is
moving from internal table to work area.
data: a, b.
DATA: V1 TYPE VBAK-VBELN, V2 TYPE VBAK-AUDAT.
DATA V TYPE SYLINNO.
tables vbak.
select-options s_vbeln for vbak-vbeln.
types: begin of ty_vbak,
vbeln type vbak-vbeln,
audat type vbak-audat,
kunnr type vbak-kunnr,
a type c,
end of ty_vbak.
data: wa_vbak type ty_vbak,
it_vbak type table of ty_vbak.
DATA: WA LIKE WA_VBAK,
IT LIKE TABLE OF WA.
select vbeln audat kunnr from vbak into table it_vbak where vbeln in
s_vbeln.
loop at it_vbak into wa_vbak.
write:/ a as checkbox, wa_vbak-vbeln, wa_vbak-audat input, wa_vbak-
kunnr.
Page No : 96
endloop.
V = SY-LINNO.
set pf-status 'STAT'.
AT USER-COMMAND.
IF SY-UCOMM = 'DOWN'.
DO V TIMES.
READ LINE SY-INDEX FIELD VALUE A INTO B
WA_VBAK-VBELN INTO WA-VBELN
WA_VBAK-AUDAT INTO WA-AUDAT
WA_VBAK-KUNNR INTO WA-KUNNR.
IF B = 'X'.
APPEND WA TO IT.
CLEAR WA.
ENDIF.
ENDDO.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT.
REFRESH IT.
ELSEIF SY-UCOMM = 'SA'.
A = 'X'.
LOOP AT IT_VBAK INTO WA_VBAK.
WRITE:/ A AS CHECKBOX, WA_VBAK-VBELN, WA_VBAK-AUDAT, WA_VBAK-
KUNNR.
ENDLOOP.
ELSEIF SY-UCOMM = 'UPD'.
DO V TIMES.
READ LINE SY-INDEX FIELD VALUE A INTO B
WA_VBAK-VBELN INTO V1
WA_VBAK-AUDAT INTO V2.
IF B = 'X'.
UPDATE VBAK SET AUDAT = V2 WHERE VBELN = V1.
ENDIF.
ENDDO.
IF SY-SUBRC = 0.
MESSAGE S000(ZMESSAGE1) WITH 'UPDATED SUCCESSFULLY'.
ELSE.
MESSAGE E000(ZMESSAGE1) WITH 'NOT UPDATED'.
ENDIF.
ELSEIF SY-UCOMM = 'DIS'.
DO V TIMES.
READ LINE SY-INDEX FIELD VALUE A INTO B
WA_VBAK-VBELN INTO V1.
IF B = 'X'.
SET PARAMETER ID 'AUN' FIELD V1.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDDO.
ENDIF.
Page No : 97
ALV (ABAP LIST VIEWERS): -
ALV is used to display the output with predefined functionalities. Like
1. Sort the list in ascending order
2. Sort the list in descending order
3. Tables
4. Filtering
5. Down the list
6. Send an attachment
7. Word processing
8. Excel sheet
9. Change the layout
10. Graphics
11. Print previews
ALV is introduced from 4.6C version onwards. ALV is used to display the data from internal table only.
Note: - REUSE_ALV_GIRD_DISPLAY is the function module which is used to display the output in a
grid format.
REUSE_ALV_LIST_DISPLAY is the function module which is used to display the output in a list
format.
The input for the above two functions modules are two internal tables.
1. Data internal table
2. Field Catalog internal table
Display the all sales documents details by using ALV.
Data IT_VBAP like table of VBAP.
Select * from VBAP into table IT_VBAP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'VBAP'
TABLES
T_OUTTAB = IT_VBAP.
When ever we are working with all the fields from any one of the database table or structure, then
we no need to prepare field catalog internal table. We simply pass i_structure_name as data base
table name structure.
Note: - Here the function module picks the column headings from the data element of each field
and also display the fields in the similar order of the fields in the table.
Page No : 98
FILLING THE FIELD CATALOG
Note: - In slis we have one type i.e. SLIS_T_FIELDCAT_ALV which contains all the fields related to
field catalog internal table. So we simply declare our internal table by referring this.
Slis is the type group which contains all the types related to ALV.
Note: - When ever we are referring any type under any type group then we must include the type group
name by using “type-pools” keyword.
Note: - All the names under the group must be starts with type group name_ (underscore).
Type-pools ZTG.
Types: begin of ZTG_T001,
Bukrs type t001-bukrs,
Butxt type t001-butxt,
Ort01 type t001-ort01,
End of ZTG_T001. (IT)
Types ZTG_T_T001 type table of ZTG_T001. (WA)
Page No : 99
Display the company codes, company names and cities.
Type-pools ZTG.
Data: it_t001 type ZTG_T_T001,
Wa_t001 like line of it_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.
Based on the given purchasing document number display the purchasing document numbers,
document dates and vendor numbers by using ALV and also display the purchasing document
number with yellow co lour, document date with edit and the vendor is hotspot.
Type-pools slis.
TABLES EKKO.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
‘REUSE_ALV_FIELDCATALOG_MERGE’ is the function module which is used to fill the field catalog
internal table.
The input for the above function module is
Data work area.
Program name in where data work area is declared.
Field catalog internal table.
Program name, in where field catalog internal table is declared.
Note: - ‘SY-CPROG’ is the system variable which contains current program name.
Note: - When ever we are working with merge function module then we must consider the following
things.
We never declare the data internal table by using ‘TYPES’ keyword.
We never refer the data internal table fields by using type. Instead of type we use like.
We must maintain the code up to 72 columns.
Based on the given purchasing document number display the purchasing document numbers,
document dates and vendor numbers by using ALV and also display the purchasing document
number with yellow co lour, document date with edit and the vendor is hotspot by using hotspot
module.
After the merge function module the field catalog as shown in the below.
Page No : 101
After merge function module we modify the field catalog based on the client requirement.
Note: - We can’t modify the key fields directly first we remove the key then we modify it.
TYPE-POOLS SLIS.
TABLES EKKO.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
DATA: BEGIN OF WA_EKKO,
EBELN LIKE EKKO-EBELN,
BEDAT LIKE EKKO-BEDAT,
LIFNR LIKE EKKO-LIFNR,
END OF WA_EKKO.
DATA IT_EKKO LIKE TABLE OF WA_EKKO.
SELECT EBELN BEDAT LIFNR FROM EKKO INTO TABLE IT_EKKO WHERE EBELN
IN S_EBELN.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
Page No : 102
Lifnr type ekko-lifnr,
Ebelp type ekpo-ebelp,
Netpr type ekpo-netpr,
End of ty_final.
Data it_final type table of ty_final.
Select ekko~ebeln ekko~bedat ekko~lifnr ekpo~ebelp ekpo~netpr into
table it_final from ekko inner join ekpo on ekko~ebeln = ekpo~ebeln
where ekko~ebeln in s_ebeln.
* Declare the field catalog.
Data: it_fcat type slis_t_fieldcat_alv,
Wa_fcat like line of it_fcat.
* Filling the field catalog.
Wa_fcat-fieldname = 'EBELN'.
Wa_fcat-col_pos = '1'.
Wa_fcat-seltext_m = 'pur.doc'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'BEDAT'.
Wa_fcat-col_pos = '2'.
Wa_fcat-seltext_m = 'DOC DATE'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'LIFNR'.
Wa_fcat-col_pos = '3'.
Wa_fcat-seltext_m = 'VENDOR'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'EBELP'.
Wa_fcat-col_pos = '4'.
Wa_fcat-seltext_m = 'ITEM'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'NETPR'.
Wa_fcat-col_pos = '5'.
Wa_fcat-seltext_m = 'NETVALUE'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
* Display output
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_FINAL.
Page No : 103
EVENTS IN ALV
In ALV, events are handle through ‘sub-routines’ (form, endform)
1. Top_of_page
2. Top_of_list
3. End_of_page
4. End_of_list
5. User_command
6. Pf_status_set
Top_of_page: -
It’s an event which is triggered at the top of each page.
Top_of_list: -
It’s an event which is triggered at the top of displayed output list.
End_of_page: -
It’s an event which is triggered at the end of each page.
End_of_list: -
It’s an event which is triggered at the end of displayed output list.
User_command: -
It’s an event which is triggered at the time of user clicks on any record of any list as well as any
menu item.
This event acts like both at line-selection & at user-command.
Pf_status_set: -
It’s an event which is triggered at the time of attaching our GUI to the program.
When ever we are working with events then we must declare an event internal table which contains 2
fields. Event
Page No : 104
Note: - In slis we have one type I.e. slis_t_event which contains the above fields. So we simply declare
the internal table by referring slis_t_event.
Based on the given company codes display the company codes, company names & customer
numbers by using ALV as shown in the below and also validate the company code.
Note: - We can also print the data in start-of-selection event when ever we are fetching the data from
data base. Then we must use end-of-selection to print the data.
Note: - When ever we are working with events then we must provide “I_callback_program” as current
program name in the grid or list display.
TYPE-POOLS SLIS.
TABLES T001.
DATA V TYPE T001-BUKRS.
SELECT-OPTIONS S_BUKRS FOR T001-BUKRS.
* Declare the final data IT.
TYPES: BEGIN OF TY_FINAL,
BUKRS TYPE T001-BUKRS,
BUTXT TYPE T001-BUTXT,
KUNNR TYPE KNB1-KUNNR,
END OF TY_FINAL.
DATA: WA_FINAL TYPE TY_FINAL,
IT_FINAL TYPE TABLE OF TY_FINAL.
* Declare the field catalog.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
* Declare the event internal table.
DATA: IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF IT_EVENT.
AT SELECTION-SCREEN.
SELECT SINGLE BUKRS FROM T001 INTO V WHERE BUKRS IN S_BUKRS.
IF SY-SUBRC <> 0.
MESSAGE E000(ZMESSAGE1) WITH 'PLEASE SELECT VALID COMANY CODE'.
ENDIF.
* Filling the data internal table
Page No : 105
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.
* Filling field catalog
WA_FCAT-FIELDNAME = 'BUKRS'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_M = 'COCD'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'BUTXT'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'COMPANY NAME'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'KUNNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'CUSTOMER'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
* Filling event IT.
WA_EVENT-NAME = 'TOP_OF_PAGE'.
WA_EVENT-FORM = 'TOP'.
* Perform TOP
APPEND WA_EVENT TO IT_EVENT.
* Display output
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IT_FIELDCAT = IT_FCAT
IT_EVENTS = IT_EVENT
TABLES
T_OUTTAB = IT_FINAL.
FORM TOP.
WRITE:/ 'SP RAO TECHNOLOGIES'.
WRITE:/ 'THESE ARE CUSTOMERS UNDER COMPANY'.
ENDFORM.
Note: - If you want to print the logo in the top of page then list display doesn’t support. Only grid
display supports the logo, but we can’t print the text in the top or bottom events by using write statements
in grid display.
REUSE_ALV_COMMENTARY_WRITE: -
It’s the function module which is used to display the text top or bottom events.
The input for the above function module is an IT which contains two fields.
Page No : 106
Note: - In slis we have one type i.e. slis_t_listheader which contains the above two fields. So we
simply declare our internal table by reffering slis_t_listheader.
Based on the given purchasing document numbers display the purchasing document number,
document dates and vendor numbers by using ALV. As shown in the below.
Note: - If you want to print the logo then you must pass the object key name into commentary write
function module.
TYPE-POOLS SLIS.
TABLES EKKO.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EKKO-EBELN,
BEDAT TYPE EKKO-BEDAT,
KUNNR TYPE EKKO-KUNNR,
END OF TY_EKKO.
DATA: WA_EKKO TYPE TY_EKKO,
IT_EKKO TYPE TABLE OF TY_EKKO.
* Declaring the field catalog.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
WA_FCAT-FIELDNAME = 'BEDAT'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'DOC DATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'KUNNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'CUSTOMER'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
* Declare two event internal tables.
DATA: IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF IT_EVENT.
* Filling the event IT.
WA_EVENT-NAME = 'TOP_OF_PAGE'.
WA_EVENT-FORM = 'TOP'.
* Perform TOP.
APPEND WA_EVENT TO IT_EVENT.
WA_EVENT-NAME = 'END_OF_LIST'.
WA_EVENT-FORM = 'END'.
APPEND WA_EVENT TO IT_EVENT.
* Display output
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IT_FIELDCAT = IT_FCAT
IT_EVENTS = IT_EVENT
TABLES
T_OUTTAB = IT_EKKO.
FORM TOP.
DATA: IT_LIST TYPE SLIS_T_LISTHEADER,
WA_LIST LIKE LINE OF IT_LIST.
WA_LIST-INFO = 'THESE ARE PO DETAILS'.
WA_LIST-TYP = 'H'.
APPEND WA_LIST TO IT_LIST.
WA_LIST-INFO = 'SP RAO TECHNOLOGIES'.
WA_LIST-TYP = 'S'.
APPEND WA_LIST TO IT_LIST.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
Page No : 108
EXPORTING
IT_LIST_COMMENTARY = IT_LIST
I_LOGO = 'SATISH'.
ENDFORM.
FORM END.
DATA: IT_LIST1 TYPE SLIS_T_LISTHEADER,
WA_LIST1 LIKE LINE OF IT_LIST1.
WA_LIST1-INFO = 'SR NAGAR'.
WA_LIST1-TYP = 'A'.
APPEND WA_LIST1 TO IT_LIST1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LIST1.
ENDFORM.
Syntax of calling subroutine for the event USER_COMMAND: -
Perform <form name> using sy-ucomm slis_selfied
Tab index
It contains code of user Value
selection menu item Field name
Syntax of definition: -
Form <form name> using <variable 1> like sy-ucomm <variable 2> type slis_selfied.
-----
-----
----- Field name Value Tab index
Endform
Based on the given company codes display the company codes, company names and vendors
under company as shown in below by using ALV and also print the company code with green color
along with hotspot.
Page No : 109
Type-pools slis.
Tables vbak.
Select-options s_vbeln for vbak-vbeln.
Data v type vbap-vbeln.
TYPES: BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
AUDAT TYPE VBAK-AUDAT,
KUNNR TYPE VBAK-KUNNR,
BUKRS_VF TYPE VBAK-BUKRS_VF,
END OF TY_VBAK.
DATA: WA_VBAK TYPE TY_VBAK,
IT_VBAK TYPE TABLE OF TY_VBAK.
DATA: IT_VBAP TYPE TABLE OF VBAP,
WA_VBAP LIKE LINE OF IT_VBAP.
* Filling the data internal table.
Select vbeln audat kunnr bukrs_vf from vbak into table it_vbak where
vbeln in s_vbeln.
* Declare the field catalog
Data: it_fcat type slis_t_fieldcat_alv,
Wa_fcat like line of it_fcat.
* Filling the field catalog.
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_M = 'SALES DOC'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'AUDAT'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'DOC DATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'KUNNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'CUST NO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'BUKRS_VF'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_M = 'COCD'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
* Declare the event IT.
Data: it_event type slis_t_event,
wa_event like line of it_event.
* Filling the event IT.
wa_event-name = 'USER_COMMAND'.
wa_event-form = 'UC'.
* Perform UC using sy-ucomm slis_selfield
Append wa_event to it_event.
* Display output
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
Page No : 110
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IT_FIELDCAT = IT_FCAT
IT_EVENTS = IT_EVENT
TABLES
T_OUTTAB = IT_VBAK.
Form UC using A like sy-ucomm B type slis_selfield.
If B-fieldname = 'VBELN'.
V = B-VALUE.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V
IMPORTING
OUTPUT = V.
SELECT * FROM VBAP INTO TABLE IT_VBAP WHERE VBELN = V.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'VBAP'
TABLES
T_OUTTAB = IT_VBAP.
*read table it_vbak into wa_vbak index b-tabindex.
*select * from vbap into table it_vbap where vbeln = wa_vbak-vbeln.
* CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
* EXPORTING
* I_STRUCTURE_NAME = 'VBAP'
* TABLES
* T_OUTTAB = IT_VBAP.
Endif.
Endform.
If the user clicks on any record then we display the sales document item details.
Form UC using A like sy-ucomm B type slis_selfield.
Read table it_vbak into wa_vbak index B-tabindex.
Select * from vbap into table it_vbap where vbeln = wa_vbak-vbeln.
CALL FUNCTION ‘REUSER_ALV_LIST_DISPLAY’
‘VBAP’
‘IT_VBAP’
Endform
Page No : 111
Based on the given vendor numbers, display the purchase document numbers, document dates &
vendor numbers by using ALV & also display the purchase document numbers with yellow color. If
the user clicks on any purchasing document number only then we display the all the purchasing
document item details by using ALV.
Type-pools SLIS.
Tables EKKO.
Select-options s_EBELN for ekko-EBELN.
* Declare the data internal table
Types: Begin of ty_ekko,
EBELN type EKKO-EBELN,
BEDAT type EKKO-BEDAT,
LIFNR type EKKO-LIFNR,
End of ty_ekko.
Data it_ekko type table of ty_ekko.
Data it_ekpo type table of ekpo.
* filling the data internal table
Select ebeln bedat lifnr from ekko into table it_ekko where ebeln in
s_ebeln.
* Declare the field catalog
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
* Filling the field catalog
Wa_fcat-fieldname = 'EBELN'.
Wa_fcat-col_pos = '1'.
Wa_fcat-seltext_m = 'PUR.DOC'.
Wa_fcat-emphasize = 'C310'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'BEDAT'.
Wa_fcat-col_pos = '2'.
Wa_fcat-seltext_m = 'DOC DATE'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'LIFNR'.
Wa_fcat-col_pos = '3'.
Wa_fcat-seltext_m = 'VENDOR'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
* Declare the event internal table
Data: it_event type slis_t_event,
wa_event like line of it_event.
* Filling the event internal table
Wa_event-name = 'USER_COMMAND'.
WA_Event-form = 'UC'.
* Perform UC using sy-ucomm slis_selfield
Append wa_event to it_event.
* Display the output
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IT_FIELDCAT = IT_FCAT
Page No : 112
IT_EVENTS = IT_EVENT
TABLES
T_OUTTAB = IT_EKKO.
FORM UC USING A LIKE SY-UCOMM B TYPE SLIS_SELFIELD.
IF B-fieldname = 'EBELN'.
Select * from ekpo into table it_ekpo where ebeln = B-value.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'EKPO'
TABLES
T_OUTTAB = IT_EKPO.
ENDIF.
ENDFORM.
LOGIC: -
WA_EVENT-NAME = ‘USER_COMMAND’. Field name (EBELN)
WA_EVENT-FORM = ‘UC’.
* PERFORM UC USING SY-UCOMM SLIS_SELFIELD Value (300012)
Append wa_event to it_event. Tabindex (4)
Call function ‘REUSE_ALV_LIST_DISPLAY’.
IT_EKKO
IT_FCAT
IT_EVENT
Page No : 113
EX: -
Parameter p_lifnr type lfa1-lifnr.
Set parameter id ‘LIF’ field p_lifnr.
Call transaction ‘XK03’ and skip first screen.
Based on the given sales document numbers to display the sales doc numbers, document dates &
customer numbers by using ALV & also display the sales document number with green color. If the
user clicks on any sales document only then we display the sales order details through ‘VA03’
transaction. If the user clicks on any customer number only then we display the customer details
through ‘XD03’ transaction.
* Declare select-options
* Declare data internal table, field catalog, event internal table
* Fill the data internal table
* Fill the field catalog
Wa_event-name = ‘USER_COMMAND’.
Wa_event-form = ‘UC’.
* Perform UC using SY-UCOMM SLIS_SELFIELD.
Based on the given purchasing document numbers, display the purchasing document numbers,
document dates & vendor numbers by using ALV. If the user clicks on any record then we display
the purchasing document details through ‘ME23N’ transaction.
Wa_event-name = ‘USER_COMMAND’.
Wa_event-form = ‘XYZ’.
* Perform XYZ using sy-ucomm slis_selfield.
Page No : 114
Form XYZ using A like sy-ucomm B type slis_selfield.
If the user click on display button then we display the selected check box purchasing doc details through
ME23N transaction.
Steps to copy the existing GUI: -
Execute SE41. Click on copy status in the application tool bar (copy status). Provide from program
SAPLKKBL. Select the status ‘STANDARD_FULLSCREEN’. Provide to program (ZREPO12), Status
(STAT). Click on copy and enter. Open our status in change mode. Expand the application tool bar.
Provide transaction code for additional button (DIS) where the place is available. Double click on it and
press enter. Provide the function text (Display). Click on enter. Select the shortcut key. Enter. Save, check
and activate GUI.
Page No : 115
Type-pools slis.
Tables ekko.
Select-options s_ebeln for ekko-ebeln.
* Declare the data IT.
Data: begin of wa_ekko,
Ebeln type ekko-ebeln,
Bedat type ekko-bedat,
Lifnr type ekko-lifnr,
Chk,
End of wa_ekko.
Data it_ekko like table of wa_ekko.
* Filling the data IT.
SELECT EBELN BEDAT LIFNR FROM EKKO INTO TABLE IT_EKKO WHERE EBELN
IN S_EBELN.
* Declare the field catalog.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
* Filling field catalog.
Wa_fcat-fieldname = 'CHK'.
Wa_fcat-COL_POS = '1'.
Wa_fcat-seltext_m = ' '.
Wa_fcat-checkbox = 'X'.
Wa_fcat-edit = 'X'.
Wa_fcat-outputlen = '3'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'EBELN'.
Wa_fcat-col_pos = '2'.
Wa_fcat-seltext_m = 'PUR DOC'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'BEDAT'.
Wa_fcat-col_pos = '3'.
Wa_fcat-seltext_m = 'DOC DATE'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Wa_fcat-fieldname = 'LIFNR'.
Wa_fcat-col_pos = '4'.
Wa_fcat-seltext_m = 'VENDOR'.
Append wa_fcat to it_fcat.
Clear wa_fcat.
* Declare the event IT.
Data: it_event type slis_t_event,
Wa_event like line of it_event.
wa_event-name = 'PF_STATUS_SET'.
wa_event-form = 'GUI'.
* Perform GUI using slis_t_extab
Append wa_event to it_event.
clear wa_event.
Wa_event-name = 'USER_COMMAND'.
Wa_event-form = 'UC'.
Page No : 116
* Perform UC using sy-ucomm slis_selfield
Append wa_event to it_event.
* Display the output
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_callback_program = sy-cprog
It_fieldcat = it_fcat
It_events = it_event
TABLES
T_outtab = it_ekko.
Blocked ALV
Blocked ALV: -
Blocked ALV is used to display the output in a block wise.
Steps to work with blocked ALV: -
1. Initialize the blocked ALV by using ‘REUSE_ALV_BLOCK_LIST_INIT’ function module. The
input for the above function module is ‘current program name’.
2. Append the data IT to the blocked ALV by using ‘REUSE_ALV_BLOCK_LIST_APPEND’
function module. The input for the above function module is
1. <Data IT>
2. <Field catalog IT>
3. <event IT> Dummy also ok
4. <Layout WA>
3. Display the data in blocked ALV by using ‘REUSE_ALV_BLOCK_LIST_DISPLAY’ function
module.
Page No : 117
Based on the given purchasing document numbers display the purchasing document header
(EBELN, BEDAT, LIFNR) and item (EBELN EBELP MENGE MEINS NETPR) details by using
blocked ALV as shown in the below.
REPORT ZREPORT2007.
TYPE-POOLS SLIS.
TABLES EKKO.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
* Declare data IT (EKKO, EKPO)
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EKKO-EBELN,
BEDAT TYPE EKKO-BEDAT,
LIFNR TYPE EKKO-LIFNR,
END OF TY_EKKO.
DATA: WA_EKKO TYPE TY_EKKO,
IT_EKKO TYPE TABLE OF TY_EKKO.
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
END OF TY_EKPO.
DATA: WA_EKPO TYPE TY_EKPO,
IT_EKPO TYPE TABLE OF TY_EKPO.
WA_FCAT1-FIELDNAME = 'EBELN'.
WA_FCAT1-COL_POS = '1'.
WA_FCAT1-SELTEXT_M = 'PUR DOC'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME = 'EBELP'.
WA_FCAT1-COL_POS = '2'.
WA_FCAT1-SELTEXT_M = 'ITME'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME = 'MENGE'.
WA_FCAT1-COL_POS = '3'.
WA_FCAT1-SELTEXT_M = 'QTY'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME = 'MEINS'.
WA_FCAT1-COL_POS = '4'.
WA_FCAT1-SELTEXT_M = 'UOM'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME = 'NETPR'.
WA_FCAT1-COL_POS = '5'.
WA_FCAT1-SELTEXT_M = 'NET PRICE'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
* Declare the event IT
DATA: IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF IT_EVENT.
DATA: IT_EVENT1 TYPE SLIS_T_EVENT,
WA_EVENT1 LIKE LINE OF IT_EVENT1.
Page No : 119
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FCAT
I_TABNAME = 'WA_EKKO'
IT_EVENTS = IT_EVENT
TABLES
T_OUTTAB = IT_EKKO.
Based on the given purchasing document no, display the purchase document numbers, item
numbers, quantity, unit of measurement, net prize by using ALV & also display the line item details
in red colour if the amt is more than 1000.
type-pools slis.
tables ekpo.
select-options s_ebeln for ekpo-ebeln.
types: begin of ty_ekpo,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
menge type ekpo-menge,
meins type ekpo-meins,
netpr type ekpo-netpr,
xyz(4) type c,
end of ty_ekpo.
data: wa_ekpo type ty_ekpo,
Page No : 120
it_ekpo type table OF ty_ekpo.
data: it_fcat type slis_t_fieldcat_alv,
wa_fcat like line of it_fcat.
* Delcare the layout
data wa_layout type slis_layout_alv.
* Fill the layout wa.
wa_layout-info_fieldname = 'XYZ'.
select ebeln ebelp menge meins netpr from ekpo into table it_ekpo where
ebeln in s_ebeln.
wa_fcat-fieldname = 'EBELN'.
wa_fcat-col_pos = '1'.
wa_fcat-seltext_m = 'PUR DOC'.
append wa_fcat to it_fcat.
clear wa_fcat.
wa_fcat-fieldname = 'EBELP'.
wa_fcat-col_pos = '2'.
wa_fcat-seltext_m = 'ITEM'.
append wa_fcat to it_fcat.
clear wa_fcat.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-col_pos = '3'.
wa_fcat-seltext_m = 'QTY'.
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 = 'NET PRICE'.
append wa_fcat to it_fcat.
clear wa_fcat.
Page No : 121
Based on the Purchase document number, display the pur doc num, item, material, quantity,
units, net prise. Here one pur doc number can have so many items. I want sub total for each
document number. Finally I want grand total also. It’ll display as in below picture.
TABLES EKPO.
SELECT-OPTIONS S_EBELN FOR EKPO-EBELN.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO WHERE EBELN I
N S_EBELN.
WA_FCAT-FIELDNAME = 'EBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-REF_TABNAME = 'EKPO'.
WA_FCAT-REF_FIELDNAME = 'EBELN'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'EBELP'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-REF_TABNAME = 'EKPO'.
WA_FCAT-REF_FIELDNAME = 'EBELP'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-REF_TABNAME = 'EKPO'.
WA_FCAT-REF_FIELDNAME = 'MATNR'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'MENGE'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-REF_TABNAME = 'EKPO'.
WA_FCAT-REF_FIELDNAME = 'MENGE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
Page No : 122
WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-REF_TABNAME = 'EKPO'.
WA_FCAT-REF_FIELDNAME = 'MEINS'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'NETPR'.
WA_FCAT-COL_POS = '6'.
WA_FCAT-REF_TABNAME = 'EKPO'.
WA_FCAT-REF_FIELDNAME = 'NETPR'.
WA_FCAT-DO_SUM = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_SORTINFO-FIELDNAME = 'EBELN'.
WA_SORTINFO-SUBTOT = 'X'.
APPEND WA_SORTINFO TO IT_SORTINFO.
CLEAR WA_SORTINFO.
Page No : 123
HIERARCHICAL ALV
Hierarchical ALV is used to display the header and item details in a hierarchical manner.
EKKO
EKPO EBELN key info wa
Note: - In slis we have one type I.e. ‘SLIS_KEYINFO_ALV’ which contains above fields. So we
simply declare our IT by referring SLIS_KEYINFO_ALV.
Ex: -
Note: - When ever we are working with hierarchical ALV then we must fill the field catalog IT.
1. REUSE_ALV_LIST_DISPLAY
2. REUSE_ALV_GRID_DISPLAY
3. REUSE_ALV_HIERSEQ_LIST_DISPLAY
4. REUSE_ALV_COMMENTARY_WRITE
5. REUSE_ALV_BLOCK_LIST_DISPLAY
6. REUSE_ALV_FIELD CATALOG_MERGE
Page No : 124
1. SLIS_T_FIELDCAT_ALV
2. SLIS_T_EVENT
3. SLIS_T_LIST HEADER
4. SLIS_SELFIELD
5. SLIS_T_EXTAB
6. SLIS_LAYOUT_ALV
7. SLIS_KEYINFO_ALV
Based on the given purchasing
document number display the
purchasing document (EBELN,
BEDAT, LIFNR) & purchasing
document item details (EBELP,
MENGE, MEINS, NETPR) in
hierarchical manner as shown in the
below by using ALV.
Type-pools slis.
Tables ekko.
Select-options s_ebeln for ekko-ebeln.
* Declare the data IT (IT_EKKO, IT_EKPO)
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EKKO-EBELN,
BEDAT TYPE EKKO-BEDAT,
LIFNR TYPE EKKO-LIFNR,
END OF TY_EKKO.
DATA: WA_EKKO TYPE TY_EKKO,
IT_EKKO TYPE TABLE OF TY_EKKO.
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
END OF TY_EKPO.
DATA: WA_EKPO TYPE TY_EKPO,
IT_EKPO TYPE TABLE OF TY_EKPO.
SELECT EBELN BEDAT LIFNR FROM EKKO INTO TABLE IT_EKKO WHERE EBELN
IN S_EBELN.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO
WHERE EBELN IN S_EBELN.
* Declare the field catalogs
data: it_fcat type slis_t_fieldcat_alv,
wa_fcat like line of it_fcat.
WA_FCAT-FIELDNAME = 'EBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_M = 'PUR DOC'.
WA_FCAT-TABNAME = 'IT_EKKO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'BEDAT'.
WA_FCAT-COL_POS = '2'.
Page No : 125
WA_FCAT-SELTEXT_M = 'DOC DATE'.
WA_FCAT-TABNAME = 'IT_EKKO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'LIFNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'VENDOR'.
WA_FCAT-TABNAME = 'IT_EKKO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'EBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-SELTEXT_M = 'PUR DOC'.
WA_FCAT-TABNAME = 'IT_EKPO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'EBELP'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'ITME'.
WA_FCAT-TABNAME = 'IT_EKPO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'MENGE'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'QTY'.
WA_FCAT-TABNAME = 'IT_EKPO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_M = 'UOM'.
WA_FCAT-TABNAME = 'IT_EKPO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'NETPR'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-SELTEXT_M = 'NETPRICE'.
WA_FCAT-TABNAME = 'IT_EKPO'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
Page No : 126
I_TABNAME_HEADER = 'IT_EKKO'
I_TABNAME_ITEM = 'IT_EKPO'
IS_KEYINFO = WA_KEY
TABLES
T_OUTTAB_HEADER = IT_EKKO
T_OUTTAB_ITEM = IT_EKPO.
Note: - When ever we are working with ALV Repots in real time then we must pass layout WA.
Data wa_layout type slis_layout_alv.
Wa_layout-colwidth_optimize = ‘X’.
Wa_layout-zebra = ‘X’.
Note: - When ever we are filling the field catalog manually, if you want to refer the database table, field
description to print as a heading then we use following fields in field catalog.
Ref_fieldname
Ref_tabname.
EX: -
Wa_fcat-fieldname = ‘VBELN’.
Wa_fcat-col_pos = ‘1’.
Wa_fcat-ref_tabname = ‘VBAK’.
Wa_fcat-ref_fieldname = ‘VBELN’.
Append wa_fcat to it_fcat.
Clear wa_fcat.
Page No : 127
Transaction / Dialog pool programming / Module Pool Programming: -
A transaction is the collection of sequential screens which accept the input & display the output.
It’s also called as Dialog Pool Programming since we have interaction between screens. It’s also called as
Module Pool Programming because the flow logic of each screen acts as a module. So it’s a pool of
module.
Note: - A transaction code contains either executable program or module pool program.
Page No : 128
Step 2: -
Execute SE38. Provide the program name. Click on create. Provide title. Select the type is module pool.
Click on save, local object. Click on display object list in the application tool bar.
Working with screen painter: -
Screen painter is a tool which contains both the graphical as well as alpha numeric mode. The transaction
code for screen painter is SE51.
Note: - The communication between flow logic editor to ABAP editor is always through screen
elements. I.e. each element in the screen we must declare one equality declaration in ABAP editor.
Steps to work with module pool program as per ABAPer point of view: -
1. Create the module pool program
2. Design the required screens
3. Maintain the equality declaration in ABAP editor
4. Maintain or implement the PBO and PAI logics of each screen
5. Create the transaction code to run the program
Page No : 129
Design the screen as shown in the below.
After the user provide the input1 and input2 click on addition
button then we display the output in the result field. If the user
clicks on back button then we go to program.
If we are working with more than one screen then the back button
functionality of the first screen is leave program, from second screen
on wards leave to screen 0.
Page No : 131
END OF TY_KNB1.
DATA: WA_KNB1 TYPE TY_KNB1,
IT_KNB1 TYPE TABLE OF TY_KNB1.
MODULE USER_COMMAND_2000 INPUT.
IF SY-UCOMM = 'DIS'.
SELECT BUKRS KUNNR AKONT FROM KNB1 INTO TABLE IT_KNB1 WHERE BUKRS = A.
LEAVE TO LIST-PROCESSING.
LOOP AT IT_KNB1 INTO WA_KNB1.
WRITE:/ WA_KNB1-BUKRS, WA_KNB1-KUNNR, WA_KNB1-AKONT.
ENDLOOP.
ELSEIF SY-UCOMM = 'BACK'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE.
Working with table control: -
Table control is used to display the multiple records in a tabular
format.
Page No : 132
Note: - When ever we are working with loop & endloop in any one of the event then we must declare a
dummy loop & endloop in another event.
CONTROLS TBC TYPE TABLEVIEW USING SCREEN 2000.
DATA A TYPE EKPO-EBELN.
DATA: BEGIN OF WA_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
END OF WA_EKPO.
DATA IT_EKPO LIKE TABLE OF WA_EKPO.
MODULE USER_COMMAND_1000 INPUT.
IF SY-UCOMM = 'DIS'.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO
WHERE EBELN = A.
CALL SCREEN 2000.
ELSEIF SY-UCOMM = 'BACK'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE.
MODULE USER_COMMAND_2000 INPUT.
IF SY-UCOMM = 'BAK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
Flow logic of 1000 screen:-
PROCESS BEFORE OUTPUT.
* MODULE STATUS_1000.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_1000.
Flow logic of 2000 screen: -
PROCESS BEFORE OUTPUT.
* MODULE STATUS_2000.
LOOP AT IT_EKPO INTO WA_EKPO WITH CONTROL TBC CURSOR TBC-CURRENT_LINE.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP.
ENDLOOP.
MODULE USER_COMMAND_2000.
In the work area field names, table control field names are different suppose V1, V2, V3, V4, V5.
PBO of 2000: -
Loop at it_ekpo into wa_ekpo with control TC cursor TC-current_line.
Module xyz.
Endloop.
Program: -
Module xyz output.
V1 = wa_ekpo-ebeln.
V2 = wa_ekpo-ebelp.
V3 = wa_ekpo-menge.
Page No : 133
V4 = wa_ekpo-meins.
V5 = wa_ekpo-netpr.
Endmodule.
Page No : 134
ELSEIF SY-UCOMM = 'BAK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
F4IF_INT_TABLE_VALUE_REQUEST
Page No : 135
Steps of module in POV event: -
Field <field name> module <module name>.
Page No : 136
GUI Components
GUI Title 2000 3000
Note: - The PBO of each screen contains by default GUI title & GUI status.
Working with sub screen areas: -
Sub screen area must be placed in normal screen only. Each sub screen area can call only one sub screen
at a time.
Page No : 137
ENDIF.
ENDIF.
ENDMODULE.
MODULE USER_COMMAND_3000 INPUT.
IF SY-UCOMM = 'INS'.
INSERT T001 FROM T001.
IF SY-SUBRC = 0.
MESSAGE S000(ZMESSAGE1) WITH 'INSERTED SUCCESSFULLY'.
ELSE.
MESSAGE E000(ZMESSAGE1) WITH 'NOT INSERTED'.
ENDIF.
ENDIF.
ENDMODULE.
Flow logic of 1000 screen.
PROCESS BEFORE OUTPUT.
MODULE STATUS_1000.
CALL SUBSCREEN: SA1 INCLUDING SY-REPID '2000',
SA2 INCLUDING SY-REPID '3000'.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_1000.
CALL SUBSCREEN: SA1, SA2.
Flow logic of 2000 screen: -
PROCESS BEFORE OUTPUT.
* MODULE STATUS_2000.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_2000.
Flow logic of 3000 screen: -
PROCESS BEFORE OUTPUT.
* MODULE STATUS_3000.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_3000.
Working with tab strip: -
Strip of tabs.
Each tab must contain at least one sub screen
area.
Each sub screen area can call only one sub
screen at a time.
By default tab strip contains 2 tabs.
Only one tab is always activated.
Design the screen as shown in the below.
Syntax of declaring the tab strip in ABAP editor:-
Controls <table strip name> type tabstrip.
Note: - When ever we are working with tabstrip
then it’s better to maintain tab name & function code
of the tab name same.
Syntax of activate the tab: -
<tabstrip name> - Active tab = ‘<tab name>’.
Steps to design the strip control: -
Select the tabstrip control screen element. Draw it. Double click on it. Provide the name (TBS). Provide
number of tab titles. Double click on tab1. Provide the name of tab1 (TAB1), provide the text function
Page No : 138
code as tab1(Company). Select the subscreen area screen element. Draw it. Double click on it. Provide the
name(SA1). Repeat the steps for all the tabs.
CONTROLS TBS TYPE TABSTRIP.
TABLES: T001, KNA1.
MODULE USER_COMMAND_1000 INPUT.
IF SY-UCOMM = 'BACK'.
LEAVE TO SCREEN 0.
ELSEIF SY-UCOMM = 'TAB1'.
TBS-ACTIVETAB = 'TAB1'.
ELSEIF SY-UCOMM = 'TAB2'.
TBS-ACTIVETAB = 'TAB2'.
ENDIF.
ENDMODULE.
MODULE STATUS_1000 OUTPUT.
SET PF-STATUS 'STAT'.
ENDMODULE.
MODULE USER_COMMAND_0100 INPUT.
IF SY-UCOMM = 'INS'.
INSERT T001 FROM T001. 3000
ENDIF.
ENDMODULE.
MODULE USER_COMMAND_0200 INPUT.
IF SY-UCOMM = 'SAV'.
INSERT KNA1 FROM KNA1.
ENDIF.
ENDMODULE.
Flow logic of 1000 screen: -
PROCESS BEFORE OUTPUT.
MODULE STATUS_1000.
CALL SUBSCREEN: SA1 INCLUDING SY-REPID '0100',
SA2 INCLUDING SY-REPID '0200'.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_1000.
CALL SUBSCREEN: SA1, SA2.
Page No : 139
Design the screen as shown in the
below.
Note: - At the time of designing the
screen double click on the drop down field
& select the drop down as list box with key
in the pop up window.
Note: - T005T is the standard data base
table which contains all the country keys &
country names.
TYPE-POOLS VRM.
TABLES T001.
TYPES: BEGIN OF TY_T005T,
LAND1 TYPE T005T-LAND1,
LANDX TYPE T005T-LANDX,
END OF TY_T005T.
DATA: WA_T005T TYPE TY_T005T,
IT_T005T TYPE TABLE OF TY_T005T.
ENDMODULE.
Page No : 140
INSERT T001.
IF SY-SUBRC = 0.
MESSAGE S000(ZMESSAGE1) WITH 'INSERTED SUCCESSFULLY'.
ELSE.
MESSAGE E000(ZMESSAGE1) WITH 'NOT INSERTED'.
ENDIF.
ENDIF.
ENDMODULE.
Differences between call screen & set screen
Ranges: -
Ranges is the key word which accepts single value, multiple values, single range, multiple ranges.
Syntax: -
Ranges <name of the ranges> for <variable name>.
Ex: -
Data V1 type t001-bukrs.
Ranges r_bukrs for v1.
Page No : 141
Design the screen as shown in the below.
After the user provide the company codes & click on display button then we display the vendors under
company details by using ordinary report.
Data: A type t001-bukrs,
B type t001-bukrs.
Data v1 like t001-bukrs.
Ranges r_bukrs for v1.
Data: begin of wa_lfb1,
Bukrs type lfb1-bukrs,
Lifnr type lfb1-lifnr,
Akont type lfb1-akont,
End of wa_lfb1.
Data it_lfb1 like table of wa_lfb1.
Page No : 142
Ex:-
Field A values ( ‘1000’, ‘2000’, ‘2200’ ).
PROGRAM ZMPP99910.
DATA A TYPE LFB1-BUKRS.
DATA B TYPE LFB1-LIFNR.
DATA V1 TYPE LFA1-LIFNR.
DATA V2 TYPE LFB1-BUKRS.
Page No : 143
IF SY-SUBRC <> 0.
MESSAGE E000(ZMESSAGE1) WITH 'THE VENDOR IS NOT UNDER THE
COMPANY'.
ENDIF.
ENDMODULE.
PROCESS BEFORE OUTPUT.
* MODULE STATUS_2000.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_2000.
CHAIN.
FIELD A VALUES ('1000','2000','2200').
FIELD B MODULE ABC.
ENDCHAIN.
MODULE USER_COMMAND_2000 AT EXIT-COMMAND.
Page No : 144
SAP-SCRIPT
In the real time if you want to design the business
documents, such as offer letters, experience letters,
invoices, commercial invoices etc. we need layout
sets. These are designed through forms. Forms are
either SAP scripts or smart forms.
Driver program is used to fetch the data from data base & transfer to the layout.
Header: -
Header is used to maintain the administrative information. i.e. form name, language & page
format.
In the real time page formats are created by BASIS people through SPAD transaction.
Page format is the collection of page width & height of displayed document.
Page No : 145
Pages: -
Page is the physical area where we can place the windows. We can’t print the data directly on the
page. Page
Windows: -
We can paste the same window in any number of pages. We can’t print the data directly on the
window. There are two types of windows.
1. Main window
2. Variable window
Note: - Main window is the default window in SAP script
without a main window we can’t design SAP script.
Note: - We can place the variable window only one time per
page. Where as main window we can place up to 99 times per
page.
Page window: -
Page window is nothing but placing the window on the page with co-ordinates (left margin, upper
margin, width, height) we can print the data only on page window.
Paragraph format: -
This is used to print the entire paragraph to the required fonts & style.
Character format: -
This is used to display the perticular text with the required font & style.
Documentation: -
This is used to maintain the document related to the form.
Note: - SE71 is the transaction code for form painter or form editor.
Steps to design the layout: -
Execute SE71 . Provide the form name. Click on create. Provide short description. Click on pages in the
application tool bar. In the menu bar click on edit create element. Provide the page name, short
description. Enter. Repeat the same steps for all pages. Click on windows in the application tool bar. Click
on edit create element. Provide the window name, short description. Enter. Repeat the same steps for
all other windows. Click on page window. Click on edit create element. It’ll display the all available
windows. Double click on the window & provide the co-ordinations. Click on paragraph formats in the
application tool bar. Provide the default paragraph. Enter. Provide short description. Click on header in the
application tool bar (F5). Click on basic settings. Provide the first page. Default paragraph. Save the
layout. In the menu bar click on settings form painter. Select the check box graphical form painter.
Page No : 146
Enter. Click on layout in the application tool bar. Arrange the layouts by using drag & drop. Minimize the
layout. Once again click on settings in the menu bar form painter remove the graphical form painter.
Enter. Save the layout. Check the layout. (Form check definition). Activate the layout (Form
active).
We can print the data on the page window is always through symbols. Each symbol start with ‘&’ ends
with ‘&’. There are 4 types of symbols.
1. Program symbols.
2. System symbols
3. Standard symbols
4. Text symbols
Program symbols: -
Program symbols are variables in the program.
Ex: -
&WA_T001-BUKRS&
&WA_KNA1-KUNNR&
System symbols: -
System symbols are system variables.
EX: -
&date&
&month&
Standard symbols: -
Standard symbols are coming from TTDTG standard data base table.
Ex: -
&Mr&
&Dear&
Text symbols:-
Text symbols are variables, which are defined in page window.
Ex: -
1: define &A&.
Steps to develop the driver program:-
1. Create an executable program and implement the retrieving logic.
2. Access the layout from the driver program by using ‘OPEN_FORM’ function module. The input
for the above function module is form name (layout).
3. Transfer the data from driver program to particular page window by using ‘WRITE_FORM’
function module the input for above function module is window name.
Repeat the same steps for each page window, which contains program symbols.
4. Close the form by using ‘CLOSE_FORM’ function module.
Based on the given vendor number display the vendor address in the address window by using
SAP-Script.
Steps to provide the symbols on the page window:-
Execute SE71. Provide the form name. Click on change. Click on page window on the application tool
bar. Double click on our required window. Click on text elements in the application tool beside header
button. Define &WA_LFA1-LIFNR& &WA_LFA1-NAME1& &WA_LFA1-ORT01&.
Click on back, save, check, activate the program.
Steps to execute the driver program: -
Execute the program. Provide the input. Execute. Provide the output is ‘LP01’. Click on print preview.
PARAMETER P_LIFNR TYPE LFA1-LIFNR.
TYPES: BEGIN OF TY_LFA1,
LIFNR TYPE LFA1-LIFNR,
Page No : 147
NAME1 TYPE LFA1-NAME1,
ORT01 TYPE LFA1-ORT01,
END OF TY_LFA1.
DATA WA_LFA1 TYPE TY_LFA1.
SELECT SINGLE LIFNR NAME1 ORT01 FROM LFA1 INTO WA_LFA1 WHERE LIFNR =
P_LIFNR.
* Access the layout from driver program
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZSCRIPT1'.
* Transfer the data to address window.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'ADDRESS'.
*Close the form
CALL FUNCTION 'CLOSE_FORM'.
* &WA_LFA1-LIFNR&
* &WA_LFA1-NAME1&
* &WA_LFA1-ORT01&
Working with logo: -
We can print either ‘.BMP’ or ‘.TIFF’ images only.
Note: - When ever we are working with ‘.BMP’ image then we must convert ‘.BMP’ to graphics image
by using ‘SE78’ transaction.
Note: - If we are working with ‘.TIFF’ image then we must convert TIFF to text image by using
RSTXLDMC standard program.
Steps to convert ‘.BMP’ to graphics image: -
Execute SE78. Expand the graphics. Double click on bitmap image. Provide the graphics name. Select the
radio button ‘color bitmap image’. Click on import in the application tool bar. Browse the bitmap image.
Enter.
Steps to insert the logo in the page window: -
Execute SE71. Open the form in change mode. Click on page widows in the application tool bar. Double
click on logo window. Click on text elements in the application tool bar. In the menu bar click on insert
graphics. Click on stored document server tab. Provide the graphics name. Select the radio button ‘color
bitmap image’. Enter. Click on back. Save, check, activate.
Based on the given vendor number display the vendor purchase orders (LIFNR, EBELN,
BEDAT) in the main window and vendor details in header window by using SAP-Script.
Note: - If you get the error WRITE_FORM is invalid START_FORM is missing then we must provide
the next page as same page in the form (page).
Steps to provide next page: -
Execute SE71. Open form in change mode. Click on the pages on the application tool bar. Provide next
page is page1. Save, check, activate.
Note: - When ever we are working with main window then we must provide text element name
otherwise the first information will be printed twice. The text element name start with ‘/E’.
PARAMETER P_LIFNR TYPE LFA1-LIFNR.
TYPES: BEGIN OF TY_LFA1,
Page No : 148
LIFNR TYPE LFA1-LIFNR,
NAME1 TYPE LFA1-NAME1,
ORT01 TYPE LFA1-ORT01,
END OF TY_LFA1.
DATA WA_LFA1 TYPE TY_LFA1.
TYPES: BEGIN OF TY_EKKO,
LIFNR TYPE EKKO-LIFNR,
EBELN TYPE EKKO-EBELN,
BEDAT TYPE EKKO-BEDAT,
END OF TY_EKKO.
DATA: WA_EKKO TYPE TY_EKKO,
IT_EKKO TYPE TABLE OF TY_EKKO.
SELECT SINGLE LIFNR NAME1 ORT01 FROM LFA1 INTO WA_LFA1 WHERE LIFNR =
P_LIFNR.
SELECT LIFNR EBELN BEDAT FROM EKKO INTO TABLE IT_EKKO WHERE LIFNR =
P_LIFNR.
* Access the layout from driver program
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZSCRIPT1'.
* Transfer the data to address window.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'ADDRESS'.
* Transfer the data to main window.
LOOP AT IT_EKKO INTO WA_EKKO.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'SATISH'
WINDOW = 'MAIN'.
ENDLOOP.
*Close the form
CALL FUNCTION 'CLOSE_FORM'.
Page No : 149
In the real time most of the times footer window is used to print the page numbers & sign in last page.
Syntax of page numbers -
* PAGE &PAGE& at &SAPSCRIPT-FORMPAGES&
Current page number of pages
Syntax of sign in last page: -
/: if &nextpage& = 0.
* SPRAO TECHNOLOGIES
/: endif.
Control commands: -
Control commands are used to control the display output. Control commands start with ‘/:’ control
commands are
1. Include
2. Define
3. Address - - - - - endaddress
4. protect - - - - - - - endprotect
5. top - - - - - - endtop
6. bottom - - - - - Endbottom
7. if - - - - endif
8. case - - - - endcase
9. set date / time mask
10. new-page
11. New window
12. box
13. perform - - - - endperform
Include: -
This command is used to include the standard text
which is defined in ‘SO10’ transaction into page
window. If you want to maintain the same information in
more than one form instead of maintain these information
in each form its better to maintain those statements in the
standard text & later we include the standard text into
each form.
Steps to create standard text: -
Execute SO10. Provide the standard text name. Click on create. Provide the screen text.
SPRAO TECHNOLOGIES
# 301, TIRUMALA MANASA COMPLEX
ABOVE DCB BANK
Steps to include the standard text in the page window: -
Execute SE71. open the form in change mode. Click on the page window in the application tool bar.
Double click on our required window. Click on text elements (F9). Place the cursor where we want to
include the standard text. In the menu bar click on insert text standard. Provide the standard text
name, enter. Click on back. Save, activate.
Whenever we create standard text it won’t ask any package or request number. So we must create
a request number to standard text to transport to quality & live server.
Steps to create the request number to standard text: -
Execute SE38. Provide program name (RSTXTRAN). Execute. Provide the standard text name (ZSTN).
Execute. Click on enter. Click on transfer text to correction in the application tool bar. Click on yes. Click
on create request. Provide short description. Enter. Request no is ‘EC6K900496’.
This request number is given to basis people then the basis people move the standard text from
development server to Quality / Live server.
Page No : 150
Define: -
This command is used to declare the variables in the page window.
Ex: -
/: define &special& = ‘DEC25’.
Address - - - - endaddress: -
This command is used to display the address in the format of target countries.
/: Address
* &wa_kna1-name1&
* &wa_kna1-ort01&
/: endaddress
Protect - - - endprotect: -
This control command is used to print the continuous text without any page break. Here the system
check each & every page which page is having the enough of page. If no page is having enough of page
then it simply break the text & print in different places.
/: protect
* SPRAO TECHNOLOGIES
* SR NAGAR
/: endprotect
Top - - - endtop: -
This control command is used to display the header information in the main window.
Ex: -
/: top
* PUR-DOC, ITEM, QTY, UOM, PRICE
/: endtop.
Bottom - - - endbottom: -
This control command is used to print the footer information in the main window.
/: bottom
* Total &v_total&
/: endbottom
Page No : 151
New – page: -
This control command is used to break the page.
/: If &wa_marc-matnr& = ‘100 – 200’.
/: New-page.
/: Endif.
New-window: -
This control command is used to call the next window.
Box: -
This command is used to draw the tables, horizontal lines & vertical lines.
Syntax of box: -
/: BOX xpos ‘<value>’ <unit> ypos ‘<value>’ <unit> width ‘<value>’ <unit> height ‘<value>’ <unit>
intensity ‘<value>’ <unit> frame ‘<value>’ <unit>.
UNITS DESCRIPTION
CM CENTIMETER
MM MILLIMETER
PT POINT
IN INCHES
CH CHAR
TW TWIP = 1/20 PT.
Ex: -
/: Box XPOS ‘0’ cm YPOS ‘0’ cm width ‘5’ cm height ‘2’ CM frame ‘20’ TW.
Note: - If we want to draw the horizontal line then height is 0, vertical line then width is 0.
/: Box xpos ‘0’ cm ypos ‘0’ cm width ‘7’ cm height ‘0’ cm frame ‘20’ pw.
7 CM 3 CM
/: Box xpos ‘0’ cm ypos ‘0’ cm width ‘0’ cm height ‘3’ cm frame ‘20’ pw.
Based on the given purchasing document number display the purchasing document item details
as shown below by using SAPSCRIPT.
Page No : 152
Title window: -
Left margin 1 cm width 18.5 cm
Upper margin 1 cm height 1 cm
Main window: -
Left margin 1 cm width 18.5 cm
Upper margin 2.5 cm height 20 cm
Page No : 153
Note: - In the real time when ever we are working with quantity & amount fields then those information
must be printed in right alignment.
M2 &WA_EKPO-EBELN&&WA_EKPO-EBELP&&WA_EKPO-MENGE(ZC)&
= &WA_EKPO-MEINS&&WA_EKPO-NETPR(ZC)&
M2
Number Tab position Alignment
Left margin 0.2CM
1 4.2CM Left
F1 ,,Total:,,&V_Total&
2 10.8CM Right
F1
3 11.2CM Left
Left margin 0.2 CM
4 18.3CM Right
Number Tab position Alignment
1 4.2 CM Left
2 18.3 CM Right
FORM ZSCRIPT2
MAIN WINDOW: -
/E SATISH
/: BOX FRAME '20' TW
/: BOX XPOS '0' CM YPOS '1' CM WIDTH '18.5' CM HEIGHT '0' CM FRAME '20' TW
/: BOX XPOS '0' CM YPOS '19' CM WIDTH '18.5' CM HEIGHT '0' CM FRAME '20' TW
/: BOX XPOS '4' CM YPOS '0' CM WIDTH '0' CM HEIGHT '20' CM FRAME '20' TW
/: BOX XPOS '6.5' CM YPOS '0' CM WIDTH '0' CM HEIGHT '20' CM FRAME '20' TW
/: BOX XPOS '11' CM YPOS '0' CM WIDTH '0' CM HEIGHT '20' CM FRAME '20' TW
/: BOX XPOS '13.5' CM YPOS '0' CM WIDTH '0' CM HEIGHT '20' CM FRAME '20' TW
/: TOP
M1 ,,PUR DOC,,ITEM,,QTY,,UOM,,PRICE
Page No : 154
/: ENDTOP
M2 &WA_EKPO-EBELN&,,&WA_EKPO-EBELP&,,&WA_EKPO-MENGE(ZCT)&,,
= &WA_EKPO-MEINS(K)&,,&WA_EKPO-NETPR(ZCT)&
/: BOTTOM
M3 ,,TOTAL:,,&V_TOTAL&
/: END BOTTOM
Format options:-
Format options are used to display the output or print the output as per client requirement.
Format Options Syntax Example Output
Offset &symbol+offset& &a& = abcdefgh &a+3& = defgh
Output length &symbol(o/p length)& &a& = abcdefgh &a(3)& = abc
Omitting leading zeros &symbol(z)& &a& = 000100.00 &a(z)& = 100.00
Omitting sign &symbol(s)& &a& = -100.00 &a(s)& = 100.00
Leading sign at left &symbol(<)& &a& = 100.00- &a(<)& = -100.00
Leading sign right &symbol(>)& &a& = -100.00 &a(>)& = 100.00-
Compress output &symbol(c)& &a& = 100.00 &a(c)& = 100.00
Ignore the separators &symbol(t)& &a& = 1,00,000.00 &a(t)& = 100000.00
Number of decimals &symbol(.number)& &a& = 10.3215 &a(.2)& = 10.32
&a(.0)& = 10
Ignore conversions &symbol(k)& &a& = &WA_EKPO-MEINS(K)&
Note: - In the real time before modifying the SAP-SCRIPT we must maintain the backup of SAP-
SCRIPT because SAP-SCRIPT doesn’t have version management (ABAP editor have version
management).
TABLES EKPO.
DATA V_TOTAL TYPE EKPO-NETPR.
SELECT-OPTIONS S_EBELN FOR EKPO-EBELN.
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
END OF TY_EKPO.
DATA: WA_EKPO TYPE TY_EKPO,
IT_EKPO TYPE TABLE OF TY_EKPO.
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO
WHERE EBELN IN S_EBELN.
CALL FUNCTION 'OPEN_FORM'.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM = 'ZTFORM3'.
LOOP AT IT_EKPO INTO WA_EKPO.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'SATISH'
WINDOW = 'MAIN'.
V_TOTAL = V_TOTAL + WA_EKPO-NETPR.
ENDLOOP.
CALL FUNCTION 'END_FORM'.
Material: -------------
Plant: -----------------
Batch: ----------------
Mfg.dt: ---------------
Exp.dt: ---------------
Page No : 157
P_NOL TYPE I.
DATA: BEGIN OF WA_MCHA,
MATNR TYPE MCHA-MATNR,
WERKS TYPE MCHA-WERKS,
CHARG TYPE MCHA-CHARG,
HSDAT TYPE MCHA-HSDAT,
VFDAT TYPE MCHA-VFDAT,
END OF WA_MCHA.
SELECT SINGLE MATNR WERKS CHARG HSDAT VFDAT FROM MCHA INTO WA_MCHA
WHERE MATNR = P_MATNR AND WERKS = P_WERKS.
* Access the layout from driver program
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZFORM195'.
* Transfer the data to main window
DO P_NOL TIMES.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HAI'
WINDOW = 'MAIN'.
ENDDO.
* Close the form
CALL FUNCTION 'CLOSE_FORM'.
MAIN WINDOW: -
/E TM
* Material,,:&wa_mcha-matnr&
* Plant,,: &wa_mcha-werks&
* Batch,,: &wa_mcha-charg&
* Mfg.dt,,: &wa_mcha-hsdat&
* Exp.dt,,: &wa_mcha-vfdat&
/: new-window
Working with Standard SAP-SCRIPT
Page No : 159
Perform - - - - endperform: -
This control command is used to adding some additional logic to the standard driver program
without disturbing the standard driver program.
Syntax of perform - - - endperform (calling) in page window: -
/: Perform <form name> in program <subroutine pool program>
Where the definition is available
/: using &input1&
/: using &input2&
||
/: changing &output1&
/: changing &output2&
||
/: endperform
Page No : 161
DATA: BEGIN OF WA_MAKT,
MATNR TYPE MAKT-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF WA_MAKT.
DATA: BEGIN OF WA_T001W,
WERKS TYPE T001W-WERKS,
NAME1 TYPE T001W-NAME1,
END OF WA_T001W.
FORM GET_DES TABLES INPUT STRUCTURE ITCSY
OUTPUT STRUCTURE ITCSY.
READ TABLE INPUT WITH KEY NAME = 'WA_MARC-MATNR'.
SELECT SINGLE MATNR MAKTX FROM MAKT INTO WA_MAKT WHERE MATNR =
INPUT-VALUE.
OUTPUT-VALUE = WA_MAKT-MAKTX.
MODIFY OUTPUT TRANSPORTING VALUE WHERE NAME = 'V_MDES'.
READ TABLE INPUT WITH KEY NAME = 'WA_MARC-WERKS'.
SELECT SINGLE WERKS NAME1 FROM T001W INTO WA_T001W WHERE WERKS =
INPUT-VALUE.
OUTPUT-VALUE = WA_T001W-NAME1.
MODIFY OUTPUT TRANSPORTING VALUE WHERE NAME = 'V_PDES'.
ENDFORM.
Text element: -
The text element is the name given to the block of statements in the page window. Text element name
start with /E. Normally the write form functional module transfers the data from driver program to all the
statements which are available in the page window.
Call function ‘WRITE_FORM’
Exporting
FORM = ‘ADDRESS’.
If you provide text element name to the write form function module then the ‘WRITE_FORM’ function
module transfers the data from driver program to all the statements which are available in the text element.
Call function ‘WRITE_FORM’
Exporting
Element = ‘DHAWAN’.
Window = ‘ADDRESS’.
Note: - The page window contains at least one text element then we must provide the text element name
to the write from function module.
EKET (Scheduling agreement table) : -
EBELN Purchasing document number
EBELP Item number
EINDT Delivery date
Modify the standard purchase order layout to incorporate the item wise delivery date.
Page No : 162
In the object we add the additional logic of item wise delivery date to the standard driver program through
subroutine pool program. Before adding the additional logic first we take a printout or print preview of
existing layout & later we put the debugging mode & identify the right place with the help of printout or
print preview. Implement the logic.
Steps to identify the right place in the page window where we add the additional logic to the page
window: -
Execute ‘ME23N’. provide PO number. Click on print preview or take a printout. Now execute the SE71.
provide form name. in the menu bar click on utilities Activate debugger. Now execute ME23N in a
separate session. Click on print preview. Now the form is in debugging mode. Click on ok. Continuously
click on F5 button. Identify the right window & text element. Right place is window name ‘MAIN’.
Element name is ‘ITEM_LINE_1’
FORM: ZSPT930_MEDRUCK
WINDOW ‘MAIN’: -
IL
/: PERFORM GET_DELDT IN PROGRAM ZTDELDT
/: USING &EKPO-EBELN&
/: USING &EKPO-EBELP&
/: CHANGING &V_DD&
/: ENDPERFORM
/ &EKPO-EBELP&,,&EKPO-EMATN&,,&EKPO-TXZ01&,,&V_DD+6(2)&.&V_DD+4(2)&.
= &V_DD+0(4)&
Sub routine pool program: -
PROGRAM ZTDELDT.
DATA V1 TYPE EKPO-EBELN.
DATA V2 TYPE EKPO-EBELP.
V_ADD = 20010522
&v_add+6(2)&.&v_add+4(2)&.&v_add+0(4)&
22 05 2001
Page No : 163
Types of windows in the SAP-SCRIPT: -
1. Main window
2. Variable window
3. Constant window
Control window is the fixed window in all the pages.
SAP script is client dependent that means if you design the SAP script in one client that isn’t reflected to
all other clients in the same server.
BASIS People job
Server1 Server2
SAP script X
Driver program
Copy the SAP script from one client to another client in the same server
Depends on package
SE71 SCC1
Steps to copy the SAP script from one client to another client (800 to 810) into the script is available
in $TMP: -
In 810 client execute SE71. In the menu bar click on utilities copy from client. Provide the form name.
Source client is 800. Provide the target form (ZSPT_930_FORM). Execute.
Page No : 164
on execute. Double click on our object. Remove the old package. Place the new package. Click on save.
Create the request (F8). Provide short description. Note down the request. Enter.
Steps to copy the SAP script from 800 to 810 client if the form is available in our own package &
request number: -
In 810 client execute ‘SCC1’. Provide the source client number, request number. Select the including
request sub tasks. Click on start immediately in the application tool bar. Click on yes.
Note: - We can’t copy the SAP script one server to another server. This is done by BASIS people. We
can copy the SAP script within the server only.
Note: - ‘RSTXFCPY’ is the standard program to copy the SAP script from one client to another client.
READ_TEXT: -
It’s the function module which is used to read the standard text information. The input for the
above function module is
1. Text ID
2. Name
3. Object
4. Language
The output for the above function module is an internal table which contains two fields. They are
TDFORMAT & TDLINE.
If you want to identify the input of the above function module then open the standard text in the
menu bar. Click on goto header. Identify the name, language, text id, object.
Note: - In the real time we use this function module to read the purchasing document header text,
purchase document item text, sales document header, sales document item text, invoice header text,
invoice item text . . . . .
When ever we are working with ‘READ_TEXT’ module, we must uncomment the execution.
Exceptions
-------
-------.
Loop at IT into WA.
Write:/ WA-TDFORMAT, WA-TDLINE.
Endloop.
Page No : 165
Based on the given material number, display the material numbers, material descriptions. If the
functional people maintain the material description in the purchase order text then we print this
information otherwise print the MAKT.
Page No : 166
SMART FORMS: -
Smart forms are used to design the business documents such as invoices, purchase orders, sales orders. . .
smart form is introduced from 4.6C version on wards.
Procedure of the smart form: -
Based on the client requirement we design the smart form layout by using ‘SMARTFORMS’
transaction code & provide the necessary symbols, save, check, activate.
When ever we activate the smart form it generates a function module. Based on the function
module we develop the print program.
Function module is used to transfers the data from print program to layout.
Components of SMART FORMS: -
1. Smart form layout
2. Function Module
3. Print program
Components of Smart form layout: -
1. Global settings
2. Pages and windows
Global settings is the collection of form attribute, form interface, global definitions.
Form attributes: -
These are used to maintain the administrative information that is form name, language, page
format, default style.
Form Interface: -
This is used to declare the variables, work areas and internal tables which are needed to transfers
the data from print program to layout
Global definition: -
These are used to declare the variables, work area, internal tables which are needed to implement
the logic in the form or layout.
Note: - ‘SMARTFORMS’ is the transaction code to design the smart form layout.
Based on the given company code, display the company code, comp name & city by using smart
forms.
Steps to design the smart form:-
Execute ‘SMARTFORMS’. Select the radio button form. Provide the form name. Click on create. Provide
short description. Double click on form interface in the left panel. The import tab (I_BUKRS, type, t001-
bukrs). Double click on global definitions in the left panel. Click on types tab. Declare the types.
Types: begin of ty_t001,
Bukrs type t001-bukrs,
Page No : 167
Butxt type t001-butxt,
Ort01 type t001-ort01,
End of ty_t001.
Click on global data tab. Provide work area. (WA_T001 TYPE TY_T001).
Click on initialization tab & implement the logic. Provide input output parameters.
INPUT PARAMETER OUTPUT PARAMETER
I_BUKRS WA_T001
select single bukrs butxt ort01 from t001 into wa_t001 where bukrs =
i_bukrs.
Expand the page in the left panel. Select the main window. Right click create text. Double click on
text. Click on editor under general attributes tab. Provide symbols.
&wa_t001-bukrs&
&wa_t001-butxt&
&wa_t001-ort01&
Click on back. Save, check, activate. In the menu bar click on environment function module name.
based on this function module we develop the print program.
Report ZSPT_930_PRINT_PROGRAM
Parameter p_bukrs type t001-bukrs.
Call function ‘/1BCDWB/SF00000341’
Exporting
I_BUKRS = P_BUKRS.
Note: - In the SAP summarized data is available in t001, kna1,
lfa1 & their detailed information is available in ‘ADRC’ table. The
link is ‘ADRNR’.
Select the page in the left panel. Right click create address. Double click on address. Provide the
address number in the general attributes tab. Save, check, activate. In the menu bar click on environment
function module name. Based on this function module we develop the print layout.
Page No : 168
REPORT ZSM1.
parameter p_kunnr type kna1-kunnr.
CALL FUNCTION '/1BCDWB/SF00000260'
EXPORTING
I_KUNNR = p_kunnr.
Note: - If you want to declare the select-options in the smart form then we must declare one structure
with the following fields in the data dictionary & later we refer the structure in the tables tab of form
interface in the smart form.
Based on the given purchasing document numbers, display the purchasing document numbers,
document dates & vendor numbers by using smart forms.
Sign (C, 1)
Option (C, 2)
Low
High
Structure: ZVBAK1
Sign char 1
Option char 2
Low char 10
High char 10
Page No : 170
Based on the client requirement which data is varying that part consider as a main area. Above main area
consider as a header & below main area consider as footer.
Based on the given purchasing document numbers, display the purchase order details as shown
in the below.
Page No : 171
Select EBELN EBELP MENGE MEINS NETPR from EKPO into table it_ekpo
where Ebeln in I_SEBELN.
loop at it_ekpo into wa_ekpo.
v_total = v_total + wa_ekpo-netpr.
endloop.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = v_total
CURRENCY = 'INR'
IMPORTING
IN_WORDS = AIW.
Double click on main window in the left panel. Click on output options tab. Provide the co ordinations of
main window.
Left margin 1 CM Width 18.5 CM
Upper margin 1CM height 25 CM
Select the main window in the left panel right click create table. Double click on table. In the data
tab provide internal table name into work area name (IT_EKPO into WA_EKPO). Click on tables tab.
Select the LTYPE1. Right click rename line. Provide new name as line1. Select the ‘Line1’. Click on
select pattern under table tab. Click on display framed pattern. Select the pattern. Select the ‘Line1’. Right
click insert empty line underneath. Select the ‘Ltype1’. Right click rename line. Provide the new
name as ‘Line2’. Select the line2. Click on details in top right. Provide the each call width.
Line1 18.5 cm
Line2 4cm 3cm 4.5cm 2.5cm 4.5cm
Click on table painter in the top right. Select the ‘Line2’. Click on select pattern under table tab. Select the
pattern.
Table
Header Right click Create Table line Select Line1
Line1
Cell Text T1 purchase order
Line2
Cell1 Text T2 Purchase doc
Cell2 Text T2 Item
Cell3 Text T2 QTY
Cell4 Text T2 UOM
Cell5 Text T2 Price
Main window
Line2
Cell1 Text M1 &WA_EKPO-EBELN&
Cell2 Text M1 &WA_EKPO-EBELP&
Cell3 Text M2 &WA_EKPO-MENGE&
Cell4 Text M1 &WA_EKPO-MEINS&
Cell5 Text M2 &WA_EKPO-NETPR&
Footer
Line1
Cell1 F1 ,, Total,,&V_Total(ZC)&
F1,, Amount in words: &AIW-Words& Rupees and
&AIW-DECWORD& Paise.
Save, check, activate the smart form.
Page No : 172
T1
Helve, 16, Bold, Center
T2
Helve, 14, Bold, Center
M1
Helve, 14, Bold, Left alignment, Left margin 0.2 cm
M2
Helve, 14, Bold, Right alignment
F1
Tab position
1. 14 cm left alignment
2. 18.3 cm right alignment
Page No : 173
Event on sort end: -
It’s an event which is triggered at the last record of each block.
ADV: - It’s used to display the subtotals.
This is similar as at end of field name in the control break statement.
Based on the given purchasing document numbers, display the purchasing item details as shown in
the below by using ‘SMARTFORMS’.
SMART FORM NAME: ZSPRAO_7AM_SF8
FORM INTERFACE
===============
Table
I_SEBELN LIKE ZSPRAO_7AM_SS
Global definitions
Types:
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
END OF TY_EKPO.
Global data
Wa_ekko type ty_ekpo
It_ekpo type table of ty_ekpo
V1 type ekpo-netpr
V2 type ekpo-netpr
Initialization
I_sebeln it_ekpo
Wa_ekpo v2
It_ekpo
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO
WHERE EBELN IN I_SEBELN.
Page No : 174
Double click on loop in the left panel. In the sort criteria block provide field name as Ebeln and select the
check box event on sort end. Select the event on sort end in left panel. Right click create text. Double
click on text.
* Sub total: &v1(zc)&
Click on back. Select the text in left panel. Right click create flow logic program lines.
Double click on code. Implement the logic & input parameter is v1.
Clear v1.
Save, check, activate.
In the menu bar click on environment function module name. based on this function module we develop
the print program.
TABLES EKPO.
SELECT-OPTIONS S_EBELN FOR EKPO-EBELN.
TABLES
I_SEBELN = S_EBELN.
Differences between SAP Script & SMARTFORMS
Note: - In the smart forms function module number we can’t transported to quality & live server.
Depends on server configuration function module number is generated. So we can’t fix the function
module number in the print program. We always generate the function module by using
Page No : 175
‘SSF_FUNCTION_MODULE_NAME’. The input for the above function module is smart form name. the
output for the above function module is smart form number.
REPORT ZSF.
TABLES EKPO.
SELECT-OPTIONS S_EBELN FOR EKPO-EBELN.
DATA V_FM TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSF2'
IMPORTING
FM_NAME = V_FM.
CALL FUNCTION V_FM
TABLES
I_SEBELN = S_EBELN.
Note: - Now-a-days most of the companies used zebra printers to print the labels. Because the cost of
payable is cheap, quality is good. Gum thickness is also good. Zebra printers don’t support sap script only.
It supports smart forms. So we must design the labels through smart form.
Based on the given material number & number of labels design the accepted labels as shown in
the below.
At the time of label design BASIS people create page format based on the table width & height through
‘SPAD’ transaction & given to us. Based on this page format we design the label.
Smart form name: ZSPRAO_7AM_SF9.
FORM INTERFACE
Import
I_MATNR TYPE MCHA-MATNR
I_NOL TYPE I
Global definitions
Types
TYPES: BEGIN OF TY_MCHA,
MATNR TYPE MCHA-MATNR,
WERKS TYPE MCHA-WERKS,
CHARG TYPE MCHA-CHARG,
HSDAT TYPE MCHA-HSDAT,
Page No : 176
VFDAT TYPE MCHA-VFDAT,
END OF TY_MCHA.
TYPES: BEGIN OF TY,
NO TYPE SYINDEX,
END OF TY.
Global data
WA_MCHA TYPE TY_MCHA
IT_MCHA TYPE TABLE OF TY_MCHA
WA TYPE TY
IT TYPE TABLE OF TY
Initialization
I_MATNR WA_MCHA
I_NOL WA
IT
SELECT SINGLE MATNR WERKS CHARG HSDAT VFDAT FROM MCHA INTO WA_MCHA
WHERE MATNR = I_MATNR.
DO I_NOL TIMES.
WA-NO = SY-INDEX.
APPEND WA TO IT.
ENDDO.
Double click on main window in the left panel. Click on output options tab. Provide the co ordinates.
Left margin: 1CM width: 18.5 CM
Upper margin: 1 CM Window height 2.5 CM
Select the main window in the left panel. Right click create flow logic loop. Double click on
loop. Click on data tab. Provide (IT into WA). Select the loop. Right click Create Text. Double
click on text.
MATERIAL : &WA_MCHA-MATNR&
PLANT : &WA_MCHA-WERKS&
BATCH : &WA_MCHA-CHARG&
MFG.DT : &WA_MCHA-HSDAT&
EXP.DT : &WA_MCHA-VFDAT&
PARAMETER: S_MATNR TYPE MCHA-MATNR,
S_NOL TYPE I.
DATA V_FM TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSF3'
IMPORTING
FM_NAME = V_FM.
CALL FUNCTION V_FM
EXPORTING
I_MATNR = S_MATNR
I_NOL = S_NOL.
Each & every window & text editor contains the following additional events in the conditions tab.
1. Only on first page
2. Not on first page
3. Only after end of Main window
4. Only before end of Main window
5. Only on page
1. Only on first page: - This is used to print the window or text editor information only on first page.
2. Not on first page:- This is used to print the window or text editor information from 2nd page on wards.
Page No : 177
3. Only after end of Main window:- This is used to print the window or text editor information after
main window data printing completion.
4. Only Before end of Main window: - This is used to print the window or text information on each page
until the main window is completed.
5. Only on page:- This is used to print the window or text editor information on a specified page.
Page No : 179
Based on the given sales document number display the item details. I want to display the
customer ship to address, billing address details and company name & it’s whareshouse address. I
don’t want to print the smartform, directly I want to downlad that output in PDF format.
DATA V_E_DEVTYPE TYPE RSPOPTYPE. " It'll come under SSF_GET_DEVICE_TYPE FM
DATA: ST_JOB_OUTPUT_INFO TYPE SSFCRESCL, "These all are come under our SF FM name
ST_DOCUMENT_OUTPUT_INFO TYPE SSFCRESPD,
ST_JOB_OUTPUT_OPTIONS TYPE SSFCRESOP.
DATA: OTF LIKE TABLE OF ITCOO, "These all are come under CONVERT_OTF_2_PDF FM
TLINE LIKE TABLE OF TLINE,
DOCS LIKE TABLE OF DOCS.
DATA bin_filesize type i. "It's for CONVERT_OTF_2_PDF FM & GUI_DOWNLOAD FM
DATA FILE TYPE IBIPPARMS-PATH. "FOR F4_FILENAME FM
DATA FILE1 TYPE STRING.
PARAMETER P_VBELN TYPE VBAK-VBELN.
DATA A TYPE KNB1-KUNNR.
DATA FM_NAM TYPE RS38L_FNAM.
DATA: WA_VBAK TYPE ZST_VBAK1,
IT_VBAK LIKE TABLE OF WA_VBAK.
DATA: WA_VBAP TYPE ZST_VBAP1,
IT_VBAP LIKE TABLE OF WA_VBAP.
DATA: WA_BILLADD TYPE ZST_BILLADD,
IT_BILLADD LIKE TABLE OF WA_BILLADD.
DATA: WA_SHIPADD TYPE ZST_SHIPADD,
IT_SHIPADD LIKE TABLE OF WA_SHIPADD.
DATA: WA_OUTPUT TYPE SSFCOMPOP, "These all are come under our SF FM name.
WA_CONTROL TYPE SSFCTRLOP.
WA_OUTPUT-TDDEST = 'LP01'.
WA_CONTROL-NO_DIALOG = 'X'.
WA_CONTROL-GETOTF = 'X'.
WA_CONTROL-PREVIEW = 'X'.
SELECT SINGLE VBELN AUDAT KUNNR FROM VBAK INTO WA_VBAK WHERE VBELN = P_VBELN.
IF SY-SUBRC = 0.
SELECT SINGLE VBELN POSNR PARVW KUNNR ADRNR FROM VBPA INTO WA_VBPA WHERE VBELN = WA
_VBAK-VBELN AND PARVW = 'AG'. "SOLD TO PARTY ADDRESS
IF SY-SUBRC = 0.
SELECT SINGLE ADDRNUMBER NAME1 CITY1 POST_CODE1 FROM ADRC INTO WA_BILLADD WHERE A
DDRNUMBER = WA_VBPA-ADRNR.
ENDIF.
SELECT SINGLE VBELN POSNR PARVW KUNNR ADRNR FROM VBPA INTO WA_VBPA1 WHERE VBELN = W
A_VBAK-VBELN AND PARVW = 'WE'. "SHIP TO PARTY
IF SY-SUBRC = 0.
SELECT SINGLE ADDRNUMBER NAME1 CITY1 POST_CODE1 FROM ADRC INTO WA_SHIPADD WHERE A
DDRNUMBER = WA_VBPA1-ADRNR.
ENDIF.
SELECT SINGLE BUKRS KUNNR FROM KNB1 INTO WA_KNB1 WHERE KUNNR = WA_VBAK-KUNNR.
IF SY-SUBRC = 0.
SELECT SINGLE KUNNR NAME1 STRAS ORT01 LAND1 PSTLZ FROM T001W INTO WA_T001W WHERE
KUNNR = WA_KNB1-KUNNR.
SELECT SINGLE BUKRS BUTXT FROM T001 INTO WA_T001 WHERE BUKRS = WA_KNB1-BUKRS.
ENDIF.
SELECT VBELN POSNR KWMENG NETWR FROM VBAP INTO TABLE IT_VBAP WHERE VBELN = WA_VBAK-
VBELN.
ENDIF.
WA_COMP-BUKRS = WA_KNB1-BUKRS.
WA_COMP-BUTXT = WA_T001-BUTXT.
WA_COMP-KUNNR = WA_T001W-KUNNR.
WA_COMP-NAME1 = WA_T001W-NAME1.
WA_COMP-STRAS = WA_T001W-STRAS.
WA_COMP-ORT01 = WA_T001W-ORT01.
WA_COMP-LAND1 = WA_T001W-LAND1.
WA_COMP-PSTLZ = WA_T001W-PSTLZ.
Page No : 181
OUTPUT_OPTIONS = WA_OUTPUT
USER_SETTINGS = ' '
P_VBELN = P_VBELN
WA_VBAK = WA_VBAK
WA_BILLADD = WA_BILLADD
WA_SHIPADD = WA_SHIPADD
WA_COMP = WA_COMP
IMPORTING
DOCUMENT_OUTPUT_INFO = ST_DOCUMENT_OUTPUT_INFO
JOB_OUTPUT_INFO = ST_JOB_OUTPUT_INFO
JOB_OUTPUT_OPTIONS = ST_JOB_OUTPUT_OPTIONS
TABLES
IT_FINAL = IT_FINAL.
FILE1 = FILE.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = BIN_FILESIZE
FILENAME = 'C:\Users\ULL@$\Desktop\HAI1.PDF'
FILETYPE = 'BIN'
TABLES
DATA_TAB = TLINE.
Based on the given purchasing document number display the document number, doc date,
vendor (ALV). Select any check box of any record and click on PRINT button then display the
purchasing item details in smart form.
REPORT ZALVR2.
TABLES EKKO.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
TYPE-POOLS SLIS.
TYPES: BEGIN OF TY_EKKO,
EBELN TYPE EKKO-EBELN,
BEDAT TYPE EKKO-BEDAT,
LIFNR TYPE EKKO-LIFNR,
A(2) TYPE C,
END OF TY_EKKO.
DATA: WA_EKKO TYPE TY_EKKO,
IT_EKKO TYPE TABLE OF TY_EKKO.
SELECT EBELN BEDAT LIFNR FROM EKKO INTO TABLE IT_EKKO WHERE EBELN IN
S_EBELN.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT LIKE LINE OF IT_FCAT.
WA_FCAT-FIELDNAME = 'A'.
Page No : 182
WA_FCAT-COL_POS = '1'.
WA_FCAT-EDIT = 'X'.
WA_FCAT-CHECKBOX = 'X'.
WA_FCAT-OUTPUTLEN = '3'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'EBELN'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-SELTEXT_M = 'PUR DOC'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'BEDAT'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-SELTEXT_M = 'DOC DATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'LIFNR'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-SELTEXT_M = 'VENDOR'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
DATA: IT_EVENT TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF IT_EVENT.
WA_EVENT-NAME = 'PF_STATUS_SET'.
WA_EVENT-FORM = 'PF'.
APPEND WA_EVENT TO IT_EVENT.
WA_EVENT-NAME = 'USER_COMMAND'.
WA_EVENT-FORM = 'UC'.
APPEND WA_EVENT TO IT_EVENT.
Page No : 183
ENDIF.
ENDFORM.
Smart form
Global Settings
Form interface
I_EBELN TYPE EKKO-EBELN
Global Definitions
Global data
WA_EKPO TYPE TY_EKPO
WA_EKKO TYPE TY_EKKO
IT_EKPO TYPE TABLE OF TY_EKPO
Types
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
END OF TY_EKPO.
SELECT SINGLE EBELN BEDAT FROM EKKO INTO WA_EKKO WHERE EBELN = I_EBELN.
Table:-
Header
Line1 - create text purchasing document
Line 2: - row1 create text pur doc: &wa_ekko-ebeln&
Row2 create text doc date: &wa_ekko-bedat&
Line 3: row1 text purchasing doucment
Row2 text item
Row3 text qty
Row4 text uom
Row5 text price
Main: -
Line3: row1 text &wa_ekpo-ebeln&
Row2 text &wa_ekpo-ebelp&
Row3 text &wa_ekpo-menge&
Row4 text &wa_ekpo-meins&
Row5 text &wa_ekpo-netpr&
Page No : 184
Based on the given sales document date display the doc number, document date, item, quantity,
price. I want to display one field that is Total amount. For example I have one material with 3
number of quantity. In this situation, I caluculate quantity multiplication netprice. That will value
will pass into Total variable. In smartform I want to display the 10 records. After 11th record to 20th
record display in 2nd page. Per page I want to display 10 records only and I want to display the total
of that page in that page footer. I want to display the total amount in that document in another
window.
TABLES VBAK.
SELECT-OPTIONS S_AUDAT FOR VBAK-AUDAT.
DATA V2 TYPE I. "For containing total number of records
WA_CONTROL-NO_DIALOG = 'X'.
WA_CONTROL-PREVIEW = 'X'.
WA_OUTPUT-TDDEST = 'LP01'.
SELECT VBELN AUDAT FROM VBAK INTO TABLE IT_VBAK WHERE AUDAT IN S_AUDAT.
IF IT_VBAK IS NOT INITIAL.
SELECT VBELN POSNR NETWR KWMENG FROM VBAP INTO TABLE IT_VBAP FOR ALL ENTRIES IN IT_
VBAK WHERE VBELN = IT_VBAK-VBELN.
ENDIF.
In smartform: -
In form attributes I’ve taken the smartstyles name. In form interface I’ve taken like
V2 TYPE INTEGER
S_AUDAT TYPE ZSO_AUDAT
In global definitions I’ve taken like this
WA_FINAL LIKE ZST_VBAP2
A TYPE SY-INDEX
PRICE TYPE VBAP-NETWR
AIW TYPE SPELL
AMT TYPE VBAP-NETWR
AINW TYPE SPELL
FLG TYPE CHAR1
Expand page1, right click on Main window create table. Select table in left panel. In the data tab
deactivate the check box internal table. In the table tab create the two lines. 1st line co-ordinates like this
0,80 CM 2,30 CM 2,75 CM 1,70 CM 2,45 CM 3,00 CM 3,00 CM.
In 2nd line I’ll take the co-ordinates like this. 2,68 CM 10,32 CM 3,00 CM
Provide the pattern for 2 lines. Expand the table. Right click on header create table line. Select the
1st line which is create previously. Then automatically It’ll display some cells. On Each cell Right click
create text. Provide the text what ever you want. You can apply smartstyles here as your wish. Select the
main area, right click create flow logic loop. Double click on loop. Select the check box internal
table. Provide internal table name, work area name. select loop in left panel, right click create flow
logic command. Double click on command in left panel. Click on conditions tab. Provide like this.
FLG = 'X'. Click on general attributes tab. Select the check box ‘go to new page’. Provide the new page
name as ‘page2’. Right click on command create table line. Provide the line as 1st line. It’ll
automatically generates some cells. on first cell right click create flow logic program line.
Double click on program line. Provide the code as bellow.
A = A + 1.
DATA: NL TYPE I.
NL = A MOD 10.
IF NL = 0.
FLG = 'X'.
ELSE.
Page No : 186
FLG = ' '.
ENDIF.
Provide output parameters as ‘A’, ‘FLG’. Input parameters as ‘A.
Right click on 1st cell under main area create text. Provide the text as &SNO&.
Right click on 2nd cell under main area create text. Provide the text as &wa_final-vbeln& Do same
steps for all cell except last cell in the main area. Right click on last cell in main area create flow
logic program lines. In the program line provide like this.
AMT = AMT + WA_FINAL-TOTAL.
Provide the output parameter as ‘AMT’, input parameters like ‘AMT’, ‘wa_final-total’.
Right click on last cell in main area create text. Provide the text as &wa_final-total(zc)&.
Right click on last cell in main area create flow logic program line. Provide the code as bellow.
IF WA_KNA1-LAND1 = 'IN'.
I_LOGO = 'INDIA'.
ELSE.
I_LOGO = 'GERMANI'.
ENDIF.
Page No : 187
Now right click on Page1 create graphic. Provide the name as &I_LOGO& and Object as
GRAPHICS and ID as BMAP and select the Color Bitmap Image (BCOL) radio button. Save, check,
activate.
Here <BR> means, character format which was created in smart styles. It’s ending with </>. VBELN
number will display as Barcodes in Smartform output now.
Page No : 188
Debugging
Debugging is a tool to trace the program execution line by line. Debugging is used to change the
field values at run time. Debugging is used to stop the program execution at any executable statement by
using break points.
There are 2 types of break points.
1. Static break point
2. Dynamic break point
Note: - SY-UNAME is the system variable which contains the current user name.
If SY-UNAME = ‘SAPUSER’.
BREAK-POINT.
Endif.
Page No : 189
Table: -
This is used to display the internal table fields & their value & also perform the internal table operations
(Append, Insert, and Delete).
Break Points: -
This is used to identify the all the break points which are placed in the program & their line number.
Watch points: -
This is used to identify the all available watch points & also we can change the watch point condition.
Callstack: -
This is used to identify the current execution event.
Over view: -
This is used to identify the all the events and all the blocks which are available in the program.
Desktop1: -
In this ABAP source code is displayed in the left side, global & local variables & their values are
displayed in right side.
Desktop2: -
In this ABAP source code is displayed in the left side, ABAP stack is displayed in right side
(currently which block is executed under which event).
Desktop3: -
In this source code is displayed in the top & global & local variables & their values are displayed
in bottom.
Standard: -
In this source code is displayed in the left side. ABAP stack is displayed in right side top. Global &
local variables are displayed in right side bottom.
Page No : 190
Structures: -
This is used to identify the work area fields & their values & also change the values.
Tables: -
This is used to display the internal table fields & their values & also perform the internal table
operations.
Objects: -
This is used to identify the all the methods of objects & also check their values.
Detail display: -
This is used to identify the detailed information of any particular field.
Difference: -
This is used to compare the any two field values & also display their history.
Differences between classic debugger & new debugger
The following ways are used to identify the errors in standard program
1. By using where used list we identify the error location.
2. By using watch point.
3. By using break point.
4. By using source code scanner.
5. By using ABAP runtime analysis [SE30].
6. By using SQL trace [ST05].
When ever we execute any transaction code if you get the error or message if you want to identify the
location of the message then we use following techniques.
EX: -
When ever we try to open a program which isn’t created, then it throws a message. This message is
triggered from which location we identify now.
By using where used list: -
Page No : 191
Execute SE38. provide the program which isn’t created. Click on display. Then we get the message.
Double click on that message. Identify the message number. In that last three digit is message number.
Rest of the things is message class.
Execute SE91. Provide message class. Click on display. Select the message number. Click on where used
list in the application tool bar. Enter. It displays the so many programs. Double click on each & every
program & identify our message is available in which program.
By using watch points: -
Execute SE38. Provide the program name. Execute ‘/H’ before display. Then debugging switched
on. Click on display. In the menu bar click on classic debugger. Click on watch point in the application
tool bar. Provide field name as SY-MSGID. Provide relational operator (=). Provide comparison value
S017. Click on F8. & identify the right location.
Execute SE38. Provide the program name. Execute ‘/H’. Click on display. In the menu bar click on
break points. Break point at message / statement. If it is a statement then provide ‘write’. Enter. Click on
F8. Identify the right location of the error.
Execute SE93. Provide the transaction code. Click on display. Identify the package. Execute SE38.
Provide the program name RS_ABAP_SOURCE_SCAN. Execute. Provide the package & provide string
searched for (S017). Execute. it provide the all the locations where the message is available. Double click
on each and every message or location. Place the break point. Execute SE38. Provide the program name.
Click on display. Then the cursor is stops at right location.
Page No : 192
BDC
(Batch Data Conversion / Communication)
BDC is used to upload the data from flat file to SAP system.
Develop a BDC program is nothing but to automate the existing transaction code. Each transaction can
create only one record at a time. If you want to create the thousands of records, one way is execute the
same transaction thousands of time. Another way is develop a BDC program to automate the existing
transaction.
Steps of the standard transaction
codes: -
1. XK01 / MK01 / FK01 Create Vendor.
2. XD01 / VD01 / FD01 Create Customer.
3. MM01 Create Material
4. ME51N Create Purchase Requisition
5. ME21N Create Purchase Order
6. MB01 Create Material Document
7. VA01 Create Sales Order
8. VL01 Create Delivery
9. VF01 Create Billing
10. FI01 Create Bank
11. KS01 Create Cost Center
12. KE51N Create Profit Center
13. FB01 Create Accounting Document
14. CS01 Create BOM (Bill of Material)
15. MSC1N Create Batch
16. COR1 Create Process Order
17. C201 Create Recipe
Page No : 193
Steps to develop the BDC program : -
1. Analyze the transaction code
Note: - In the real time recording is provided by functional people either in development server or in
quality server depends on the data availability.
Step 2: -
In the real time functional people or end users provide a sample file in the development server to
test the BDC program.
Step 3: -
‘UPLOAD’ is the function module which is used to browse the file as well as upload the data from
file to internal table. The input for the above functional module is
1. File type ‘DAT’
Page No : 194
2. Data internal table which is similar as file.
Note: - In the real time instead of upload functional module we always use GUI_UPLOAD +
F4_filename function module.
Step 4: -
Collect the screen & field details are nothing but fill an internal table which contains the following
fields.
Note: - In the DDIC we have one structure that is BDCDATA which contains above fields, so we
simply declare our internal table by referring BDCDATA structure.
Step 5: -
Develop a conversion program to upload the vendor master data from flat file to SAP system by
using BDC call transaction method through XK01 transaction. The flat file contains vendor
numbers, names and search terms.
Step 1 (Do the record): -
Execute ‘SHDB’. Click on new recording. Provide recording name (ZSXK01). Provide transaction code
(XK01). Enter. Provide the vendor number (v1010), account group (0004). Enter. Provide the name (Big
Bazar), search term (BB), country (IN). Save.
TYPES: BEGIN OF TY_VEN,
LIFNR TYPE LFA1-LIFNR,
NAME1 TYPE LFA1-NAME1,
SORTL TYPE LFA1-SORTL,
END OF TY_VEN.
DATA: WA_VEN TYPE TY_VEN,
IT_VEN TYPE TABLE OF TY_VEN.
DATA: WA_BDCDATA LIKE BDCDATA,
IT_BDCDATA LIKE TABLE OF WA_BDCDATA.
* Upload the data.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
Page No : 195
DATA_TAB = IT_VEN.
LOOP AT IT_VEN INTO WA_VEN.
WA_BDCDATA-PROGRAM = 'SAPMF02K'.
WA_BDCDATA-DYNPRO = '0100'.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'BDC_CURSOR'.
WA_BDCDATA-FVAL = 'RF02K-KT0KK'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'BDC_OKCODE'.
WA_BDCDATA-FVAL = '/00'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'RF02K-LIFNR'.
WA_BDCDATA-FVAL = WA_VEN-LIFNR.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'RF02K-KTOKK'.
WA_BDCDATA-FVAL = '0004'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
* 2nd screen and field details
WA_BDCDATA-PROGRAM = 'SAPMF02K'.
WA_BDCDATA-DYNPRO = '0110'.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'BDC_CURSOR'.
WA_BDCDATA-FVAL = 'LFA1-LAND1'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'BDC_OKCODE'.
WA_BDCDATA-FVAL = '=UPDA'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'LFA1-NAME1'.
WA_BDCDATA-FVAL = WA_VEN-NAME1.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'LFA1-SORTL'.
WA_BDCDATA-FVAL = WA_VEN-SORTL.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'LFA1-LAND1'.
WA_BDCDATA-FVAL = 'IN'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
CALL TRANSACTION 'XK01' USING IT_BDCDATA MODE 'A'.
REFRESH IT_BDCDATA.
Page No : 196
ENDLOOP.
Develop a conversion program to upload the customer number data from flat file to SAP system
by using BDC Call transaction method through XD01 transaction. The flat file contains the
customer numbers, names, search terms & street.
Do the recording: - Execute SHDB. Click on new recording in the application tool bar. Provide
recording name (ZXD01), transaction code (XD01). Enter. Provide the customer number (12501), account
group (0004). Enter. Provide the name (GMR INFRA LTD), search term (GMR), street (Ameerpet),
country (IN), language key (EN). Save.
Steps to create a transaction code for BDC program: -
Execute SE93. Provide the transaction code [(zsbdc2) any name]. Click on create. Provide short
description. Select the radio button program and selection screen. Enter. Provide the program name. Select
the GUI check boxes. Click on save.
Page No : 197
TYPES: BEGIN OF TY_CUS,
KUNNR TYPE KNA1-KUNNR,
NAME1 TYPE KNA1-NAME1,
SORTL TYPE KNA1-SORTL,
STRAS TYPE KNA1-STRAS,
END OF TY_CUS.
DATA: WA_CUS TYPE TY_CUS,
IT_CUS LIKE TABLE OF WA_CUS.
DATA: WA_BDCDATA LIKE BDCDATA,
IT_BDCDATA LIKE TABLE OF WA_BDCDATA.
* UPLOAD THE DATA.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_CUS.
LOOP AT IT_CUS INTO WA_CUS.
WA_BDCDATA-PROGRAM = 'SAPMF02D'.
WA_BDCDATA-DYNPRO = '0100'.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'BDC_CURSOR'.
WA_BDCDATA-FVAL = 'RF02D-KTOKD'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'BDC_OKCODE'.
WA_BDCDATA-FVAL = '/00'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'RF02D-KUNNR'.
WA_BDCDATA-FVAL = WA_CUS-KUNNR.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'RF02D-KTOKD'.
WA_BDCDATA-FVAL = '0004'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
* 2nd screen details
WA_BDCDATA-PROGRAM = 'SAPMF02D'.
WA_BDCDATA-DYNPRO = '0110'.
WA_BDCDATA-DYNBEGIN = 'X'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'BDC_CURSOR'.
WA_BDCDATA-FVAL = 'KNA1-SPRAS'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'BDC_OKCODE'.
WA_BDCDATA-FVAL = '=UPDA'.
Page No : 198
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'KNA1-NAME1'.
WA_BDCDATA-FVAL = WA_CUS-NAME1.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'KNA1-SORTL'.
WA_BDCDATA-FVAL = WA_CUS-SORTL.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'KNA1-STRAS'.
WA_BDCDATA-FVAL = WA_CUS-STRAS.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'KNA1-LAND1'.
WA_BDCDATA-FVAL = 'IN'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
WA_BDCDATA-FNAM = 'KNA1-SPRAS'.
WA_BDCDATA-FVAL = 'EN'.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
Page No : 199
Steps to work with session method: -
1. Do the Recording.
2. Prepare flat file.
3. Upload the data from flat fie to internal table.
4. Create the session by using ‘BDC_OPEN_GROUP’ function module.
The input for the above function module is
i. GROUP Name of the session, which is used to process the session.
ii. KEEP Re maintain the session. After processing the session (Activate = ‘X’).
iii. HOLDDATE The session is locked, until it reaches the hold date.
iv. USER Valid user.
5. Loop at <Data internal table>.
-------------
-------------
Call the transaction by using ‘BDC_INSERT’ function module.
The input for the above function module is
i. <TCODE>
ii. <BDCDATA INTERNAL TABLE>
Page No : 201
CLEAR WA_BDCDATA.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'XD01'
TABLES
DYNPROTAB = IT_BDCDATA.
REFRESH IT_BDCDATA.
ENDLOOP.
* Close the session
CALL FUNCTION 'BDC_CLOSE_GROUP'.
BNKA (Bank Master Table)
BANKS Bank country key
BANKL Bank key
BANKA Bank name
Steps to create a bank: -
Execute FI01. Provide bank country key ‘IN’, bank key [any name (669111)]. Enter. Provide the bank
name. Save.
Develop a conversion program to upload the vendor and customer master data from two flat files
to SAP system by using BDC session method. The vendor flat files contain vendor numbers, names
& search term, customer flat file contains customer numbers, customer names, search terms &
street.
CALL FUNCTION ‘UPLOAD’
‘DAT’ ----------
IT_VEN. ----------
CALL FUNCTION ‘UPLOAD’ -----------
‘DAT’
IT_CUS. ----------
----------
CALL FUNCTION ‘BDC_OPEN_GROUP’ -----------
GROUP = ‘SPMT’
KEEP = ‘X’
USER = SY-UNAME
LOOP AT IT_VEN INTO WA_VEN.
------------
------------ Collect the screen and field details of vendor
------------
CALL FUNCTION ‘BDC_INSERT’
‘XK01’
IT_BDCDATA.
REFRESH IT_BDCDATA.
ENDLOOP.
LOOP AT IT_CUS INTO WA_CUS.
------------
------------ Collect the screen and field details of vendor
------------
CALL FUNCTION ‘BDC_INSERT’
‘XD01’
IT_BDCDATA.
REFRESH IT_BDCDATA.
ENDLOOP.
Page No : 202
CALL FUNCTION ‘BDC_CLOSE_GROUP’.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
TYPES: BEGIN OF TY_VEN,
LIFNR TYPE LFA1-LIFNR,
NAME1 TYPE LFA1-NAME1,
SORTL TYPE LFA1-SORTL,
END OF TY_VEN.
DATA: WA_VEN TYPE TY_VEN,
IT_VEN TYPE TABLE OF TY_VEN.
START-OF-SELECTION.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_VEN.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_CUS.
Page No : 203
'=UPDA'.
perform bdc_field using 'LFA1-NAME1'
WA_VEN-NAME1.
perform bdc_field using 'LFA1-SORTL'
WA_VEN-SORTL.
perform bdc_field using 'LFA1-LAND1'
'KW'.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'XK01'
TABLES
DYNPROTAB = BDCDATA.
REFRESH BDCDATA.
ENDLOOP.
Page No : 204
ENDFORM.
Develop a conversion program to upload the bank details from flat file to SAP system by using
BDC call transaction method through FI01 transaction. The flat file contains Bank country key,
bank key & bank name.
Steps to do the recording: -
Execute SHDB. Click on new recording in the application tool bar. Provide recording name (ZSFI01),
transaction code (FI01). Click on start recording. Provide bank country key, bank key. Enter. Provide the
bank name. Save. Save the recording.
Steps to develop the program from recording: -
Execute SHDB. Select the recording name. click on program in the application tool bar. Provide the
program name (ZSPR_930AM_BDC5). Select the radio button transfer from recording. Enter. Provide
title. Select the status, application. Click on source code. Save in our own package.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
TYPES: BEGIN OF TY_BANK,
BANKS TYPE BNKA-BANKS,
BANKL TYPE BNKA-BANKL,
BANKA TYPE BNKA-BANKA,
END OF TY_BANK.
DATA: WA_BANK TYPE TY_BANK,
IT_BANK TYPE TABLE OF TY_BANK.
START-OF-SELECTION.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_BANK.
Develop a conversion program to upload the vendor city from flat file to SAP system by using
BDC call transaction method through XK02 transaction. The flat file contains vendor numbers and
city.
Steps to do the recording: -
Execute SHDB. Click on new recording in the application tool bar. Provide the recording name,
transaction code (XK02). Enter. Provide existing vendor number (V1011). Select the address checkbox.
Enter. Provide the city. Save.
Note: - When ever we are working with update transaction then we must remove the other than flat file
fields recording steps from recording by using minus (-) symbol in the application tool bar.
start-of-selection.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_VC.
start-of-selection.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_VEN.
Page No : 208
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFA1-NAME1'
WA_VEN-NAME1.
perform bdc_field using 'LFA1-SORTL'
WA_VEN-SORTL.
perform bdc_field using 'LFA1-LAND1'
'IN'.
CALL TRANSACTION 'XK01' USING BDCDATA MODE 'N' MESSAGES INTO
IT_BMC.
IF SY-SUBRC <> 0.
LOOP AT IT_BMC INTO WA_BMC.
Page No : 209
Handling the errors through session method: -
Call function ‘BDC_OPEN_GROUP’
GROUP = ‘HE’
KEEP = ‘X’
USER = SY-UNAME.
LOOP AT IT_VEN INTO WA_VEN.
---
---
Call transaction ‘XK01’ using IT_BDCDATA mode ‘N’.
If SY-SUBRC < > 0.
CALL FUNCTION ‘BDC_INSERT’
‘XK01’
IT_BDCDATA.
ENDIF.
REFRESH IT_BDCDATA.
ENDLOOP.
CALL FUNCTION ‘BDC_CLOSE_GROUP’.
After, we execute the program, we process the session ‘HE’ through ‘SM35’ in background & observe the
error log.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
TYPES: BEGIN OF TY_VEN,
LIFNR TYPE LFA1-LIFNR,
KTOKK TYPE LFA1-KTOKK,
NAME1 TYPE LFA1-NAME1,
SORTL TYPE LFA1-SORTL,
Page No : 210
END OF TY_VEN.
DATA: WA_VEN TYPE TY_VEN,
IT_VEN TYPE TABLE OF TY_VEN.
start-of-selection.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_VEN.
Page No : 211
Session over view (SM35): -
Analysis: -
This is used to identify the number of transactions are available in the session and their status and also this
is used to identify the screens & fields information.
Process: -
This is used to process the session either in foreground or background or error mode.
Statistics: -
This is used to identify the quick information of the session. I.e. how many transactions are successfully
processed how many are deleted. How many are still to be process.
Log: -
This is used to identify the each & every step of entire session processing.
Recording:-
This is used to cal the SHDB transaction code.
Delete: -
This is used to delete the sessions from the session overview.
Lock: -
This is used to lock the session until a particular date.
Unlock: -
This is used to unlock the session which is already locked.
Syntax of concatenate: -
Concatenate <variable1> <variable2> ---- into <variable3> separated by ‘<delimiter>’.
Ex: -
Data A(10) type C value 'SPRAO'.
Data B(20) type C value 'TECH'.
Data C(30) type C.
Concatenate A B into C separated by ' '.
Write C.
O/P SPRAO TECH
Ex: -
Syntax of Split: -
Split <variable1> at ‘<delimiter>’ into <variable1> <variable2> - - - - - -
Ex: -
Data A(30) type C value 'SPRAO TECH'.
Data B(10) type C.
Data C(20) type C.
Split A at ' ' into B C.
Page No : 212
Write:/ B, C.
O/P SPRAO TECH
Ex: -
Based on the given vendor numbers, display the vendor numbers, vendor names & cities as
shown in the below. If the user clicks on update button then we update the vendor cities of selected
checkbox by using BDC call transaction method through ‘XK02’ transaction method.
Page No : 214
VERAK type CSKS-VERAK,
End of ty_cost.
Data: wa_cost type ty_cost,
It_cost type table of ty_cost.
Start-of-selection.
Call function ‘UPLOAD’
Exporting
FILETYPE = ‘DAT’
Tables
DATA_TAB = IT_COST.
Loop at it_cost into wa_cost.
==========================
Perform bdc_field using ‘CSKSZ-KOKRS’ WA_COST-KOKRS.
Perform bdc_field using ‘CSKSZ-KOSTL’ WA_COST-KOSTL.
Perform bdc_field using ‘CSXSZ-DATAB_ANFO’ WA_COS-VFD.
Perform bdc_field using ‘CSKSZ-DATB1_ANFO’ WA_COST-VTD.
==========================
Perform bdc_field using ‘CSKSZ-KTEXT’ WA_COST-KTEXT.
Perform bdc_field using ‘CSKSZ-VERAK’ WA_COST-VERAK.
==========================
Call transaction ‘KS01’ using BDCDATA mode ‘A’.
Refresh BDCDATA.
Endloop.
Form BDC-DYNPRO using program DYNPRO.
==========================
Endform.
Form BDC_FIELD using FNAM FVAL.
==========================
Endform.
DATA V1.
TYPES: BEGIN OF TY_VEN,
LIFNR TYPE LFA1-LIFNR,
NAME1 TYPE LFA1-NAME1,
SORTL TYPE LFA1-SORTL,
Page No : 215
END OF TY_VEN.
DATA: WA_VEN TYPE TY_VEN,
IT_VEN TYPE TABLE OF TY_VEN.
ULINE.
Page No : 216
BDC table control:-
When ever we upload the multiple records in a tabular format for a single transaction then it’s called bdc
table control.
When ever we upload the vendor bank details, customer bank details then we go for bdc table
control. Because one vendor having any number of bank details in a tabular format & customer also
having any number of bank details in a tabular format.
Vendor bank screen: -
Develop a conversion program to upload the vendor bank details from flat file to sap system by
using BDC call transaction method through XK01 transaction. Flat file contains vendor & vendor
bank details with separation at V and B. the vendor details are vendor number, name & search
terms. The bank details are vendor number, bank country key, bank key & account number.
Steps to do the recording: -
Execute SHDB. Click on new recording in the application tool bar. Provide recording name
(SXK01), transaction code (XK01). Enter. Provide vendor number (H9080), account group (0004). Enter.
Provide the name (power grid). Search term (pg), country (IN). Enter. Third screen we no need to provide
information. Enter. In 4th screen provide the details.
Page No : 217
Click on Save.
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA V2 TYPE N.
DATA V_FNAM(20) TYPE C.
DATA V1.
TYPES: BEGIN OF TY_VEN,
LIFNR TYPE LFA1-LIFNR,
NAME1 TYPE LFA1-NAME1,
SORTL TYPE LFA1-SORTL,
END OF TY_VEN.
DATA: WA_VEN TYPE TY_VEN,
IT_VEN TYPE TABLE OF TY_VEN.
START-OF-SELECTION.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT.
LOOP AT IT INTO WA.
IF WA-ROW+0(1) = 'V'.
SPLIT WA-ROW AT ',' INTO V1 WA_VEN-LIFNR WA_VEN-NAME1 WA_VEN-
SORTL.
APPEND WA_VEN TO IT_VEN.
CLEAR WA_VEN.
ELSE.
SPLIT WA-ROW AT ',' INTO V1 WA_BANK-LIFNR WA_BANK-BANKS WA_BANK-
BANKL WA_BANK-BANKN.
APPEND WA_BANK TO IT_BANK.
CLEAR WA_BANK.
ENDIF.
ENDLOOP.
* First screen
LOOP AT IT_VEN INTO WA_VEN.
perform bdc_dynpro using 'SAPMF02K' '0100'.
Page No : 218
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-LIFNR'
WA_VEN-LIFNR.
perform bdc_field using 'RF02K-KTOKK'
'0004'.
* SECOND SCREEN
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-LAND1'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'LFA1-NAME1'
WA_VEN-NAME1.
perform bdc_field using 'LFA1-SORTL'
WA_VEN-SORTL.
perform bdc_field using 'LFA1-LAND1'
'IN'.
*THIRD SCREEN
perform bdc_dynpro using 'SAPMF02K' '0120'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-KUNNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
* FOURTH SCREEN
perform bdc_dynpro using 'SAPMF02K' '0130'.
perform bdc_field using 'BDC_CURSOR'
'LFBK-BANKN(02)'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
LOOP AT IT_BANK INTO WA_BANK WHERE LIFNR = WA_VEN-LIFNR.
V2 = V2 + 1.
CONCATENATE 'LFBK-BANKS(' V2 ')' INTO V_FNAM.
Page No : 219
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM.
Over view:
Data v2(2) type N.
Data v_fnam(20) type c.
Loop at it_ven into wa_ven.
-----
- - - - - 1st screen & field details
-----
-----
- - - - - 2nd screen & field details
-----
-----
- - - - - 3rd screen & field details
-----
-----
- - - - - 4th screen, OK_CODE & CURSOR details
-----
Loop at it_bank into wa_bank where lifnr = wa_ven-lifnr.
V2 = V2 + 1.
Concatenate ‘LFBK-BANKS(‘ V2 ‘)’ into V_FNAM WA_BANK-BANKS.
Concatenate ‘LFBK-BANKL(‘ V2 ‘)’ into V_FNAM WA_BANK-BANKL.
Concatenate ‘LFBK-BANKN(‘ V2 ‘)’ into V_FNAM WA_BANK-BANKN.
Endloop.
Clear V2.
V_FNAM
Call transaction ‘XK01’ using BDCDATA mode ‘A’.
Refresh BDCDATA. LFBK-BANKN(01)
Endloop.
Develop a conversion program to upload the customer bank details flat file to SAP system by
using ‘XD01’ transaction code. The flat file contains both customer & bank details with separation
Page No : 220
of C & B. In the flat file customer details are customer numbers, names, search term, street. In the
flat file bank details are customer numbers, bank country key, bank key & account number.
Execute SHDB. Click on new recording. Provide recording name (SXD01_TBC), transaction code
(XD01). Enter. Provide the customer number (65432), account group (0004). Enter. Provide the name
(Coal India), search term (CI), street (Ameerpet), country (IN), language (EN). Enter. Third screen we no
need to provide any details. Enter. 4th screen we no need to enter any details. Enter. Provide the bank
details.
Endloop.
Clear V2.
Call transaction ‘XD01’ using BDCDATA mode ‘A’.
Refresh BDCDATA. C,65432,GMR,G,SR NAGAR
Endloop. C,65433,GVK,GV,BG
B,65432,IN,12121,1919191919
B,65433,IN,121212,2525151515
B,65433,IN,121213,1515152525
Page No : 221
Note: - At the time of session processing through SM35 the following commands are used.
‘/n’ – It skips the current transaction from session processing.
/BEND: - It skips the entire session processing.
/BDEL: - It deletes the current transaction from the session processing.
Note: - When ever we run the any conversion program in background then we must maintain the file in
the application server directly (SAP directory AL11).
Call transaction ‘<TCODE>’ using <BDCDATA internal table> mode ‘A/N/E’ messages into
<BDCMSGCOLL internal table> update ‘A/S’.
Page No : 222
UPLOAD: -
Upload is the function module which is used to browse the file as well as upload the data from file to
internal table. The input for the above function module is
1. File type ‘DAT’
2. Data internal table which is similar as file.
GUI_UPLOAD: - It’s the function module which is used to upload the data from file to internal table.
The input for the above function module is
1. File name with extension.
2. Field separator = ‘X’.
3. Data internal table which is similar as file
Include ziit001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\Users\Administrator\Desktop\DARLING.TXT'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_T001.
Note: - Now a day ‘upload’ function module is obsolete. So we use ‘GUI_UPLOAD’ function module.
For the ‘GUI_UPLOAD’ function module file name is fixed. This isn’t allowed by client people and
functional people.
Instead of UPLOAD function module we use F4_FILENAME & GUI_UPLOAD function module.
F4_FILENAME is the function module which is used to browse the file and GUI_UPLOAD function
module is used to upload the data from file to internal table. The output for the F4_FILENAME is file
path or file name.
DATA V_FILE TYPE STRING.
INCLUDE ZIIT001.
PARAMETER P_FILE LIKE IBIPPARMS-PATH.
Page No : 223
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
START-OF-SELECTION.
V_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = V_FILE
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_T001.
LOOP AT IT_T001 INTO WA_T001.
WRITE:/ WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
ENDLOOP.
Download: - Download is the function module which is used to browse the file as well as download the
data from internal table to file. The input for the above function module is
1. File type ‘DAT’
2. Data internal table
TABLES T001.
SELECT-OPTIONS S_BUKRS FOR T001-BUKRS.
INCLUDE ZIIT001.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001 WHERE BUKRS IN
S_BUKRS.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILETYPE = 'DAT'
TABLES
DATA_TAB = IT_T001.
GUI_DOWNLOAD: - It’s the function module which is used to download the data from internal table to
file. The input for the above function module is
1. File name with extension.
2. Field separation
3. Data internal table which data we want to download
TABLES T001.
SELECT-OPTIONS S_BUKRS FOR T001-BUKRS.
INCLUDE ZIIT001.
SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001 WHERE BUKRS IN
S_BUKRS.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\Users\Administrator\Desktop\T002.TXT'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_T001.
Page No : 224
Note: - Now a day ‘DOWNLOAD’ function module is absolute. Se we use ‘GUI_DOWNLOAD’
function module. In the ‘GUI_DOWNLOAD’ function module the file name is fixed. This isn’t allowed
by functional people.
Instead of ‘DOWNLOAD’ we use ‘F4_FILENAME’ function module with ‘GUI_DOWNLOAD’
function module.
INCLUDE ZIIT001.
PARAMETER P_FILE TYPE IBIPPARMS-PATH.
DATA V_FILE TYPE STRING.
Page No : 225
WRITE:/ WA-ROW, WA-COL, WA-VALUE.
ENDLOOP.
ULINE.
LOOP AT IT INTO WA.
IF WA-COL = '0001'.
WA_T001-BUKRS = WA-VALUE.
ELSEIF WA-COL = '0002'.
WA_T001-BUTXT = WA-VALUE.
ELSEIF WA-COL = '0003'.
WA_T001-ORT01 = WA-VALUE.
ENDIF.
AT END OF ROW.
APPEND WA_T001 TO IT_T001.
ENDAT.
ENDLOOP.
LOOP AT IT_T001 INTO WA_T001.
WRITE:/ WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
ENDLOOP.
Application Server: -
Application server is the SAP directory. The transaction code for application server is AL11. In the
application server each file is called one data seg.
In the application server we can’t create the file directly through program only we can create.
Note: - .Directory is the [.(DIR_TEMP)] is the default directory in the application server.
INCLUDE ZIIT001.
OPEN DATASET 'SPT' IN TEXT MODE FOR INPUT ENCODING DEFAULT.
DO.
READ DATASET 'SPT' INTO WA_T001.
IF SY-SUBRC = 0.
APPEND WA_T001 TO IT_T001.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET 'SPT'.
* Display the output.
LOOP AT IT_T001 INTO WA_T001.
WRITE:/ WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
ENDLOOP.
Note: - When ever we develop the conversion program to schedule in background then file must be in
the application server.
In this case we need to develop one more separate program to upload the data from presentation
server & download into application server. In the conversion program instead of GUI upload we upload
the data from application server by using open data set and read dataset.
Interview questions on BDC: -
1. Why we go for BDC.
2. What are steps to work with BDC programming?
3. What are differences between DML commands & BDC?
4. What are differences between call transaction method & session method?
5. When we choose call transaction method.
6. When we choose Session method.
7. What are the types of update modes? (Synchronous & Asynchronous)
8. How we handle the errors in call transaction method
9. What are the function modules we used in session method?
10. How to process the session (SM35)
11. How we run the session in background (RSBDCSUB standard program).
12. How to do the recording (SHDB)
13. What is the last entry at screen? (BDC-OK_CODE)
14. What are the fields in BDC data structure / dynpro components?
15. What is the use ‘/N, ‘/BEND’, ‘/BDEL’.
16. How we hold/lock the session until particular date.
17. Can we process multiple transactions at a time? (By using session)
18. When we maintain the file in application server.
19. What is transaction code for application server? (AL11)
20. What are components of BDCMSCOLL structure & what is the use (it hold the
Page No : 227
Success / failure information).
21. Can we use call transaction method & session method in the same program (yes)
22. What is the use of FORMAT_MESSAGE function module (handle the errors)
Note: - TEXT_CONVERT_XLS_TO_SAP is the FM to upload the data from excel sheet to SAP
system. Here we use one type that is TRUX_T_TEXT_DATA.
Page No : 228
CROSS APPLICATIONS
Cross application is the concept to exchange the data among the systems.
ALE is (Application Link Enabling) is an SAP technology to support cross application.
ALE uses IDOC to support the cross applications.
IDOC is the carrier to carry the data from one system to another system.
SAP can understand only the IDOC format, when it communicates with any other system.
Distributing the data: -
Irrespective of the receivers, the ABAPER job in sender system is to generate the Idoc.
The process of generating the Idoc is nothing but out bound process.
Irrespective of the senders, the abaper job in receiver system is to collect the data from Idoc.
The process of collecting the data from Idoc is nothing but in bound process.
Runtime components of Idoc: -
1. It generates a unique Idoc number, which is 16 digit.
2. It generates 3 types of records.
i. Control records
ii. Data records
iii. Status records
1. Control record : -
i. Control record specifies the sender as well as receiver information.
ii. It generates only one control record.
iii. This information will be saved on EDIDC table
2. Data records: -
i. It specify the data which is send by the senders system.
ii. It generates any number of data records.
iii. This information will be saved on EDIDD table.
3. Status records: -
i. It generates status codes for each and every stage of transferring the data.
ii. It generates any number of status records.
iii. This information will be saved on EDIDS table.
Page No : 229
Note: - The linking between EDIC, EDIDD and EDIDS is the IDOC number.
Custom Idoc –
If you want to send as well as receives the custom table information then we go for custom idoc.
Zhai
EID
ENAME
ESAL
Extension Idoc –
If you want to send as well as receives the additional fields information of standard data base table along
with standard fields information then we go for extension Idoc.
LFA1
LIFNR
NAME1
ORT01
||
+
ZHAI
EID
ENAME
ESAL
Page No : 230
Note: - IDOC is the collection of segments. Each segment is the collection of fields.
Characteristics of an IDOC: -
1. Name of the IDOC.
2. List of the segment
3. Hierarchy of the segments in the IDOC.
4. Optional (vs) mandatory for the segments
5. Provide parent & child relationship of the segments.
6. Each segment can carry up to 1000 bytes.
7. Provide the minimum and maximum number of repeations for the segment.
Communication between one system to another system is nothing but communication between one client
of sender system to another client of receiving system. Each participated system is called one logical
system.
Steps to establish the communication settings: -
1. Define logical system (SALE)
2. Assign client to logical system (SCC4)
3. Maintain RFC destination details (SM59)
Note: - In the real time communication settings are established by BASIS people.
If the receiver is available in following address & he wants vendor H7070 details.
Client : 810
User : SAPUSER
Password : india123
Logical system: SP810.
In this before sending the vendor details first we need to establish the communication settings from sender
to receiver system.
Steps to define logical system: -
Execute SALE. Expand basic settings. Expand logical systems. Execute define logical system. Enter.
Click on new entries in the application tool bar. Provide sender, receiver logical system name & short
description. Save.
SP800 Sender logical system
SP810 Receiver logical system
Steps to assign client to logical system: -
Execute ‘SCC4’. Click on change mode. Select the client. Click on details. Provide the logical system
name SP800. Click on save.
Page No : 231
Steps to maintain RFC destination details: -
Execute ‘SM59’. Select the ABAP connections. Click on create. Provide RFC destination (SP810).
Provide short description (Sender to receiver). Click on logon & security tab. Provide the receive log on
details.
Client : 810
User : SAPUSER
PW Status : is initial
Password : india123.
Click on save. Click on connection test. Click on back. Click on remote logon in the application
tool bar.
Note: - The table is cross-client. It means what ever the changes are made in one client those are
automatically reflected into all other clients in same server.
Outbound process: -
Based on the given input one outbound program will triggered & fetch the application data from
the data base & generate the master IDOC.
Master IDOC is nothing but data in internal table. Master IDOC won’t save anywhere in SAP.
ALE service layer reads the distribution model & identifies the interested receivers. Based on the
receivers it generates the communication IDOC.
Distribution model is the collection of senders, receivers, message type.
Message type is used to identify the type of the application (vendor, customer, material, . . .).
Communication IDOC is the physical IDOC which is receiver specific.
ALE communication layer dispatch these communication IDOC to their relevant receiver systems.
Page No : 232
Note: - If you get the zero master IDOCs, the reason is the given input having no data in the data base.
Note: - If you get the zero communication IDOCs the reasons are
1. There is no interested receivers are available in distribution model.
2. Communication settings problem.
Page No : 233
Steps to create the port number: -
Execute ‘WE21’. Select the transactional RFC. Click on create (F7). Enter. The system automatically
generates a port number (A000075). Provide short description (port number). Provide RFC destination
(SP810). Click on save.
Note: - After we get the status code 03, we execute ‘RBDMOIND’ standard program. If the status code
03 turn to 12 then the IDOC is successfully reached to destination. If the status code remains 03, then the
IDOC is in the TRFC queue. If the status code turns to 11, then the IDOC is damaged in the queue.
Inbound process: -
Note: - Outbound program can be developed either through executable program or through function
module where as inbound program must be developed through functional module only because the
interface parameters are same for any message type (import, export, changing, - - -).
Page No : 234
At the first time, before creating the inbound partner profile we do following things.
1. Define logical systems (this isn’t required, if we are working with the same server).
2. Assign client to logical system.
Note: - Process code is used to identify the function module.
In the receiver system 810 client: -
Steps to assign client to logical system: -
Execute SCC4. Click on change mode. Enter. Select the client (810). Click on details. Provide
logical system (SP810). Save.
Note: - At the time of creating the outbound partner profile if we select the mode of dispatch is collect
then we must execute ‘RSEOUT00’ standard program then only the collect idocs will be dispatched to
their relevant receiver system.
Note: - At the time of creating the inbound partner profile if you select the mode of posting is trigger by
background (collect) then we must execute ‘RBDAPP01’ standard program. Then only the collect idocs
will be posted to their relevant data base table.
Page No : 235
Types of distributing the data: -
1. Send entire information
2. Send changes only (change pointer technique)
3. Get entire information
Change pointer technique: -
Change pointer technique is used to send the changes of master data from sender to receiver system.
Process flow of change pointer technique: -
Page No : 236
When ever the changes occurred in the master data the standard SAP itself prepare one change document.
ALE service layer invokes the SMD (Shared Master Data) SMD reads the distribution model & identifies
the interested receivers. If any receiver is available then it generates the change pointers for the change
document. These change pointers are available in ‘BDCP’ table. The change pointer technique reads the
change pointers & generates as well as dispatch the idoc to the receiver system.
ALE configuration steps for change pointer technique: -
1. ALE Configuration steps for Idoc outbound.
Create distribution model (BD64) Create outbound partner profile (WE20)
2. Activate the change pointer technique (BD61)
3. Activate the message type (BD50)
4. Generate as well as dispatch the IDOC (BD21)
Configure the ALE to send the changes of vendor master data from sender to receiver system
Steps to activate change pointer technique: -
Execute BD61. Select the change box change points activated. Click on save.
Steps to activate message type: -
Execute ‘BD50’. Click on position. Provide the message type (CREMAS). Enter. Select the
activate checkbox (CREMAS, CREMAS_SUSMM). Click on save.
Steps to change the vendor: -
Execute ‘XK02’. Provide vendor number (H7071). Select the address check box. Enter. Provide the title
(Company) change search to BIG instead of ‘B’. Click on save.
Steps to generate as well as dispatch for IDOC for change pointers: -
Execute ‘BD21’. Provide the message type (CREMAS). Execute.
Check the idoc in WE02 / WE05.
Note: - Change pointer technique always at senders system only for master data.
Steps to identify the old & new changes of any document: -
Execute SE11. Open the table CDHDR in display mode. Click on contents. Provide the object ID
as your document number (H7071). Execute. Identify the object class & changes.
Open the CDPOS table in SE11. Click on contents. Provide the object class (KRED) object ID (H7071)
changenr (592227). Execute & identify the old & new values of the document.
Some of the standard requesting message type: -
Application Message type Requesting Message type
VENDOR CREMAS CREFET
CUSTOMER DEBMAS DEBFET
MATERIAL MATMAS MATFET
Note: - ‘ALEREQ01’ is the IDOC type for any requesting message type.
Note: - ‘EDIMSG’ is the standard data base table which contains all the message types, IDOC types
and requesting message types.
Note: - Before configure the get entire information we must establish the communication settings from
receiver to sender.
Note: - In the receiver requested data isn’t available. Then we get the status 51. (No object for requested
Idoc selected for sending).
Note: - The name of the standard segment start with ‘E’. The name of the custom segment starts with
‘Z1’. The definition name of the standard segment starts with ‘EZ’. The definition of custom segment
starts with ‘Z2’.
Note: - The segment definition is useful when we communicate with non-SAP system. Based on the
segment definition only the middleware converters convert the sender’s format to receiver’s format.
Page No : 239
Filtering technique: -
Filtering techniques are used to generate the idoc based on the conditions. Filtering techniques
are always at sender system.
There are 3 types of filtering techniques.
Idoc filtering: -
Idoc filtering is used to drop the idoc at run time. Idoc filtering conditions are placed or
maintained in distribution model.
Before generating the communication idocs ALE service layer reads the distribution model & identifies
the interested receivers. If any receiver is available then it checks the given input satisfies the filtering
conditions or not. If it satisfies the filtering condition then only it generates the communication idoc. Other
wise it won’t generate any communication idoc.
Configure the ALE to send only semi finished products to the receiver system
In this object we provide the idoc filtering conditions in the distribution model.
Steps to create distribution model: -
Execute ‘BD64’. Click on change mode. Click on create model view in the application tool bar.
Provide the short description & technical name (DBMATMAS). Enter. Select the distribution model
which is in last. Click on add message type. Provide sender, receiver, and message type (MATMAS).
Enter. Expand the distribution model until ‘No filter set’. Double click on it. Click on create filter group in
the bottom. Expand the data filtering. Expand the filter group. Double click on our requirement (material
type). Click on insert row button (+). Select the value (HALB). Enter. Click on ok. Save the distribution.
Create outbound partner profile WE20.
Steps to send the material: -
Execute ‘BD10’. Provide the material number (100-110), message type (MATMAS), logical system
(SA810). Execute. Here 100 – 110 is a raw material. So it won’t generate any communication idoc.
Segment filtering: -
It’s used to drop the segments permanently to the particular receiver system. The transaction code for
segment filtering is ‘BD56’.
Note: - ‘WE30’ is the transaction code to create as well as display the idoc.
Page No : 240
Note: - ‘WE31’ is the transaction code to create as well as display the segment.
Note: - When ever we are working with segment filtering then we must create dummy partner profile
for sender system itself.
Configure the segment filtering to drop the ‘E1LFA1A’ segment information permanently to the
SP810 receiver.
Reduced Idoc: -
Reduced idoc is used to drop the segments as well as fields permanently to the particular receiver
system. We can’t drop the mandatory segments as well as mandatory fields which are in green colour. The
transaction code for reduced idoc is ‘BD53’.
In the reduced idoc we create the new message type based on the existing message type. Based on
the new message type we configure the ALE. (Create distribution model, outbound partner profile).
Steps to work with reduced idoc: -
Execute BD53. Provide the reduced message type (DEBMAS). Click on create. Provide the
reference message type (DEBMAS). Enter. Provide short description (Reduced message of customer).
Select the required segments by placing the cursor on the segment. Click on select button in the
application tool bar. Double click on the segment. Select the required fields. Click on select. Enter. Repeat
the same steps for all other segments. Click on save. Based on this new message type (ZSDEBMAS) we
create the distribution model & outbound partner profile.
Against vendor supplies the where house department create a GR [Goods Receipt] with ‘MIGO’
transaction with 101 moment type. Against GR the Finance people physically verify the stock & prepare
the invoice receipt (IR). Against IR document the account payable department pay the amount to the
vendor with deducts of TDS amount. After few days the vendor asks the form 16 to the tax department of
the company. When ever the tax department or Finance department generate the form 16 then need to
enter the LR number. Vehicle number, transporter name etc. This information is not captured in the entire
MM life cycle. Here design one screen with those fields & attached to ‘MIGO’ transaction by using
‘BADI’. When ever the where house people create the GR then they also maintain these additional screen
Page No : 241
information. These information stored in separated ‘Ztable’. If you want to send or receive this ‘Ztable’
information then we go for custom idoc.
Each batch has their own characteristics (Classification) that information is maintained in separate
‘ZTABLE’. If you want to send as well as receive that ‘ZTABLE’ information then we go for
custom idoc.
If you want to open the batch classification details then execute ‘MSC3N’. Provide the material,
plant & batch. Click on enter. Click on classification tab. Identify the classification details.
‘MCHA’ is the standard data base table which contains material batch details.
Configure the ALE to send as well as receives the GR additional information which is
stored in the following table.
Page No : 242
ALE Configuration steps for custom idoc
outbound: -
1. Create the segments (WE31).
2. Create the IDOC (WE30).
3. Create the Message type (WE81)
4. Link the message type to idoc type (WE82).
5. Create the port number (WE21).
6. Create the outbound partner profile (WE20)
7. Distribution model isn’t required if we pass
control record information in the program (Sender,
Receiver, Message type - - -).
Save the segment. Repeat the steps for all the segments.
Step 2: -
Generate the master IDOC is nothing but fill an internal table which contains two fields.
Note: - In the data dictionary we have one structure or a table I.e. EDIDD which contains the above
fields. So we simply declare our internal table by referring EDIDD structure or table.
Note: - When ever we are working with custom idoc then we must declare 3 internal tables. One is for
data. One is for control & one is for communication & also need to declare one work area & internal table
for each segment in the idoc.
Procedure to fill master idoc: -
Based on the given input we’ll fetch the data from data base & fill the each segment internal table. Loop
the each segment internal data. Fill the master idoc.
Page No : 244
IT_DATA like table of WA_DATA.
Data: WA_SEG1 like Z1SGRS1,
IT_SEG1 like table of WA_SEG1.
Select GRNO GRYEAR LRNO VNO TNAME from ZS930GR into table IT_SEG1 where GRNO in
S_GRNO.
Loop at IT_SEG1 into WA_SEG1.
WA_DATA-SEGNAM = ‘Z1SGRS1’.
WA_DATA-SDATA = WA_SEG1.
Append WA_DATA to IT_DATA.
Clear WA_DATA.
Endloop.
Step 3: -
Collect the control record information is nothing but fill an internal table which contains following fields.
SNDPRT Sender Partner Type
SNDPRN Sender Partner Number
RCVPRT Receiver Partner Type
RCVPRN Receiver Partner Number
RCVPOR Receiver Port Number
DOCTYP IDOC Number
MESTYP Message type
In the dictionary we have one structure or a table that is EDIDC which contains above fields. So we
simply declare our internal table by referring EDIDC structure.
Data: WA_CONT like EDIDC,
IT_CONT like table of WA_CONT.
WA_CONT-SNDPRT = ‘LS’.
WA_CONT-SNDPRN = ‘SP800’.
WA_CONT-RCVPRT = ‘LS’.
WA_CONT-RCVPRN = ‘SP810’.
WA_CONT-RCVPOR = ‘S930GRP’.
WA_CONT-DOCTYP = ‘ZS930GRI.
Page No : 245
WA_CONT-MESTYP = ‘S930GRMAS’.
Append WA_CONT to IT_CONT.
Repeat the same steps for all the receivers.
Step 4: -
For each receiver in the control record internal table we need to generate as well as dispatch the
communication idoc.
Page No : 246
9. Link the process code to function module (WE42).
10. Create inbound partner profile (WE20).
Page No : 247
Against the process code it triggers the ZS930_IDOC_INPUT_GRTOR function module & stores the
sender sending information in idoc data internal table. Here our business logic is read the segments & their
information from IDOC_DATA internal table & posted to their respective data base tables.
Function module: ZS930_DOC_INPUT_GRTOR.
Data: wa_data like line of idoc_data,
Wa_reseg1 like z1sgrs1,
Wa like zs930gr,
Wa_stat like line of idoc_status.
Loop at idoc_data into wa_data.
If wa_data-segnam = ‘Z1SGRS1’.
Wa_rseg1 = wa_data-sdata.
Move-corresponding wa_rseg1 to wa.
Insert zs930gr from wa.
If sy-subrc = 0.
Wa_stat-docnum = wa_data-docnum.
Wa_stat-status = ‘53’.
Append wa_stat to idoc_status.
Else.
Wa_stat-docnum = wa_data-docnum.
Wa_stat-status = ‘51’.
Append wa_stat to idoc_status.
Endif.
Endif.
Endloop.
Page No : 248
Steps to test the inbound program by using inbound test tool: -
Execute ‘WE19’. Select the radio button via message type. Provide message type (S930GRMAS). Click
on execute. Double click on the segment. Provide the sample data (300001, 2014, LR98765, AP04 4304,
SANDEEP). Enter. Click on inbound function module in the application tool bar. Select the check box call
in debugging mode. Select the radio button in four ground. Enter. In the menu bar click on debugging
classic debugger. Continuously click on F5 button, absorb the process flow.
In sender system 800 client
Steps to send or generate IDOC through test transaction: -
Execute WE19, select the Radio button via message type. Provide the message type. Execute. Double
click on the segment provide sample data. (60000, 2015, LR2222, AP20222, PAVAN). Enter. In the menu
bar click on edit control record. Provide receiver port (S930GRP), partner number (SP810), port type
(LS), sender partner number (SP800), partner type (LS). Enter. In the menu bar click on IDOC test
outbound idoc. Enter.
Configure the ALE to send as well as receives the employee training details as shown in the
below.
Page No : 249
WA_CONT-SNDPRT = ‘LS’.
WA_CONT-SNDPRN = ‘SP800’.
WA_CONT-RCVPRT = ‘LS’.
WA_CONT-RCVPRN = ‘SP810’.
WA_CONT-RCVPOR = ‘ETPORT’.
WA_CONT-DOCTYP = ‘ZETI.
WA_CONT-MESTYP = P_MESTYPE.
Append WA_CONT to IT_CONT.
Page No : 250
If SY-SUBRC = 0.
WA_STAT-DOCNUM = WA_DATA-DOCNUM.
WA_STAT-STATUS = ‘53’.
Append WA_STAT to IDOC_STATUS.
Else.
WA_STAT-DOCNUM = WA_DATA-DOCNUM.
WA_STAT-STATUS = ‘51’.
Append WA_STAT to IDOC_STATUS.
Endif.
Endif.
Endloop.
Extension idoc: -
It’s the collection of standard idoc + custom segment. As per client requirement if we add the CST number
(Central Sales Tax), LST Number (Local Sales Tax), PAN Number to the LFA1table through append
structure. If you want to send as well as receives the custom fields information along with standard field
information then we go for extension IDOC.
Page No : 251
4. Create the port number (WE21)
5. Create the outbound partner profile (WE20)
6. Create the distribution model (BD64)
Before configure the ALE the following fields are added to LFA1 table through append structure.
Field Data element Data type Length
CSTNO ZSPCSTNO CHAR 10
LSTNO ZSPLSTNO CHAR 10
PANNO ZSPPANNO CHAR 10
Steps to create additional segments: -
Execute ‘WE31’. Provide the segment name (Z1930VS1). Click on create. Provide short description.
Provide the field names as well as data elements.
1 CSTNO ZSPCSTNO
2 LSTNO ZSPLSTNO
3 PANNO ZSPPANNO
Save, repeat the same steps for all segments.
Steps to create extension idoc: -
Execute ‘WE30’. Provide the extension idoc name (Z930EI). Select the radio button extension. Click on
create. Provide the linked basic type (CREMAS05). Provide short description (Vendor extension idoc).
Enter. Select the any one of the segment (E1LFA1M) (Reference segment), click on create segment.
Enter. Provide the segment type (Z1930VS1). Provide minimum (1), maximum (99). Enter. Save.
Steps to link the message type to extension idoc: -
Execute WE82. Click on change mode. Enter. Click on new entries in the application tool bar. Provide the
message type (CREMAS), basic type (CREMAS05), extension (Z930EI), release (700). Click on save.
Create the port number.
Steps to create outbound partner profile:-
Execute WE20. Select the partner if the message type is already available then select message type. Click
on detail. Provide the extension. Click on save.
If the message type isn’t available then click on create outbound parameter. Provide the message type
(CREMAS), port number (A000075). Select the radio button transfer idoc immediate. Provide the basic
type (CREMAS05), extension (Z930EI). Save.
Create distribution model.
Note: - Developing a extension idoc outbound program is nothing but fill the additional segment
information only. The standard segments are filled by standard program.
Here we add the filling of additional segments information to the standard program BD14.
Adding some additional functionality to the standard functionality without disturbing the standard
functionality is always through enhancements.
Page No : 252
Enhancements
Enhancement is nothing but adding some additional functionality to the standard functionality without
disturbing the standard functionality.
USER EXIT: - User exits are used to adding some additional functionality to the standard functionality is
always through sub routines (form, end form).
These are implemented in the form of subroutines and hence are also known as FORM EXITs. The user
exits are generally collected in includes and attached to the standard program by the SAP. User Exits are
developed for the SD module. User-exits are empty subroutines that SAP Developers have provided for
you. You can fill them with your own source code. Technically this is a modification.
FORM USEREXIT_XXXX....
ENDFORM.
Program: MV45AFZB
Scenario 3: -
In the real time SD functional consultant provide the number ranges for sales order, delivery & billing
document. Based on the sales organization & company we split the number ranges into smaller ranges by
using user exit.
Program Name: MV45AFZZ
User Exit: USEREXIT_NUMBER_RANGE
Scenario 4: -
As per client requirement if we add some additional fields to standard SD tables if you want to assign
these fields values at the time of creating the sales documents then we use user exit.
Program Name: MV45AFZZ
User Exit: USEREXIT_MOVE_FIELD_TO_VBAK
Page No : 253
Scenario 5: -
In the real time at the time of creating the sales order some times the end user select the same tax
conditions more than once. To avoid this by using user exit.
Program Name: MV45AFZZ
User exit Name: USEREXIT_SAVE_DOCUMENT_PREPARE
Delete the sales order key information from the ‘Z’ table at the time of cancel the sales document
by using user exit.
Steps to implement the user exit: -
Execute SE38. Provide the program name MV45AZZ. Click on display. Click on find function key.
Provide the user exit name (USEREXIT_DELETE_DOCUMENT). Enter. Double click on form or user
exit. identify the place where we implement the logic. Click on enhance ( ) symbol in the application tool
bar. In the menu bar click on edit enhancement operations show implicit enhancement options. It’ll
provide yellow line for all the forms. Select our user exit yellow line. Right click enhancement
implementation create. Click on code. Click on create enhancement implementation. Provide the
implementation name (ZS10AM_UEI), short description (Delete sales document). Enter. Save in our own
package or local object. Select the implementation name. enter. Provide the logic.
Delete from ZS10AM_SKI where VBELN = VBAK-VBELN. Save, check, activate.
Split the sales order number ranges into smaller ranger based on the sales organization.
When ever we are working with number ranges then we must create one ‘Z’ table which contains based on
which fields we want to split the number ranges and from value, to value and current value.
Table: ZS10NR
USEREXIT_NUMBER_RANGE: -
Data WA like ZS10NR.
Select single * from ZS10NR into WA where VKORG = VBAK-VKORG and BUKRS_VF = VBAK-
BUKRS_VF.
USEREXIT_SAVE_DOCUMENT: -
Update ZS10NR set CVAL = VBAK-VBELN where VKORG = VBAK-VKORG and BUKRS_VF =
VBAK-BUKRS_VF.
CUSTOMER EXIT: - It’s used to adding some additional functionality to the standard
functionality is always through function modules. These are one type of enhancements that are
available in some specific programs, screens and menus within standard SAP Applications. These
are Function Modules with a custom empty include program, you can add your own functionality in
these include programs.
Customer Exits are available in all SAP modules, where as user exits are only available in SD
module.
Page No : 254
All customer exits ( Function Modules) starts with CALL CUSTOMER word.
Note: - Customer exit is either menu exit or screen exit or function exit or field exit.
Advantages:
- They do not affect standard SAP source code
- They do not affect software updates
Disadvantage:
- Customer exits are not available for all programs and screens found in the SAP System. You can only
use customer exits if they already exist in the SAP System.
MENU EXIT: - It’s used to adding some additional menus to the standard program.
SCREEN EXIT: - It’s used to adding some additional sub screens to the standard program.
Working with Screen exit:-
Screen exit is used to adding some additional sub screens to the standard transaction code. Screen exit
isn’t possible for all the transaction codes. Some of the transaction codes which contains screen exit.
Steps to identify the right customer exit which contains screen exit: -
Double click on each customer exit. Identify the right customer exit which contains screen exit.
(RVEXAKK1).
Page No : 255
FUNCTION EXIT: - Function exit play a major role in the real time. Because when ever we are working
with menu exit & screen exit & their functionality is implemented through function exit.
FIELD EXIT: - It’s used to perform the additional validations on the field. Now a days field exits are
outdated.
In this extension idoc we identify the right function exit to add the filling of additional segments
logic to the standard program ‘BD14’. If you want to identify the function exit, first we need to identify
the customer exit. Because function exit is key part of customer exit.
Note: - Customer exit always identified through package of the transaction code.
If SUCOMM = ‘+CS1’.
CALL TRANSACTION ‘SE16’.
ELSEIF SUCOMM = ‘+CS2’.
CALL TRANSACTION ‘SE11’.
ENDIF.
Save, check, activate the include. Back, activate the function module. Back. Activate the components.
Back. Activate the project.
Note: - Some times we can’t identify the right function exit based on the short description. So we
always identify the right function exit through break points.
Note: - Outbound exit will be triggered after filling of each & every standard segment.
Note: - Customer exit is always implemented through project i.e. ‘CMOD’ transaction.
Page No : 256
Steps to identify the right function exit based on the break point: -
Execute ‘CMOD’. Provide the project name (Z930VE). Click on create. Provide short description. Click
on save. Click on enhancement assignments in the application tool bar. Provide the enhancement as
customer exit names. Enter. Save. Click on components in the application tool bar. Double click on each
function exit. Place the cursor on include. Click on set / delete session break point. Activate. Back.
Click on change mode. Click on activate. Click on back. Activate the project. Now execute ‘BD14’.
Provide the input (S9090), message type, target system. Execute. Based on the given input outbound
program will be triggered & fetch the application data from database & fill the first standard segment.
After filling the each & every standard segment it goes to the right place then the cursor will stop at right
place due to break point & identify the right exit.
FUNCTION EXIT_SAPLKD01_001.
Project: Z930VE
FUNCTION EXIT: EXIT_SAPLKD01_001
Page No : 257
ALE configuration steps for extension IDOC inbound: -
1. Create the additional segment (WE31).
2. Create the extension idoc (WE30)
3. Link the message type to extension idoc (WE82)
5. Create inbound partner profile (WE20).
6. Link the message type to FM.
Serialization: -
Serialization is used to send as well as receive the collected message type information in a sequence.
EX: -
Material contains classification. I.e. first you need to send material & then classification.
If you send classification first then it waits until material is sent.
Create the serialization to send the material (MATMAS) & CLFMAS information.
Note: - CLFMAS Material classification
ALE configuration steps for serialization outbound: -
1. Create the serialization group (SALE)
Sender Receiver Message type 2. Create the distribution model with
SP800 SP810 MATMAS related message types and SERDAT
SP800 SP810 CLFMAS message type.
SP800 SP810 SERDAT 3. Create the outbound partner profile with
related message types & SERDAT
message type.
Steps to create serialization group: -
Execute SALE. Expand modeling & implementing business process. Expand master data distribution.
Expand serialization for sending & receiving data. Expand serialization using message type. Expand
define serialization groups. Click on new entries in the application tool bar. Provide the serialization group
(S930SG), short description. Click on save, (warning). Enter. Select the serialization group. Double click
on assignment of logical message to serial group. Click on new entries. Provide the message type
sequence number
MATMAS 1
CLFMAS 2
Click on save. Enter.
Create the distribution model with MATMAS CLFMAS and SERDAT: -
Note: - Whenever we send the material details through BD10 & classification details through
BD93 then the system check the serialization sequence & sent to the receiver system in same server.
Note: - WE47 is the transaction code which contains all the status codes & their short description.
Outbound status codes: -
Status code 03 (Data passed to port ok). After we get the status 03, we execute RBDMOIND
standard program. If the status code 03 turns 12 then the idoc s successfully reached to destination.
If the status code 03 remains 03 same, then the idoc is in the TRFC (TRFC) port.
If the status code 03 turned to 11 then the idoc is damaged in the TRFC port.
Status code 30 (Idoc ready for dispatch): -
If the status code remains 30 then must check mode of dispatch in the outbound partner profile
(WE20). If the mode of dispatch is collect then we must execute RSEOUT00 standard program.
Then only the collect idoc will be departed to their relevant receiver systems.
If the mode of dispatch is immediate that is due to traffic. It’ll reach with in 5 minutes.
Status code 29 (error in ALE server): -
An entry in the outbound table is missed (ABAPer job)
Outbound partner profile isn’t available
Data miss matched (functional people job)
Ex: The given company 1000 isn’t available
Synchronization and configuration problem (BASIS people job)
Status code 26 (error during syntax check the idoc): -
When ever we aren’t follow the syntax rules, then we get the syntax error i.e. 26.
Status code 42 (idoc was created by test transaction: -
When ever we generate the idoc through test transaction WE19 then we get the status code 42.
Status code 01 (idoc generated): -
When ever the communication idoc is generated then we get the status code ‘01’.
Note: - Status code 00 only used in R/2 system not in R/3 system.
Status code 64 (idoc ready to be transferred to application): -
If the status code remains 64 then must check the mode of posting in the inbound partner profile
(WE20). If the mode of posting is trigger by background or collects then we must execute the
RBDAPP01 standard program then only the collect IDOCS will be posted to their relevant data base
tables. If the mode of posting is trigger immediate that’s due to traffic.
Status code 51 (Application document not posted): -
Data mismatched (functional people)
Ex:- The given country ‘IN’ is not defined
Synchronization & Configuration problem (BASIS people job)
Page No : 260
Status code 56 (idoc with error added):-
An ALE in the inbound table isn’t found (ABAPer job)
(Inbound partner profile is not available)
Status code 53 (Application document posted):-
When ever the data is posted from the application to their relevant data base table successfully then
we get the status code 53.
Status code 50 (idoc added): -
When ever the idoc reached to receiver system then we get the status code 50.
Status code 62(Idoc passed to application):-
After idoc reached to receiver system then the inbound function module collect the data from idoc &
transferred to particular application if it’s success then we get the status code 62.
Status code 74 (Idoc was created by test transaction): -
When ever we test the inbound program through inbound test tool WE19 then we get the status code
74 instead of 50.
Archiving idoc: -
Archiving idocs are used to move or transverse the idocs information from SAP system to temporary
file in the presentation server. This is used to improve the performance of the system. Before
archiving the idocs the BASIS people create the physical file path in the presentation server &
logical file path in the SAP system & link the logical file path to physical file path through file
transaction.
Note: - We can’t archive the error idocs which status code is 29 & 51 directly. First we need to
convert the error status code through some other status codes by using RC1_IDOC_SET_STATUS
standard group. Later we archive the idoc.
Steps to convert the idoc status code: -
Execute SE38. Provide the program name. RC1_IDOC_SET_STATUS. Click on execute. Provide
the idoc number. Old status code (51). New status code (68). Remove the check box test. Execute.
29 into 31
51 into 68
Steps to archive the idocs:-
Execute SARA. Provide the archive idoc is provide is ‘IDOC’. Click on enter. Click on write. Click
on maintain. Provide the variant name (ZSV1). Click on create. Select the radio button for all
selection view. Enter. Provide the inputs as per client requirement. Click on attributes. Provide the
short description. Save. Click on back. Click on start data. Click on immediate or provide date &
time save. Here the idocs are transferred or archived into physical file in the presentation server
which is created by BASIS people.
Note: - ‘RSEXARCA’ is the standard program which is used to archive the IDOCS.
Note: - ‘RSEXARCD’ is the standard program which is used delete the archive idoc.
Note: - ‘RSEXARCL’ is the standard program which is used reload the archive idocs.
Note: - ‘WE11’ is the transaction code which is used to delete the idocs.
Steps to download the idoc information: -
Execute ‘IDOC’ transaction. Select the radio button analyse idoc field values. Execute (F8). Provide
the idoc number (798746). Select the checkbox ‘Also output empty fields’. Execute. In the menu bar
click on system list save local file. Select the radio button spread sheet. Enter. Browse the
file. Save. Generate.
Working with transactional data: -
By using message control technique we can send the transactional data. When ever the functional
people or end user create & save the transactional data then it automatically generate as well as
dispatch the idoc.
Page No : 261
ALE configuration steps for transactional data: -
1. Provide the output medium as ALE for the application
2.
Configure the ALE to send as well as receives the purchase order information
Steps to provide output medium as ALE for purchase order application: -
Execute ‘NACE’. Select the purchase order application (EF). Click on output types. Select the
output type which is provided by functional people. Double click on processing routines in the left
panel & absorb the medium. If the ALE medium isn’t available, click on change mode, select the
EDI medium. Click on copy in the application toolbar. Select the transaction medium as
‘Distribution (ALE) instead of EDI. Click on enter.
Create the distribution model.
Page No : 262
OOABAP
Different types of programming structures
1. Unstructured Programming
2. Procedural Programming
3. Object Oriented Programming
1. Unstructured programming: -
The entire program contains only one mail.
The same set of statements is placed in multiple locations of the same program.
It’s very difficult to maintain if the program becomes very large.
2. Procedural programming: -
The entire program is splitted into smaller programs.
The same set of statements is placed in a procedure (Subroutines or Function Module) & later we
call the same procedure from different locations of the same program.
All the subroutines & function modules can access the global declarations.
It take little bit extra time to enhance the existing functionality.
3. Object Oriented Programming: -
The entire program is visualized in terms of class & objects
All the methods can’t access the global declarations.
It takes very less time to enhance the existing functionality.
Key features of object oriented programming: -
1. Better programming structure
2. Most stress on data security & access
3. Reduce the redundancy of code
4. Data abstraction & encapsulation.
5. Inheritance and polymorphism
Class and Object: -
Class is the blueprint or template of an object. Object is the real one.
EX: - If you want to build a form house then we take a plan from engineer to build the form house. It’s
nothing but class. Based on the plan constructed house is an object.
Note: - Based on one class we can create any number of objects.
There are two types of classes.
1. Local Class
2. Global class
Differences between Local & Global classes
Page No : 263
Class definition: -
Class definition is nothing but declaring the all the components of the class & any one of the visibility
section.
Components of a class: -
1. Attributes
2. Methods
3. Events
4. Interfaces
Attributes: - Attributes are used to declare the variables, work areas, internal tables which are needed to
implement the logics.
Methods: - Method is the collection of statements which perform the particular activity. Methods are
coding blocks of a class, which can provide some business functionality
Events: - Event is an action which is performed at run time. Events are used to provide the dynamic
features at run time. Events are used to handle the methods of some other class.
Interface: - Interface is the collection of methods which are defined & not implemented.
Page No : 264
Syntax of creating the object for the class: -
This is two step procedure.
1. Create the reference to the class
2. Create the object based on reference
Syntax of creating the reference to the class:-
Data <reference name> type ref to <class name>
Page No : 266
CLASS C1 DEFINITION.
PUBLIC SECTION.
DATA A TYPE I VALUE '20'.
CLASS-DATA B TYPE I VALUE '30'.
ENDCLASS.
START-OF-SELECTION.
DATA RC1 TYPE REF TO C1.
CREATE OBJECT RC1.
WRITE RC1->A.
WRITE RC1->B.
WRITE C1=>B.
Manually filling the company code, company name & city internal tables by using OOABAP.
TYPES: BEGIN OF TY_T001,
BUKRS TYPE T001-BUKRS,
BUTXT TYPE T001-BUTXT,
ORT01 TYPE T001-ORT01,
END OF TY_T001.
DATA: WA_T001 TYPE TY_T001,
IT_T001 TYPE TABLE OF TY_T001.
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS: GET_DATA IMPORTING
I_BUKRS TYPE BUKRS
I_BUTXT TYPE BUTXT
I_ORT01 TYPE ORT01.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
Page No : 267
METHOD GET_DATA.
WA_T001-BUKRS = I_BUKRS.
WA_T001-BUTXT = I_BUTXT.
WA_T001-ORT01 = I_ORT01.
APPEND WA_T001 TO IT_T001.
CLEAR WA_T001.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA RC1 TYPE REF TO C1.
CREATE OBJECT RC1.
CLASS LC IMPLEMENTATION.
METHOD M1.
EMPNO = I_ENO.
EMPNAME = I_ENAME.
CALL METHOD M2.
ENDMETHOD.
METHOD M2.
WRITE:/ EMPNO, EMPNAME.
ENDMETHOD.
ENDCLASS.
Page No : 268
DATA OBJ TYPE REF TO LC.
START-OF-SELECTION.
CREATE OBJECT OBJ.
CLASS LC IMPLEMENTATION.
METHOD GET_DET.
SELECT SINGLE NAME1 LAND1
FROM KNA1 INTO (E_NAME1, E_LAND1)
WHERE KUNNR = I_KUNNR.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
CREATE OBJECT OBJ.
Constructor:- Constructor is a special method to initialize the attributes at runtime. Constructor contains
two types. They are Insance constroctor and Static Constroctor.
Page No : 269
Differences between Notmal methods and Constructors.
Write a simple program to differentiate between Instance constroctor and Static constroctor
CLASS SR DEFINITION.
PUBLIC SECTION.
METHODS CONSTRUCTOR.
CLASS-METHODS CLASS_constructor.
ENDCLASS.
CLASS SR IMPLEMENTATION.
METHOD CONSTRUCTOR.
WRITE:/ 'INSIDE THE INSTANSE CONSTRUCTOR'.
ENDMETHOD.
METHOD CLASS_CONSTRUCTOR.
WRITE:/ 'INSIDE THE STATIC CONSTRUCTOR'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
Develop a Global class & method to display the all purchasing document details based on the
given purchasing document number.
Execute ‘SE24’. Provide the object type as class name (ZSPRAO_10AM_GC1). Click on create. Enter.
Provide short description. Click on save click on local object. Provide the method name
(GET_PO_DETAILS). Select the level (INSTANCE Method). Select the visibility as public, provide short
description. Click on parameters.
Parameter Type Typing message Associated type
I_EBELN IMPORTING TYPE EKKO-EBELN
E_WA EXPORTING TYPE EKKO
Click on save. Click on code icon beside exceptions. Click on signature in the application tool bar &
identifies the input output parameters & implement the logic.
METHOD GET_PO_DETAILS.
SELECT SINGLE * FROM EKKO INTO E_WA WHERE EBELN = I_EBLEN.
ENDMETHOD.
Save, check, activate the method. Click on back. Repeat the same steps for all other methods. Save, check,
activate the class.
Steps to create the object for Global class: -
Place the cursor in the program where we want to create the object. Click on pattern in the application tool
bar. Select the radio button ABAP objects patterns. Enter. Select the radio button create object. Provide
the instance name as reference name (RGC). Provide the Global class name (ZSPRAO_10AM_GC1).
Enter.
Note: - Constructer is the one special type of method in the class. We no need to call the constructer
externally by using call method. When ever we create the object for the class then automatically
constructer will be triggered & asked the input output parameters.
Steps to call the Global method: -
Place the cursor where we want to call the method in the program. Click on pattern in the application tool
bar. Select the ABAP objects patterns. Enter. Select the radio button call method. Provide the instance
name as reference name (RGC). Provide the class name (ZSOPRAO_10AM_GC1), method name
(GET_PO_DETAILS). Enter.
Note: - If you want to declare the WA with some of the fields in the global method & class then we
must create one structure with those fields in the data dictionary & after we refer the structure in global
method & class.
Note: - If you want to declare the IT with some of the fields in the global class & method then in data
dictionary we have to create table type &later we refer the table type in the global class & method.
Note: - If you want to declare the select-options in global class & method then we must create one table
type with sign, option, low, high in the data dictionary & later we refer the table type in the global method
& class.
Based on the given sales document number, display the sales document number, document date
& customer number by using global class & method.
In this object we create one structure with VBELN, AUDAT, KUNNR & later we refer the
structure in the global method.
Structure : ZSPRAO_10AM_GCS
Component Component type
VBELN VBELN_VA
AUDAT AUDAT
KUNNR KUNAG
Page No : 272
START-OF-SELECTION.
CREATE OBJECT RGC.
* Call the method
CALL METHOD RGC->GET_SO_DETAILS
EXPORTING
I_VBELN = P_VBELN
IMPORTING
E_WA = WA_VBAK.
WRITE:/ WA_VBAK-VBELN, WA_VBAK-AUDAT, WA_VBAK-KUNNR.
Based on the given material numbers, display the material numbers, material types, plant
numbers, plant descriptions by using global class & method.
In this object we create two table types one is for select-options, one is for display the output.
Creation of table type is two step procedure.
1. Create the structure with those fields.
2. Based on the structure we create the table type.
Structure: ZSPRAO_10AM_GCSI
Sign Char 1
Option Char 2
Low Char 18
High Char 18
Table type name: ZSPRAO_10AM_TTI.
Line type : ZSPRAO_10AM_GCSI.
Code: -
SELECT MARA~MATNR MARA~MTART MARC~WERKS T001W~NAME1 INTO TABLE E_IT
FROM MARA INNER JOIN MARC ON MARA~MATNR = MARC~MATNR INNER JOIN T001W
ON MARC~WERKS = T001W~WERKS WHERE MARA~MATNR IN I_SMATNR.
TABLES MARA.
SELECT-OPTIONS S_MATNR FOR MARA-MATNR.
DATA IT_FINAL TYPE ZSPRAO_10AM_TTO.
* Create the reference to the class
DATA RGC TYPE REF TO ZSPRAO_10AM_GC3.
* Create the object
START-OF-SELECTION.
CREATE OBJECT RGC.
Page No : 273
* Call the method
CALL METHOD RGC->GET_MAT_DETAILS
EXPORTING
I_SMATNR = S_MATNR[]
IMPORTING
E_IT = IT_FINAL.
* Display the output
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'ZSPRAO_10AM_GCSO'
TABLES
T_OUTTAB = IT_FINAL.
Based on the given company code, display the vendors, vendor company details (BUKRS,
LIFNR, AKONT) by using global class and method
Steps to create the global class method: -
Execute SE24. Provide the class name (ZSPRAO_10AM_GC4). Click on create. Enter. Provide short
description. Enter. Click on types tab. Provide the type name.
Page No : 274
Inheritance: - Inheritance is nothing but creating new object based on existing one. The new class is
called child class / derived class / sub class. The existing class is called super class / parent class.
The sub class can access the all the components of super class which are defined under public or
protected section only not under the private section. Through super class object we can access the
components of the super class only. Through sub class object we can access the components of sub class
as well as super class also.
Syntax of defining the subclass: -
Class <sub class name> definition inheriting from <super class name>.
Public / protected / private section.
---
--- components.
---
Endclass.
Types of Inheritence
Actually Multiple inheritance isn’t possible. If we want Multiple Inheritence then we can do through
interfaces only. Directly it’s not possible.
Based on given company code display the company code, company name & city by using
OOABAP which inheritance concept.
PARAMETER P_BUKRS TYPE T001-BUKRS.
DATA: BEGIN OF WA_T001,
BUKRS TYPE T001-BUKRS,
BUTXT TYPE T001-BUTXT,
ORT01 TYPE T001-ORT01,
END OF WA_T001.
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS GET_DATA IMPORTING
I_BUKRS TYPE BUKRS.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD GET_DATA.
SELECT SINGLE BUKRS BUTXT ORT01 FROM T001 INTO WA_T001 WHERE BUKRS
= I_BUKRS.
ENDMETHOD.
ENDCLASS.
CLASS C2 DEFINITION INHERITING FROM C1.
Page No : 275
PUBLIC SECTION.
METHODS DISPLAY.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD DISPLAY.
WRITE:/ WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: RC1 TYPE REF TO C1,
RC2 TYPE REF TO C2.
CREATE OBJECT: RC1, RC2.
CALL METHOD RC2->GET_DATA
EXPORTING
I_BUKRS = P_BUKRS.
CALL METHOD RC2->DISPLAY.
We can declare the classes in two ways. Global classes can declare in SE24 transaction We can
maintain some methods in global classes, we can use those methods in local classes. Local classes are
declared in SE38 transaction.
Usual ABAP class is nothng but normal class. A class which contain at least one or more than one abstract
method, then it’s called as Abstract class. A class which don’t allow the Inheritence concept that class is
called Final class. Persistence service is used to form a bridge between your relational database and ABAP
objects. Friend class is used to access the properties of another class which are defined in Private section
also. A class which can allow to create only one instance (object), it’s called as Singleton class.
Method Overriding: -
Method overriding means We can declare one method in super class. We have some values in this method.
I’m using method redefinition in the sub class. In sub class I’m giving the different values. At the time of
calling the method from subclass object, it’ll display the values which are defined in the subclass method.
CLASS SR DEFINITION.
PUBLIC SECTION.
METHODS: M1,
M2 FINAL.
CLASS-METHODS M3.
ENDCLASS.
CLASS SR IMPLEMENTATION.
Page No : 276
METHOD M1.
WRITE:/ 'UNDER SUPER CLASS INSTANCE METHOD'.
ENDMETHOD.
METHOD M2.
WRITE:/ 'UNDER SUPER CLASS INSTANCE FINAL METHOD'.
ENDMETHOD.
METHOD M3.
WRITE:/ 'UNDER SUPER CLASS STATIC METHOD'.
ENDMETHOD.
ENDCLASS.
CLASS KS DEFINITION INHERITING FROM SR.
PUBLIC SECTION.
METHODS M1 REDEFINITION.
METHODS M4.
CLASS-METHODS M5.
ENDCLASS.
CLASS KS IMPLEMENTATION.
METHOD M1.
WRITE:/ 'REDEFINED M1 METHOD IN SUB CLASS WITH OBJ2'.
ENDMETHOD.
METHOD M4.
WRITE:/ 'UNDER SUB CLASS INSTANSE METHOD'.
ENDMETHOD.
METHOD M5.
WRITE:/ 'UNDER SUB CLASS STATIC METHD'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
CREATE OBJECT OBJ1.
CREATE OBJECT OBJ2.
Note: - We can’t redifne Static methods, Final methods in the Sub class.
After click on Detail view, you select ‘FINAL’ check box as shown in the beside picture. Next click
on change. Save, check, activate the class.
Page No : 278
If you want redefine the method in sub class. Then you have to do like this.
Click on the method which method you want to redifne. Clikcon Redefine Icon. Then you can write the
code in that method.
Abstract: - A class which contain atleast one or more than one abstract method then it’s called as Abstract
class. These are used to define some common functionalities in Abstract class (Super-class) and those can
be used in derived classes (Sub classes).
Note: - When ever we are working with Abstract class in SE38, then you have define ‘ABSTRACT’ as
keword externally as given below syntax.
class SR DEFINITION ABSTRACT.
CLASS SR IMPLEMENTATION.
METHOD SATHISH.
WRITE:/ 'SATHISH = SANJAYRAMASWAMI'.
ENDMETHOD.
METHOD HARSHITHA.
WRITE:/ 'HARSHITA = SATHISH'.
ENDMETHOD.
ENDCLASS.
Page No : 279
CLASS KS IMPLEMENTATION.
METHOD KALPANA.
WRITE:/ 'SANJAYRAMASWAMI = KALPANA'.
ENDMETHOD.
METHOD SANJAYRAMASWAMI.
WRITE:/ 'SANJAY RAMASWAMI CHARACTER ACTS AS MAIN ROAL IN MY LIFE'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
* CREATE OBJECT OBJ. "we can't create instances of the abstract class
CREATE OBJECT OBJ1.
OBJ = OBJ1.
CALL METHOD OBJ->SANJAYRAMASWAMI.
CALL METHOD OBJ->SATHISH.
Interface: - Interface is the collection of Methods which are defined but not implemented. These all are
implemented through another cass.
INTERFACE MEN.
METHODS: FATHER,
BROTHER.
ENDINTERFACE.
INTERFACE WOMEN.
METHODS: MOTHER,
SISTER.
ENDINTERFACE.
START-OF-SELECTION.
CREATE OBJECT OBJ.
OBJ1 = OBJ.
OBJ2 = OBJ.
CALL METHOD OBJ1->FATHER.
CALL METHOD OBJ2->MOTHER.
Encapsulation: - Binding or wraping the code and data in a single unit is called Encapsulation. CLASS is
the best example for the Encapsulation. In a class we can write methods, events, variables all as single
unit. So, Class is the best exaple for Encapsulation.
Polymorphism: - A single entity or method behaves in multiple forms then it’s called Polymorphism. For
example take VBELN. It acts as Sales document number in VBAK table. It acts as Delivery number in
LIKP table. It acts as billing number in VBRK table. VBELN is only one variable acts as 3 types in 3
different tables.
Page No : 281
Exceptions: - Exception is nothing but run time error. We handle this exceptions by using TRY &
CATCH blocks.
CLASS SR DEFINITION.
PUBLIC SECTION.
METHODS DEV IMPORTING I_X TYPE I
I_Y TYPE I
EXPORTING E_Z TYPE I.
ENDCLASS.
CLASS SR IMPLEMENTATION.
METHOD DEV.
TRY.
E_Z = I_X / I_Y.
CATCH CX_ROOT.
MESSAGE 'CONT DEVISIBLE BY ZERO' TYPE 'I'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
CREATE OBJECT OBJ.
Casting: - Casting is noting but switching one object from one type to another type. This is two types. 1>
Narraow casting 2> Wide casting.
Narrow casting is nothing but switching one object from more detailed view to less detailed view.
Wide casting is nothing but switching one object from less detailed view to more detailed view.
Note: - When ever we are working with class, we have to implement all methods in implementation
part. Other wise it’ll display error. If you are working with Abstract class, we may have abstract methods
& normal methods. We have to implement the normal methods in parent class & implement the abstract
methods in child class. Otherwise it’ll show error. If you are working with Inheritence and redefinition
method, then the visibility must me same in super, sub classes of that methods.
Page No : 282
OOPS ALV
When ever we are working with OPPS ALV, then we must design one custom screen other than ‘1000’
and draw the custom control screen element. In that we display the ALV output.
CL_GUI_CUSTOM_CONTAINER: - The Global class which refers the custom control screen element.
CL_GUI_ALV_GRID: - The global class which refers the ALV Grid.
SET_TABLE_FOR_FIRST_DISPLAY: - This is the Global method under grid class which is used to
display the output in an OOPS ALV. The input for the above method is two internal tables.
1. Data internal table
2. Field catalog internal table
If you want to call this method then we must create object for gird class. When ever we create the
object for gird class then automatically one constructor is triggered and asks the input as object name of
container class.
When ever we create the object for container class then automatically one constructor is triggered and asks
the input as container name.
Note: - When ever we are working with OOPS ALV then we
must design one custom screen
Steps to work with OOPS ALV:-
1. Create the selection-screen / input fields.
2. Declare the data internal table and field catalog internal table
3. Create the reference to the container and grid class start-of-
selection.
4. Call screen ‘<screen number>’ & place custom control
component in it.
PBO of the screen: -
1. Design the back button
2. Create the object to the container and gird class
3. Fill the data internal table
4. Fill the field catalog
5. Call the SET_TABLE_FOR_FIRST_DISPLAY method
PAI of the screen
1. Logic of back button.
Page No : 283
Some of the fields in field catalog: -
1. Field name Name of the field
2. Col_pos Column position
3. Coltext Column heading
4. Emphasize Color
5. Outputlen Length of the displayed field
6. No-zero Remove the leading zero’s
7. No-sign Remove the leading sign
8 No-out Hide the displayed field
9. Hotspot Handle symbol
10. Edit Changeable mode
11. Do_sum Calculate the total
Based on the given purchasing document numbers to display the all the purchasing document
header details by using OOPS ALV.
REPORT ZOOPS7.
TABLES EKKO.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
* Declare the data internal table
DATA IT LIKE TABLE OF EKKO.
* Create the reference to the container and grid
DATA RC TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA RG TYPE REF TO CL_GUI_ALV_GRID.
START-OF-SELECTION.
CALL SCREEN '2000'.
MODULE STATUS_2000 OUTPUT.
SET PF-STATUS 'STATUS'.
* Create the object for container and grid
CREATE OBJECT RC
EXPORTING
CONTAINER_NAME = 'CC'.
CREATE OBJECT RG
EXPORTING
I_PARENT = RC.
* Filling the data internal table
SELECT * FROM EKKO INTO TABLE IT WHERE EBELN IN S_EBELN.
* Display the output
CALL METHOD RG->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'EKKO'
CHANGING
IT_OUTTAB = IT.
ENDMODULE.
MODULE USER_COMMAND_2000 INPUT.
IF SY-UCOMM = 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
Based on the given customer numbers to display the customer numbers, names & cities by using
OOPS ALV and also display the customer numbers with green color, name with hotspot, city with
edit.
TABLES KNA1.
SELECT-OPTIONS S_KUNNR FOR KNA1-KUNNR.
* Declare the data internal table
TYPES: BEGIN OF TY_KNA1,
KUNNR TYPE KNA1-KUNNR,
NAME1 TYPE KNA1-NAME1,
ORT01 TYPE KNA1-ORT01,
END OF TY_KNA1.
DATA: WA_KNA1 TYPE TY_KNA1,
IT_KNA1 TYPE TABLE OF TY_KNA1.
* Declare the field catalog
DATA: IT_FCAT TYPE LVC_T_FCAT,
WA_FCAT LIKE LINE OF IT_FCAT.
* Create the references
DATA: RC TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
RG TYPE REF TO CL_GUI_ALV_GRID.
START-OF-SELECTION.
CALL SCREEN '2000'.
Page No : 285
MODULE STATUS_2000 OUTPUT.
SET PF-STATUS 'STAT'.
CREATE OBJECT RC
EXPORTING
CONTAINER_NAME = 'CC'.
CREATE OBJECT RG
EXPORTING
I_PARENT = RC.
* Filling the data internal table
SELECT KUNNR NAME1 ORT01 FROM KNA1 INTO TABLE IT_KNA1 WHERE KUNNR IN
S_KUNNR.
* Filling the field catalog
WA_FCAT-FIELDNAME = 'KUNNR'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-COLTEXT = 'CUSTOMER'.
WA_FCAT-EMPHASIZE = 'C501'.
WA_FCAT-NO_ZERO = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'NAME1'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-COLTEXT = 'CUST.NAME'.
WA_FCAT-HOTSPOT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'ORT01'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-COLTEXT = 'CITY'.
WA_FCAT-EDIT = 'X'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
* Display the output
CALL METHOD RG->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = IT_KNA1
IT_FIELDCATALOG = IT_FCAT.
ENDMODULE.
MODULE USER_COMMAND_2000 INPUT.
IF SY-UCOMM = 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
Based on the given sales order numbers, display the
sales document header details (VBELN, AUDAT,
KUNNR) & sales doc item details (VBELN, POSNR,
KWMENG, MEINS, NETWR) side by side by using
OOPS ALV.
TABLES VBAK.
SELECT-OPTIONS S_VBELN FOR VBAK-VBELN.
TYPES: BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
Page No : 286
AUDAT TYPE VBAK-AUDAT,
KUNNR TYPE VBAK-KUNNR,
END OF TY_VBAK.
DATA: WA_VBAK TYPE TY_VBAK,
IT_VBAK TYPE TABLE OF TY_VBAK.
TYPES: BEGIN OF TY_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
KWMENG TYPE VBAP-KWMENG,
MEINS TYPE VBAP-MEINS,
NETWR TYPE VBAP-NETWR,
END OF TY_VBAP.
DATA: WA_VBAP TYPE TY_VBAP,
IT_VBAP TYPE TABLE OF TY_VBAP.
* Declare the field catalogs
DATA: IT_FCAT1 TYPE LVC_T_FCAT,
WA_FCAT1 LIKE LINE OF IT_FCAT1.
DATA: IT_FCAT2 TYPE LVC_T_FCAT,
WA_FCAT2 LIKE LINE OF IT_FCAT2.
* Create the references
DATA: RC1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
RG1 TYPE REF TO CL_GUI_ALV_GRID.
DATA: RC2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
RG2 TYPE REF TO CL_GUI_ALV_GRID.
START-OF-SELECTION.
CALL SCREEN '2000'.
MODULE STATUS_2000 OUTPUT.
SET PF-STATUS 'STAT'.
CREATE OBJECT RC1
EXPORTING
CONTAINER_NAME = 'CC1'.
CREATE OBJECT RG1
EXPORTING
I_PARENT = RC1.
CREATE OBJECT RC2
EXPORTING
CONTAINER_NAME = 'CC2'.
CREATE OBJECT RG2
EXPORTING
I_PARENT = RC2.
* Filling the data internal tables
SELECT VBELN AUDAT KUNNR FROM VBAK INTO TABLE IT_VBAK WHERE VBELN IN
S_VBELN.
SELECT VBELN POSNR KWMENG MEINS NETWR FROM VBAP INTO TABLE IT_VBAP
WHERE VBELN IN S_VBELN.
* Filling the field catalogs
WA_FCAT1-FIELDNAME = 'VBELN'.
WA_FCAT1-COL_POS = '1'.
WA_FCAT1-COLTEXT = 'SALES.DOC'.
APPEND WA_FCAT1 TO IT_FCAT1.
Page No : 287
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME = 'AUDAT'.
WA_FCAT1-COL_POS = '2'.
WA_FCAT1-COLTEXT = 'DOC.DATE'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME = 'KUNNR'.
WA_FCAT1-COL_POS = '3'.
WA_FCAT1-COLTEXT = 'CUSTOMER'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT2-FIELDNAME = 'VBELN'.
WA_FCAT2-COL_POS = '1'.
WA_FCAT2-COLTEXT = 'SALES.DOC'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2-FIELDNAME = 'POSNR'.
WA_FCAT2-COL_POS = '2'.
WA_FCAT2-COLTEXT = 'ITEM'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2-FIELDNAME = 'KWMENG'.
WA_FCAT2-COL_POS = '3'.
WA_FCAT2-COLTEXT = 'QTY'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2-FIELDNAME = 'MEINS'.
WA_FCAT2-COL_POS = '4'.
WA_FCAT2-COLTEXT = 'UOM'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2-FIELDNAME = 'NETWR'.
WA_FCAT2-COL_POS = '5'.
WA_FCAT2-COLTEXT = 'PRICE'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
CALL METHOD RG1->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = IT_VBAK
IT_FIELDCATALOG = IT_FCAT1.
CALL METHOD RG2->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = IT_VBAP
IT_FIELDCATALOG = IT_FCAT2.
ENDMODULE.
MODULE USER_COMMAND_2000 INPUT.
IF SY-UCOMM = 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
Page No : 288
Some of the fields in layout work area: -
1. CWIDTH_OPT Compress the displayed fields.
2. ZEBRA Stripped pat urn
3. INFO_FNAME color field
Note: - In the DDIC we have one structure. That is ‘LVC_S_LAYO’ which contains above fields. So
we simply declare our layout work area by referring ‘LVC_S_LAYO’.
Based on the given purchasing document numbers, display the document numbers,
item numbers, quantity, UOM & net price & also display the item details in a yellow color if the
amount is more than ‘1000’ by using OOPS ALV.
Steps to work with row color: -
1. Declare the additional color field in the data internal table, which is char & length is 4.
2. Fill the data internal table based on given input
3. Modify the color field based on client requirement
4. pass the color field name into layout work area (INFO, FNAME field)
5. Fill the field catalog
6. Display the output by using SET_TABLE_FOR_FIRST_DISPLAY method by passing data
internal table, field catalog internal table, layout work area.
TABLES EKPO.
SELECT-OPTIONS S_EBELN FOR EKPO-EBELN.
* Declare the data internal table
TYPES: BEGIN OF TY_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
CF(4) TYPE C,
END OF TY_EKPO.
DATA: WA_EKPO TYPE TY_EKPO, WA_EKKO-CF =
IT_EKPO TYPE TABLE OF TY_EKPO. ‘C310’.
* Declare the field catalog Modify it_ekpo from
DATA: IT_FCAT TYPE LVC_T_FCAT, wa_ekpo transporting
WA_FCAT LIKE LINE OF IT_FCAT. CF where netpr > 1000.
* Declare the layout work area
DATA WA_LAYOUT TYPE LVC_S_LAYO.
* Create the reference
DATA: RC TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
RG TYPE REF TO CL_GUI_ALV_GRID.
START-OF-SELECTION.
CALL SCREEN '2000'.
MODULE STATUS_2000 OUTPUT.
SET PF-STATUS 'STAT'.
* Create the object
CREATE OBJECT RC
EXPORTING
CONTAINER_NAME = 'CC'.
CREATE OBJECT RG
Page No : 289
EXPORTING
I_PARENT = RC.
* Filling the data internal table
SELECT EBELN EBELP MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO
WHERE EBELN IN S_EBELN.
* Modify the color field.
WA_EKPO-CF = 'C310'.
MODIFY IT_EKPO FROM WA_EKPO TRANSPORTING CF WHERE NETPR > 1000.
* Pass the color field into layout work area.
WA_LAYOUT-INFO_FNAME = 'CF'.
* Filling the field catalog
WA_FCAT-FIELDNAME = 'EBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-COLTEXT = 'PUR.DOC'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'EBELP'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-COLTEXT = 'ITEM'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'MENGE'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-COLTEXT = 'QTY'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-COL_POS = '4'.
WA_FCAT-COLTEXT = 'UNITS'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'NETPR'.
WA_FCAT-COL_POS = '5'.
WA_FCAT-COLTEXT = 'PRICE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
CALL METHOD RG->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = WA_LAYOUT
CHANGING
IT_OUTTAB = IT_EKPO
IT_FIELDCATALOG = IT_FCAT.
ENDMODULE.
MODULE USER_COMMAND_2000 INPUT.
IF SY-UCOMM = 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
Note: - If you want subtotals in OOPs ALV, Declare one Internal table with type compitable
LVC_T_SORT. Declare one work area also. In this one fill the fields as
WA_SORT-FIELDNAME = ‘EBELN’, WA_SORT-SUBTOT = ‘X’.
Page No : 290
Working with events: -
Events are raised as well as handled within the class & also handle through some other class by using
methods. Events have only exporting parameters. It doesn’t contain importing parameters. Actually Events
are used to provide the dynamic values to the application.
Note: - When ever we are working with events then we must register the events before call the methods.
Syntax of declaring the events: -
Events <event name> exporting <EP1> <EP2> - - -
Syntax of raise the event:-
Raise event <event name>
Syntax of declaring event handler method: -
Methods <event handler method name> for event <event name> of <class name>.
Which class contains events
Syntax of register the events: -
SET handler <object name of class>-><event handler method> for <object name of class>
Which class contains event declaration
Which class contains event handler method
Based on the given customer number, display the customer number, name, city by using
OOABAP & also print the error if the input is invalid by using events.
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS: GET_DATA IMPORTING I_KUNNR TYPE KNA1-KUNNR,
DISPLAY.
EVENTS NODATA.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD GET_DATA.
SELECT SINGLE KUNNR NAME1 ORT01 FROM KNA1 INTO WA_KNA1 WHERE KUNNR
= I_KUNNR.
IF SY-SUBRC <> 0.
RAISE EVENT NODATA.
ENDIF.
ENDMETHOD.
METHOD DISPLAY.
WRITE:/ WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1-ORT01.
ENDMETHOD.
ENDCLASS.
CLASS C2 DEFINITION.
PUBLIC SECTION.
METHODS EHM FOR EVENT NODATA OF C1.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD EHM.
Page No : 291
MESSAGE E000(ZHAI11) WITH 'INVALID CUSTOMER'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: RC1 TYPE REF TO C1,
RC2 TYPE REF TO C2.
CREATE OBJECT: RC1, RC2.
SET HANDLER RC2->EHM FOR RC1.
CALL METHOD RC1->GET_DATA
EXPORTING
I_KUNNR = P_KUNNR.
CALL METHOD RC1->DISPLAY.
Based on the given sales document numbers & dates, display the sales document numbers,
document dates & customer numbers by using OOPS ALV& also display the TOP_OF_PAGE as
‘These are sales order details’. TOP_OF_LIST as ‘SPRAO Technologies’.
TABLES VBAK.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,
S_AUDAT FOR VBAK-AUDAT NO-EXTENSION.
* Declare the data internal table
Page No : 292
TYPES: BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
AUDAT TYPE VBAK-AUDAT,
KUNNR TYPE VBAK-KUNNR,
END OF TY_VBAK.
DATA: WA_VBAK TYPE TY_VBAK,
IT_VBAK TYPE TABLE OF TY_VBAK.
* Declare the field catalog
DATA: IT_FCAT TYPE LVC_T_FCAT,
WA_FCAT LIKE LINE OF IT_FCAT.
DATA: RC TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
RG TYPE REF TO CL_GUI_ALV_GRID.
CLASS C2 DEFINITION.
PUBLIC SECTION.
METHODS: EHTL FOR EVENT PRINT_TOP_OF_LIST OF CL_GUI_ALV_GRID,
EHTP FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD EHTL.
WRITE:/ 'SPRAO TEHCNOLOGIES'.
ENDMETHOD.
METHOD EHTP.
WRITE:/ 'THESE ARE SO DETAILS'.
ENDMETHOD.
ENDCLASS.
* Create the reference to the container & grid
START-OF-SELECTION.
MODULE STATUS_2000 OUTPUT.
SET PF-STATUS 'STAT'.
CREATE OBJECT RC
EXPORTING
CONTAINER_NAME = 'CC'.
CREATE OBJECT RG
EXPORTING
I_PARENT = RC.
* Filling the data internal table
SELECT VBELN AUDAT KUNNR FROM VBAK INTO TABLE IT_VBAK WHERE VBELN IN
S_VBELN AND AUDAT IN S_AUDAT.
* Fill the field catalog
WA_FCAT-FIELDNAME = 'VBELN'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-COLTEXT = 'SALES.DOC'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'AUDAT'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-COLTEXT = 'DOC.DATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
Page No : 293
WA_FCAT-FIELDNAME = 'KUNNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-COLTEXT = 'CUSTOMER'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
* Create the reference & object for local class
DATA RC2 TYPE REF TO C2.
CREATE OBJECT RC2.
* Register the events.
SET HANDLER RC2->EHTL FOR RG.
SET HANDLER RC2->EHTP FOR RG.
* Display the output.
CALL METHOD RG->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = IT_VBAK
IT_FIELDCATALOG = IT_FCAT.
ENDMODULE.
MODULE USER_COMMAND_2000 INPUT.
IF SY-UCOMM = 'BACK'.
LEAVE TO SCREEN 0.
ENDIF.
ENDMODULE.
Note: - LVC_FIELDCATALOG_MERGE is the function module which is used to fill the field catalog
internal table. The input for the above function module is data structure which data we want to display
(Based on the displayed fields we create structure in SE11). The output for the above function module is
field catalog internal table. Instead of passing the structure to the merge function module we can directly
pass the structure to SET_TABLE_FOR_FIRST_DISPLAY method. So we can’t use merge function
module to prepare the field data
Syntax of call transaction: -
Call transaction ‘<TCODE>’.
Syntax of set the value before calling the transaction: -
Set parameter id ‘<idname>’ field ‘<value>’.
Steps to identify the parameter id: -
Execute required transaction (XK03). Place the cursor on input field. Click on F1. clickon technical
information. Identify the parameter id.
Parameter p_lifnr type lfa1-lifnr,
Set parameter id ‘LIF’ field p_lifnr.
Call transaction ‘XK03’.
Syntax of get the current document which is opened: -
Get parameter id <ID NAME> field variable.
EX: -
Data V type EKKO-EBELN.
Get parameter id ‘BES’ field V.
Write V.
GET & SET are called SAP memory. IMPORT, EXPORT, CHANGING, - - are called ABAP memory.
Based on the given sales document numbers, display the sales document numbers, document
dates & customer numbers by using OOPS ALV. If the user clicks on any sales document number
Page No : 294
only then we display the sales order details through VA03 transaction. If the user clicks on any
customer number only then we display the customers details through XD03 transaction.
TABLES VBAK.
SELECT-OPTIONS S_VBELN FOR VBAK-VBELN.
TYPES: BEGIN OF TY_VBAK,
VBELN TYPE VBAK-VBELN,
AUDAT TYPE VBAK-AUDAT,
KUNNR TYPE VBAK-KUNNR,
END OF TY_VBAK.
DATA: WA_VBAK TYPE TY_VBAK,
IT_VBAK TYPE TABLE OF TY_VBAK.
DATA: IT_FCAT TYPE LVC_T_FCAT,
WA_FCAT LIKE LINE OF IT_FCAT.
CLASS C2 DEFINITION.
PUBLIC SECTION.
METHODS EHDC FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD EHDC.
READ TABLE IT_VBAK INTO WA_VBAK INDEX E_ROW-INDEX.
IF E_COLUMN-FIELDNAME = 'VBELN'.
SET PARAMETER ID 'AUN' FIELD WA_VBAK-VBELN.
CALL TRANSACTION 'VA03'.
ELSEIF E_COLUMN-FIELDNAME = 'KUNNR'.
SET PARAMETER ID 'KUN' FIELD WA_VBAK-KUNNR.
CALL TRANSACTION 'XD03'.
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
CALL SCREEN 2000.
SELECT VBELN AUDAT KUNNR FROM VBAK INTO TABLE IT_VBAK WHERE VBELN IN
S_VBELN.
WA_FCAT-FIELDNAME = 'VBELN'.
Page No : 295
WA_FCAT-COL_POS = '1'.
WA_FCAT-COLTEXT = 'SALES.DOC'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'AUDAT'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-COLTEXT = 'DATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-FIELDNAME = 'KUNNR'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-COLTEXT = 'CUSTOMER'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
DATA RC2 TYPE REF TO C2.
CREATE OBJECT RC2.
SET HANDLER RC2->EHDC FOR RG.
Page No : 296
Working with OOPS BDC
1. Do the recording
2. Prepare the file
3. Upload the data from file to internal table / BDC program
4. For each record in the internal table collect the screen and field details.
5. For each record in internal table, call the transaction.
Note: - In this OOPS BDC we need to declare 3 methods.
1. Upload data.
2. Fill screen details
3. Fill field details
Syntax of declaring the method for upload data: -
Methods <method name> importing <file name> type string.
Syntax of implementation: -
Method <method name>
Call function ‘GUI_UPLOAD’
<Field name>
‘X’
<Data IT>
Endmethod.
Declaring the fill screen method: -
Methods fill_screen importing
I_prog type bdc_prog
I_dynpro type bdc_dynr
I_dynbegin type bdc_start.
Implementation
Method fill_screen.
Wa_bdcdata-program = i_prog.
Wa_bdcdata-dynpro = i_dynpro.
Wa_bdcdata-dynbegin = i_dynbegin
Append wa_bdcdata to it_bdcdata.
Clear wa_bdcdata.
Declaring the fill field method: -
Method fill_field importing
I_fnam type fnam____4
I_fval type c.
Implementation
Method fill_field.
Wa_bdcdata-fam = i_fnam.
Wa_bdcdata-fval = i_fval.
Append wa_bdcdata to it_bdcdata.
Clear wa_bdcdata.
Endmethod.
Develop a conversion program to upload the bank details from flat file to SAP system by using
BDC call transaction method by using OOPS ABAP.
The flat file contains bank country key, bank key & bank name.
Steps to do the recording:-
Execute SHDB. Click on new recording in the application tool bar. Provide the recording name,
transaction code (FI01). Enter. Provide country (IN), bank key (554141). Enter. Provide the bank name
(HDFC Bank). Save.
Page No : 297
REPORT ZOOABAPBDC.
TYPES: BEGIN OF TY_BANK,
BANKS TYPE BNKA-BANKS,
BANKL TYPE BNKA-BANKL,
BANKA TYPE BNKA-BANKA,
END OF TY_BANK.
CLASS C1 DEFINITION.
PUBLIC SECTION.
CLASS C1 IMPLEMENTATION.
METHOD UPLOAD_DATA.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = I_FILE
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_BANK.
ENDMETHOD.
METHOD FILL_SCREEN.
WA_BDCDATA-PROGRAM = I_PROG.
WA_BDCDATA-DYNPRO = I_DYNPRO.
WA_BDCDATA-DYNBEGIN = I_DYNBEGIN.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDMETHOD.
METHOD FILL_FIELD.
WA_BDCDATA-FNAM = I_FNAM.
WA_BDCDATA-FVAL = I_FVAL.
APPEND WA_BDCDATA TO IT_BDCDATA.
CLEAR WA_BDCDATA.
ENDMETHOD.
Page No : 298
ENDCLASS.
START-OF-SELECTION.
DATA RC1 TYPE REF TO C1.
CREATE OBJECT RC1.
CALL METHOD RC1->UPLOAD_DATA
EXPORTING
I_FILE = 'C:\Users\Administrator\Desktop\22.TXT'.
Page No : 299
I_FNAM = 'BDC_OKCODE'
I_FVAL = '=UPDA'.
ENDLOOP.
Interface: -Interface is the collection of methods which are defined not implemented. These are
implemented through class implementation. Interfaces are reusable components. We can declare the same
interface in any number of classes under public section only. Interface components are always access
through object.
We can’t create the interface object directly. First we create the interface reference & later assign
the class object to interface reference. Then automatically interface object is created.
Syntax of declaring the interface: -
Interface <interface name>
----
- - - - method declaration
----
Endinterface.
Syntax of access the interface in class definition: -
Interfaces <interface name>.
Based on the given company code, display the customers under company details (BUKRS
KUNNR AKONT) by using OOABAP with interface concept.
REPORT ZOOPS1199.
PARAMETER P_BUKRS TYPE KNB1-BUKRS.
INTERFACE IF1.
METHODS DISPLAY.
ENDINTERFACE.
CLASS C1 definition.
PUBLIC SECTION.
TYPES: BEGIN OF TY_KNB1,
BUKRS TYPE KNB1-BUKRS,
KUNNR TYPE KNB1-KUNNR,
AKONT TYPE KNB1-AKONT,
END OF TY_KNB1.
DATA: WA_KNB1 TYPE TY_KNB1,
IT_KNB1 TYPE TABLE OF TY_KNB1.
METHODS: GET_DATA IMPORTING I_BUKRS TYPE BUKRS.
INTERFACES IF1.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD GET_DATA.
SELECT BUKRS KUNNR AKONT FROM KNB1 INTO TABLE IT_KNB1 WHERE BUKRS =
I_BUKRS.
ENDMETHOD.
Page No : 300
METHOD IF1~DISPLAY.
LOOP AT IT_KNB1 INTO WA_KNB1.
WRITE:/ WA_KNB1-BUKRS, WA_KNB1-KUNNR, WA_KNB1-AKONT.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA RC1 TYPE REF TO C1.
DATA RFC1 TYPE REF TO IF1.
CREATE OBJECT RC1.
RFC1 = RC1.
CALL METHOD RC1->GET_DATA
EXPORTING
I_BUKRS = P_BUKRS.
CALL METHOD RFC1->DISPLAY.
REPORT ZOOPS1100.
PARAMETER P_BUKRS TYPE T001-BUKRS.
INCLUDE ZIIT001.
CLASS C1 DEFINITION ABSTRACT.
PUBLIC SECTION.
METHODS: GET_DATA IMPORTING I_BUKRS TYPE BUKRS,
DISPLAY ABSTRACT.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD GET_DATA.
SELECT SINGLE BUKRS BUTXT ORT01 FROM T001 INTO WA_T001 WHERE BUKRS
= I_BUKRS.
ENDMETHOD.
ENDCLASS.
CLASS C2 DEFINITION INHERITING FROM C1.
PUBLIC SECTION.
METHODS DISPLAY REDEFINITION.
ENDCLASS.
CLASS C2 IMPLEMENTATION.
METHOD DISPLAY.
WRITE:/ WA_T001-BUKRS, WA_T001-BUTXT, WA_T001-ORT01.
ENDMETHOD.
Page No : 301
ENDCLASS.
START-OF-SELECTION.
DATA RC2 TYPE REF TO C2.
CREATE OBJECT RC2.
CALL METHOD RC2->GET_DATA
EXPORTING
I_BUKRS = P_BUKRS.
CALL METHOD RC2->DISPLAY.
Deferred class: -
If you want to access the class before declaring & implementing the class then we must specify the class
as deferred.
Syntax –
Class <class name> definition deferred.
Ex: - class c1 definition deferred.
Friend class:-
Through friends class we can access the private components of some other class.
REPORT ZOOABAP1111.
class c2 definition deferred.
class c1 definition friends c2.
public section.
methods M1.
private section.
methods M2.
endclass.
class c1 implementation.
method M1.
write 'SPRAO Technologies'.
endmethod.
method M2.
write:/ 'S.R Nagar, Hyderabad'.
endmethod.
endclass.
class c2 definition.
public section.
methods M3.
endclass.
class c2 implementation.
method M3.
data rc1 type ref to c1.
CREATE OBJECT rc1.
CALL METHOD rc1->M1.
CALL METHOD rc1->M2.
endmethod.
endclass.
start-of-selection.
data rc2 type ref to c2.
CREATE OBJECT rc2.
CALL METHOD rc2->M3.
Page No : 302
BAPI
(Business Application Programming Interface)
BAPI's are used to connecting from SAP to SAP as well as SAP to NON-SAP.
Page No : 303
2. Create the BAPI function module (SE37)
1. Which is remote enable.
2. Must contains RETURN parameter
3. All parameters are pass by value
3. Create the object and methods for BAPI function module (SWO1)
4. Release the object and method (SWO1).
Develop a custom BAPI to display the purchasing doc number, doc date & vendor number based
on the given purchasing doc number.
Steps to create the BAPI structure: -
Execute SE11. Select the radio button data type. Provide the BAPI structure name (ZBAPI_10AM_STR).
Click on create. Select the radio button structure. Enter. Provide short description (BAPI Structure).
Provide the component & component type.
EBELN EBELN
BEDAT BEDAT
LIFNR LIFNR
Save in own package. Check, activate.
Steps to create function group: -
Execute SE37. In the menu bar click on goto function groups create group. Provide the function
group name (ZBAPI_10AM_FG), short description. Save in our own package.
Steps to activate the function group: -
In the menu bar click on environment inactive objects. Expand the function group under transportable
objects. Select the function group. Right click activate. Enter.
Steps to create function module: -
Execute ‘SE37’. Provide the function module name. Click on create. Provide the function group
(ZBAPI_10AM_FG), short description. Enter. Click on attributes tab. Select the radio button remote-
enabled module. Click on import tab.
Import
Parameter type associated type pass by value
I_EBELN TYPE ZBAPI_10AM_STR-EBELN
Export
Parameter type associated type pass by value
E_WA TYPE ZBAPI_10AM_STR
RETURN TYPE BAPIRET2
Source code
Select single ebeln bedat lifnr from ekko into wa_ekko where ebeln = i_ebeln.
Save, check, activate. Click on back. In the menu bar click on function module. Release -> Release.
Function module is released.
Steps to release the object & method for BAPI function module: -
Execute SWO1. Provide the object name (ZBAPI_10AM). Click on create. Provide the object name
(ZBAPI_10AM). Click on create. Provide the same to all. Select the application (M). Enter. Click on
enter. Save in our package. Place the cursor on methods. In the menu bar click on utilities. API methods
Add method. Provide function module name (ZBAPI_10AM_FM). Click on enter. Click on next step
(CTRL + SHIFT + F11). Click on next. Click on yes. Click on save.
Steps to release the object & method: -
Place the cursor on object (ZBAPI_10AM). In the menu bar click on edit change release status
object type to modeled (to implemented, to release also). Select the method. In the menu bar, click on
edit change release status object type component to modeled (to implemented, to released also).
Click on generate (CTRL + F3).
Steps to check BAPI is available or not in BOR:-
Execute BAPI transaction. Click on alphabetical tab & absorb our BAPI.
Page No : 304
Note: - In the real time we never create our own custom BAPIs. We always use existing BAPIs.
Note: - In the real time we always use the BAPIs like conversion program or report.
Steps to identify the standard BAPIs: -
Method 1:-
Execute ‘SE93’. Provide the related transaction code (ME23N). Click on display. Click on display object
list (CTRL + SHIFT + F5) in the application tool bar. Expand the package. Expand the business
engineering. Expand the business object types. Double click on our required business object. Expand the
method. Double click on our required method (Get details). Click on ABAP tab. Identify the BAPI name
(BAPI_PO_GETDETAIL).
Method 2:-
Execute BAPI transaction. Click on hierarchical tab. Expand the module. Expand the application (sales).
Expand the object. Double click on method. Identify the BAPI in right side.
Method 3:-
By using BAPI methods we can identify the standard BAPI.
Some of the BAPI methods are
1. Get list ()
2. Get details ()
3. Get status ()
4. Existence check ()
5. Create ()
6. Change ()
7. Delete ()
Steps to identify the BAPI based on BAPI method name: -
Execute ‘SE37’. Provide BAPI <Method name>. Click on F4. We get the list of BAPIs related to that
method & identify our required method.
Note: - When ever we are working with create, change, delete BAPIs, then we must committed the data
base by using ‘BAPI_TRANSACTION_COMMIT’ function module. Other wise the data base isn’t
updated.
Steps to create cost center group manually: -
Execute ‘KSH1’. Provide the Controlling area (6000). Enter. Provide the cost center group name (ZSPG).
Enter. Provide short description. Click on cost center in the application tool bar. Provide the from to (1000
– 3000), (5000 – 7000) cost centers. Enter. Click on save.
Create the cost center group by using BAPI.
BAPI: - BAPI_COSTCENTERGROUP_CREATE
PARAMETER P_CAREA LIKE BAPICO_GROUP-CO_AREA.
DATA WA_RETURN LIKE BAPIRET2.
DATA: IT_HNODE LIKE TABLE OF BAPISET_HIER,
WA_HNODE LIKE LINE OF IT_HNODE.
DATA: IT_HVAL LIKE TABLE OF BAPI1112_VALUES,
WA_HVAL LIKE LINE OF IT_HVAL.
WA_HNODE-GROUPNAME = 'ZSPG'.
WA_HNODE-HIERLEVEL = '0'.
WA_HNODE-VALCOUNT = '2'.
WA_HNODE-DESCRIPT = 'COSTCENTER GROUP1'.
APPEND WA_HNODE TO IT_HNODE.
WA_HVAL-VALFROM = '0000001000'.
WA_HVAL-VALTO = '0000002000'.
APPEND WA_HVAL TO IT_HVAL.
WA_HVAL-VALFROM = '0000003000'.
Page No : 305
WA_HVAL-VALTO = '0000004000'.
APPEND WA_HVAL TO IT_HVAL.
CALL FUNCTION 'BAPI_COSTCENTERGROUP_CREATE'
EXPORTING
CONTROLLINGAREAIMP = P_CAREA
IMPORTING
RETURN = WA_RETURN
TABLES
HIERARCHYNODES = IT_HNODE
HIERARCHYVALUES = IT_HVAL.
Upload the Bank details from flat file to SAP system by using BAPI
Page No : 308
Based on the given comp code vendor number & date, display the vendor open item details
by using BAPI.
PARAMETER: P_BUKRS LIKE BAPI3008_1-COMP_CODE,
P_LIFNR LIKE BAPI3008_1-VENDOR,
P_DAT LIKE BAPI3008-KEY_DATE.
DATA WA_RETURN LIKE BAPIRETURN.
DATA T_OT LIKE TABLE OF BAPI3008_2.
CALL FUNCTION 'BAPI_AP_ACC_GETOPENITEMS'
EXPORTING
COMPANYCODE = P_BUKRS
VENDOR = P_LIFNR
KEYDATE = P_DAT
IMPORTING
RETURN = WA_RETURN
TABLES
LINEITEMS = T_OT.
IF WA_RETURN IS INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'BAPI3008_2'
TABLES
T_OUTTAB = T_OT.
ELSE.
WRITE WA_RETURN-MESSAGE.
ENDIF.
Based on the given company code, customer number, from date & to date display the
customer cleared items by using BAPI.
PARAMETER: P_BUKRS LIKE BAPI3007_1-COMP_CODE,
P_KUNNR LIKE BAPI3007_1-CUSTOMER,
P_FD LIKE BAPI3007-FROM_DATE,
P_TD LIKE BAPI3007-TO_DATE.
DATA WA_RETURN LIKE BAPIRETURN.
DATA T_CI LIKE TABLE OF BAPI3007_2.
CALL FUNCTION 'BAPI_AR_ACC_GETBALANCEDITEMS'
EXPORTING
COMPANYCODE = P_BUKRS
CUSTOMER = P_KUNNR
DATE_FROM = P_FD
DATE_TO = P_TD
IMPORTING
RETURN = WA_RETURN
TABLES
LINEITEMS = T_CI.
IF WA_RETURN IS INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'BAPI3007_2'
TABLES
T_OUTTAB = T_CI.
ELSE.
WRITE WA_RETURN-MESSAGE.
Page No : 309
ENDIF.
Based on the given purchasing document number display the purchasing document item
details & history details by using BAPI.
BAPI: BAPI_PO_GETDETAIL
PARAMETER P_EBELN LIKE BAPIEKKO-PO_NUMBER. ME23N
DATA: IT_ITEMS LIKE TABLE OF BAPIEKPO,
WA_ITEMS LIKE LINE OF IT_ITEMS.
DATA: IT_HIS LIKE TABLE OF BAPIEKBE,
WA_HIS LIKE LINE OF IT_HIS.
DATA: IT_RETURN LIKE TABLE OF BAPIRETURN,
WA_RETURN LIKE LINE OF IT_RETURN.
CALL FUNCTION 'BAPI_PO_GETDETAIL'
EXPORTING
PURCHASEORDER = P_EBELN
ITEMS = 'X'
HISTORY = 'X'
TABLES
PO_ITEMS = IT_ITEMS
PO_ITEM_HISTORY = IT_HIS
RETURN = IT_RETURN.
IF IT_RETURN IS INITIAL.
LOOP AT IT_ITEMS INTO WA_ITEMS.
WRITE:/ WA_ITEMS-PO_NUMBER, WA_ITEMS-PO_ITEM.
ENDLOOP.
ULINE.
LOOP AT IT_HIS INTO WA_HIS.
WRITE:/ WA_HIS-MAT_DOC, WA_HIS-DOC_YEAR.
ENDLOOP.
ELSE.
LOOP AT IT_RETURN INTO WA_RETURN.
WRITE:/ WA_RETURN-MESSAGE.
ENDLOOP.
ENDIF.
Based on the given purchasing document numbers, display the purchasing document item,
service & history details by using BAPI.
REPORT ZBAPI993.
TYPE-POOLS SLIS.
DATA V1 LIKE BAPIEKKO-PO_NUMBER.
SELECT-OPTIONS S_EBELN FOR V1.
DATA: BEGIN OF WA,
EBELN TYPE EKKO-EBELN,
END OF WA.
DATA IT LIKE TABLE OF WA.
IF IT_RETURN IS INITIAL.
WA_FCAT1-FIELDNAME = 'PO_NUMBER'.
WA_FCAT1-COL_POS = '1'.
WA_FCAT1-SELTEXT_M = 'PO NUMBER'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT1-FIELDNAME = 'PO_ITEM'.
Page No : 311
WA_FCAT1-COL_POS = '2'.
WA_FCAT1-SELTEXT_M = 'ITEM NUMBER'.
APPEND WA_FCAT1 TO IT_FCAT1.
CLEAR WA_FCAT1.
WA_FCAT2-FIELDNAME = 'MAT_DOC'.
WA_FCAT2-COL_POS = '1'.
WA_FCAT2-SELTEXT_M = 'MATERIAL DOCUMENT'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT2-FIELDNAME = 'DOC_YEAR'.
WA_FCAT2-COL_POS = '2'.
WA_FCAT2-SELTEXT_M = 'DOCUMENT YEAR'.
APPEND WA_FCAT2 TO IT_FCAT2.
CLEAR WA_FCAT2.
WA_FCAT3-FIELDNAME = 'PCKG_NO'.
WA_FCAT3-COL_POS = '1'.
WA_FCAT3-SELTEXT_M = 'PACKAGE NUMBER'.
APPEND WA_FCAT3 TO IT_FCAT3.
CLEAR WA_FCAT3.
WA_FCAT3-FIELDNAME = 'SUBPCKG_NO'.
WA_FCAT3-COL_POS = '2'.
WA_FCAT3-SELTEXT_M = 'SUB PACKAGE NUMBER'.
APPEND WA_FCAT3 TO IT_FCAT3.
CLEAR WA_FCAT3.
Page No : 312
IT_EVENTS = IT_EVENT3
TABLES
T_OUTTAB = IT_SER1.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
ELSE.
LOOP AT IT_RETURN1 INTO WA_RETURN1.
WRITE:/ WA_RETURN1-MESSAGE.
ENDLOOP.
ENDIF.
Enhanced BAPIs: -
Based on the client requirement if you add additional fields to the standard data base table. If you want to
update these fields information by using BAPI then we go for BAPI enhanced.
Page No : 313
BADI (Business ADD-INS)
BADIs are used to adding some additional functionality to standard functionality without disturbing the
standard functionality. BADIs are introduced from 4.6C version on wards. BADI contains 2 sections.
1. BADI Definition
2. BADI Implementation
Badi Definition:- Each BADI definition contains one adapter class and interface. Adapter class taking
care the version change management (When ever the version is changed if any changes required in the
BADI those are done by adapter class). Interface is the collection of methods which are defined not
implemented. Those are implemented through BADI implementation based on client requirement.
The transaction code for BADI definition is SE18.
BADI Implementation: - BADI Implementation is nothing but implementing the methods which are
defined in BADI definition. The transaction code for BADI implementation is SE19.
Note: - In the real time we never create our own BADI. We always use existing BADIs.
Types of BADI’S
There are 4 types of BADI’s
1. Single Implementation BADI
2. Multiple implementation BADI
3. Filter BADI
4. Custom BADI.
3. Custom Badi:
These are created by us (Technical people)
Page No : 314
4. Filter Badi:
It is type of BADI which has a filter value so that only those implementations which satisfy
the filter value are executed. The remaining implementations are not executed this type of
BADI is called a filter BADI.
Filter Badi is used to implement the same BADI multiple times with different conditions. If we want to
implement the BADI based on country specific then we go for filter BADI.
When ever we are working with cost center and profit center related BADIs then we must provide
filter type as controlling area.
When ever we are working with GL Account related BADIs then we must provide filter type as
chart-of-accounts.
When ever we are working with vendor & customer screen BADIs then we must provide filter
type as screen group.
If WITH IN SAP checkbox is selected then this BADI is only used by sap.
If multiple use checkbox is selected then it is a multiple implementation BADI.
If multiple use checkbox is not selected then it is a single implementation BADI.
If filter dependent checkbox is selected then it is filter dependent BADI. We need to specify
the filter type such as land1,bukrs,werks.for the filter BADI.
Page No : 315
Scenario 2: -
At the time of creating the vendor and customer some times MDM people provide the incorrect recon
account and cash management group. To avoid this we implement the BADI to preset the recon account
and cash management group based on given company code.
Scenario 3: -
At the time of creating the vendor and customer some times MDM people provide the invalid terms of
payment to avoid this we implement the BADI to preset the terms of payment based on the purchase
organization or sales organization.
Scenario 4: -
Against the vendor supplies, the warehouse department create a goods receipt with MIGO transaction 101
movement type. Against GR the finance people physically verify the stock & prepares the IR document.
Against IR document the account payable department pay the amount to the vendor with deducts of TDS
amount. After few days the vendor asks the Form 16 to finance people at the time of generating form 16,
the finance department must provide LR Number, Vehicle number, Transport name. These information
isn’t captured in the entire MM life cycle. Here we implement the BADI to attach additional subscreen
which contains above fields to MIGO transaction.
Page No : 316
Scenario 5: -
The warehouse people issue the goods
against cost center by using MIGO or MB1A
transaction code with 201 movement type. Some
times they entered invalid cost center. To avoid
this we implement the BADI to throw an error
message if they pass invalid cost center or cost
center not belongs to that plant.
Method 1: -
Execute ‘SE24’. Provide the object type as ‘CL_EXITHANDLER’. Click on display. Double click on
GET_INSTANCE method. Place the break-point on first call method. Now we execute our required
transaction (which transaction BADIs we want) in a separate session. Execute XK01. Enter. In the menu
bar click on debugger switch to classic debugger. Provide the field name as EXIT_NAME. Enter.
Identify the BADI (VENDOR_ADD_DATA). Continuously click on F8 button. Identify the all the BADIs
& maintained in Excel sheet. After delete the break point. Now open the each & every BADI in ‘SE18’.
(BADI Name: VENDOR_ADD_DATA). Click on display. Click on interface tab. Double click on each &
every method. Identify the input, output parameters. In the menu bar click on goto documentation to
component. Read the documentation if it satisfies our requirement then we implement this method through
SE19.
Note: - In the real time we always identify the BADIs with the help of functional people.
Method 2: -
Execute ‘SE93’. Provide transaction code (XK01). Click on display. Click on display object list (Ctrl +
Shift + F5). Expand the package in the left panel (FBK). Expand the enhancements. Expand the classic
BADIs definition. Identify the all the BADIs. Open the each and every BADI in SE18. Click on interface
tab. Double click on each method. Identify the input, output parameters. In the menu bar click on goto
documentation to component. Read the documentation. If it satisfies client requirement then we
implement this method through SE19.
Method 3: -
Execute SE93 transaction. Provide the transaction code(for which transaction Badi we want like
XK01/XD01). Click on Display. Identify the package. Go to SE84 transaction, expand enhancements,
expand Business Add-ins and select definition. Provide package name and execute, you will find list of
BADI's.
Implement the BADI to maintain the key information in an excel sheet at the time of create &
save the vendor. The key information is vendor number, company code, account group, name,
search term, street, city, postal code, country, created by, created date.
Implement the BADI to preset the Recon Account & cash management group based on the given
company code
When ever we are working with Preset BADIs then we must create one ‘Z’ table with preset fields and
based on which we want to preset the values and later the table data is updated by functional people.
Page No : 318
Based on this table data we preset the values. In this object we must create one ‘Z’ table with the
following fields.
1. MANDT Client
Input field
2. BUKRS Company code
(Based on this, we preset the values)
3. AKONT Recon Account
4. FDGRV Cash Management
And later this table data is provide by functional people based on this data we preset the values.
Page No : 319
Steps to work with Screen BADI: -
1. The Screen fields are added to standard data base table through append structure or create a table with
screen fields.
2. Based on this table fields we create the Module Pool program & sub screen.
3. This module pool program and sub screen is attached to standard transaction code by using Badi.
Page No : 320
modification – free enhancement of vendor master data. Enter. Click on new entries. Provide the screen
group (SP), short description (Screen group). Save. Select the screen group. Double click on label tab
pages. Click on new entries in the application tool bar. Provide the number (111), function code (SPF),
description (Tax details). Save, back to initial group.
If I_SCREEN_GROUP = ‘SP’.
E_ADD_ON_ACTIVE = ‘X’.
Endif.
Save, check, activate the method. Click on back. Save, check, activate the BADI.
Implement the BADI to throw an error message if they pass invalid cost center at the time of
goods issue against cost center.
In the real time they issue the goods against cost center in two ways.
1. MIGO transaction code with 201 movement type
2. MB1A transaction with 201 movement type
In the client first four digit of cost center is plant number.
1. BWART Movement type
2. KOSTL Cost Center
3. WERKS Plant
Page No : 321
Logic: -
If BWART = ‘201’.
If WERKS <> KOSTL + 0(4).
MESSAGE E000 (ZMESSAGE1) WITH ‘COST CENTER ISN’T BELONGS TO THIS PLANT’.
ENDIF.
ENDIF.
Enhancement Spot: -
Enhancement Spot is the collection of BADI definitions. If you want to create a BADI then first we create
the enhancement spot. In that we create the BADI definition.
Page No : 322
LSMW LSMW
(Legacy Systems Migration Workbench)
LSMW is used to upload the data from file to SAP system.
Page No : 323
STEP 6 Specify files: Click on execute. Click on change mode. Select the legacy data on the PC
(Frontend). Click on create or adding on top. Browse the filename. Provide short description. Select the
delimiter is comma, enter. Save, back.
STEP 7 Assign files: Click on execute. Click on change mode. Save, back.
STEP 8 Read data: Click on execute. Click on execute. Back, click on back.
STEP 9 Display read data: Click on execute. Enter. Click on back.
STEP 10 Convert data: Click on execute. Click on execute. Back, click on back.
STEP 11 Display converted data: Click on execute. Enter. Back.
STEP 12 Create batch input session: Click on execute. Select the check box keep. Execute. Enter.
STEP 13 Run batch input session: Click on execute. Select the session name. Process. Click on process.
Next on wards the end user execute the same LSMW from 6th step on wards for each flat file.
Steps to create the request number to LSMW: - In the menu bar click on extras Generate change
request. Click on create request. Provide the short description. Enter.
Develop a conversion program to upload the vendor master data from flat flie to SAP system by
using LSMW. (Direct input method). The flat file contains vendor numbers, names & search terms.
Steps: Execute LSMW. Provide project name, sub project name & object name. Provide short description.
Execute.
STEP 1 Main Object Attributes: Click on execute. Click on change mode. Select the radio button.
Standard batch/ direct input method. Select the object – (0040), select the method (0001) [standard]. Save,
back.
STEP Maintain Structure Relations: Click on execute. Click on change mode. Select our required
structure & click on relationship. Here we establish the relationship to BLA1. Save. Back.
STEP Maintain field mapping and conversion rules: Click on execute. Click on change mode. Select
the transaction code field. Click on rule. Select the constant. Enter. Provide the transaction code (XK01).
Enter. Provide the rest of the mandatory (LIFNR, NAME1, SORTL are link from source field & KTOKK,
LAND1 are link from Rule). Save, back.
Rest of the steps are same as previous method.
Events in LSMS:
1. Global Data
2. Begin_of_processing
3. Begin_of_transaction
4. End_of_transaction
5. End_of_processing
Page No : 324
Global data: - It’s an event which is used to declare the variables, work areas & internal tables which are
needed to implement the logics.
Begin_of_processing: - It’s an event which triggered at the time of entire flat file processing start.
Begin_of_transaction: - It’s an event which is triggered at the time of each record processing start.
End_of_transaction: - It’s an event which is triggered after completion of each record processing.
End_of_processing: - It’s an event which is triggered after completion of entire flat file processing.
Note: - LSMW events are available in 5th step. That field mapping & conversion rules.
Develop a conversion program to update the vendor city from flat file to SAP system by using
LSMW (batch input recording method). Through XK02 transaction. The flat file contains vendor
numbers & cities & also download the error vendor which aren’t created.
Execute LSMW. Provide the project name, sub project name, object name. Click on create. Provide short
descriptions. Execute Maintain object attributes. Execute. Change mode. Select the radio button batch
input recording. Click on over view icon in the right side. Select the recording. Click on create. Provide
the recording name (SXK02). Short description. Enter. Provide transaction code (XK02). Enter. Provide
the vendor which is already created. Select the address check box. Enter & update the city. Click on save.
Click on default all.
Note: - When ever we are working with update transaction then we must remove the other than flat file
fields recording steps from recording.
Here we remove the NAME1, SORTL, LAND1 recording steps by using ( - ) screen field in the
application tool bar. Save, back. Click on back. Provide the recording name. Save, back.
In main field mapping and conversion rules: execute. Click on change mode. Provide the mapping.
(LIFNR ORT01 from source field, D0110 from rule constant as X). Click on layout (Ctrl + F7) in the
application tool bar. Select the Global data definitions, Processing time check boxes. Enter. Then we get
the events. Double click on global data. Declare the work area & internal tables.
Data: Begin of wa_error,
LIFNR type lfa1-lifnr,
End of wa_error.
Data it_error like table of wa_error.
Data V type lfa1-lifnr.
Click on save. Check, back. Click on save. Double click on begin of transaction. Implement validation
logic.
Select single lifnr from lfa1 into V where lifnr = itab1-lifnr.
If sy-subrc <> 0.
Wa_error-lifnr = itab1-lifnr.
Append wa_error to it_error.
Skip_transaction.
Endif.
Save, check, back. Double click on end of processing.
Call function ‘GUI_DOWNLOAD’
EXPORTING
FILE NAME = ‘C:\VIDYA.TXT’
WRITE_FIELD_SEPERATOR = ‘X’
TABLES
DATA_TAB = IT_ERROR.
Save, check, back. Save, back. Rest of the steps are same as previous one.
Page No : 325
Note: - When ever we are working with BAPI methods & idoc methods then we must create a file port
in WE21 transaction. In the real time file ports are provided by BASIS people.
Note: - In the LSMW BAPI and Idocs methods acts like inbound.
Steps to create file port: - Execute WE21. Expand the file. Select the SUBSYSTEM file port. Click on
copy in the application tool bar. Provide the to port (SPT). Enter. Select the check box Unicode format in
system settings. Click on save.
Develop a conversion program to upload bank details from flat file to SAP system by using
LSMW (BAPI method) the flat file contains bank country key, bank key & bank name.
STEPS Execute LSMW. Provide project name (ZSFI), sub project name (ZSBAN), object name (ZSBC).
Click on create. Provide short description. In the menu bar click on settings IDOC inbound processing.
Provide the file port (SPT). Partner type (LS), partner number (SP800). Click on activate idoc inbound
processing. Click on yes. Save, back, execute.
Maintain object attributes: -Execute. Click on change mode. Select the radio button BAPI. Select the
business object of Bank (BUS1011), method (Create), save, back.
STEP Start idoc generation: execute, click on execute.
STEP Start IDOC processing: Execute. Click on Execute & absorb the status. If the status is ‘53’, it’s
success.
Develop a conversion program to upload customer master data from flat file to SAP system by
using LSMW (Idoc method). The flat file contains customer number, names, search terms & street.
STEP Execute LSMW. Provide project (ZSSD), subproject (ZSCUS), object. Click on create. Provide
short descriptions. In the menu bar click on settings idoc inbound processing. Provide the file port
(SPT), partner type (LS), partner number (SP800). Click on activate Idoc inbound processing. Click on
back. Execute.
STEP Maintain object attributes: Execute. Click on change mode. Select the radio button IDOC. Provide
the message type (DEBMAS), idoc type (DEBMAS06). Save, back.
Hai friends, this is Sathish Reddy. If you find any mistake in this material please send me mail to
[email protected]
Thank you.
Your friend
Page No : 326