This action might not be possible to undo. Are you sure you want to continue?
System Application and Products for
data processing (SAP)
Ìnternational Demo and Education
· Ìn today's dynamic and turbulent business environment, there is a strong need for the
organization to become globally competitive.
· The survival guide to competitiveness is to be closer to the customer and deliver
value added product and services in the shortest possible time.
· This, in turn, demands integration of business processes of an enterprise.
· Definition - Enterprise Resource Planning (ERP) is such a strategic tool, which helps
the company to gain competitive edge by integrating all business processes and
optimizing the resources available.
· Over the years the need to integrate the new techniques, led to the development of a
total integrated solution called Enterprise Resource Planning (ERP).
· ERP attempts to integrate the suppliers and customers with the manufacturing
environment of the organization.
TechnoIogies that made ERP a reaIity
· Ìt is not possible to think of an ERP system without sophisticated information
· Ìt is said that, ERP is the finest expression of the inseparability of business and
· The incremental improvement in the information technology and the drastic reduction
in prices of computers have made it possible even for the small organization to think
about ERP systems.
· Earlier ERP systems were built only to work with huge mainframe computers.
SingIe -Tier Architecture
· Features :
Ìt has a single monolithic executable file.
Ìt has both programs and data on one computer.
Time required to update the application is high.
Cost of redistributing the application is high.
· Client :
· Ìmplement the user interface.
· Contains application logic.
· Stores Data.
· Contains business logic.
The benefits of the two-tier modeI :
· Data sharing÷The data is separated from the client side and is stored in a central
place to which all the users have access. As the data is stored at one central
location, it reduces data redundancy and provides consistent data to all the users
accessing the system.
· Reduced duplication and maintenance÷Since data is stored centrally, data
maintenance is easy. There is no duplication of data and hence, no inconsistency in
the data stored.
Disadvantages of two-tier architecture :
· Excessive load on the server.
· High network traffic.
· Difficulty in implementing incremental improvements.
· Applications are being bound to the data stored.
· User Services - Provide services such as the user interface.
· Business Services - Ìmplement business rules.
· Data services - Provide handling and validation of data.
Introduction to Databases
· A database system is an integrated collection of related files, along with details of the
interpretation of the data contained therein.
· A DBMS ( Database Management System ) is a software system that allows access
to data contained in a database.
· The objective of DBMS is to provide a convenient and effective method of defining,
storing, and retrieving the information contained in the database.
· The DBMS interfaces with application programs, so that the data contained in the
database can be used by multiple applications and users.
· The DBMS system allows users to access and manipulate the data contained in the
database in a convenient and effective manner.
· Ìn addition the DBMS exerts centralized control of the database, prevent
unauthorized users from accessing the data, and ensure the privacy of data.
DBMS VS RDBMS
· RDBMS is object based and relation is more important than object.
· More than one user can access the tables in RDBMS which is not possible in DBMS
· Client-Server architecture is not supported by DBMS
· Security is not there in DBMS and generally used by small organization for handling
less amount of data
ReIationaI Database Management System
· Relational Data Model (RDM) was formally introduced in 1970.
· The relational model frees the user from details of storage structures and access
· Ìt is conceptually simple and, more importantly based on sound theoretical principles
( relational algebra ) that provide formal tools to tackle problems arising in database
design and maintenance.
· RDM consists of three basic components:
÷ A set of domains and a set of relations.
÷ Operations on relations
÷ Ìntegrity rule
· Some of the Database systems supported by SAP are:
÷ DB2/400 (uses EBCDÌC codepage).
÷ Microsoft SQL Server
· SAP R/3 is an example of ERP system.
· SAP R/3 (System Application and Products for data processing) a German software
company founded in the 70's by a group of former ÌBM employees.
· R/2 systems first developed by SAP were mainframe based applications offering only
a subset of R/3's current functionality. R/2 ( Real time two-tier architecture ) systems
are based on Two-tier architecture.
· The modern client-server version of R/3 ( Real time three-tier architecture ) was first
introduced in 1992 and has become the most popular ERP system in the world.
· R/3 is based on a client/server architecture and use a relational database to track all
information related to a corporation.
· R/3 is basically a large collection of small programs called transactions.
· A transactions consists of ABAP code, and an associated set of screens that can be
used to enter, change or display data.
· Collection of related transactions are grouped together into a module.
· A module is a set of transactions that deal with the same area of business
Some of FunctionaI ModuIes supported by SAP
· Production Planning (PP).
· Materials Management (MM).
· Sales and Distribution (SD).
· Financial Accounting/Controlling (FÌ/CO).
· Project System (PS).
· Fixed Assets Management (AS).
· Work Flow (WF).
· Ìndustry Solution (ÌS).
· Human Resources (HR).
· Plant Maintenance (PM).
· Quality Management (QM).
ogicaI Representation of R/3 System
erneI and Basis system
The kernel & basis services component is a runtime environment for all R/3 applications
that is hardware, operating system and database-specific. The runtime environment is
written principally in C and C++. However, some parts are also written in ABAP. The
tasks of the kernel and basis services component are as follows:
· Running applications - All R/3 applications run on software processors (virtual
machines) within this component.
· User and process administration - The R/3 System is the only user of the host
· Database access - The applications don't communicate directly with the database.
Ìnstead, they use Basis services.
· Communication - R/3 applications can communicate with other R/3 Systems and with
non-SAP systems using a BAPÌ interface. The services required for communication
are all part of the kernel and basis services component.
· System Monitoring and Administration - The component contains programs that allow
you to monitor and control the R/3 System while it is running, and to change its
R/3 System Architecture
· Presentation Server ÷ Ìt is actually a program named SAPGUÌ.EXE,usually installed
on user's workstation.
· AppIication Server ÷ Ìt is a set of executables that collectively interpret the ABAP/4
program & manage input & output for them.
· Database server ÷ Ìt is a set of executables that accept request from AS.These
request are passed on to RDBMS
Structure of a AppIication Server
· All requests that come in from presentation servers are directed first to the
dispatcher. The dispatcher writes them first to the dispatcher queue. The dispatcher
pulls the requests from the queue on a first-in, first-out basis. Each request is then
allocated to the first available work process. A work process handles one request at
omponents of a Work Process
· A task handler.
· An ABAP/4 interpreter.
· A screen interpreter
· A database interface.
Types of Work Processes
· D(Dialog) Dialog requests.
· U(Update) Requests to update data in the database.
· B(Background) Background jobs.
· S(Spool) Print spool requests.
· E(Enqueue) Logical lock requests.
· M(Message) Routes messages between
application servers within an R/3 system.
· G(Gateway) Funnels messages in to and
out of R/3 system.
Work process uses two special memory areas to perform its functionality:
· User ontext ÷ Ìt is memory on AS containing characteristics of user that is logged
on R/3 system.
- User's current settings
- User's authorization
- Name of urrent Program.
· RoII Area ÷ Ìt is memory on AS that is allocated by a work process for an instance
of a program.
- VaIues of variabIes
- Dynamic memory aIIocation
- urrent program pointer
DeveIopment Iass (Package)
· A development class groups objects that are logically related. A development
class is a type of development object. Ìt is called as Package in 4.7 version.
· The development classes are described in table TDEVC.
· A change request records the changes made to a development object.
· Use TCODE SE80 for creating development class
· Use TCODE SE09 (transport organizer) for display of development class &
· Use TCODE SE01 for creating request number individually without creating
development class (Package).
· USE TCODE SM01 for displaying all TCODE in system
· Use TCODE SM12 for LOCK ENTRY.
Data Dictionary Objects (SE11)
Ìt is a utility for defining data objects :
· Database tabIe
· Data eIement
· TabIe type
· Search HeIp
· ock Object
· Type Group (Type PooI)
· TabIe PooI / TabIe Iuster
Types of TabIes in R/3 System
· Transparent tables.
· Pooled tables.
· Cluster tables.
omponents of a Database TabIe :
· Table object.
· Data element object.
· Domain object.
· Technical settings
TabIe Object : Represents a table in the ABAP data dictionary.
FieIds : Define information stored in the table.
Transparent TabIes :
1. A transparent table in the dictionary has a one-to-one relationship with a table in the
database. Ìts structure in R/3 DDÌC corresponds to a single database table.
2. For each transparent table definition in the dictionary, there is one associated table
in the database.
3. Transparent tables are used to hold application data.( master or transaction data)
Data EIement and Domain Object
· Data EIement : Ìt is a semantic characteristics of a table field Data elements appear
as objects in the dictionary. Because they are objects in their own right, you can
reuse data elements within the same table or among fields in several tables.
- Domain name
- Field label
- F1 documentation : TCODE ÷ SE61.Type name of document and select document
class & language. Use this document name as a reference to link with another
document in which you have selected a text which is to be hyperlinked. Ìnsert -> link
-> document class, name.
· Domain : Ìt is a technical characteristics of a field. A domain specifies information like
data type , length & decimal places. Like data elements, domains are stored as
objects in the Dictionary. You can reuse domains just as you can reuse data
· onversion Routines :
These are the function modules used to convert the contents of a screen field from
display format to sap internal format (Ìnput conversion) & vice versa (output
conversion). Ìt is automatically called when values are saved/displayed in screen field
which refers to domain with conversion routine & also when contents of field are
output with write statement.
DeIivery Iass and Parameter ID
· DeIivery Iass : Ìt is used during installation, upgradation, client copy, transporting
between customer systems & in extended table maintenance. The value in delivery
class field identifies the 'owner' of the data in this table.
A ÷ Application table
÷ Customizing table
÷ Table for storing temporary data
G ÷ Customizing table, protected against SAP updation
E ,S,W ÷ System table.
· Parameter ID : A field can be filled with default value from SAP memory using a
parameter ÌD. Fields referring to data element are then automatically filled with this
value in all subsequent screen templates.
· TechnicaI Settings : Specify how the R/3 system handles a table.
- Data class
- Size category
- Buffering permission
- Buffering types
Data Iass and Size ategory
· Data Iass : Ìt determines the tablespace. A tablespace is a physical file on
disk that is used to hold tables. Every table is assigned to one tablespace.
Tables with similar characteristics are usually grouped into one tablespace.
APP0 ÷ Master data
APP1 ÷ Transactional data
APP2 ÷ Organizational data
USER,USER1 ÷ Customer data class
· Size ategory : Ìt enables you to specify the maximum no. of records
(ÌN BYTES) you expect this table to hold.
- Ìnitial extent
- First extent
- Second extent
Buffer Synchronization & Buffering Permission
· Buffer Synchronization : Ìf you have two application server, the same record can be
buffered on each server. Ìf a buffered record is updated in one AS, it will update the
DB. But the changes must be communicated to other AS. This is done in the process
known as buffer synchronization, which occurs at 1- 4 min. interval depending on your
system configuration. At a predefined interval, each synchronization process checks
the synchronization log on DB server to see whether any buffered data has been
modified. Data that has been modified is marked invalid in buffer. The next time that
new data is read from DB.
· Buffering Permission
- Buffering not aIIowed : Ìf application program needs most recent data from table or
table is updated too frequently.
- Buffering aIIowed but switched off : From technical point of view, buffering is
permitted. Whether or not table buffering result in gain in performance depends on
table size & frequency of accessing table. Buffering is switched off because it is not
possible to know that these values will be in customer system. You can switched on
buffering at any time if buffering is advantageous for table size & access profile.
- Buffering switched on : Ìf table should be buffered.
· FuII buffering: All records of table are loaded into buffer when one record of table is
accessed. Tables best suited for this are small (up to 30 KB), read frequently & rarely
written. Generic/full table buffer TABL is used
· Generic buffering: All the records with respect to generic key fields are loaded into
buffer. Generic key is a part of primary key that is left justified. Mention no. of key
fields. Generic/full table buffer TABL is used
· SingIe record buffering: Only the record that are actually read are loaded into buffer
one by one.Single record table buffer TABLP is used.
Buffering Database TabIes
· You can reset the table buffers on application server by entering $TAB in command
field. All the data in buffer is invalidated.Ìt can take several hours in large systems.
· Only tables that are rarely written (read only) or for which temporary inconsistencies
are of no significance should be buffered.Tables whose entries are frequently
modified should not be buffered.Otherwise there would be constant invalidation &
reloading which would have negative effect on performance.
Ìt contains the information about the object that is relevant for ABAP programs &
screen. Ìt is generated the first time when object is activated & next version of object
is adjusted after each time it is activated. Tables, views, data element, structure, table
type have runtime object. Time stamp ABAP (ABAP program ) & time stamp DYNP
(screen) are used to ensure most up to date information.
Index and Database UtiIity (SE14)
· Index : Ìt is an efficiency mechanism for quickly finding rows within a table. Ìt supports
where clause in select statement to find a row. Row number to each record is
assigned by the database internally. Primary index is created automatically with ÌD 0
(zero).Ìt consists of all Primary keys . Secondary index can be any other number or
alphabetic character. When multiple index exist, RDBMS uses an optimizer to pick
- Max. 15 number of secondary index .
- Avoid overlapping indexes.
- Use SQL trace tool to find which index has been used (TCODE ÷ ST05).
- Do not add unnecessary indexes.
- Make indexes very selective.
· Database UtiIity: Ìt is the interface between DDÌC & database. Ìt allows you to create,
delete & adjust database objects from DDÌC objects. Transparent tables, views,
pools/clusters can be edited by using SE14. You can also edit index in SE14.
3. Mass processing - System table TBATG is used. Request collected in this table is
processed in background at fixed time. For Scheduling jobs, initial screen->extras
->schedule job. For displaying request for mass processing, DB request->mass
Ìf you want to activate a large set of objects simultaneously, you can use mass
activation with program RADMASG0. Screen inputs are:
· Transport request
· External table ÷ You can define table TACOB as external table.All objects in this table
· Direct objects ÷ The objects to be activated can also be entered directly with an input
Ìt defines whether the table can be activated from ABAP dictionary directly or
whether runtime object of table must be generated with C program.Ìt is
optional & only important for tables of runtime environment.
- 00 (default)
Refer On line help.
Restrictions on TabIes
· Max 16 key fields allowed.
· Max length of table key is 255.
· Table may not have more than 249 fields.
· Sum of all field length is limited to 1962 (excluding length of LCHR &
· Fields of LRAW or LCHR must be at the end of table.Only one such field is
allowed per table. There must also be a field of type ÌNT2 preceding this
· Ìf addition of all key length is larger than 64, the table can not be buffered
generically. And if larger than 120,table can not buffered.
· CURRENCY & QUANTÌTY field should not be used as a primary key as
buffering not possible, transport restricted.
Foreign key & Primary key
· The attribute ( or combination of one or more attributes ) which can uniquely
identify the instance of a set is called primary key.
· A foreign key is an attribute or set of attributes of a relation, such that the
value of each attribute in the set is that of a primary key of the related set.
TechnicaI requirements for creating F
· The corresponding field in check table must be primary key.
· The domain names for FK field and check table field ( or technical
characteristics ) must be same.Data elements name may be different.
Generic & onstant F
· Generic FK ÷ A tick mark in generic check box causes a field to be ignored
during FK check.
· Constant FK ÷ Ìf a constant value is entered on create FK screen, those
record in check table which contains these constant values are valid for FK
Understanding ardinaIity & Foreign ey FieId Type
· ardinaIity : Ìt describes, for each value in check table,how many rows of data are
allowed to be in FK table.Cardinality is described as X:Y. X refers to the check table.
Y refers to the foreign key table.
The value of X means.
1 : Deletion of master record from check table deletes corresponding records from the
foreign key table.
: Deletion of master record does not affect the foreign key table records.
The value of Y means:
1 : There is always one & only one row in foreign key table for each row in check table.
: There is, at the most, one row in foreign key table for each row in the check table.
N : There is always at least one row in foreign key table for each row in check table.
N : There might or might not be rows in foreign key table for each row in check table.
· Foreign ey FieId Type:
- Not specified
- Key fields/candidates.
- Non-key fields/candidates.
- Key fields of a text table.
· Cardinality & foreign key field type is mandatory only in
- Text table
- Help view
- Maintenance view
Text TabIe and VaIue TabIe
· Text TabIe : Table A is a text table (FK table ) of table B( Check table ) if
primary key of table A is same as primary key of table B with the addition of a
language key field ( data type LANG).Table A may therefore contain
explanatory text in several languages for each key entry of table B. Every
table can have only one text table. Always mention Foreign key field type ->
key fields of text table and Cardinality -> 1 : N.
· VaIue TabIe : Domain contains the value table option. Ìt automatically
propose the check table when creating a foreign key relationship.
· Reference FieId :
URRENY field must be linked to a field of data type UY.
QUANTITY field must be linked to a field of data type UNIT.
Reference table can be the same table or any other table.
Structures in DDI
· Definition : A structure is a series of fields grouped together under a common name.
· Difference between structures and tables :
- A structure does not have an associated database table.
- A structure does not have a primary key.
- A structure does not have technical settings & indexes.
· Types of structures :
1. Flat structure - A structure whose each field either refer to a data element or direct
2. Nested structure - A structure which refer at least one further structure.
3. Deep structure - A structure which refer at least one table type.
· Adding Structures to a TabIe :
- .INU-XXX ( group name & name suffix )
- APPEND STRUTURE : The chain of structures created by including one structure
within another is called an include chain. The maximum depth is nine & only one
table type can be included in an include chain. APPEND structure is assigned to
exactly one Table / structure. There can be, however, several APPEND structure to
table/structure. The fields in append structure have a name starting with ZZ or YY.
Important TabIes for MM
· MARA --- material master
· MAKT --- material description
· MARM --- unit of measure
· MARC --- plant data for materials
· MLAN --- tax classification for materials
· MARD --- storage location for materials
· MBEW --- material valuation
Important TabIes for Vendor
· LFA1 --- vendor master ( general info)
· LFB1 --- vendor master ( company code)
· LFM1 --- vendor master purchasing org info
· LFBK --- vendor master bank details
· LFC1 --- vendor master transaction info
· LFM2 --- vendor master purchasing info
Important TabIes for Purchase Order
· EKKO --- Purchasing document header
· EKPO --- Purchasing document item
· EÌNA --- Purchase info record (general data)
· EORD --- Purchasing source list
· EÌNE --- Purchase info record (organization data)
· EKET --- delivery schedules
Important TabIes for Purchase Requisition
· EBAN --- Purchase requisition
· EBKN --- Account assignments
Important TabIes for Goods Receipt
· MSEG --- Document segment:material
· EKBE --- History of purchasing document
· MVER --- Material consumption
· MKPF --- Header: material document
· SO31 --- Statistics: movements for current
Important ustomer TabIes
· KNA1 ÷ general customer info
· KNB1 ÷ customer master company code
· KNVV ÷ customer master sales info
· KNBK ÷ customer bank details
· KNC1 ÷ customer transaction details
· KNVP ÷ customer master partner functions
Important SaIes TabIes
· VBAK --- Sales document header
· VBAP --- Sales document item info
· VBEP --- Sales document:schedule line
· VBEH --- Schedule line history
· VBUK --- Header status
· VBUP --- Ìtem status
· VBFA --- Sales document flow
Important Shipping/DeIivery/BiIIing TabIes
· LÌKP --- Sales doc:delivery header
· LÌPS --- Sales doc:delivery items
· VTTP --- Shipment item
· VTTK --- Shipment header
· VTFA --- Shipment doc. Flow
· VBLK --- delivery note header
Important BiIIing TabIes
· VBRK --- Billing : header data
· VBRP --- Billing : item data
· KONV --- Condition table
A view is a virtual table which is used to access the data of
multiple database tables.
Types of Views :-
÷ Database view.
÷ Projection view.
÷ Maintenance view.
÷ Help view.
· Ìt access the data of one or more database tables.
· Ìf it is created on more than one table it can be used
only for reading.
· Ìt implement an inner join.
· Ìt only contain transparent tables.They may or may not
have FK relationship.
· Ìt can be used in ABAP program with open & native
· Ìt has corresponding object in database.
· Append view & technical settings is possible .
· Ìt is used to access few or all columns of a single DB table for
reading & writing data.
· Can not specify selection conditions.
· Ìt can be used in ABAP program.
· Ìt can access pooled & cluster tables also.
· There is no corresponding object in DB.
· To update the data of one or more tables at a time.
· Transaction Codes associated with MV:
SE54 - Generate tabIe maintenance diaIog.
SM30 - Extended tabIe maintenance.
· Ìt implement both inner join and left outer join.
· FK relationship is compulsory between tables.
· Ìt can not be used in ABAP program.
· All key fields of primary & secondary tables must be
included in MV.
· You can insert tables that are linked by FK with one of
secondary tables that was already inserted.
· Cardinality & FK field type is mandatory in MV.Ìf secondary
table is dependent table, cardinality can be 1:1 or 1:C. Ìf
secondary table is reference table, cardinality can be 1:N or
· The key fields must be defined before other fields.They must
not be mixed.
· Maintenance attribute (p) has to be defined like
R,S,H,<space>.Refer on line help.
· Ìn SE54 , Mention function group,Authorization group,
maintenance Type (one or two step) & screen number for
overview & single screen.
· Ìt is used while creating search helps for providing F4 help.
· Ìt implement outer join.
· FK relationship is compulsory between tables.
· Ìt can not be used in ABAP program.
· Not necessary to include all key fields of secondary tables in
· You can insert tables that are linked by FK with one of
secondary tables that was already inserted.
· Cardinality & FK field type is mandatory in HV.Ìf secondary
table is dependent table, cardinality can be 1:1 or 1:C. Ìf
secondary table is reference table, cardinality can be 1:N or
Ìt is a input help (F4 help), a standard function of R/3 system. Used to display possible
input values for a field in screen template and are basically of two types:-
EIementary & oIIective.
Elementary search help provides a single search path.
Collective search help provides collective elementary search path.
· omponents of Search HeIps:
SeIection method - tables & views (database, projection & help).DB view for inner
join & help view for outer join.
Search heIp parameters - copied from corresponding selection method.
Search heIp exit - Ìt is a function module used to deviate a standard flow of input
help process. F4ÌF_SHLP_EXÌT_EXAMPLE is used as pattern for all search help to
be created. Help processor calls search help exit at following times:
- Before displaying dialog box
- Before selecting data
- Before displaying hit list
- Before returning values to screen template.
Some of the names of predefined search help exit:
Import & export parameters - Ìmport parameters are used to copy context
information from screen template to help process .Export parameters are used to
return values from hit list to screen template.
DiaIog type -
- Ìmmediate value display
- Complex dialog with value restriction
- Dialog depending upon no. of entries
Hot key - Ìt is used to select elementary search help from collective search help &
to enter restrictions in dialog box to restrict values from entry field.The short cut must
be entered in input field like
pos - defines position of parameter in hit list.
Spos - define position of parameter in dialogbox.
Sdis - Used for import parameter or default value which can not be changed.
Note: Elementary search help in collective search help can have different number &
types of parameters.Not all of the parameters need to be assigned.
Hierarchy of Search HeIp
Append Search HeIp: An append search help is used to enhance a collective search help (not
elementary search help) by further search paths (elementary search helps). This technique can be
used by special developments,sap partners & sap customers.Structure of append & corresponding
collective search help must be same.Parameters of both search helps having same name are
assigned to one another.Go to -> append search help.
· The objects which synchronizes simultaneous access of several users to the same
data records with lock mechanism.
· Lock objects name starts with EY or EZ.
· Every lock object when activated creates two function modules:
Enqueue_<Iock object name>: For setting Iocks.
Dequeue_<Iock object name>: For reIeasing Iocks.
· All tables included must be linked with FK. FK fields must be key fields of FK table.
· The lock argument of a table in the lock object consists of the key fields of the table.
· Use TCODE SU01 for creating new user name.
· Exclusive & cumulative : The locked data can only be displayed or edited by a
single user. Ìt can be requested several times from the same transaction and are
· Shared : More than one user can access locked data at same time in display mode.
· Exclusive not cumulative : The locked data can only be displayed or edited by a
single user but it can be called only once from the same transaction.
Structure of ock Objects
Parameters of Function ModuIes
· FieId name
· X_<fieId name>: Ìf <field> = initial value & X_<field> = initial value -> generic
lock.Ìf <field> = initial value & X_<field> = X ->lock is set with exactly initial
value of <field>.
· Mode_<tab>: E,S,X for each table.
· _Scope : 2 for enqueue & 3 for dequeue.
· _Wait : Ìf _wait = initial value & if there is competing lock,a lock attempt
fails. Ìf _wait = X & if there is competing lock,lock attempt fails for first time.
Lock attempt is repeated after waiting for certain time. FOREÌGN_LOCK
exception is triggered only if certain time is elapsed.
· SYSTEM_FAÌLURE exception is triggered when problem occurred while
· Ìt is also called as type group.SE11->utilities-> other dictionary objects.
· Ìt is used to define ONSTANTS & TYPES whose name always starts with
<type pool name>_.
· Ìnclude type pool in ABAP program like
TYPE-POOS <type pooI name>.
You can use constants & types in ABAP program.
Ìt defines the structure & functional attributes of an internal table in ABAP
program. You can use table type in ABAP program by using TYPE in data
statement & TYPES statement.
· Row type - Data element (elementary row type),structure,table,view
(structure row type), table type,built in type.
· Access mode:
TabIe Search Access time Access by
Standard Sequential Linear on no of entries Ìndex, key
Sorted Binary Logarithmic on no of entries Ìndex, key
Hashed Hash proc. Constant Key
Index : Ìt can be standard or sorted table.Ìndex is used to access such
tables used in function modules & subroutines to define generic parameters.
Not specified : Ìt can be standard ,sorted or hashed table.Ìndex can not
be used to access this table.table type becomes generic.
· ey definition :
1. Standard key - Ìf structured row type,key components are character like
components.Ìf elementary row type,key components consists of entire table
row.Ìf table type as row type,key components are empty.
2. ine type - Key components consists of entire table row.
3. ey components - Key components is defined by selecting components
from structured row type.
4. ey not specified - Table type becomes generic.
· ey category - Ìnternal table may have unique or duplicate entries.
Access mode Key category
not specified not specified
index tabIe not specified
standard tabIe non-unique
sorted tabIe unique or non-unique
hashed tabIe unique
Generic TabIe Type
· A table type which does not define all the attributes of internal table.A table
type is generic in following cases:
- access mode -> index table,not specified
- key definition -> not specified
- key category -> not specified
· Generic table types can not be used to define data objects with DATA
statement or data types with TYPES statement.
Ranges TabIe Type
· A table type which define structure & functional attributes of internal ranges
table in ABAP program.
· Ranges tables can be used in logical condition (ÌN operator) in select, if,
while & check statements or to pass data to selection tables.
· Components of ranges table type:
SÌGN ÷ data element DDSÌGN
OPTÌON ÷ data element DDOPTÌON
LOW ÷ user defined data element or built in type
HÌGH ÷ user defined data element or built in type
· Access mode (default) ÷ standard table,standard key with non-unique
TabIe PooIs & PooIed TabIes
· Table pools are the tables in DB in which all records from pooled tables are stored in
specific logical manner.Tables assigned to table pool are referred to as pooled tables.
· There is always many to one relationships between pooled tables & table pools.
· The data from several different tables can be stored together in a table pool/table
cluster. A table pool/table cluster should be used exclusively for storing internal system
data (screen sequence, program parameters, temporary data, documentation). All
commercial data is stored in transparent tables.
Structure of TabIe PooI :
FieId Data type Meaning
Tabname CHAR(10) Name of pooled table
Varkey CHAR (n) Contains the entries from all key fields of the
pooled table record as a string, max. length for n
DataIn ÌNT2(5) Length of the string in Vardata
Vardata RAW (n) Contains the entries from all data fields of the
pooled table record as a string, max. length n
depends on the database system used.3800 for
Restrictions of TabIe PooIs
· The name of a pooled table may not exceed 10 characters.
· Since 'arkey is a character field, all key fields of a pooled table must have
character data types (for example, CHAR, NUMC, CLNT).
· The total length of all key fields or all data fields of a pooled table must not
exceed the length of the 'arkey or 'ardata field of the assigned pool.
1. SE11-> utilities -> other dictionary objects -> table pool.
2. GOTO-> technical settings->size category.
4. Utilities->database utility->create db table
5. To create pooled tables,first create transparent tables.change table
category to pooled table by Extras->change table category.
6. Mention name of table pool in attributes.
Note: To create table pool in db (in 4.6 version only), use database utility->
create db table (unlike transparent table where after activation,db table
is automatically created).
TabIe Iusters & Iuster TabIes
Structure of TabIe Iuster
Field Data type Meaning
Varkey HAR (n) Contains the entries from common key fields of
cluster table record as a string, max. length for n
is 120.Ìt is also called as cluster key. There can
be multiple cluster key in table cluster and it
must exist in cluster tables too.
Pageno INT2(5) Number of continuation record
Timestamp HAR(14) Time stamps
PageIg INT2(5) Length of the string in Vardata
Vardata RAW (n) Contains the entries from the data fields &
uncommon key fields of the assigned cluster
tables as a string, max.length n depends on
database system used.3800 for oracle.Ìf string
exceeds max. length,a continuation record is
written on next page by using field pageno.
PooIed Vs Iuster TabIes
· Pooled tables may or may not have primary key fields in common but cluster
tables must have at least one primary key field in common.
· Table pools are used to hold data from a large number(tens to thousands) of
very small tables.Cluster tables are used to hold data from a few ( 2 to 10)
very large tables.
Restrictions on PooIed/Iuster tabIes:
· Secondary indexes can not be created.
· Can not use ABAP distinct, Join or group by in select statements.
· Can not use native SQL statements.
· Can not specify field names after order by clause. Order by primary key is the
only permitted version.
Structure of ABAP Program
· Declaration part for global data, classes & selection screens.
· Calling processing blocks
· Processing Blocks:
- Dialog modules
- Event blocks
- Procedures (methods, subroutines, function modules)
Types of Screens in ABAP:
Screens send data to program, receive data from program & react to user's interaction.
- DiaIog Screens : Can create entire screen & flow logic using (SE51) screen painter.
Used for input & output.
- SeIection screens : Used to enter values in ABAP program. Can be created using
ABAP statements. Used for input only.
- ists : Output screens which display formatted data.
ABAP Program Types
· Type 1 : Executable /Report programs.Only selection screens & lists are used.
· Type M : Module pool program.Controlled by screen flow logic.Define screen in screen
painter. Can set screen statically or dynamically. can call selection screens,lists,other
programs (type 1 & M).Can start by Tcode.
· Type F : Function group.Containers for function modules.Can not executed or started
by Tcode. Also contain global data & subroutines visible to all function modules.Also
contain event blocks for screens in function modules.SE37 ,function builder,is used to
create function group & function module.
· Type : Class pool.Containers for global classes in ABAP objects.Can not executed
or started by Tcode.SE24,class builder,is used to create class definitions.
· Type J : Ìnterface pool.Containers for global interface in ABAP objects.Can not
executed/started by Tcode.SE24,class builder,is used to create interface definitions.
· Type S : Subroutine pool.Container for subroutines. Can not contain screens.Can not
executed or started by Tcode.
· Type I : Ìnclude program.Can insert in another program using ÌNCLUDE statement.
More suitable for data declarations or sets of similar processing blocks.
· Subobjects/omponents of Program:
ABAP Editor (SE38)
Ìt is a tool used to write ABAP programs,class Methods,function modules,screen flow
logic, type pool & logical databases.
· Editor mode: Frontend & backend editor.
· UpIoading/DownIoading fiIes:Utilities->more utilities->upload /download.
· To navigate to particuIar Iine:Context menu->goto line->line no.
· Using compression Iogic:To compress certain parts of program in backend editor
like modules,nested statements,subroutines.
· Using pattern: You can insert following pattern
- caII function
- ABAP objects pattern
- seIect * from
- write: fieId,symboI,icon,Iine,checkbox etc.
- internaI tabIe/structure
- caII diaIog
- other pattern: predefined/ user-defined ABAP statements.
· Using ABAP heIp :
- by pressing F1
- Ì button in ABAP editor
- utilities -> help on
- by TCODE ABAPHELP
· Using Pretty printer : A function used to standardize layout of your program. To set
pretty printer use utilities ->settings->ABAP editor->pretty printer. To apply it on
current source code press toolbar button.
· Extended program check :Ìt will display error, warnings, messages after execution.
· Editor Iock : Ìf you set this attribute,other users can not change,rename or delete
· Fixed point arithmetic :Ìf you set this attribute system rounds type P fields according
to number of decimal places or pads them with zeros.
Memory Structures of an ABAP Program
Three types of memory:
· InternaI session memory (RoII area): Only one internal session is ever active. Ìf the
active application program calls a further application program, the system opens
another internal session. Here, there are two possible cases: Ìf the second program
does not return control to the calling program when it has finished running, the called
program replaces the calling program in the internal session. The contents of the
memory of the calling program are deleted. Ìf the second program does return control
to the calling program when it has finished running, the session of the called program
is not deleted. Ìnstead, it becomes inactive, and its memory contents are placed on a
· ABAP memory : ABAP memory is a memory area within the internal session of an
ABAP program & any other program called from it using CALL TRANSACTÌON or
SUBMÌT.ABAP memory is available to all internal sessions. ABAP programs can use
EXPORT & ÌMPORT statements to access it.
· SAP memory : All ABAP programs can also access the SAP memory. This is a
memory area to which all sessions within a SAPgui have access. You can use SAP
memory either to pass data from one program to another within a session, or to pass
data from one session to another. Application programs that use SAP memory must
do so using SPA/GPA parameters (also known as SET/GET parameters).
· Static heck
· Syntax heck : Checks the syntax and internal semantics of a program.
· Extended Program heck : Errors, warnings, messages.
· Dynamic heck : Errors that cannot be detected statically and that occur at runtime
are detected by the ABAP runtime environment. Such errors lead to exceptions. Ìf
such an exception is not handled ,a runtime error occurs generating a short dump.
Short dumps are retained in the system for 14 days. Use Transaction ST22 to
administer short dumps.
- Ìnternal error : The kernel encountered an error.
- Ìnstallation and environment or resource error.
- Error in application program
· Statements : An ABAP program consists of individual ABAP statements. Each
statement begins with a keyword and ends with a period.
· Formatting ABAP Statements : You can write several statements on one line, or
spread a single statement over several lines. You must separate words within a
statement with at least one space.
· Text Literals : Alphanumeric characters in the program code that are enclosed in
quotation marks. Ìf you want to enter text literals that do not fit into a single line, you
can use '&' character to combine a succession of text literals into a single one.
· Chained Statements : To concatenate a sequence of separate statements, write the
identical part only once and place a colon (:) after it.
· Comments : To comment entire line, enter an asterisk (*) at the beginning of the
line. To comment part of a line, enter a double quotation mark (") before the
comment. Use ctrl< & ctrl> for commenting multiple statements till 4.7 version.
Types and Objects
Types are descriptions that do
not occupy memory. Objects are
instances of types, and do occupy
their own memory space.
· Fixed-ength EIementary Types :
Four character types: Character (C), Numeric character (N), Date (D), Time(T).
One hexadecimaI type: Byte field (X).
Three numeric types: Ìnteger (Ì), Floating-point number (F) and Packed number (P).
· VariabIe-ength EIementary Types :STRÌNG for character strings , XSTRÌNG
for byte strings.
· Reference Types : Ìt describe data objects that contain references (pointers) to
other objects (data objects and objects in ABAP Objects).
Ex->Data reference & object reference
· ompIex Types :
1. Structures :Nested and Non-nested structures, Flat and Deep structures.
2. InternaI tabIes
ExampIes for ompIex Data Types
ist of haracter Data Types
InternaI Description DefauIt
VaIid VaIues DefauIt InitiaI
C Character 1 255
N Numeric text 1 65535 0-9 0
D Date 8
- 0-9 00000000
T Time 6
- 0-9 000000
X Hexadecimal 1 65535
ist of Numeric Data Types
VaIid vaIues DefauIt
Ì Ìnteger 4
- 0 -2^31 to
8 16 32 0-9. 0
ocaI Data Types in Programs
· EIementary Data Types :
TYPES <t>[(<length>)] [TYPE <type>|LÌKE <obj>] [DECÌMALS <dec>].
· Reference Types :
TYPES <t> TYPE REF TO data | class | interface.
· ompIex Types :
- TYPES <t> [TYPE <type>|LÌKE <obj>].
- TYPES: BEGÌN OF <structure>,
BEGÌN OF <structure>,
END OF <structure>.
END OF <structure>.
- TYPES <t> TYPE|LÌKE <tabkind> OF <linetype> [WÌTH <key>].
Data Types in the ABAP Dictionary
· Database tabIes & views :
TYPES <t> TYPE <dbtab> | <dbview> | <projectionview>.
· Data eIement :
TYPES <t> TYPE <data element>.
· Structures :
TYPES <t> TYPE <structure>.
· TabIe types :
TYPES <t> TYPE <tabletype>.
· Type groups :
onversion of Dictionary Types to ABAP Types
When you refer to data types from the ABAP Dictionary in an ABAP program, The
predefined Dictionary types are converted to ABAP types as follows:
Dictionary type Maximum Iength n ABAP type
DEC 1-31 P((n+1)/2)
ÌNT1 3 Ì
ÌNT2 5 Ì
ÌNT4 10 Ì
CURR 1-17 P((n+1)/2)
CUKY 5 C(5)
QUAN 1-17 P((n+1)/2)
UNÌT 2-3 C(n)
PREC 16 F(8)
FLTP 16 F(8)
NUMC 1-255 N(n)
CHAR 1-255 C(n)
LCHR 256-max C(n)
STRÌNG 1-max STRÌNG.
RAWSTRÌNG 1-max XSTRÌNG
DATS 8 D
ACCP 6 N(6)
TÌMS 6 T
RAW 1-255 X(n)
LRAW 256-max X(n)
CLNT 3 C(3)
LANG internal 1, external 2 C(1)
Type Addition Vs ike Addition
· TYPE & LÌKE addition is used in various ABAP statements for defining data
types and specifying the types of interface parameters or field symbols.
· As a rule, you can use LÌKE to refer to any object that has been declared
using DATA or a similar statement.
· To ensure compatibility with previous releases, you can use the LÌKE
addition to refer to the data types of database tables and flat structures in
the ABAP Dictionary. The LÌKE addition searches first for a data object
<obj> in the program, then in the ABAP Dictionary for a database table or
flat structure with the same name. You can no longer use this kind of type
reference in ABAP Objects classes. You should also avoid using the LÌKE
addition in other ABAP programs except to refer to data objects. To refer to
data types, you should use the TYPE addition instead.
Data objects are memory locations that are used to hold data while program is running.
1. iteraIs :
- Number IiteraIs
Ex : '+12.3E-4', '-12.34567','-765E-04'
- haracter IiteraIs
Ex : 'boston'
2. Text symboIs
3. VariabIes : can be declared statically using the following statements:
DATA, STATÌCS, CLASS-DATA,PARAMETERS, SELECT-OPTÌONS,
Variables are declared dynamically when you add characters or bytes to a string,
or lines to an internal table. Following are some of data statements :
- DATA <f>[(<length>)] [TYPE <type>|LÌKE <obj>] [DECÌMALS <dec>]
- DATA <f> TYPE REF TO data | class | interface.
- DATA <f> [TYPE <type>|LÌKE <obj>].
- DATA <f> TYPE|LÌKE <tabkind> OF <linetype> [WÌTH <key>].
- DATA : BEGÌN OF <structure>,
BEGÌN OF <structure>,
END OF <structure>.
END OF <structure>.
4. onstants : Constants are named data objects that you create Statically using a
CONSTANTS statement.The value of a constant must be defined when you declare
it.You can also define complex constants like
ONSTANTS: BEGÌN OF myaddress,
name(20) TYPE c VALUE 'Fred Flintstone',
street(20) TYPE c VALUE 'Cave Avenue',
number TYPE p VALUE 11,
postcode(5) TYPE n VALUE 98765,
city(20) TYPE c VALUE 'Bedrock',
END OF myaddress.
5. Interface work area : Ìnterface work areas are special named data objects that are
used to pass data between
- Screens and ABAP programs
- ogicaI databases and ABAP programs
- ABAP programs and externaI subroutines.
Ìnterface work areas is defined with the TABLES and NODES (for logical databases)
TABLES <dbtab> | <structure> | <view>.
6. Predefined data objects :
- SPAE : constant,1 byte long of type C.
- System FieIds From Structure SYST:
SY-DATUM : current date
SY-HOST : name of the app server
SY-DBSYS : name of the db server.
SY-UNAME : current user name
SY-MANDT : client id.
SY-UINE : horizontal line
SY-VINE : vertical line.
SY-SUBR : stores the status of the previous executed statement.
SY-REPID: current ABAP program
SY-PROG : Main program name
SY-TODE: current transaction
SY-ANGU : User's logon language
SY-INDEX: loop counter
SY-OPSYS : Operating system of App. server
SY-UZEIT : current time.
Attributes of Data Objects
1. DESRIBE FIED <f> [TYPE <t> [OMPONENTS <n>]] [ENGTH <I> IN
BYTE/HARATER MODE] [OUTPUT-ENGTH <o>] [DEIMAS <d>] [EDIT
MAS <m>] [HEP-ID <h>].
2. DESRIBE DISTANE BETWEEN <f1> AND <f2> INTO <d> IN BYTE/
HARATER MODE .
· To find out the attributes of a data object at runtime (ex.type of a generic parameter in
· T can be C, D, F, Ì, N, P, T, X ,S for two-byte integers,B for one-byte integers,R for
references,H for internal tables,C for structures,U for structures without an internal
table as a component,V for structures with at least one internal table as a component
· To find out any conversion routine defined for the field in the ABAP Dictionary, use the
EDÌT MASK addition:
· To find out F1 help defined for a field in the ABAP Dictionary,use the HELP-ÌD
addition. The function module HELP_OBJECT_SHOW displays the documentation for
the data element in a dialog box.
OMPATIBIITY Vs ONVERTIBIITY: Two data types or data objects are comp-
atible when all of their technical attributes (field length, number of decimal places, type)
are exactly the same. Do not confuse two terms compatible and convertible. When
working with data objects, you will often make assignments between data objects that
have different technical attributes. Ìn this case, the data types are converted. Ìn order
for non-compatible data types to be converted, a conversion rules must exist. Only
compatible data objects can be assigned to one another without a conversion.
· Basic Form of WRITE Statement:
WRITE [/][<pos>][(<Ien>)] <f>.
Field <f> can be any data object, a field symbol or formal parameter or a text symbol.
Choose print from lists to print or ecute and print on the selection screen to send the
lists directly to printer. The name of the output screen is identical to title of the program.
By default, the list header is identical to the title of the program.But you can maintain list
header by using text elements. A horizontal line is displayed, then the actual list begins.
Output format of predefined data types:
Data Type Output Iength Positioning
C field length left-justified
D 8 left-justified
F 22 right-justified
Ì 11 right-justified
N field length right-justified
P 2 * field length (+1) right-justified
T 6 left-justified
X 2 * field length left-justified
The numeric data types F, Ì, and P are right-justified and padded with blanks on the left.
Ìf a type P field contains decimal places, the default output length is increased by one.
The system automatically converts dates of type D based on the format specified in the
user's master record .
· Positioning WRITE Output on the ist:
WRITE AT [/][<pos>][(<Ien>)] <f>.
Slash '/' denotes a new line, <pos> is a number or variable up to three digits long denot-
ing the position on the screen,<len> is a number or variable up to three digits long denot
ing the output length. Ìf the format specification contains only direct values (that is, no
variables), you can omit the keyword AT. Ìf the output length <len> is too short, fewer
characters are displayed. Numeric fields are truncated on the left and prefixed with an
asterisk (*). All other fields are truncated on the right, but no indication is given that the
field is shorter.
· Formatting Options:
WRITE .... <f> <option>.
Options for aII data types Function
LEFT-JUSTÌFÌED Output is left-justified.
CENTERED Output is centered.
RÌGHT-JUSTÌFÌED Output is right-justified.
UNDER <g> Output starts directly under field <g>.
NO-GAP The blank after field <f> is omitted.
USÌNG EDÌT MASK <m> Specifies format template <m>.
USÌNG NO EDÌT MASK Deactivates a format template specified in
NO-ZERO Ìf a field contains only zeros, these are
replaced by blanks. For type C and N fields,
leading zeros are replaced automatically.
Options for numeric fieIds Function
NO-SÌGN leading sign is not displayed on the screen.
DECÌMALS <d> <d> defines the number of digits after the decimal point.
EXPONENT <e> Ìn type F fields, the exponent is defined in <e>.
ROUND <r> Type P fields are multiplied by 10**(-r) and then rounded.
CURRENCY <c> Format according to currency <c> in table TCURX.
UNÌT <u> The number of decimal places is fixed according to unit
<u> specified in table T006 for type P fields.
Options for date fieIds Function
DD/MM/YY Separators as defined in user's master record.
MM/DD/YY Separators as defined in user's master record.
DD/MM/YYYY Separators as defined in user's master record.
MM/DD/YYYY Separators as defined in user's master record.
DDMMYY No separators.
MMDDYY No separators.
YYMMDD No separators.
· Using edit mask: _ are replaced by one by one with characters from source field.
Ex: WRITE AT [/][<pos>][(<Ien>)] <DATE> USING EDIT MAS '__/__/____'.
WRITE AT [/][<pos>][(<Ien>)] <f> USING EDIT MAS '==APHA'.
Where ALPHA is a conversion routine (conversion_exit_alpha_output).
· DispIaying SymboIs and Icons on the ist:
WRITE <symboI-name> AS SYMBO.
WRITE <icon-name> AS ION.
WRITE <Iine-name> AS INE.
The names of symbols, icons are system-defined constants that are specified in the
include programs <SYMBOL> ,<ÌCON>,<LÌNE> (angle brackets are part of the name).
You can replace the above ÌNCLUDE statements with one single ÌNCLUDE statement:
The easiest way to output symbols, icons, lines is to use a PATTERN option.
· HorizontaI Iines:
ULÌNE [AT [/][<pos>][(<len>)]]. OR
WRÌTE [AT [/][<pos>][(<len>)]] SY-ULÌNE. OR
WRÌTE [AT [/][<pos>][(<len>)]] '-------------'.
· VerticaI Iines:
WRÌTE [AT [/][<pos>]] SY-VLÌNE. OR
WRÌTE [AT [/][<pos>]] '|'.
· BIank Iines :
SKÌP TO LÌNE <n>.
The second statement allows you to move the output position upwards or downwards.
· DispIaying FieId ontents as heckboxes :
WRITE <f> AS HEBOX.
Ìf the first character of field <f> is an "X", the checkbox is displayed filled. Ìf the first
character is SPACE, the checkbox is displayed blank. The user can fill or clear them
with a mouse click. Fields that are ready for input are an essential component of
· WRITE <f> ....... QUIINFO info
A Quickinfo is assigned to the output. Ìf the mouse cursor is placed on the output area
of <f>, the content of info appears in a coloured rectangle. For info, a character-type
data object of the length 40 is expected. The addition QUIINFO has no effect on
ready-for-input fields and line elements. Ìf a list output is overwritten by another
output, then no Quickinfo for the overwritten field appears beginning from the position
at which the overwriting starts.
· WRITE ..... TIME ZONE tz
This addition edits a time stamp in relation to a time zone. Ìt must contain a time zone
from the column TZONE of the database table TTZZ in uppercase letters. Ìf tz is
initial, the UTC reference time is output.
DATA: time_stamp TYPE timestamp,
tzone TYPE timezone.
time_stamp = 20020627180000.
tzone = 'AUSTAS'.
WRÌTE / time_stamp TÌME ZONE tzone.
· oIors in ists :
To set colors statically, use :
FORMAT OOR <n> [ON] INTENSIFIED [ON|OFF] INVERSE [ON|OFF] INPUT
[ON|OFF] HOTSPOT [ON|OFF].
To set colors at runtime, use:
FORMAT OOR = <c> INTENSIFIED = <int> INVERSE = <inv> INPUT = <i>
HOTSPOT = <h>.
COLOR sets the color of the line background.
<n> <c> oIor Intended for
OFF/ COL_BACKGROUND 0 depends on GUÌ background
1/ COL_HEADÌNG 1 gray-blue headers
2/ COL_NORMAL 2 light gray list bodies
3/ COL_TOTAL 3 yellow totals
4/ COL_KEY 4 blue-green key columns
5/ COL_POSÌTÌVE 5 green positive threshold value
6/ COL_NEGATÌVE 6 red negative threshold value
7/ COL_GROUP 7 violet Control levels
ÌNTENSÌFÌED determines the color palette for the line background. The default setting
is ÌNTENSÌFÌED ON.Ìf ÌNVERSE ON is set, then ÌNTENSÌFÌED OFF has no effect. Ìf
the contents of <int>is zero, the variable has the same effect as the OFF option. Ìf the
contents of <int> is unequal to zero, the variable has the same effect as the ON option.
Ìf ÌNVERSE ON is set, the system changes the foreground color instead of background
color.<inv> is similar to <int>.
· EnabIing FieIds for Input :
To make output fields input-enabled statically, use:
FORMAT INPUT [ON|OFF].
To make output fields input-enabled at runtime, use:
FORMAT INPUT = <i>.
For input fields, the options COLOR, ÌNVERSE, and HOTSPOT have no effects. The
ÌNTENSÌFÌED option changes the foreground color of the input fields. You can make
horizontal lines input-enabled but not blank lines created by skip.<i> is similar to <inv>.
· Outputting FieIds as Hotspots :
To designate fields as hotspots statically, use:
FORMAT HOTSPOT [ON|OFF].
To designate fields as hotspots at runtime, use:
FORMAT HOTSPOT = <h>.
Ìf the user clicks once onto a hotspot field, an event is triggered (for example, AT LÌNE-
SELECTÌON). For fields that are not defined as hotspots, the user must double-click the
field or use a function key to trigger an event. You cannot use the HOTSPOT option if
ÌNPUT ON is set but COLOR, ÌNTENSÌFÌED, ÌNVERSE can be used. You cannot
format horizontal lines created with ULÌNE and blank lines created with SKÌP as
· ountry-specific and User-specific Output Formats : You can change User
master settings (number and date fields) from within your program, using
SET OUNTRY <c>.
For <c>, set either a country key defined in table T005X or SPACE. Ìf <c> is not
SPACE, the system formats the output of all subsequent WRÌTE statements according
to the settings defined in table T005X & set SY-SUBRC to 0 if ,<c> Finds. Ìf the country
key you specified does not exist, the system sets SY-SUBRC to 4 and formats for all
subsequent WRÌTE statements the decimal characters as period '.' and date
specifications as MM/DD/YY. Ìf <c> is SPACE, the system does not read table T005X
but uses the settings in the user master record.You can also use URRENY & UNIT
addition in write statements.
· ines in ists : You must include the include program <LÌNE> or the more compre÷
hensive include program <LÌST> into your program.Use pattern option.
· NOTE : For each new event, the system resets all formatting options to their default
values. All formatting options have default value OFF, except the ÌNTENSÌFÌED
· To set all formatting options to OFF in one go, use:
· NOTE: You can use all formatting options for individual output fields in write
WRITE <field> COLOR <n> [ON] ÌNTENSÌFÌED [ON|OFF] ÌNVERSE [ON|OFF]
ÌNPUT [ON|OFF] HOTSPOT [ON|OFF].
· Using Move :
- MOVE <f1> TO <f2> or the equivaIent statement <f2> = <f1>.
- MOVE-ORRESPONDING <struct1> TO <struct2>.
This statement moves the contents of the components of structure <struct1> to the
components of <struct2> that have identical names.
· Using WRITE TO :
- WRITE <f1> TO <f2> [<option>].
This statement converts the contents of a data object <f1> to type C, and places the
string in the variable <f2>.Contents of <f1> remain unchanged. <f2> is always
interpreted as a character string.You can also use all of formatting options available
with the WRÌTE statement, apart from UNDER and NO-GAP.
- WRITE (<f>) TO <g> [<option>].
You can specify the name of the source field dynamically as the contents of another
· Using EAR :
To reset a variable <f> to the appropriate initial value for its type.
NumericaI aIcuIations ( Data Types I,P,F )
· Assignment : COMPUTE <n> = <expression> or <n> = <expression>.
COMPUTE is optional.
· Order of expressions.
1. Expressions in parentheses
3. ** (powers)
4. *, / , MOD, DIV (muItipIication, division)
5. +, - (addition, subtraction)
· Arithmetic operations :
Operation mathematicaI expression eyword
Addition <p> = <n> + <m>. ADD <n> TO <m>.
Subtraction <p> = <m> - <n>. SUBTRAT <n> FROM <m>.
MuItipIication <p> = <m> * <n>. MUTIPY <m> BY <n>.
Division <p> = <m> / <n>. DIVIDE <m> BY <n>.
Integer division <p> = <m> DIV <n>. ---
Remainder of division <p> = <m> MOD <n>. ---
Powers <p> = <m> ** <n>. ---
Ìn the statements using keywords, the results of the operations are assigned to
· Arithmetic aIcuIations Using Structures :
- ADD- ORRESPONDING <struct1> TO <struct2>.
- SUBTRAT- ORRESPONDING <struct1> TO <struct2>.
- MUTIPY- ORRESPONDING <struct1> TO <struct2>.
- DIVIDE- ORRESPONDING <struct1> TO <struct2>.
ABAP performs the corresponding calculation for all components that have the same
name in both structures.
· Adding Sequences of FieIds :
- ADD <n1> THEN <n2> UNTI <nz> GIVING <m>.
Ìf <n1>,<n2>,...<nz> is a sequence of equidistant fields of the same type
and length in memory, they are summed and the result is assigned to <m>.
- ADD <n1> THEN <n 2> UNTI <nz> TO <m>.
This statement is identical to the preceding one, with one difference: The sum
of the fields is added to the existing contents of <m>.
· Date and time fieIds have character types, not numeric ones. However, you
can still use date and time fields in numeric operations. To allow you to do so,
the system performs automatic type conversions. You may also find it useful
to use offset & length specifications when using date and time fields in
· MathematicaI functions :
[OMPUTE] <n> = <func>( <m> ).
ABS Absolute value of argument.
SÌGN Sign of argument
CEÌL Smallest integer value not smaller than argument.
FLOOR Largest integer value not larger than argument.
TRUNC Ìnteger part of argument.
FRAC Fraction part of argument.
ACOS, ASÌN, ATAN,COS, SÌN, TAN Trigonometric functions.
COSH, SÌNH, TANH Hyperbolic functions.
EXP Exponential function with base e (e=2.7182818285).
LOG Natural logarithm with base e.
LOG10 Logarithm with base 10.
SQRT Square root.
haracter String Statements (types , D, N,T)
· Using Shift (case sensitive):
- SHIFT <c> [BY <n> PAES] [<mode>].
<mode> is left (default),right,circular.
- SHIFT <c> UP TO <str> <mode>.
Ìf <str> not found in <c>, SY-SUBRC is 4 & <c> is not shifted. Otherwise, it is 0.
- SHIFT <c> EFT DEETING EADING <str>.
- SHIFT <c> RIGHT DEETING TRAIING <str>.
This statement shifts field <c> to the left or to the right, provided the first character
on the left or the last character on the right occur in <str>. The right or left of the field
is then padded with blanks.
· Using RepIace (case sensitive):
- REPAE <str1> WITH <str2> INTO <c> [ENGTH <I>].
Ìf SY-SUBRC is 0, <str1> is found in <c> and replaced by <str2>.
· Using TransIate (not case sensitive):
- TRANSATE <c> TO UPPER ASE.
- TRANSATE <c> TO OWER ASE.
- TRANSATE <c> USING <r>.
This statement replaces all characters in field <c> according to the substitution rule
stored in field <r> . <r> contains pairs of letters, where the first letter of each pair is
replaced by the second letter.
· Using OverIay (case sensitive):
- OVERAY <c1> WITH <c2> [ONY <str>].
This statement overlays all positions in field <c1> containing letters which occur in <str>
with the contents of <c2>. <c2> remains unchanged. Ìf you omit ONLY <str>, all
positions of <c1> containing spaces are overwritten. Ìf at least one character in <c1>
was replaced , SY-SUBRC is set to 0 .Ìn all other cases, SY-SUBRC is set to 4.
· Using Search (not case sensitive):
- SEARH <c> FOR <str> [<options>].
<pattern> Searches for <pattern> (any sequence of characters).
Trailing blanks are ignored.
.<pattern>. Searches for <pattern>.Trailing blanks are not ignored.
*<pattern> A word ending with <pattern> is sought.
<pattern>* Searches for a word starting with <pattern>.
Ìf successful ,SY-SUBRC is set to 0 and SY-FDPOS is set to the offset of the string in
the field <c>. Otherwise, SY-SUBRC is set to 4. Words are separated by blanks,
commas, periods, semicolons, colons, question marks, exclamation marks,
parentheses, slashes, plus signs, and equal signs. The system does not distinguish
between upper and lower case characters. <option> in the SEARCH FOR statement
can be any of the following:
Searches the field <c> for a word containing the string in <str>. The characters can
be separated by other characters. The first letter of the word and the string <str>
must be the same.
- STARTING AT <n1>
Searches the field <c> for <str> starting at position <n1>. The result SY-FDPOS
refers to the offset relative to <n1> and not to the start of the field.
- ENDING AT <n2>
Searches the field <c> for <str> up to position <n2>.
- AND MAR
Ìf the search string is found, all the characters in the search string (and all characters
in between when using ABBREVÌATED) are converted to upper case.
· Using StrIen :
[OMPUTE] <n> = STREN( <c> ).
STRLEN returns length of a string up to last character that is not a space.
· Using ondense :
ONDENSE <c> [NO-GAPS].
Ìt removes any leading blanks in field <c> and replaces other sequences of blanks
by exactly one blank. Ìf the addition NO-GAPS is specified, all blanks are removed.
· Using oncatenate (case sensitive):
ONATENATE <c1> ... <cn> INTO <c> [SEPARATED BY <s>].
Ìt combines two or more separate strings into one. Ìf the result fits into <c>, SY-
SUBRC is set to 0. However, if result has to be truncated, SY-SUBRC is set to 4.
· Using SpIit (case sensitive):
SPIT <c> AT <deI> INTO <c1> ... <cn>.
The system searches the field <c> for the separator <del>. The parts before and after
the separator are placed in the target fields <c1> ... <cn>. Ìf all target fields are
long enough and no fragment has to be truncated, SY-SUBRC is set to 0 else 4.
SPIT <c> AT <deI> INTO TABE <itab>.
The system adds a new line to the internal table <itab> for each part of the string.
· Using Move :
MOVE <c1> TO <c2> PERENTAGE <p> [RIGHT].
Copies the percentage <p> percent of the character field <c1> to <c2>. The value of
<p> can be a number between 0 and 100.
HexadecimaI Operations (type X)
A hexadecimal field with length n is n bytes long, and has a display length in ABAP of
· Setting Bits :
SET BIT <n> OF <f> [TO <b>].
This statement sets the bit at position <n> of field <f> to 1 (or to the value of field
<b>). The field <b> must contain the value 0 or 1. Ìf the bit is set, SY-SUBRC is set to
0. Ìf <n> or <b> contain invalid values, a runtime error occurs.
· Reading Bits :
GET BIT <n> OF <f> INTO <b>.
This statement reads the bit at position <n> of field <f> into field <b>. Ìf the bit is read,
SY-SUBRC is set to 0.
· Bit Operations :
<x> = <bitexp>.
<y> <z> BIT-NOT <y> <y> BIT-AND <z> <y> BIT-XOR <z> <y> BIT-OR <z>
0 0 1 0 0 0
0 1 1 0 1 1
1 0 0 0 1 1
1 1 0 1 0 1
· EIementary Data Types : There are ten predefined ABAP data types C ,D, F, Ì,
N, P,T, X, STRÌNG, XSTRÌNG .There are 100 possible type combinations between
these elementary data types. ABAP supports automatic type conversion and length
adjustment for all of them except type D (date) and type T (time) fields which cannot
be converted into each other.
· Structures : ABAP has one rule for converting structures that do not contain internal
tables as components. There are no conversion rules for structures that contain
- Converting a structure into a non-compatible structure
- Converting elementary fields into structures
- Converting structures into elementary fields
Ìn each case, the system first converts all the structures to type C fields.
· InternaI tabIes : Ìnternal tables can only be converted into other internal tables.You
cannot convert them into structures or elementary fields. Ìnternal tables are convertible
if their line types are convertible. The convertibility of internal tables does not depend
on the number of lines.
Note : Elementary fields with types Ì and F occupy special memory addresses that are
platform-specific. For example, the address of a type Ì field must be divisible by 4, and
the address of a type F field by 8. Consequently, type Ì and F fields are known as
aligned fields. Structures containing fields with type Ì or F are also aligned, and may
contain filler fields immediately before their aligned components.The system normally
aligns fields and structures automatically when you declare them.
Offset & ength
You can address a section of a string in any statement in which non-numeric elementary
ABAP types or structures that do not contain internal tables occur using the following
You cannot use offset and length to address a literal or a text symbol.Do not use offset
and length to address components of structures.
You can use offset & length in all cases like :
- MOVE or the assignment operator.
- WRÌTE statement.
- When assigning values with WRÌTE TO.
- When assigning field symbols using ASSÌGN.
- When passing actual parameters to subroutines in the PERFORM statement.
.... <f1> <operator> <f2> ...
· omparisons Between Different Data Types:
EQ equaI to
= equaI to
NE not equaI to
<> not equaI to
>< not equaI to
T Iess than
< Iess than
E Iess than or equaI to
<= Iess than or equaI to
GT greater than
> greater than
GE greater than or equaI to
>= greater than or equaI to
You can compare compatible & incompatible data objects. For incompatible,
the system performs a type conversion. Two structures are equal if all of their
elementary components are equal. Ìf the structures are unequal, the first pair
of elements that are unequal determine which structure is larger.
· omparing strings ( types ,D,N,T):
1. O (ontains OnIy)
<f1> O <f2>
<f1> contains only characters from <f2>, case-sensitive, Trailing blanks are included.
Ìf true, SY-FDPOS contains length of <f1>. Ìf false, SY-FDPOS contains the offset of
character of <f1> that does not occur in <f2>.
2. N (ontains Not onIy)
<f1> N <f2>
3. A (ontains Any)
<f1> A <f2>
<f1> contains at least one character from <f2>, case-sensitive. Ìf true, SY-FDPOS
contains offset of first character of <f1> that also occurs in <f2> . Ìf false, SY-FDPOS
contains the length of <f1>.
4. NA (contains Not Any)
<f1> NA <f2>
5. S (ontains String)
<f1> S <f2>
<f1> contains string <f2>, not case-sensitive, Trailing spaces ignored . Ìf true, SY-
FDPOS contains offset of <f2> in <f1>. Ìf false, SY-FDPOS contains the length of
6. NS (contains No String)
<f1> NS <f2>
7. P (ontains Pattern)
<f1> P <f2>
<f1> matches pattern <f2>. Ìf <f2> is of type C, you can use * (for any character
string), + (for any single character) as wildcard character. Trailing spaces ignored ,
not case-sensitive. Ìf true, SY-FDPOS contains offset of <f2> in <f1> . Ìf false, SY-
FDPOS contains length of <f1>.
You can use the escape character # to specify
- characters in upper and lower case
- the wildcard character "*" & "+" (enter:#* & #+)
- the escape symbol itself (enter: ## )
- blanks at the end of a string (enter: #___ )
8. NP (contains No Pattern)
<f1> NP <f2>
· omparing Bit Sequences
1. <f> O <hex>
True if the bit positions that are 1 in <hex>, are 1 in <f>. The second operand must
have type X.
2. <f> Z <hex>
True if the bit positions that are 1 in <hex>, are 0 in <f>.
3. <f> M <hex>
True if from the bit positions that are 1 in <hex>, at least one is 1 and one is 0 in <f>.
· hecking Whether a FieId BeIongs to a Range
.... <f1> BETWEEN <f2> AND <f3> .....
· hecking for the InitiaI VaIue
.... <f> IS INITIA .....
True if <f> contains the initial value for its type. Use CLEAR statement to set initial
· hecking SeIection riteria
... <f> IN <seItab> ....
· ombining SeveraI ogicaI Expressions :
You can combine several logical expressions together in one single expression by
using the logical link operators AND,OR,NOT:
- To combine several logical expressions together in one single expression which is
true only if all of the component expressions are true, link the expressions with AND.
- To combine several logical expressions together in one single expression which is
true if at least one of the component expressions is true, link the expressions with OR.
- To negate the result of a logical expression, you can precede it with the NOT
· The IF ontroI Structure
· The ASE ontroI Structure
> [OR <f
> OR ...].
> OR ...]
· UnconditionaI oops:
DO [<n> TIMES] [VARYING <f> FROM <f1> NEXT <f2>]
[VARYING <g> FROM <g1> NEXT <g2>] .
Use EXÌT or STOP statement to avoid endless loops. You can nest DO loops &
combine them with other loop forms. system field SY-ÌNDEX contains the number of
loop passes, including the current loop pass. You can use VARYÌNG addition more
than once in a DO statement.<f1> & <f2> are the first two fields of a sequence of
fields the same distance apart in memory & with the same type & length. Ìn the first
loop pass,<f> takes value <f1>,in the second loop pass,<f2> & so on. Ìf you change
value of field <f> within DO loop, value of current field <fi> is changed. You must
ensure that there are not more loop passes than fields in sequence, otherwise a
runtime error occurs.
· onditionaI oops:
WHIE <condition> [VARY <f> FROM <f
> NEXT <f
<condition> can be any logical expressions. Can use exit,stop,sy-index. Can nest
· OOP : Loops through internal tables and extract datasets.
· SEET : Loops through datasets from database tables.
· ONTINUE, HE, and EXIT can be used in all four loop types in ABAP (DO,
WHIE, OOP, and SEET).
- To terminate a single loop pass immediately and unconditionally, use the CONTÌNUE
statement in the statement block of the loop.After the statement, the system ignores
any remaining statements in the current statement block, & starts the next loop pass.
- To terminate a single loop pass conditionally, use the CHECK <condition> statement
in the statement block of the loop.Ìf the condition is not true, any remaining
statements in the current statement block after the CHECK statement are ignored,
and the next loop pass starts. <condition> can be any logical expressions.
- To terminate an entire loop immediately and unconditionally, use the EXÌT statement
in the statement block of the loop.After this statement, the loop is terminated, and
processing resumes after the closing statement of the loop structure (ENDDO,
ENDWHÌLE, ENDLOOP, ENDSELECT). Ìn nested loops, only the current loop is
Allows you to create language independent programs.Any text that program displays on
screen can be maintained as a text element & are stored in language specific text pools.
1. Text symboI - Ìt is a named data object generated when you start program from text
pool of ABAP program.Ìt has three character ÌD,contents, occupied length,max length
(132). Use it instead of hard-coded text to make program language independent. You
can address text symbol by
- TEXT-<ID> : SPACE is used if no text symbol in logon language.
- '<defauIttext>' (<ID>) : Default text is used if no text symbol in logon language.
2. ist & oIumn headings - List headings can be up to 70 characters long & each of 4
columns of column heading can be up to 255 characters long.Ìn both,you can enter 10
placeholders &0 to &9,each followed by up to 18 periods. System replaces placehold-
ers in TOP-OF-PAGE event with contents of system fields SY-TVAR0 to SY-TVAR9.
2. SeIection text - You can replace standard text (names of parameters & select-
options) that appear next to input fields on selection screens by ABAP dictionary text
(field label/short text) or by your own text.
· To copy text elements between programs,SE32-> enter program name-> copy.
· For translating,SE38-> utilities->translation. The initial screen of the translation
transaction (SE63) appears.
· Variants allow you to define sets of input values on selection screens for all programs
except subroutine pools (type S).
· Variants are the only method for passing values to a report program in a background
· You can create,change,delete,copy,print variants.
· You can create any number of variants for any program in which selection screens are
· Variants are an interface between the user and the selection screen. They can be
used both in dialog and in background mode,although their uses are slightly different.
· OnIy for background processing : Not in dialog mode.
· Protect variant : To prevent your variant being changed by other users.
· OnIy dispIay in cataIog : Not when the user calls the F4 value help.
· System variant : This field cannot accept input. Ìt is set automatically when a system
variant (beginning with CUS& or SAP&) is created.
· Type : System indicates here whether a field is a parameter (P) or a select-option (S).
· Protect fieId : Visible on selection screen but do not accept user input.
· Hide fieId : This allows you to change the appearance of the selection screen.
· SeIection variabIe : To set the value dynamically at runtime.
· Without vaIues : Contents of field not saved with the variant. Used when u do not
want to overwrite the contents of this field on the selection screen.
· Switch GPA off : This attribute only appears if you created the corresponding
selection criterion using 'MEMORY ÌD xxx'. You can switch the SPA/GPA handling on
and off in the variant. This means that fields filled using SPA/GPA appear with their
initial values after you have loaded a variant in which those fields have an initial value.
VariabIe VaIues in Variants
To avoid having to create a new variant each time you use different values, you can
use variables in variants. There are three ways to do this:
1. Dynamic date caIcuIations : Attributes->selection variable->selection variables->
D-> Single-click the stoplight to turn it to green-> F4->choose date calculations.
2. User-defined variabIes :You can use user-defined variables to make input values in
a variant user-dependent. Ìn an executable program (report), you must create a
parameter or selection option using the addition...MEMORY ÌD <pid> with the correct
parameter ÌD. Users can change the values of their user-specific variables on the
3. TabIe variabIe from TVARV : Using fixed values from table TVARV is particularly
useful in background processing. You do not need to create a new variant or keep
changing existing variant each time a value changes. Ìnstead, you can change the
relevant values in table TVARV.Use SM30 for table maintenance of TVARV.
Field symbols are symbolic names for other fields. Field symbols are similar to derefe-
renced pointers in C (that is, pointers to which the content operator * is applied). A field
symbol can point to any data object. When you address a field symbol, the system
works with the contents of the data object assigned to it, and not with the contents of
field symbol itself. Ìt allow you to access data objects dynamically in ABAP programs.
All operations programmed with field symbols are applied to the field assigned to it.
Specific statements such as CREATE OBJECT <FS> or LOOP AT <FS> are not
· DecIaring FieId SymboIs :
1. FIED- SYMBOS <FS> [<type>].
The <type> addition allows you to specify type of a field symbol which can be
Generic or fuIIy defined. Ìf type of field symbol and type of data object to which field
symbol is assigned are not compatible or convertible, the system reacts with a syntax
or runtime error. You can specify type either generically or in full. Ìf you specify a
generic type, type of field symbol is either partially specified or not specified at all. Any
attributes that are not specified are inherited from the corresponding data object in
ASSÌGN statement.Ìf you specify the type fully, all of the technical attributes of field
symbol are determined when you define it. You can then only assign data objects to it
that have exactly the same data type.
Generic Type : <type> can be no type specification, TYPE ANY,TYPE C, N, P, or
X,TYPE TABLE (standard), TYPE ANY TABLE, TYPE ÌNDEX TABLE, TYPE
STANDARD TABLE, TYPE SORTED TABLE,TYPE HASHED TABLE.
FuIIy Type : <type> can be TYPE D, F, Ì, or T,TYPE <type>,TYPE REF TO DATA |
CLASS | ÌNTERFACE,LÌKE LÌNE OF <itab>,LÌKE <f>.
2. FIED-SYMBOS <FS> STRUTURE <s> DEFAUT <f>.
Ìt is used to assign a structure to field symbol The structure <s> is either a structured
local data object in the program, or a flat structure from the ABAP Dictionary. <f> is a
data object that must be assigned to the field symbol as a starting field. However, this
assignment can be changed later using the ASSÌGN statement. You can address the
individual components of the field symbol.
· Assigning FieId SymboIs:
1. ASSIGN <f> TO <FS>
Ìt assign the data object to field symbol.The system checks whether the technical
attributes of the data object <f> correspond to any type specifications for the field
symbol <FS>. The field symbol adopts any generic attributes of <f> that are not
contained in its own type specification. After assignment, it points to <f> in memory. Ìf
<f> is a structure,You can not address the individual components of the field symbol.
2. ASSIGN <f>[+<o>][(<I>)] TO <FS>
You can use positive offset and length specifications to assign a part of a field to a
field symbol. Both offset <o> and length <l> can be larger than the length of <f>. You
can address memory beyond the boundary of <f>, but not beyond the data areas for
field symbols. By default <l> is length of <f>. Use asterisk (*) for <l> to prevent <FS>
from referring to an address beyond the limits of <f>.
3. ASSIGN (<f>) TO <FS>.
This is dynamic assign statement. Ìt assigns the field whose name is contained
in the field <f> to the field symbol <FS>. You cannot use offset and length in a
dynamic ASSÌGN. System searches data object first in procedure then local data of
program then in table work area in the main program of the current program group. Ìf
the search is successful and a field is assigned to the field symbol, SY- SUBRC is set
to 0.Otherwise, it is set to 4, and the field symbol remains unchanged.
4 . ASSIGN TABE FIED (<f>) TO <FS>.
The system searches data object within the table work areas.This addition can not
be used in ABAP objects.
5. ASSIGN <FS1>[+<o>][(<I>)] TO <FS2>.
6. ASSIGN [TABE FIED] (<f>) TO <FS2>.
<f> contains the name of a field symbol <FS1>.
7. ASSIGN OMPONENT <idx>|<comp> OF STRUTURE <s> TO <FS>.
Ìt assign component <comp> of structure <s>to the field symbol <FS>. Expressions
such as <FS>-COL1 are syntactically incorrect. You can use sy-index in place of
<comp> in loop to address individual components of structure <s> to <fs>. Ìf the
assignment is successful, SY-SUBRC is set to 0. Otherwise, it is set to 4.<comp> &
<s> can also be the field symbol.
· UNASSIGN <FS>:
Ìt allows you to specify explicitly that a field symbol <FS> should not have a data
object assigned to it.
· hecking Whether a FieId SymboI is Assigned :
... <FS> IS ASSIGNED.
· asting data objects:
Use the CASTÌNG addition to the ASSÌGN statement. This allows you to assign a
data object to a field symbol where the type of the data object is incompatible with
that of the field symbol.
1. ImpIicit casting
ASSIGN ... TO <FS> ASTING.
Ìf field symbol is either fully typed or has one of the generic built-in ABAP types ÷
C, N, P, or X.
2. ExpIicit casting
ASSIGN ... TO <FS> ASTING TYPE <type>|IE <obj>[DEIMAS <d>].
Ìf the field symbol is neither fully typed nor generically typed (type ANY). When the
system accesses the field symbol, the content of the assigned data object is
interpreted as if it had the type declared in the statement.
Data references are pointers to data objects.You can use data references to create
data objects dynamically.
· reating data reference variabIe:
You create the data type of a data reference variable using:
TYPES <t_dref> TYPE REF TO <type> | IE REF TO <obj>.
You can create a data reference variable either by referring to the above data type
DATA <dref> TYPE REF TO <type> | IE REF TO <obj> | TYPE <t_dref>
VAUE <vaI> | VAUE IS INITIA.
<type> can be DATA, dictionary types, elementary data types, user defined data
types, class name etc.<obj> can be local data object , class reference etc.
· reating data object dynamicaIIy:
REATE DATA <dref> [TYPE <type>|IE <obj>].
This statement creates a data object in the internal session of current ABAP program.
After the statement, the data reference in the data reference variable <dref> points to
the object. The data object that you create does not have its own name. You can only
address it using a data reference variable. You can also specify the data type
REATE DATA <dref> [TYPE (<name>)].
· Getting References to Data Objects :
GET REFERENE OF <obj> INTO <dref>.
Ìt allow you to place a <dref> to an existing data object in a reference variable. <obj>
can be statically-declared data object, field symbol, another data reference (pointer
to pointer) ,class reference (pointer to class reference) etc.
· Dereferencing Data References
ASSIGN <dref>->* TO <FS> [ASTING ...].
This statement is used to access the contents of the data object to which a data
reference is pointing by using field symbol.Ìf the assignment is successful, SY-
SUBRC is set to zero. Ìf you create a data object dynamically, the only way to access
its contents is to use dereferencing. Ìf the data reference in <dref> is initial or invalid,
you cannot dereference it. The field symbol remains unchanged, and SY-SUBRC is
set to 4. To fill the contents of the data object, you can use
<FS> = <vaI> or <dref>->* = <vaI>.
· You can also use dref2 = dref1 (Assigning one pointer to another).
· An internal table is a dynamic sequential dataset in which all records have the same
structure and a key.
· Ìnternal table is a dynamic data object as the memory will be allocated only at the
· The major application of internal table is to process data from the database tables.
· We can improve the efficiency of programs by using an internal table as an interface
to the database table, which allows us to retrieve or update multiple rows at a time.
· Ìnternal tables help reduce the load on the database system and the communication
· Ìnternal Tables have two parts :
- Header Iine.
Header line works as an interface to the body of the internal table.
Body is a group of rows which forms the actual internal table.
Basic Operations of an internal table:
- Population data.
- Processing data.
InternaI TabIe Types
Like all local data types in programs , you define internal tables using the TYPES
TYPES <t> TYPE|IE <tabIetype> OF <Iinetype> [WITH <key>][INITIA SIZE <n>].
· TabIe type:
1. ÌNDEX TABLE : For creating a generic table type with index access.
2. ANY TABLE : For creating a fully-generic table type.
3. STANDARD TABLE or TABLE
4. SORTED TABLE
5. HASHED TABLE
· ine type : Ìt can be any data type if you are using the TYPE addition or any data
object recognized within the program at that point if you are using the LÌKE addition.
· ey : <key> of an internal table can be
1. [UNIQUE|NON-UNIQUE] EY <coI1>...<coIn> : Ìn tables with a structured line
type, all of the components <coÌ
> belong to the key as long as they are not internal
tables or references.
2. [UNIQUE|NON-UNIQUE] EY TABE INE : Ìf a table has an elementary line type,
you can define the entire line as the key. Ìf table whose line type is an internal table,
a syntax error occurs. Ìf a table has a structured line type, it is possible to specify the
entire line as the key. However, you should remember that this is often not suitable.
3. [UNIQUE|NON-UNIQUE] DEFAUT EY :This declares the fields of the default key
as the key fields. Ìf the table has a structured line type, the default key contains all
non-numeric columns of the internal table that are not and do not contain references
or internal tables. Ìf the table has an elementary line type, the default key is the entire
line. An internal table whose line type is an internal table, the default key is empty.
· Unique/non-unique : The optional additions UNÌQUE or NON-UNÌQUE determine
whether the key is to be unique or non-unique, that is, whether the table can accept
· InitiaI Memory Requirement : You can specify the initial amount of main
INITIA SIZE <n>
Ìt reserve memory space for <n> table lines when you declare the table object. When
this initial area is full, the system makes twice as much extra space available up to a
limit of 8KB. Further memory areas of 12KB each are then allocated.
InternaI TabIe Object
Like all variables, you declare internal tables using the DATA statement.
· DATA <itab> TYPE <type>|IE <obj> [WITH HEADER INE].
· DATA <itab> TYPE|IE <tabIetype> OF <Iinetype> WITH <key>
[INITIA SIZE <n>] [WITH HEADER INE].
Standard TabIes in previous versions:
· Before reIease 3.0 :
DATA : BEGIN OF <itab> OURS <n>,
END OF <itab>.
· From reIease 3.0 :
TYPES <t> TYPE|IE <Iinetype> OURS <n>.
DATA <itab> TYPE|IE <Iinetype> OURS <n> [WITH HEADER INE].
· From reIease 4.0 :
TYPES <itab> TYPE|IE [STANDARD] TABE OF <Iinetype>.
DATA <itab> TYPE|IE [STANDARD] TABE OF <Iinetype>.
Both of above statements has <key> as non-unique default key as default.
Operations on Entire InternaI TabIes
· Assigning internaI tabIes :
MOVE <itab1> TO <itab2>. OR
<itab2> = <itab1>.
Both operands must either be compatible or convertible. These statements assign the
entire contents of table <itab1> to table <itab2>.For internal tables with header lines,
place bracket ([ ]) after the table name.
· InitiaIizing InternaI TabIes :
Free <itab> - All rows are deleted and all memory used by the body of the internal
table is freed.The header line remain unchanged.
Refresh <itab> - All rows are deleted. All memory used by the body of the internal
table remains allocated.The header line, if it exists, is unchanged.
Iear <itab> | Iear itab[ ] ÷ Delete all rows from internal table and leave the
memory allocated.Clear the header line.
· omparing InternaI TabIes :
.... <itab1[ ]> <operator> <itab2[ ]> ..
<operator> can be EQ, =, NE, <>, ><, GE, >=, LE, <=, GT, >, LT, <. The more
lines an internal table contains, the larger it is. Ìf two internal tables contain the
same number of lines, they are compared line by line, component by component.
· Sorting InternaI TabIes :
SORT <itab> [ASENDING|DESENDING] [AS TEXT] [STABE]
BY <f1> [ASENDING|DESENDING][AS TEXT]
<fn> [ASENDING|DESENDING][AS TEXT].
The statement sorts the internal table <itab> in ascending order by its key if f1>..<fn>
is not mentioned. ASCENDÌNG is default. You can specify a sort field dynamically by
specifying (<f>) instead of <fi>. Without the addition AS TEXT, strings are sorted
according to the sequence specified by the hardware platform. With AS TEXT, the
system sorts character fields alphabetically according to the current text environment.
Ìt only affects sort fields with type C. Ìf you sort a table several times by the same key,
the sequence of the table entries will change in each sort. Using STABLE option, the
sort sequence is preserved.
· Determining the Attributes of InternaI TabIes
DESRIBE TABE <itab> [INES <I>] [OURS <n>] [IND <k>].
<k> can be 'T' for standard table, 'S' for sorted table, and 'H' for hashed table. <n>
contains value of the ÌNÌTÌAL SÌZE of the table.<l> contains the number of filled lines.
System FieIds associated with internaI tabIes.
DESRIBE TABE <itab>.
SY-TABIX÷ index of itab SY-TFI ÷ number of rows in itab.
SY-TOU ÷ the OCCURS value SY-TENG ÷ length of a row in itab in bytes
Operations on individuaI Iines for aII tabIe types
· Inserting ines into TabIes :
- INSERT <Iine> INTO TABE <itab>.
To add a single line to an internal table. <line> is work area or header line or ÌNÌTÌAL
LÌNE. Ìf successful, SY-SUBRC is 0,otherwise 4. Lines are added to internal tables
Standard tabIes: The line is appended to the end of the internal table.
Sorted tabIes: The line is inserted into the table according to the table key as per the
sorted order . Ìf the key is non-unique, duplicate entries are inserted above the
existing entry with the same key. The runtime for the operation increases logarithmi-
cally with the number of existing table entries.
Hashed tabIes: The table is inserted into the internal hash administration according
to the table key.
- INSERT INES OF <itab1> [FROM <n
>] [TO <n
>] INTO TABE <itab2>.
The system inserts multiple lines of table <itab1> one by one into <itab2>. <itab1>
and <itab2> are tables with a compatible line type. Ìf <itab1> is an index table, you
can specify <n1> & <n2>.This method is 20 times faster than inserting them line by
line in a loop.
· Appending Summarized ines :
OET <wa> INTO <itab>.
To summate entries in an internal table. <itab> must have a flat line type, and all of
the fields that are not part of the table key must have a numeric type (F, Ì, or P). Ìf
there is no corresponding entry already in the table, the COLLECT statement has
the same effect as inserting new line ,Else COLLECT statement does not append a
new line, but adds the contents of numeric fields in the work area to the contents of the
numeric fields in the existing entry. The system field SY-TABÌX contains the index of
the line inserted or modified in the COLLECT statement for index tables. The system
field SY-TABÌX has value 0 for hashed tables as it has no linear index.
· Reading a singIe ine of TabIe :
1. READ TABE <itab> FROM <wa> INTO <wa> [OMPARING <f1> <f2> ...|A
FIEDS] [TRANSPORTING <f1> <f2> ...|A FIEDS|NO FIEDS].
The values of the key fields are taken from the corresponding components of work
area.<wa> must be a work area compatible with the line type of <itab>.
2. READ TABE <itab> WITH TABE EY <k1> = <f1> ... <k2> = <f2> INTO <wa>
[OMPARING .] [TRANSPORTING .].
You have to supply the values of each key field explicitly. You can specify a key field
dynamically by specifying (<f>) instead of <ki>.
3. READ TABE <itab> WITH EY = <f> INTO <wa>
[OMPARING ... ] [TRANSPORTING.].
Whole line of internal table is used as search key. contents of entire table line are
compared with contents of field <f>.Search key allows you to find entries in internal
tables that do not have a structured line type, that is, where the line is a single field or
an internal table type.
4. READ TABE <itab> WITH EY <k1> = <f1> ... <kn> = <fn > INTO <wa>
[OMPARING ...] [TRANSPORTING ...].
You have to supply the values of any of the table fields <k1> to <kn>.You can specify
a table field dynamically by specifying (<f>) instead of <ki>. Ìf you use COMPARÌNG
& TRANSPORTÌNG addition, the specified table fields <fi> of the structured line type
are compared with the corresponding fields of the work area before being transported.
Ìn both additions, you can specify a field <fi> dynamically.Ìf the system finds an entry
with the specified key <key> and if the contents of the compared fields are the same,
SY-SUBRC is set to 0. Ìf the contents of the compared fields are not same, it returns
the value 2. Ìf the system cannot find an entry, SY-SUBRC is set to 4. Ìf the internal
table is an index table, SY-TABÌX is set to the index of the line retrieved. Ìf the table has
a non-unique key and there are duplicate entries, the first entry is read.
5. ... Assigning <FS>..
You can assign the table entry read from the table to a field symbol instead of ÌNTO
<wa>. After READ statement, the field symbol points to the table line.
· hanging ines
1. MODIFY TABE <itab> FROM <wa> [TRANSPORTING <f1> <f2> .......]
<wa> is used to find one line that you want to change, but it also contains the new
contents.System searches the internal table for the line whose table key corresponds
to the key fields in <wa>. You can specify the non-key fields that you want to assign
to the table line in the TRANSPORTÌNG addition. You can also specify a field <fi>
dynamically. Ìf successful, SY-SUBRC is set to 0. Otherwise, SY-SUBRC is set to 4.
Ìf the table has a non-unique key and the system finds duplicate entries, it changes
the first entry.
2. MODIFY <itab> FROM <wa> TRANSPORTING <f1> <f 2> ... WHERE <cond>.
To change one or more lines using a logical condition <cond> in which first operand
must be a component of the line structure or TABLE LÌNE.TRANSPORTÌNG addition
is not optional. You can only modify the key fields of the internal table if it is a standard
table. Ìf at least one line is changed, the system sets SY-SUBRC to 0, otherwise to 4.
· DeIeting Iines :
1. DEETE TABE <itab> FROM <wa>.
<wa> is used to find one line that you want to delete.System searches internal table
for the line whose table key corresponds to the key fields in <wa>. Ìf the system finds
a line, it deletes it from the table and sets SY-SUBRC to zero.Otherwise, SY-SUBRC
is set to 4. Ìf the table has a non-unique key and the system finds duplicate entries, it
deletes the first entry.
2. DEETE TABE <itab> WITH TABE EY <k1> = <f1> ... <kn> = <fn>.
You have to supply the values of each key field explicitly.You can specify name of key
3. DEETE <itab> WHERE <cond>.
To delete more than one line using a logical condition <cond> in which the first
operand must be a component of the line structure or TABLE LÌNE.Ìf at least one line
is deleted, the system sets SY-SUBRC to 0, otherwise to 4.
4. DeIeting Adjacent DupIicate Entries
DEETE ADJAENT DUPIATES FROM <itab>[OMPARING <f1> <f2> ...
The system deletes all adjacent duplicate entries from the internal table <itab>.You
can use this statement to delete all duplicate entries from an internal table if the
table is sorted by the specified compare criterion. Ìf at least one line is deleted, the
system sets SY-SUBRC to 0, otherwise to 4. You can also specify a field <fi>
dynamically. Without the COMPARÌNG addition, the contents of the key fields of the
table must be identical in both lines. Ìf you use the addition COMPARÌNG <f1> <f2> ...
the contents of the specified fields must be identical in both lines. Ìf you use the
addition COMPARÌNG ALL FÌELDS the contents of all fields of both lines must be
· Processing TabIe Entries in oops
OOP AT <itab> INTO <wa> | ASSIGNING <FS> | TRANSPORTING NO FIEDS
This reads the lines of the table one by one. For Standard & sorted tables lines are
processed according to linear index. Within the processing block,system field
SY-TABÌX contains the index of current line. For Hashed tables,As long as the table
has not been sorted, the lines are processed in the order in which you added them
to the table.Within processing block,system field SY-TABÌX is always 0. You can nest
LOOP blocks. SY-SUBRC is 0 if at least one table entry was processed. Otherwise, it
is 4. When you call procedure within loops, it does not change entire internal table
otherwise loop can no longer work properly. Ìn each loop pass, field symbol <FS>
points to table entry read in that pass.TRANSPORTÌNG NO FÌELDS addition is useful
if you want to find index of a particular internal table, or the number of lines in a table
that meet a particular condition. Ìn logical condition <cond> the first operand must be
a component of line structure or TABLE LÌNE.
· ontroI IeveI processing
Control level processing is allowed within a LOOP over an internal table. This Means
that you can divide sequences of entries into groups based on contents of certain
fields. The first column defines the highest control level and so on. The control level
hierarchy must be known when you create the internal table.The control levels are
formed by sorting the internal table in the sequence of its structure, that is, by the first
field first, then by the second field, and so on.Tables in which the table key occurs at
the start of the table are particularly suitable for control level processing.Control level
statements are defined like:
FIRST First line of the internal table
AST Last line of the internal table
NEW <f> Beginning of a group of lines with the same contents in the field
<f> and in the fields left of <f>
END Of <f> End of a group of lines with the same contents in the field <f>
and in the fields left of <f>
You can also use ON HANGE OF <itab-f>..ENDON statements instead of NEW<f>.
Ìt executes the processing block enclosed by the "ON HANGE OF f" and "ENDON"
statements whenever the contents of the field f change (control break processing). Ìt
can be used in other loops also. Ìf the internal table has the columns <f
>, ...., and
if it is sorted by these columns, you must program the loop as follows:
OOP AT <itab>.
AT FIRST. ... ENDAT.
AT NEW <f1>. ...... ENDAT.
AT NEW <f
>. ...... ENDAT.
<singIe Iine processing>
AT END OF <f2>. ... ENDAT.
AT END OF <f1>. ... ENDAT.
AT AST. .... ENDAT.
You can specify <fi> dynamically. Ìf you are working with a work area <wa>, it does not
contain the current line in the AT... ENDAT statement block. All character fields to the
right of the current group key are filled with asterisks (*). All other fields to the right of
the current group key contain their initial value. Ìf you use SUM statement in an AT ÷
ENDAT block, the system calculates totals for the numeric fields of all lines in the
current line group and writes them to the corresponding fields in the work area . You
can only use this statement within a LOOP.
Operations on individuaI Iines for index tabIes
· Appending TabIe ines
1. APPEND <Iine> TO <itab>.
<line> is either a work area or ÌNÌTÌAL LÌNE. After each APPEND statement, the
system field SY-TABÌX contains the index of the appended line.For non-unique key,
duplicate entries may occur. A runtime error occurs if you attempt to add a duplicate
entry to a sorted table with a unique key. Equally, a runtime error occurs if you violate
the sort order of a sorted table by appending to it.
2. APPEND INES OF <itab1> [FROM <n1>] [TO <n2>] TO <itab2>.
To append an index table to another index table. After the APPEND statement,the
system field SY-TABÌX contains the index of the last line appended.
3. APPEND <wa> TO <itab> SORTED BY <f>.
You can use the APPEND statement to create ranked lists in standard tables.To do
this, create an empty table. The new line is not added to the end of internal table
<itab>. Ìnstead, the table is sorted by field <f> in descending order. The internal table
may only contain as many entries as you specified in the ÌNÌTÌAL SÌZE parameter of
the table declaration. You can use the APPEND statement to generate ranked lists
containing up to 100 entries. When dealing with larger lists, it is advisable to sort
tables normally for performance reasons.
· Inserting ines Using the Index
1. INSERT <Iine> INTO <itab> [INDEX <idx>].
To insert a single line into an index table. <line> is either a work area or ÌNÌTÌAL LÌNE. Ìf
the table contains <idx> -1 lines, the new line is added at the end of the table. Ìf the
table has less than <idx> - 1 lines, the new line cannot be inserted, and SY-SUBRC is
set to 4. When the system successfully adds a line to the table, SY-SUBRC is set to 0.
Without the ÌNDEX addition, you can only use the above statement within a LOOP
(<idx> is implicitly set to SY-TABÌX).
2. INSERT INES OF <itab1> [FROM <n
>] [TO <n
>] INTO <itab2> [INDEX <idx>].
The system inserts the lines of table <itab1> one by one into <itab2>.This method
faster than inserting them line by line in a loop.
· Reading ines Using the Index
1. READ TABE <itab> INDEX <idx> INTO <wa> [OMPARING <f
...|A FIEDS] [TRANSPORTING <f
> ...|A FIEDS|NO FIEDS].
2. READ TABE <itab> INDEX <idx> ASSIGNING <FS>.
if successful, SY-SUBRC is 0 & SY-TABÌX contains index of line.
· Binary Search in Standard TabIes
1. READ TABE <itab> WITH EY <k1> = <f1>... <kn> = <fn> INTO <wa>
[OMPARING ...][TRANSPORTING...] BINARY SEARH.
2. READ TABE <itab> WITH EY <k1> = <f1>... <kn> = <fn> ASSIGNING <FS>
3. READ TABE <itab> WITH EY = <f> INTO <wa> [OMPARING ...]
[TRANSPORTING...] BINARY SEARH.
To read entries from standard tables using a key other than the default key, you can
use a binary search instead of the normal linear search. The standard table must be
sorted in ascending order by the specified search key.
· Finding haracter Strings in InternaI TabIes
SEARH <itab> FOR <str> <options>.
Refer character string statement search for <str> & options>.The statement searches
the internal table <itab> for the character string <str>. Ìf the search is successful, SY-
SUBRC is set to 0 and SY-TABÌX is set to the index of the table line in which the string
was found. SY-FDPOS contains the offset position of the string in the table line.
Otherwise, SY-SUBRC is set to 4.
· hanging TabIe ines Using the Index
1. MODIFY <itab> FROM<wa>[INDEX<idx>] [TRANSPORTING <f
> ... ].
The work area <wa> addition replaces the existing line in <itab>. Ìf the operation is
successful, SY-SUBRC is set to 0. Ìf the internal table contains fewer lines than <idx>,
no line is changed and SY-SUBRC is set to 4. <idx> is implicitly set to SY-TABÌX in
loop statement. Ìf you change a sorted table, you should only specify non-key fields.
2. WRITE <f> TO <itab> INDEX <idx>.
Statement converts the contents of field <f> to type C and then transfers the resulting
character string into the line with index <idx>. Ìf the operation is successful, SY-
SUBRC is set to 0. Ìf the internal table contains fewer lines than <idx>, no line is
changed and SY-SUBRC is set to 4.
· DeIeting TabIe ines Using the Index
1. DEETE <itab> [INDEX <idx>].
Ìf system deletes the line with the index <idx> sets SY-SUBRC to 0. Otherwise, if no
line with index <idx> exists, SY-SUBRC is set to 4.<idx> is implicitly set to SY-TABÌX
2. DEETE <itab> [FROM <n
>] [TO <n
>] [WHERE <condition>].
To delete more than one line using the index.you must specify at least one of the
additions. Ìf at least one line is deleted,system sets SY-SUBRC to 0, otherwise to 4.
· Processing in Ioops.
OOP AT <itab> INTO <wa>|ASSIGNING FS>| TRANSPORTING NO FIEDS
>] [TO <n
>] where <cond>.
You can leave the loop with the CONTÌNUE or EXÌT statement. The system field SY-
TABÌX contains the index of the current line.
Access using FieId SymboI
· Field symbols allow you to read and change table entries directly.
· Ìf you try to assign a new value to a key field in sorted or hashed table using a field
symbol, a runtime error occurs.
· You cannot use the SUM statement with field symbols, since the statement is always
applied to work areas.
· Advantage : When you read from an internal table, there are no overheads for copying
the table line to the work area.
· Overheads while READ : After a READ statement, the system has to register the
assignment. When you delete a table line, system also has to unassign the field
symbol to prevent it from pointing to an undefined area.Use <fs>for tables with a line
width of 1000 bytes or more.
· Overheads for LOOP :The system does not register the assignment of each current
line to the field symbol. Ìnstead, it registers a general assignment between a line of
the table and the field symbol.. Ìf you include the statements ASSÌGN, UNASSÌGN, or
the ASSÌGNÌNG addition for the same field symbol within the loop block, a runtime
error occurs. it is worth using field symbols in a LOOP when the internal table has as
few as 10 lines.
Using Header ines as Work Areas
Operations without header Iine Operations with header Iine
Operations for aII TabIe Types
ÌNSERT <wa> ÌNTO TABLE <itab>. ÌNSERT TABLE <itab>.
COLLECT <wa> ÌNTO <itab>. COLLECT <itab>.
READ TABLE <itab> ... ÌNTO <wa>. READ TABLE <itab> ...
MODÌFY TABLE <itab> FROM <wa> ... MODÌFY TABLE <itab> ...
MODÌFY <itab> FROM <wa> ...WHERE ... MODÌFY <itab> ... WHERE ...
DELETE TABLE <itab> FROM <wa>. DELETE TABLE <itab>.
LOOP AT ÌTAB ÌNTO <wa> ... LOOP AT ÌTAB ...
Operations for Index TabIes
APPEND <wa> TO <itab>. APPEND <itab>.
ÌNSERT <wa> ÌNTO <itab> ... ÌNSERT <itab> ...
MODÌFY <itab> FROM <wa> ... MODÌFY <itab> ...
· An Extract is a dynamic sequential dataset in which all records can have records of
different length and structure.
· Ìndex or key access permitted with internal tables is not allowed.
· You may only create one extract in any ABAP program.
· Extracts larger than 500KB are stored in operating system files. The practical size of
an extract is up to 2GB, as long as there is enough space in the file system.
· Ìn contrast to internal tables, the system partly compresses extract datasets when
storing them. This reduces the storage space required.
· You need not specify the structure of an extract dataset at the beginning of the
program, but you can determine it dynamically during the flow of the program.
· You can use control level processing with extracts.Ìt is quicker to use than an internal
· Procedure for creating an Extract:
1. Define the record types that you want to use in your extract by declaring them as field
groups. The structure is defined by including fields in each field group.
2. Fill the extract line by line by extracting the required data.
3. Once you have filled the extract, you can sort it and process it in a loop. At this stage,
you can no longer change the contents of the extract.
· Defining an Extract
1. FIED-GROUPS <fg>.
2. FIED-GROUPS HEADER.
3. INSERT <f1>... <fn> INTO <fg>.
All records with same structure form a record type.You must define each record type
as a field group, using FÌELD-GROUPS statement.A field group does not reserve
storage space for fields, but contains pointers to existing fields.You can also define a
special field group called HEADER.This group is automatically placed before any other
field groups when you fill the extract.When sorting extract dataset,system uses fields in
HEADER as default sort key.ÌNSERT statement defines fields of field group <fg> or
header.Fields in the field group must be global data objects in the ABAP program.You
cannot assign a local data object defined in a procedure to a field group. The ÌNSERT
statement, just as the FÌELD-GROUPS statement,neither reserves storage space nor
transfers values. Ìf the field group HEADER is defined, an undefined field group
consists implicitly of the fields in HEADER, otherwise, it is empty.
· FiIIing an Extract with Data
1. EXTRAT <fg>.
2. EXTRAT [HEADER].
When the first EXTRACT statement occurs in a program, the system creates extract
dataset and adds first extract record to it. Ìn each subsequent EXTRACT statement,
the new extract record is added to the dataset. Each extract record contains exactly
those fields that are contained in the field group <fg>, plus the fields of the field group
HEADER (if one exists).As soon as the system has processed the first EXTRACT
statement for a field group <fg>,You can no longer insert new fields into the field groups
<fg> & HEADER. A runtime error occurs.
· Processing Extracts
1. Sorting Extracts :
SORT [ASENDING|DESENDING] [AS TEXT] [STABE]
> [ASENDING|DESENDING] [AS TEXT]
> [ASENDING|DESENDING] [AS TEXT].
- No further EXTRACT statements may occur after the sort statement, otherwise a
runtime error occurs.
- All fields by which you want to sort are contained in the HEADER
- Without the BY option, the system sorts the dataset by the key specified in the
HEADER field group.
2. Reading an Extract
3. ontroI eveIs Processing :
Ìf you have sorted an extract dataset by the fields <f1>, <f2>, ..., from HEADER the
processing of the control levels should be written like:
AT FIRST.... ENDAT.
AT NEW <f
AT NEW <f
> [WITH <fg
>] ..... ENDAT.
<singIe Iine processing without controI statement>
AT END OF <f
AT END OF <f
AT AST..... ENDAT.
- AT <fgi> [WITH <fgj>] : The system processes the statement block, if the record
type of the currently read extract record was defined using the field group <fgi>.
When using the WÌTH <fgj> option, in the extract dataset, the currently read record of
field group <fgi> must be immediately followed by a record of field group <fgj>.
- NT(<f>) : Ìf <f> is a non-numeric field of the HEADER field group and the system
sorted the extract dataset by <f>, CNT(<f>) contains the number of different values
<f> assumed within the control level or entire dataset respectively. The system fills
these fields at the end of a control level (AT END OF ) and after reading last record of
dataset (AT LAST).
- SUM(<g>) : Ìf <g> is a numeric field of the extract dataset, SUM (<g>) contains the
total of the values of <g> within the control level or entire dataset respectively. The
system fills these fields at the end of a control level (AT END OF ) and after reading
last record of dataset (AT LAST).
Data clusters are the group of any number of internal data objects from an ABAP
program which can be stored externally outside internal session of that program group.
You can store data clusters in ABAP memory temporarily or in database persistently.
Three ways of storing data externally.
1. ABAP memory.
2. Iuster database
Data Iusters in ABAP Memory
You can store data clusters in ABAP memory.An object saved in ABAP memory can be
read from any other ABAP program in the same call chain. You can pass data
- From an executable program (report) to another executable program called using
- From a transaction to an executable program (report).
- Between dialog modules.
- From a program to a function module.
and so on.The contents of the memory are released when you leave the
· Saving Data Objects in ABAP Memory :
> [FROM <g
> [FROM <g
>] ... TO MEMORY ID <key>.
This statement stores the data objects specified in the list as a cluster in memory. Ìf you
do not use the option FROM <fi>, the data object <fi> is saved under its own name. Ìf
you use the FROM <gi> option, the data object <gi> is saved under the name <fi>. The
name <key> identifies the cluster in memory. Ìt may be up to 32 characters long. The
EXPORT statement always completely overwrites the contents of any existing data
cluster with the same name <key>.Ìf you are using internal tables with header lines, you
can only store the table itself, not the header line.
· Reading Data Objects from ABAP Memory :
> [TO <g
> [TO <g
>] ... FROM MEMORY ID <key>.
You do not have to read all of the objects stored under a particular name <key>. Ìf the
memory does not contain any objects under the name <key>, SY-SUBRC is set to
4.Otherwise 0, regardless of whether it contained the data object <fi>.Ìf the cluster
does not contain the data object <fi>>, the target field remains unchanged. the system
does not check whether the structure of the object in memory is compatible with the
structure into which you are reading it.The data in the target field may be incorrect.
· DeIeting Data Iusters from ABAP Memory
FREE MEMORY [ID <key>].
Ìf you omit the addition ÌD <key>, the system deletes the entire memory.
Data Iusters in the Database
You can store data clusters in special relational databases in the ABAP Dictionary
called cluster databases.
Ex : system cluster database INDX.
You can either create your own cluster databases or you can use the system cluster
· Saving Data Objects in Iuster Databases
> [FROM <g
> [FROM <g
TO DATABASE <dbtab>(<ar>) [IENT <cIi>] ID <key>.
This statement stores the data objects specified in the list as a cluster in the cluster
database <dbtab>.You must declare <dbtab> using a TABLES statement. The CLÌENT
<cli> option allows you to disable the automatic client handling of a client-specific
cluster database. The EXPORT statement also transports the contents of the user
fields of the table work area <dbtab> into the database table. You can fill these fields
yourself beforehand.The EXPORT statement always completely overwrites the
contents of any existing data cluster in the same area <ar> with the same name <key>
in the same client <cli>. Ìf you are using internal tables with header lines, you can only
store the table itself, not the header line.
· reating a Directory of a Data Iuster
IMPORT DIRETORY INTO <dirtab> FROM DATABASE
<dbtab>(<ar>) [IENT <cIi>] ID <key>.
This creates a directory of data objects belonging to a data cluster in database <dbtab>
in internal table <dirtab>.ÌMPORT statement also reads contents of user fields from
database table.Ìf system is able to create a directory, SY-SUBRC is set to 0, otherwise
to 4. The internal table <dirtab> must have the ABAP Dictionary structure CDÌR. You
can declare it using TYPE addition in DATA statement.CDÌR has following components:
FieId name Type Description
NAME CHAR(30) Name of the object in the cluster
OTYPE CHAR(1) Object type: F: elementary field
T: internal table
FTYPE CHAR(1) Data type of object: Structured has data types C
TFÌLL ÌNT4 Number of filled lines in internal tables
FLENG ÌNT2 Length of field or structure
· Reading Data Objects From Iuster Databases
> [TO <g
> [TO <g
>] ... FROM DATABASE
<dbtab>(<ar>) [IENT <cIi>] ID <key>.
The ÌMPORT statement also reads the contents of the user fields from the database
table. Ìf the database does not contain any objects that correspond to the key <ar>,
<key>, and <cli>, SY-SUBRC is set to 4. Ìf, on the other hand, there is a data cluster in
the database with the same key, SY-SUBRC is always 0, regardless of whether it
contained the data object <fi>. Ìn this statement, the system does not check whether
the structure of the object in the database is compatible with the structure into which
you are reading it. Ìf this is not the case, a runtime error occurs.
· DeIeting Data Iusters from Iuster Databases :
DEETE FROM DATABASE <dbtab>(<ar>) [IENT <cIi>] ID <key>.
The DELETE statement deletes all of the lines in the cluster database over which the
data cluster extends. Ìf the system is able to delete a data cluster with the specified
key, SY-SUBRC is set to 0, otherwise to 4.
· Open SQ Statements and Iuster Databases :
You can use OPEN SQL statements to access cluster databases.There is little sense
in reading the fields CLUSTR and CLUSTD using the SELECT statement, or changing
them using UPDATE as it contains the coded data clusters. You should only use the
Open SQL statements UPDATE, MODÌFY, and DELETE if the runtime of the corres-
ponding data cluster statements is too long. Do not use the Open SQL statement
ÌNSERT at all in cluster databases.
Working with FiIes on the AppIication Server
· Opening a FiIe for Read Access
OPEN DATASET <dsn> FOR INPUT.
This statement opens the file <dsn> for reading. Ìf you do not specify any additions for
the mode, the file is opened in binary mode for reading. SY-SUBRC returns 0 if the
system opens the file. The file must already exist, otherwise, the system sets SY-
SUBRC to 8, and ignores the statement. <dsn> can be literal or field. Ìf the file exists
and is already open, the position is reset to the beginning of the file.
· Opening a FiIe for Write Access
OPEN DATASET <dsn> FOR OUTPUT.
Ìf the file does not already exist, it is created automatically. Ìf it does already exist, but
is closed, its contents are overwritten. Ìf the file exists and is already open,the position
is reset to the beginning of the file. Ìf successfully, SY-SUBRC is 0.otherwise 8.
· Opening a FiIe for Appending Data
OPEN DATASET <dsn> FOR APPENDING.
This statement opens a file to which you can append data. Ìf the file does not already
exist, it is created automatically.Ìf it does exist, but is closed, the system opens it, and
sets the position to the end of the file. Ìf the file exists and is already open,the position
is set to the end of the file. SY-SUBRC is always 0.
NOTE : Ìf you do not specify a path for filename,system opens the file in the directory
in which the R/3 System is running on the application server.
· Using Binary Mode
OPEN DATASET <dsn> FOR .... IN BINARY MODE.
Ìf you read from or write to a file that is open in binary mode,the data is transferred
byte by byte. The system does not interpret the contents of the file while it is being
· Using Text Mode
OPEN DATASET <dsn> FOR .... IN TEXT MODE.
Ìf you read from or write to a file that is open in text mode, the data is transferred Iine
by Iine. The system assumes that the file has a line structure.While writing, system
places an end of line marker at the end.While reading, system reads all of the data up
to the next end of line marker. You should always use text mode if you want to write
strings to files or where you know that an existing file has a line construction like all
· Opening a FiIe at a Given Position
OPEN DATASET <dsn> [FOR ....] [IN ... MODE] AT POSITION <pos>.
This statement opens file <dsn>, and prepares it for reading or writing from position
<pos>. <pos> is no. of bytes from beginning of file.Use binary mode.
· Executing Operating System ommands
OPEN DATASET<dsn>[FOR ..] [IN .. MODE] AT POSITION <pos> FITER <fiIt>.
Operating system command ( like 'compress','uncompress') in the field <filt> is
processed when file <dsn> is opened Ìf your system is running under UNÌX or
· Receiving Operating System Messages
OPEN DATASET <dsn> [FOR ....] [IN ... MODE] AT POSITION <pos> FITER
<fiIt> MESSAGE <msg>.
This statement imports message from operating system & places it in variable <msg> .
You can use this addition along with system field SY-SUBRC for error handling.
· Iosing a FiIe
OSE DATASET <dsn>.
To avoid errors, and to make your programs easier to read, you should always close a
file before the next OPEN DATASET statement. You only need to close a file if next
time you open it for write access.
· DeIeting a FiIe
DEETE DATASET <dsn>.
This statement deletes file <dsn>.Ìf successful, SY-SUBRC is 0 else 4.
· Writing Data to FiIes
TRANSFER <f> to <dsn> [ENGTH <Ien>].
This statement writes the values of the field <f> into the file <dsn>.<f> can have an
elementary data type, but may also be a structure, as long as it does not contain an
internal table. You cannot write internal tables into files in a single step. You can
specify the length of the data you want to transfer using the LENGTH addition. The
system then transfers the first <len> bytes into the file.
· Reading Data from FiIes
READ DATASET <dsn> INTO <f> [ENGTH <Ien>].
This statement reads data from file <dsn> into the variable <f>. Ìn order to determine
into which variable you should read data from a file, you need to know the structure of
the file.Ìf successful, SY-SUBRC is set to 0. When the end of the file is reached, SY-
SUBRC is set to 4. Ìf the file could not be opened,SY-SUBRC is set to 8. Ìf you are
working in binary mode, you can use the LENGTH addition to find out the length of the
data transferred to <f>.
· Using authorization object S_DATASET
The system automatically checks the user's authorization against the authorization
object S_DATASET while reading,writing,deleting & transferring.Ìf the result of the
automatic authorization check is negative, a runtime error occurs.
AUTHORÌTY_CHECK_DATASET function module allows you to check whether the
user is authorized to access a file before the system tries to open it. This avoids a
possible runtime error.This function has three import Parameters program, activity,
filename.Use type-pool SABC for activity.
· hecking authorization using tabIe SPTH
The system automatically checks authorization against table SPTH. SPTH contains the
PATH : Ìt contains generic filenames like ,*, /tmp, /tmp/myfile
SAVEFAG :Ìf the flag is set ( 'X' ), the files specified in the PATH column are
included in security procedures.
FS_NOREAD : Ìf flag is set ( 'X' ), files specified in the PATH column may not be
accessed at all from ABAP. FS_NOWRÌTE is also automatically set.
FS_NOWRITE : Ìf the flag is set ( 'X'), the files specified in the PATH column may not
be accessed for changing from ABAP.
FSBRGRU : This column contains the names of authorization groups. Authorization
object S_PATH contains first field (RS_BRGRU) which corresponds to authorization
group.You can use second field of authorization object S_PATH (ACTVT) to check
whether user has authorization to read (value 3) or change (value 2) the files in the
Working with FiIes on the Presentation Server
To work with files on the presentation server, you use special function modules. Ìnternal
tables serve as an interface between programs & function modules.
· Writing Data to Presentation Server with DiaIog :
To write data from an internal table to the presentation server using a user dialog, use
the function module DOWNOAD.
Import Parameter Function
BÌN_FÌLESÌZE File length for binary files
CODEPAGE Only for download under DOS: Value ÌBM
FÌLENAME Filename (default value for user dialog)
FÌLETYPE File type (default value for user dialog)
ÌTEM Title for dialog box
MODE Write mode (blank = overwrite, 'A' = append)
FÌLETYPE File Type
File Type has following types
- BIN : Binary files: You must specify the file length. The internal table must consist
of a single column with data type X.
- AS : ASCÌÌ files(.txt).
- DAT : Excel files (.xls/.txt) The columns are separated using tabs. The lines are
separated with line breaks.
- W1 : Excel and Lotus files: The files are saved in a WK1 spreadsheet.
Export Parameter Function
ACT_FÌLENAME File name (as entered in the user dialog)
ACT_FÌLETYPE File type (as entered in the user dialog)
FÌLESÌZE Number of bytes transferred
TabIe Parameter Function
DATA_TAB Ìnternal table containing data
Exception Parameter Function
ÌNVALÌD_FÌLESÌZE Ìnvalid parameter BÌN_FÌLESÌZE
ÌNVALÌD_TABLE_WÌDTH Ìnvalid table structure
ÌNVALÌD_TYPE Value of FÌLETYPE parameter is incorrect
· Writing Data to Presentation Server without DiaIog :
Use the function module WS_DOWNOAD.Refer documentation(SE37).
· Reading Data from Presentation Server with DiaIog :
Use the function module UPOAD. Refer documentation(SE37).
· Reading Data from Presentation Server without DiaIog :
Use the function module WS_UPOAD. Refer documentation(SE37).
· Use the foIIowing function moduIes when working with fiIes on the
presentation server from 4.7 version onwards:
Class CL_GUÌ_FRONTEND_SERVÌCES gives you the relevant information. The
physical names of the files depend on the operating system of the presentation server.
· To display filename in F4(POV request) in Pop up, call the function module :
1. CALL FUNCTÌON 'WS_FIENAME_GET'
MASK = ',*.*,*.*.'
FÌLENAME = FNAME
ÌNV_WÌNSYS = 1 NO_BATCH = 2
SELECTÌON_CANCEL = 3 SELECTÌON_ERROR = 4
OTHERS = 5.
ÌF SY-SUBRC <> 0.
MESSAGE ÌD SY-MSGÌD TYPE SY-MSGTY NUMBER SY-MSGNO
WÌTH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
2. PERFORM vaIue_request_pc_fiIe_downIoad USING zpresxI
FORM value_request_pc_file_download USÌNG field.
CLASS cl_gui_frontend_services DEFÌNÌTÌON LOAD.
DATA: files TYPE filetable, rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
initial_directory = 'C:\'
file_table = files
rc = rc.
READ TABLE files ÌNDEX 1 ÌNTO field.
DownIoad InternaI TabIe To ExceI Sheet
UpIoad/DownIoad ExceI Sheet to InternaI TabIe
1. To DownIoad InternaI tabIe to ExceI Sheet :
CALL FUNCTÌON 'MS_EXCEL_OLE_STANDARD_DAT'.
1. To UpIoad ExceI Sheet to InternaI TabIe :
CALL FUNCTÌON 'ALSM_EXCEL_TO_ÌNTERNAL_TABLE'.
Using PIatform-Independent FiIenames
To make programs portable, the R/3 System has a concept of logical filenames and
paths. These are linked to physical files and paths . Ìn an ABAP program, you can then
use the function module FIE_GET_NAME to generate a physical filename from a
logical one. For maintaining platform-independent filenames use the Transaction FIE.
1. Maintaining Syntax Groups
2. Assigning Operating Systems to Syntax Groups
3. reating and Defining ogicaI Paths
4. reating and Defining ogicaI FiIenames
5. Using ogicaI FiIes in ABAP Programs by caIIing FIE_GET_NAME function
The physical path must always contain the reserved word <FÌLENAME>. Reserved
word <PARAM_1> , <PARAM_2> & <PARAM_3> is an import parameter of the
function module FÌLE_GET_NAME.<FÌLENAME> is replaced by corresponding
physical file name during run time.
Ìn addition to the mandatory placeholder "<FÌLENAME>", you can use the following
reserved words, which are substituted with the current values at runtime. Reserved
words must be enclosed in angle brackets.
Reserved word substitution vaIue
<FÌLENAME> Name of the file according to request
<OPSYS> Operating system acc. to request
<ÌNSTANCE> Ìnstance of the R/3 application
<SYSÌD> Name of the R/3 application acc. to SY-SYSÌD
<DBSYS> Data base system acc. to SY-DBSYS
<SAPRL> R/3 Release acc. to SY-SAPRL
<HOST> Host name acc. to SY-HOST
<MANDT> Client acc. to SY-MANDT
<LANGUAGE> Logon language acc. to SY-LANGU
<DATE> Date acc. to SY-DATUM
<YEAR> Year acc. to SY-DATUM, four characters
<SYEAR> Year acc. to SY-DATUM, two characters
<MONTH> Month acc. to SY-DATUM
<DATE> Day acc. to SY-DATUM
<WEEKDAY> weekday acc. to SY-FDAYW
<TÌME> Time acc. to SY-UZEÌT
<STÌME> Hour and minute acc. to SY-UZEÌT
<HOUR> Hour acc. to SY-UZEÌT
<MÌNUTE> Minute acc. to SY-UZEÌT
<SECOND> Second acc. to SY-UZEÌT
<PARAM_1> External parameter 1
<PARAM_2> External parameter 2
<P=name> Name of a profile parameter
(see report RSPARAM for valid entries)
<V=name> Name of a variable
(stored in Variables table)
<F=name> Return value of a specific function module Naming convention
for this function module: FÌLENAME_EXÌT_NAME
<CLÌENT> Client acc. to SY-MANDT
- Local directory for temporary files under Windows NT:
- Local directory for temporary files under DOS:
- Local directory for temporary files under UNÌX:
· Note : To create a directory in Application server, Use Tcode A11.
Accessing the Database in the R/3 System
· Standard SQ : SQL (Structured Query Language) is a largely standardized
language for accessing relational databases. Ìt can be divided into three areas:
Data ManipuIation anguage (DM) : Statements for reading and changing data in
Data Definition anguage (DD) : Statements for creating and administering
Data ontroI anguage (D) : Statements for authorization & consistency checks.
· The Database Interface: Each work process on an application server has a
database interface. The R/3 System communicates with the database by means of
this interface. The database interface converts all of the database requests from
the R/3 System into the correct Standard SQL statements for database system.
· Open SQ : Open SQL statements are a subset of Standard SQL that is fully
integrated in ABAP. They allow you to access data irrespective of the database
system that the R/3 installation is using. Open SQL consists of the Data Manipulation
Language (DML) part of Standard SQL. ABAP programs that only use Open SQL
statements will work in any R/3 System, regardless of the database system in use.
Open SQL statements can only work with database tables that have been created in
the ABAP Dictionary.
· Native SQ : Native SQL is only loosely integrated into ABAP, and allows access to
all of the functions contained in the programming interface of the respective database
system. Unlike Open SQL statements, Native SQL statements are not checked and
converted, but instead are sent directly to database system. Programs that use Native
SQL are specific to the database system for which they are written.
· The ABAP Dictionary : The ABAP Dictionary uses the DDL part of Open SQL to
create and change database tables. Ìt also administers the ABAP Dictionary in the
· Authorization and onsistency hecks : The authorizations of programs or
users to read or change database tables is administered within the R/3 System using
the R/3 authorization concept.
Open SQL is a subset and variation
of ANSÌ SQL.
The ABAP/4 interpreter passes all
Open SQL statements to the database
interface part of the work process .
There , they are converted to SQL
that is native to the installed DBMS.
Advantages of Open SQ.
· PortabiIity : The SQL statements will be portable between databases.
· Buffering Data on the AppIication Server: The database interface buffers
information from the database on the application server.
· Automatic Iient HandIing : The client field is automatically populated by the
database interface in the WHERE clause of an Open SQL statement. You need to
specify the client specifically in an Open SQL statement, use the addition
... IENT SPEIFIED ....
directly after the name of the database table. This addition disables the automatic
client handling and you can use the field MANDT both in the WHERE clause and in a
table work area.
All Open SQL statements fill the following two system fields with return codes:
· SY-SUBR : After every Open SQL statement, the system field SY-SUBRC contains
the value 0 if operation was successful, a value other than 0 if not.
· SY-DBNT: After an open SQL statement, the system field SY-DBCNT contains the
number of database lines processed.
Reading data from database
The Open SQL statement for reading data from database tables is:
SEET <resuIt> INTO <target> FROM <source> [WHERE <condition>]
[GROUP BY <fieIds>] [HAVING <cond>] [ORDER BY <fieIds>].
SEET <resuIt> : The SELECT clause defines the structure of the data you want to
read, that is, whether one line or several, which columns you want to read, and
whether identical entries are acceptable or not.
INTO <target>: The ÌNTO clause determines the target area <target> into which the
selected data is to be read.
FROM <source>: The FROM clause specifies the database table or view <source>
from which the data is to be selected. Ìt can also be placed before ÌNTO clause.
WHERE <cond>: The WHERE clause specifies which lines are to be read by
specifying conditions for the selection.
GROUP BY <fieIds>: GROUP-BY clause produces a single line of results from groups
of several lines.A group is a set of lines with identical values for each column listed in
HAVING <cond>: The HAVÌNG clause sets logical conditions for the lines combined
using GROUP BY.
ORDER BY <fieIds>: The ORDER-BY clause defines a sequence <fields> for the
lines resulting from the selection.
1. SEET <resuIt> : The SELECT clause can be divided into two parts for lines
SEET <Iines> <coIs> ...
<lines> specifies whether you want to read one or more lines. <cols> defines the
· Reading a SingIe ine:
SEET SINGE <coIs> ... WHERE ...
To read a single entry from the database. Ìf system finds a line with the corresponding
key, SY-SUBRC is set to 0, otherwise to 4.
· Reading SeveraI ines:
SEET [DISTINT] <coIs> ... WHERE ...
Ìf you do not use DÌSTÌNCT (<lines> is then empty), the system reads all of the lines
that satisfy the WHERE condition. Ìf you use DÌSTÌNCT, system excludes duplicate
entries.Entries not necessarily be adjacent.The target area of the ÌNTO clause can be
an internal table with a line type appropriate for <cols>. Ìf the target area is not an
internal table, but a flat structure, you must include an ENDSELECT statement after
the SELECT statement:
SEET [DISTINT] <coIs> ... WHERE ...
Ìf at least one line is read, SY-SUBRC is set to 0 after the statement (or loop) has
been processed. Ìf no lines are read, SY-SUBRC is set to 4. The number of lines
read is placed in the system field SY-DBCNT. Within the loop, SY-DBCNT already
contains the number of lines that have already been passed to the target area.
Technically, it is possible to nest SELECT loops. For performance reasons, you should
avoid doing so.
· Reading the WhoIe ine:
SEET <Iines> * ...
This reads all columns for the specified lines. Reading individual columns can be
considerably more efficient than reading all of the columns in a table. You should
therefore only read the columns that you need in your program.
· Reading SingIe oIumns
SEET <Iines> <s
> [AS <a
> [AS <a
There are different ways of addressing the columns, depending on the form of your
- <si> specifies the component <ci> of the database table. This is only possible if the
corresponding name is unique. This is always the case if you only specify a single
database table in the FROM clause.
- <si> specifies the full name of the required component in the form <dbtab>~ <ci>
where <dbtab> is the name of the database table. This is always necessary if the
component name appears in more than one database table in the FROM clause, &
is only possible if database table <dbtab> only appears once in the FROM clause.
- <si> specifies the full name of the required component in the form <tabalias>~<ci>
where <tabalias> is an alias name for the database table. This is always necessary if
the table from which you want to read occurs more than once in the FROM clause.
You must define the alias name <tabalias> in the FROM clause. Ìn the SELECT
clause, you can use the AS addition to specify an alias name <ai> for each column
<si>. The alias column name is used instead of the real name in the ÌNTO and
ORDER BY clauses.
· Reading Aggregate Data for oIumns
SEET <Iines> <agg>( [DISTINT] <s
> ) [AS <a
<agg>( [DISTINT] <s
> ) [AS <a
To read aggregate data for a column in the database.The expression <agg>
represents one of the following aggregate functions:
- MAX: returns the maximum value of the column <si>.
- MIN: returns the minimum value of the column <si>
- AVG: returns the average value of the column <si>
- SUM: returns the sum value of the column <si>
- OUNT( DISTINT <s
> ): returns the number of different values in column <s
- OUNT( * ) : returns the total number of lines in the selection.
The arithmetic operators AVG and SUM only work with numeric fields. The data type
of aggregate functions using MAX,MÌN,or SUM is the Dictionary type of correspond-
ing column. Aggregate expressions with the function AVG have the Dictionary type
FLTP, and those with COUNT have the Dictionary type ÌNT4.
· Specifying oIumns DynamicaIIy
SEET <Iines> (<itab>/ <str>) .....
To specify <cols> dynamically. The parentheses must include the name of an internal
table <itab> or character string <str> that is either empty or contains <s1> <s2> ....
to specify the columns or aggregate expressions to be read. For this purpose, the line
type of <itab> or string must be a type C field with a maximum length of 72. Ìf the
internal table or string is empty, the system reads all columns.
2. INTO <target>: The ÌNTO clause defines the target area into which selection
from the SELECT clause is written. Ìf you select a single line, the target area must be
flat. Ìf you select more than one line, the target area may be either tabular or flat. Ìf
target area is flat,you need to use SELECT loop.When you select all of the columns,
target area must either be a structure or convertible into one.When you select indivi-
dual columns, target area can be a component of a structure or a single field.
· Specifying a FIat Work Area :
SEET ... INTO [ORRESPONDING FIEDS OF] <wa> ..
When you read the data into <wa>, its previous contents are overwritten. However,
the components of <wa> that are not affected by the SELECT statement retain their
previous values.Ìf work area is structured, you can use CORRESPONDÌNG FÌELDS
addition.This transfers only the contents of fields whose names are identical in the
database table and the work area. Declare table work area using the TABLES
statement if you want to omit ÌNTO clause.
· Specifying InternaI TabIes :
SEET ... INTO|APPENDING [ORRESPONDING FIEDS OF] TABE
<itab> [PAAGE SIZE <n>] ...
When you read several lines of a database table, you can place them in an internal
table. When you use ÌNTO, all existing lines in the table are deleted. When you use
APPENDÌNG, the new lines are added to the existing internal table <itab>. With
APPENDÌNG, the system adds the lines to the internal table appropriately for the table
type. Fields in internal table not affected by the selection are filled with initial values. Ìf
you use the PACKAGE SÌZE addition,the lines of the selection are not written into the
internal table at once, but in packets. You can define packets of <n> lines that are
written one after the other into the internal table.Ìf you use ÌNTO, each packet
replaces the preceding one. Ìf you use APPENDÌNG, the packets are inserted one
after the other. This is only possible in a loop that ends with ENDSELECT. Without
package size, do not mention ENDSELECT.
· Specifying SingIe FieIds
SEET ... INTO (<f
>, ...). ...
You must specify as many individual fields <fi> as are specified in the field list of the
3. FROM <source> : The FROM clause has two parts , one for specifying
database tables, and one for other additions:
SEET... FROM <tabIes> <options>...
<options> allows you to specify further additions that control the database access.
· Specifying Database TabIes StaticaIIy :
SEET... FROM <dbtab> [AS <aIias>] <options> .....
The AS addition allows you to specify an alternative name <alias> that you can then
use in the SELECT, FROM, WHERE, and GROUP BY clauses.
· Specifying Database TabIes DynamicaIIy :
SEET... FROM (<str>) <options> . ..
The field <str> must contain the name of a database table or view in the ABAP
Dictionary. The table name must be written in uppercase. When you specify the name
of a database table dynamically, you cannot use an empty ÌNTO clause to read all of
the columns into the work area <dbtab>. Ìt is also not possible to use alternative table
· Specifying Two or More Database TabIes as an Inner Join :
SEET...... FROM <TAB> [INNER] JOIN <RTAB> [AS <aIias>] ON <cond>
Here,<LTAB> is Left-hand table and <RTAB> is Right-hand table. You can read
from more than one table in a single SELECT statement, such that the data in the
tables all has to meet the same conditions. <RTAB> is a single database table and
<LTAB> is either a table or another join expression. The database tables can be
specified statically or dynamically. You may also use aliases. You can enclose each
join expression in parentheses. The ÌNNER addition is optional. A join expression
links each line of <LTAB> with the lines in <RTAB> that meet the condition <cond>. Ìf
<RTAB> does not contain any lines that meet the condition <cond>, the line from
<LTAB> is not included in selection.<cond> must contain a column from the right-
hand table <RTAB>. Ìt does not matter on which side of the comparison it occurs.
Each join must contain at least one comparison in the condition <cond>.
· Specifying Two or More Database TabIes as a eft Outer Join :
SEET...... FROM <TAB> EFT [OUTER] JOIN <RTAB> [AS <aIias>] ON
The left outer join reads lines from the left-hand database table or join even if there is
no corresponding line in the right-hand table. The OUTER addition is optional. All lines
selected from <LTAB> are included in the final selection. Ìf <RTAB> does not contain
any lines that meet the condition <cond>,system includes a single line in the selection
whose columns from <RTAB> are filled with null values. Ìn the left outer join, more
restrictions apply to the condition <cond> like :
- EQ or = is the only permitted relational operator in ON clause.
- There must be at least one comparison between columns from <LTAB> and
- The WHERE clause may not contain any comparisons with columns from <RTAB>.
All comparisons using columns from <RTAB> must appear in the condition <cond>.
- There should not be another join statement after left outer join.
· Iient HandIing :
SEET... FROM <tabIes> IENT SPEIFIED........
You can switch off the automatic client handling in Open SQL statements. Ìf you use
this addition, you can then address the client fields in the individual clauses of the
· DisabIing Data Buffering :
SEET... FROM <tabIes> BYPASSING BUFFER. ..
To read data directly from the database table instead of from the buffer. Data you
read is the most up to date.
· Restricting the Number of ines :
SEET... FROM <tabIes> UP TO <n> ROWS. ..
Ìf <n> is a positive integer, the system reads a maximum of <n> lines. Ìf <n> is zero,
the system reads all lines that meet the selection criteria. Ìf you use the ORDER BY
clause as well, the system reads all lines belonging to the selection, sorts them, and
then places the first <n> lines in the selection set.
4. WHERE <cond>: The WHERE clause restricts the number of lines selected
by specifying conditions. A line is only selected if the condition is true for it.
· omparisons for AII Types :
SEET ... WHERE <s> <operator> <f> ...
<s> represents a column of one of the database tables named in the FROM clause.
<f> can be another column in a database table from the FROM clause, a data object,
or a scalar subquery.
· VaIues in IntervaIs :
SEET ... WHERE <s> [NOT ] BETWEEN <f
> AND <f
The condition is true if the value of column <s> is [not] between the values of the data
> and <f
>. You can't use BETWEEN in the ON condition of FROM clause.
· omparing Strings :
SEET ... WHERE <s> [NOT ] IE <f> [ESAPE <h>] ...
The condition is true if the value of the column <s> matches [does not match] the
pattern in the data object <f>. <f> must have data type C. You can use the following
wildcard characters in <f>:
- % for a sequence of any characters (including spaces).
- _ for a single character.
Ìf you want to use the two wildcard characters explicitly in the comparison, use the
ESCAPE option. ESCAPE <h> specifies an escape symbol <h>. Ìf preceded by <h>,
the wildcards and the escape symbol itself lose their usual function within the pattern
<f>. Logical expressions elsewhere in ABAP use other wildcard characters (+ and *).
You cannot use LÌKE in the ON condition of the FROM clause.
· hecking ists of VaIues :
SEET ... WHERE <s> [NOT ] IN (<f
>, ......, <f
The condition is true if the value of column <s> is [not] in the list <f
· hecking Subqueries :
SEET ... WHERE <s> [NOT ] IN <subquery> ...
The condition is true if the value of <s> is [not] contained in the results set of the scalar
SEET ... WHERE [ NOT ] EXISTS <subquery> ...
This condition is true if the result set of the subquery <subquery> contains at least
one [no] line. You cannot check a subquery in the ON condition of the FROM clause.
· hecking SeIection TabIes :
SEET ... WHERE <s> [NOT ] IN <seItab> ...
The condition is true if value of <s> [not] satisfy the conditions stored in <seltab>.
<seltab> can be either a real selection table or a RANGES table. You cannot check a
selection table in the ON condition of the FROM clause.
· hecking for NuII VaIues :
SEET ... WHERE <s> IS [NOT ] NU ...
· Negating onditions :
SEET ... WHERE NOT <cond> ...
The condition is true if <cond> is false, and false if <cond> is true.
· inking onditions
SEET ... WHERE <cond
> AND <cond
SEET ... WHERE <cond
> OR <cond
NOT takes priority over AND, and AND takes priority over OR. However, you can
also control the processing sequence using parentheses.
· Dynamic onditions :
SEET ... WHERE (<itab> / <str>) ...
<itab> is an internal table with line type C and maximum length 72 characters. All of
the conditions listed above except for selection tables, can be written into lines of
<itab>. However, you may only use literals, & not names of data objects. <str> is a
character string with length 72.
· TabuIar conditions :
SEET ... FOR A ENTRIES IN <itab> WHERE <cond> ...
For each line of <itab>, the system selects the lines from the database table that
satisfy the condition. The internal table itab must have a structured line type Do not
use the operators LÌKE, BETWEEN, and ÌN in comparisons using internal table fields.
You can not use the ORDER BY & HAVÌNG clause in the same SELECT statement.
ORDER BY PRÌMARY KEY is possible .The same internal table can be specified
after FOR ALL ENTRÌES and after ÌNTO. The addition FOR ALL ENTRÌES is only
possible before WHERE conditions of the SELECT statement. You can use the option
FOR ALL ENTRÌES to replace nested select for better performance. If you don't
want dupIicate records, add aII primary key fieIds of tabIe in seIect cIause.
5. GROUP BY <fieIds>: The GROUP BY clause summarizes several lines that
have the same content in particular columns from the database table into a single line
of the selection. Aggregate functions are applied to other columns.
· Specifying oIumns StaticaIIy :
SEET <Iines> <s
> [AS <a
> [AS <a
>] ... <agg> <s
> [AS <a
> [AS <a
>] ...... GROUP BY <s
Ìn the GROUP BY clause, you list the field names of the columns whose contents
must be the same. Alias names from the SELECT clause are not allowed in GROUP
BY clause. To use the GROUP BY clause, you must specify all of non-aggreagated
columns in the SELECT clause. All columns of the SELECT clause that are not listed
in the GROUP BY clause must be included in aggregate functions. Non-aggregated
columns from database table can be mentioned in the GROUP BY clause.
· Specifying oIumns DynamicaIIy :
... GROUP BY (<itab>/ <str>) ...
<itab> is an internal table with line type C and maximum length 72 characters contain-
ing the column names <s1> <s2>.
<str> is a character string with length 72.
6. HAVING <cond>:
SEET <Iines> <s1> [AS <a1>] <s2> [AS <a2>] ...<agg> <sm> [AS <am>]
<agg> <sn> [AS <an>] ......GROUP BY <s1> <s2> ....HAVING <cond>.
The HAVÌNG clause uses conditions to restrict the number of groups selected.You can
only use the HAVÌNG clause in conjunction with GROUP BY clause. The conditions
<cond> that you can use in the HAVÌNG clause are the same as those in the select
clause, with the restrictions that you can only use columns from the SELECT clause,
and not all of the columns from the database tables in the FROM clause. But you can
use aggregate expressions, even if they do not appear in the SELECT clause. You can
not use aggregate expressions in the conditions in the WHERE clause.You can specify
the conditions in the HAVÌNG clause dynamically.
7. ORDER BY <fieIds>: The ORDER BY clause sorts lines in the selection
according to the contents of their columns.
· Sorting by the Primary ey :
SEET <Iines> *...... ORDER BY PRIMARY EY
This sorting method is only possible if you use an asterisk (*) in the SELECT clause to
select all columns. Furthermore, it only works if you specify a single database table in
FROM clause.You cannot use views or joins, since neither has a defined primary key.
· Sorting by any oIumns :
SEET .. ORDER BY <s
> [ASENDING|DESENDING] ...
The sort order depends on the sequence in which you list columns.You can use either
names of columns as specified in the SELECT clause or their alias names (for aggre-
gate expressions also). You may only use columns that occur in the SELECT clause.
· Specifying the oIumns DynamicaIIy:
SEET ...... ORDER BY (<itab>/<str>)
<itab> is an internal table with line type C and maximum length 72 characters containi-
ng the column names <s1> <s2>... <str> is a character string with length 72.
8.Subqueries : A subquery is a special SELECT statement which does not
contains ÌNTO or ORDER BY clause. You cannot use them in ON condition of the
( SEET <resuIt> FROM <source> [WHERE <condition>] [GROUP BY
<fieIds>] [HAVING <cond>] )
You can nest subqueries, that is, the WHERE and HAVÌNG clauses of subqueries can
themselves contain a subquery.
· ScaIar Subqueries :
... <Iine> [<agg>] <s>
Ìn a scalar subquery, the selection in the SELECT clause is restricted to one column
or one aggregate expression.
... <s> [NOT ] IN <subquery>...
The condition is true if the value of <s> is [not] contained in the results set of the
scalar subquery <subquery>.
... <s> <operator> <subquery>...
The value of <s> is compared with the value in the selection from the subquery.The
condition is either true or false. The subquery may only contain one line, otherwise a
runtime error occurs. A one-line subquery can be created by completely defining the
key in the WHERE clause or using SingIe line. Do not use Single after 4.7 version.
... <s> <operator> A|ANY|SOME <subquery>...
Subquery contains more than one line.Ìf you don't use the ALL, ANY, or SOME
expression, a runtime error occurs. Any or some is similar.
· Non-scaIar Subqueries in onditions : A non-scalar subquery can only have a
WHERE or HAVÌNG clause in the [NOT] EXÌSTS <subquery> condition.This condition
is true if the result set of the subquery contains at least one [no] line.
· Using a ursor to Read Data :
OPEN URSOR [WITH HOD] <c> FOR SEET <resuIt> FROM <source>
[WHERE<condition>][GROUP BY<fieIds>][HAVING<cond>][ORDER BY<fieIds>].
An open cursor points to an internal handler, similarly to a reference variable pointing
to an object.Can not use SÌNGLE addition, ÌNTO clause, and column selection may
not contain only aggregate expressions.Declare cursor <c> using the DATA statement
and special data type CURSOR.To close cursor use:
OSE URSOR <c>.
WÌTH HOLD addition in OPEN CURSOR statement allows you to prevent a cursor
from being closed when a database commit occurs in Native SQL.
FETH NEXT URSOR <c> INTO <target>.
This writes one line of the selection into the target area <target>,and the cursor moves
one line further in the selection set. SY-SUBRC is set to 0 until all the lines of the
selection have been read, otherwise it is 4. After a FETCH statement, system field SY-
DBCNT contains the number of all the lines read.
hanging Data in Database
You can insert, change and delete entries in database tables. However, Open SQL
statements do not check authorization or the consistency of data in the database.
1. Inserting ines into TabIes :
· Inserting a SingIe ine :
INSERT INTO <dbtab> [IENT SPEIFIED] VAUES <wa> .
INSERT <dbtab> [IENT SPEIFIED] FROM <wa >.
Ìf the database table does not already contain a line with the same primary key as
specified in the work area, the operation is completed successfully and SY-SUBRC is
set to 0. Otherwise, the line is not inserted, and SY-SUBRC is set to 4. You can only
insert lines into an ABAP Dictionary view if it only Contains fields from one table and
its maintenance status is defined as #ead and change. You specify the database table
dynamically as (<name>). This addition deactivates the automatic client handling of
Open SQL. Ìf the addition IENT SPEIFIED is used, the client identifier specified in
source is taken into account. Without the addition IENT SPEIFIED, the ABAP
runtime environment does not transfer the client identifier specified in source to the
database system, but transfers the identifier of the current client instead.
· Inserting SeveraI ines :
INSERT <dbtab> [IENT SPEIFIED] FROM TABE <itab>
[AEPTING DUPIATE EYS] .
Ìf system is able to insert all of lines from the internal table,SY-SUBRC is 0. Ìf one or
more lines cannot be inserted because the database already contains a line with the
same primary key, a runtime error occurs. You can prevent the runtime error occurring
by using the addition ACCEPTÌNG DUPLÌCATE KEYS. Ìn this case, the lines that
would otherwise cause runtime errors are discarded, and SY-SUBRC is set to 4. The
system field SY-DBCNT contains the number of lines inserted into the database table,
regardless of the value in SY-SUBRC.
2. hanging ines :
· hanging ines oIumn by oIumn :
UPDATE <dbtab> [IENT SPEIFIED] SET <set
> ... [WHERE <cond>].
The Where clause determines the lines that are changed. The expressions <seti> can
> = <f> : The value in column <s
> is set <f> for all lines selected.
> = <s
> + <f>
> = <s
> - <f>
Ìf at least one line is changed, the system sets SY-SUBRC to 0, otherwise to 4. SY-
DBCNT contains the number of lines changed. Ìf you use SET statements, you
cannot specify the database table dynamically.
· hanging IndividuaI ines From a Work Area :
UPDATE <dbtab> [IENT SPEIFIED] FROM <wa> .
You specify the database table dynamically as (<name>). Ìf the database table
contains a line with the same primary key as specified in the work area, the operation
is completed successfully and SY-SUBRC is set to 0. Otherwise,the line is not inserted,
and SY-SUBRC is set to 4.
· hanging SeveraI ines Using an InternaI TabIe :
UPDATE <dbtab> [IENT SPEIFIED] FROM TABE <itab> .
Ìf the system cannot change a line because no line with the specified key exists, it does
not terminate the entire operation, but continue processing the next line of the internal
table.Ìf all lines from the internal table have been processed, SY-SUBRC is set to 0.
Otherwise, it is set to 4. SY-DBCNT contains no. of lines processed.
3. DeIeting ines :
· DeIeting ines Using onditions :
DEETE FROM <dbtab> [IENT SPEIFIED] WHERE <cond> .
You can specify the database table dynamically as (<name>). Ìf at least one line is
deleted, the system sets SY-SUBRC to 0, otherwise to 4. SY-DBCNT contains the
number of lines deleted.
· DeIeting SingIe ines Using Work Areas :
DEETE <dbtab> [IENT SPEIFIED] FROM <wa> .
Ìf the database table contains a line with the same primary key as specified in the work
area, the operation is completed successfully and SY-SUBRC is set to 0. Otherwise,
the line is not deleted, and SY-SUBRC is set to 4.
· DeIeting SeveraI ines Using an InternaI TabIe :
DEETE <dbtab> [IENT SPEIFIED] FROM TABE <itab> .
Ìf all lines from the internal table have been processed, SY-SUBRC is set to 0.
Otherwise, it is set to 4. SY-DBCNT contains no. of lines processed.
4. Inserting or hanging ines : Ìf the database table contains no line with
the same primary key as the line to be inserted, MODÌFY works like ÌNSERT, that is,
the line is added. Ìf the database already contains a line with the same primary key as
the line to be inserted, MODÌFY works like UPDATE, that is, the line is changed.For
performance reasons, you should use MODÌFY only if you can't distinguish between
these two options in your ABAP program.
· Inserting or hanging SingIe ines using work areas :
MODIFY <dbtab> [IENT SPEIFIED] FROM <wa> .
You can specify database table dynamically as (<name>). SY-SUBRC is always 0.
· Inserting or hanging SeveraI ines using an internaI tabIe :
MODIFY <dbtab> [IENT SPEIFIED] FROM TABE <itab> .
SY-SUBRC is always set to 0. SY-DBCNT is set to number of lines in internal table.
Performance of SQ Statements
The performance of an ABAP program is largely determined by the efficiency of its
database accesses. Ìt is therefore worth analyzing your SQL statements closely. To
help you to do this, you should use !erformance Trace and #untime Analysis tools.
· Use The Optimizer : Used to create the execution plan for SQL statements.
(for example, to determine whether to use an index or table scan).
· eep the ResuIt Set SmaII
· Restrict the Number of ines using UP TO
· Restrict the Number of oIumns
· Use Aggregate Functions : More efficient than performing the calculations in the
· Use SET statements in UPDATE Instead of WA
· Avoid Repeated Access
· Avoid Nested SEET oops
· Using Join : Joins bypass the table buffer and read directly from database. For this
reason, you should use an ABAP Dictionary view instead of a join if you only want to
read the data.
· Accessing record from muItipIe tabIes : Efficiency wise preference
- For aII entries in : Ìt prevent redundant data from being transferred from DB
- Nested seIect
· Using indexes : To increase the efficiency of where & having clauses, you should
formulate them to fit with the database table indexes.
- heck for EquaIity and ink Using AND :The database index search is
particularly efficient if you check all index fields for equality (= or EQ) and link the
expressions using AND.The optimizer usually stops working when an OR expression
occurs in the condition.
- Use Positive onditions : Ìf possible, avoid using the NOT operator in WHERE
clause, because it is not supported by database indexes;invert the logical expression
- hecking for NuII VaIues : The ÌS NULL condition can cause problems with
indexes. Some database systems do not store null values in the index structure.
- Avoid ompIex onditions
· Buffer TabIes on the AppIication Server : You should buffer the following types of
- Tables that are read very frequently
- Tables that are changed very infrequently
- Relatively small tables (few lines, few columns, or short columns)
- Tables where delayed update is acceptable.
Once you have buffered a table, take care not to use any Open SQL statement that
bypass the buffer.
SELECT statement bypasses buffer when you use any of following:
- The BYPASSÌNG BUFFER addition in the FROM clause
- The DÌSTÌNCT addition in the SELECT clause
- Aggregate expressions in the SELECT clause
- Joins in the FROM clause
- The ÌS NULL condition in the WHERE clause
- Subqueries in the WHERE clause
- The ORDER BY clause
- The GROUP BY clause
- The FOR UPDATE addition
Furthermore, all Native SQL statements bypass the buffer.
· Avoid Reading Data RepeatedIy
· Sort Data in Your ABAP Programs : The ORDER BY clause in the SELECT
statement is not necessarily optimized by the database system or executed with the
correct index. This can result in increased runtime costs.
· Use ogicaI Databases : SAP supplies logical databases for all applications. Ìt is
important that you use the right logical database.
Source code ModuIes
Source code modules help you to avoid repeatedly writing the same set of statements
and to make your programs easier to read and understand. When the program is
generated, the source code in the modularization unit is treated as though it were
actually physically present in the main program.ABAP contains two kinds of source
code modules: Local modules are called macros, and cross-program modules are
called include programs.
· Macros :
<statements> can contain up to nine placeholders (&1, &2, ..., &9).Use a macro like
<macro> [<p1> <p2> ... <p9>].
When the program is generated, the system replaces <macro> by the defined
statements and each placeholder &i by the parameter <pi>. You can use macros
within macros. You must define the macro before the point in the program at which
you want to use it.
· IncIude Programs ( Type I ) : Ìnclude programs are global R/3 Repository
objects without parameter interface. Ìnclude programs cannot call themselves.Ìnclude
program must contain complete statements.To use an include program in another
program, enter the statement:
Statements of your include program fit logically into the source code of the programs
from which it is called. Particular care is required if you use both macros and include
programs, since not all include programs are included in the syntax check
(exception: TOP include).
Procedures contain a set of statements, and are called from other ABAP Programs.
Procedures have an interface for passing data, & can also contain local data.Subroutine
is one of the example of procedure. Subroutines are principally for local modularization,
that is, they are generally called from the program in which they are defined.
· Defining Subroutines :
FORM <subr> [USING ... [VAUE(<p
>)] [TYPE <t>|IE <f>]... ]
>)] [TYPE <t>|IE <f>]... ]
Like any other processing block, subroutines cannot be nested. You should therefore
place your subroutine definitions at the end of the program.
· GIobaI Data from the Main Program : Subroutines can access all of the global
data in the program in which they are defined (main program).To Prevent the value of
a global data object from being changed inside a subroutine, use the statement
OA <f>. Ìf you want to use the table work area locally, but preserve its contents
outside the subroutine, you must use the LOCAL statement.
· ocaI Data in the Subroutine :
- ocaI Data Types and Objects : They are deleted when the subroutine ends, and
recreated each time the routine is called. They hide identically named global data
types or objects.
- Static ocaI Data Objects : Ìf you want to keep the value of a local data object
after exiting the subroutine, you must use the STATÌCS statement to declare it instead
of the DATA statement.Ìt persists its value between two calls.
- ocaI fieId symboIs : All field symbols declared in a subroutine using the FÌELD-
SYMBOLS statement are local. Do not address local field symbols outside the
subroutine. Local field symbols hide global field symbols having the same name. local
field symbols are unassigned after ENDFORM.
- ocaI opies of GIobaI FieIds : You can create local copies of global data on the
local stack. To do this, use a local field symbol.
ASSIGN LOCAL COPY OF <f> TO <FS>.
You can use the LOCAL COPY OF addition with all variants of the ASSÌGN
statement except ASSÌGN COMPONENT.
ASSIGN LOCAL COPY OF INITIAL <f> TO <FS>.
ASSIGN LOCAL COPY OF INITIAL LINE OF <itab> TO <FS>.
ASSIGN LOCAL COPY OF INITIAL LINE OF (<f>) TO <FS>.
· The Parameter Interface :
- aII by Reference :
FORM <subr> USING ... <p
> [TYPE <t>|IE <f>] ...
HANGING ... <p
> [TYPE <t>|IE <f>] ...
The address of the actual parameter is transferred to the formal parameter. Formal
parameter occupies no memory of its own. Ìf the value of the formal parameter
changes, the contents of the actual parameter in the calling program also change.
- aII by VaIue :
FORM <subr> USING ... VAUE(<p
>) [TYPE <t>|IE <f>] ...
The formal parameter occupies its own memory space. When you call the subroutine,
the value of the actual parameter is passed to the formal parameter. Ìf the value of
formal parameter changes, this has no effect on the actual parameter.
- aII by VaIue and return :
FORM <subr> HANGING ... VAUE(<p
>) [TYPE <t>|IE <f>] ...
The formal parameter occupies its own memory space.The value of the actual
parameter is passed to the formal parameter. Ìf the subroutine concludes
successfully, that is, when the ENDFORM statement occurs, or when the subroutine
is terminated through a CHECK or EXÌT statement, the current value of the formal
parameter is copied into the actual parameter.
· Specifying the Type of FormaI Parameters : Formal parameters can have any
valid generic data type like No type specification, TYPE ANY, TYPE C, N, P, or X,
TYPE ... TABLE. Formal parameters inherit the attributes of their corresponding
actual parameters dynamically at runtime. The technical attributes of the formal
parameters can be fully specified like TYPE D, F, Ì, or T, TYPE <type>, TYPE REF
TO <cif>, TYPE LÌNE OF <itab>, LÌKE <f>.Ìn this case, The technical attributes of
actual parameter must correspond to those of the formal parameter.
· Structured FormaI Parameters : To access the components of a generically
passed structure, you must use field symbols as you can not address its individual
ASSIGN OMPONENT <idx>|<name> OF STRUTURE <s> TO <FS>.
Ìnstead of using TYPE or LÌKE, you can specify the type of a structure as follows:
> [STRUTURE <s>] ...
where <s> is a local structure in the program or a flat structure from the ABAP
Dictionary. You can address its individual components.
· The TABES Addition :To ensure compatibility with previous releases, the
following addition is still allowed before & instead of USÌNG & CHANGÌNG.
FORM <subr> TABES ... <itab
> [TYPE <t>|IE <f>] ...
· Terminating Subroutines : You can terminate subroutine by using the EXÌT or
CHECK statement. When you terminate a subroutine with EXÌT or CHECK, the
current values of the output parameters (CHANGÌNG parameters passed by VALUE)
are passed back to the corresponding actual parameter. Use EXÌT to terminate a
· aIIing Subroutines : Subroutines can call other subroutines (nested calls) and
may also call themselves (recursive calls). The additions USÌNG and CHANGÌNG
have exactly the same meaning.
To call internal subroutines use :
PERFORM <subr> [USING ... <p
>... ] [HANGING... <p
To call external subroutines use :
PERFORM<subr>(<prog>) [USING ... <p
>... ][HANGING... <p
>... ][IF FOUND].
To specify subroutine & program name dynamically use :
PERFORM (<fsubr>)[IN PROGRAM (<fprog>)] [USING ... <p
>... ] [IF FOUND].
Use the ÌF FOUND option to prevent a runtime error from occurring if the program
<prog> does not contain a subroutine <sub>.
To Call Subroutines from a List use :
PERFORM <idx> OF <subr
Only for internal subroutine calls without a parameter interface.
Shared Data Area
Used to access the global data of the calling program from an external subroutine. All
interface work area declared using TABLES and NODES behave like the common data
area by default.
You declare a common data area in all programs concerned using :
DATA: BEGIN OF OMMON PART [<name>],
END OF OMMON PART [<name>].
Ìt is a good idea to put the declaration in an include program & include it in all
concerned programs ( calling & called programs). Ìf you only have one common
part in each program, you do not have to specify a name.
Messages are single texts, stored in table T100, that you can maintain in Transaction
SE91. T100 has Language key,Twenty-character message class, Message number,
Message text (up to 72 characters).
· Message Types :
A Termination message appears in a dialog box, program terminates.
E Error Depending on the program context, an error dialog appears
or the program terminates.
I Information message appears in a dialog box. Once the user has
confirmed the message, the program continues
immediately after the MESSAGE statement.
S Status program continues normally after the MESSAGE
statement & message is displayed in the status bar.
W Warning Depending on the program context, an error dialog
appears or the program terminates.
X Exit No message is displayed, the program terminates with
a short dump containing message ÌD. Ìt force a
The Message Statement
· Using a GIobaI Message Iass :
MESSAGE <t><num> [WITH <f
> ... <f
>] [RAISING <exc>].
Global message class is defined in ... MESSAGE-ÌD <id> in a program or function
group.<t> is message type,<num> is message number, <f
> ... <f
> are values for
four placeholders in message text replaced at runtime.
· Specifying the Message StaticaIIy :
MESSAGE <t><num>(<id>) [WITH <f1> ... <f4>] [RAISING <exc>].
Message class <id> overrides any global message class specified at the beginning of
· Specifying the Message DynamicaIIy :
MESSAGE ID <id> TYPE <t> NUMBER <n> [WITH <f1> ... <f4>][RAISING<exc>].
where <id>, <t>, and <n> are fields or variables containing the message class,
message number, and message type respectively.
· You can also display any character string in message format by using statement :
MESSAGE <TEXT> type <t>.
· You can also display message in Pop Up by using :
CALL FUNCTÌON 'POPUP_TO_INFORM'
titel = sy-repid
txt2 = sy-subrc
txt1 = 'The control could not be created'.
· Function groups are containers for function modules.
· To create Choose SE37(function builder)-> oto ->Function groups->Create group
(starts name with Y or Z).
· The system automatically creates a main program containing TOP include for global
data (L<fgrp>TOP , include program (<fgrp>UXX) within the main program is
used to hold the function modules within the group & include program (<fgrp>FXX)
contain the coding of external subroutines .
· When you call function module, the system loads the whole of its function group into
the internal session of the calling program.
· You cannot declare a COMMON PART in a function group. Function groups have
their own table work areas (TABLES).
· All function modules in a function group can access global data & external subroutines
of group.A function modules can have local data & subroutines.
· Function groups can contain dialog screens, selection screens, and lists. User input
is processed in dialog modules or in corresponding event blocks in the main program
of the function group. There are special include programs in which you can write
· Function modules are procedures that are defined in function groups.You create
function modules using Function BuiIder (SE37).
· Function moduIes Vs subroutines :
- Function modules unlike routines must belong to a pool(function group).
- You can assign default values to input parameters in function modules but not in
- Function modules also supports exception handling.
- The calling program and the function module cannot exchange data using a shared
memory area.This is possible with subroutines.
· Interface parameters ExpIanation
Import Values transferred from the calling program to the function
module. Optional, default value, pass by value
Export Values transferred from the function module back to calling
program. Always optional,pass by value,no default values
hanging Values that act as import & export parameters simultaneous-
ly. Call by reference,Optional, default value, changing value.
TabIes Ìnternal tables that can be imported and exported.Tables
are always passed by reference.Optional only.
Exceptions Error situations that can occur within the function module.
· Reference type for an interface parameter : The reference type must be a global
Dictionary type or exist in a type pool. Ìn the latter case, the type pool must be
declared in the TOP include of function group. Additionally you can use internal ABAP
types C, Ì, N, X, P, D, T, F, and the TABLE type.Ìt can be either generic or fully typed.
· Triggering Exceptions : You can specify the MESSAGE-ÌD in the first statement of
the include program L<fgrp>TOP.
MESSAGE..... RAISING <Exception>.
- Ìf you trigger the exception in the RAÌSE statement and the calling program is to
handle it, the function module processing is terminated, and the numeric value
assigned to the exception is placed in the system field SY-SUBRC. Ìf the calling
program fails to handle the exception, the system triggers a runtime error.
- Ìf you use the MESSAGE... RAÌSÌNG statement & Ìf the calling program does not
handle the exception,the message is displayed and handled according to the context
in which it occurs in the function module.Ìf the calling program handles the exception,
the message is not displayed.Ìnstead, the procedure is interrupted in accordance
with the message type, and processing returns to the calling program. The contents
of the message are placed in the system fields SY-MSGÌD,SY-MSGTY,SY-MSGNO,
and SY-MSGV1 to SY-MSGV4.
- You can catch messages from function modules that are not sent using the RAÌSÌNG
addition in the MESSAGE statement by including the implicit exception
ERROR_MESSAGE in the EXCEPTÌONS list of the CALL FUNCTÌON statement.
Type S, Ì, and W messages are ignored (but logged during background processing).
Type E and A messages trigger the exception ERROR_MESSAGE.Type X messages
trigger the usual runtime error and short dump.
· Function module -> Check -> Main program,etended program check.
· Only standard table can be passed to TABLES with or without header line. Non-
standard tables can only be passed to importing,exporting or changing parameters
without header line.
· You can test function modules before calling it from any program.You can also save
· To release a function module, choose Function module -> #elease options-> #elease.
By releasing a function internally, the SAP developer tells other developers at SAP
that they can use this particular function module safely. Releasing a function module
signals that a developer has tested it.
Organization of ExternaI Procedure aIIs
· The main program (type 1 or M) belongs to a main program group. When you call a
function module from a function group that has not already been loaded, an additional
program group is created, into which the function group to which the function module
belongs is loaded. The additional program group, along with its data, exists for the
rest of the lifetime of the internal session.
· Ìf you call an external subroutine using PERFORM, the main program of subroutine is
loaded into the existing main program or function group in the corresponding main or
additional program group (if it has not already been loaded).
· An additional program group is only opened in an external PERFORM if subroutine
belongs to a function group that has not yet been loaded. This will happen if the main
program of the subroutine begins with the FUNCTÌON-POOL statement. The program
type does not necessarily have to be set to F.
· Classes in ABAP Objects behave like function groups. The first time you address a
class (for example, using the CREATE OBJECT statement) or address a static class
component, the system opens an additional program group for the class.
· Ìnterface work areas that you declare using the TABLES, NODES, or DATA BEGÌN
OF COMMON PART statements exist once only in each program group, and are
shared by all of its programs. Each main program that begins with the PROGRAM or
REPORT statement, and each function group that begins with FUNCTÌON-POOL
shares the interface work areas with main programs of all of its external subroutines.
· A subroutine may belong to a main program group on occasion when it is run, but the
next time, it may belong to an additional program group. For this reason, you should
avoid using external subroutines if they use interface work areas or call screens.
· You are trying to edit an SAP object that has already been changed or enhanced in
the current system. This could be
1. A change (without Modification Assistant)
2. A modification (with Modification Assistant)
Through an upgrade or the import of a Support Package, an object version that was
changed by SAP has been imported. The new SAP version, however, has not yet
been compared with the changed version.
· System Response : The system will deny access in change mode or enhancement
mode until the objects have been compared.
· Procedure : Run the modification comparison (SPAU) for the object. Ìf the object is
supported by the Modification Assistant, you can compare/adjust it by clicking the
stoplight. Ìf the object was not changed using the Modification Assistant, but by
inclusion of notes using the Note Assistant, the respective notes must be
compared/adjusted. Ìf it is not absolutely clear which note caused the object to be
changed, you can use the Modification Browser SE95 to perform a search: Expand
the subtree "Note Corrections" and then use the search function to search for the
· Note : You can apply the note manually or by using tcode SNOTE. You can search
the corresponding note in OSS (Online Service System www.service.sap.com).
· Definition : Ìt represents the object-oriented extension of the ABAP language.
· Object-Oriented Programming : Ìt is a structured problem-solving method in which
the software solution reflects objects in the real world.
· Iasses : Classes are templates for objects. A class is an abstract description of an
· Objects : Objects are runtime instances of a class. Ìt is a section of source code that
contains data and methods or functions.
· Object References : Ìt addresses the object & allow you to access the attributes and
methods of an object.
· Methods operate on private data , which is only visible to the methods of the object.
Thus the attributes of an object cannot be changed directly by the user, but only by
the methods of the object.This guarantees the internal consistency of the object.
· You can create any number of objects based on a single class. Each instance of a
class has a unique identity and its own set of values for its attributes.
· EncapsuIation : Ìt is a process by which Objects restrict the visibility of their resourc-
ces (attributes and methods) to other users.
· PoIymorphism : Ìt is a process by which identically-named methods behave
differently in different classes.
· Inheritance : Ìt is a process by which You can use an existing class to derive a new
class. Derived classes inherit the data and methods of the superclass. However, they
can overwrite existing methods, and also add new ones.
· Advantages of object-oriented programming:
- The amount of work involved in revising and maintaining the system is reduced.
- Through polymorphism and inheritance, object-oriented programming allows you to
reuse individual components.
- Ìt is possible to implement changes at class level, without having to make alterations
at other points in the system.
- Complex software systems become easier to understand.
· Function Groups Vs ABAP Objects : Before R/3 Release 4.0, the nearest
equivalent of objects in ABAP were function groups. The attributes correspond to
the global data of the function group, while the individual function modules represent
actions that manipulate that data (methods). This means that the actual order data is
encapsulated in the function group, and is never directly addressed, but instead only
through the function modules.Thus function modules can ensure that the data is
· Local classes are defined within an ABAP program. Local classes and interfaces can
only be used in the program in which they are defined. Local class is preferred over
global class with same name.
· Defining ocaI Iasses : The declaration part of a class <class> is a statement
ASS <cIass> DEFINITION.
Ìt contains the declaration for all components (attributes, methods, events) of the
The implementation part of a class <class> is a statement block:
ASS <cIass> IMPEMENTATION.
The implementation part of a class contains the implementation of all methods of the
Structure of a Iass
1. Attributes : Attributes are internal data fields within a class that can have any ABAP
data type.The contents of instance attributes define the instance-specific state of an
object. You declare them using the DATA statement. The contents of static attributes
define the state of the class that is valid for all instances (objects) of the class. Static
attributes exist once for each class. You declare them using the ASS-DATA
2. Methods : Methods are internal procedures in a class that can access all of the
attributes of a class. The definition and parameter interface of a method is similar to
that of function modules. You implement it in the implementation part using the
following processing block:
You can declare instance methods using the METHODS statement. They can
access all of the attributes of a class, and can trigger all of the events of the class.
You can declare static methods using the ASS-METHODS statement. They can
only access static attributes & trigger static events. There are two speciaI methods
called ONSTRUTOR & ASS_ ONSTRUTOR, which are automatically called
when you create object.
3. Events : Objects or classes can use events to trigger event handler methods in other
objects or classes. You declare instance events using the EVENTS statement. An
instance event can only be triggered in an instance method. You declare static
events using the ASS-EVENTS statement. All methods (instance and static
methods) can trigger static events.
4. Types : You can define your own ABAP data types within a class using the TYPES
statement. Types are not instance-specific, and exist once only for all of the objects in
5. onstants : You declare them using the CONSTANTS statement. Constants are not
instance-specific, and exist once only for all of the objects in a class.
6. VisibiIity Sections : You can divide the declaration part of a class into up to three
ASS <cIass> DEFINITION.
PubIic Section: All of the components declared in the public section are accessible
to all users of the class, and to the methods of the class and any classes that inherit
from it. Public components form the interface between the class and its users.
Protected Section: All of the components declared in the protected section are
accessible to all methods of the class and of classes that inherit from it. Protected
components form a special interface between a class and its subclasses. Since inherit-
ance is not active in Release 4.5B, the protected section currently has the same effect
Private Section : Components that you declare in the private section are only visible in
the methods of the same class. The private components are not part of the external
interface of the class.
· ASS <cIass> DEFINITION REATE PUBI|PROTETED|PRIVATE
The CREATE PUBLÌC addition is implicit in every class definition if you do not use one
of the other CREATE additions. Ìt defines the default state, that is, that every user can
create instances of the class. The effect of optional additions CREATE PROTECTED
and CREATE PRÌVTATE is that not every user can instantiate the class. Ìf you use
CREATE PROTECTED, the class can only be instantiated by itself or its subclass. Ìf
you use CREATE PRÌVATE, the class can only instantiate itself. The additions
CREATE PROTECTED and CREATE PRÌVATE allow you to control the instantiation of
· DATA A VAUE 'X' READ-ONY.
You can only use READ-ONY addition in the public section of a class declaration or in
an interface definition. The READ-ONLY addition makes a public attribute, declared in a
DATA statement, readable from outside the class, but only modifiable by methods of
the class. When inheritance is introduced, the READ-ONLY addition will also be
permitted in the protected area. Subclasses of a class will then be able to change the
READ-ONLY attributes in the public section, but not those in the protected section.
Object references are pointers to objects used to access an object from an ABAP
program. There are two principal types of references: Class references and interface
references. You declare & define class references using the
TYPES <REF> TYPE REF TO <cIass>.
DATA <REF> TYPE REF TO <cIass>.
A class reference <CREF> allows a user to create an instance (object) of the correspo-
nding class. you can create an object using the statement
REATE OBJET <REF>.
Programs can access the instance & static components of an object using Class
To access an attribute <attr>: <cref>-><attr>
To call a method <meth>: A METHOD <cref>-><meth>
You can use class name to access static components also.
To access a static attribute <attr>: <cIass>=><attr>
To call a static method <meth>: A METHOD <cIass>=><meth>
You can use self-reference variable ME to access components in same class:
To access an attribute <attr> in the same class: ME-><attr>
To call a method <meth> in the same class: A METHOD ME-><meth>
· Ìf you write the statement
<cref1> = <cref2>
the two class references <cref1> and <cref2> must have the same type, that is, they
must either refer to the same class, or the class of <cref1> must be predefined empty
class OBJECT. The class OBJECT has no components.
· An object exists for as long as it is being used in the program. An object is in use by a
program for as long as at least one reference points to it, or at least one method of the
object is registered as an event handler.
· The object,not class reference, is displayed as cIassname<1> in debugger after the
CREATE OBJECT statement has been executed for the first time & so on.
· Ìf you are using one class reference in another class, either define it above the other
completely or use deferred word for example :
ASS: _EMPOYEE DEFINITION DEFERRED.
· Note: Global classes can contain the same components as local classes. However,
the public section of a global class may only contains types that are globally visible
(that is, predefined ABAP types or data types from the ABAP Dictionary). This means
that in the public section of a global class:
÷ You may not define internal data types for the class using the TYPES statement.
÷ You may only use globally visible, fully-defined (not generic) types to specify the
types of attributes, parameters, and field symbols.
DecIaring and aIIing Methods
You can declare methods in the declaration part of a class.To declare instance methods,
use the following statement:
METHODS <meth> IMPORTING.. [VAUE(]<i
>[)] TYPE type [OPTIONA]..
>[)] TYPE type [OPTIONA]..
>[)] TYPE type [OPTIONA]..
>..(or RAISING cx_... cx_...)
To declare static methods, use the following statement:
You cannot use EXPORTÌNG or CHANGÌNG if you use RETURNÌNG. This is suitable
for methods that return a single output value.They also define the attributes of the
interface parameters, namely whether a parameter is to be passed by reference or
value (VALUE), its type (TYPE), and whether it is optional (OPTÌONAL OR DEFAULT).
As in function modules, you can use the RAÌSE <exception> and MESSAGE RAÌSÌNG
statements to handle error situations (conventional exceptions) in implementation part.
For class based exceptions, use RAISE EXEPTION TYPE cx_... [EXPORTING ... fi = ai ...]
and handle this exceptions in TRY.. ENDTRY block.
To call a method, use the following statement:
A METHOD <cref>-><meth> EXPORTING... <i
>... HANGING ... <c
REEIVING r = h EXEPTIONS... <e
> = rc
Within the implementation part of a class, you can call the methods of the same class
directly using their name <meth>.
A METHOD <meth>...
Visible instance methods can be called from outside the class using
A METHOD <cIass>=><meth>...
where <class> is the name of the relevant class.
You pass & receive values to & from methods in same way as function module
... <FormaI parameter> = <ActuaI parameter>
· onstructors : Constructors are special methods that cannot be called using CALL
METHOD. Ìnstead, they are called automatically by the system after the object has
been created in the CREATE OBJECT statement. You declare it in the public section
>[)] TYPE type [OPTIONA]..
The static constructor of a class is declared as follows:
The static constructor has no parameters. The system calls static constructor Once for
each class, before the class is accessed for the first time.Hence can not access the
components of its own class.
(b) Multiple Ìnheritance
(c) Multilevel Ìnheritance
(a) Single Ìnheritance
B C D
(e) Hierarchical Ìnheritance
Derived class visibility
· Ìnheritance allows you to derive a new class from an existing class.
ASS <subcIass> DEFINITION INHERITING FROM <supercIass>.
· The new class is called the subclass of the class from which it is derived. The original
class is called the superclass of the new class.
· Only the pubIic and protected components of the superclass are visible in the
subclass. Although the private components of the superclass exist in the subclass,
they are not visible. Protected becomes protected in subclass.
· You can declare private components in a subclass that have the same names as
private components of the superclass. Each class works with its own private
· A class can have more than one direct subclass, but it may only have one direct
superclass. This is called singIe inheritance.
· The root node of all inheritance trees in ABAP Objects is the predefined empty class
· You can use the REDEFINITION addition in the METHODS statement to redefine an
inherited public or protected instance method in a subclass. When you redefine a
method, you cannot change its parameter interface. Method retains the same name
and interface, but has a new implementation.
For example, a superclass method M1 contains a call CALL METHOD [ME->]M2,
and M2 is redefined in a subclass, calling M1 from an instance of the superclass will
cause the original method M2 to be called, and calling M1 from an instance of the
subclass will cause the redefined method M2 to be called. Within a redefine method,
you can use the pseudoreference SUPER-> to access the obscured method. This
enables you to use the existing function of the method in the superclass without
having to recode it in the subclass.
· The ABSTRAT additions to the CLASS statements allow you to define abstract
class. Abstract classes cannot be instantiated.
· The ABSTRAT additions to the METHODS statements allow you to define abstract
methods. An abstract method is defined in an abstract class and cannot be
implemented in that class. Ìnstead, it is implemented in a subclass of the class.
· FINA additions to the CLASS statements allow you to define final classes. Final
classes cannot have subclasses.
· FINA additions to the METHODS statements allow you to define final methods. A
final method cannot be redefined in a subclass.
· PoIymorphism : Reference variables defined with reference to a superclass or an
interface defined with reference to it can also contain references to any of its
subclasses. you can use the TYPE addition in CREATE OBJECT statement to create
an instance of a subclass, to which the reference variable of superclass will then
DATA: cref TYPE REF TO <supercIass>.
REATE OBJET cref TYPE <subcIass>.
Ìf you redefine an instance method in one or more subclasses, you can use a single
reference variable to call different implementations of the method. This concept of
addressing different classes using reference variables with a single type is called
· Namespace for omponents : All public and protected components within an
inheritance tree belong to the same namespace, and consequently must have unique
names except redefinition methods & constructors.The names of private components,
on the other hand, must only be unique within their class.
· Inheritance and Static Attributes : A subclass can access the public and protected
static attributes of all of its superclasses.
· Instance onstructors : Every class has an instance constructor called
CONSTRUCTOR. You can not call them using the statement CALL METHOD
CONSTRUCTOR & cannot redefine the instance constructor in subclass. The
instance constructor of a subclass has to ensure that instance Constructors of all of
its superclasses are also called. To do this, the instance constructor of each
subclass must contain a
A METHOD SUPER-> ONSTRUTOR
statement. Ìn superclasses without an explicitly-defined instance constructor, the
implicit instance constructor is called. When you instantiate a subclass, the instance
constructors are called hierarchically.
· Static onstructors : Every class has a static constructor called ASS_
ONSTRUTOR. The first time you address a subclass in a program, its static
constructor is executed. However, before it can be executed, the static constructors
of all of its superclasses have already been executed hierarchically.
· Note : Only single, Multilevel and Hierarchical Ìnheritance is possible in ABAP with
Inheritance: GraphicaI Overview
· Ìnterfaces are independent structures that you can implement in a class to extend
the scope of that class.
· Ìnterfaces extend the scope of a class by adding their own components to its public
section. This allows users to address different classes via a universal point of contact.
Ìnterfaces like inheritance, provide polymorphism, since they allow a single method
within an interface to behave differently in different classes.
· The definition of a local interface <intf> is enclosed in the statements:
The definition contains the declaration for all components (attributes, methods,events)
of the interface. You can define the same components in an interface as in a class.
· Ìnterfaces do not have an implementation part, since their methods are implemented
in the class that implements the interface.
· The components of interfaces automatically belong to the public section of the class in
which the interface is implemented.
· To implement an interface in a class, use the statement
in the declaration part of the class in the public section.
· A component <icomp> of an interface <intf> can be addressed as though it is a
member of the class under the name <intf~icomp>.
· The implementation part of the class must contain a method implementation for each
interface method <imeth>:
· Ìnterfaces can be implemented by different classes. Each of these classes is
extended by the same set of components. However, the methods of the interface can
be implemented differently in each class.
· To define an interface reference, use the addition TYPE REF TO <intf> in the TYPES
or DATA statement. Unlike classes, interfaces do not have instances.
· Assigning class reference <cref> to an interface reference <iref> make the interface
reference <iref> point to the same object as the class reference <cref>:
<iref> = <cref>
· Using the class reference variable <cref>:
To access an instance & static attribute <attr>: <cref>-><intf~attr>
To call a instance & static method <meth>: A METHOD <cref>-><intf~meth>
· Using the interface reference variable <iref>:
To access an instance & static attribute <attr>: <iref>-><attr>
To call a instance & static method <meth>: A METHOD <iref>-><meth>
· Addressing a constant <const> in interface: < intf>=><const>
· Addressing a static attribute <attr>: < cIass>=><intf~attr>
Calling a static method <meth>: A METHOD <cIass>=><intf~meth>
· <iref1> = <iref2>
Both interface references must refer to the same interface, or the interface of <iref1>
must contain the interface <iref2> as a component.
· <iref> = <cref>
The class of the class reference <cref> must implement the interface of the interface
· <cref> = <iref>
The class of <cref> must be the predefined empty class OBJECT.
· <cref> ?= <iref> or MOVE <iref>? TO <cref>
You must always use casting (casting operator (?=)) for assigning an interface
reference to a class reference if <cref> does not refer to the predefined empty class
OBJECT & interface must be implemented in that class or in its superclass.
Triggering and HandIing Events
· Ìn ABAP Objects, triggering and handling an event means that certain methods act
as triggers and trigger events, to which other methods - the handIers - react. This
means that the handler methods are executed when the event occurs.
· To trigger an event, a class must
- Declare the event in its declaration part
- Trigger the event in one of its methods
· To declare instance events, use the following statement :
EVENTS <evt> EXPORTING... VAUE(<e
>) TYPE type [OPTIONA].
To declare static events, use the following statement:
The parameters are always passed by value.
· An instance event in a class can be triggered by any method in the class. Static
events can be triggered by any static method. To trigger an event in a method, use
the following statement:
RAISE EVENT <evt> EXPORTING... <e
> = <f
· To handle an event, a method must
- be defined as an event handler method for that event
- be registered at runtime for the event.
· Any class can contain event handler methods for events from other classes or same
classes. To declare an event handler method, use the following statement for an
instance method :
METHODS <meth> FOR EVENT <evt> OF <cif> IMPORTING.. <e
For a static method, use CLASS-METHODS instead of METHODS. <evt> is an event
declared in the class or interface <cif>. The interface of an event handler method
may only contain formal parameters defined in the declaration of the event <evt>. The
event handler method does not have to use all of the parameters passed in the RAÌSE
· To allow an event handler method to react to an event, you must determine at runtime
the trigger to which it is to react. Ìt links a list of handler methods with corresponding
- SET HANDER... <h
>...FOR <ref> : Ìt register the handler for single instance that
can trigger the event:.
- SET HANDER... <h
>...FOR A INSTANES :Ìt register the handler for all
instances that can trigger the event. The registration then applies even to triggering
instances that have not yet been created when you register the handler.
- SET HANDER... <h
>: Cannot use the FOR addition for static events. The
registration applies automatically to the whole class, or to all of the classes that
implement the interface containing the static event.
After the RAÌSE EVENT statement, all registered handler methods are executed
before the next statement is processed (synchronous event handling). Ìf a handler
method itself triggers events, its handler methods are executed before the original
handler method continues. When an event is triggered, the system looks in the
corresponding event table and executes the methods in the appropriate instances.
Structure of a Iass PooI
· Ìf you define classes and interfaces globally, they are stored in special ABAP
programs called class pools (type K) or interface pools (type J).
· Each class or interface pool contains definition of a single class or interface.
· The programs are automatically generated by the Class Builder when you create a
class or interface.
· Class pools contain a definition part for type declarations, and the declaration and
implementation parts of the class.
· Ìn definition part, you can define data and object types, but no data objects or field
symbols. The types that you define in a class pool are only visible in the implemen-
tation part of the global class.
· The only processing blocks that you can use are the declaration part and implement-
ation part of the global class. You cannot use any of the other ABAP processing
blocks (dialog modules, event blocks, subroutines, function modules). you cannot
process screens in classes. You cannot program lists and selection screens in
· You can define Local Classes in the definition part of a class pool. Local classes can
only be instantiated in the methods of the global class & are not visible externally.
Ìn transaction maintenance (SE93), you can specify a transaction code as an OO
transaction. When the transaction is called up, the program is loaded, an instance of
the class is created, and the method is executed in its own internal session .
Iass BuiIder (SE24)
The Class Builder is a tool within the ABAP Workbench that allows you to create,
define, change and test global ABAP classes and interfaces.Use the Class Builder to:
· Display an overview (in the Class Browser) of global object types & their relationships.
· Maintain existing global classes or interfaces.
· Create new global classes and interfaces.
· Ìmplement inheritance between global classes
· Create compound interfaces
· Create and specify the attributes, methods, and events of global classes & interfaces.
· Define internal types in classes.
· Ìmplement methods.
· Redefine methods
· Maintain local auxiliary classes.
· Test classes or interfaces in a simulated runtime environment.
· Naming onvention : The following naming convention has been conceived for use
within the SAP namespace. Ìf you do not follow the naming conventions for object
types (classes and interfaces), conflicts will occur when system creates persistent
classes, since it will be unable to generate the necessary co-classes.
- Class in the class library : _<cIass name>
- Ìnterfaces in the class library : IF_<interface name>
- Local classes in programs : _<cIass name>
- Local interfaces in programs : IF_<interface name>
- Method name : <method name>
- Events : <event name>
- Local type definitions within a class : TY_<type name>
- Data definitions (variables) : <variabIe name>
- Data definitions (constants) : O_<constant name>
- Attribute access methods : SET_<attribute name>, GET_<attribute name>
- Event handler methods : ON_<event name>
- Methods that perform type conversions :AS_<new type>
- Methods that return a Boolean value : IS_<adjective>
- Check methods : HE_<objective>
- ÌMPORTÌNG parameters : IM_<parameter name>
- EXPORTÌNG parameters : EX_<parameter name>
- CHANGÌNG parameters : H_<parameter name>
- RESULT : RE_<resuIt
· Iass Browser : Use the Class Browser to display global ABAP classes and
interfaces or business object types from the class library. You cannot create new
object types from the Class Browser.
· Standard (NormaI ABAP) Iasses: Ìf classes are marked with !ublic option, means
each user can create instances of the particular class (with CREATE OBJECT). The
!rotected option defines that only inherited classes or the relevant class itself can
create instances of this class. Ìf you choose the !rivate option, only the relevant class
itself can create its instances (only using its own method). You can define an abstract
class with the Abstract option. You cannot create an instance for this class. You can
only access this class with static attributes or with subclasses. You define a final
class with Final option. Ìf you select Modeled only option, the class is not included
in the class pool. You will not be able to address it at runtime or test it. When you
choose Create Inheritance function, the Inherits from dialog box appears. You can
define inheritance relationship here by specifying the name of superclass. You can
define the superclass as any class from class library that is not defined as final. The
system creates a class pool for new class. A class pool was generated for the new
class if the Modeled only option was not activated.
Note : Do not store global classes in local objects.
· Exception Iasses: The prefix CX is added to class name of all exception classes.
Exception classes are derived from one of the predefined basic classes CX_STATÌC_
CHECK, CX_DYNAMÌC_CHECK or CX_NO_CHECK . Ìn contrast to normal classes,
you cannot create a method for an exception class. The Class Builder simply creates
constructor. However, you can create attributes & maintain exception texts.
· reating Persistent Iasses: Use of the prefix CL_ is required for persistent classes
since generation of the corresponding auxiliary classes assumes exactly this naming
convention. Once You activated a persistent class, the new class implements all the
methods of interface ÌF_OS_STATE. These service methods are common to all
persistent classes and are used when the object status is manipulated. The application
developer can only redefine the implementation of the two methods INIT HANDE_
EXEPTION. The other methods are reserved for internal use. The Class Builder auto-
matically creates two further auxiliary classes with the new persistent class CL class.
They are assigned to a separate class pool. These classes are needed for managing
persistent objects using Object Services.
· reating Interfaces: You have created a new interface along with its basic data.
The system generates an interface pool for the interface, as long as you did not create
the interface as Modeled.
· reating Attributes: Attributes contain data. They define the state of an object.
- Type: constant, an instance attribute, or a static attribute
- VisibiIity: Public, protected, private
- ModeIed onIy: Ìf you have selected this option, the system does not enter the
interface in the class pool. You cannot access the components at runtime.
- Typing method: ABAP keyword for defining the type reference. You can choose
one of the following: Type, Like or Type Ref To (for class references).
- Reference type: You can use any elementary ABAP type (including generic types)
or object type (classes and interfaces).
- Read-OnIy: This option restricts the changeability of attributes as well as visibility.
Users cannot change the attribute if a flag is set.
- Description: Short description of the components.
- InitiaI vaIue: You must enter an initial value for constants.
- Ìf you need the definition of a structured data object click on 'Direct type entry'
option and define the structure within DATA statement in the displayed editor like
DATA: BEGÌN OF structure,
END OF structure.
Once, You have created and specified attributes for a class or interface. The system
generates corresponding ABAP code in the definition part of the class or interface
pool for all of the attributes except those for which you set the nly modeled option.
· reating and Defining Methods:
- Type: Specifies the type as an instance method or a static method (not instance-
- VisibiIity: Public, protected, private.
- ModeIed onIy: Ìf the flag is set, no entry will be made in the class pool. You cannot
access the components at runtime.
Before you can implement methods, you must create your parameters & exceptions.
- Abstract : Can only be implemented in derived classes.
- FinaI: Can not redefined in subclasses.
· reating Parameters for Methods:
- ategory : As for function modules, a parameter can be passed with Ìmporting,
Exporting, Changing or Returning. Ìf you use changing parameters, you cannot use
returning parameters. Ìf you use returning parameters, you cannot use exporting or
changing parameters. Constructor methods may only have importing parameters.
- VaIue transfer: Ìn contrast to function modules, parameters for methods are
normally passed by reference. However, you can force the system to pass a param-
eter by value by selecting this option. This is only possible for importing, exporting &
changing parameters. Returning parameters can only be passed by value.
- OptionaI: Ìf you select this option, the parameter does not have to be specified
when the method is called.
- Typing method: ABAP keyword for defining the type reference. You can use Type,
ike, and Type ref to.
- Reference type: You can use any elementary ABAP type (including generic types)
or object type (classes & interfaces).
- DefauIt vaIue
· reating Exceptions for Methods: You can use the classical exceptions or the new
class-based exceptions in the method. Ìf you want to create a class-based exception,
first activate the ception classes checkbox and then enter the appropriate excep-
tion classes under ception.
· ImpIementing Methods: Double-click, or choose $ource code. Ìt could be very useful
to display the signature of the method here. To do so, click on $ignature. You can
also create text eIements in the source code using forward navigation.
· reating Event HandIer Methods : Each class can define methods that are
intended specially for handling events. The events to be handled can be triggered in
the defining class or in external classes and interfaces. Click on the etail view' icon
to go to etail 'iew of the method. This method is marked as event handler method.
· reating Events:
- Type: instance event or with static event.
- VisibiIity: Define the visibility of the event with Public, Protected or Private.
- ModeIed onIy: Ìf the flag is set, no entry will be made in the class pool. You cannot
access the components at runtime.
· reating InternaI Types: You must not create public data types within global classes.
- Type: A unique name to identify the type. Use the prefix TY_.
- VisibiIity: Ìf you make the type private, it can only be accessed from within the class
itself. Ìf the type is protected, it is also visible to the subclasses of the class.
- ModeIed: Ìf you select this option, the system does not enter the type in the class
pool. You will not be able to address the component at runtime.
- Typing method: This can be one of TYPE, LÌKE, or TYPE REF TO.
- Reference type: You can use any elementary ABAP type (including generic types)
or object type (classes and interfaces).
- Ìf you need to mention an internal data type in a class further (for example, to specify
the field length of a character field), choose irect type entry. Note that this only
makes sense if you have not selected nly modeled.
· ImpIementing ocaI AuxiIiary Iasses: The Class Builder lets you implement local
auxiliary classes within a global class. This enhancement can be useful when you
want to encapsulate implementation details of the global class to hide them from
outside. The local auxiliary classes can only be seen and used within the defining
· Defining Macros that are ocaI to the Iass: Choose Macros. System displays the
Editor. Edit the macros within the corresponding statement block :
· Enhancing Iasses with Interfaces:
- Interface : Definition of the interface name. When you press Enter, the system
checks that the interface exists in the class library.
- Abstract : Only mark the checkbox if the defining class is an abstract class. This
means that all the instance methods of the interface have property ABSTRACT . For
this reason these interface methods may not be implemented in the defining class.
Ìnstead, the derived classes must implement all the interface methods.
- FinaI: Marking the checkbox means that all instance methods of the interface have
attribute FÌNAL . This means that the interface methods may not be redefined in the
subclasses when the classes are inherited.
- ModeIed onIy: The system does not enter the interface in the class pool. You can't
access the components at runtime.
- You can also assign attribute ABSTRACT or FÌNAL for selected instance methods
of the interfaces by using 'Detail View' option.
- You can assign all the components of the interfaces aIias names as an abbreviation
for the full name. To do so, click on Aliases and enter the alias name. Ìn addition to
the name, you can also define the visibility (PUBLÌC, PROTECTED, PRÌVATE) and
thus restrict the use of alias names.
· reating SubcIasses: To create a new direct subclass from an existing non-final
class in the Class Builder choose Edit->Create subclass.
· Extending SubcIasses:
- By adding new components: You can define new components in all three visibility
sections (public, protected, and private) of a subclass. Since both inherited and new
components belong to the same namespace, you must ensure that all components in
the class have unique names.
- By redefining inherited methods: You can only redefine instance methods.
Attributes, static methods, and other inherited components of a subclass cannot be
redefined. Methods that you want to redefine may not have been defined as final
methods in the superclass. Constructor methods may not be redefined, since they are
implicitly final. A method redefinition may only extend to a new implementation of the
method. The signature (names and types of the parameters) may not be changed.
The interface of the redefined method must remain the same as that of the original
method in the superclass. Click on #edefine. The ABAP source code of the original
method implementation appears. Ìmplement the method again. Activate anyway. Ìf
you redefine a method in a subclass, the corresponding original method in the
superclass remains unchanged. Ìf, however, you need to address components of the
direct superclass, you can use the pseudoreference SUPER.
· Nesting Interfaces: ABAP Objects supports nested, or compound interfaces. Comp-
ound interface contains one or more interfaces as component interfaces. These may
contain further interfaces as components. A number of levels of nesting are therefore
possible. Ìnterfaces that do not contain other interfaces are referred to as simple
interfaces. When a class uses a compound interface, it must implement all methods
of all component interfaces. All the interfaces involved are implemented at the same
level, whatever their nesting hierarchy. You access their components using their
original names, that is, the form :
· Defining Friends ReIationships: A class can permit explicitly named users (friends)
to access its protected and private components. All the users declared to be friends
(classes and interfaces) must already exists. Enter the classes or interfaces in friend
column for which you want to permit access to the protected and private components
of the defining class. Ìf you specify an interface for Friends, this means that all the
classes that implement this interface have access to the protected and private
components. Ìf you set the flag to Modeled only, no entry is made in the class pool.
Friends relationship is only displayed and managed in the Class Builder. Friends
relationship cannot be used at runtime. The friends relationship is always one-sided
and is not inherited. This means that friends of a superclass are not automatically
friends of the subclasses.
· Defining GIobaI Exception Iasses: Ìn addition to using pre-defined exception
classes for errors in the runtime environment, you can define your own global
exception classes for special errors within your application using the Class Builder.
Exception classes are derived from one of the predefined basic classes CX_STATÌC_
CHECK, CX_DYNAMÌC_CHECK or CX_NO_CHECK as subclasses. Ìn contrast to
normal classes, you cannot create a method for an exception class. The Class Builder
simply creates the constructor. However, you can create attributes and maintain
exception texts. There should be an explanatory text assigned to each exception.
This text describes the exception situation for the user. You can assign one or more
texts to an exception class in the Class Builder. Different texts are addressed with
corresponding ÌDs. Each class has a default text whose ÌD corresponds to the class
name. Ìf you want to create further texts for special cases of this exception, you have
to assign a separate ÌD for each text. Exception texts are generally language-specific
& have to be translated. The OTR can be used here as a central storage area for
exception texts. You might want to parameterize exception texts with attributes of the
exception class. To do so, enclose the attribute name in '&' characters.
Example: An error occurred in object &ATTRÌBUTE&.
To create exception texts:
1. Select the exception class.
2. Switch the Class Builder to change mode and click on Tets.
3. First edit the default text whose ÌD was created automatically.
4. Choose ENTER.
The system displays the Create T# Concept dialog box. Confirming your entries
will copy the new text to the OTR. Ìf necessary, create further ÌDs to assign special
texts and repeat steps 4-6. The exception texts for an exception class are created in
the OTR and can be output as message texts.
· Settings in the Iass BuiIder: Choose &tilities->$ettings. Select the appropriate
settings on the Class Builder title element. The selected settings will take effect in the
Class Builder when you select the Filter checkbox. Choose &tilities-> #efactoring
Assistant. Move the components from one class/interface to another class/interface
using Drag & Drop.
· Testing: You can only test the public components of objects.
Exceptions can be triggered both implicitly in the ABAP runtime environment and
explicitly in the ABAP program. The program execution can be continued by handling
an exception in the ABAP program. Some Exceptions cannot be handled and resulting
in a runtime error.
Class-based exceptions are handled in the following control structure:
... " TRY block (application coding)
ATH cx_... cx_... ...
... " CATCH block (exception handler)
ATH cx_... cx_... ...
... " CATCH block (exception handler)
... " CLEANUP block (cleanup context)
Class-based exception handling is based on exception classes. Exception classes can
be defined by the user with the Exception Builder (SE24) in the ABAP Workbench. A
series of predefined exception classes is also available. Class-based exceptions are
either raised by ABAP statement RAÌSE EXCEPTÌON or by the ABAP runtime environ-
ment. Ìf a class-based exception occurs, the system interrupts the normal program flow
and tries to find a suitable handler. Ìf it does not find a handler, a runtime error occurs.
Exceptions that are raised in procedures but are not handled in the procedure itself are
forwarded to the caller. The caller can either handle the exception or forward it.
Handlers are defined for one or more exception classes. To define handlers for all the
subordinate classes of the exception classes, a superclass is specified. This enables
entire groups of related exceptions to be handled.
· TRY BIock : in which exceptions can occur. This exception block consists of all the
statements between the TRY and the CATCH statement. The TRY block contains the
application coding whose exceptions are to be handled. This statement block is proce-
ssed sequentially. Ìt can contain further control structures and calls of procedures or
other ABAP programs. Ìf no exceptions occur in the TRY block, program execution is
continued directly after ENDTRY after the block has been completed. TRY-ENDTRY
structures can be nested in any statement blocks. Ìn particular, the three statements
blocks above can also contain complete TRY-ENDTRY blocks.
Raising an Exception With Generation of an Exception Object:
RAISE EXEPTION TYPE cx_... [EXPORTING ... fi = ai ...]
This statement raises the exception linked to exception class cx_... and generates a
corresponding exception object. The optional ÌMPORTÌNG parameters of the instance
constructor of the exception class can be supplied with the EXPORTÌNG addition. This
can fill the attributes of the object with values that a handler can access.
Raising an Exception with an Existing Exception Object:
RAISE EXEPTION ref
Ìn this case, the exception object must already exist and the REF reference variable
must point to it. This may be the case if the exception has already been caught once but
if the handler wants to raise it again or if the exception object was generated previously
by means of CREATE OBJECT.
· ATH BIock : One or more CATCH blocks for catching exceptions. These Exce-
ption blocks are initiated with CATCH and ended with a further CATCH, CLEANUP,
or ENDTRY.A catch block contains the exception handler that is executed when a
particular exception has occurred in TRY block of the same TRY-ENDTRY structure.
A TRY- ENDTRY structure can contain several exception handlers.The syntax for
introducing an exception handler is:
ATH cx_... cx_... INTO ref.
Any number of exception classes can be specified after CATCH. This defines an excep-
tion handler for all the specified exception classes and their subordinate classes. After
an exception occurs, the system searches through the listed exception handlers in spe-
cified order. The first exception handler whose CATCH statement contains the corresp-
onding exception class or one of its superclasses is executed. The system then continu-
es program execution directly after ENDTRY. No subsequent exception handlers are
considered. For this reason, the order of the different exception handlers within a TRY-
ENDTRY structure must be based on the inheritance hierarchy of the specified except-
ion classes. For example, a handler for the most general exception class CX_ROOT
can only ever be the last statement block before CLEANUP or ENDTRY. Otherwise,
none of the subsequent handlers would ever be reached. With the ÌNTO addition, a
reference to the exception object can be placed a reference variable. This enables the
attributes of the exception object to be accessed in the handler. The reference variable
must be suitable for the exception. Ìts static type must be the exception class itself or
one of its superclasses. You are advised to use an exception class below CX_ROOT or
CX_ROOT itself rather than the general class OBJECT. Only these classes contain
FS_EMPLOYEE_MT-MT_EMPDET_OB-EMPLOYEE = T_EMPLOYEE.
CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS
OUTPUT = FS_EMPLOYEE_MT.
COMMÌT WORK .
CATCH CX_AÌ_SYSTEM_FAULT .
DATA FAULT TYPE REF TO CX_AÌ_SYSTEM_FAULT .
CREATE OBJECT FAULT.
WRÌTE :/ FAULT->ERRORTEXT.
the methods relevant for exceptions. Ìf the system does not find a handler for an exce-
ption in a TRY-ENDTRY structure, it searches for a handler in the enclosing TRY-
ENDTRY structures from the inside out. Ìf the system does not find a handler here, it
tries to propagate the exception to a procedure caller.
· EANUP BIock: For cleanup work after the exceptions have been caught, for
example bringing objects into a consistent state. This statement block is initiated by
CLEANUP and ended with ENDTRY. A TRY-ENDTRY structure must not contain more
than one CLEANUP block. Ìf the system has not found a handler for an exception, but
exception is handled in an enclosing TRY-ENDTRY structure or is propagated to a
caller, the CLEANUP block is executed before it is handled by outside TRY-ENDTRY
structure. All the exceptions that occur within a CLEANUP block must also be handled
here since it can only be exited in the normal way.
· Propagating Exceptions: Class-based exceptions that occur in procedures
(methods, function modules, subroutines) do not necessarily have to be handled here.
They can be propagated to the caller of the procedure. Ìf the caller is a procedure and
the call takes place in a TRY block, the caller can handle the exception or propagate it
to its caller. Exceptions cannot be propagated to the callers from programs called up
with SUBMÌT ... AND RETURN or CALL TRANSACTÌON. A static constructor of a
class cannot usually propagate exceptions. Likewise, event handler methods can't
Methods of ocaI Iasses : The RAÌSÌNG addition is specified in the declaration of
METHODS meth ... RAISING cx_... cx_...
The exception classes whose objects are to be propagated are specified after RAÌSÌNG,
in the order described above. Conventional exceptions with the EXCEPTÌONS addition
cannot be specified simultaneously. This ensures that the caller of a procedure knows
which exceptions can occur in a procedure and can handle the exceptions or forward
them using the RAÌSÌNG addition. Exception classes in the RAÌSÌNG clause also have
to be specified in inheritance hierarchy order. This enables the caller of a procedure to
list the CATCH blocks in the correct order.
Methods of GIobaI Iasses : The RAÌSÌNG addition cannot be specified directly
with the methods of global classes. Ìnstead, the exception classes whose objects are to
be propagated must be entered in the exception table of the method in Class Builder.
The Class Builder sorts the specified exceptions in the order described above and
generates the corresponding RAÌSÌNG clause. The ception Class checkbox has to
be selected in the exception table of the Class Builder for this purpose. Otherwise, the
Class Builder views the exceptions entered as conventional exceptions and generates a
corresponding EXCEPTÌONS clause. The tool does not allow exception classes and
conventional exceptions to be used simultaneously.
Function moduIes : Ìn the same way as global methods in Class Builder, exceptions
in function modules are propagated when they are specified in the Function Builder. To
propagate class-based exceptions, the corresponding checkbox must also be selected
here. Otherwise, conventional exceptions are declared.
· Subroutines : With subroutines, the RAÌSÌNG addition is specified in the definition
of the subroutine.
FORM form ... RAISING cx_... cx_...
The exception classes whose objects are to be propagated are specified after
RAÌSÌNG. Class-based exceptions are the only exceptions that can be listed in the
interface of a subroutine.
· Types of exceptions : CX_STATÌC_CHECK, CX_DYNAMÌC_CHECK, CX_NO
_CHECK and their superclass, CX_ROOT, are abstract classes.
1. Exceptions that have to be decIared :The associated exception classes are
subordinate classes of CX_STATÌC_CHECK. For these classes, a corresponding
exception must either be handled or forwarded explicitly with the RAÌSÌNG addition.
This is checked in the syntax check. Exceptions requiring declarations can only lead to
runtime errors if they are not handled. At present, only self-defined exceptions for error
situations in the application coding are subordinate classes of CX_STATÌC_CHECK.
There are no predefined exceptions CX_SY_... for error situations in the runtime
environment that are subordinate classes of CX_STATÌC_CHECK.
2. Exceptions that do not have to be decIared :The associated exception classes are
subordinate classes of CX_DYNAMÌC_CHECK. Ìf this kind of exception occurs at
runtime, it has to either be handled or explicitly forwarded with the RAÌSÌNG addition, in
the same way as the subordinate classes of CX_STATÌC_CHECK. This is, however,
not checked in the syntax check. Ìf this kind of exception is neither handled nor forwar-
ded at runtime, a runtime error occurs. Most of the predefined exceptions CX_SY_...
are subordinate classes of CX_DYNAMÌC_CHECK.Since exceptions of CX_DYNAMÌC
_CHECK category do not have to be declared in the interface, the called procedure
determines whether they are prevented or handled. The caller cannot assume that this
kind of exception is forwarded.
3. Exceptions that must not be decIared :The associated exception classes are
subordinate classes of CX_NO_CHECK. This kind of exception can be handled.
Otherwise, it is forwarded automatically. The RAÌSÌNG clause contains the addition
CX_NO_CHECK implicitly. Some of the predefined exceptions CX_SY_... are subordi-
nate classes of CX_NO_CHECK. The caller of a procedure must always take into
account the fact that the procedure can propagate exceptions of the CX_NO_CHECK
· ocaI Exception Iasses : Local exception classes can be defined for specific
exceptions that only occur within one single ABAP program. The condition for a local
exception class is that it inherits from one of the three classes CX_STATÌC_CHECK,
CX_DYNAMÌC_CHECK, or CX_NO_CHECK, or from their subordinate classes. An
individual constructor & individual attributes can be created. Ìndividual methods should
not be created and the methods of superclasses should not be redefined.
· GIobaI Exception Iasses : Exceptions are represented by objects that are instan-
ces of exception classes. All exception classes must inherit from common superclass
CX_ROOT and one of its subordinate classes CX_STATÌC_CHECK, CX_DYNAMÌC
_CHECK ,CX_NO_CHECK. All exception classes must begin with the prefix CX_. They
are usually defined globally with the Class Builder(SE24). Exception classes have the
onstructor: The constructor must have a predefined structure & a specific interface.
With global classes, the Class Builder generates the correct constructor and sets it to
an unchangeable status. Ìt also transfers the text of the superclass for an exception
class whose exception text is not specified explicitly. Constructor has two ÌMPORTÌNG
- TEXTÌD of the SOTR_CONC type :This parameter can be used to determine which
of your exception texts the exception will use.
- PREVÌOUS of the CX_ROOT type : This parameter can be used to assign PREVÌOUS
attribute a previous exception.
Methods: Ìn exception classes, New methods cannot be added. Following two prede-
fined methods are inherited from the root class CX_ROOT:
- GET_TEXT: Sends back the exception texts of a class (controlled by the TEXTÌD
attribute) as a string.
- GET_SOURCE_POSÌTÌON: Returns the program name, name of a possible include
program, and the line number of the statement that raised the exception.
Attributes: The following attributes are inherited from CX_ ROOT:
- KERNEL_ERRÌD: The name of the associated runtime error Ìf the exception is not
handled. Parameters cannot be transferred to the constructor for this attribute. Ìf the
exception is raised with RAÌSE EXCEPTÌON, the attribute is set to initial.
· Exception Texts: The exception texts of global exception classes are stored with
their various translations in the OTR (Open Text Repository). A text is assigned to an
exception class via the TEXTÌD attribute defined in the CX_ROOT superclass. This
attribute contains the globally unique ÌD of the text object in the OTR in an exception
object at runtime. GET_TEXT method reads this text, may substitute text parameters
with the contents of the corresponding attributes, and returns the text as a string. The
exception texts in the OTR are in any language. As soon as GET_TEXT is called up,
the logon language must be set. Ìt always makes more sense to work with the
exception object itself within an application rather than to work with the value returned
by GET_TEXT. The exception texts of global classes are defined on the Tets tab
page of the Exception Builder. Although the exception texts are not primarily designed
for interaction with the end user, it may, in certain cases, be worth outputting them as
messages. For this purpose, the MESSAGE statement has been extended to enable
any strings to be output:
MESSAGE string TYPE type.
· Exceptions in Function ModuIes and Methods : These exceptions and the
mechanisms for handling them are available in addition to the class-based exceptions
both before and after 6.10 for reasons of downward compatibility. The two handling
types cannot be used in parallel within the same processing block.
Menu Painter (SE41)
· Menu Painter is a tool used to design user interfaces for your programs.
· An instance of the user interface, consisting of a menu bar, a standard toolbar, an
application toolbar, and a function key setting, is called a GUÌ status.
· The GUÌ status and GUÌ title (TÌTLE BAR) defines how the user interface will look and
behave in an ABAP program.
· Some statuses do not use all of these objects. For example, the status of a modal
dialog box uses only function keys and an application toolbar.
· The principal object of a user interface is the GUÌ status. This can be assigned to any
screen (screen,list,selection screen). GUÌ title for screen.
· Different GUÌ statuses can refer to common components.
· A program can have many GUÌ statuses and titles. These represent the different
modes (for example,change or display) in which an application may operate.
· Several different screens can use the same status.
· Ìnterface Object List contains status list, menu list, function list, title list, menu bar list
and function key setting list.
· You can also change menu texts, function texts, icons, title texts and short
documentation if you access the list in change mode.
· reating a GUI TitIe : You can create a GUÌ title for each screen in program which
you can set in an ABAP program using the following statement:
SET TITEBAR <TITEODE>.
To determine a title at runtime, use an & (ampersand) with your title text.
SET TITEBAR <TITEODE> WITH <var1> <var2>... <varN>.
At runtime, these variables are replaced with the values that you specify. You can use
up to nine variables in a title. After SET TÌTLEBAR, the field SY-TÌTLE contains the
current title. SY-SUBRC = 0 ÌF Entry found, else 4. Once you have set a title, it remains
active within the transaction until the next SET TÌTLEBAR statement.
· reating a GUI Status :
Status type References to
ialog status Menu bars, standard toolbar, function keys and
ialog bo Function keys and application toolbar. Dialog boxes do
not have menu bars or a standard toolbar.
Contet menu A context menu. Context menus contain a set of
functions that you can use to construct a context-
· reating a ontext Menu :
- You can use the entries from a context menu that you define in the Menu Painter to
construct a context menu on a screen or list using method OAD_GUI_STATUS
from the global class _TMENU.
- Ìn the Code column, enter a function code, and under Tet, the corresponding text
for the menu entry.
- To enter a separator, choose dit ->Insert -> $eparator
- Ìf you want to create a cascading menu, leave the Code field empty, and enter the
menu text for the cascading menu.You can then open it by double-clicking, and
enter the required entries.
· reating a Menu Bar :
- You can either create a new menu bar, or link to an existing one.
- A menu bar may contain up to six menus.Each menu can contain up to 15 entries.
The system then adds the two standard menu bars -$ystem & Help.
- Choose-> Display standards to display SAP standard menus.Change the first menu
title <Object> to something relevant to your application. To use a standard function,
activate it by entering a function code next to it.
- Choose Utilities-> Help texts->Standards/Proposals. Ìt helps you to create transacti-
ons with the look and feel of the standard R/3 applications.
- A menu can contain any of the following :
1. Function names (with function code and text)
2. Submenus (pull-down menus) /Cascading Menus up to three levels deep.
3. Separators: Menu functions that logically belong together are grouped together
- Choose &tilities -> $ettings -> &ser-specific to change displayed length of the field.
- You can cut, copy, paste, and delete menu entries.
- Ìf you double-click a function code, the Function Attributes dialog box appears. Here
you can, for example, change the icon assigned to a function.
· Defining Function ey Settings :
- The function keys are special keys on the keyboard (F keys) which enable you to
trigger functions without having to use the menu.
- To add function keys to your interface, you must assign function code to a specific
function key & text which is visible as documentation whenever the user presses the
right mouse button.
- Ìn the R/3 System, there is a distinction between:
1. Reserved function keys 2. Recommended function key settings
3. Freely assigned function keys
- F1(Help),F3(Back),F4(Possible entries),F12(Cancel) are reserved by SAP.
- You can overwrite #ecommended function key text but not recommended.
· Defining an AppIication TooIbar :
- Pushbuttons are arranged in the application toolbar,which appears below the
- You can include up to 35 pushbuttons in the application toolbar.
- You must have assigned a function code to a function key before you can include it
in the application toolbar.
- You should only create pushbuttons for functions that are available on menu.
- You can create icons for functions in the application toolbar by Double-clicking a
function in function key setting. An icon can appear alone or with text.
- Enter an Infotet if required which is displayed when the user places the cursor on
the icon & also displayed in the status bar
- Ìf you set the Fixed positions attribute (oto->Attributes ->Application toolbar ),
the pushbuttons in the application toolbar are not shifted when you activate or
deactivate functions dynamically.
- You can divide up application toolbars by separators.
· reating the Standard TooIbar: The functions that you want to assign to the
standard toolbar must already have been assigned to function keys.SAP recommends
that you always activate at least the Back, it, and Cancel functions in the standard
toolbar.Enter the required function codes above the relevant icons in the $tandard
· Testing a Status: Choose &ser interface -> Test status. Enter a screen number
and title if you want to simulate a whole screen. Ìf you do not enter a screen number,
the system simulates the status using an empty test screen.Choose Execute. A dialog
box appears, containing the window co-ordinates.choose Continue. The system
always uses the inactive version of the status where one exists.
· Using the Extended heck : The Menu Painter's extended check examines all
the GUÌ statuses in your program for correctness, syntax errors, and completeness.
choose &tilities -> tended check either from the initial screen of the Menu Painter,
or from the work area.
· opying a Status: You can create a new GUÌ status by coping all or some of
components of an existing status in same or another program by using Copy $tatus
dialog box. Also you can copy individual menu bar,function key settings & application
toolbar by choosing dit -> Copy .But any changes to components are visible in both
statuses. There are several ways you can remove a link. The simplest method is to
simply overwrite the link with new information.You can also use the dit -> Initialize
function to reset a function key, menu, or pushbutton setting. Choose &ser interface ->
elete -> $ub-object to delete Ìnterface Objects. Choose &tilities -> &nused objects
for locating and deleting unused Objects.
· Functions : When you choose a function, its function code is passed either to
system field SY-UCOMM (in type 1 programs) or to the OK_CODE field (in transact-
ions). Definition of an interface function contains the following elements: Function
code, Function Type, Function text, Ìcon name, Ìcon text, Ìnfotext, Fastpath .
· Function types: Can tell the system when or how to carry out a function.Double-
click a function in the GUÌ status.The Function Attributes dialog box appears,assign
function type. The system uses the following function types:
SPAE Normal function code processing (for example, in a PAÌ module).
E Triggers an "at exit-command" module in the Process After Ìnput
(PAÌ) processing block (MODULE <xxx> AT EXÌT-COMMAND).
When the user selects an E type function, the system enters the "at
exit-command" module before carrying out any input checks.
T Calls another transaction. Activating a T type function has the same
effect as the LEAVE TO TRANSACTÌON statement. The user cannot
return to the original transaction.
S Triggers system functions used internally in SAP standard applications.
Do not use type 'S' when creating your own functions.
P Triggers a function defined locally at the GUÌ. This function is not passed
back to ABAP program (no SY-UCOMM or OK_CODE).Ìnstead, it is
processed at the presentation server. Ìt can only currently be used for
tabstrip controls (Screen Painter).
· Fastpaths: Allow you to enter a menu path using a single letter or sequence of
letters instead of the mouse.For example, You can choose the function Delete from
the Edit menu by entering D or enter the entire menu path using the letter .DE in the
command field. The fastpath for a menu must be unique within the menu bar. The
fastpath for a function must be unique within its menu. The system creates a set of
default fastpaths automatically.You can then change the fastpath if required by
Choosing oto ->bject lists -> Fastpath.To display a default set of fastpaths, choose
· Activating and Deactivating Function odes : Active functions are executable
functions and inactive functions are not executable. Ìf inactive functions are assigned
to the application toolbar,the system does not display the function unless you have set
the fixed positions option for application toolbar. Ìn the standard toolbar, the system
grays out inactive functions at runtime. Ìnactive functions are grayed out in menu.You
can activate or deactivate menu options from within Menu Painter.Choose tras ÷>
Function Active <-> Inactive.The system activates deactivated function or deactivates
active function.Select tras ->Active functions in current status.You can now
deactivate a set of functions by deselecting the corresponding checkbox.Choose
tras->Active functions in multiple statuses. The system generates a list showing all
the statuses where the function is used.
· Deactivating Functions at Runtime :
SET PF-STATUS 'status_name' EXUDING 'function_code'.
Above statement Deactivates a Single Function whose code is function_code.
SET PF-STATUS 'status_name' EXUDING itab.
Above statement deactivates several functions at once by filling an internal table with
all the function codes you want to deactivate. Ìnternal table has a line type sy-ucomm.
· Defining Dynamic Function Texts : You must define a field of the structure
SMP_DYNTXT in your ABAP program that will contain the required text at runtime.
Choose dit -> Insert -> Func.with dyn. tet. You can change static function texts to
dynamic ones, and vice versa by Double-clicking the function that you want to
change. The Function Attributes dialog box appears. Choose Change tet type.
· Defining Dynamic Menu Texts : Choose dit -> Insert -> Menu with dyn. tet.
· Setting a GUI Status and GUI TitIe : You set a GUÌ status and GUÌ title for a
screen in the PBO (Process Before Output) module of corresponding screen using
the ABAP keywords SET PF-STATUS & SET TÌTLEBAR.When you set a GUÌ status
or a GUÌ title, it remains set until you explicitly set a new GUÌ status or title for same
or next screen. Ìf you want to use a GUÌ status or GUÌ title from another ABAP
program, you can use the SET statement with the addition OF PROGRAM.
SET PF-STATUS <stat> [OF PROGRAM <prog>] EXUDING <f>|<itab>].
SET TITEBAR <titIe> [OF PROGRAM <prog>] [WITH <g1 >... <g9>].
Area Menu Maintenance (SE43)
Screen Painter (SE51)
· The Screen Painter is a ABAP Workbench tool that allows you to create dialog
screens for your transactions & to write flow logic behind the screen.
· EIements of a screen :
- Screen Attributes : Ìt include the program the screen belongs to & the screen type.
- Screen eIements : are the parts of a screen with which user interacts.
- FIow Iogic : Controls the flow of your program.
· Screen Painter Modes : (&tilities -> Settings ) The Screen Painter has a layout
editor that you use to design your screen layout.
- GraphicaI mode : is available only on MS Windows 95, MS Windows NT, and Unix
/Motif platforms. You use a drag and drop interface similar to a drawing tool.
- AIphanumeric mode : You use your keyboard and menus.
You can create a screen from the Screen Painter initial screen or from the object list
in the Object Navigator.
· The program you specify should be an executable program (type 1),a module pool
(type M), or a function group (type F) and must already exist.
· A screen number must be unique and up to 4 numbers long. All screen numbers
above 9000 are reserved for SAP customers. The number 1000 is reserved for table
screens and report selection screens.
· Screen type :
NormaI : Ìf you set this option, the screen is flagged as a normal screen (default).
Subscreen : Ìdentifies the screen as a subscreen.
ModaI diaIog box : Ìdentifies a specialized interface for display of lists in a dialog box.
SeIection screen : Ìdentifies an automatically created screen. Selection screens
request values for database selection criteria before a report is started. The system
sets this attribute automatically.
· The system only supports the HoId data, Set data, and DeIete data functions. For
hold data, the system can hold entries made on the screen at runtime in this way. The
system automatically displays this data if the user calls the particular screen again.
· Ìf you set the option Switch off runtime compression, the screen is not compressed
· Use the option HoId scroII position to specify whether the vertical and horizontal
scroll positions should be retained for a screen after returning from another screen.
· With Without appIication tooIbar attribute you can suppress the display of the
application toolbar belonging to the current program status.
· Next screen : Number of the next screen to be displayed, assuming that the screen
sequence is processed statically.
· ursor position : Ìdentifies the screen element that contains the cursor when a
screen is first displayed. Ìf you leave this field blank, the system uses the first screen
field that can accept input.
· Screen group : Specifies a four-character identifier of a group of associated screens
to ensure that modifications to all screens in group are consistent. Screen groups can
be maintained in Table TFAWT. SY-DNGR field contains screen group name.
· ines/coIumns occupied : Specifies the size of the screen area currently occupied
with screen elements.
· ines/coIumns Maint.: Size of the screen in rows/columns. The size is measured in
characters starting with the upper left corner. Screens can have a maximum size of
200 rows x 255 columns.
· The fIow Iogic editor is similar to the ABAP Editor and provides functions for editing
screen flow logic.
· After designing screen, Use the heck function to ensure that your screen layout
conforms with the SAP ergonomic standards.
· FIow ogic eywords : You define the flow logic in the flow logic editor of the Screen
Painter, using the following keywords:
CALL Calls a subscreen.
CHAÌN Starts a processing chain.
ENDCHAÌN Ends a processing chain.
ENDLOOP Ends loop processing.
FÌELD Refers to a field. You can combine this with the MODULE
and SELECT keywords.
LOOP Starts loop processing.
MODÌFY Modifies a table.
MODULE Ìdentifies a processing module.
ON Used with FÌELD assignments.
PROCESS Defines a processing event.
SELECT Checks an entry against a table.
VALUES Defines allowed input values.
· ExampIe of FIow ogic : The following example shows some use of screen flow
*Processing Before Screen Output
PROESS BEFORE OUTPUT.
* Self-programmed F1 Help
PROESS ON HEP-REQUEST.
FÌELD GSSG-BUKRG MODULE V-BUKRG.
* Processing after user input
PROESS AFTER INPUT.
* Lock customer master record
* Read customer master record
* Read business area
* Process function code
FÌELD OK-CODE MODULE OKCODE ON ÌNPUT.
EIement PaIette (GraphicaI Screen Painter):
· GraphicaI ayout Editor : The graphical layout editor provides a user-friendly
environment for designing screens. Components of the Layout Editor :
EIement paIette , for creating screen elements. Drag and drop these onto the screen.
Work area This is main part of full screen editor, in which you design the screen itself.
· Screen size is measured in characters from a screen's top left corner. The standard
screen size is 21 lines by 83 columns. The maximum screen size is 200 lines by 240
columns. The system maintains the screen title, menu bar, status bar and command
field separately. These are not affected if you change the screen size.
· You can convert screen element to a another kind of element using the dit menu.
· Text FieIds : Ìt provide labels for other elements.Can not modify.Can include literals,
lines, icons, and other static elements. Cannot begin a text with _ or ?. Ìf you use a
text to label a radio button or checkbox, the text must have the same element name
as the element it labels.
· Input/Output FieIds : For entering and displaying data. To assign a label to it, place a
text field next to it. To define the size of an entry element, enter underscore
characters in the Tet field. You can also use any other characters to format your
template. For numeric values, you can define a comma (,) as the separator and a
period (.) as the decimal point. As the last character of the template, you can set a V
as place holder for signs.
· Dropdown ist Box : This is a special type of input/output field. Dropdown list boxes
contain a list of entries from which the user can choose one. You cannot type an
entry into the text field of a list box.
· heckbox : Use checkbox elements to select one or more options in a group.
· Radio buttons : are exclusive selection buttons that belong to a logical group. Like
checkbox, Program control is not immediately passed back to a work process on the
application server. Further selections are possible until the user pushes a button or
chooses a menu function.
· Pushbutton : You use pushbuttons to trigger a particular function. When a user
chooses one, the system sends the associated function code to the underlying ABAP
program. At that point, control automatically returns to a work process on the appli-
cation server that processes the PAÌ (Process After Ìnput) module. A pushbutton
label can be simple text or it can be dynamic text that changes at runtime. You must
define fields in your program for dynamic text.
· Boxes : A box groups a set of elements that belong together - for example, a radio
button group. Boxes are only for display. Boxes provide visual emphasis but have no
other function. The top edge of a box normally contains a left-justified header. This
header can be either a text field or an output field.
· Subscreen area : Subscreen elements are rectangular areas of a screen reserved
for displaying other screens at runtime. A subscreen area cannot include any other
screen elements. You use subscreens to include other screens within main program.
· ustom ontainer : You can use the custom container to embed one or more
controls (ex.ALV grid control) within a screen area. The custom container, like other
screen elements, supports resizing and compression. Ìn the Screen Painter, a
rectangular area appears as a placeholder for one or more controls. The control itself
does not appear on the screen until runtime.
· Status Icons : Status icons are output fields that contain an icon. The icon is
specified at runtime. You use icons to indicate statuses in your application. Ìcons are
predefined in the system and are each two to four characters long.
· SeIecting FieIds : You can list fields from the ABAP Dictionary or your program in
the ict./!rogram Fields dialog box (choose et from ict. / et from !rogram.
Choose Reset to cancel a copy. You can also add elements without first selecting
fields from the ict./program fields dialog. Ìn this case, you have to provide a field
· Modifying Screen EIements : To select a single element, single-click it. You can
select several elements by dragging a rectangular "rubber-band" around them or by
holding down the CTRL key while clicking on each element. You can Use the arrow
keys to select individual elements one by one. You can delete any screen element by
selecting it and choosing dit -> elete. To move an object, select it and use the
mouse to drag it to a new position. You can select several elements and move them
as a group. You can resize elements by selecting and dragging right or bottom edge
of the element. You can also resize screen itself. You can use Undo/Repeat, ut,
opy, and Paste Option.
· Using Icons : You can use icons in place of or together with text elements, Push -
butttons, checkboxes, and radio buttons. Select icon name from $creen !ainter
Attributes dialog box.
· Using Radio Buttons : Before you can create a radio-button group, you must create
the individual radio buttons separately.For Defining a Radio Button Group, Select the
individual radio buttons & Choose Edit -> Grouping -> Radiobutton group -> Define.
For Adding Radio Buttons to an Existing Group,Select an existing group,Choose dit
÷> rouping -> #adio button group -> issolve, Add the new buttons to the selection,
Select the group and choose dit -> #adiobutton group -> efine. The system
displays a dotted line around the new group.
· Tabstrip ontroIs :
A tabstrip control is like a card index file used to define several components of an
application on a single screen and to navigate between them. Ìt make the structure of
the application easier for users to learn and understand. You should used tabstrip
controls whenever a single object or application has different components or logical
views that users need to navigate between.
Tab TitIe : They are pushbuttons. You can use icons on a tab title. The text should be
short and meaningful.
Tab TitIe Row : The first row of the tabstrip control is reserved for the tab titles.
Tab Page : Ìt contains a collection of fields that logically belong together. Tab pages
are implemented using subscreens.
Tab Environment : The screen environment around tabstrip must remain constant.
When you change between tab pages, the menus, application toolbar, and other
fields outside the tabstrip control must not change. For further information about
designing and using tabstrip controls, see Transaction BIBS. Under lements, you
will find a sample program for a tabstrip control. Under #ules, there are tips for
Procedure for defining Tabstrip ontroIs :
1. Choose the tabstrip control icon from the element palette, Drag the object out to the
required size and release the mouse button. Assign a name & other attributes to the
new tabstrip control. Declare the tabstrip control in your ABAP program (not in screen
flow logic) using the following statement:
ONTROS <tab_strip_name> TYPE TABSTRIP.
2. By default new tabstrip controls come with two tab titles.Assign name, text, icon
name to each tab title.Mention Function code that triggers the PAÌ event. When the
user clicks the tab, the function code is placed in the system field SY-UCOMM. Ìf you
are scrolling at the backend, the function code is also placed in the OK_CODE field.
Mention FctType .A tab title may have the function type <P> or <SPACE>.To scroll
locally at the frontend, use type <P>. Ìn this case, the PAÌ event is not triggered when
the user chooses a tab title, and there is no data transfer to the application server. To
scroll at the backend, use function type <SPACE> (no special type assignment). Ìn
this case, the PAÌ event is triggered when user chooses a tab title, and the function
code is placed in the OK_CODE field.
3. You must assign a subscreen area to each tab page. Ìf you are using local scrolling
at the frontend (function type <P>) you must assign a separate subscreen area to
each tab page.Ìf you are scrolling at the backend (function type <SPACE>), you can
use one shared subscreen area for all tab pages. Select a tab title.Choose $ubscreen
area from the element toolbar.Position the subscreen area within the tabstrip control,
and drag it to the required size. Enter a name for the subscreen area. This name also
appears as the reference field in the tab title attributes.
4. Ìf you are using Local Scrolling at the Frontend, you must include subscreen screens
in all of your subscreen areas in the tabstrip control. Use following syntax in PBO &
PAÌ event of your flow logic. Mention screen no in 4 digit without quotation mark.
PROESS BFORE OUTPUT.
> INUDING [<progname
> INUDING [<progname
PROESS AFTER INPUT.
A SUBSREEN: <subscreen_area
5. Ìf you are scrolling at the application server, you only need to include one subscreen
at a time in a single subscreen area.
PROESS BFORE OUTPUT.
A SUBSREEN < subscreen_area> INUDING [<progname>]
PROESS AFTER INPUT.
A SUBSREEN < subscreen_area>.
Ìf you are calling the subscreen from the current program, use SY-REPÌD in place of
program name. Ìf you are scrolling at the application server, <subscreen _scrn> can
be the variable whose value will be changed during run time.
6. Using the Tabstrip ontroI Wizard : The tabstrip control wizard allows you to create
and implement tabstrip controls quickly & easily. The wizard takes you through the five
steps required to create a working tabstrip control. The Generated dialog logic uses
- Creates an instance of the tabstrip control.
- Defines the tab pages and associated function codes.
- Assigns a common subscreen area to all tab pages.
- Creates a new subscreen screen (unless you want to use an existing one).
- Generates the flow logic required for backend scrolling.
- Creates the PBO and PAÌ modules and all necessary data definitions.
- Creates the appropriate includes for the modules and data definitions (if required).
· TabIe ontroIs : A table control is an area on the screen in which you can display
data in tabular form. You process it using a loop. See Transaction BIBS. Table controls
allow you to enter, display, and modify tabular data easily on the screen. They provide
the following functions:
- On definition
- Fixed columns
- Column headers
- At runtime
- Vertical and horizontal scrolling.
- Modifiable column width.
- Row and column selection.
- Movable columns
- Settings can be saved.
Lines in a table control may contain keywords, input/output fields, radio buttons,
checkboxes, radio button groups, and pushbuttons. A line can be up to 255 columns
Procedure for defining TabIe ontroIs :
1. With the Screen Painter in change mode, choose the table control icon from the
element palette. The mouse pointer changes its shape. Drag and drop the object
onto the screen work area. Resize or reposition the table control if necessary. Assign
an element name to the new table control.
2. To define elements for your table control, you can use ABAP Dictionary fields, fields
from the program, or completely new fields. Ìf you want to create new fields, you use
elements from the element palette as follows:
- Choose an element from the element palette and place it in the definition line of the
table control. The system creates a new column.
- Assign an element name to the element, and any necessary attributes.
- Create a column header by dragging a text or entry element into column heading.
- Repeat steps 1-3 for each additional column.
3. Ìn the table control attributes, select ith title. A dialog box appears, reminding you to
create a title element. Enter a text field or an input/output element in the title row.
Enter an element name, and the title in the Tet field.
4. Ìnsert the following CONTROLS statement in the global data declaration of your
transaction. Mention screen no in 4 digit without quotation mark.
ONTROS <tab_ctrI_name> TYPE TABEVIEW USING SREEN <screen_no>.
5. TabIe ontroI Wizard allows you to create a working table control quickly and
easily. Ìt also lets you generate certain standard table maintenance functions. You
can create table controls in this way and then adapt them to the particular needs of
- Creates an instance of the table control.
- Assigns an ABAP Dictionary or program table to the table control.
- Selects the table fields for the column definition.
- Assigns important table control attributes.
- Generates the relevant statements in the screen flow logic.
- Creates PBO and PAÌ modules, subroutines (for standard table maintenance
functions), and all necessary data definitions.
- Generates standard functions for table maintenance (scrolling, insert/delete lines,
- Creates includes for the modules, data definitions, and subroutines, if required.
6. You can Change the Size and Position of table control , rearrange the columns in a
table control, use the cut and paste functions to move columns within the table
control. To allow users to select columns in the table control, set the column sel.
attribute. You can also decide whether to allow single or multiple column selection.
You can also allow users to select rows in a table control. To do this, you must set
the Line sel. attribute. Again, you can choose whether to allow single or multiple line
selection. Ìn addition, you must mark the w/ $elColumn field and enter a field name
into the adjacent field. This name allows you to query which line the user selected
from your ABAP program.
· Step oops: Step loops are considerably less flexible than their replacement, table
controls. To create a Steploop :
- Open a screen in the layout editor.
- Ìn one or more lines, create the elements you want to repeat.
- Select all the elements on the desired line(s) as a group.
- Choose dit-> rouping->$teploop -> efine.
Your element lines now make up a single steploop block. The block includes the
original elements with their attributes and a predefined number of repetition blocks.
Each repetition contains a copy of the first block without attributes. The repetition
blocks are consecutively numbered, so that you can establish a reference to a
particular line. You can define a loop block as fixed or variabIe. Ìn a fixed loop, the
lower limit of the loop area always remains as originally defined. For a variable loop,
the number of repetitions is adjusted dynamically in the screen program to suit the size
of the current window. Ìn order to be able to react to the variable loop size, the system
always places the current number of loop blocks in the system field SY-LOOPC. Ìf the
screen includes several loop blocks, you can define only one of these as variable.
Choose dit -> rouping -> $teploop -> Fi or 'ariable. Variable loop is adjusted
dynamically with the screen size and a fixed loop is not.
onverting a Step oop : You can convert a steploop into a table control. Select a
steploop without its headings or with its headings and choose dit -> Convert -> Table
Control for Converting step loop into table control without Headings or with headings
· Defining the EIement Attributes :
1. GeneraI Attributes :
- EIement type : Ìdentifies a screen element type .
- Name : Ìdentifies an element. The name can contain only alphabetic and the special
characters #, /, -, _,$. Field names can not exceed 40 characters and must begin with
a letter or an * (asterisk). You use this name to address a field from a module pool.
All input/output fields require a name. Text fields require a field name only if they are
translated into another language. Ìf you enter a field name with a - (dash), system
checks to see if the ABAP Dictionary contains the field. You can refer to the
following string types:
STRG : Character string of variable length
SSTR : Short character string of variable length
RSTR : Byte string of variable length (hexadecimal)
These string types correspond to Dictionary types STRÌNG, SSTRÌNG & RAWSTRÌNG
and can be used wherever type CHAR used to be used. Note that the maximum length
of an input/output field on the screen is restricted to 255 characters. You can only
define input/output fields in the Screen Painter that fit on a single line. Characters in a
string that are longer than this are truncated. The element in the ABAP program or
ABAP Dictionary can, however, be of any length.
- Text : Specifies a field's text. Ìf you want to use an icon instead of text, leave this field
- Dropdown : This attribute can only be assigned to an input /output field. You can
assign the following values:
No entry : Visualization as normal input/output field.
Listbox : Visualization as listbox in which a list of entries is displayed with one short
Listbox with key : Visualization as listbox whose entries display both key & descp.
The selected value cannot be changed at runtime. The width of the list is determined
by the VisLg (visible length) fields. The height is automatically set by the system. You
assign a value list to the output field using the ValueÌD. The default value of this is the
name of the input/output field (ame attribute). How value list is displayed depends
on the entry in the Ìnput help attribute. You can trigger an event by selecting a value
from the dropdown list. To do so you have to define a function code with attribute
- With icon : Sets an icon value. Only use this attribute for output fields. For a list of all
existing icons including length & quick info texts, refer to table ION or Tcode ÌCON.
Ìf you want to inform the system that you want to assign an icon to the field at runtime,
possibly with an accompanying text use the function module "ION_REATE".
- Icon name : Ìdentifies an icon for a keyword. For templates, you set the Icon ame
attribute at runtime.
- Quick info : Ìdentifies an icon's info text. This text is visible when the user holds the
cursor over an icon.
- ScroIIabIe : You must set the attribute $crollable if you want to make visible length
less than the defined length.
- ine : Specifies the line where the screen element appears.
- oIumn : Ìdentifies the column where the element begins.
- Height : Specifies the height of an element in Lines.
- Defg : Defined length. Ìdentifies the actual length of the field in the Dictionary or
your program. You can only set & change the visible length and not the defined length
for an input/output field of string type (STRG, SSTR, RSTR). This is because the
entire length of the strings is always copied at runtime. Such input/output fields can
always be scrolled.
- Visg : The length of an element displayed on the screen. You can only change the
visible length for input/output templates or for elements in table columns. For input
/output fields having the ropdown attribute and the Listbo entry this is the length of
the element including the dropdown button. The visual length is then identical to the
width of the dropdown list.
- Groups : Modification groups This attribute allows you to update several elements at
once. You can assign each field to up to four modification groups.
- Fctode : Function code. This attribute is only for pushbuttons and input/output fields
with the ropdown List bo attribute. The specified function code of 20-character is
sent to the server as an event.
- FctType : Function Type. Refer Menu Painter.
- ontext Menu Form : Name extension for the callback routine ON_CTMENU_
<NAME>. The name extension <NAME> can be chosen to suit your needs and is
assigned either for the entire screen or for a screen element (input field, text field, box
or table control). The callback routine ON_CTMENU_<NAME> is needed to set up the
context menu in the ABAP program. This routine connects the screen (elements) from
the Screen Painter to the context menu of the program.
2. Dictionary Attributes :
- Format : Data type. The data type determines what checks (valid date, numc values)
the system should perform on field input and how to convert the field for input/output.
- From Dict. : Specifies the current ABAP Dictionary reference.
- Modified : The system sets this attribute if it detects a difference between Dictionary
definition for the field and the way it is used in the screen.
- onv.Exit : Ìf you want the system to use a non-standard conversion routine for the
conversion of field input, specify a four-character code here.
- Search heIp : Allows user to specify a search help as input to the element.
- Reference FieId : For tabstrip controls it establishes the link between a tab title and
a subscreen area. For currencies and quantities it specifies a currency or unit key.
- Parameter ID : ÌD for a SET/GET parameter (up to 20 characters long). This attribute
is used with either the SET parameter or GET parameter attribute.
- SET / GET parameter : Set and display default in an element. Ìf you choose Set
Parameter, the system stores the value entered by the user in the relevant Parameter
ÌD parameter. Ìf you choose Get Parameter, the system displays value in Parameter
ÌD in the element instead of the initial value.
- Foreign key check : Determines whether the system performs a foreign-key check
for the field.
- Upper/ower case : Set this attribute if your program handles the user's input as a
literal. Ìf not, the input is converted to all upper-case.
3. Program Attributes for Screen EIements :
- Input fieId : Defines an element as an input field.
- Input (Required entry) : Ìt has 4 values in 4.7 version.
Not possibIe : Ìnput/output fields cannot be assigned an input value at runtime,
that is the screen element can only be used for input.
PossibIe : Ìnput/output fields can be assigned an input value at runtime. However,
input is not required for the transaction flow.
Recommended: Ìnput/output fields should be given input at runtime. The system
does not always check at once to see if entry was made, but input is necessary
for further transaction flow. You should use this kind of field if the input is made in
more than one screen and will be tested together at a later time.
Required: Ìnput/output fields must be assigned input value at runtime. The system
checks this input at once when processing the PAÌ event.
- Output fieId : Defines an element as an output field.
- Output fieId onIy : Protects display-only elements from being changed into input-
possible elements at runtime.
- PossEntry / VaIue Iist : This attribute can only be set (and is only displayed) for
input/output fields with the attribute Dropdown and the entry List box. You use it to
determine how and when the value list for a dropdown list box is generated. There
are two possible entries:
Space: The system provides standard help. The help processor is started in the
PBO and fills the value table automatically before sending it to the Value Request
Manager. The sources are domain fixed values, value tables, and search helps.
Ìf the input/output field is linked to a PROCESS ON VALUE REQUEST module,
this takes priority over the automatic process described above.
A from program: The values are determined by the application itself within a PBO
module. The value table is passed to the Value Request Manager together with the
ValueÌD (attribute Name) with function module VRM_SET_VALUES.
- PossEntry / PossibIe entries key : Specifies whether a possible entries pushbutton
should appear beside the element. This attribute don't appear for listbox elements
with the dropdown attribute.
- Right-justified : When you activate this attribute, any output in the field is right-
justified. You can also display text fields in this way.
- With Ieading zeros : Left justifies values in numerical fields with leading zeroes.
- *-entry : Allows the user to enter an * (asterisk) in the first position of the element.
The system ignores the asterisk and transports input starting from the second
position. Transport is determined by the conversion guidelines in the field format.
However, the first-character asterisk triggers a flow logic module you declare with:
FIED... MODUE... ON *-INPUT .
- Without reset : Prevents the reset character (!) from being used to delete input from
an SAP field.
- Without tempIate : Prevents special characters from being treated differently. Ìf the
user enters special characters as part of the input, they are transferred to the screen
as regular text. Ìf you set this attribute, you cannot set the Req.entry attribute.
4. DispIay Attributes :
- Fixed font : Displays input/output fields and text fields in a nonproportional font. Do
not set this attribute, since fixed fonts are more difficult to read than proportional.
- Bright : Highlights an element.
- InvisibIe : Set this attribute if you want the element to be invisible.
- 2-dimensionaI : Displays elements without the three-dimensional shading that
normally appears around the element border. This field is automatically set when
you use an icon.
- As IabeI Ieft / right : This attribute is used for text fields and input/output fields that
are only used for display purposes (Ìnput field attribute not set). Ìf this attribute is set,
text field appears to the left / right of the screen element.
- DoubIe-Iick sensitive : Makes a screen element double-click sensitive (hotspot).
You can only set this attribute for text fields and input/output fields. Ìf you set this
attribute, double-clicking the element at runtime triggers an action.
5. Tabstrip ontroI Attributes :
- Tab titIe : Number of tab titles in the tabstrip control.
- Resizing VerticaI/horizontaI : Ìndicates that the tabstrip changes its size when you
change the height (vertical resizing) or width (horizontal resizing) of the window. Set
this attribute if you want tabstrip control always to appear in proportion to screen.
- Min. Iines : The minimum number of lines that can be displayed when you resize
vertically. Ìt is the height of the largest subscreen area in tabstrip control.
- Min. oIumns : The minimum number of columns that can be displayed when you
resize horizontally. Ìt is the width of the largest subscreen area in tabstrip control.
6. TabIe ontroI Attributes :
- TabIe type : Ìndicates whether the table control is for data entry or selection.
- W/ oIHe : This attribute allows you to create column headings as text fields or
- W/ TitIe : This attribute allows you to create a table title as a text field or an input/
- onfigbI : Allows you to save the current setting of the table control attributes to a
file at runtime. The system retrieves the settings from this file whenever the table is
displayed. Switch off this attribute if there is nothing to configure (for example, when
the table consists of a single column that is always displayed in full) or if the table
control is modified in the program.
- Resizing : Ìndicates a table supports vertical and/or horizontal resizing. Set this if
you want the table to change with a window's size.
- Separators : Ìnserts vertical separator lines between the table fields (columns) and
horizontal lines between the table rows.
- ine seI. : Allows line selection. Choose None, Single, or Multiple.
- oIumn seI. : Allows column selection. Choose None, Single, or Multiple.
- w/ SeIoIumn : Specifies whether a line selection column appears with the table.
The column is stored internally as a checkbox.
- Fixed oIumns : Excludes one or more columns from horizontal scrolling. Enter the
number of columns from the left that you want to fix.
7. Attributes of the Subscreen Area :
- ScroIIabIe : This is the scrolling function if the defined length of the subscreen area
exceeds the visible length.
- Resizing verticaI/ horizontaI : Set this attribute if you want the size of subscreen
area to change with the size of the window.
- Min. Iines : Defines the minimum number of rows for vertical resizing.
- Min. oIumns : Defines the minimum number of columns for horizontal resizing.
· hecking Screens : Choose $creen->Check->$ynta to check the syntax within the
Screen Painter (attributes and flow logic). Choose $creen->Check->Consistency to
check data consistency between a module pool, the ABAP Dictionary, and a screen.
The Consistency function also checks Next screen & Cursor position , search help,
reference field, and other attributes. Ìf you choose Screen->Check->Layout, the
system checks whether the layout of your screen corresponds to the SAP ergonomic
standards. However, these errors do not influence the processing of the screen. You
can generate a screen regardless of layout errors.
· Testing Screens : Choose Screen->Test. Testing allows you to check a simulation of
the screen as it will appear at runtime.
DiaIog (ModuIe PooI) Programming
Ìn a dialog-driven program, the program flow is controlled by a series of user dialogs. Dialog-driven
programs are typically started using transaction codes, which specify the first screen of program.
This initial screen allows users to enter or request information. The screen flow logic then reacts to
the user input by calling various modules of ABAP processing logic. Ìt then moves on to the next
screen. The corresponding ABAP processing logic might contain statements for displaying data or
updating the database. Type M programs serve principally as containers for dialog modules, and
are therefore known as moduIe pooIs. Programs that are partially or wholly dialog-driven can't be
executed in the background. They are therefore sometimes referred to as dialog programs.
Screens are the most general type of user dialog that you can use in ABAP programs.
You do not define them in ABAP programs, but instead in the Screen Painter. A screen
consists of the input/output mask and the flow logic. You can define screens for any
program with type 1, M, or F. The screen flow logic is divided into Process Before
Output (PBO) event, which is processed before the screen is displayed, and Process
After Ìnput (PAÌ) event, which is processed after a user action on the screen.
Screen fields are fields in the working memory of a screen. Their contents are passed to
identically-named fields in the ABAP program in the PAÌ event, and filled from the same
identically-named fields in the program in the PBO event. The screen fields are linked
with the input/output fields on the screen and with the OK_CODE field. Ìnput and output
fields must have a unique name. This assigns them to a screen field with same name,
which allows you to work with their values in an ABAP program. Every screen has a
twenty-character OK_CODE field (also known as the function code field), which is not
displayed on the screen. User actions that trigger the PAÌ event also place the corres-
ponding function code into this field, from where it is passed to ABAP program. You can
also use the command field in the standard toolbar to enter function code. You must
assign a name to the OK_CODE field in the element list for each screen to be able to
use it for particular screen. Ìf there is a field in the ABAP program with the same name,
you can find out the function that the user chose by querying its contents in a PAÌ
module. Ìf the OK_CODE field does not have a name, the PAÌ event is still triggered, but
there is no screen field into which the function code can be passed. Note also that the
OK_CODE field is filled with the contents of the identically-named field in the ABAP
program in the PBO event. Ìn screens, system fields are administered in the structure
SYST, not SY. Therefore, you must address them using the form SYST-<name>.
Screen FIow ogic
Screen flow logic contains the procedural part of a screen. You create it in the flow logic
editor, which is very similar to the ABAP Editor. The language used to program screen
flow logic has a similar syntax to ABAP, but is not part of ABAP itself. Ìt is sometimes
referred to as screen language. Unlike ABAP programs, screen flow logic contains no
explicit data declarations. You define screen fields by placing elements on the screen
mask. The screen flow logic is like an ABAP program in that it serves as a container for
processing blocks. There are four event blocks, each of which is introduced with the
screen keyword PROCESS:
PROESS BEFORE OUTPUT.
PROESS AFTER INPUT.
PROESS ON HEP-REQUEST.
PROESS ON VAUE-REQUEST.
As in ABAP, the event block is introduced by the corresponding keyword statement, and
it concludes either when the next block is introduced, or at the end of the program. The
first two statements are created automatically by the Screen Painter when you create a
new screen. The corresponding events are triggered by the runtime environment:
· PROESS BEFORE OUTPUT (PBO) is automatically triggered after the PAÌ
processing of the previous screen and before the current screen is displayed. You
can program the PBO processing of the screen in this block. At the end of the PBO
processing, the screen is displayed.
· PROESS AFTER INPUT (PAI) is triggered when the user chooses a function on
the screen. You can program the PAÌ processing of the screen in this block. At the
end of the PAÌ processing, the system either calls the next screen or carries on
processing at the point from which the screen was called.
· PROESS ON HEP-REQUEST (POH) and PROESS ON VAUE-REQUEST
(POV) are triggered when the user requests field help (F1) or possible values help
(F4) respectively. You can program the appropriate coding in the corresponding
event blocks. At the end of processing, the system carries on processing the current
As is normal with events, you must only program event blocks for the events to which
you want the flow logic to react. However, the screen flow logic must contain at least the
two statements PROCESS BEFORE OUTPUT and PROCESS AFTER ÌNPUT in the
correct order. There are two ways of calling a screen. You can either use a transaction
code, or the CALL SCREEN statement in an ABAP program. When you call a screen,
the PROCESS BEFORE OUTPUT event (PBO) is called, and the corresponding event
block in the screen flow logic is processed. The screen itself is then displayed until the
user triggers the PROCESS AFTER ÌNPUT (PAÌ) event by choosing a function. Ìn
between, there may be field or input help processing. The corresponding event blocks in
the flow logic are processed, if they exist. Main purpose of event blocks in the screen
flow logic is to call dialog modules in the ABAP program and to provide the ABAP
program with data.
User Actions on Screens
There is a series of user actions that conclude the user's interaction with the screen in
the SAPgui and pass control back to the runtime environment on the application server,
where the PAÌ event is triggered. These are:
- hoosing a pushbutton on the screen
- SeIecting a checkbox or radio button to which a function code is assigned.
- hoosing a function in the menu, standard tooIbar, or appIication tooIbar.
- hoosing a function key on the keyboard.
- SeIecting an entry from a drop down box.
All of these actions have in common that they are linked to a function code. Function
code of a pushbutton, checkbox, radio button, or dropdown box on the screen is set in
the corresponding element attributes. The function codes in menus, the standard
toolbar, and the application toolbar are set in the GUÌ status. The function codes of
function keys are also assigned in the GUÌ status. The PAÌ event is always triggered
when the user resizes a screen containing elements for which the #esizing attribute is
active. This applies to table controls, subscreens, and custom controls.
· Processing Input/Output FieIds : The ABAP program must contain identically-
named data objects that correspond to the screen fields, otherwise data may be lost.
The ABAP data types must correspond to the screen data types. Ìf you want to use
input/output fields in one program only, you should create them in the ABAP program,
activate the program, and then copy the fields from the ABAP program to the screen. Ìf
your input/output fields are required in more than one program, and you want to use
information from the ABAP Dictionary, such as field labels, field help, and input help,
you should copy fields from the ABAP Dictionary. You can refer to both structures and
database tables. You must then declare identically-named fields as an interface work
area in the ABAP program using the TABLES statement. Declaring an identically-
named field using a TYPES reference to the data type in the ABAP Dictionary is insuffi-
cient for data to be transferred between the screen and the ABAP program. Ìt is often
worth defining your own ABAP Dictionary structure for screens, containing all of the
input/output fields you want to use for one or more screens of a program.
· Pushbuttons on the Screen : Ìn the attributes of a pushbutton, you can specify a
function code up to 20 characters long. Pushbuttons have a label - the text that you
specify statically in the attributes - and can also have icons. Ìf you set the utput field
attribute for a pushbutton, you can also set its text dynamically in the ABAP program.
To do this, you must create a field in the ABAP program with the same name as the
pushbutton. You must then assign the required text to the field before the screen is
displayed. You can also assign icons to dynamic texts on pushbuttons by including the
icon code in the text. The icon codes are all contained in the include program <ÌCON>.
For example, the ÌCON_CANCEL ( ) icon has the code @0W@. Ìn each PAÌ event,
the function code, as long as it is not empty, is placed in system field SYST-UCOMM
(SY-UCOMM) and assigned to the OK_CODE field. Very important and frequently-
used function codes should appear on the screen as well as in GUÌ status. When you
define pushbuttons, you must ensure that your function code is either the same as a
corresponding function in the GUÌ status, or does not accidentally coincide with the
function code of an entirely different function.
· heckboxes and Radio Buttons with Function odes : Ìn the Screen Painter, you
can assign a function code (up to 20 characters long) to checkboxes & radio buttons.
When a function code is assigned to a checkbox or radio button, clicking it not only
changes the field contents, but also triggers the PAÌ event and places the function code
in the OK CODE field. While it is possible to assign an individual function code to each
checkbox, you can only assign one function code to all of the radio buttons in a group.
You should ensure when you assign function codes to checkboxes and radio buttons
that they do not coincide with function codes from the GUÌ status.
· Using GUI Statuses : The function of a GUÌ status is to provide the user with a range
of functions on a screen. Each function has an associated function code, and when the
user chooses a function, PAÌ event is triggered. Ìn each PAÌ event, the function code,
as long as it is not empty, is placed in the system field SYST-UCOMM (SY-UCOMM)
and assigned to the OK_CODE field. You should always activate at least one of the
Back (F3), Exit (shift+F3), and Cancel (F12) functions, so that the user can always
leave the screen in the normal fashion. Use eave program statement to exit the
program. You can also use the Menu Painter to create area menus. An area menu is a
user interface that does not belong to an ABAP program and may therefore not trigger
any PAÌ events. Ìt may only contain function codes that call transactions or system
functions. Examples of area menus are the initial screen of the R/3 System (S000) and
the initial screen of the ABAP Workbench (S001). Reserved Function Keys are F1, F4,
F10 (places the cursor in the menu bar). Ìf the command field does not contain an entry
and no function code is assigned to the ENTER key in the Menu Painter, the function
code is empty and therefore not passed to SY-UCOMM or the OK_CODE field. But The
PAÌ event is always triggered when the user chooses ENTER. To assign a GUÌ status
in PBO event to a screen, use the ABAP statement :
SET PF-STATUS <stat> [OF PROGRAM <prog>] [EXUDING <f>|<itab>].
This statement defines the user interface for all subsequent screens of a screen sequ-
ence until another is set using a new SET PF-STATUS statement. Specify <f> to deac-
tivate function code stored in field <f>. Specify <itab> to deactivate all function codes
stored in the internal table <itab>. Field <f> and the lines of table <itab> should be of
type C, and have length 20 ( like sy-ucomm). To assign a GUÌ Title to a screen, use
the ABAP statement :
SET TITEBAR <titIe> [OF PROGRAM <prog>] [WITH <g1 >... <g9>].
· Reading Function odes : Ìn your ABAP programs, you should work with the OK_
CODE field instead of SY-UCOMM. There are two reasons for this: Firstly, the ABAP
program has full control over fields declared within it, and secondly, you should never
change the value of an ABAP system field. The OK_CODE field can have a different
name on each screen. However, common practice is to use the same name for the field
on each screen of an ABAP program. You then only need one field in ABAP program,
with the same name, into which the function code is placed. Ìn application programs,
the first step in PAÌ processing should be to save the function code in an auxiliary varia-
ble and then initialize the OK_CODE field. You can then read the function code from the
auxiliary variable and control the program flow from there.
DATA: O_ODE IE SY-UOMM,
SAVE_O IE SY-UOMM.
MODUE USER_OMMAND_100 INPUT.
SAVE_O = O_ODE.
· Finding Out the ursor Position :
GET URSOR FIED <f> [OFFSET <off>][INE <Iin>][VAUE <vaI>]
After user interaction with the screen, you may need to know the position of the cursor
when the action occurred. This is particularly important if the user chooses the Choose
function (F2 or mouse double-click). This statement transfers name of screen element
on which the cursor is positioned during a user action into the variable <f>. Ìf the
cursor is on a field, the system sets SY- SUBRC to 0, otherwise to 4. OFFSET writes
cursor position within screen element to the variable <off>. LÌNE writes line number of
the table to the variable <lin> if the cursor is positioned in a table control. Ìf the cursor is
not in a table control, <lin> is set to zero. VALUE writes the contents of the screen field
in display format, that is, with all of its formatting characters, as a string to the variable
<val>. LENGTH writes display length of the screen field to the variable <len>.
aIIing ABAP DiaIog ModuIes
The main task of the screen flow logic is to call dialog modules in an ABAP program.
You can do this using the MODULE statement . Ìn the PBO event, you can use this
statement to call any dialog module in the ABAP program that has been defined using
MODUE <mod> OUTPUT.
Ìn the PAÌ, POH, and POV events, you can use the statement to call any dialog module
in the ABAP program that has been defined using
MODUE <mod> [INPUT].
Since dialog modules in an ABAP program can be called from more than one screen,
you can program functions that you need in several screens centrally in single module.
For example, it is usual to copy the contents of the OK-code field into an auxiliary
variable and then reset the field in all PAÌ events. You could program this task in single
module. Ìf you need to distinguish between screen numbers in a dialog module, you can
use the system field SY-DYNNR, which always contains the number of current screen.
· SimpIe ModuIe aIIs : To call a module, use the flow logic statement
The system starts the module <mod>, which must have been defined for the same
event block in which the call occurs. Ìn the PAÌ event, all of the data from the screen is
transported to the ABAP program (as long as there are program fields with the same
names as the screen fields) after the automatic input checks and before the first PAÌ
module is called.
· ontroIIing the Data Transfer : Data is passed from screen fields to ABAP fields
with the same names once in each dialog step. Ìf you only use simple module calls, all
of the data is transferred in the PAÌ event before PAÌ processing starts. The FÌELD
statement in the screen flow logic allows you to control the moment at which data is
passed from screen fields to their corresponding ABAP fields.
Data is not transported from screen field <f> into the ABAP field <f> until the FÌELD
statement is processed. Ìf a field occurs in more than one FÌELD statement, its value is
passed to the program when the first of the statements is reached. Only screen fields
that do not appear in a FÌELDS statement are transferred at the beginning of the PAÌ
event. Do not use fields in PAÌ modules until they have been passed to the program
from the screen, otherwise the ABAP field will contain the same value as at the end of
the previous dialog step. The fields that were initial in PBO event & are not changed by
user are not transported by the FÌELD statement. Ìf a field of this type is filled with a
value in a PAÌ module before its corresponding FÌELD statement is executed, any
value that you assign to it is not overwritten.
· aIIing ModuIes UnconditionaIIy : Ìn the PAÌ event, the PAÌ modules are called in
the sequence in which they occur in the screen flow logic, after the automatic field
checks. This means that the input on the screen must satisfy the automatic checks
before the first module can be called. Ìn particular, all required fields must be filled, and
any checks against value lists or check tables defined for the field in ABAP Dictionary
must be successful. Ìn some cases, the user may have to enter a considerable amount
of data merely in order to be able to leave the screen. To avoid this, You can assign the
function type E to the function codes of both pushbuttons on the screen & of elements
in the GUÌ status. As a rule, type E functions should allow the user to leave the screen.
Consequently, the function codes for Back (F3), Exit (Shift + F3), and Cancel (F12)
usually have type E. When the user chooses a function with type E, the screen flow
logic jumps directly to the following statement:
MODUE <mod> AT EXIT-OMMAND.
Regardless of where it occurs in the screen flow logic, this statement is executed imm-
ediately, & before the automatic checks for the field contents on the screen. Before the
module <mod> is executed, the contents of the OK-CODE field are transported to the
ABAP field with the same name. However, no other screen fields are transported to the
program at this stage. Ìf you have more than one MODULE statement with the AT EXÌT-
COMMAND addition, only the first is executed. Ìf there are no MODULE statements with
the AT EXÌT-COMMAND statement or Ìf the module does not leave the screen, normal
PAÌ processing resumes, that is, the automatic field checks take place, and the normal
PAÌ modules are called, with data being transported from screen back to the program
according to the sequence defined in the FÌELDS statements. You should therefore
program it to contain an appropriate variant of the LEAVE statement, to leave current
screen, the call chain, or the entire program, as appropriate.
· onditionaI ModuIe aIIs : Simple module calls are processed in the sequence in
which they appear in the screen flow logic. However, the syntax of the screen language
also allows you to make PAÌ module calls dependent on certain conditions by using the
MODULE statement together with the FÌELD statement. Conditional module calls can
help you to reduce the runtime of your program, particularly with modules that comm-
unicate with database tables. You can ensure that a PAÌ module is only called when a
certain condition applies by using the following statement :
FIED <f> MODUE <mod> ON INPUT|REQUEST|*-INPUT.
The additions have the following effects:
ON INPUT : The ABAP module is called only if the field contains a value other than its
ON REQUEST: The module <mod> is only called if the user has entered something in
the field. This includes cases when the user overwrites an existing value with the same
value, or explicitly enters the initial value. Ìn general, the ON REQUEST condition is
triggered through any form of "manual input". The following additional methods of
entering values also call the module:
- The element attribute PARAMETER-ÌD (SPA/GPA parameters).
- The element attribute HOLD DATA
- CALL TRANSACTÌON ... USÌNG
- Automatic settings of particular global fields
ON *-INPUT : The ABAP module is called if the user has entered a "*" in the first
character of the field, and the field has the attribute -entry in the Screen Painter. When
the input field is passed to the program, the * is removed. * behaves like an initial field in
the ON ÌNPUT condition.
The functions of the FÌELD statement for controlling data transport also apply when you
To ensure that one or more PAÌ modules are only called when several screen fields
meet a particular condition, you must combine the calls in flow logic to form a process-
FIED: <f1>, <f 2>,...
MODUE <mod1> ON HAIN-INPUT|HAIN-REQUEST.
FIED: <g1>, <g 2>,...
MODUE <mod2> ON HAIN-INPUT|HAIN-REQUEST.
So <mod1> is called when one of the fields <fi> meets the condition. <mod2> is called
when one of the fields <fi> or <gi> meets the condition.
Within processing chain, you can combine individual FÌELD statements with a MODULE
statement to set a condition for a single field within the chain:
FIED: <f1>, <f 2>,...
FIED <f> MODUE <mod1> ON INPUT|REQUEST|*-INPUT
MODUE <mod2> ON HAIN-INPUT|HAIN-REQUEST.
The module <mod1> is called when screen field <f> meets the specified condition for
individual fields.<mod2> is called when one of the fields <fi> or <f> meets the condition.
Ìf you use the addition ON CHAÌN-ÌNPUT or ON CHAÌN-REQUEST with FÌELD <f>, the
condition also applies to the entire chain & module <mod1> & <mod2> are both called.
Ìn cases where you apply conditions to various combinations of screen fields, it is worth
setting up a separate processing chain for each combination & calling different modules
from within it. The functions of the FÌELD statement for controlling data transport also
apply when you use processing chains. Within a processing chain, screen fields are not
transported until the FÌELD statement.
You can specify that a module should only be called if the cursor is positioned on a
particular screen element. To do this, use the statement :
MODUE <mod> AT URSOR-SEETION.
The module <mod> is called whenever the function code of the user action is S with
function type S. Ìf you use this statement, it is best to assign the function code CS to
function key F2. This also assigns it to the mouse double-click. The moduIe is caIIed
in the sequence in which it occurs in the fIow Iogic. Ìt does not bypass automatic
input checks. Data is transported from screen fields in the order in which it is defined by
the FÌELD statements. The function code is empty, and neither SY-UCOMM nor the
OK_CODE field is affected. You can also combine this MODULE statement with the
FÌELD statement :
FIED <f> MODUE <mod> AT URSOR-SEETION.
or, for more than one field :
FIED: <f1>, <f 2>,...
MODUE <mod> AT URSOR-SEETION.
The module <mod> is only called if the cursor is positioned on an input/output field <f>
or an input/output field <fi> in the processing chain. You can only apply this statement
to input/output fields. The call hierarchy of the different combinations is as follows:
- Ìf a MODULE... AT CURSOR-SELECTÌON statement is executed that was combined
with FÌELD, a statement without FÌELD is not executed.
- Ìf a statement using FÌELD appears more than once for the same screen field <f>,
only the first statement is executed.
- Ìf a statement without FÌELD occurs more than once, only last statement is executed.
Note : FIED <f> MODUE <mod>.
FIED: <f1>, <f 2>,...
FIED: <g1>, <g 2>,...
These modules will be called without any condition and after field value is
transported from screen to program.
Ìt is normally necessary to check user input for validity and consistency. There are three
kinds of input checks on screens:
· Automatic Input hecks : Ìn the PAÌ event, the screen makes a series of automatic
input checks. These are carried out before any data is transferred to the ABAP
program, and before the screen flow logic is processed. Ìf the automatic input checks
find an error, a message appears in status bar of the screen, and the corresponding
fields remain ready for input. The automatic input checks run in the following order:
- Mandatory FieIds : Ìf a field is defined as a mandatory field in the Screen Painter, the
user must enter a value for it before the PAÌ processing can start.
- Input Format : The values entered in the input fields on the screen must correspond
to the data format of the corresponding screen field. For example, the format of a date
field (type DATS) is eight characters and has the format YYYYMMDD. All of the
characters must be numeric. MM must be 12 or less, and DD must be 31 or less. The
system also checks that the specified day is valid for the month.
- ABAP Dictionary hecks : Ìf you create an input field in the Screen Painter by
copying a ABAP Dictionary field, the screen checks whether the value satisfies any
foreign key relationship to another database table or that the value is one of the fixed
values of the domain of the fields. This is only checked if the Foreign key attribute is
set in the Screen Painter for the input field.
· Input check in the Screen FIow ogic : There are two special variants of the
FÌELD statement that you can use in PAÌ processing to check the values of screen
fields. However, this method is obsolete and should no longer be used. Ìt is only
supported for compatibility reasons.
- hecking a VaIue ist : You can check a screen field against a value list as follows:
FIED <f> VAUES (<v1>, <v2>,...).
The individual entries <vi> in the list can have the following format :
[NOT] BETWEEN <val1> AND <val2>
Ex : FÌELD carrier VALUES (NOT 'AA', 'LH', BETWEEN 'QF' AND 'UA').
Ìf the check fails, an error message is displayed and the corresponding field is again
ready for entry.
- hecking Against Database TabIes : You can check a screen field against the
contents of a database table as follows:
FIED <f> SEET *
WHERE <k1> = <f1> AND <k2> = <f2> AND...
WHENEVER [NOT] FOUND SEND ERRORMESSAGE|WARNING
[<num> [WITH <h1>... <h4>]].
This combines the FÌELD statement with a SELECT statement. The syntax of the
SELECT statement must be entered exactly as shown above. Ìn the WHERE condition,
no comparison operators other than the equals sign (=) are allowed, not even EQ. Ìn
the WHERE condition, the fields of the primary key <ki> of the database table <dbtab>
are checked against the screen fields <fi>. Ìf a matching entry is found, you can write it
into the table work area of a screen field, which was defined by transfer from the ABAP
Dictionary. You can also send an error or warning message depending on the outcome
of the search, which makes the input field for <f> ready for input again.
<num> allows you to specify a message number from the message class specified in
the MESSAGE-ÌD of the first statement in the program.
Ex : FÌELD connect SELECT *
WHERE carrid = carrier AND connid = connect
WHENEVER NOT FOUND SEND ERRORMESSAGE 107
WÌTH carrier connect.
· Input hecks in DiaIog ModuIes : You can't perform input checks in PAÌ modules of
programs until you have transported the contents of the input fields to the ABAP
program. You can then use logical expressions to check the values that the user
entered. You should then allow the user to correct any wrong entries before calling
further modules by sending warning (type W) or error (type E) messages from PAÌ
modules that are called in conjunction with the ABAP statements FÌELD and CHAÌN.
- hecking SingIe FieIds :
FIED <f> MODUE <mod>.
Ìf you send a warning or error message from a module <mod> that you called using a
FÌELD statement the corresponding input field on the current screen is made ready for
input again, allowing the user to enter a new value. Ìf the field is only checked once,
the PAÌ processing continues directly after the FÌELD statement, and the preceding
modules are not called again.
- hecking a Set of FieIds :
FIED: <f1>, <f 2>,...
FIED: <g1>, <g 2>,...
Ìf you send a warning or error message from a module <mod> that you called using a
FÌELD statement, all of the fields on the screen that belong to the processing chain (all
of the fields listed in the field statements) are made ready for input again. Other fields
are not ready for input. Whenever the MODULE statement appears within a
processing chain, even if there is only one FÌELD attached to it, all of the fields in the
chain (not only the affected field) are made ready for input again, allowing the user to
enter new values. Ìf the fields in the processing chain are only checked once, the PAÌ
processing continues directly after the FÌELD statement, and the preceding modules
are not called again.
- hecking FieIds RepeatedIy : Ìf you use the FÌELD statement outside a chain, only a
single field is made ready for input when a warning or error message is displayed. Ìf
you use it between the CHAÌN and ENDCHAÌN statements, it controls a set of fields.
All of the fields controlled by a FÌELD statement are transported back to the screen,
bypassing PBO processing. This means that any changes made to the field contents
before the message become visible on the screen. You may sometimes need to
include the same field in more than one FÌELD or CHAÌN statement. Ìf one of the
corresponding modules sends a warning or error message, PAÌ processing resumes
with the value that the user corrected. However, in this case, processing cannot simply
resume at the corresponding FÌELD or CHAÌN statement if the field in question has
already been included in an earlier FÌELD or CHAÌN statement. Ìnstead, all of the
FÌELD and CHAÌN statements containing a field in which an error occurred are
repeated. PAÌ processing resumes at the first FÌELD or CHAÌN statement containing a
field in which an error occurred and that the user changed the last time the screen was
All of the functions of the FÌELD and CHAÌN statements for controlling data transport
and conditional module calls can also be used in combination with warning and error
messages. The contents of each field are transported at the FÌELD statement in which
the field occurs. Ìf a warning or error message occurs in a conditional module of a
processing chain, all of the fields in that chain will be ready for input when the screen is
redisplayed, although not all of the fields will have been transported.
FieId HeIp (F1 HeIp)
There are three ways of displaying field help for screen elements :
· Data EIement Documentation : Ìf you place a field on the screen in the Screen
Painter by copying a ABAP Dictionary field, the corresponding data element
documentation from the ABAP Dictionary is automatically displayed when the user
chooses field help (as long as the help has not been overridden in the screen flow
· Data EIement SuppIement Documentation : Ìf the data element documentation is
insufficient, you can expand it by writing a data element supplement. Data element
supplement documentation contains the heading efinition, as well as the following
To create data element supplement documentation for a screen, choose oto ->
ocumentation -> supplement doc. from the element list of the screen. A dialog box
appears in which the system proposes a number as the identified for the data element
supplement. You can then enter help texts for the above headings using the SAPscript
editor. Data element supplement documentation created in this way is program- and
screen-specific. Any data element supplement documentation created in the ABAP
Dictionary with the same number is overridden by the screen-specific documentation.
You can link existing data element supplement documentation created in the ABAP
Dictionary with a screen field by using the table THLPF. To do this, crate a new row in
THLPF containing the following data: Program name, screen name, field name, and
number of the data element supplement documentation.
To display data element supplement documentation, you must code the following
screen flow logic in the POH event:
PROESS ON HEP-REQUEST.
FIED <f> [MODUE <mod>] WITH <num>.
if there is screen-specific data element supplement documentation for the field <f>,
you can display it by specifying its number <num>. The number <num> can be a literal
or a variable. The variable must be declared and filled in the corresponding ABAP
program. You can fill the variables, for example, by calling the module <mod> before
the help is displayed. However, the FÌELD statement does not transport the contents
of the screen field <f> to the ABAP program in the PROCESS ON HELP-REQUEST
· aIIing HeIp Texts from DiaIog ModuIes : Ìf data element supplement
documentation is insufficient for your requirements, or you want to display help for
program fields that you have not copied from the ABAP Dictionary, you can call dialog
modules in the POH event:
PROESS ON HEP-REQUEST.
FIED <f> MODUE <mod>.
When the user chooses F1 for a field <f>, the system calls the module <mod>
belonging to the FÌELD <f> statement.
Ìnstead of calling an extra screen with text fields, you should use one of the following
function modules to display a suitable SAPscript document:
- HEP_OBJET_SHOW_FOR_FIED : This function module displays the data
element documentation for components of any structure or database table from the
ABAP Dictionary. You pass the name of the component and structure or table to the
import parameters FÌELD and TABLE.
- HEP_OBJET_SHOW : Use this function module to display any SAPscript
document. You must pass the document class (for example, TX for general texts, DE
for data element documentation) and the name of the document to the import
parameters DOKCLASS and DOKNAME. For technical reasons, you must also pass
an empty internal table with the line type TLÌNE to the tables parameter of the function
One of the important features of screens is that they can provide users with lists of
possible entries for a field. There are three techniques that you can use to create and
display input help:
· Input HeIp from the ABAP Dictionary : When you create screen fields with reference
to ABAP Dictionary fields, the corresponding search helps are then automatically
available. Ìf a field has no search help, the ABAP Dictionary still offers the contents of
a check table, the fixed values of the underlying domain, or static calendar or clock
help. The following list shows, in ascending order of priority, the input help that is used:
- Calendar and clock help
- Domain fixed values
- Search help of the data element
- Check table
- Check table with text table
- Check table with search help
- Search help for a field
· Input HeIp on the Screen : Search helps from the ABAP Dictionary can be attached
to a screen field. To do this, enter the name of the search help in the corresponding
field in the attributes of the screen field in the Screen Painter. This assigns the first
parameter of the search help to the screen field. Ìt is only possible to place a value
from the hit list onto the screen.
· Input HeIp in DiaIog ModuIes :
PROESS ON VAUE-REQUEST.
FIED <f> MODUE <mod>.
After the PROCESS ON VALUE-REQUEST statement, you can only use the MODULE
statement together with the FÌELD statement. When the user chooses F4 for a field
<f>, the system calls the module <mod> belonging to the FÌELD <f> statement. The
contents of the screen field <f> are not available, since it is not transported by the
FÌELD statement. However, this procedure is only recommended if it really is not
possible to use a search help. Despite the introduction of search helps (and search
help exits), there are still cases in which you need to use parts of the standard F4
functions directly. Ìn this case, there are some standard function modules that you can
use in the POV event. They support search helps, as well as all other kinds of input
help, and are responsible for data transport between the screen and the input help.
These all have the prefix F4ÌF_. The most important are:
- F4IF_FIED_VAUE_REQUEST : Calls the input help of the ABAP Dictionary
dynamically. You can pass the component names of a structure or database table of
the ABAP Dictionary to the function module in the import parameters TABNAME and
FÌELDNAME. The function module starts the ABAP Dictionary input help for this
component. All of the relevant screen fields are read. Ìf you specify the import
parameters DYNPPROG, DYNPNR, and DYNPROFÌELD, the user's selection is
returned to the corresponding field on the screen. Ìf you specify the table parameter
RETURN_TAB, the selection is returned into the table instead.
- F4ÌF_ÌNT_TABLE_VALUE_REQUEST : This function module displays a value
list that you created in an ABAP program. The value list is passed to the function
module as the table parameter VALUE_TAB. Ìf you specify the import parameters
DYNPPROG, DYNPNR, and DYNPROFÌELD, the user's selection is returned to the
corresponding field on the screen. Ìf you specify the table parameter RETURN_TAB,
the selection is returned into the table instead.
There are also two function modules - DYNP_VAUES_READ and
DYNP_VAUES_UPDATE - that can read the values of screen fields and return
values to them during the POV event.
DiaIog ModuIes (SE35)
Ìt is a standardized user interface in the R/3 System to enter both single values and
complex selections.Used purely for data input.You define selection screens using
ABAP statements in a program.System automatically assumes the tasks of the Screen
Painter and Menu Painter. You can use a single standard seIection screen and
many user-defined seIection screens in report program.The standard selection
screen always has the screen number 1000 & is called automatically when you start
the Program by parameters or select-options statements. User-defined selection
screens can have any screen number except 1000. You can only use user-defined
selection screens in module pools and function modules. Ìnput parameters are
primarily used to control the program flow, while users can enter selection criteria to
restrict the amount of data read from the database.
· Basic form :
PARAMETERS <p>[(<Iength>)] [TYPE <type>|IE <obj>] [DEIMAS <d>].
Variables declared with the PARAMETERS statement are called parameters.
Parameter names are limited to eight digits.The data types valid for parameters
include all elementary ABAP types except data type F. You cannot use data type F,
references and aggregate types. Parameters can only refer to fields of database
tables, views and structures. The parameter adopts the attributes of the Dictionary
type, that is, technical properties and help texts(F1 & F4).
· Dynamic Dictionary Reference :
PARAMETERS <p> IE (<name>) .
At the time the selection screen is called, field <name> must contain the name from a
data type of the ABAP Dictionary. The field label from the Dictionary appears as the
description on the selection screen. Otherwise, the selection text is displayed.
· DefauIt VaIues for Parameters :
PARAMETERS <p> ...... DEFAUT <f> ......
Default value <f> can be either a literal or a field name.
· SPA/GPA Parameters as DefauIt VaIues :
PARAMETERS <p> ...... MEMORY ID <pid>......
The current value of SPA/GPA parameter <pid> from the global user-related SAP
memory is assigned to parameter <p> as a default value.
· AIIowing Parameters to Accept Upper and ower ase :
PARAMETERS <p> ...... OWER ASE ......
Ìf you use the TYPE addition to refer to data types from the ABAP Dictionary, the
parameter adopts all attributes of the Dictionary field. These attributes cannot be
changed, and you cannot use the LOWER CASE addition.
· Reducing the VisibIe ength :
PARAMETERS <p> ... VISIBE ENGTH <Ien> ...
You can define visible length of a parameter as smaller than its actual length.
· Defining Required FieIds :
PARAMETERS <p> ...... OBIGATORY ......
A question mark appears in the input field for parameter <p>.The user cannot continue
with the program without entering a value in this field.
· Search HeIps for Parameters :
PARAMETERS <p> ... MATHODE OBJET <search_heIp>.
The search help <search_help> must be defined in the ABAP Dictionary. The system
now automatically displays the input help button for the field on the screen and
activates the F4 key for it.
· hecking Input VaIues :
PARAMETERS <p> TYPE <type> ... VAUE HE ...
Ìf a check table or a list of fixed values is defined in the ABAP Dictionary for the
relevant type, the user can only enter these valid values. you should use the VALUE
CHECK addition only for required fields(obligatory).
· Defining heckboxes :
PARAMETERS <p> ...... AS HEBOX ......
Parameter <p> is created with type C and length 1. Valid values for <p> are ' ' and 'X'.
Ìf you use the TYPE addition to refer to a dictionary type of type CHAR and length 1
for which 'X' and ' ' are defined as valid values in the domain,the parameter
automatically appears as a checkbox on the selection screen.
· Defining Radio Buttons :
PARAMETERS <p> ...... RADIOBUTTON GROUP <radi>......
Parameter <p> is created with type C and length 1, and is assigned to group <radi>
(max length 4). Only one parameter per group can have a DEFAULT value 'X'. Ìf you
don't use the DEFAULT addition, the first parameter of each group is set to 'X'.
· Hiding Input FieIds :
PARAMETERS <p> ...... NO-DISPAY ......
Ìf the parameter belongs to the standard selection screen, you can assign a value to it
either by using the DEFAULT addition when you declare it, or during ÌNÌTÌALÌZATÌON
event. When you use user-defined selection screens, you can assign a value to the
parameter at any time before calling the selection screen. Ìf you want to display a
parameter having NO-DÌSPLAY addition only in certain cases, you cannot make it
visible using the MODÌFY SCREEN statement.Ìnstead declare it without the NO-
DÌSPLAY addition and suppress its display using the MODÌFY SCREEN statement.
· Modifying Input FieIds :
PARAMETERS <p> ...... MODIF ID <key> ......
The MODÌF ÌD addition always assigns <key> to the SREEN-GROUP1 column of
internal table SCREEN. Parameters assigned to a modification group can be
processed as an entire group with the OOP AT SREEN and MODIFY SREEN
statements during the AT SELECTÌON-SCREEN OUTPUT event.<key> should have
maximum length 3.
· SEETION TABES :
SEET-OPTIONS <seItab> for <f>.
ABAP contains selection criteria. These selection criteria allow the user to handle
complex selections.Ìnstead of writing lengthy Logical expressions,you can use special
internal tables, called selection tables. SELECT-OPTÌONS Statement are used to
create selection tables. A selection table is an internal table object of the standard
table type that has a standard key and a header line.You use the SELECT-OPTÌONS
statement to declare selection tables and create corresponding input fields on the
associated selection screen. When the selection screen is processed, the values
entered by the user into the input fields are assigned to the header line of the selection
table and appended to the table.<f> is a locally declared field. You can use all
elementary data types except F. You cannot use references and aggregate types. You
can process the selection table like any other internal table in the program. The row
type of a selection table consists of four component (sign,option,low,high):
SÌGN - data type C with length 1. Possible values are Ì (inclusive),E(exclusive).
OPTÌON - data type C with length 2. Ìf HÌGH is empty, you can use EQ, NE,GT, LE,
LT,CP, and NP.For operators CP and NP,wildcard characters *,+ &
escape character # can be used. Ìf HÌGH is filled, you can use BT and NB.
OW & HIGH -have the same technical attributes as <f> & help texts (F1 & F4).
· Ranges tabIes :
TYPES|DATA <rangetab> TYPE RANGE OF <type>.
TYPES|DATA <rangetab> IE RANGE OF <obj>.
Ìt create internal tables of the same type as selection tables without header line.You
can refer ranges table type from DDÌC. You can also use RANGES statement to create
internal tables of same type as selection tables with header line.
RANGES <rangetab> FOR <f>.
<type>,<obj>,<f> can be locally or globally defined.
- are not part of selection screen like selection table.No input fields generated.
- Cannot be used as a data interface in submit statement.
- Cannot be used in logical databases.
· DefauIt VaIues :
SEET-OPTIONS <seItab> FOR <f> DEFAUT <g> [to <h>] [OPTION <op>]
'EQ' is default for option & 'Ì' is default for sign.
· Restricting Entry :
SEET-OPTIONS <seItab> FOR <f> ..... NO-EXTENSION
NO ÌNTERVALS allow the user to process only single fields on the selection Screen.
NO-EXTENSÌON allow the user to process only the first row of the selection table on
the selection screen.
· AdditionaI Options : Following options have the same syntax and the same
function as for the PARAMETERS statement.
SEET-OPTIONS <seItab> FOR <f> ... MEMORY ID <pid>..........
SEET-OPTIONS <seItab> FOR <f> ... OWER ASE..............
SEET-OPTIONS <seItab> FOR <f> ... OBIGATORY ..............
SEET-OPTIONS <seItab> FOR <f> ... NO DISPAY ..............
SEET-OPTIONS <seItab> FOR <f> ... MODIF ID <key>...........
SEET-OPTIONS <seItab> FOR <f> ... MATHODE OBJET...........
· Note : You can use selection table in where clause of SELECT, UPDATE,DELETE
statements of OPEN SQL and also in logical expressions such as ÌF ,CHECK and
WHÌLE. Ìf selection table is empty, system will select all records from table if we
mention selection table in where clause of select statement.
Defining SeIection Screens
There are three ABAP statements for defining selection screens:
PARAMETERS for single fields
SELECT-OPTÌONS for complex selections
SELECTÌON-SCREEN for formatting the selection screen and defining user specific
All three statements must be included in following statements for user defined Screens.
SEETION-SREEN BEGIN OF SREEN <numb> [TITE <titIe>]
SEETION-SREEN END OF SREEN <numb>.
Screen number <numb> can be any four-digit number apart from 1000. <Title> can
either be a static text symbol or a dynamic character field. Ìf you use a character field,
you must not define it using DATA statement.The system generates it automatically.
The character field can be filled during the ÌNÌTÌALÌZATÌON event. AS WÌNDOW
addition is used to call a user-defined selection screen as a modal dialog Box,
warnings and error messages also displayed as modal dialog boxes.You can reuse
elements of one selection screen in another using the statement:
SEETION-SREEN INUDE: BOS <bIock>, PARAMETERS <p>,
SEET-OPTIONS <seIcrit>, OMMENT <comm>,
· GUI Status of SeIection Screens : Ìf you want to use your own GUÌ status for a
selection screen or deactivate functions in the standard GUÌ status, you can use one
of the following function modules in the PBO event of selection screen:
RS_SET_SESREEN_STATUS : Sets another GUÌ status defined in the same
ABAP program, or deactivates functions of the standard GUÌ status.
RS_EXTERNA_SESREEN_STATUS : Sets a GUÌ status defined in external
function group. You must use SET PF-STATUS statement to set status in a special
function module in this function group.You must pass name of function module that
sets the status as a parameter to RS_EXTERNAL_SELSCREEN_STATUS.
To find out the function codes of the standard GUÌ status, choose $ystem ->$tatus
and double-click the &I status field. Ìnternal table must have a line type of sy-
ucomm. p_status should be equal to sy-pfkey which contains the name of current
Formatting SeIection Screens
· BIank ines :
SEETION-SREEN SIP [<n>].
This statement generates <n> blank lines where <n> can have a value between 1 and
9.To produce a single blank line, you can omit <n>.
· UnderIines :
SEETION-SREEN UINE [[/]<pos(Ien)>] [MODIF ID <key>].
This statement generates an underline. For <pos>, you can specify a number or either
one of the expressions POS_LOW and POS_HÌGH.
· omments :
SEETION-SREEN OMMENT [/]<pos(Ien)> <comm> [FOR FIED <f>][MODIF
ID <key>] [VISIBE ENGTH <vIen>].
This statement writes the <comm> comment on the selection screen. For <comm>,
you can specify a text symbol or a field name with a maximum length of eight
characters. This character field must not be declared with the DATA statement, but is
generated automatically with length <len>. The field must be filled before the selection
screen is called. You must always specify <pos(len)> addition. You use FOR FÌELD
<f> to assign a field label to the comment. <f> can be name of a parameter or a
select-option. Ìf you use FOR FÌELD addition, you can omit <COMM>.Comment is
displayed in shortened length< vlen>.
· SeveraI EIements in a SingIe ine :
SEETION-SREEN BEGIN OF INE.
SEETION-SREEN END OF INE.
To position a set of parameters or comments in a single line. Selection text is not
displayed when you use this option.So you must use the COMMENT.You must not use
a slash (/). you can omit <pos> between the statements specified above. The element
is placed at the current position in the line.To determine position of an element in a
line, you use:
SEETION-SREEN POSITION <pos>.
For <pos>, you can specify a number or either one of the expressions POS_LOW and
POS_HÌGH.Use POSÌTÌON addition only between BEGÌN OF LÌNE and END OF LÌNE.
· BIocks of EIements :
SEETION-SREEN BEGIN OF BO <bIock>
[WITH FRAME [TITE <titIe>]] [NO INTERVAS].
SEETION-SREEN END OF BO <bIock>.
You can nest up to five different blocks with frames. Ìf you use NO ÌNTERVALS
addition, nested blocks automatically adopt the NO ÌNTERVALS addition. <title>
can be text symbol or character field without DATA statement.
aIIing SeIection Screens
· aIIing Standard SeIection Screens : The standard selection screen of an
executable program consists of :
- Selections of a logical database that may be linked to the program.
- All selection screen elements from the declaration part of a program that are not
assigned to a user-defined selection screen.
As long as at least one input field is defined for the standard selection screen, it is
called fully automatically between the ÌNÌTÌALÌZATÌON and START-OF-SELECTÌON
· aIIing User-Defined SeIection Screens :
- aII From a Program :
A SEETION-SREEN <numb> [STARTING AT <x
[ENDING AT <x
You can call standard(report program only ) or user-defined selection screens from
any program in which they are defined. You must always use CALL SELECTÌON-
SCREEN to call selection screens, and not CALL SCREEN.Use AS WÌNDOW addition
in the definition of the selection screen to display warnings & error messages in modal
dialog box.CALL SELECTÌON-SCREEN statement sets SY-SUBRC EQ 0 if chosen
ecute & 4 if chosen Cancel. System field SY-DYNNR of the associated event
blocks contains the number of the selection screen that is currently active.
- aII as a Transaction : When the program is started using the transaction
code (SE93), the mentioned selection screen and not the standard selection screen
is called between the ÌNÌTÌALÌZATÌON and the START-OF-SELECTÌON event.
User Actions on SeIection Screens
When you select a pushbutton,checkbox or radiobutton, the runtime analysis triggers
the AT SELECTÌON-SCREEN event and places the function code <ucom> into
component UCOMM of the interface work area SSCRFÌELDS.You must use TABLES
statement to declare the SSCRFÌELDS structure.After the AT SELECTÌON-SCREEN
event has been processed, system displays the selection screen again. The only way
to exit the selection screen and carry on processing the program is to choose ecute
(F8). For <ucom>, you must specify a function code of up to four characters.
· Pushbuttons on the SeIection Screen :
SEETION SREEN PUSHBUTTON [/]<pos(Ien)> <push>
USER-OMMAND <ucom> [MODIF ID <key>].
The above syntax is used to create a pushbutton on the selection screen. <push>
determines the pushbutton text as text symbol or character field without DATA
· heckboxes and Radio Buttons with Function odes :
PARAMETERS ... AS HEBOX | RADIOBUTTON GROUP ...
You can assign a function code <ucom> to an individual checkbox & first button in the
radiobutton group.checkboxes and radio buttons with function codes are more suitable
for controlling dynamic modifications on a selection screen than for controlling the
· Pushbuttons in the AppIication TooIbar :Ìn the application toolbar of the
standard GUÌ status of the selection screen, five pushbuttons are predefined with the
function codes FC01 to FC05, but are inactive by default. You can activate them during
the definition of the selection screen as follows:
SEETION-SREEN FUNTION EY <i>.
The numbering <i> must be between 1 and 5. The individual function texts must be
assigned to the FUNCTXT_0<i> components of structure SSCRFÌELDS before the
selection screen is called.The pushbuttons on the application toolbar are more suitable
for controlling dynamic modifications of the selection screen than for controlling the
· hanging the Standard GUI Status : The GUÌ status of a selection screen
is generated by the system. The SET PF-STATUS statement in the PBO event of the
selection screen has no effect on the standard GUÌ status. Ìf you want to use your own
GUÌ status for a selection screen or deactivate functions in the standard GUÌ status in
exceptional cases, you can use one of the following function modules in the PBO event
of the selection screen:
SeIection Screen Processing (Events)
To allow programmers to modify the selection screen before it is called (PBO) and
react to user actions on the selection screen (PAÌ), the ABAP runtime environment
generates a number of special selection screen events before the selection screen is
displayed and after the user has executed actions on the selection screen. The SY-
DYNNR system field contains the number of the active selection screen with length of
· INITIAIZATION : This event occurs before standard selection screen is called.
You can use it to initialize the input fields of the standard selection screen.Used to
change default values of parameters or selection criteria defined in logical databases.
Never used to display list.
· AT SEETION-SREEN OUTPUT : This PBO event allows you to modify
the selection screen directly before it is displayed. LOOP AT SCREEN ..ENDLOOP
must be processed in this event using SCREEN table.
· AT SEETION-SREEN ON <fieId> : This is one of the PAÌ event of the
selection screen which is triggered when the contents of each individual input field are
passed from the selection screen to the ABAP program. The input field <field> can be
checked in the corresponding event block. Ìf an error message occurs within this event
block, the corresponding field is made ready for input again on the selection screen.
· AT SEETION-SREEN ON BO <bIock> : This is one of the PAÌ
event of selection screen which is triggered when contents of all of fields in a block are
passed from selection screen to ABAP program. Ìf an error message occurs within this
event block, the fields in the block are made ready for input again on selection screen.
· AT SEETION-SREEN ON RADIOBUTTON GROUP <radi> :This event
block allows you to check the whole group. Ìf an error message occurs within this event
block, the radio button group is made ready for input again on the selection screen.
The individual fields of radio button groups do not trigger the event AT SELECTÌON-
SCREEN ON <field>.
· AT SEETION-SREEN ON <seItab> OR
AT SEETION-SREEN ON END OF <seItab>
The first event is triggered for the current line of the selection table. Ìt can then be
processed like a AT SELECTÌON-SCREEN ON <field>. The second event block allows
you to check the whole selection table <seltab>. Warning messages are displayed as
dialog boxes, not in the status line. Ìn the Multiple selections dialog box, user actions
either lead to input help or trigger the PAÌ event of the dialog box.
· AT SEETION-SREEN ON HEP-REQUEST FOR <fieId> : This event
is triggered when the user calls the F1 help for the field <field>. Ìf no Corresponding
event block has been defined, the help from the ABAP Dictionary is displayed, or none
at all if the field has no Dictionary reference. Ìf a corresponding event block exists, it
takes precedence over the default help mechanism.You cannot declare the event block
AT SELECTÌON-SCREEN ON HELP-REQUEST for input fields on selection screen
that are declared within a logical database.
· AT SEETION-SREEN ON VAUE-REQUEST FOR <fieId> : Similar to
above event except That this event is triggered when the user calls the F4 help for the
Field <field>. This event cann't be defined for input fields on the selection screen that
are declared within a logical database.
· AT SEETION-SREEN : This event is triggered in the PAÌ of the selection
screen once the ABAP runtime environment has passed all of the input data from the
selection screen to the ABAP program. Ìf an error message occurs in this processing
block, the selection screen is redisplayed with all of its fields ready for input. This
allows you to check input values for consistency.
· START-OF-SEETION : After the AT SELECTÌON-SCREEN event has been
processed, the system displays the selection screen again. The only way to exit the
selection screen and carry on processing the program is to choose ecute (F8). Only
if the AT SELECTÌON-SCREEN event is exited properly, that is not through an error
message, the other events of the executable program are triggered, starting with
START-OF-SELECTÌON. This event is Triggered after initialization if there is no
PURPOSE : Retrieve / display / formatting output data or list.
· END-OF-SEETION : This event is triggered
÷ At the end after displaying the list. After start-of-selection is processed.
÷ Can be triggered using the 'STOP' statement.
PURPOSE : To display summary for the reports generated.
· NOTE : User actions on the selection screen result in other events that are either
used for field or possible entries help, or that trigger PAÌ processing of another
selection screen.Order of events need not be in execution order.
Messages on Selection Screens
Ìn ABAP programs, this corresponds to the AT SELECTÌON-SCREEN processing
blocks, except those with the OUTPUT addition.
Type DispIay Processing
A DiaIog box Program terminates & control returns to last area menu
I DiaIog box Program continues processing after MESSAGE statement
S Status bar Program continues processing after MESSAGE statement
of next screen
X None Triggers a runtime error with short dump
W Status bar Like type E, but the user can confirm the message by
pressing ENTER without having to enter new values.
System resumes selection screen processing directly after
MESSAGE statement. You cannot use warning messages
with the ON HELP-REQUEST or ON VALUE- REQUEST
additions. Ìnstead, a runtime error occurs.
E Status bar Selection screen processing terminates, and the selection
screen is redisplayed.Screen fields specified through the additions to AT
SELECTÌON-SCREEN statement are ready for input.The user must enter
a new value.The system then restarts the selection screen processing
using new values.You can't use error messages with ON HELP-REQUEST
or ON VALUE-REQUEST additions.Ìnstead, a runtime error occurs.
· A report is an executable program, that extracts the data & presents the information
onto the output device like the screen or the printer.
· Execution of report programs are controlled by events.
· Events are blocks of statements executed in response to an action.
· Reports are basically of two types:
IassicaI Reports :- Used to generate information in a single list (basic list / report ).
Interactive Reports :- Used to display information in the form of multiple lists. Here a
user can interact with the list to generate further lists. Ìnstead of one extensive &
detailed list, with interactive reporting you create a condensed basic list from which
the user can call detailed information by positioning the cursor and entering
commands. Ìnteractive reporting thus reduces information retrieval to the data
actually required. Detailed information is presented in detail lists.
· Ìn an interactive report we can have :-
÷ One Basic list.
÷ Up to 20 secondary list.
÷ Every list is assigned an index.
÷ Basic list index 0.
÷ Secondary list index 1 to 20.
· Classical report contains only basic list.
· When the system processes event blocks that are not assigned to interactive list
events, and when processing dialog modules, the ABAP program writes its list output
to the basic list.
· While the basic list is being created, SY-SIND is zero.
· Ìn executable programs, the basic list is automatically sent to the list processor and
displayed at the end of the END-OF-SEETION event.
· By default, the basic list has a standard list status and a standard page header.
· Basic list is also displayed after the PAÌ processing block on the screen from which
the EAVE TO IST-PROESSING statement occurred.
· For background processing ,only classical reporting is used.
· The ABAP statements that create lists actually create the list on the application
server, where it is buffered. Ìn executable programs, the list that you create is
displayed after the last event block in the program. When the list is displayed, the
system calls the list processor, which displays the list on a special container screen
(number 120). The container screen temporarily replaces the previous screen
(standard selection screen, 1000, for executable program) of the calling program.
Ìnteractive user actions on a list trigger events in the ABAP program. Detail lists
temporarily replace the previous list on the container screen. From a dialog screen,
you can call the list processor and display up to twenty lists in a list system using the
LEAVE TO LÌST-PROCESSÌNG statement. You can create the lists using ABAP
statements WRÌTE, ULÌNE and SKÌP.
· The standard page header consists at least two-line, first line contains list header
and page number, second line contains horizontal line. System field SY-TITE stores
list heading. Column heading and List heading is not scrolled vertically. Column
heading only scroll horizontally,not list heading.
· The standard list consists of one single page of dynamic length (internal limit: 60,000
lines) with vertical scroll if required. The output length is determined by the current
· The standard list is at least as wide as the standard window with horizontal scroll if
· To print the list , choose List -> !rint. The printed standard page header additionally
contains the current date.
· To save the list, choose List -> $ave.
· You can also modify list & column headers while displaying the list on the screen. To
do so, choose $ystem -> List -> List header. Save your changes. The system stores
the modified headers as text elements of the program in the text pool of the current
· SeIf-defined Page Header :
The system processes the statements in TOP-OF-PAGE event before outputting the
first line on a new page.
REPORT <rep> NO STANDARD PAGE HEADING.
When you use this statement, the system does not display a standard page header (list
& column headings). When you scroll vertically, the self-defined page header remains
visible like the standard page header.
· SeIf-defined ist Width :
REPORT <rep> INE-SIZE <width>.
This statement determines the width of the output list of program <rep> as <width>
characters. Ìf you set <width> to zero, the system uses the width of the standard list. A
line can be up to 255 characters long.But most printers cannot print lists wider than 132
characters. The system field SY-INSZ contains the current line width.
· SeIf-defined Page ength :
REPORT <rep> INE-OUNT <Iength>[(<n>)].
This statement determines the page length of the output list of program <rep> as
<length> lines. Ìf you specify the optional number <n>, the system reserves <n> lines of
the page length for the page footer. Ìf you set <length> to zero, the system uses the
standard page length. The system field SY-INT contains the current number of lines
per page. So for the list itself you can use only <length> minus page header length
minus <n> lines.
· reating BIank ines : Ìf the number of lines remaining on the current page is too
small, the SKÌP statement produces a page break, displaying the page footer if any.
Ìn the default setting, the system does not output any blank lines created using the
WRÌTE statement (write ' '.) not by skip statement.use
SET BAN INES ON|OFF
(ON) to output blank lines created by WRÌTE statements. To reset the default setting,
use the OFF option.
· Defining a Page Footer :
This event occurs if, while processing a list page, the system reaches the lines
reserved for the page footer.Reserve lines for the footer in the LÌNE-COUNT option of
the REPORT statement.
NOTE : Each new page has its own line counter. For ex, Ìf self defined page has line-
count as 35. So second page's first line number is not 36 but 1.
Lists with Several Pages
· Automatic page break : Ìf during list processing the system reaches the end of the
area provided for the actual list, it outputs the page footer, if any, and starts a new page.
The SY-PAGNO system field always contains the current page number.
· UnconditionaI Page Break :
This statement ends the current page, does not trigger the END-OF-PAGE event. All
other output appears on a new page.Only starts a new page if output is written to the
current page as well as to the new page after NEW-PAGE as System don't produce
empty pages. The system then increases the SY-PAGNO system field by one.
· onditionaI Page Break :
RESERVE <n> INES.
This statement triggers a page break if less than <n> free lines are left on the current list
page between the last output and the page footer. <n> can be a variable. Before starting
a new page, the system processes the END-OF-PAGE event. The RESERVE statem-
ent thus defines a block of lines that must be output as a whole.
· Standard Page Headers of IndividuaI Pages :
NEW-PAGE [NO-TITE|WITH-TITE] [NO-HEADING|WITH-HEADING].
You can switch the standard list or column heading for all subsequent pages on or off
using the TÌTLE or HEADÌNG additions respectively.
· Page Iength & width of individuaI pages :
NEW-PAGE INE-OUNT <Iength> INE-SIZE <width>.
This statement determines page length & width of the subsequent pages as <length>
& <width>. <length> & <width> can be a variable. Ìf you set <length> & <width> to zero,
the system uses the standard page length & width. To adapt the page length & width
to the current window length & width , set <length> & <width > to SY-SROWS & SY-
SOS. The SY-SROWS & SY-SCOLS system field contains the number of lines &
characters of the current window.
Note: Ìf you want variable line size and line count, use new page statement and also
mention line count with footer length in report statement. Also use AT FÌRST ---
ENDAT in LOOP ------ ENDLOOP. So that all the pages can have the variable
Scrolling in Lists
From within the program, you can scroll through lists vertically and horizontally. Use the
SCROLL keyword. SY-SUBRC is 0 if the system successfully scrolled, and 4 if scrolling
was not possible, because it would exceed the list boundaries.
· VerticaI ScroIIing :
SRO IST FORWARD|BAWARD [INDEX <idx>].
To scroll through a list vertically by the size of current window & independent of the
page length.Without ÌNDEX, the statement scrolls forward or backward by one whole
Window. Ìf you use ÌNDEX <idx> addition, system scrolls in the list with the level <idx>.
Note that the actual list is scrolled by SY-SROWS minus the number of header lines.
SRO IST TO FIRST PAGE | AST PAGE | PAGE <pag>[INDEX <idx>]
To scroll a list vertically by page Iength .<pag> is a page number. Ìf you specify the
LÌNE option, the system displays the page to which it scrolls starting from line <lin> of
the actual list. Ìt does not count the page header lines.
SRO IST FORWARD | BAWARD <n> PAGES [INDEX <idx>].
To scroll a list by a specific number of pages. Ìf you do not specify the ÌNDEX option, the
statement scrolls forward or backward <n> pages.
· HorizontaI ScroIIing :
SRO IST EFT | RIGHT [INDEX <idx>].
Ìf you do not specify the ÌNDEX option, the statement scrolls to the left or right margin of
the current list. Ìf you specify the ÌNDEX option, the system scrolls the list of list level
To scroll a list horizontally by columns, use following two statements.
SRO IST TO OUMN <coI> [INDEX <idx>].
SRO IST EFT | RIGHT BY <n> PAES [INDEX <idx>].
To exclude a line (for example, a header or comment line) from horizontal scrolling,
define the line feed for that line as follows:
The line following the statement cannot be scrolled horizontally. However, it can be
scrolled vertically. To undo the above statement, use:
This statement makes sense if no line was output after NEW-LÌNE NO-SCROLLÌNG
To determine the left boundary of the horizontally scrollable area, use:
SET EFT SRO-BOUNDARY [OUMN <coI>].
Ìf you do not use the COLUMN option, the left boundary of the scrollable area of the
current page is set to the current output position; if you use the COLUMN option, the left
boundary is set to position <col>. Now, only the part to the right of this area can be
scrolled horizontally. The above statement applies to the entire current page, and only to
it. You must repeat the statement for each new page, otherwise the system uses the
default value (left list margin). To set the same scrollable area for all pages of a list, you
can execute the statement, for example, at the TOP-OF-PAGE event.
Positioning in lists
For the current output position, refer to the system fields :
SY-ONO (for the current column) & SY-INNO (for the current line)
SAP intends to allow only read access to the system fields SY-COLNO and SY-LÌNNO.
· POSITION statement :
This statement sets horizontal output position & SY-COLNO system field to <col>.
· BA statement :
Ìf this statement does not follow a RESERVE statement, the subsequent output appears
beneath the page header. The system sets SY-COLNO to 1 and SY-LÌNNO according to
the length of the page header. Ìf the BACK statement is executed at the TOP-OF-PAGE
event, the system set the output position to beneath the standard page header. Any
output written now overwrites the self-defined page header specified at TOP-OF-PAGE.
· NEW-INE statement :
This statement positions the next output in a new line. SY-COLNO is set to 1, and SY-
LÌNNO is increased by one. NEW-LÌNE does not create a blank line.
· RESERVE statement with BA :
RESERVE <n> Iines.
Ìf BACK follows RESERVE, the subsequent output appears in the first line written after
· VerticaI Positioning: You specify vertical output positions as follows:
SIP TO INE <n>.
This statement sets the vertical output position and the SY-LÌNNO system field to
<n>. Ìf <n> does not lie between 1 and the page length, the system ignores the
statement. When you use LÌNE, the system also counts page header and page
footer lines unlike BACK. Make sure that you do not unintentionally overwrite header
or footer lines.
Note: You should use all scrolling statements after displaying all records. But Set Left
Scroll-Boundary option should be used before displaying the records for which
you want to apply horizontal scrolling.
System Fields for Basic List:
SY-SIND: Ìndex of the basic list = 0
SY-TITE: List Heading ( Read and Change )
SY-INSZ: Current line width
SY-INT: Current number of lines per page.
SY-PAGNO: Current page number.
SY-SROWS: Number of lines of the current window.
SY-SOS: Number of characters of the current window.
SY-ONO: Current column
SY-INNO: Current line
· As with all other screens, you can link a dialog status to list using the SET PF-
STATUS statement. Ìn the dialog status, you link function codes to function keys,
menu entries, icons in the standard toolbar, and pushbuttons in the application
· You can access the function code in the system field SY-UOMM.
· Ìn order to create a new list level, the GUÌ status of the basic list must allow user
actions, and the relevant event blocks must be defined in the program.
· SY-LSÌND is automatically increased by one, Each time the user executes an action
on a list & if there is an event block defined that corresponds to the function code.
· Ìf the user creates a list on the next level (that is, SY-LSÌND increases), the system
stores the previous list and displays the new one.
· You cannot nest processing blocks. Therefore, you cannot process other events
within the processing blocks of interactive lists.
· A certain user action always triggers the same processing block in your program.
You must use control statements (ÌF, CASE) within the processing block to make
sure that the system processes the desired statements.
· To layout the page headers of the secondary lists, you must use the event TOP-OF-
PAGE DURING INE-SEETION.However,you can use END-OF-PAGE event for
secondary lists. Use SY-LSÌND or SY-PFKEY in control statements (ÌF, CASE) to
display header/footer for interactive lists.
· System FieIds for Interactive ist:
SY-SIND: Ìndex of the list created during the current event
SY-ISTI: Ìndex of the list level from which the event was triggered
SY-II: Absolute number of the line from which the event was triggered
SY-ISE: Contents of the line from which the event was triggered
SY-UROW: Position of the line in the window from which the event was triggered
(counting starts with 1)
SY-UO: Position of the column in the window from which the event was triggered
(counting starts with 2)
SY-PAGE: Page number of the first displayed page of the list from which the event
SY-STARO: Number of the first line of the first page displayed of the list from which the
event was triggered (counting starts with 1). This line may contain the
page header. (Use for vertical scrolling).
SY-STAO: Number of the first column displayed in the list from which the event was
triggered (counting starts with 1). (Use for horizontal scrolling).
SY-UOMM: Function code that triggered the event
SY-PFEY: Gui Status of the list currently being displayed.
· You can use the logical database assigned to the executable program (report) only
for the basic list. Ìf you want to use a logical database during interactive events, you
must either call another executable program using SUBMÌT, or call the logical
database using a function module.
· To return from a high list level to the next-lower level, the user can choose Back from
a detail list.The system deletes the contents of the released list and returns to the
previous list level.
· You can change the value of the system fields SY-LSÌND which accepts only index
values which correspond to existing list levels. Ìt then deletes all existing list levels
whose index is greater or equal to the index you specify. For example, if you set SY-
LSÌND to 0, the system deletes all secondary lists and overwrites the basic list with
the current secondary list. The best place to set it is in the last statement of the event
block as the change only takes effect at the end of the corresponding event.
· One of the three following list events may be called, depending on the function code
triggered by the user.
AT PF<nn> (obsoIete)
AT INE-SEETION (choose function key F2)
· DiaIog Status for ists :
- You can define your own GUÌ status for lists and attach it to a list level using SET PF-
STATUS statement. Ìf you do not set a particular GUÌ status, system sets a default
list status for the list screen in an executable program. Ìn other programs, when you
call a list from screen processing, you must set this status explicitly using the statement:
SET PF-STATUS space
- AT PF<nn> (obsoIete) : All function keys of the keyboard F<nn> that are not used for
predefined system functions, are set to the function codes PF<nn>, where <nn> is a
number between 01 and 24. During list processing, the function codes PF<nn> are
linked to the events AT PF<nn>. Choosing PF<nn> always triggers AT PF<nn>. You
should no longer use event blocks for PF<nn>.
- AT INE-SEETION : For this event, the F2 key (double-click) is assigned function
code PI and function text hoose. The function also always appears in application
toolbar. During list processing, PÌCK function code is assigned to the event AT LÌNE-
SELECTÌON. PÌCK always triggers this event.
- AT USER-OMMAND : All other function codes are either intercepted by the runtime
environment or trigger the event AT USER-COMMAND. Function codes that trigger
AT USER-COMMAND must be defined in your own GUÌ status. Ìn this event block,
you can use an ÌF or CASE structure to tell the function codes apart. There are further
system fields that are filled in list events, such as SY-LSÌND and SY-PFKEY, that
allow you to make further case distinctions.
- You can create a dialog status for a list using the Menu Painter in ABAP Workbench.
As soon as you create the status, you should choose Extras-> Adjust tempIate and
select List status for your template. This status already contains standard function
codes for list processing. They are distributed as follows on the menus, standard
toolbar, and application toolbar:
ode Menu Function key Description
%PC List Save list to file
%SL List Save list in SAP office
%ST List Save list in report tree
PRÌ List CTRL-P Print displayed list
%EX List Shift-F3 Exit processing
PÌCK Edit F2 Event AT LÌNE-SELECTÌON
RW Edit F12 , ESC Cancel processing
%SC Edit CTRL-F Find
%SC+ Edit CTRL-G Find next
BACK Goto F3 Back one level
P-- CTRL-PgUp Scroll to first window page
P- PgUp Scroll to previous window page
P+ PgDn Scroll to next window page
P++ Ctrl-PgDn Scroll to last window page
%CTX Shift-F10 Context menu on list
Ìn addition, the following function codes are predefined, but not set as status functions.
You can assign them freely to any empty status element.
PF<nn> Event AT PF<nn>
PP<n> Scroll to top of list page <n>
PP-[<n>] Scroll back one list page or <n> pages
PP+[<n>] Scroll forward one list page or <n> pages
PS<n> Scroll to column <n>
PS-- Scroll to first column of the list
PS-[<n>] Scroll left by one or <n> columns
PS+[<n>] Scroll right by one or <n> columns
PS++ Scroll to last column of the list
PZ<n> Scroll to line <n>
PL-[<n>] Scroll back to first line of the page or by <n> lines
PL+[<n>] Scroll to last line of the page or by <n> lines
/.... For other system commands
The runtime environment directly queries and processes all function codes of the above
tables, except PÌCK and PF<nn>. These function codes do not trigger events, and you
cannot use them for the AT USER-COMMAND event.
- Function key F2 : A double-click is always equivalent to pressing function key F2 .
Each function code you assign to F2 is therefore activated by double-clicking. Double-
clicking triggers the AT LÌNE-SELECTÌON event only if the function code PÌCK is
assigned to function key F2. Ìf you assign your own function code to F2 , double-clicking
triggers the AT USER-COMMAND event. Ìf a predefined function code is assigned to
F2 , double-clicking triggers the corresponding action from the runtime environment.
- You can change the list-specific template if you have other requirements. You can
· replace function code PÌCK with your own function code to prevent the AT
LÌNE-SELECTÌON event from being triggered in the report. You can then
program all reactions to user actions in a single processing block (AT USER-
· delete predefined function codes whose functionality you do not want to
support. For example, this allows you to prevent the user from printing the list or
saving it in a file on the presentation server.
· modify the standard key settings. For example, you can assign your own
function code to F3 to navigate within the lists according to your requirements,
instead of returning one list level ( Back). This may be important if you keep
several lists on the same logical level and therefore do not want to delete the
displayed list as would the standard F3 setting. Or you may want to display a
warning before leaving a list level.
- SET PF-STATUS <stat> [EXUDING <f>|<itab>] [OF PROGRAM <prog>]
This statement sets the status <stat> for the current output list. The status is active
for all subsequent list levels until you set another status. The SY-PFKEY system field
always contains the status of the current list. You can define a single global status, &
then just deactivate the functions you do not need using EXCLUDÌNG. Specify <f> to
deactivate the function code stored in field <f>. Specify <itab> to deactivate all function
codes stored in the internal table <itab>. The ÌMMEDÌATELY addition is intended
specially for list processing. You use it while creating a detail list within an event block
to change the status of the list currently displayed (index SY-LÌSTÌ). Without this
option, the system changes the status of the current secondary list (SY-LSÌND) that is
displayed only at the end of the processing block.
- SET TITEBAR <ttI> [WITH <g1> ... <g9>] [OF PROGRAM <prog>].
This statement sets the title for the current output list. Ìt remains active for all screens
until you specify another using SET TÌTLEBAR. The system also replaces '&' placehol-
holders in succession by the contents of the corresponding <gi> parameter.
· ontext Menus for ists : You can call context menu using the right-hand mouse
button ( Shift + F10 ). The function code %CTX is assigned to function key Shift+F10
in already defined dialog status. To do this, List with contet menu option must be
selected (oto->Attributes-> F key setting. Context menus on lists are generated
dynamically in ABAP program as objects of the class CL_CTMENU. For context
menus on lists, you must program a callback routine in the ABAP program:
FORM on_ctmenu_request USING <I_menu> TYPE REF TO cI_ctmenu.
When you right-click a list line (or choose Shift+F10 ), the callback routine is executed,
and the context menu defined in it is displayed. Ìf the user chooses a menu item, the
system carries on processing according to function code assigned to it (SY-UCOMM).
Ìf you right-click outside a list line, the system displays the standard context menu.
· Triggering a ist Event from the Program :
SET USER-OMMAND <fc>.
This statement takes effect after the current list is completed. Before the list is display-
ed, the event assigned to function code <fc> is triggered, regardless of the dialog
status you are using. The effect is the same as when the user chooses the function.
· ists in DiaIog Boxes :
WINDOW STARTING AT <Ieft> <upper> [ENDING AT <right> <Iower>].
When you use this statement, the system displays the current list (index SY- LSÌND)
as a dialog box. The WÌNDOW statement takes effect only within the processing block
of an interactive event, that is, only for detail lists. Dialog boxes have no menu bar
and no standard tooIbar. The application toolbar appears at the bottom of the dialog
box. Choose ialog bo as the status type in the Menu Painter.
· Passing Data from ists to Programs : To effectively use interactive lists for
interactive reporting, it is not sufficient for the program to react to events triggered by
user actions on the output list. You must also be able to interpret the lines selected by
the user and their contents. To do this, you use information that the interactive lists
pass to the program. ABAP provides two ways of passing data:
1. Automatic Data Transfer : The system passes data to programs automatically
using the system fields that it fills for each interactive event. System fields provide you
with information about the list index, the position of the list in the output window, and
the cursor position. The only system field that contains the contents of the selected
line is SY-ISE. The system field SY-LÌSEL is a type C field with length 255.
Although, it contains the selected line, it is only of limited use for passing values of
single fields, since it is a character string. To process certain parts of SY-LÌSEL, you
must specify corresponding offsets. SY-LÌSEL is, however, suitable for designing
headers of detail lists, or for checking that a selected line is not a space or an
2. The HIDE Technique :
HIDE : <f1>,<f2>,------.
You use the HÌDE technique while creating a list level to store line-specific information
for later use. This statement places the contents of variable <f> for the current output
line (system field SY-LÌNNO) into the HÌDE area. The variable <f1>,<f2>,--- must not
necessarily appear on the current line. To make your program more readable, always
place the HÌDE statement directly after the output statement for the variable <f> or
after the last output statement for the current line. As soon as the user selects a line
for which you stored HÌDE fields, the system fills the variables in the program with the
values stored. You can think of the HÌDE area as a table containing two columns, in
which the system stores the names and values of all HÌDE fields for each list and line
number. As soon as they are needed, system reads values from the table.
Note: You cannot use the HÌDE technique to process user entries in list fields that
accept input. Use READ LÌNE statement for this purpose.
3. Reading ines from ists :
READ INE <Iin> [INDEX <idx>][FIED VAUE <f1> [INTO <g1>] ... <fn> [INTO
<gn>]] [OF URRENT PAGE|OF PAGE <p>].
All the lists generated by a single program are stored internally in the system. You can
therefore access any list in a program that was created for the same screen and that
has not yet been deleted by returning to a lower list level. To read a line from a list
after an interactive list event, use the READ LÌNE statement. The statement without
any options stores the contents of line <lin> from the list on which the event was
triggered (index SY-LÌLLÌ) in the SY-LÌSEL system field and fills all HÌDE information
stored for this line back into the corresponding fields. As far as SY-LÌSEL and the HÌDE
area are concerned, READ LÌNE has the same effect as an interactive line selection.
Ìf the selected line <lin> exists, the system sets SY-SUBRC to 0, otherwise to 4.The
options have the following effects:
INDEX <idx>: System reads the information for line <lin> from the list of level <idx>.
FIED VAUE <f 1 > [INTO <g 1 >] ... <f n> [INTO <g n>]: The system interprets the
output values of the variables <f i > in line <lin> as character strings and places them
either into same fields <f i > or, when using ÌNTO, into the fields <g i >.When refilling
the fields, the system applies the conversion rules. Fields that do not appear in a line
do not affect the target field. Ìf a field appears several times in a line, the system uses
only the first one. The system transports the field contents using the output format, that
is, including all formatting characters. This may cause problems, such as converting
editing characters to decimal characters or other incompatible cases. You use this
option mainly to process user entries in list fields that accept input, since you cannot
use the HÌDE technique in this case.
OF URRENT PAGE: With this option, <lin> is not the number of the line of the entire
list, but the number of the line of the currently displayed page of the addressed list.
The system field SY-CPAGE stores the corresponding page number.
OF PAGE <p>: With this option, <lin> is not the number of the line of the entire list, but
the number of a line on page <p> of the addressed list.
4. Reading current ine from ists :
READ URRENT INE [FIED VAUE <f1> [INTO <g 1>] ...].
This statement reads a line read before by an interactive event ( F2 ) or by READ
LÌNE. The FÌELD VALUE option is the same as for READ LÌNE. This allows you to fill
fields in the same line using values from the program.
5. Reading ists at the ursor Position :
GET URSOR FIED <f> [OFFSET <off>] [INE <Iin>]
[VAUE <vaI>] [ENGTH <Ien>].
This statement transfers the name of the field on which the cursor is positioned during
a user action into the variable <f>. Ìf cursor is on a field, system sets SY- SUBRC to
0, otherwise to 4. The system transports the names of global variables, constants,
field symbols, or reference parameters of subroutines. For literals, local fields, and
VALUE parameters of subroutines, the system sets SY-SUBRC to 0, but transfers
SPACE as the name.
OFFSET <off>: The field <off> contains the position of the cursor within the field. Ìf
the cursor is on the first column, <off> = 0.
INE <Iin>: The field <lin> contains the number of the list line on which the cursor is
VAUE <vaI>: The field <val> contains the character string output representation of
field on which cursor is positioned.The representation includes formatting characters.
ENGTH <Ien>:The field <len> contains the output length of the field on which the
cursor is positioned.
GET URSOR INE <Iin> [OFFSET <off>] [VAUE <vaI>] [ENGTH <Ien>].
This statement transfers the number of the line on which the cursor is positioned during
a user action into the variable <lin>. Ìf the cursor is on a list line, the system sets SY-
SUBRC to 0, otherwise to 4. You can use this statement to prevent user from selecting
OFFSET <off>: The field <off> contains the position of the cursor within the list line. Ìf
the cursor is on the first column, <off> = 0.
VAUE <vaI>: The field <val> contains the character string output representation of
line on which the cursor is positioned. Representation includes formatting characters.
ENGTH <Ien>: The field <len> contains the output length of the line on which the
cursor is positioned.
6.Determining the Attributes of ists: Ìf you need to know the attributes of list levels
that are not stored in system variables, you can use the DESCRÌBE LÌST statement.
To retrieve the number of lines or pages of a list, use:
DESRIBE IST NUMBER OF INES|PAGES <n> [INDEX <idx>].
This statement writes the number of lines or pages of the list level <idx> into variable
<n>. Ìf a list with index <idx> does not exist, the system sets SY-SUBRC unequal to 0,
otherwise to 0.
To retrieve the page number for a certain line number, use:
DESRIBE IST INE <Iin> PAGE <pag> [INDEX <idx>].
This statement writes for list level <idx> the page number on which list line number
<lin> is found into the variable <pag>. Ìf there is no list with the index <idx>, SY-
SUBRC is 8. Ìf there is no line with number <line>, it is 4. Otherwise, it is 0.
To retrieve the attributes of a certain page, use:
DESRIBE IST PAGE <pag> [INDEX <idx>] [<options>]
This statement retrieves for list level <idx> the attributes specified in <options> for
page <pag>.Ìf there is no list with the index <idx>, SY-SUBRC is 8. Ìf there is no page
with number <pag>, it is 4. Otherwise, it is 0. Use DESCRÌBE LÌST for completed lists
only, since for lists in creation (index is SY-LSÌND) some attributes are not up to date.
The <options> of the statement are:
INE-SIZE <coI>: Writes the page width into the variable <col>.
INE-OUNT <Ien>: Writes the page length into the variable <len>.
INES <Iin>: Writes the number of displayed lines into the variable <lin>.
FIRST-INE <Iin1>: Writes the absolute number of the first line into variable <lin1>.
TOP-INES <top>: Writes the number of page header lines into the variable <top>.
TITE-INES <ttI>: Writes the number of list header lines of standard page header
into the variable <ttl>.
HEAD-INES <head>: Writes the number of column header lines of the standard
page header into the variable <head>.
END-INES <end>: Writes the number of page footer lines into the variable <end>.
· ScroIIing in DetaiI ists: You can scroll in a detail list using SCROLL statement
mentioned in basic list. You can only use the SCROLL statement for completed lists.
SCROLL statement without ÌNDEX option always refers to the previously displayed
list on which the interactive event occurred . You can use the ÌNDEX option to scroll
explicitly on existing list levels. To do this, the lists need not be displayed. When the
user displays the list again, it is scrolled to the specified position.
Another way of scrolling interactive lists from within program is to use SET USER-
OMMAND statement in conjunction with predefined function codes (P...).
· Setting the ursor from within the Program: You can set the cursor on
current list dynamically from within your program. You can do this to support the user
with entering values into input fields or selecting fields or lines. Ìf input fields occur on a
list, the system by default places the cursor into the first input field. You can sets the
cursor in the most recently-created list. While the basic list is being created, this is
always the basic list itself. For a detail list, it is the previous list.
SET URSOR <coI> <Iin>
This statement sets the cursor to column <col> of line <lin> of the output window. The
system sets the cursor only to positions that are visible in the display. For positions
outside the displayed area, it ignores the statement. To set the cursor to a part of the list
currently not displayed, you must scroll the list first. You can set the cursor only to lines
that contain list output. These include lines skipped with the SKÌP statement, but no
SET URSOR FIED <f> INE <Iin> [OFFSET <off>]
This statement sets the cursor on line <lin> onto the field whose name is stored in <f>.
Ìf a field appears more than once on a line, the system sets the cursor to the first field. Ìf
the field does not appear on the line or if it is outside the displayed area, the system
ignores the statement. You can use the SCROLL statement to scroll the line into the
visible area of the screen. Use the OFFSET option to set the cursor to position <off> of
the field stored in <f>.
SET URSOR INE <Iin> [OFFSET <off>]
This statement sets the cursor to line <lin>. The system ignores the statement, if the
line does not appear in the list or in the visible area of the window. You can use the
SCROLL statement to scroll the line into the visible area of the screen. Use OFFSET
option to set the cursor to column <off> of line <lin>.
· Modifying ist ines:
MODIFY INE <n> [INDEX <idx>|OF URRENT PAGE|OF PAGE <p>]
[ INE FORMAT <option1> <option 2> ... ]
[ FIED VAUE <f1> [FROM <g 1>] <f 2> [FROM <g 2>] ... ]
[ FIED FORMAT <f1> <options 1> <f 2> <options 2> ... ]
This statement modifies line <n> of the list on which an interactive event occurred
(index SY-LÌSTÌ). Use OF CURRENT PAGE to specify line <n> of the currently
displayed page (page number SY-CPAGE) .Use OF PAGE <p> to specify line <n> of
page <p>. Without formatting option, the above statements fill the current contents of
the SY-LÌSEL system field into the specified line. The line's HÌDE area is overwritten by
the current values of the corresponding fields. However, this does not influence the
displayed values. Ìf the system succeeded in modifying the specified line, it sets SY-
SUBRC to 0, otherwise to a value unequal to 0. You can specify formats from the
FORMAT statement in <options i >. The option FÌELD FORMAT overwrites the
specifications of the LÌNE FORMAT option for the corresponding field. Ìf a field <f i >
occurs more than once in the line, the system modifies only the first. Ìf a field <f i > does
not occur in the line at all, the system ignores the option. FieId vaIue statement overwri-
tes the contents of the fields <f i > in the list line with the current contents of the fields
<f i > or <g i >. Ìf necessary, the system converts the field type to type C.
· Memory Management for Lists :
The system stores the previous list along with the currently displayed list in memory.
When we move back the list order:
- as 2 1 , the 2
list in memory is released.
- as 2 0 , both 1
list in memory is released )
To navigate backwards in the list we can use SY-LSÌND.
Messages in Lists
Ìn ABAP programs, this includes the following processing blocks:
TOP-OF-PAGE DURING INE-SEETION
Type DispIay Processing
A Dialog box Program terminates, and control returns to last area menu.
E Status bar Once the user has confirmed the error by pressing ENTER,
the current event block is terminated and the previous list
level remains displayed. Ìf you use an error or warning
message while creating the basic list, the entire program is
I Dialog box Program continues processing after the MESSAGE
S Status bar Program continues processing after MESSAGE statement
of next screen
W Status bar Like type E.
X None Triggers a runtime error with short dump.
Logical Data Base.
· Logical databases are special ABAP
programs that read data from database
· They are used by "Executable (type)
· At run time, you can regard the logical
database and the executable program as a
single ABAP program that runs in a pre-
· Logical databases are advantageous when it
comes to ensuring data is retrieved properly,
since all of the select / check logic is pre-
· LDB programs reads data from one or more
database tables and supply data to a report
· Queries are written in LDB.
· Helps reusability of queries.
· Reports can be assigned to LDB.
· As an when we execute the report the LDB
program will be executed.
· Ìt reads the data from the database and transfers
to the report one row at a time.
· Transaction code "SE36¨.
· Note :- Ìn LDB the select statements be executed
as nested select.
Structure of Logical Database
· Logical database
can be divided into
÷ Selection part
÷ Actual database
· Note :- Ìn LDB the select statement is executed as
· PUT :- A "!&T" statement the workarea to identical
workarea in the report.
· NODE :- A "NODE¨ statement is used with the report
program to create a work area identical to the LDB
tables , into which the PUT statement can place the
· GET <node> :- Triggered when node gets a row of
· GET <node> LATE :- Triggered the child row is
· These events are triggered after START-OF-
SELECTÌON and before END-OF-SELECTÌON.
· Advantages of LDB:-
÷ Reusability of query.
÷ Built-in selection screen.
÷ Tunning query in LDB, improves the
performance of all application using the
· Disadvantages of LDB:-
÷ Ìneffeciency of nested select.
Ìn an ABAP program, there are no automatic authorization checks associated with Open
SQL statements. This can cause problems,since Open SQL and Native SQL statements
allow unrestricted access to all database tables. To check the authorization of user of
an ABAP program, use the AUTHORÌTY-CHECK statement:
AUTHORITY-HE OBJET '<object>' ID '<name1>' FIED <f1>
ID '<name2>' FIED <f2>
ID '<name9>' DUMMY
ID '<name10>' FIED <f10>.
<object> is the name of the object that you want to check. You must list the names
(<name1>, <name2> ...) of all authorization fields that occur in<object>.You can enter
the values <f 1 >, <f 2 >.... for which the authorization is to be checked either as variab-
les or as literals. The AUTHORÌTY-CHECK statement checks the user's profile for the
listed object, to see whether the user has authorization for all values of <f>. Then, and
only then, is SY-SUBRC set to 0.You can avoid checking a field by replacing FÌELD <f>
with DUMMY. You can only evaluate the result of the authorization check by checking
the contents of SY-SUBRC. Much of the data in an R/3 system has to be protected so
that unauthorized users cannot access it. Therefore the appropriate authorization is
required before a user can carry out certain actions in the system. When you log on to
the R/3 system, the system checks in the user master record to see which transactions
you are authorized to use. Check table TATZ (Valid activities for each authorization
· MODULE USER_COMMAND_0100 ÌNPUT.
AUTHORÌTY-CHECK OBJECT 'S_CARRÌD'
ÌD 'CARRÌD' FÌELD '*'
ÌD 'ACTVT' FÌELD '03'.
ÌF SY-SUBRC NE 0.
· SELECT * FROM SPFLÌ.
AUTHORÌTY-CHECK OBJECT 'F_SPFLÌ'
ÌD 'ACTVT' FÌELD '02'
ÌD 'NAME' FÌELD SPFLÌ-CARRÌD
ÌD 'CÌTY' DUMMY.
ÌF SY-SUBRC NE 0.
hecking the Runtime of Program Segments
The ABAP Workbench provides several tools for the runtime measurement of Complete
application programs: SQLTrace and Runtime Analysis. You can use the GET RUN
TÌME FÌELD statement to measure the relative runtime of Program segments in
microseconds. The syntax is as follows:
GET RUN TIME FIED <f>.
When this statement is called initially, the value of field <f>, which should be of type Ì, is
set to zero. Each subsequent call of the statement sets the value of field <f> to the
runtime of the program that has elapsed since the statement was called first.
Generating & Running Programs DynamicaIIy
You should be aware that this method affects system response times, since programs
created dynamically must be regenerated for each run. SAP therefore recommends that
you use the standard way of creating and generating program code with the ABAP
Editor as frequently as possible.
· reating a New Program DynamicaIIy: To create a new dynamic program at runti-
me of an ABAP program, you must use an internal table. For this purpose, create the
internal table with a single column of type character and a row width of 72. Ìnternal table
must contains the program code. Use append statement for adding the code into
internal table. To transfer the contents of this internal table into the program library
(ABAP Editor) (in the R/3 Repository) , Use the following statement:
INSERT REPORT <prog> FROM <itab>.
<prog> can be the variable or character string. Ìf a program with the name <prog>
already exists, its source code is replaced with a new one from the internal table <itab>
without prior warning. All other attributes remain intact.
· hanging Existing Programs DynamicaIIy: Since you cannot check the syntax
when a program is generated dynamically, you may want to have a set of syntactically
correct structures in the system that you can load into an internal table, modify, and
write back to the system. Such structures can consist of reports, subroutines, include
programs, or modules from the module pool. Use the following syntax:
READ REPORT <prog> INTO <itab>.
· Running Programs reated DynamicaIIy: Ìn this case, you can
- Use the SUBMÌT statement,
- Work with include programs or subroutines.
When you use the SUBMÌT statement, all modifications made to a program during
runtime take immediate effect before they are submitted. But this is not the case if you
change the codes of include programs or subroutines dynamically. One way to solve this
problem is to use the ÌNCLUDE statement within an external subroutine that is called by
the program. This allows you to create or modify include programs or subroutines and
use the updated versions directly in the same program.
· reating and Starting Temporary Subroutines :
GENERATE SUBROUTINE POO <itab> NAME <prog> [<options>].
This statement creates a subroutine pool in the main memory area of the running
Program & not in R/3 repository. You pass the source code of the subroutine pool in
internal table <itab>. The statement returns the name of the generated subroutine pool
in field <prog> that should have type C of length 8. You use the name in <prog> to call
the external subroutines defined in table <itab> through dynamic subroutine calls:
PERFORM (<fsubr>)[IN PROGRAM (<prog>)] [USING ... <p
>... ] [IF FOUND].
The subroutine pool only exists during the runtime of the generating program and can
only be called from within this program. You can create up to 36 subroutine pools for
one program. Ìf an error occurs during generation, SY-SUBRC is set to 8. Otherwise, it
is set to 0.You can use the following options <options> in the GENERATE SUBROUT-
ÌNE POOL statement:
· MESSAGE <mess>: Ìn the case of a syntax error, field <mess> contains the error
· INUDE <incI>: Ìn the case of a syntax error, field <incl> contains the name of the
include program in which the error possibly occurred.
· INE <Iine>: Ìn the case of a syntax error, field <line> contains the number of the
· WORD <word>: Ìn the case of a syntax error, field <word> contains the wrong word.
· OFFSET <offs>: Ìn the case of a syntax error, field <offs> contains the offset of the
wrong word in the line.
· TRAE-FIE <trac>: Ìf you use this option, you switch on the trace mode and field
<trac> contains the trace output.
· To debug a given application, run the
application in the debugging mode.
· Note : - Only active programs can be
executed in the debugging mode.
· While debugging we can set :-
· Breakpoints : to stop the execution of
the application at that point.
· Watchpoints : useful for tracing the
value of individual fields during the
execution of programs.
· Performance Trace ( ST05).
· SQL Trace.
· RFC Trace.
· Enqueue Trace.
· Buffer Trace.
· The trace result is stored in a log file . We can see the
result : log file list trace.
· Runtime Analysis ( SE30 ).
· Analyse the performance of :
· Function Module.
AV Grid ontroI
The ALV Grid Control (ALV = $A! ist Viewer) is a flexible tool for displaying lists. For
practical examples of the ALV Grid Control, see development class SIS. ALV is a
reporting tool which provides most of the standard operations as built-in ( eg :- sorting,
saving to file etc..,).
· Functions provided by the ALV Grid Control.
- Display non-hierarchical lists consistently with a modern design
- Use typical list functions - such as sorting and filtering - without extra programming
- Adapt predefined list functions and their enhancements
- Program responses to user actions (such as double-clicking a line) individually
- Connect to the report/report interface.
· Constraints : The ALV Grid Control does not allow you to display block or hierarchical
lists. Currently, simple lists can be displayed in single-line format only. However,
users can define multiple-line format in the print preview and print the list as such. At
the moment, you cannot use tables that have object references. Similarly, the only
deep structures that can be used are those described in the documentation covering
the extended functionality of the ALV Grid Control (such as, structures for drag-and-
· Ìnstance for the ALV Grid Control :
Data <name of reference variabIe> type ref to cI_gui_aIv_grid.
You can call methods on this instance with which you can define and change the
properties of this control. Do not derive this class to be able to access protected areas
of the class. This is not required for using the ALV Grid Control.
· Inheritance Hierarchy :
· The following graphic illustrates the steps required to display a list with the ALV Grid
· As a minimum, you must provide the following two types of information for displaying
- An internal table with the data to be displayed, called the output table
- A description of the structure of this data that is declared to the ALV Grid Control
through the field catalog or through the corresponding structure of Data Dictionary.
· The field catalog is a table that contains information on the fields to be displayed. For
example, the ALV uses this table to identify the type of a field. You can also use
special fields of this catalog to determine the number format and column properties of
the list to be output.
· Working With Controls: SAP made controls programming consistent for the following
- Creating a control and integrating it into the screen
- Passing methods from the backend to the frontend
- Handling events triggered by the control at the frontend
- Destroying the control (Lifetime Management)
· SpeciaI Event HandIing Aspects : The ALV Grid Control uses the grid control to
display the output table. So we can say that the ALV Grid Control is a wrapper that
uses the wrapper of a Basis control. As the 'outer layer', this wrapper spares the
developer from having to register the events on the frontend in order to simplify event
handling. The ALV Grid Control differs from Basis controls in the following respects :
- All events are registered as system events when the control is instantiated.
- Ìf you want to register all events as application events, you must use parameter
Ì_APPL_EVENTS. As usual, you must then call method CL_GUÌ_CFW=>DÌSPATCH
in the PAÌ module.
- Events DELAYED_CALLBACK or DELAYED_CHANGED_SEL_CALLBACK are
registered using method register_delayed_event.
- For Drag & Drop With the ALV Grid Control no DÌSPATCH call is required.
· Easiest way to dispIay a AV Iist : Refer sample report BCALV_GRÌD_DEMO in
development class SLÌS .
1. Declare reference variables for the ALV Grid Control and the container. Ìn addition,
declare an internal table that you fill with selected data later on:
DATA: grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container
gt_sflight TYPE TABLE OF sflight.
Here we are using the custom container control.
2. Create a standard screen and mark an area for the custom container control in the
graphical Screen Painter (icon identified by letter 'C'). Assign name CCCONTAÌNER
to this area.
3. Ìn the PBO module of the screen, you must now instantiate the container control
and the ALV Grid Control. By doing this, you create a link between the container
control and the screen, using the container created in the Screen Painter. Using
parameter parent , you define the container control as the parent of the ALV Grid
Control: ÌF g_custom_container ÌS ÌNÌTÌAL.
CREATE OBJECT g_custom_container
EXPORTÌNG CONTAÌNER_NAME = 'CCCONTAÌNER'.
CREATE OBJECT GRÌD1
EXPORTÌNG Ì_PARENT = g_custom_container.
· ALV's can be generated and used in two
÷ Function module approach.
÷ Object-oriented approach.
· For function module built-in methods like:-
· The fields to be passed to these function
module should be stored in the field catalog.
· Different data type related to the ALV's are
defined in the TYPE POOLS : ( SLÌS).
· Ìn Object-Oriented method built-in classes :-
· Note :- To define instance of a class :-
· DATA : <obj> TYPE REF TO <class>.
· Method with the CL_GUÌ_ALV_GRÌD class to
display the data :-
· For object-oriented method a screen with a
custom control should be made available.
· There are two scenarios in which data has to be
transferred from legacy system to R/3.
- During SAP implementation.
- During maintenance. The organization may be
maintaining legacy along with SAP, such data has
to be transferred periodically.
· BDC (Batch Data Communication) : Ìs a
programming technique for transferring bulk data
from legacy system to R/3, non-interactively.
Steps Ìnvolved in BDC:
· Ìdentification of needs for data transfer.
· Ìdentify the source of data.
· Data purging. ( Purging :- Removing
obsolete (outdated) data.)
· Data cleansing ( Cleansing :- Removing
inconsistencies in the data )
· Transfer the data to flat file.
· Transfer flat file data to R/3.
Types of BDC
There are two ways of performing BDC:
· BATCH ÌNPUT METHODS:
÷ SESSÌON ( for bulk data transfer)
÷ CALL TRANSACTÌON (limited data transfer)
· DÌRECT ÌNPUT METHOD.
- Ìn case of batch input method a transaction is
used as an input for updating data.
- Ìn case of direct input function modules are used
as interfaces, which performs the consistency
checks before updating data into R/3.
· PROGRAM module pool name.
· DYNPRO screen no.
· DYNBEGÌN start screen.
· FNAM field name.
· FVAL field value.
· Used to store set of transactions along
with input data. Ìt is a file "Queue¨
stored on the application server.
· Session information can be viewed in
transaction code SM35.
· To record the execution of a transaction
the recording technique is available in
transaction code ( SHDB ).
Function Module to Generate a
· BDC_OPEN_GROUP : To open a session.
· Export Parameters :
÷ Group = name of the session.
÷ Keep = 'X' , to retain or delete the session after
processing the session.
÷ Holddate = The date after which the session can
÷ User = Name of the user under who's
authorization the session is processed in
· BDC_ÌNSERT :- Store single
transaction data within a session.
÷ Tcode = '<transaction code>'.
÷ DYNPROTAB = < itab of BDCDATA>
· BDC_CLOSE_GROUP :- To close a
Processing Sessions :
· A session can be processed in 3
different modes :
- Display errors only.
· Every time a session is processed the
system will generate a log ( error log ).
This log file is generally used to trace
Okcodes associated with
· /BDE :- switch from foreground-to-background.
· /BDA :- switch from errors only-to-foreground.
· /BEND :- to terminate the process session.
· /BDEL :- to delete current transaction.
· /BBEG :- restart the current transaction with a
· /N :- to terminate the processing of current
Features of Session
· Every session will be assigned to a
QUEUE-ÌD , which can uniquely identify
· Multiple sessions cannot be created
within a program.
· A session can be used to store data of
Call Transaction Method:
· Ìn this method no sessions are created,
instead of storing transaction within a
session, the transaction is called directly.
· Syntax :-
- CALL TRANSACTÌON '<tcode>'
- USÌNG <itab of BDCDATA>
- MODE 'A'/'E'/'N'
- UPDATE 'S'/'A'/'L'
- MESSAGE ÌNTO <itab of BDCMSGCOLL>
- A all screens
- E error screens
- N no screens
- S synchronous
- A asynchronous
- L Local.
· Note :- After a transaction call the system
returns a collection of messages into a
internal table called BDCMSGCOLL.
· Ìf the message returned is 'E' or 'A' it's a error
· SAP has provided background processing
techniques with which we can run a program in
the background without user intervention.
· Transaction code for background processing :
SM36 job scheduling.
SM 37 job over viewing.
RSBDSUB : Ìs a built in program which takes
session name and immediately executes session.
RSBDT : Ìs a built in program which takes
session id and immediately execute session. Ìt
takes only the ÌD, no other parameters can be
Legacy System Migration
· Ìt is a interactive tool for data transfer.
· Ìn order to minimize the complexity and cost
incurred on data transfer, SAP has developed
· Advantages :
÷ Minimal coding.
÷ Various conversion rules ( with reusability ).
÷ Different methods of data transfer:
÷ Batch Ìnput.
÷ Direct input.
÷ BAPÌ input.
÷ Ìdoc input.
General Transfer operations
· Read data ( from source ).
· Convert data ( according to R/3 ).
· Transfer data ( to R/3 using program ).
· Transaction code for LSMW : LSMW.
· SAP script is a tool for designing the layout of business documents like :
· Purchase order,
· DeIivery note, etc.,.
· SAP scripts are generally referred to as the "TEXT PROCESSÌNG¨ tool of SAP.
· SAPscript is the integrated text management system of the R/3 System.
· SAPscript is tightly integrated into the SAP System. You will therefore be using it for
many different word-processing tasks all over the SAP System.
· Tcode :
- SO10 (Standard Text)
- SE71 (Form Painter)
- SE72 (Style)
- SE73 (Font Maintenance)
- SE74 (Sapscript format conversion)
- SE78 (Administration of form graphics)
- SE63 (Translation Tool)
- SPAD (Spool Administration)
- SP01 (Spool Request)
· Style contains only paragraph and character format.
· SAP provides standard forms for most of the business documents used in general
· Some basic standard forms :
Purchase Document(s) MEDRUCK
Sales Order RVORDER01.
Delivery Note RVDELNOTE.
· Note :- An SAP script form is basically a client dependent object.
· TCODE SO10 for standard text used for creating & changing documents.
· Mention text name, text id & language.
· Two types of editor - P editor & INE editor (goto->change editor)
· You use the PC editor to create and edit texts.Only suitable for Windows NT 4.0 or
· Use a paragraph format to lay out the paragraphs of text entered in the editor. You
use a paragraph format to determine
- the font, the font size, and the font style
- the outline attributes of the paragraphs
- the tabs within the paragraph
· The system assign the default form SYSTEM .
· Use a character formats to lay out character strings within a text.You use a character
format to determine
- the font and the font size
- special attributes of characters, such as superscript or subscript
· You can insert non-typable characters into your document (Ìnsert ->character ->
displayable character, sap symbols, sap icons.
· You can insert following types of symbols
1. Text SymboIs : You can define text symbols locally in your document. You use
the defined symbol to insert the terms or text fragments at the desired places. You
can edit the value of text symbol, delete text symbol & format the text symbol. Use
edit->insert command option to enter text symbol. Ex: &ASTFAG&.
2. Program SymboIs: The values of program symbols come from tables of Programs.
You use either print program to provide data or data defined globally in programs. Ìf
no program is selected, choose Append print program.
3. Standard SymboIs: They are maintained in table TTDTG & are globally available
to all documents.They are language dependent.
4. System SymboIs : Come from global system variables. Ìt can be global, sap script,
· Setting a page break manually : Ìf you insert a page break, the page layout of new
page is determined by the form which may contain several different page layouts.
Choose format -> page, select page layouts. System will enter
NEW-PAGE <PAGE AYOUT> .
· To find documents, Choose $tandard tet -> ind .&se ildcard +,.
· To delete documents, choose text->delete.
· You can enter a short title for a document, which you can later use to find document.
Choose $tandard tet -> Find.
· Numbering & marking headings & paragraphs : You can number the headings & other
paragraph types in your text or mark them in another way.
· Ìn the print preview, you can check line feeds and page breaks and Ìf necessary,
correct them before printing the document. Choose Text -> Print.
· Ìn the field Page selection determine the pages you want to print. The parameters n
and m symbolize the page numbers you select.
· Page seIection Output
No value Entire text
N Page n
n,m Pages n and m
n-m Pages n to m
n- From page n to end of text
-m From 1st page to page m
· You can also choose a fax machine as output device.
· Choose $ettings -> ditor mode to shift to line editor.
· To display paragraph tags Choose Format -> !aragraph on/off.
· To assign paragraph format, position the cursor on the desired paragraph. Choose
Format -> !aragraph. To assign character format mark the desired character string.
Choose Format -> Character. To Reset character formats, Mark the formatted
character string. Choose dit -> #eset character formats. The system resets all
· To Ìnsert Texts, Choose Insert -> Tet -> $tandard/documentation/hypertet. When
inserting text directly, the text is inserted in the editor in formatted form. You can then
edit it further. To include a text by reference, use the ÌNCLUDE statement. To expand
included text, Choose dit -> $elected area-> pand ICL&.
· Additional information consists of symbols, control commands, text elements,
comments, SAP characters and links. The PC editor displays them in a different color
and read-only. Choose dit -> Insert command.
· Choose dit -> Insert command to create additional information consists of symbols,
control commands, text elements, comments, SAP characters and links. Enter the
symbol name of a text symbol, a program symbol, a standard symbol, or a system
symbol in the form &symboIname&. Enter the command name in the form
&commandname& . Enter the name of the text element, desired comment, number of
the SAP character. For link, enter the character format, the key, and the text of the
link. For Changing Additional Ìnformation, Double-click on the additional information in
the PC editor to select it. Choose dit -> Change command. For deleting additional
Ìnformation Choose dit-> elete command.
· You can use four types of cIipboards for cutting and copying text.
1. The SAPscript Clipboard : for copying text within or between SAPscript documents.
Use only within one R/3 system and one client. To mark the text, choose dit ->
$elect. To copy to and from the clipboard, choose dit -> $elected area -> Copy
or dit-> $elected area-> Cut, and dit->!aste.
2. SAPscript User Clipboards : Use the SAPscript user clipboards to copy
permanent text areas. The "permanent text" is kept in the clipboard until you
overwrite it, even if you log off or restart the R/3 system. Choose dit ->$elect to
mark the text. Choose dit -> $elected area-> Copy to user clipboard .Select one
of the five available clipboards. To insert the text, choose Insert -> Clipboard->
&ser clipboard and select the appropriate clipboard. You can edit the contents of
the SAPscript user clipboards. Choose oto -> &ser clipboard to open a normal
SAPscript text entry session for the contents of one of the clipboards.
3. ABAP Editor Clipboards : You use the ABAP editor clipboards for copying blocks of
text from the ABAP editor to the line editor only in one R/3 system and one client.
To mark text in the ABAP editor, use the line commands XX, YY, or ZZ. Each
command writes to a different clipboard. Ìt must be used in pairs, for example, XX
<text to mark> XX. To insert the text in the line editor, choose Insert-> Clipboard ->
4. PC or Workstation Clipboard : Use the PC or workstation clipboard for copying text
between SAPscript documents, between SAPscript and other programs, from
SAPscript to the ABAP editor. Choose CTRL-C , CTRL-X , CTRL-V.
· You can find and replace words and character strings in the PC editor. Choose dit ->
Find & Choose dit ->#eplace.
· The ine Editor : You can easily use texts created with the PC editor in line editor.
The system converts the assigned formats and styles appropriately and provides them
· You can compare or copy the following kinds of objects across clients
- Standard texts.
Choose &tilities -> Compare clients or &tilities -> Copy from client . Ìt is not possible
to copy styles or forms to client 000.
onverting SAPscript Texts (SE74)
SAPscript texts are stored in Ìnterchange Text Format (ÌTF). Use TODE SE74. Ìt
allows you to assign & rename paragraph formats & character formats in the source &
target text when converting formatted text.
Format conversion :
- Ìmport of RTF files
- Export of RTF files
- Word document templates (prototypes)
- Format conversion in SAPscript texts.
You can export & import ÌTF,RTF,ASCÌÌ & only export HTML files. But before that ,you
have to do format conversion if you want to do the import and export of RTF files. First
create word document template (.DOT) by using RTF file.So all character & paragraph
formats are copied from RTF file to .DOT. Now select import of RTF files. Enter the
name of document template & style or form. Now you can map source format with
target format. You can map exactly one paragraph style to exactly one sapscript
paragraph format, but you can map one character style onto up to four sapscript
character formats. Now you can download RTF files to text editor (text->download)
but you have to mention the name of document template (.DOT). You can also upload
RTF files to the text editor (text-> upload) but you have to mention the name of
document template (.DOT). When exporting RTF files, you can map paragraph or
character format to exactly one paragraph or character template.You can convert the
paragraph & character formats of form or style to those of another form or style. While
importing & exporting ASCÌÌ files, you have to mention line width & character set.
The function module CONVERT_ÌTF_TO_HTML converts a sapscript text to HTML.
SAPscript Form (SE71)
· Modifying SAP Forms :
- Ìf you access an SAP-standard form from another client, then the central copy in
client 000 is used.
- To modify SAP standard forms,
- Copy the forms you need from client 000 to your development client.
- Rename the forms using a name from the customer name reserve
(names starting with Y or Z).
- Copy the forms to one of your own Y or Z development classes.
- You must also modify the ABAP print program used to print documents that use this
form. You should rename such print programs and store them in your own Y or Z
· Forms are used to control the page layout and also the text formatting in your
· The print program uses the form to format the document/text for display or printing.
· A form or style other than the SAP standard in client 000 is available only in the client
in which it was created. Forms and styles are also language-specific.
· Ìf a local version of a form or style is not present in a client, the client 000 version is
used instead ( also for non-standard forms & styles ).
· The language in which a form or style is created is its original language. You can
translate a form or style into other languages using SAP's translation tools
· Ìf a form or style is needed only in its original language and need not be translated,
then you can indicate this in the language attributes in the header data.
· Ìn versions other than the original language version, changes to a form or style are
limited only to translation of texts. No changes to definitions and attributes are
· Header Data : is used for information and control purposes.
- Form class (development)
- Start page : Tells the print program which page format to use first for printing.
- Default paragraph : Paragraph set to * in standard text maintenance.
- Tab stop : are only valid in paragraphs where you have not defined your own tabs.
- Page format : Determined from the spool administration table with transaction
SPAD. Make sure there is a printer assignment. There must be an additional spool
format for the printer with the same page format.
- Orientation :Note that the formats landscape and portrait are not supported by all
- Lines per inch (LPÌ) : The value 6.00 is set by the system, as this value is supported
by all printers.
- Characters per inch (CPÌ) : The value 10.00 is set by the system, as this value is
supported by all printers.
- Font attributes : With these fields, you can set the default font for a form.
· Paragraph Formats and Attributes :
- Text processing is simplified by the use of different paragraph attribute such as
Standard , Font , Tabs , Outline.
- The paragraph tag can have one or two characters. The first character in the
paragraph tag must be a letter, the second a letter, number, or blank. special
characters are not valid.
- Left or right margin : Amount of space between the paragraph and the left or right
border of the form window.
- Ìndent first line : Ìndent of the first line of a paragraph. Ìf the value is positive, it is
indented to the right, if it is negative, it is indented to the left.
- Space before and space after : Space before and space after control the amount of
space between paragraphs.
- Alignment : Left-aligned, Right-aligned, Centered, Justified.
- Line spacing : Spacing between the lines. The default value is 1 line.
- No blank lines : Suppression of blank lines. You can control whether the blank lines
of a paragraph should be suppressed in the printout or not.
- Page protection : All lines of the paragraph are on one page or a paragraph can be
divided by a page break.
- Next paragraph same page : Cohesion of two adjacent paragraphs. Here you can
define whether the subsequent paragraph should begin on the same page.
- You can also set font attributes such as Font family, Font size , Bold / Ìtalic /
- Specify these underline attributes: Spacing between the base line & the underline,
Thickness , Ìntensity.
- The following selection criteria apply to the font attributes bold, italics & underlined:
Off : attribute is not set
Retain : inherited
On : attribute is set
- Use Tcode SE73 for SAPscript font maintenance. The name of a font family
appears in three different connections in SAPscript :
1. The set of font families is maintained in the SAPscript font maintenance. Each font
family is also assigned the attribute "proportional" or "nonproportional".
2. A system font (or SAP font) is a combination of font family, font size, the attribute
for bold and italic. The font selections used in text layout with SAPscript are
always system fonts.
3. A printer font is the combination of printer type, font family, font size, the attribute
for bold and italic. Printer fonts are the character fonts of the output devices which
are available for SAPscript. Printer fonts require the maintenance of certain
metrics data (information about the width of the characters) and control data to set
the fonts on the output devices.
- You can define as many tab positions as you require for each paragraph format. The
text can be aligned in different ways:
- Left-aligned with LEFT
- Right-aligned with RÌGHT
- Centered with CENTER
- Sign, right-aligned with SÌGN
- Alignment of decimal point with DECÌMAL
- The tab stops you define in the paragraph format replace the tab spacing you defined
in the header data of the form. Ìf there are fewer tabs in the paragraph formats than
in the header data, the tab stops of the header data are used for the rest of the line.
The tab stops are represented as ,, in the text editor.
- The paragraph numbering and marking (OUTLÌNE) attributes are used to structure
texts into chapters, subchapters, and sections. Numbering is carried out automati-
cally by SAPscript. The outline hierarchy of various paragraphs is formed by
assigning a common highest-level outline paragraph to all outline paragraphs.
ExampIe: Three outline paragraphs, AA, BB, and CC, are to be defined, where AA
is the highest and CC the lowest paragraph in the hierarchy. AA is to be used, for
example, for chapter headings, BB for section headings, and CC for headings within
the sections. Paragraph AA must be specified as the highest-level outline paragraph
for all three paragraphs. Make sure that AA, this paragraph itself, is entered as the
highest-level outline paragraph for AA.
- The outline levels of the paragraphs are numbered upwards from 1. The following
list shows the outline levels which need to be entered for the three paragraphs:
Paragraph : AA Outline : AA Outline level : 1
Paragraph : BB Outline : AA Outline level : 2
Paragraph : CC Outline : AA Outline level : 3
- Number margin : Amount of space between the paragraph number and the left
margin of the form window. Note that your numbering may extend into the text area
of the paragraph. Beginning of first line of a paragraph can be worked out as follows:
Beginning of first line = paragraph margin + indent of first line.
- Left/right delimiter : Specify the character that precedes or follows the numbering.
Also specify Number chaining .
- Character string : This character string allows you to choose a format for the
paragraph number different to that of the paragraph. Ìt is therefore possible to output
the number, for example, in bold type, underlined etc. The font family can also be
changed. Ìf an entry is not made, the number is assigned the same font attributes as
- Numbering type :
ARABÌC : Arabic numerals: 1, 2, 3.
CHAR : Fixed character: letter or numeral, entered in the field
LETTER : Letters: A-Z
ROMAN : Roman numerals: Ì, ÌÌ, ÌÌÌ, ÌV
- Fixed character :Define the fixed character to be used for numbering. You should
only make an entry in the field Fixed character if you have specified CHAR as the
numbering type. Fixed characters include + - and o .
ExampIe : Ìf CHAR has been chosen as the numbering type for a paragraph, and if
'o' has been entered as the fixed character, this character precedes the paragraph:
ExampIe : A character string can also be used instead of a single character. The
underscore '_' is replaced with blanks. Ìf 'Example' is chosen as the character string,
the result is as follows: Example paragraph...
- Output length : Enter the number of characters for Arabic numerals.
EXAMPE : The numbering type defined for an outline paragraph is arabic
numerals, and the output length is 4. The paragraph numbering therefore appears
as 0001 0002 0003 etc.
- Upper case : Specify for letters or Roman numerals.
· haracter Formats and Attributes : Character formats, as opposed to paragraph
attributes, allow you to format entire blocks of text within a paragraph. The character
format can have one or two characters. The first character must be a letter, the
second a letter, number, or blank; special characters are not valid.
- Marker : Links a search key to the selected character string when the end user uses
this character format. Examples include glossary, hypertext, and data element links.
Here, selected character strings are assigned the appropriate key.
- Bar code : Bar code that is required for certain variables and is known to the printer,
for example EAN8. The character string is printed as a bar code if the character
string concerned is selected. Bar code names, such as EAN8, refer to system bar
codes. These are defined in the SAPscript font maintenance.
- Protected : The character string is not split by a line break, but printed together on
the next line.
- Hidden : The character string is not printed. The text is only visible in the text editor.
- Superscript/subscript : The character string is printed half a line higher or lower.
- Font attributes can be specified for character formats as well as for paragraph
formats with the same options.
- Example : <I><B>&PAGE&</></>
<B>&PAGE&</> B is Bold and Ì is Ìtalic format name
· Windows : Windows are defined in form maintenance. They represent areas that are
positioned on pages as page windows and in which at a later time text is printed.
You must define at least one window for each form. Otherwise, SAPscript cannot
format the text. You can assign window names and window types. However, note that
you can define only one main window per form.
- MAIN : Main window in which continuous text is printed. This is the window used by
dialog users of a print program and form. The text in the main window can extend
over several pages. Ìf the text fills one page, output continues in the window of the
next and subsequent pages, as long as MAÌN has been defined for these pages.
- VAR : Window with variable contents. The text can vary on each page in which the
window is positioned. Variable windows are formatted for each page. To every
window you can assign text, which is printed in the corresponding window when the
form is formatted. To assign text, use text elements, which are stored with the form.
Ìf the text selected for the window exceed the window size, then the text is cut off.
- ONST : Window with constant contents that is formatted only once.
- DefauIt Paragraph: For a particular window, you can override the default paragraph
format that is set in the form header.
· Pages : You must define at least one page for every form. And you must designate a
"first" page in the form header. Otherwise text formatting is not possible. Ìn addition,
you should inform the system which page is to be used after reaching the end of the
first page. Ìf you do not specify a next page, the output of your text ends at the end of
the current page.
- Name of the next page
- Page counter mode:
ÌNC : Ìncreases the counter by 1
HOLD : Counter remains unchanged
START : Sets the counter to 1
You can display the contents of the page counter with the system symbol &PAGE&.
- Numbering type of the page counter :
ARABÌC : Arabic numerals
LETTER : Letters
ROMAN : Roman numerals
CHAR : Fixed character
Although CHAR is displayed as an entry option for the numbering type of the page
counter, internally CHAR is converted to ARABÌC.
- Output length for page numbering with numerals
- Upper or lower case for numbering with Roman numerals or letters
- Resource name : With #esource name, you specify that the paper for this page
should be taken from a particular paper tray at the printer. Ìn #esource name, enter
the print control that has been defined for switching to paper tray you want to use.
Ìn printer types pre-defined by SAP, these print controls are generally as follows:
TRY01 - Select first paper tray
TRY02 - Select second paper tray (if available at printer)
TRY03 - Select third paper tray (if available at printer)
TRYEN - Print envelopes (if available at printer)
TRYMN - Switch the printer to manual paper feed (if available at printer).
The printer pauses until you feed a sheet of paper into it.
TRYMES - Witch the printer to manual envelope feed (if available at printer).
The printer pauses until you feed an envelope into it.
See the spool system (transaction SPAD) to check on how your printers are defined.
- Print mode : With !rint mode, you can specify single or double sided printing for a
page. You can choose from the following values:
' ' : Currently active printing mode continues unchanged.
S : The page is printed in simplex mode. That is, the printer should print on only one
side of the paper.
D : The page is printed on the first side of a sheet in duplex mode (double sided).
T : The page is printed on the first side of a sheet in tumble duplex mode. That is,
the printer prints on both sides. The page on the second side is always inverted,
so that footer of the second page is printed opposite the header of the first page.
Ìf another mode was previously active, then the printer is switched to corresponding
mode with the start of the page.
· Page Windows : The page window component exists only for the alphanumeric Form
Painter. The graphical Form Painter uses a separate design window for the page
layout. When you define page windows, the window names are linked to page names.
You must specify the position and size of the window on the assigned page. Define
the position of a window by specifying the left margin and upper margin and the size
of a window by specifying its width and height.
Note that the width of the main window must be the same on all pages. All other
window types can have different sizes and positions on different pages. To print
multiple columns, define several main windows on a page. As text entry is continuous,
once the first main window has been filled, output continues in the second main
· Text EIements : You can define text elements (window texts) for each window.
Choose dit ->Tet elements. The print program accesses text elements by name,
formats them and prints them in the respective window. That is, the program can
decide which text elements should be printed in a particular window. Ìt calls these text
elements by name to print them. You must therefore change text element names in
the print program if you make any changes to text element names in a form. Ìn the
layout of a text element, you can use only the paragraph and character formats
defined in the form. At the start of a window, you can define a text element without the
/E command in the paragraph format column. This text is always printed at the start of
the window. Ìt is not necessary to insert this text explicitly via a print program. The /E
in the tag column is used to identify the text as a text element
· Main Window : Ìn the definition of page windows you can define several main
windows per page. However, you must first specify an area for the main windows.
Edit->Main Window. This function allows you to output text either in columns as in
newspapers, or next to and below each other as in label printing. You can specify the
size and position of this area under the group heading Area:
Left margin : Amount of space from the left border of the page
Right margin : Amount of space from the right border of the page
Area width : Width of the area (required entry)
Area height : Height of the area (required entry)
To position several main windows in this area, you must assign values to the
variables under the group headings Horizontal and 'ertical. Under the group heading
Spacing : Horizontal spacing of the main windows
Number : Number of main windows (horizontal)
Under the group heading 'ertical, enter
Spacing : Vertical spacing of the main windows
Number : Number of main windows (vertical)
The field $tart position under the group heading !ositions is a counter for the main
windows defined in a page window. You can use this counter to number the columns.
Always enter a value greater than or equal to 1 for the counter $tart position. Ìf you
change the counter of the form main window, the form main window can no longer be
distinguished from the main windows of the page window.
· To display the versions of a form, choose &tilities -> 'ersions.
· IncIuding Graphics : You can include graphics ÷ such as diagrams or charts ÷ in
your SAPscript documents. Typically, such graphics are included in documents by
way of forms. Graphics are uploaded either in "Baseline TÌFF 6.0" format (file
extension .tif on PC files) or as printer macros. A printer macro in this case is the
sequence of printer instructions needed to print out a diagram. Graphics and printer
macros are uploaded with program RSTXDM into individual standard text
documents. At upload, the graphics or printer macros are converted to the format
required by the target printer, either PostScript, PCL-5 for newer Hewlett-Packard and
compatible printers, or PRESCRÌBE for Kyocera printers. The resulting SAPscript
document can be printed only on the target printer type. Online display is not possible.
Ìn a form, you might include graphics such as a company logo in the header window.
You can accommodate printing on different types of printers with separate includes for
each format in which you have uploaded graphics. Ìf you define the includes as text
elements, then your print program can select the appropriate include depending upon
the device type of the printer that the user selects. You can determine the device type
by looking up the printer name in table TSP03 (field PADEST) and evaluating the
device type (field PATYPE). For more information, see the report documentation for
RSTXLDMC. Using graphics in forms can greatly increase the size of print requests
and therefore seriously affect the performance of your printers.
· StyIes (SE72) : The procedure for copying and modifying the styles is similar to
that of forms. To display the different versions of a style, choose Utilities -> Versions.
Ìn a style you can define character and paragraph formats that you want to use
independently of forms. The SAP System provides styles, for example, for mail
messages and for online documentation. You can assign a style to any SAPscript
text. Ìf you do this, the text in the main window is formatted according to paragraph
and character definitions of the style, not the form. Any format definitions in the form
are unavailable for use.
· Design TooIs: SAPscript offers two methods for designing your forms: the
alphanumeric Form Painter and the graphical Form Painter. The graphical version
allows you to easily and intuitively design your forms, starting with Release 4.0.
However, you can use the graphical Form Painter only if your frontend is equipped
with the 32bit operating system Windows95 or WindowsNT.
· Inserting Graphics :
1. Storing Graphics as Text (obsolete), choose insert -> graphics
2. Storing Graphics on the Document Server, choose insert -> graphics
3. To insert *.tiff graphics, choose insert -> graphics ->Ìmport.
4. Use program RSTXDM to convert *.tiff graphics to standard text and include it.
5. Use the SAPscript raphics Administration to import, administer, transport, and
preview graphics before printing. Ìn the navigation tree, you can go to any imported
graphic. Up to Release 4.6, the graphics were stored as standard texts. This is
obsolete now. As of Release 4.6, graphics are stored on a document server. Ìn
addition to *.TÌF files, you can now import *.BMP graphics files as well.
SAPscript ontroI ommands
The purpose of control commands is to allow control of the output formatting. These
commands are not interpreted by the SAPscript editor, but are passed through to the
SAPscript Composer for processing. The Composer is the program that converts text
from the form displayed in the editor to the form used for printing. This includes, for
example, line and page formatting, the replacement of symbols with their current values
and the formatting of text according to the paragraph and character formats specified.
SAPscript control commands are entered and edited in the text editor in the same way
as a normal line of text. They do, however, differ from normal lines of text:
· Enter the paragraph format /: in the format column to identify a control command.
· Enter the command itself in the text line. You will notice that all key words and other
parts of the specification not given as literal values enclosed in inverted commas are
automatically converted to capital letters.
· Make sure that a control command, together with any parameters it requires, does not
occupy more than a single line.
· Enter only one control command in each line.
· Note that the editor formatting has no effect on lines containing control commands.
· Ìf a control command is unknown or it contains syntax errors, the line containing it is
treated as a comment line. Ìt is neither interpreted nor printed.
1. NEW-PAGE : SAPscript automatically inserts a page break when the main window
of a page (MAÌN) is full. You can use the NEW-PAGE command to force a page
break in the text at any point you want one. The text following this command then
appears on a new page. The page break is always performed (it is an unconditional
page break). The NEW-PAGE command completes the current page. This means
that all the windows that are still on the page are printed immediately. Ìf you use the
NEW-PAGE command without parameters, the page defined in the current form as
the next page will be taken next. Ìf, however, your form contains a number of different
pages, then you can specify any one of these as the next page to be used.
/: NEW-PAGE [page_name]
Ìf, in a NEW-PAGE command, you specify a page not contained in the form, the
specification is ignored. Take care that there are no blank lines immediately before a
NEW-PAGE command. Ìf an implicit page break occurs within the blank lines, an
unexpected blank page may be printed.
2. PROTET : To allow you to define the areas to be protected against a page break on
an individual basis, SAPscript provides the PROTECT.. ENDPROTECT command
pair. Ìf you enclose the text to be protected in these commands, then SAPscript will
ensure that each line of this text is printed together on the same page. Ìf the complete
text fits in the space remaining on the current page, then it is printed on this page just
as it would be if no PROTECT command had been used. Ìf, however, the remaining
space is not sufficient for the text, then the PROTECT command has the same effect
as a NEW-PAGE command and text is printed on a new page as a kind of conditional
NEW- PAGE command. This command pairs cannot be nested.
3. NEW-WINDOW : Each page can consist of up to 99 main windows. Each main
window is assigned a consecutive identifying number (0..98), and the windows are
filled in this order. This feature enables SAPscript to print labels and to output multi-
column text. When one main window fills up, the next main window on that page is
taken, if there is a next one. A page break is inserted after the last main window.
You can use the NEW-WÌNDOW command to call the next main window explicitly,
even if the current main window is not yet full. Ìf you are in the last main window of the
page, the command has the same effect as the NEW-PAGE command.
4. DEFINE : Text symbols acquire their values as a result of explicit assignment. To
interactively assign text symbols, in the text editor choose Include->$ymbols->Tet.
This method is available for all text symbols belonging to a text module as well as
those of the associated form. Values defined in this way are lost when the transaction
is left. Ìf you want to print the text module again, then you must enter the symbol
values again. The purpose of the DEFÌNE command is to provide a means of making
this value assignment a permanent part of the text, so that the values are available
again when the text module is called again. This command can also be used to re-
assign a new value to a text symbol half-way through the text.
/: DEFINE &symboI_name& = 'vaIue'
Ex. /: DEFÌNE &subject& = 'Your letter of 7/3/95'
The value assigned can have a maximal length of 60 characters. Ìt may itself contain
other symbols. A symbol contained within the value assigned to another symbol is not
replaced with its own value at the point at which the DEFÌNE command is executed.
Rather, this replacement is made when the symbol defined in the DEFÌNE command
is called in the text.
Ex /: DEFÌNE &symbol1& = 'mail'
/: DEFÌNE &symbol2& = 'SAP&symbol1&'
/: DEFÌNE &symbol1& = 'script'
&symbol2& -> SAPscript
Ìf, however, the DEFÌNE command is written using the ':=' character rather than the '='
character, then any symbol contained within the value being assigned is replaced
immediately with its current value. The assignment to the target symbol is made only
after all symbols in the value string are replaced with their values. The total length of
the value string may not exceed 80 characters. The target symbol must be a text
symbol, as before.
Ex /: DEFÌNE &symbol1& = 'mail'
/: DEFÌNE &symbol2& := 'SAP&symbol1&'
/: DEFÌNE &symbol1& = 'script'
&symbol2& -> SAPmail
5. SET DATE MAS : To define the formatting of date fields, use the SET DATE MASK
control command. Executing this command causes all subsequent date fields to be
printed using the specified format.
/: SET DATE MAS = 'date_mask'
Ìn the date mask, you can use the following codes:
DD: day (two digits), DDD: day name - abbreviated
DDDD: day name - written out in full MM: month (two digits)
MMM: month name ÷ abbreviated MMMM: month name - written out in full
YY: year (two digits) YYYY: year (four digits)
LD: day (formatted as for the L option) LM: month (formatted as for the L option)
LY: year (formatted as for the L option)
All other characters found in a date mask are interpreted as simple text and are
copied straight into the output.
Ex: Assuming the current system date is March 1st, 1997.
/: SET DATE MASK = 'Foster City, MM/DD/YY'
&DATE& -> Foster City, 03/01/97
/: SET DATE MASK = 'MMMM DD, YYYY'
&DATE& -> March 01, 1997
The date mask may be reset to the default setting by using an empty string:
/: SET DATE MASK = ' '
The abbreviated and full forms of the names of the days and months are stored in the
language dependent TTDTG table.
6. SET TIME MAS : To format time fields to your needs, use the SET TÌME MASK
control command. Executing this command causes all subsequent time fields to be
printed using the specified format.
/: SET TIME MAS = 'time_mask'
Ìn the time mask, you can use the following codes:
HH hours (two digits)
MM minutes (two digits)
SS seconds (two digits)
Ex : Assuming the current time is 10:08:12,
/: SET TÌME MASK = 'HH:MM'
&TÌME& -> 10:08
/: SET TÌME MASK = 'HH hours MM minutes'
&TÌME& -> 10 hours 08 minutes
The time mask may be reset to the default setting by using an empty string:
/: SET TÌME MASK = ' '
7. SET OUNTRY : The formatting for certain field types depends on the country
settings. These field types include, for example, date fields and number fields that
include either a decimal point or the 'thousands' separator character. The formatting
options defined in the user master record are usually the ones used here. To choose a
formatting option other than the one specified in the user master record, use the SET
COUNTRY control command. The country-dependent formatting options are stored in
the T005X table. Company code wise details are stored in T001 table.
/: SET OUNTRY country_key
You can enter the country key either as a literal value enclosed in quotes or as a
/: SET COUNTRY 'CAN'
/: SET COUNTRY &country_key&
Use a blank country name to revert to the setting found in the user master record:
/: SET COUNTRY ' ' .
8. SET SIGN : To set the sign explicitly, use SET SÌGN control command. Executing
this command affects the formatting of all subsequent program symbols that possess
a leading sign.
/: SET SIGN EFT
/: SET SIGN RIGHT
9. RESET : To reset the numbering of an outline paragraph to its initial value, use the
RESET control command. Ìf you do not use the RESET command, then numbering of
all outline paragraphs in a text is continuous. Ìf you specify the name of an outline
paragraph in the RESET command, then its paragraph numbering and that of sub-
ordinate paragraphs is reinitialized.
/: RESET paragraph_format
10. INUDE : To include the contents of another text into the current text, use the
ÌNCLUDE control command. SAPscript still treats the text to be included as a
separate text. The text is copied over only at the point at which output is formatted
so that the most current version of a text is included into the output
/: INUDE name [OBJET o] [ID i] [ANGUAGE I] [PARAGRAPH p]
You must specify the name of the text to be inserted in quotes as a literal value. You
can, alternatively, specify the name via a symbol. All remaining parameters in the
ÌNCLUDE command are optional. Ìf an optional parameter is not specified, then
SAPscript uses default values as applicable for the calling environment. The
ÌNCLUDE command returns a status code in the SAPSRIPT-SUBR symbol:
0: the text include was successful.
1: the command could not be executed because it contained syntax errors.
2: the rules governing the text to be included were not followed
4: the specified text could not be found.
The text to be included is formatted using the style allocated. The PARAGRAPH
parameter can be used to redefine the standard paragraph for this style for the current
call. All *-paragraphs in the included text will then be formatted using the paragraph
specified here. The first line of the text to be included will be given NEW-
PARAGRAPH format as long as it is not a comment or command line. Ìf no OBJECT
is specified, then TEXT will be used (standard texts) and any kind of text can be
included in a form. Ìn the case of a document text (DOKU object), you can include
only document texts. Only hypertexts and document texts can be included in a
hypertext (DSYS object). The text ÌD is a part of the text key, which permits further
text objects within a given object. Ìf no ÌD is specified, then the default include ÌD is
used from the TTXÌD table for the calling text. Ìf there is no entry in this table, then the
text ÌD of the calling text is used.
11. STYE : The STYLE control command allows you to change the style within a text.
The new style is in force until another STYLE command is issued. Ìf you specify * as
the name of the style, then the system reverts to the default paragraph of the original
style or form. Dominant will effect the text included with ÌNCLUDE.
/: STYE styIe [DOMINANT] OR /: STYE *
12. ADDRESS :
/: ADDRESS [DEIVERY] [TYPE t] [PARAGRAPH a] [PRIORITY p] [INES I]
/: TITE title
/: NAME name1[,name2[,name3[,name4]]]
/: PERSON name of natural person [TITE form of address]
/: PERSONNUMBER number of the person
/: DEPARTMENT department
/: STREET street name HOUSE house number
/: OATION additional location information
/: POBOX po box [ODE post code / zip code] [ITY city]
/: POSTODE post code / zip_code
/: ITY city1[,city2]
/: REGION county / state
/: OUNTRY recipient country [ANGUAGE language code]
/: ANG_FOR_OUNTRY language key
/: FROMOUNTRY sender country
/: ADDRESSNUMBER address number
The ADDRESS - ENDADDRESS control command formats an address according to
the postal convention of the recipient country defined in the COUNTRY parameter.
The reference fields are described in the structures ADRS1, ADRS2, or ADRS3,
depending on the type of address. Either direct values or symbols may be assigned to
the parameters. Refer SAP function module ADDRESS_ÌNTO_PRÌNTFORM. Ìf
DELÌVERY is not specified and if a POBOX is specified, then the POBOX is used in
an address instead of a STREET.
- DELÌVERY : Means that the address should be formatted as a complete delivery
address, using the street name and number rather than the P.O. Box.
- TYPE : Specifies the type of address. The following types are possible:
ADRS1 : This is the default address of a company or organization , expected in
most SAP applications.
ADRS2 : This is the address of a natural person, a private or home address.
ADRS3 : This is the address of a colleague or contact within a company .The
company name should be specified in the TÌTLE & NAME fields; the
ATTN: contact person should be named in PERSON and TÌTLE.
- PARAGRAPH: Specifies the paragraph format to be used for outputting the address.
Ìf this parameter is not given, address will be output using default paragraph format.
- PRÌORÌTY : Specifies which of the address lines may be omitted. Any combination of
the following codes may be specified.
A -Title P - Mandatory empty line 4 - Name4
3 - Name3 R - Region T - Neighborhood, administrative section of a city (CÌTY2)
D - Department L - Country name C - Post code or zip code 2 - Name2
B - P.O. Box (Japan only) S - Street or POBox, depend upon DELÌVERY parameter
N - Name and form of address of natural person (PERSON and TÌTLE)
Ì - Location information in LOCATÌON O ÷ City
- LÌNES : Specifies how many lines may be used for formatting the address. Ìf there are
too few lines available to allow all the address data to be formatted, then the data
specified in the PRÌORÌTY parameter are omitted.
- TÌTLE : Title or form of address. Used only with addresses of types 1 and 3.
- NAME : Up to four names may be given, separated by commas. Used only with
addresses of types 1 and 3.
- PERSON : Name of the addressee. Used only for addresses of type 2 or 3.
- PERSONNUMBER : Personal number. Can be used only for address types 2 or 3.
- TÌTLE (with PERSON) : Title of the addressee. Can be used only for address types 2
or type 3 (private or personal address).
- DEPARTMENT : Department of the addressee. Can be used only for address type 3
- STREET : Street name.
- HOUSE : House number for the corresponding street.
- LOCATÌON : Additional location information, such as the building, apartment etc.
- POBOX : P. O. Box
- CODE : The post code / zip code of the P. O. Box if this differs from the post code /
zip code of the recipient.
- CÌTY : City in which destination P.O. Box is located if this differs from recipient city.
- POSTCODE : Post code / zip code of the recipient.
- CÌTY : Addressee's city. city1 is expected to be the city; city2 is the neighborhood or
administrative section, if required.
- NO_UPPERCASE_FOR_CÌTY: Usually, the system prints the city and country
names of foreign addresses in uppercase ( NO_UPPERCASE_FOR_CÌTY ' ' ).
You can use this parameter to force the system to output city and country name
unchanged (uppercase/lowercase) ( NO_UPPERCASE_FOR_CÌTY 'X' ).
- REGÌON : This allows an administrative region, county, province, or state etc. to be
- COUNTRY : Specifies the recipient country.
- COUNTRY_ÌN_REC_LANG : This flag tells the system to use the recipient language
for the country name. ( COUNTRY_ÌN_REC_LANG 'X' ).
- LANG_FOR_COUNTRY :Default = Space. Use this parameter to explicitly set the
language in which to print the country name of a foreign address. By default, the
system uses the language of the sending country.
- LANGUAGE : Language code of the language of the recipient country, if it differs
from that of the recipient COUNTRY.
- FROMCOUNTRY : Specifies the language to be used for formatting the name of the
- ADDRESSNUMBER: The number is used to index a central address file, from which
desired address is read instead of using set of the above fields.
13. TOP : You can use the TOP.. ENDTOP control command to specify lines of text that
you want to print always at the top of the main window so that the table heading
information were repeated at the start of each new page of output.
The lines of text enclosed between the two control commands will be output from now
on at the start of the main window. Ìf the main window already contains some output
then a newly specified header text takes effect on the next page only. An existing
header text can be disabled by using the TOP.. ENDTOP command pair without
enclosing any text lines between the two command lines.
14. BOTTOM : You can specify footer texts for the main window in a similar way to
header texts. Footer texts are always printed at the bottom of the main window.
An existing footer text can be disabled by using the BOTTOM.. ENDBOTTOM
command pair without enclosing any text lines between the two command lines.
Assuming there is still sufficient space in the main window, a newly specified footer
text will also be printed on the current page.
15. IF : Ìf the logical expression contained within the ÌF command is true, then the text
lines enclosed by the ÌF... ENDÌF command pair are printed. Otherwise they are
/: IF condition
/: ESEIF condition
The logical expression can use comparison operators (= EQ,< LT,> GT,<= LE,>= GE,
<> NE). The logical operators can be used to combine conditions (NOT,AND,OR).
Evaluation of both the individual logical expressions and of the combinations of
expressions is performed strictly from left to right. There are no precedence rules.
Bracketed expressions are not supported. You must not extend a condition over more
than one line. You can nest ÌF commands. The comparison is always performed on
literal values, that is, the symbols are formatted as character strings before they are
16. ASE : The CASE command covers a special case of the multiple case ÌF
command. Rather than allowing an arbitrary condition to be tested in each of the
individual cases (as in the general multiple case ÌF command), the CASE command
allows a given symbol to be tested against specific values until a matching value is
/: ASE symboI
/: WHEN vaIue1
/: WHEN vaIue2
/: WHEN OTHERS.
The symbol in the CASE line is formatted. Ìf its value is found in one of the WHEN
lines, then the text lines following this WHEN line are printed. Ìf no matching value is
found then the text lines enclosed by the WHEN OTHERS line and the ENDCASE
command are printed. The WHEN OTHERS section is optional.
17. PERFORM : You can use the PERFORM command to call an ABAP subroutine
(form) from any program. You can use such calls to subroutines for carrying out
calculations, for obtaining data from the database that is needed at display or print
time, for formatting data, and so on. PERFORM commands, like all control
commands, are executed when a document is formatted for display or printing.
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
/: USING &INVAR2&
/: HANGING &OUTVAR1&
/: HANGING &OUTVAR2&
ÌNVAR1 and ÌNVAR2 are variable symbols and may be of any of the four SAPscript
symbol types. OUTVAR1 and OUTVAR2 are local text symbols and must therefore be
character strings. The ABAP subroutine called via the command line stated above
can be defined in the ABAP report prog as follows for example:
FORM <form> TABES IN_TAB STRUTURE ITSY OUT_TAB STRUTURE
DATA: X TYPE I,Y TYPE I.
READ TABE IN_TAB WITH EY 'INVAR11'.
HE SY-SUBR = 0.
X = IN_TAB-VAUE.
Y = X MOD 10.
READ TABE OUT_TAB WITH EY 'OUTVAR1'.
HE SY-SUBR = 0.
OUT_TAB-VAUE = Y.
The values of the SAPscript symbols passed with /: USÌNG... are stored in the internal
table ÌN_TAB . The internal table OUT_TAB contains names and values of the
CHANGÌNG parameters in the PERFORM statement which are local text symbols.
18. PRINT-ONTRO : You can use this command to call certain printer functions from
a SAPscript text. Although you cannot enter control characters for the printer directly in
your text, you can define a print control via the spool maintenance transaction SPAD
that contains the printer commands you want. You can then call a print control using
the PRÌNT-CONTROL SAPscript command.
/: PRINT-ONTRO name
Specify the name of the print control either with or without inverted commas. The print
control printed via PRÌNT-CONTROL should always be a print control created in the
customer name area (Zxxx) for the device type used. After executing a PRÌNT-
CONTROL command, SAPscript inserts a space character at the start of the next text
line. Ìf you do not want this, you should give this text line the '=' paragraph format.
19. Using Boxes, ines, and Shading : The BOX command for drawing a box or a
horizontal or vertical line. The POSÌTÌON command for specifying the starting point
(the upper left corner) of a box or line. The SÌZE command for specifying the width
and height of a box. You can use POSÌTÌON and SÌZE to preset arguments, but you
can also set the start point and size arguments of a box or line directly in the BOX
command. By default, the height and width of a box are set to the height and width of
current window and the upper left corner of a box is aligned with current SAPscript
window. Use POSÌTÌON and SÌZE to preset the arguments in a BOX command if
BOX command exceeds the 132-character (1 line in SAPscript) length limitation if you
specify all arguments directly in the BOX command. You may exceed this length limit
if, for example, you use symbols in a command. The following calculation is
performed internally to determine the absolute output position of a box on the page:
X(abs) = XORÌGÌN + XPOS
Y(abs) = YORÌGÌN + YPOS
1. /: BOX XPOS '1' CM YPOS '1' CM
With BOX, you can specify an offset for the starting point only as a whole number .
2. /: POSÌTÌON XORÌGÌN '-.2' CM YORÌGÌN '-.2' CM
/: SÌZE WÌDTH '+.2' CM HEÌGHT '+.2' CM
/: BOX FRAME 10 TW
Ìn the POSÌTÌON command, you can specify positive and negative offsets and use
3. /: POSÌTÌON PAGE
/: POSÌTÌON XORÌGÌN 1 CM YORÌGÌN 1 CM
/: SÌZE PAGE
/: SÌZE HEÌGHT '-2' CM WÌDTH '-2' CM
/: BOX FRAME 10 TW
You can also use POSÌTÌON to set the starting point to the upper left corner of
active page format. POSÌTÌON PAGE moves the starting point from the active
window to the active page format. This command draw a frame 1 CM in from the
margins of the paper:
4. /: POSÌTÌON YORÌGÌN '-0.2' CM
/: SÌZE HEÌGHT '+0.2' CM
/: BOX Ì NTENSÌTY 5
The box starts 0.2 CM above the top of the window. the SÌZE command increases
height of box by 0.2 CM to accommodate positioning of box above the window.
5. /: BOX FRAME 10 TW WÌDTH 0 TW HEÌGHT '10' CM
Vertical line 10 CM long
6. /: BOX FRAME 10 TW WÌDTH '10' CM HEÌGHT 0 TW
Horizontal line 10 CM long
7. /: BOX WÌDTH '17.5' CM HEÌGHT '13.5' CM FRAME 10 TW
/: BOX WÌDTH '17.5' CM HEÌGHT 1 CM FRAME 10 TW ÌNTENSÌTY 15
/: BOX XPOS '10.0' CM WÌDTH 0 TW HEÌGHT '13.5' CM FRAME 10 TW
/: BOX XPOS '13.5' CM WÌDTH 0 TW HEÌGHT '13.5' CM FRAME 10 TW
This commands draw a table. The vertical lines in the table are drawn in at 10 CM
and 13.5 CM from the left edge of the window. Adjust the tabs in a window to
match the position of lines and boxes. The following conversion factors apply:
1 TW = 1/20 PT , 1 PT = 1/72 ÌN ,1 ÌN = 2.54 CM , 1 CM = 10 MM
1 CH = height of a character relative to the CPÌ specification in the form header
1 LN = height of a line relative to the LPÌ specification in the form header
1. /: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]
2. /: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]
3. /: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]
20. HEX, ENDHEX : Use this command to send printer commands in a printer language
directly to a printer that supports that language. SAPscript does not interpret the data
enclosed by the HEX and ENDHEX command pair, but inserts it unchanged into the
output stream. This technique allows objects with a pixel-oriented format (for example,
graphics) to be printed as part of a SAPscript text. The characters 0 to 9 and A to F
for representing the values 10 to 15 are valid hexadecimal characters. The text may
also include comment lines /* which will not be interpreted as hexadecimal data but
are simply passed over by formatting routines.
/: HEX [TYPE printer_Ianguage] [XPOS x_position] [YPOS y_position]
[HEIGHT height] [EFT Ieft_indentation]
The HEX command denotes the start of the hexadecimal data. Ìf the TYPE parameter
is present, the data will be sent to the printer only if the printer understands the
specified printer language. The following printer languages are currently supported:
POST (Postscript), PRES (Kyocera Prescribe) & PCL (HP Printer Control Language).
The output cursor is set to the absolute position indicated by the specified X and Y
position parameters before the hexadecimal data is printed. Ìf either the X or the Y
position is not specified, then 0 will be assumed for this parameter. The HEÌGHT
parameter determines the amount of space to be reserved on the page for the
output of the hexadecimal data. Ìf the LEFT parameter is also specified, then output of
hexadecimal data will is indented from left margin by specified amount. You can use
the RSTXLDMC program to upload correctly formatted pixel data to the R/3
system and to prepare it as a HEX-ENDHEX control command. This can then
be saved as normal SAPscript text.
/: HEX TYPE P HEIGHT '7.5' M EFT '2.25' M
/* reator: report ZQVNTE30 date 19940705 time 125129 user SAPSRIPT
21. SUMMING : The SUMMÌNG command is used for accumulating a total value for a
program symbol. The command should be specified just once. Then, each time the
specified program symbol is formatted, its current value is added into the total symbol.
Several program symbols may all be added into a single total symbol.
/: SUMMING program_symboI INTO totaI_symboI
SAPscript cannot create the field for the total dynamically. The summing symbol used
for totalling and the accompanying program symbol(s) must be declared with TABES
in the ABAP program. Otherwise, only zero is added. Declaring the symbol with the
DATA statement is not sufficient (global data).
· SAPscript symbols are the placeholders They represent data that will not be added to
the text until a later point. This is normally the point at which the output is formatted. All
symbols occurring in the text are then replaced with their current values. This
replacement is performed only in the output text. SAPscript recognizes four different
kinds of symbols:
1. System symboIs 2. Standard symboIs 3. Program symboIs 4. Text symboIs.
The main difference between these is the source of their values. SAPscript provides
values for the system symbols. Standard symbols and their values are defined in the
TTDTG table. Program symbols represent data supplied by the program that is
currently executing. The values for text symbols come either from control commands
in the text itself or are supplied dynamically by the Include function in the text editor.
· Syntax of Symbols:
- Use the delimiter & both immediately before and after the symbol.
- Do not use blank characters in the name of a symbol. Moreover, since the characters
'+() are used for defining formatting options, you must not use any of these a symbol
- Make sure that no SAPscript editor line break occurs between the symbol delimiters.
Ìf necessary, use a long line to avoid this (paragraph format = or /=).
- Enclose additional formatting options in round brackets and insert them immediately
after symbol name. Code letters identifying these options must be given in capitals. A
symbol name can contain a maximum of 130 characters. However, only the first 32
characters are used for unique identification.
You can use system symbols in all kinds of text. SAPscript supplies the values for
system symbols. The names of the system symbols are fixed.
1.urrent Date : The current date is displayed. Ìt is formatted according to the
specifications found in the user master data. You can adapt this format to your own
requirements by specifying a date mask (SET DATE MASK) or by using a country-
specific formatting option (SET COUNTRY). The current value for this symbol is taken
from the SY-DATUM field.
Syntax : &DATE&
2. urrent Day Number : The current day number is printed. The display includes
Syntax : &DAY&
3. urrent Month Number : The current month number is printed. The display includes
Syntax : &MONTH&
4. urrent Year Number : The current Year number is printed. The display includes
Syntax : &YEAR&
5. urrent Day Name: The name of the current day is written out in full.
Syntax : &NAME_OF_DAY&
6. urrent Month Name: The name of the current month is written out in full.
Syntax : &NAME_OF_MONTH&
7. urrent Time : The current time is printed in the form hours:minutes:seconds. You
can adapt this format to your own requirements by specifying a time mask (SET TÌME
MASK). The value for the time field is taken from the SY-UZEÌT field.
8. Hours omponent of urrent Time : The component of the current time referring to
hours is printed. The display includes leading zeros.
Syntax : &HOURS&
9. Minutes omponent of urrent Time : The component of the current time referring
to minutes is printed. The display includes leading zeros.
Syntax : &MINUTES&
10. Seconds omponent of urrent Time : The component of the current time
referring to seconds is printed. The display includes leading zeros.
Syntax : &SEONDS&
11. urrent Page Number: You can use this symbol to insert into the text the page
number that the current page will have when printed. You can specify
the formatting option for the page number
Syntax : &PAGE&
12. Page Number of the Next Page : This symbol is used to print the
number of the following page. The output format is the same as with &PAGE& . Note
that on the last page of the output, in each window that is not of type MAÌN,
&NEXTPAGE& has the value 0.
Syntax : &NEXTPAGE&
13. SeIected Device Type : The &DEVÌCE& symbol is used to print the type of the
output device. This type is passed in the DEVÌCE parameter when the SAPscript
output (OPEN_FORM, PRÌNT_TEXT) is started, and it specifies the device for which
the output should be formatted. Possible values are:
ABAP (ABAP list display)
Syntax : &DEVIE&
14. Spaces : You can use this symbol to generate a string of space characters. You
must pass the number of space characters required with the symbol. Ìf you leave out
the number, then no spaces are printed.
Syntax : &SPAE&
15. UnderIine : You can use this symbol to insert a string of underline characters into
the output text. You must pass the number of underline characters required with the
symbol. Ìf you leave out the number, then just one underline character is printed.
Syntax : &UINE&
16. VerticaI ine : You can use this symbol to insert a string of vertical line characters
into the output text. You must pass the number of vertical line characters required with
the symbol. Ìf you leave out the number, then just one vertical line character is printed.
Syntax : &VINE&
· For printing the program symbols, SAPscript uses the WRÌTE statement of the ABAP
programming language. The effect of this statement is controlled externally via
parameters (such as specifications in the user master record, table T005X), depending
on the data type. Ìf a program symbol is not printed in the way you expected it, first
check whether the control parameters stated above are set correctly.
· The value of a program symbol is limited up to a maximum of 255 characters.
· When SAPscript encounters a symbol, it checks it by following hierarchy
- System Symbol
- Program Symbol (Tables statements)
- Standard Symbol (TTDTG Table)
- Program Symbol (DATA, CONSTANTS, ÌNFOTYPE, PARAMETER)
- Text Symbol
· Text symbol will be preferred over the same name program symbol.
· System Fields in the ABAP Programming Environment : You can refer to all the fields
in SYST structure. You should, however, note that some of the fields are specific to a
certain environment. They contain values that do not come from your application but
have been set by the SAPscript programming environment (for ex., SYST-REPÌD).
· User Address Data : USR03 table contains information from the user master
record for a given user
- Business address
- Telecommunication (telephone, telefax)
- Other data such as user language, department, cost center.
You can maintain the contents of these fields in the 'Address' section of the user
maintenance. Ìf this table exists in the calling program, then SAPscript copies the data
from the work area of this program. Otherwise, SAPscript uses the values for the
currently active user.
· General SAPscript Fields : You can print the following fields of structure SAPSRIPT
as program symbols in SAPscript forms:
1. &SAPSRIPT-SUBR& : Receives a value after executing an ÌNCLUDE statement.
The value shows whether the ÌNCLUDE was found or not. ÌNCLUDE was found:
&SAPSCRÌPT-SUBRC& = 0, ÌNCLUDE was not found: &SAPSCRÌPT-SUBRC& = 4.
2. &SAPSRIPT-DRIVER& : SAPscript formats a text for a specific output device. The
initial formatting is independent of the specific language of this device. SAPscript then
calls a driver to convert the device-independent format to device-specific control
commands. This field contains the name of the driver. The available drivers are stored
in table TSP09.
POST - Postscript driver
HPL2 - HP Laserjet driver for the PCL4/PCL5 languages
PRES - Driver for output devices using the PRESCRÌBE language
3. &SAPSRIPT-FORMPAGES& : This field contains a number representing the total
number of pages of the currently formatted form (any output between START_FORM
and END_FORM). The page counter mode (START, ÌNC, HOLD) of the individual
pages is ignored. You can use this symbol to formulate information like 'Page x of y'.
4. &SAPSRIPT- JOBPAGES& : This field contains a number representing the total
number of pages of all forms contained in the currently formatted print request, in other
words, of all forms created using the OPEN_FORM, START_FORM.. ENDFORM,
START_FORM.. END_FORM,..., CLOSE_FORM function modules.
5. &SAPSRIPT-OUNTER_x& (x = 0.. 9) : These fields represent ten counter
variables that you can use in your text and forms for any counting purposes. You can
use the '+' and '-' formatting options to increment or decrement a counter before its
value is printed. You can use the DEFINE control command to assign any specific
value to a counter. Ìf you want to change the value of a counter variable without
actually printing the new value, use this formatting option together with an additional
option to set the output length to 0 .
Assume that &SAPSCRÌPT-COUNTER_1& initially has the value 2.
&SAPSCRÌPT-COUNTER_1& -> 2
&SAPSCRÌPT-COUNTER_1(+)& -> 3
&SAPSCRÌPT-COUNTER_1(-)& -> 2
&SAPSCRÌPT-COUNTER_1(-)& -> 1
&SAPSCRÌPT-COUNTER_1(+)& -> 3
6. &SAPSRIPT-TEEAND& : This field contains the country key of the fax target
address when using fax output via SAPscript (field ÌTCPO-TDTELELAND of parameter
OPTÌONS of function module OPEN_FORM).
7. &SAPSRIPT-TEENUM& : This field contains the local fax number of the fax target
address when using fax output via SAPscript (field ÌTCPO-TDTELENUM of parameter
OPTÌONS of function module OPEN_FORM).
8. &SAPSRIPT-TEENUME& : This field contains the complete fax number of the fax
target address when using fax output via SAPscript (field ÌTCPO-TDTELENUME of
parameter OPTÌONS of the function module OPEN_FORM).
Standard symbols are defined in table TTDTG. This table contains both the name of
each symbol and its value. The value, which is language-dependent, can contain up to
60 characters. SAP supplies this table filled with standard entries. You can extend it
with customer-specific symbols. You can use standard symbols in all kinds of text.
All symbols that do not correspond to one of the three types of symbols described
above are text symbols. You define the value of a text symbol yourself in the text
module. There are two ways of doing this:
· Ìn the text editor, choose nclude -> Symbols ->Text.
All the text symbols contained either in the current text or in a form assigned to the
text are displayed. You can assign a value of up to 80 characters to a text symbol.
Enter this value in the same form as it is to appear in the output. The effect of
assigning a value is temporary, since the values assigned are not stored with the text
but are lost as soon as you leave the editor. You use this kind of value assignment if
you had a ready-made text containing symbols that you want to print with specific
values in place of the symbols, and you want to do this only once without storing the
· Ìn the text, use the control command DEFINE.
Since control commands are stored with the text module, any value you assign in this
way is preserved when you save the text. You can change the value assigned to a
symbol in the text at any time simply by issuing another DEFÌNE command.
Remember always to use the ' (inverted comma) character to delimit a value. The
maximal length for these values is also 80 characters.
The value of a symbol is normally printed using its full length, although trailing spaces
are removed. An exception are program symbols of these data types: CURR, DEC,
QUAN, ÌNT1, ÌNT2, ÌNT4, PREC, and FLTP. These are formatted right-justified with an
output length as specified in the Dictionary.
1. Offset : Specifying an offset has the effect that a certain number of bytes of the
symbol value, starting with the first byte on the left, will not be displayed. Ìf the offset
specified is greater than the length of the value, nothing is printed.
Syntax : &symboI+offset&
2. Output ength: Ìf you need only a part of symbol value, you can use an output length
specification to define how many bytes of value should be copied.
Syntax : &symboI(Iength)&
You can combine an output length specification with an offset specification. You can
use the character * to specify the length of a program symbol. The value of the symbol
is then printed using the output length defined in the ABAP Dictionary.
3. Omitting the eading Sign :
Syntax : &symboI(S)&
4. eading Sign to the eft : The leading sign is normally displayed to the right of a
numeric value, except in the case of a floating point number. This option enables you to
specify that the leading sign should be placed to the left of the number.
Syntax : &symboI(<)&
The SET SÌGN LEFT control command specifies that all subsequent symbols with a
numeric value should have a left-justified leading sign.Ìf you use this control command,
you must no longer repeat the < option for each individual symbol.
5. eading Sign to the Right : The default setting is to print the leading sign to the right
of a numeric value. Ìf you used the SET SÌGN LEFT control command to specify that
the leading sign should be printed in front of the value, you can override this
specification for individual symbols. The symbols specified with the > option are then
printed with the leading sign to the right.
Syntax : &symboI(>)&
You can use the SET SÌGN RÌGHT control command to switch back to the default
setting for the output of the leading sign.
6. Omitting eading Zeros : Certain symbol values are printed with leading zeros. Ìf
you want to suppress these, use the Z option.
Syntax : &symboI(Z)&
7. Space ompression : The C option has the effect of replacing each string of space
characters with a single space and shifting the 'words' to the left as necessary to close
up the gaps. Leading spaces are completely removed. The results are the same as
those of the ABAP command CONDENSE.
Syntax : &symboI()&
8. Number of DecimaI PIaces : A program symbol of one of the data types DEC,
QUAN, and FLTP can contain decimal place data. Use the option below to override
Dictionary definition for number of decimal places for formatting of this symbol value.
Syntax : &symboI(.N)&
9. Omitting the Separator for 'Thousands' : The T option allows you to omit the
separator character of numeric field.
Syntax : &symboI(T)&
10. Specifying an Exponent for FIoating Point Numbers :
Syntax : &symboI(EN)&
For Example, PLMK-SOLLWERT field is assumed to have the value 123456.78
and to be of data type FLTP.
&PLMK-SOLLWERT& -> +1.23456780000000E+05
&PLMK-SOLLWERT(E3)& -> +123.456780000000E+03
&PLMK-SOLLWERT(E6)& -> +0.12345678000000E+06
&PLMK-SOLLWERT(E0)& -> +123456.780000000
&PLMK-SOLLWERT(E)& -> +123456.780000000
11. Right-Justified Output : Symbol values other than numeric values are normally
formatted left-justified. To specify right-justified formatting, use the R option. You must
use this option in conjunction with an output length specification.
Syntax : &symboI(R)&, &symboI(8R)
12. FiII haracters : You can replace leading spaces in a value with a fill character. Use
the F option with the fill character.
Syntax : &symboI(F f )& where f is a fill character
Ex : The figure for customer sales in the KNA1-UMSAT field is $700. The Dictionary
description of the field specifies an output length 8.
&KNA1-UMSAT& -> 700.00
&KNA1-UMSAT(F*)& -> **700.00
&KNA1-UMSAT(F0)& -> 00700.00
13. Suppressing Output of InitiaI VaIues : Use the Ì option to suppress the output of
symbols that still contain their initial values.
Syntax : &symboI(I)&
14. Ignoring onversion Routines : SAPscript conversion routines specified in the
Dictionary are automatically recognized and used when program symbols are
formatted. To suppress conversion, use the K option.
Syntax : &symboI()&
15. Pre-Text / Post-Text : You can specify a text to be printed immediately before the
symbol value and after the symbol value . Ìf the symbol contains its initial value, these
texts are suppressed.
Make sure that the symbol, the pre-text, and the post-text all appear on a single line of
the editor. You may have to use a long line (paragraph attribute = or /=) in the editor.
The inverted comma ' is used as a delimiter for these texts. Ìf this character is also part
of one of these texts, enter it twice at this point, so that it is not interpreted as a
delimiter character. A pre-text or post-text may itself contain symbols in addition to
normal text. However, these symbols may not have a pre-text or a post-text.
Ex :The KNA1-PFACH field contains a customer P.O.
P.O. Box &KNA1-PFACH& -> P.O. Box (Ìf it is initial)
&'P.O. Box 'KNA1-PFACH& -> (Ìf it is initial)
&'P.O. Box 'KNA1-PFACH& -> P.O. Box 123456 (Ìf it is not initial)
TrueType fonts are fonts that are not built into the printer, but that are loaded at request
from the computer into the printer memory before the actual print process starts. You
can import TrueType font files and then use these fonts for printing SAP forms. This
allows you to, for example, use your company's own fonts. You need a TrueType file
for the desired fonts (for example, myfont.ttf ), which you can load into the SAP System.
To use TrueType fonts for printing SAP forms, proceed as follows:
1. Start SAPscript font maintenance ( SE73 ). Choose Install TrueType font.
2. Enter a font name that starts with Z (for example, ZMYFONT). The system uses
this name for the TrueType font.
3. Specify the attributes of the font (normal, bold, italic, or bold and italic).
4. Enter the path and file name of the font file and choose ecute.
5. Specify the control sequence that identifies the font in Rich Text Format. The
SAPscript text editor and the graphic print preview use this information to display
the characters correctly.
6. Create a style or a form and define formats using the TrueType fonts.
7. You can print and archive forms using TrueType fonts. To print a form, use an output
device whose device type uses one ot the drivers PCL, Postscript, Prescribe, or
· You want to print labels (for example, shipping labels or barcode labels) on a special
printer. Release 4.6A allows you to create labels using an external design program
and to print them from within a SAPscript form.
· Nearly all special label printers on the market use individual control languages, for
which no printer drivers exist in the SAP Standard. To be able to address these label
printers from within the R/3 system, you use an external program to define the entire
· Refer SAP Library Help for Printing Labels on individual printer types.
Summing and arrying Forward
· You want to print the current total as carry forward amount on the current page and on
the subsequent page. Don't place the carry forward amount into the BOTTOM area.
SAPscript processes the BOTTOM area at the beginning of a page; therefore it is not
suited for carry forward amounts. Don't place the carry forward amount into the TOP
area of the main window on the subsequent page, the carry forward amount may be
higher than it should be: This happens if the last part of text of the previous page does
not fit onto the page, but the text is held together, for example, by a PROTECT
command. You must place the carry forward amount on the current page into a window
of type VAR. On the subsequent page, use a local text symbol to print the amount in
the TOP area of the main window:
· At the beginning of the form main text (before printing the first text element), define the
amount variable and the total variable
/: SUMMING &SUMTAB-AMOUNT& INTO &SUMTAB-TOTA&
/: DEFINE &ASTPAGE& = ' '
&SUMTAB-TOTAL& contains the carry forward amount of the current page or the
grand total, respectively. Also define a local symbol &LASTPAGE& to print the grand
total on the last page. At the end of the form main text (when printing the last text
element of the main window), set the local textsymbol &LASTPAGE& to a different
value, such as 'X':
/: DEFINE &ASTPAGE& = 'X'
· To print the carry forward amount in the TOP area of the subsequent page including
the pre-text 'Carry forward' and a tab, we use the local text symbol &CARRY&. The
corresponding text element is also defined in the main window:
* &'arry forward:,,' ARRY&
(CALL FUNCTÌON WRÌTE_FORM EXPORTÌNG ELEMENT = 'CARRY'
TYPE = 'TOP')
· Define the carry forward window on the current page as type VAR and position it at
the end of the main window of the page. Print the carry forward amount there and
define the local text symbol &CARRY& to print the amount again in the TOP area of
the subsequent page. Use the local text symbol &LASTPAGE& to print the grand total
on the last page. The carry forward window then contains the following text (define it
as paragraph T1 with tab):
/: IF &ASTPAGE& = 'X'
T1 <H>Grand totaI:,, &SUMTAB-TOTA&</>
T1 <H>arry forward:,, &SUMTAB-TOTA&</>
/: DEFINE &ARRY& = &SUMTAB-TOTA&
SAPscript Form Debugger
· Errors in the print program or the form that occur when printing in dialog mode (not
when printing in background mode or in the update task) can often be identified quite
easily by using the SAPscript form debugger.
· Activate the debugger by choosing &tilities ->Activate debugger in the Form: #equest
screen. You can then generate printer output in dialog.
· A dialog box containing the default breakpoints appears.
· Track each call of a SAPscript function module, each ÌNCLUDE call, and each warning
in the debugger.
· To switch off the debugger, choose ebugger -> it in the debugger window.
You use the form tree to store forms in structure nodes and thus classify them uniquely.
You can then search for them more easily. Any unclassified forms are stored in the node
&nclassified forms. The classified form is stored in the form tree. By default, there are
trees for all applications. Ìf you need new trees and new nodes in a tree, you can create
them in any system. You can add the following types of nodes:
- Form nodes for storing forms
- Structure nodes for creating new tree parts
- Reference nodes for adding existing trees for reference purposes
- Nodes for unclassified forms
You can classify forms by selecting Form ->Classify in the 2nd Form Painter screen.
You cannot classify locally stored objects. You can create, rename, delete the nodes.
Choose &tilities ->Classify multiple forms in the initial Form Painter screen . Choose
raphic ->Import, raphic ->Transport, raphic ->$creen information, raphic ->!rint
omponents of SAPscript
SAPscript comprises these five components:
· an editor for entering and editing the lines of a text. The application transactions
automatically call this editor if the user decides to maintain texts that concern an
· styles and forms for print layout. These are created independent of the individual texts
using the corresponding maintenance transactions and are allocated to the texts later.
· the composer as central output module. Ìts task is to prepare a text for a certain output
device by including the corresponding formatting information. This information comes
from the style and form allocated to the text. The SAPscript composer is invisible on
· a programming interface that allows you to include SAPscript components into your
own application programs and to control the output of forms from within the programs.
· several database tables for storing texts, styles and forms.
Text EIements of a Form
Text elements in SAPscript are the individual text components of a form. Ìn the different
windows, you can define text elements with different attributes. For printout, the print
program accesses them. Text elements are related to a window not to a page window,
that is, a print program can call for each window only those text elements that exist in
this window. To achieve good structuring and readability, you assign a fixed name to
each text element in the form. The print program then uses these names to access the
elements. You can compare text elements with text symbol in ABAP programs.
However, text elements are much flexible:
- The length of a text element is unlimited.
- Text elements may contain variable symbols.
- You can use several different formatting options within one text element.
- You can use SAPscript control statements in text elements.
Ìn each window, you may use two different kinds of text elements:
1. Text EIements with Names : You recognize named text elements by the paragraph
format /E. This name can be up to 30 characters long and may consist of letters, digits
and/or special characters. The name is followed by the text lines of this text element.
The end of a text element definition is marked by the beginning of next text element
(the next /E line). Different windows may contain text elements with the same names.
To output named text elements, you must use the interface function module
WRÌTE_FORM, which is called in the print program.
2. Text EIements Without Names : Nameless text elements or default text elements
are those text lines and control statements that appear at the beginning of the
corresponding window contents without having the /E paragraph format. They include
all lines up to the next /E paragraph or to the end of text if no other named element
follows. Thus, you can have only one nameless text element in each window.
The differences between named an nameless text elements are:
- The system outputs named text elements only if the print program explicitly
calls them in the function module WRÌTE_FORM. But it outputs nameless text
element automatically whenever it processes the corresponding window.
- The nameless text element of the MAÌN window appears only once at the beginning of
the main window. Ìt does not appear on the subsequent pages of the form which also
contain the main window.
- The nameless text elements of all other windows (except MAÌN) appear each time.
· Activate Text EIements : You activate the text elements of a window from within the
print program by setting the parameter FUNCTÌON when calling the function module
WRÌTE_FORM. FUNCTÌON may have the following values:
- SET : Replace all active text elements of the window by the current one (default).
- APPEND : Append the current text element to the active text elements.
- DELETE : Delete the current text element from the list of active text elements.
Active text elements are all text elements the system already output to the window
when the current page is called. Ìn the main window, the value A!! within the
BODY area equals the value $T. The value LT has no effect in this context. Ìn
the areas TOP and BOTTOM, the values act as described above.
A print program is an application program ( REPORT or MODULE POOL ) that allows
you to print documents to which forms are allocated. The print program retrieves the
required data from the database and combines them with the data the user entered.
Then, it processes the underlying form, formats the data accordingly, and prints it. R/3
applications (FÌ, CO, MM and so on) deliver standardized forms and print programs that
customers may have to adapt to their special needs. Only the close interaction of print
program and predefined form allows the user to print forms such as orders or invoices.
One important feature of SAPscript is that forms contain texts with variables besides the
layout information. These variables are replaced independent of the formatting and
appear as values in the printout. The print program is responsible for retrieving the data
from the R/3 system and for the control logic of the output. This allows the user of
SAPscript forms to separate the logic of retrieving data from the layout of the output.
The print program retrieves or calculates the required data and determines their output
order. SAPscript is responsible for formatting and positioning this data on a print page.
Thus, you can modify the layout of the form without having to change the print program.
At runtime of the print program, SAPscript can automatically access data that is defined
in the controlling program. Technically speaking: SAPscript retrieves the values directly
from the data fields of this program.
Note : For each printout of a form, you must use the pair of function modules
OPEN_FORM and CLOSE_FORM. You can also use a print program to print several
forms, which you can either maintain in separate spool requests or combine into one. Ìn
the latter case, you must use the function modules START_FORM and END_FORM
inside OPEN_FORM and CLOSE_FORM.
· onstant Windows (ONST) : As far as the processing of the window contents is
concerned, the system currently treats constant and variable windows alike. The only
difference is that constant windows have the same size throughout the form.
· VariabIe Windows (VAR) : The contents of variable windows is processed again for
each page, on which the window appears. The system outputs only as much text as
fits into the window. Text exceeding the window size is truncated; the system does not
trigger a page break. Unlike constant windows, the page windows declared as variable
windows may have different sizes on different form pages.
· Main Windows (MAIN) : Each form must have one window of type MAÌN. Such a
window is called the main window of the form. For SAPscript forms, the main window
has a central meaning:
- Ìt controls the page break.
- Ìt contains the text body that may cover several pages.
- Ìt allows to fix text elements at the upper and lower margins of the allocated page
window (for example, for column headings).
As soon as a window of type MAÌN is full, SAPscript automatically triggers a page
break and continues to output the remaining text in the main window of the
subsequent page. Page windows of type MAÌN have the same width throughout the
form. Ìf a page does not have a main window, the system implicitly processes all other
windows of the page and continues with the subsequent page. This page must not
call itself as subsequent page (recursive call), since this would produce an endless
loop. Ìn such a case, SAPscript terminates the output after three subsequent pages.
For outputting texts in the main window, you can choose one of three different areas.
The upper margin of the main window is called TOP area; the lower margin is called
BOTTOM area. The area in-between is called BODY of the main window. The sizes of
the TOP and BOTTOM areas depend on the sizes of their text contents. The BODY
area varies accordingly. When calling the function modules WRÌTE_FORM or
WRÌTE_FORM_LÌNES, the parameter TYPE determines into which of the three areas
to output the text (Default ÷BODY). The TOP area always appears at the beginning of
the main window. You can use it, for example, to automatically output headings on the
subsequent pages. TOP area in the main window is actually output as soon as the
print program writes text into the BODY area. Ìf the BODY area of the main window
was filled before the program reached the definition of the TOP area, this definition is
used as TOP area for the subsequent page. This means, that you can no longer delete
a heading in the TOP area after writing text into the BODY area. The BOTTOM area
appears at the end of the main window. Unlike the TOP area, you can define BOTTOM
area for the current page after the output to the BODY area is complete, provided
there is enough space left on the page. Otherwise, the BOTTOM area text is output on
the subsequent page. The output of the TOP and BOTTOM area is triggered by
the text in the BODY area. Therefore, text elements written to the TOP or BOTTOM
areas must not necessarily appear in the output. Ìf the BODY area does not contain
any text, output of TOP and BOTTOM elements is suppressed.
The following table summarizes the points in time, at which the variables in the different
windows are replaced with the current values.
Window type Area Point of time of variabIe repIacement
MAÌN BODY immediately
MAÌN TOP at the beginning of the main window
MAÌN BOTTOM immediately or at the beginning of the main window of
the subsequent page
VAR after processing the main window
CONST after processing the main window
Due to these conditions, you cannot use only one variable with changing contents for
TOP and BOTTOM areas, since the variable is not always replaced immediately, even
if it occurs several times.
Page ontroI in Forms
· SAPscript automatically triggers a page break as soon as the main window of one
page is full. You can specify the subsequent page either statically when defining the
form, or you can set the subsequent page dynamically during form output.
· Ìf the subsequent page is not specified, SAPscript automatically terminates printing.
· The page sequence set in the form definition can be changed by the application
program dynamically at runtime. Ìf you want the form to start with a page other than
the one defined in the form header, specify the desired start page using the parameter
STARTPAGE when you call the function module START_FORM. However, this new
start page is valid only for the current call of the function module. Ìf you want to break
to a subsequent page other than the one specified in the page definition, use the
control statement NEW-PAGE to set the name of the new page.
NEW-PAGE ends the output on the current page. The new subsequent page is only
valid for the current call of the control statement. You can either include the control
statement explicitly into the text of a text element or pass it to the form output using
the function module CONTROL_FORM.
How to convert Sapscript spooIs request to PDF?
· SAP have created a standard program RSTXPDFT4 to convert your Sapscripts spools
into a PDF format.
· Specify the spool number and you will be able to download the sapscripts spool into
your local harddisk.
· Ìt look exactly like what you see during a spool display.
· Please note that it is not restricted to sapsciprts spool only. Any reports in the spool
can be converted using the program 'RSTXPDFT4'.
How to UpIoad graphics (IMAGE) to your Sapscript?
/: INUDE Z_YOUR_OGO OBJET TEXT ID ST ANGUAGE E
These are the steps to be followed for uploading graphics in R/3 system
1. First save the file as BMP
2. Open the BMP file in ÌMaging (Goto -> Programs -> Accessories ->Ìmaging)
and make it Zoom as 100% and save as *.TÌFF
3. Open SE38 and execute program RSTXDM
4. Give your TÌFF file path name
5. Select Bcol (for Color)
6. TEXT ÌD will be ZHEX-MACRO-*.
7. Ìnplace of * write your own logo name (ZCOMPANYLOGO)
8. Execute the program
9. Now Goto SE71 create your ZFORM
10. Create logo window
11. Goto text element of logo window
1. Goto SE71 Change the mode to GRAPHÌCAL
2. Choose the Graph Tabstrips
3. Now type in some name for the LOGO WÌNDOW
4. Press the ÌMPORT BUTTON (third button from left) and then ÌMPORT the BMP file
from your DESKTOP.
5. The code will be written automatically. You just need to drag and drop wherever you
want the graphics to be.
/: INUDE Z_OMPANY_OGO OBJET GRAPHIS ID BMON ANGUAGE EN
Import/Export SapScript form from P fiIe
· Use ABAP program: RSTXSRP
· Ìt will download and upload your sapscripts as a text file in your local harddisk.
MaiIing PDF attachments using Scripts
MaiIing ExceI Sheet as attachment from Itab
· Ìs an advanced tool for SAP scripts which makes form development easier.
· Smart form supports both internet (XML) as well as Email format.
· Smart form is provided from 4.6c version of SAP.
· Transaction code for smart forms is SMARTFORMS.
· To convert existing SAP script to smart from : Utilities migrate SAP script form.
· The layout of smart forms is made up of hierarchy of nodes.
· Every time the smart from is activated the system will generate a function module
which is used in the print program.
· You use SAP Smart Forms to create and maintain forms for mass printing in SAP
Systems. Besides using the printer for standard output you can also select the
Ìnternet (by using a generated HTML output), a fax, or e-mail as output medium.
· SAP Smart Forms offers the following advantages:
- Creating and maintaining forms requiring half the time
- Adapting forms without any programming knowledge due to entirely graphical user
- Ìntegrating input elements into the HTML output, which enables you to use a form in
Ìnternet applications as well
· To print a form, you call it from within an application program, in which you retrieve the
application data to be merged into the form. As data retrieval and form logic are
separated, you must only adapt the Smart Form if changes to the form logic are
necessary. The application program passes the data via a function module interface to
the Smart Form.
· Ìt provides Form Painter for the layout of a form page or the Table Painter for the
design of table output.
· You can include static and dynamic tables into a Smart Form. Dynamic tables enable
you to display tables whose size is determined only at the moment of their output by
the number of the table items to be displayed. Table functions are:
- Line feeds in individual table cells
- Event-controlled output of table headings and footers
- Ìntegrated calculation of grand totals and subtotals
- Colored boxes and shadings in tables
· To position output on a form page you use windows. Besides using simple windows for
displaying output of fixed length there are special window types, for example, for
continuous text or for distinctions between the original and a copy of a form.
· You can include background pictures as graphics, which you can either use as copy
templates for a form or print as background graphics.
· You can specify spool attributes in the form to allow for postage optimizing.
· A form consists of pages, windows, addresses, graphics (such as company logo),
and data or text contents. Within an output area, you can use static or dynamic tables
to display data or texts in lines, columns, or cells. To further structure and format text
and data, use paragraphs with the paragraph and character formats.
· Main Window and Secondary Windows : On a page, there are two different types of
output areas for texts and data: the main window and the secondary window. You can
position windows anywhere on a page, even overlapping. You can position the same
window on several pages of a form, so that the same contents are displayed on all
these pages. You can choose a different size for the window on each page, except for
the main window. As soon as a main window is completely filled with text and data, the
system continues displaying the text in the main window of the next page. Ìt triggers
the page break automatically.
- You can define only one window in a form as main window.
- The main window must have the same width on each page, but can differ in height.
- A page without main window (ex. first page as covering letter or last page with
summary ) must not call itself as next page, since this would trigger an endless loop.
Ìn such a case, the system automatically terminates after three pages.
Ìn a secondary window you display text and data in a predetermined output area.
There is no flow text display with page break. Ìf you position a secondary window with
the same name on several pages, the system displays the contents of this secondary
window on each page. Text and data that do not fit into the secondary window are
truncated and not displayed.
· Texts and Data in a Form : You enter text in an editor. Data can be character strings
or numbers. The system reads this data from a database and uses fields (parameters)
to dynamically display it. To display texts and data in table format , you use tables or
templates. To format texts and fields (data), you use paragraph and character formats.
To determine the paragraph and character formats, use the Smart Styles.
· Architecture :
When you activate the Smart Form, the system generates a function module that
encapsulates all attributes of the Smart Form. As soon as the application program calls
the function module, the Smart Form uses the module's interface (which corresponds
to the form interface) to transfer any table data previously selected and to print the form
according to the form description. This is also referred to as 'calling a Smart Form for
printing'. The form description can also contain statements that select further data
during form processing. However, you should not use this method of data retrieval.
Especially if you print mass forms, performance will deteriorate considerably. When
creating a form, you must:
- Retrieve the application data.
- Describe your form.
- Pass the application data to the form.
· Retrieving AppIication Data : To achieve a good performance when printing a form,
you must separate data selection from the use of data in the form. Thus you can
bundle database operations before you start processing the form. Before you retrieve
data, you should know:
- Which application data you want to appear in the form
- Which database tables you must access to retrieve this data
Write an ABAP program to retrieve data or include a retrieval routine into your
application. This code consists of statements that select data from the database
according to certain selection criteria. Store the retrieved data in internal tables,
structures, or variables and transfer it to the form in one step. While you initialize the
form, you can format the data, which you passed to the form, for output in the form.
Formatting data in the form and not in the application program allows you to use one
application program for several forms with different formatting routines.
· Describing a Form : You describe a form using a $mart Form. To do this, use the
Form Builder :
- Describe the interface of the form. Ìt results from the application data previously
- Create one or more pages. On a page, you can position windows, addresses, and
graphics. Within a window, you can create additional elements.
- Create elements (text, graphics, tables, and so on) for each page, using other tools of
the Form Builder:
÷ Use the Form Painter to position windows, graphics, and addresses on a page.
÷ Use the PC Editor to write your texts.
÷ Use the Table Painter to format your tables.
- Use the flow control to control whether and when to print pages and elements.
· Form ogic: You use the form logic to control the flow of the form output. The
following rules apply throughout:
- The nodes in the tree structure are processed from top to bottom.
- For each node there is a tab page, which you can use to link the node to a condition.
Ìf the condition is true, the system processes the node. Ìf not, it skips the node and all
its inferior nodes.
- You must define a next page for each page. However, you can also go to other pages
For node 5 these are the nodes 6 to 9 (directly inferior nodes are only the nodes of the
next hierarchy level, that is 6, 7, and 9). A node without an inferior node is also called
elementary node. Elementary nodes can never have inferior nodes. Ìf the condition of
node 7 is false, neither node 7 nor node 8 are processed. Processing resumes directly
with node 9.
Technologies available for interacting between
· ALE ( Application Link Enabling ).
· EDÌ ( Electronic Data Ìnterchange ).
· RFC ( Remote Function Call ).
· BAPÌ ( Business APÌ ( Application Program
Ìnterface ) )
· ÌDOC ( Ìntermediate Document ).
· Ìs a system in which part of the business
process is carried on in one system and
another part in another. Used to distribute the
business functionality across the system.
· SAP R/3 was initially developed to be used as a
central system. But later, the need to go in for
distributed environment was strongly felt .
Need to go for distributed system
· Geographical Location :- Ìf the operations of the
organization is spread across different
locations, the central system demands a high
bandwidth of network. The cost criteria is much
higher in this case, hence distributed system
forms a cheaper alternative.
· System Requirement :- Ìf the organization
involves high volume of transaction. Ìt
demands very large database , high network
availability, hardware configurations etc.,. A
distributed system can better cope with these
· Legacy Tools :- The organization wants to use
legacy systems along with SAP.
· Different versions of SAP :- The organization
uses different versions for different modules.
Existing technoIogies for data distribution
· Disk Mirroring.
· Online distribution using the two-phase-commit
· Distributed updates to replicas.
SAP's chaIIenge for a distributed environment
· A syntax that understands the syntax and
semantics of the data.
· Distributed systems that can maintain their
autonomy while being integrated as one logical
· Distributed systems that can handle different
· Receiving systems that can handle their own
problems and not tie up the sending system,
and vice versa.
AE (AppIication inking and EnabIing)
· From SAP R/3 3.0 onwards SAP has
introduced the ALE technology.
· ALE is a built-in integration technology of SAP.
· ALE is SAP's technology to support distributed
yet integrated processes across several SAP
· ALE is based on application-to-application
integration using messaging architecture, a
message defines data that is exchanged
between two processes.
· ALE architecture is independent of the
participating systems, allowing SAP to use the
techniques used for SAP-to-SAP
communication to communicate with non-SAP
systems as well.
· The ALE technology supports guaranteed
delivery, which means that an application
sending a message does not have to worry
about network problems or connection failures.
The application can concentrate on the
· Any of the distributed systems can be upgraded
to a newer release of the SAP system without
affecting the existing functionality. The ALE
layer ensures backward compatibility of
messages exchanged between systems.
· SAP systems connected via ALE are loosely
coupled, but they provide a high level of
· ALE provides two methods of exchanging
Ìn asynchronous method distribution of data is
guaranteed even if the remote system is not on
at the time of transfer.
Ìn synchronous method, the availability of the
remote system is must. Ìt is generally used
only for reading the data.
RoIe of AE in data distribution
· The process flow used to exchange data
between distributed systems in ALE
architecture consists of :
- Outbound Process.
- Ìnbound Process.
- Exception-handling Process.
The Outbound Process
· Ìdentify the need for sending an ÌDOC.
· Generate the master ÌDOC.
· Generate the communication ÌDOC
The Inbound Process
· Store the ÌDOC in the database.
· Ìnvoke the posting module.
· Create the document.
Services provided by AE
· Application Services.
· Distribution Services.
· Communication Services.
· ALE distribution involves two process :
- Outbound process.
- Ìnbound process.
· An ÌDOC is a container that is used to
exchange data between any two processes.
The document represented in an ÌDOC is
independent of the complex structure SAP
uses to store application data.
· Components of ÌDOC:
- ÌDOC type.
- ÌDOC ( ÌDOC data / ÌDOC instance ).
- MESSAGE TYPE.
Idoc Types and Message Types
· An Ìdoc type is the definition of a specific data
· MATMAS 01/02/03.
· CREMAS 01/02/03.
· ORDERS 01/02/03.
· An Ìdoc is an actual instance of data based on
an Ìdoc type. Therefore, there can be many
Ìdoc's created from a single Ìdoc type.
· A message type specifies the meaning of the
· An Ìdoc can support multiple message type.
· The Ìdoc structure does not change with
IDO record types
· Control record :- contains the data that uniquely
identifies the Ìdoc.
· Data record :- contains the application data
related to the message type. An Ìdoc may have
multiple data records, called segments. A data
segment is made up of a key section and a data
section. The key section uniquely identifies its
respective data segment.
· Status records :- contain the information relative
to the various statuses that the Ìdoc
encounters, such as Ìdoc related, document
Idoc ontroI Record
· Ìdoc ÌD number ( DOCNUM ).
· Ìdoc type ( DOCTYP ) .
· Direction ( DÌRECT ).
· Name of Sender ( SNDPRN ).
· Name of receiver ( RCVPRN ).
· Processing Status ( STATUS ).
· Control records are stored in the R/3
transparent table EDÌDC.
Idoc Data Record
· Ìdoc ÌD number ( DOCNUM ).
· Segment Name ( SEGNAM ).
· Ìdoc Data ( SDATA )
· The data records is stored in the table EDÌD4,
the table structure is 71 bytes of administration
data followed by 1000 bytes of free-form
Idoc Status Record
· Ìdoc ÌD number ( DOCNUM ).
· Ìdoc Status ( STATUS ).
· Date/Time status was generated ( CREDAT,
· Status text ( STATXT).
· The status records are stored in the table
· The status field :-
· 1 --- 49 for outbound messages.
· 50 --- 99 for inbound messages.
Transaction codes associated with IDO's.
· WE60 to view the structure of a specific ÌDOC.
· WE05 to display a list of Ìdoc's in the system with
the Ìdoc lists transactions.
· BD54 defining logical system.
· SCC4 assigning logical system name to the client.
· BD64 model maintenance.
· SM59 defining RFC destination
· WE21 creating a new port.
· WE20 creating partner profiles.
· The partner profile in configures the ALE layer, while
the RFC destination and
AE configuration steps
· Transaction code :- SALE
· Define logical system.
· Logical system is nothing but the name given to
each system involved in the distribution .
· Assign client to the logical system.
· The logical system is assigned to a client on the
R/3 system and not entire system.
· Create RFC destination for the sending system.
· Ìs a set of communication and log-on
parameters of the remote system.
· Create physical connection called ports.
· The data of the Ìdoc's are distributed through
theses physical channels.
· Create a model view.
· To define the distribution model view.there is
really only one model view.
· The owner of a model view is set to the system
on which you create it.
· Create partner profiles.
· Messages and partner specific settings required
for communication is set.
Methods for distributing data
· Change pointers
onfiguring IDO for sender and receiver system
In the source system
Step1 :- Create two Logical
Eg :- LS800ABAP1.
Save the Logical systems.
Step2 :- Assign client to the
Note :- Only the sending
logical system should be
assigned to the client.
Save the client information.
In the receiver system
Step1 :- Create two Logical
Eg :- LS800ABAP1.
Save the Logical systems.
Step2 :- Assign client to the
Note :- Only the receiving
logical system should be
assigned to the client.
Save the client information.
In the source system
Step3 :- Create RFC
Enter TC :- SM59 ( Create)
Eg :- Name : LS000ABAP2.
Connection Type : 3.
Description : trial connect..`
Target Host name : ABAP2.
System No : 00
In the receiving system
No RFC configuration on the
In the source system
Step4 :- Create the model view
Enter TC :- BD64 . create.
Eg :- Enter
Technical name :- NMODEL1` .
MenuEditAdd Message type.
Eg :- sender.
Save the model view.
In the receiver system
No configuration on the
In the source system
Step5 :- Generate partner profile.
Enter TC :- BD82.
Eg :- enter
Model view :`NMODEL1`.
Partner System : LS000ABAP2
Execute.(This will generate the port
and the partner profile.)
Dblclick on the messages to open the
( TC :- WE20)
In the receiver system
Step3 :- Create partner profile in the
Eg :- enter TC WE20.
Select Partner Type LS.
Partner num : LS800ABAP1.
Partner Type : LS.
Type : USE.
Agent : SAPUSER.
Lang : EN.
Message Type : MATMAS.
Process code : MATM
Save the partner profile.
· Create a new material for distribution (MM01).
· Execute a selection program ( BD10).
· Enter material no , message type , logical
· Other selection programs:
· BD11 material master (pull).
· BD12 customer master (push).
· BD13 customer master (pull).
· BD14 vender master (push).
Steps InvoIved in creating IDO types
· Create Segments (WE31)
· Create new ÌDOC ( Basic Type) (WE30).
· Create message type (WE81).
· Assign ÌDOC type and message type (WE82).
· Develop the selection and posting program.
IDO creation steps in detaiI
· Step1 : - TC WE31. Create a segment.
· Give the segment name
· ( Z1MARAS) create.
· Mention the fields with the respective data
elements. Save the segment .
· Release segment ( Edit set release ).
· Ìf needed, create another segment
· ( Z1MAKTS) ,
· Repeat the previous steps.
· Step2 :- Create new ÌDOC type ( WE30 ).
· Mention the ÌDOC type name ( ZMATMAS) as
basic type , create.
· Select the ÌDOC type .
· Add segment to ÌDOC type.
· The segment can be mandatory or optional.
· Maintain min & max values . ( min & max option
is for how many instance can be created for
· Release the ÌDOC basic type ( editset
· Step 3 :- Create message type ( WE81 ).
· Step 4 :- Link the message type with the ÌDOC type
· ( WE82 ).
· Mention the message type , ÌDOC type and release
· Step 5 :- Develop the selection program.
· Use :-
· EDÌDD structure generally used in coding.
· RCUDRM name for logical system field.
· MASTER_ÌDOC_DÌSTRÌBUTE function module
which takes the parameter : master idoc control and
data , generate communication ÌDOC.
· Commit work.
· Note : - #epeat the OC creating steps in
the receiving system , excluding the
· Step 6:- Developing of posting program.
· Copy function module
ÌDOC_ÌNPUT_MATMAS01.( inbound function
· Create the function group and activate it.
· Remove the source code.
· Add the customized source code which reads
data from the user-defined ÌDOC and writes it
into the database.
· Configure the ALE on both the sending and receiving
system as usual.
· Note :- Ìn the partner profile of the receiving system for
the inbound message assign user-defined message (
you created ) and assign available process codes
depending on the type of data being send. For (eg : -
for material data use process code MATM ).
· Run the selection program on the sending machine.
The program generates an ÌDOC number if and send
· On the receiving system the ÌDOC reaches with an
error as no ÌNBOUND posting program is available for
saving the data into the data base.
· Run the Tcode WE19 .
· Ìt takes the ÌDOC number and list the segments
of the ÌDOC type with the data it has.
· click the ÌNBOUND FUNCTÌON CALL button
on the application toolbar.
· Enter the posting program (you created) and
· The data is saved into the database.
· Filter are used to remove unwanted data from
· There are three ways to filter data :-
· Data filtering ( BD64).
· Segment filtering (BD56).
· Message reduction (BD53).
· Distribution of data base on given condition.
· Ìf the condition is on a field, that falls in a
mandatory segment, ÌDOC will be created only
if the condition is satisfied.
· Ìf the condition is on a field which is not
mandatory, then the segment generated will
depend on the condition ( which in turn suits the
needs of different recipients ).
reating data fiIter
· Data filtering is configured while creating the
model view for ÌDOC distribution.
· After adding the message type to the model
· Dbl Click on "NO FÌLTER SET ¨.
· Change to " change mode ".
· Click on " CREATE FÌLTER GROUP ".
· Open the filter group.
· Click on the field on which filter is to be set.
· Enter the filter values.
· SEGMENT FÌLTERS:-
· Ìt is for restricting the distribution of certain
segments to certain recipients.
· STEPS :-
· Enter TC :- BD56.
· Give the message type.
· Select new entry.
· Provide the sender , receiver and the segment
which needs to be filtered.
· MESSAGE REDUCTÌON :-
· Create a reduced message type referring to an
existing message type, where we can choose
which segments, and the fields in the segments
has to be populated while creating the ÌDOC's.
· Steps :-
· Enter Tcode :- BD53.
· Give the name for the reduced message type.
· Click Create (F5) , Click on Change.
· Enter the reference message type name.
· Select the field within the segment or the entire
segment from the list.
· Note :- ( * ) is a mandatory field / segment. ( - )
( + ) selected field.
Save the new message type.
· Change pointers help reflect the changes
made to master data automatically.
· Change pointer uses the tool:
· SHARED MASTER DATA TOOL [SMD
· Change pointers uses two change document
· CDHRD ( header data).
· CDPOS (item data).
Data FIow for hange Pointers
· A program RBDMÌDOC will be scheduled for
processing in the background. Ìt reads the
entries in the BDCP, BDCPS tables , reads the
changes, if it finds any changes, it reads the
data from database , creates ÌDOC from it and
distribute the ÌDOC's.
· Steps associated with change pointer :
· Activate change pointer globally ( BD61).
· Activate change pointer message type ( BD50).
· Assign fields for change pointer ( BD52)
Remote Function aII
· RF is basicaIIy pIatform independent core
technoIogy which provides communication
between SAP and any other systems.
· Making a function #emote Enabled converts it to
binary standard which make it appIication
· Type of function caIIs :
· SAP R/3 ------- SAP R/3.
· SAP R/3 ------- NON-SAP
GUI . BAPI . RFC .
API . IDOC
riteria for making a function moduIe RF
· Function module should not have any reference
· No commit work statements within the function
· Syntax :
· CALL FUNCTÌON <function_name>
TransactionaI RF (tRF)
· To make RFC safe and reliable TRFC was
introduced from SAP 3.0.
· TRFC ensures that the function call execution is
guaranteed once even if the remote system is
not available / on at the time of the call.
· When the remote system is not available the
TRFC function call is stored in two database
tables ARFCSDATA and ARFCSSTATE.
· The program 'RASRFSE' is scheduIed to run in
the background periodicaIIy.
· It reads the entry from the tabIe ARFSDATA ,
RFSSTATE and tries to caII the function on a
· The number of attempts is specified in SM59.
· Syntax :-
· A FUNTION <function_name>
IN BAGROUND TAS
Note :- AE uses TRF , that is why distribution of
IDOS is guaranteed.
Asynchronous RF : - (aRF)
· Mostly used for parallel processing.
· ARFC helps create new sessions from our
· Useful in case of multi-session application.
· Syntax :-
CALL FUNCTÌON 'function_name'
STARTÌNG NEW TASK 'task'.
EDI (EIectronic Data Interchange)
· EIectronic exchange of business document
between systems of business partner's over a
omponents of an EDI system :
· Trading partners.
· Application programs.
· Business documents.
· Translators (EDÌ subsystems).
· EDÌ messages.
· VAN ( Value Added Network).
· Trading partners :-
÷ Banks etc..,
· AppIication Program :- The system(s) used by the
· Business Document :- Proof of the business
· TransIators :- The actuaI EDI components which
forms interface between the partner appIication.
· VAN :- ommunication network(s) used to
EDI system data fIow :
SAP R/3 (OR)
SAP Business Objects
· Business Object :- Encapsulation of data and
process of a business entity.
÷ Eg :- purchase order , invoice etc..,
· These R/3 application were developed in an
OO (object oriented) environment.
· BFA :- Business Frame Work Architecture.
· Eg :- ALE , tRFC , BUSÌNESS OBJECT (BO)
· BO were actually developed for building work
· BOR :- Business Object Repository.
· BOB :- Business Object Builder . To work as
well as to maintain Business Objects (BO)
· Tcode :- SWO1.
· Layers of a BO :-
· Ìntegrity (business rules for validation).
· Ìnterface (methods).
· Access (technologies used to invoke methods).
· SAP has added standardized methods called
BAPÌ's to the BO, which allows external
applications to integrate with SAP.
· BAPÌ :- Business Application Programming
· A Business Object Type (BOT) is a definition
or specification for a business object method.
· BOT help create Business Object Ìnstances
omponents of BO
· Keyfields (uniquely identify the instance).
· Attributes (describe property of instance).
· Methods (operations on the data).
· Event (change in object status).
· Ìnterfaces ( set of methods).
· Two methods to invoke a BAPÌ from an external
· OO access.
· RFC access.
· Development of BAPÌ is reflected in
three areas of the R/3 system.
for BAPI method
· All the BAPÌ parameters must refer to the
dictionary structures created exclusively for
· All the parameters in BAPÌ function module
must reference to the APAP DDÌC.
· Every BAPÌ must return parameters.
BAPI ActiveX controIs in VB
· SAP BAPÌ control :- used to logon to R/3.
Create an instance of SAP business object.
Ìnvoke the BAPÌ. Log Off.
· SAP logon control :- used to create a
connection instance to R/3 system.
· SAP Table View control :- To display data.
SAP Business Work FIow
· Workflow is used to automate the business
process in a more efficient way.
· A workflow can be thought of as a flow chart for
a business process.
· Ìt ensures the availability of information at the
right places at the right time in the right form.
Scenarios in which SAP BWF is usefuI
· Ìf the business process is of repeated
· Contains sequence of steps and more than one
agent at each step.
· Dead-line monitoring.
· Ìt is also used in exception handling, in ALE or
Type of Agents
· Org .Unit.
· Tcode ( PPOC).
÷ Create Organization Plan.
÷ Create Org.Unit.
÷ Create Job / positions.
÷ Create Assign Holder.
÷ Create Chief Position.
÷ Create task .
· Assign agents.
· Start the work flow manually (SWUS).
hanging SAP standards
· SAP has provided various applications that
supports most of the standard business
process, but to meet specific requirement of the
client, we are allowed to change the SAP
· Methods for changing SAP standards :-
· Customer development.
Tool ASAP (Accelerated SAP)
· Customizations is of two types :-
· Function .
· Making various setting to the parameters with
the user interface provided by SAP.
· Tcode : SPRO.
· Personalization :- tailoring the user interface to
the individual user or group requirement.
· These personalization are provided by SAP,
these SAP standards are called ROLES. There
are about 120 roles provided by SAP.
· Transactional Variants :- To provide required
functionality to existing roles.
· Tcode :- SE93.
· Adding own functionality to the standard
· Enhancement will be provided by SAP in the
existing application strategic locations.
· Enhancement can be possible using
· Eg :-
· PERFORM USER_EXÌT.
· FORM USER_EXÌT.
· no code.
· END FORM.
· Locating user_exit in an existing application.
· Open the programsearch for user_exit
· Table enhancement.
· Customer Enhancements can be created in
Tcode :- CMOD.
· User Exits are developed in Tcode :- SMOD
· Menu exit is used to enable the functionality of
a menu item provided by the standard SAP.
· The function code of the menu item starts with
· Screen Exit :- Ìs basically a subscreen to add
new field to the existing SAP Std. Screen. Ìt is
called from the std. SAP screen.
BAPI User Guide
BAPÌs (Business Application Programming Ìnterfaces) are the standard SAP interfaces.
They play an important role in the technical integration and in the exchange of business
data between SAP components, and between SAP and non-SAP components either on
a local network or on the Ìnternet. Object-oriented technologies have become standard
for communication between different software products. For this reason SAP has
introduced business object types that structure the data and processes according to
business criteria. These object-oriented interfaces allow other components to directly
access the application layer of an SAP system without having to know the specific
implementation details. Tcode for BAPÌ explorer is BAPI.
· BAPIs can be used for the foIIowing types of integration:
- Connecting SAP Systems to the Ìnternet using the SAP Business Connector or
Ìnternet Application Components (ÌACs). The standard SAP interfaces and all BAPÌs
are published centrally in the XML-based Interface Repository (IFR). They are stored
as XML schema, which means that they are directly available for use in integration
scenarios where multiple components communicate with one another using the
Ìnternet. You can access the Ìnterface Repository in the Ìnternet using the following
- Creating true component software, by enabling standardized communication between
SAP components. The aim is to encapsulate the functions of the SAP system in
independent business components that are integrated through a common interface
- Connections to third-party software and legacy systems.
- Ìmplementing distributed scenarios with asynchronous connections using Application
Link Enabling (ALE).
- Using PC programs as frontends to SAP Systems. These can be developed with
Visual Basic (Microsoft), for example, or with Visual Age for Java (ÌBM)
- Workflow applications that extend beyond system boundaries
- Workflow applications that communicate with one another using the Ìnternet
- Customers' and partners' own developments
· Benefits of BAPIs :
- BAPÌs represent well-defined, internally consistent units that always represent
business facts and leave a consistent database state behind.
- The business contents can be standardized, since BAPÌs not only allow the integration
of the SAP system and other software components at a technical level, but also at the
- BAPÌs have become a communication standard between business systems. Access is
possible through object-oriented interface technologies (such as COM/DCOM from
Microsoft). The SAP business objects conform to the guidelines of the OAG (Object
Application Group), and meet the CORBA standard from the OMG (Object
- Stability and compatibility : Once SAP has released a BAPÌ, its interface definitions
and parameters will remain stable in the long term, which means application programs
will not be affected by changes to the underlying SAP software or data. Ìf upward-
compatible enhancements are made to the BAPÌs, the stability of the existing
applications is not affected.
- Openness : BAPÌs can be accessed from any widespread development platform.
- Universal Usability of BAPÌs : BAPÌs can be used for both the synchronous and for
the asynchronous call to an SAP component. Ìf the call is synchronous, the BAPÌ is
called as a remote function call (RFC). ALE inbound processing is used to enable
asynchronous communication with BAPÌs. When the BAPÌ is called in the sender
system, an ÌDoc is generated and dispatched to the receiver system. When the ÌDoc
reaches the receiver, the parameters of the corresponding BAPÌ are automatically
filled with the ÌDoc data, and the BAPÌ is called synchronously.
· Business Object Types : A business object type is the representation of a business
entity, like an employee or a sales order, in an SAP System. Ìt encompasses both the
functions (in the form of methods) and the data (in the form of attributes) of this entity.
The term "business object type" corresponds to the term "class" in object-oriented
programming languages. Ìt defines a template for concrete objects that all have the
same structure and the same behavior.
· The Business Object Repository : The Business bject #epository (BOR) is the
central access point for the SAP business object types and their BAPÌs. Tcode is
SWO3. The BOR provides the following services in the BAPÌ context:
- Allows an object-oriented view of all data and processes in an SAP System
- Arranging the various business object types according to the component hierarchy
This enables you to find the required functions quickly and easily.
- Storage of all relevant information: The BOR contains all the relevant information on
the SAP business object types, their key fields, and their BAPÌ methods that is needed
to integrate the correct object type definitions and BAPÌ calls in an application
program. This enables the integration of middleware (such as the DCOM Connector,
ActiveX Controls, CORBA Gateway, and so on).
- Ìt ensures BAPÌ interface stability : Any interface changes carried out in the BOR are
automatically checked for syntax compatibility against the associated development
objects in the ABAP Dictionary
- Ìt manages BAPÌs in release updates : BAPÌ interface enhancements made by adding
parameters are recorded in the BOR. Previous interface versions can thus be
reconstructed at any time. When a BAPÌ is created, the release version of the new
BAPÌ is recorded in the BOR. The same applies when any interface parameter is
- Ìt creates instances of SAP business objects : The runtime environment of the BOR
receives requests to create runtime objects from client applications and creates the
appropriate object instances.
· Structure : SAP business objects encapsulate SAP data and business processes
while hiding the structure and implementation details of the underlying data. To
achieve this encapsulation, SAP business objects are created as entities with several
- At the core of an SAP business object is the kernel, which represents the object's
- The second layer, the integrity layer, represents the business logic of the object. Ìt
comprises the business rules for consistent embedding in the environment and the
constraints regarding the values and domains that apply to the business object.
- The third layer, the interface layer, describes the implementation and structure of the
SAP business object, and defines the object's interface to the outside world.
- The fourth and outermost layer of a business object is the access layer, which defines
the technologies that can be used for external access to the object's data, for example,
COM/DCOM ((Component Object Model/Distributed Component Object Model). Ìt
specifies the technologies that enable object data to be accessed from external
programs, for example, COM/DCOM (Component Object Model/Distributed
Component Object Model).
· Object Instances : Each SAP business object is a representation, or instance, of its
object type. Ìf an application program uses an instance of a business object, the object
instance responds only to the set of characteristics and methods defined for its own
object type. SAP business object types are defined by the following:
- Object type : The object type describes the features common to all instances of that
object type. This includes information such as the unique name of the object type, its
classification, and the data model.
- Key Fields : The key fields determine the structure of an identifying key, which
allows an application to access a specific instance of the object type. The object type
mployee and the key field mployee umber are examples of an object type and a
corresponding key field.
- Attributes : An attribute describes a specific property of a business object. For
example, mployee ame is an attribute of the mployee object type.
- Methods : A method is an activity that can be performed on a business object and
that provides access to the object data. A method is defined by a name and a set of
parameters and exceptions that can or must be provided by the calling program in
order to use the method. BAPÌs are examples of such methods.
- Events : An event signals that the status of a business object has changed.
- Ìnterfaces : Definitions of attributes, methods and events grouped together in one
context. An object type can support one or more interface types.
· Inheritance & PoIymorphism : One objective and the main benefit of object-oriented
technology is software reusability. The reuse of software code is achieved by deriving
new object types from existing ones. When an object type is generated from existing
object type, the new object type is called the subtype and the existing object type is
called the supertype. A subtype inherits all the properties and methods defined for the
supertype from which it descends, but can also have additional properties and
methods. A subtype may also implement a different behavior for the methods inherited
from the supertype. Polymorphism is the term used to describe when the same
method triggers different types of behavior in different business object types.
· Integration : The graphic below shows the relationship between an SAP business
object type, its associated BAPÌs and its function modules.
The BAPÌs in the SAP Systems are currently implemented as function modules, which
are created and managed in the Function Builder. Each function module underlying a
- Supports the Remote Function Call (RFC) protocol
- Has been assigned as a method to a SAP business object type in the Business
- Ìs processed without returning any screen dialogs to the calling application
To use a BAPÌ method to access data in SAP business objects, an application program
only needs to know how to call the method. The following information is required:
- The name of the BAPÌ
- Details of the BAPÌ interface:
- Ìmport parameters, which contain data to be transferred from the calling program to
- Export parameters, which contain data to be transferred from the BAPÌ back to the
- Ìmport/export (table) parameters for both importing and exporting data.
Application programmers can work with SAP business objects and implement their
BAPÌs without needing to know or consider the underlying implementation and coding
details for the object.
· Note : BAPÌs used for outbound processing are defined in the Business Object
Repository (BOR) as APÌ methods of SAP interface types. These BAPÌs are known as
BAPIs used for outbound processing. The target system is determined for the BAPÌ
call in the distribution model of Application Link Enabling (ALE).
· Instance-dependent BAPIs (Instance Methods) : use specific instances of an object
type, which the client application must specify in the key fields of the business object.
An example of an instance-dependent BAPÌ is CompanyCode.GetDetail() and when
used the client application must specify the company code ÌD, for example,
· Instance-independent BAPIs (Static Methods) : do not use specific instances of an
object type. They usually return a list of object type instances in tables to the calling
program. Ìnstance-independent BAPÌs are also called class methods. The BAPÌ
CompanyCode.GetList(), which returns a list of company codes, is an example of an
Some instance-independent BAPÌs generate object instances and report back
information on the generated object instance to the calling application. An example of
this type of BAPÌ is SalesOrder.CreateFromData(), which creates a customer order
and reports back information to the calling program.
· BAPI ExpIorer : The BAPÌ Explorer is the working environment for developing BAPÌs
themselves and for developing with BAPÌs in an SAP System. To call the BAPÌ
Explorer, choose Tools -> Business Framework -> BA!I plorer. To call it directly,
use transaction BAPÌ. The BAPÌ Explorer is used internally in SAP to develop BAPÌs,
but can also be used by customers and partners. The BAPÌ Explorer provides all the
tools used to create BAPÌs and the required development objects in an integrated
programming environment. The entire development process of a BAPÌ takes place in
the framework of form-controlled "projects" to achieve maximum quality, stability and
usability of the BAPÌ. By choosing oto -> BA!Is to display, you can display all the
BAPÌs contained in the BOR, that is BAPÌs of SAP interface types and BAPÌs that have
not yet been released. Using the standard functions Find and Find net you can search
the displayed business object types or interface types using specified criteria
(placeholders such as ' * ' can be used). Depending on the development object
selected in the hierarchy display, in the Tools view, the following tools and navigation
options are provided:
- Direct access to the Business Object Builder, Function Builder and ABAP Dictionary.
- List generator to create lists of BAPÌs using specified selection criteria.
BAPÌ developments must be carried out and documented using a project in
the BAPÌ Explorer. For each of these projects there is a project form that takes you
step by step through the entire development process and provides direct navigation
options to the required development tools and information.
· Object-Oriented Access to BAPIs : Object-oriented access to BAPÌs in the BOR is
possible from a number of platforms.
- SAP DOM omponent onnector (Windows NT) : The SAP DCOM Component
Connector, which was developed jointly by SAP and Microsoft, enables the seamless
integration of SAP objects and COM objects. SAP business objects and their BAPÌs
can be called directly from COM-based development tools. COM components are also
provided in the SAP development environment.
- SAP Java onnector : The SAP Java Connector enables communication between Java
applications and SAP Systems. Ìt supports calls from Java to SAP Systems and from
SAP Systems to Java.
· Function-Oriented Access to BAPIs : You can access BAPÌs from platforms that do
not provide direct object-oriented access to SAP business objects by making Remote
Function Calls (RFCs) to the function module underlying the BAPÌ. This approach can
be used on all development platforms supporting the RFC protocol, for example,
ABAP or external platforms using C/C++ Class Library.
· Programming DiaIog AppIications : With dialog applications the caller usually waits
until the method call has been processed. SAP provides various help functions in the
form of service BAPÌs to support the programming of dialog applications. The service
BAPÌs can be found in the BOR component hierarchy under Basis Components ->
- Each dialog transaction that uses BAPÌs to change data in one or more objects must
directly execute the COMMÌT WORK command to save the data. The BAPÌ
apiService.TransactionCommit() is used for this and it writes the changes to
the database. Ìf data is not to be written to the database, the BAPÌ apiService.
Transaction#ollback() can reset the changes, provided that the changes have not
already been passed to database with BAPÌ Bapi$ervice.TransactionCommit(.
- To display the possible entries (F4 help) for an input field transferred when a BAPÌ is
called, you should include the service BAPÌ elpValues.GetList() in your program.
- To provide F1 help (field help) for input fields in your application you can use the
- Each BAPÌ contains a parameter named #eturn. This parameter reports exception
messages or success messages back to the calling program. Two service BAPÌs
can diagnose and process error messages from BAPÌ calls:
apiService.MessageGetetail() displays the short and long texts of BAPÌ error
messages. apiService.ApplicationLogGetetail(, displays entries in application
logs. apiService.nterfaceGetocu() method reads entire interface documentation
of a BAPÌ. apiService.yperLinkGetText() method reads SAP object
documentation that has hyperlinks to a document.
· Programming Distributed AppIications : BAPÌs can also be used in Application Link
Enabling (ALE) to exchange and replicate data between two distributed systems.
- Synchronous BAPIs : Synchronous BAPÌs are generally used to read data from a
remote logical system, for example to display a customer list. Before calling the BAPÌ,
it is therefore necessary to determine the RFC destination of the remote system or the
BAPÌ server. The application developer has access to an APÌ for determining the RFC
destination of the BAPÌ.
- Asynchronous BAPIs : Asynchronous BAPÌs are generally used for replicating data
on one or more logical systems, for example to distribute article master data. To
implement an asynchronous data transfer with a BAPÌ, an ALE ÌDoc interface must be
generated. This interface controls all of the data communication between logical
systems using ÌDoc technology. The application then calls the generated ALE ÌDoc
interface locally instead of the BAPÌs. As with synchronous BAPÌs, the corresponding
logical systems of the BAPÌ must be determined before you call the ALE-ÌDoc
interface. These are transferred to the ALE-ÌDoc interface as input parameters.
- Processing the Return Parameter : Each BAPÌ has the standardized #eturn
parameter for returning messages to the calling application. For more information
about this parameter, see Return Parameters (Error Handling) in the BAPÌ
Programming Guide. First the function module that converts the ÌDoc into the
corresponding BAPÌ in the receiving system is called. After this status records are
written for the ÌDoc in which messages sent in the Return parameter are logged.
Ìf the field type contains A (abort) in at least one of the transferred return parameter
entries, the status 51 (error, application document has not been posted) is assigned to
all the status records of the ÌDoc and a ROLLBACK WORK is executed. Ìf the field
type contains E (error) in at least one of the transferred Return parameter entries, the
status 51 (error, application document has not been posted) is assigned to all the
status records of the ÌDoc and a COMMÌT WORK is executed anyway. Otherwise
status 53 (application document posted) is written and a COMMÌT WORK is executed.
- AE Distribution ModeI : As with the message types, synchronous and
asynchronous BAPÌs are maintained in the ALE context in the ALE distribution model.
Based on the distribution model, the logical systems (for asynchronous BAPÌs) or RFC
destinations (for synchronous BAPÌs) are determined at runtime.
· Standardized BAPIs : Some BAPÌs and methods provide basic functions and can be
used for most SAP business object types. Such BAPÌs are known as "standardized"
- BAPIs for Reading Data :
Getist() : With the BAPÌ GetList() you can select a range of object key values, for
example, company codes & material numbers. GetList() is a class (Static) method.
GetDetaiI() : The BAPÌ GetDetail() uses a key to retrieve details about an instance
(one specific occurrence) of a business object type and returns this data to the calling
program. Then this information is reported back to the calling program. The BAPÌ
GetDetail() is an instance method.
GetStatus() : The BAPÌ GetStatus() is used to query the status of an SAP business
object instance, for example, the processing status of a sales order. This BAPÌ is
used only for displaying the status of an object and does not retrieve full details like
the BAPÌ GetDetail(). The BAPÌ GetStatus() is an instance method.
Existenceheck() : The BAPÌ ExistenceCheck() checks whether an entry exists for
a business object instance, for example, whether the customer master has been
created. The ExistenceCheck() BAPÌ is an instance method.
- BAPIs for reating or hanging Data :
reate() or reateFromData() : The BAPÌ Create() or CreateFromData() creates an
instance of an SAP business object type, for example, a purchase order. These
BAPÌs are class methods.
hange() : The BAPÌ Change() changes an existing instance of a SAP business
object type, for example, a purchase order. Change() BAPÌ is an instance method.
DeIete() and UndeIete() : The BAPÌ Delete() deletes an instance of an SAP business
object type from the database, for example, a purchase order. The BAPÌ Undelete()
removes a deletion flag. These BAPÌs are instance methods.
anceI() : Unlike the BAPÌ Delete () the BAPÌ Cancel() cancels an instance of a
business object, that is the instance to be cancelled remains in the database and an
additional instance is created that is canceled.
Add<subobject> and Remove<sub-object> : The BAPÌ Add<sub-object> adds a
sub-object to an existing object instance and the BAPÌ Remove<sub-object>
removes a sub-object from an object instance. These BAPÌs are instance methods.
- BAPIs for Mass Processing : When a BAPÌ is called, several business object
instances are processed at the same time. With BAPÌs for mass processing, the
suffix "Multiple" is added to the method name, for example, ChangeMultiple(),
CreateMultiple(), DeleteMultiple(). The BAPÌs here are always class methods.
- BAPIs for RepIicating Business Object Instances : The following BAPÌs are
used for replicating business object instances:
RepIicate() and SaveRepIica() : The BAPÌs Replicate() and SaveReplica() are
implemented as methods of replicable business object types(). They enable specific
instances of an object type to be copied to one or more different systems. These
BAPÌs are used mainly to transfer data between distributed systems within the
context of Application Link Enabling (ALE). These BAPÌs are class methods.
· Standardized Parameters : There are some parameters that can be created for
various BAPÌs because they contain the same or equivalent data in all BAPÌs. Such
parameters are known as "standardized" parameters. They should be implemented
the same in all BAPÌs.
· BAPIs for onverting Between InternaI and ExternaI Data Formats (Domain
- BapiService.DataonversionInt2Ext1() : This BAPÌ converts data from the internal
format into the required external format.
- BapiService.DataonversionExt2Int1() : This BAPÌ converts data from the
external format into the required internal format.
The data can only be converted provided that the conversion routines for the
domains underlying the data to be converted are maintained in the ABAP Dictionary.
Otherwise, the data is returned unconverted.
· Transaction ModeI for DeveIoping BAPIs : Within the context of the transaction
model used to develop BAPÌs, a transaction represents one processing step or one
logical unit of work (LUW). An R/3 LUW is all the steps involved in a transaction
including updating the database. The ACÌD principle applies to transaction models,
meaning that transactions are:
Atomic : When a transaction is called, database operations are either fully executed or
not at all. Either all relevant data has to be changed in the database or none at all.
Consistent : Ìf a transaction is called more than once, each call must have the same
result. No data is imported that may indirectly affect the result.
Ìsolated : There must be no functional dependencies between two transactions, one
Durable : Changes cannot be reversed and transactions cannot be canceled.
transaction must not affect another transaction.
A BAPÌ must be implemented so that it is transactional. Ìn other words, it complies with
the ACÌD principle. The BAPÌ transaction model must also enable users to combine
several BAPÌs in one LUW. The BAPÌ transaction model must afford the user explicit
transaction control. Therefore, if several BAPÌs are called together, the caller can
decide him/herself when to execute a COMMÌT WORK (or, as the case may be, a
ROLLBACK WORK). This means that BAPÌs themselves cannot (generally) execute a
COMMÌT WORK command. The following restrictions apply to combining several
BAPÌs in one LUW:
- Ìf an instance was created, modified or deleted by a write BAPÌ, a read BAPÌ can
only access the most recent data if a COMMÌT WORK has taken place.
- Ìt is not possible to make two write accesses on the same instance within one LUW.
For example, you cannot first create and then change the object within same LUW.
You can, however, create several instances of the same object type within an LUW.
Additionally, the call of a BAPÌ must not trigger further LUWs that are independent of
the BAPÌ. For this reason BAPÌs must not contain the following commands:
- CALL TRANSACTÌON
- SUBMÌT REPORT
- SUBMÌT REPORT AND RETURN
· OId BAPI Transaction ModeI (with ommit) : Ìf a BAPÌ executes a COMMÌT
WORK command, this must be mentioned in the BAPÌ documentation. This is the only
way users are able to know that the BAPÌ contains a COMMÌT WORK command.
aII BAPI to read and/or change data
aII BAPI to read and/or change data
· BAPI Transaction ModeI (Without ommit) :
aII BAPI apiService.TransactionCommit()
aII BAPI apiService.TransactionCommit()
· SAP Enhancements to ReIeased BAPIs : Whenever SAP enhances a BAPÌ,
downward compatibility of syntax & contents must be guaranteed whenever possible.
Accordingly, when you enhance a BAPÌ, you can differentiate between a compatible
enhancement and an incompatible enhancement depending on whether the downward
compatibility of the BAPÌ can be guaranteed. To protect the stability of the interface,
compatible enhancements are always preferred to incompatible enhancements.
Changes made to a BAPÌ only take effect when the changes are defined in the
Business Object Repository (BOR), that is, they have been saved and generated.
Version management of BAPÌs is also carried out in the BOR.
· ompatibIe hanges to Function ModuIes :
In interface :
- New optional parameter as a field
- New optional parameter as a structure
- New optional parameter as a table
- Adding new optional field to the structure at the end
- Adding new optional field to the table at the end
- Compatible changes to field types (in the ABAP Dictionary)
- Converting mandatory fields to optional fields
In program code :
- New additional coding that does not involve changes to the interpretation/processing
- Changes to the existing code which do not involve changing the interpretation or
- Using customer exits.
· IncompatibIe hanges to Function ModuIes :
In interface :
- New mandatory parameter
- Adding new fields between existing fields in the structure
- Adding new fields between existing fields in the table
- Adding new mandatory fields to the structure
- Adding new mandatory fields to the table
- Ìncompatible changes to field types (in the ABAP Dictionary)
- Changing optional fields to mandatory fields
- Renaming parameters
In program code :
- New additional source code that involves changes to the interpretation
- Changes to the existing source code that involve changing to the interpretation
- Adding or removing COMMÌT WORK commands in the program
Ìn cases of incompatible changes to a BAPÌ, you should work through the following
three steps: Create an additional BAPÌ, Support and label the expiring BAPÌ and Delete
the replaced BAPÌ.
reate an AdditionaI BAPI : To ensure that the interface stability of an existing BAPÌ
is not impaired, you must not make any incompatible changes to the existing BAPÌ.
Ìnstead, create one or, if necessary, several additional BAPÌs to replace the existing
one. The new BAPÌ must retain the same name as the BAPÌ to be replaced. A numeric
suffix is simply added to it. This suffix changes if further incompatible changes are
Support and abeI the Expiring BAPI : After the BAPÌ has been superseded by a
new BAPÌ, you should not remove the replaced BAPÌ from the Business Object
Repository (BOR). Ìnstead, you first label this BAPÌ as expired, and continue its support
in the release in which you have introduced the new BAPÌ as well as in the next
functional release. During this time the original BAPÌ must remain fully functional and
executable. The following tasks are required when a BAPÌ has expired /obsolete:
- Select the relevant SAP business object type in the Business Object Builder, and
open the node Methods. Position the cursor on the BAPÌ, and choose dit-> Change
status to -> bsolete.
- Ìn the BOR, document which method(s) are to replace the expiring BAPÌ.
- Record the BAPÌs that have been set to "obsolete" in a particular release in note
number 0107644, "Collective Note for Obsolete BAPÌs from Release 4.5A", in
SAPNet- R/3 Frontend.
- Ìnform your users about the relevant successor BAPÌs in Release Notes.
DeIete the RepIaced BAPI : Ìf the expiry phase of a BAPÌ set to obsolete has come to
an end, you can remove the BAPÌ from the BOR. You should delete an obsolete BAPÌ
as close to the beginning of a new release as possible, so that developers have time to
adjust to its successor. To delete a BAPÌ, follow the steps below:
- Delete the method from the BOR : To do this, display the relevant SAP business
object type in the Business Object Builder in change mode. Expand the node
Methods Place the cursor on appropriate BAPÌ, & delete it by choosing dit -> delete.
- Delete the function module that implements the BAPÌ : Ìn the Function Builder, enter
the name of the function module in the Function module field, and choose Function
module -> ther functions -> elete.
- Record the release in which the BAPÌ was deleted from the BOR in the note number
0107644, "Collective Note for Obsolete BAPÌs from Release 4.5A", in SAPNet ÷ R/3
· aIIing BAPIs from different pIatforms :
Calling BAPÌs from Java : Refer Library help
Calling BAPÌs from Visual Basic : Refer Library help
Calling BAPÌs from ABAP : Like normal function module
BAPI Programming Guide
AppIication ink EnabIing (AE) Quick Start
This guide describes the steps involved in setting up an ALE distribution of application
data in R/3 Systems. You will learn how to set up a message flow between two clients
and to distribute material master data between them using SAE Tcode.
1. Setting up Iients : First of all, you have to set up two clients to enable communi
-cation between logical systems. The two clients may be located in the same R/3
system or in separate systems. $uppose Clients 800 and 000 are provided. Client 800
is a source client and client 000 is a target client.
2. Defining ogicaI System Names for Iients : To avoid any confusion, participating
systems in a distributed environment must have an unique ÌD. The name of the logical
system is used as the unique ÌD. This name is assigned explicitly to one client in an
R/3 System. Go to SAE Tcode->Logical Systems->Define Logical Systems->New
Entries->Client 800 is named logical system LOGSYS800 and Client 000 is named
logical system LOGSYS000. Ìf you are using two clients in different physical systems,
make sure your settings (Logical system name and description) are the same in both
systems. When using two clients in one physical R/3 System, you only have to make
the settings once, since the entries are client-independent.
3. Assign ogicaI System to Iient : Assign the respective logical system to both the
clients. Choose Assign Logical $ystem to Client. Execute the function in both clients.
To display the client maintenance screen, double-click on a client. Ìn the Logical
system field, enter logical system to be assigned to individual client. Save your entry.
Assign LOGSYS800 to 800 client and LOGSYS000 to 000 client.
4. reate RF Destinations for both Iients : For the two logical systems to be able
to communicate with one another, they must know how to connect to each other. The
RFC destination provides this information. Ìn each of the two clients, you must assign
the RFC destination for the other logical system. Login in 800 Create RFC Destinations
(SM59)->Create->RFC destination (LOGSYS000)->Connection Type (3)-> Description
as RFC destination for the logical system LOGSYS800->Logon & Security->As logon
parameters, enter the logon language (EN ), the logon client (000) and the logon user
(user ÌD with target system password)->Technical Settings->Target host (Target
Application server host name)->System Number(00)->Save. The target system
indicates which receiving system application server is to handle the communication.
The specifications could be the UNÌX host name, the host name in DNS format, the ÌP
address or the SAP router name. The system number indicates the service used (TCP
service, SAP system number). Ìn SAP logon you can determine the target system and
the system number by selecting the button $erver: Ìn Transaction SM51 you can
display a list of the SAP servers in the target system. After saving the RFC destination,
you can use Test connection to test the connection, and try to logon via #emote Logon.
Ìf you succeed, the system displays a new window for the other system. To check that
you are in the correct client choose $ystem -> $tatus. Repeat the steps for target client
5. Maintain Distribution ModeI and Add Message Type : The systems involved in the
distribution must know which messages are to be distributed. They must know where
the messages are coming from and where they are going to. This information is
specified in the distribution model. The distribution is based on the distribution model
and is directly controlled by it. The following sections show you how to model a
message flow between your two logical systems. You are going to distribute material
master data from one logical system to another. Modeling involves maintaining model
views of the distribution model. To create a new distribution model Logon to the logical
system from which you want to send materials to another system (Login in 800 client
sending system LOGSYS800).Go to maintain Distribution model and Distribute Views
(BD64)->Change Mode->Create Model view->Enter the technical name MATMASDÌST
and a description for it->Position the cursor on MATMASDÌST and select Add message
type->Enter the logical system name of the sender LOGSYS800 and the receiver
LOGSYS000 and the message type MATMAS-> Save the distribution model.
6. Generating Partner ProfiIes in the Sending System : When you have created the
distribution model, you must tell the participating systems how ALE is to execute to
transfer the data. This is done in the partner profiles. First, generate the partner profiles
in the sending system (LOGSYS800). To do this, log on to the relevant logical system
->Generate Partner Profiles(BD82)->Enter MATMASDÌST as the name of your
distribution model. Without changing the parameters proposed by the system, execute
the program. The partner profiles required have now been generated on the sending
system. The system will create partners, port with RFC destinations and Outbound
7. Distributing the Distribution ModeI : To be able to generate the partner profiles in
the receiving system, this system must be informed of all the messages flows in the
distributed environment. This is achieved when you transport the distribution model
views from the sending system to the receiving system. Go to Maintain Distribution
model->Edit -> Model View-> Distribute->Enter the model view MATMASDÌST->
Select LOGSYS000 , the name of the receiving logical system->Execute the program.
Your distribution model view will be copied to the receiving system. You can also
Transport the Model View Edit -> Model View-> Transport. You can also create the
same model view in receiver system.
8. Generating Partner ProfiIes in the Receiving System : When you have copied the
distribution model to the receiving system, you can also generate the partner profiles
here. To do this, log on to the receiving logical system (for example, LOGSYS000 ).
Generate Partner Profiles(BD82)->Enter the name of your distribution model view
(MATMASDÌST) Without changing the parameters proposed by the system, execute the
program. The required partner profiles will be generated in the receiving system.
9. reating MateriaI Master Data : Once you have made all the settings required to
distribute materials, you can create a material and then distribute it. Log on again to the
sending system and Create a new material by using MM01 Tcode. Enter the material,
industry sector and material type. Make sure that the industry sector and material type
you enter are known in the receiving system. Otherwise, errors will occur when you post
the material in the receiving system. Choose Select view and then Basic data. Enter the
basic data of your material->Material short text->Base unit of measure->Save the
10. Sending MateriaI Master Data : Followings are the some selection programs /
Tcodes for different master data.
BD10 Send Material
BD11 Get Material
BD12 Send Customer
BD13 Get Customer
BD14 Send vendor
BD15 Get vendor
Enter the following data in BD10:
- The material no that you have created
- Message type: MATMAS for R/3 standard, ARTMAS for R/3 Retail
- A target system
- Ìf you want to send configuration values for material variants in the ÌDoc of the material
master record, activate the $end Material Completely indicator
- Specify the application server group you want to use
- Ìf you want to send more than one material at a time, specify the number of
materials that you want to send together.
Execute a selection program ( BD10). You should now be able to display your material
in the receiving system. Ìf the material is not available here, either the transmission has
not yet finished or an error has occurred.
11. hecking Processing Status : The system provides functions for monitoring
communication. These functions enable you to confirm whether ALE messages have
been processed and transferred correctly or whether errors occurred. You can monitor
the processing status in both the sending system and the receiving system by using
WE02 (Display ÌDoc List) or BD87 (Status Monitor for ALE Messages).
Execute the function, and select the ÌDocs of the logical message type MATMAS which
you created today. A list of inbound and outbound ÌDocs grouped by status is displayed:
Status Description of Status
03, 12, 38 ÌDoc successfully transferred
02, 04, 05, 2526, 29 Processing error
30 Waiting status (still processing...)
>=50 Ìnbound ÌDoc (not relevant in this context)
Other Not relevant in this context
Status Description of Status
53 ÌDoc successfully updated by application
64 Waiting status (still processing...)
<50 Outbound ÌDoc (not relevant in this context)
51, 56, 60, 61,63, 65 Ìnbound error
Other Not relevant in this context
Ìf an error has occurred, use the monitoring function to resolve it. The cause of the error
is likely to be a value in your material that the receiving system does not know and
therefore can't process it. Send your material again. Ìf your ÌDoc in the sending system
was successfully transferred (status 03) but does not appear in the receiving system, a
technical communication error is the likely cause. You can use the status monitor in the
sending system to check this. Choose Goto -> Transactional RFC ->Display calls. Ìf an
error occurs you should consult your system administrator.
AE Introduction and Administration
The integration technology Application Link nabling (ALE) is an important middleware
tool in SAP's Business Framework Architecture (BFA). BFA is a component-based
architecture enabling software components from SAP and from other software vendors
to communicate and be integrated with each other. ALE can integrate business
processes between R/3 Systems & non-R/3 systems as well as between R/3 systems.
Data is exchanged between applications and remains consistent in all applications.
Application systems are loosely coupled in an ALE integrated system. Data is
exchanged asynchronously, whereby the data arrives in the receiver system, even if the
receiver system cannot be connected to at the time the data is sent. ALE uses
synchronous communication for reading data only. To make it easier to assign ALE
functions to specific user types, the following user roles have been defined:
- ALE Administration SAP_BC_MÌD_ALE_ADMÌN
- ALE Development SAP_BC_MÌD_ALE_DEVELOPER
- Logistics - Master Data Distribution SAP_BC_MÌD_ALE_MD_LO
- Accounting - Master Data Distribution SAP_BC_MÌD_ALE_MD_FÌ
- Human Resources - Master Data Distribution SAP_BC_MÌD_ALE_MD_HR
Company-wide applications such as accounting, human resource management and
sales planning may be carried out in the company's headquarters, whereas production
and materials management may be carried out in decentralized plants.
Decentralized business applications ensuring data consistency are used because:
- The increasing globalization of markets has led to the physical division of
- Business processes are not restricted to one organization only and more and more
customers and vendors are becoming involved.
- R/3 System performance can be improved by distributing the business applications.
ALE supports the configuration and operation of distributed applications. ALE controls
Messaging across loosely coupled R/3 Systems, ensuring that data is always
consistent. Applications are integrated using a local database rather than a central one.
There is no data retention. ALE guarantees the distribution and synchronization of
master data,customizing data & transaction data through asynchronous communication.
Ìf ALE business processes are supported, functions and processes must be defined on
a cross-system basis. The message types exchanged between the systems are defined
in the distribution model. When defining organizational units like company codes and
plants in the R/3 System, it is important to note that these have to be unique worldwide,
across all systems. For example, the plant 0001 can only exist in one R/3 System.
· Benefits of AE:
- Application data can be distributed between different releases of R/3 Systems
- Data can continue to be exchanged after a release upgrade without requiring special
- Customers can add their own enhancements
- Communication interfaces enable connections to non-SAP systems.
- R/3 and R/2 Systems can communicate with each other.
- ALE has functions for monitoring messages flows & handling communication
· IDocs : An intermediate document (ÌDoc) is a container for exchanging data between
R/3, R/2 and non-SAP systems. ALE uses ÌDocs to exchange data between logical
systems. Non SAP-systems can use ÌDocs as the standard interface for data transfer.
ÌDocs are created by message types and (object) methods when data is to be
distributed. The message type is the format in which the data for a specific business
process is transmitted electronically. An ÌDoc represents a configuration of an
IDoc Type that determines the ÌDoc structure. ExampIe: The order number 4711 has
been sent to a supplier as ÌDoc no. 0815. ÌDoc number 0815 is formatted in the ÌDoc
type ORDERS 1, and has the status records "created" and "sent". The purchase order
corresponds to the "logical" message type ORDERS.
An ÌDoc consists of a control records, several data segment records and status
records. The functions of the individual elements of an ÌDoc are as follows:
- Message type, ÌDoc type, sender, receiver and current status of the ÌDoc are defined
in the ÌDoc control records.
- Each data segment contains a sequential segment number, name, type and a 1000
character long string field containing the actual data of the segment.
- The status records show the history of processing steps applied to the ÌDoc so far.
The structure of the ÌDoc is recorded in the SAP System. The structure definition
covers the following:
- The segment sequence. Hierarchical relationships between segments are possible.
The number of times a segment can occur is specified for each segment, as is
whether the segment is a mandatory segment or an optional segment.
- The fields contained in a segment.
Ìn the example shown above the ÌDoc contains a header segment that has to be the
first segment of the message. Thereafter there must be at least one additional item.
The following conditions apply:
- Each item must be followed by at least one sub-item and at most 99.
- Up to 9999 text segments can appear after an item's sub-items (optional).
- The last segment in a message must be an accumulation segment (ACCUM).
Note : An ÌDoc can only contain character fields.
ÌDoc type contains the Basic type and Extension.
Display ÌDoc by WE02 or BD87.
· Message Distribution : Asynchronous distribution of messages is possible via ALE
outbound and inbound processing. Message distribution is based on ÌDocs. ÌDocs are
created and dispatched in distributed systems using message types and SAP business
object methods (BAPÌs). An ÌDoc containing the data to be transferred is created and
prepared for dispatch in the outbound system. Then the ÌDoc is transferred to the target
system. Ìn the target system the ÌDoc starts inbound processing. The data is processed
and then posted in the application either fully automatically or part manually. Ìnbound
and outbound ÌDocs can be processed individually or in a packet. Ìn mass processing
several ÌDocs are processed together in one packet.
· Distribution Using BAPIs : BAPÌs can be called by applications synchronously or
asynchronously. Synchronously-called BAPÌs are only used for reading external data to
avoid database inconsistencies arising from communication errors. A BAPÌ should be
implemented as an asynchronous interface, if one of the criteria below applies:
- Consistent database changes in both systems : Data must be updated in the local
system as well as on a remote system
- Loose coupling : An asynchronous interface would represent too narrow a coupling
between the client and the server systems. Ìf the connection fails the client system
can no longer function correctly.
- Performance load : The interface is used often or it handles large volumes of data. A
synchronous interface cannot be used in this situation because performance would be
Ìf you want to implement a BAPÌ as an asynchronous interface, you have to generate
a BAPI-AE interface for an existing BAPÌ. Data distribution using BAPÌs is illustrated
in the graphic below:
egacy System Migration Workbench
The Legacy System Migration Workbench (Tcode - LSMW) is a tool that supports data
migration from legacy systems (non-SAP systems) to SAP systems. Ìt is a cross-
platform component of the SAP system. The LSMW comprises the following main
- Read data (legacy data in spreadsheet tables and/or sequential files). You can use
any combination of PC and server files.
- onvert data (from the source into the target format).
- Import data (to the database used by the SAP application).
The following additionaI functions are available:
- Import techniques : Apart from standard batch/direct input and recordings, BAPÌ and
ÌDocs are available as additional import methods.
- GIobaI functions : You can call certain functions from an ABAP code location of your
choice, and so influence the procedure used to migrate your data.
- Editor function : The source code for a target field can be checked. You can insert
source fields, global variables, and global functions as well as use the Pretty Printer.
- Action Iog : All the actions associated with an object are stored in an action log.
The field assignments for all parts of a project can be downloaded/uploaded in one
- Unassigned source fieIds: Neglected data can be displayed.
- Source fieIds: You can create source fields by copying them from other sources.
- Processing times: The ABAP code can be added to at different times.
· Authorizations: The LSM Workbench is independent from the client. Access to the
LSMW is controlled by authorizations. The assignment of these authorizations is
basically independent from the client. The isplay, ecute, Change, and
Administration functions can be controlled by assigning authorizations.
· Documentation: User-specific documentation can be stored at different levels and
formatted into an overall documentation by pressing the appropriate button.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.