Anda di halaman 1dari 45

HR ABAP Programming

What is ABAP/4?
Advanced Business Application Programming.ABAP is SAP's fourth generation language. All of
R/3's applications and even parts of its basic system are developed in ABAP. ABAP is used for
customization and modification of SAP applications.

HR ABAP

Logical Database (PNP)


Programming with Infotypes
Processing Time infotypes/Cluster
Processing Payroll infotypes/Cluster

Tools for Abapers.


Transactions (Development and Workbench)
ABAP Keywords
ABAP System fields (Structure SYST)
ABAP Sample Report
ABAP Links
ABAP Source ABAP/4 information and SAP technical documentation. A lot of useful reports,
interesting samples and free souce code.
SAP Hints and Tips on Configuration and Abap/4 Modules are Material Management, Production
Planning, Sales/Distribution, Financial, Controlling and Basis Components.

HR ABAP
1) Logical database

A logical database is a special ABAP/4 program which combines the contents of


certain database tables. Using logical databases facilitates the process of reading
database tables.
HR Logical Database is PNP
Main Functions of the logical database PNP:

Standard Selection screen


Data Retrieval
Authorization check

To use logical database PNP in your program, specify in your program attributes.
Standard Selection Screen

Date selection
Date selection delimits the time period for which data is evaluated. GET

PERNR retrieves all records of the relevant infotypes from the database.
When you enter a date selection period, the PROVIDE loop retrieves the
infotype records whose validity period overlaps with at least one day of this
period.
Person selection
Person selection is the 'true' selection of choosing a group of employees for
whom the report is to run.
Sorting Data
The standard sort sequence lists personnel numbers in ascending order.
SORT function allows you to sort the report data otherwise. All the sorting
fields are from infotype 0001.
Report Class
You can suppress input fields which are not used on the selection screen by
assigning a report class to your program.
If SAP standard delivered report classes do not satisfy your requirements,
you can create your own report class through the IMG.

Data Retrieval from LDB


1. Create data structures for infotypes.
INFOTYPES: 0001, "ORG ASSIGNMENT
0002, "PERSONAL DATA
0008. "BASIC PAY
2. Fill data structures with the infotype records.
Start-of-selection.
GET PERNR.
End-0f-selection.
Read Master Data

Infotype structures (after GET PERNR) are internal tables loaded with data.
The infotype records (selected within the period) are processed sequentially
by the PROVIDE - ENDPROVIDE loop.
GET PERNR.
PROVIDE * FROM Pnnnn BETWEEN PN/BEGDA AND PN/ENDDA
If Pnnnn-XXXX = ' '. write:/ Pnnnn-XXXX. endif.
ENDPROVIDE.

Period-Related Data
All infotype records are time stamped.
IT0006 (Address infotype)
01/01/1990 12/31/9999 present
Which record to be read depends on the date selection period specified on the
selection screen. PN/BEGDA PN/ENDDA.

Current Data
IT0006 Address - 01/01/1990 12/31/9999

present

RP-PROVIDE-FROM-LAST retrieves the record which is valid in the data selection


period.
For example, pn/begda = '19990931' pn/endda = '99991231'
IT0006 subtype 1 is resident address
RP-PROVIDE-FROM-LAST P0006 1 PN/BEGDA PN/ENDDA.

2) Process Infotypes

RMAC Modules - RMAC module as referred to Macro, is a special construct of


ABAP/4 codes. Normally, the program code of these modules is stored in table
'TRMAC'. The table key combines the program code under a given name. It
can also be defined in programs.The RMAC defined in the TRMAC can be used
in all Reports. When an RMAC is changed, the report has to be regenerated
manually to reflect the change.
Reading Infotypes - by using RMAC (macro) RP-READ-INFOTYPE
REPORT ZHR00001.
INFOTYPE: 0002.
PARAMETERS: PERNR LIKE P0002-PERNR.
RP-READ-INFOTYPE PERNR 0002 P0002 <BEGIN> <END>.
PROVIDE * FROM P0002
if ... then ...endif.
ENDPROVIDE.

Changing Infotypes - by using RMAC (macro) RP-READ-INFOTYPE.


Three steps are involved in changing infotypes:
1. Select the infotype records to be changed;
2. Make the required changes and store the records in an alternative table;
3. Save this table to the database;

The RP-UPDATE macro updates the database. The parameters of this macro are the
OLD internal table containing the unchanged records and the NEW internal table
containing the changed records. You cannot create or delete data. Only modification
is possible.
INFOTYPES: Pnnnn NAME OLD,
Pnnnn NAME NEW.
GET PERNR.
PROVIDE * FROM OLD
WHERE .... = ... "Change old record
*Save old record in alternate table
NEW = OLD.
ENDPROVIDE.
RP-UPDATE OLD NEW. "Update changed record
Infotype with repeat structures
How to identify repeat structures.

a. On infotype entry screen, data is entered in table form.


IT0005, IT0008, IT0041, etc.
b. In the infotype structure, fields are grouped by the same name followed by
sequence number.
P0005-UARnn P0005-UANnn P0005-UBEnn
P0005-UENnn P0005-UABnn
Repeat Structures
Data is entered on the infotype screen in table format but stored on the database in
a linear
structure.
Each row of the table is stored in the same record on the database.
When evaluating a repeat structure, you must define the starting point, the
increment and the
work area which contains the complete field group definition.
Repeat Structures Evaluation (I)
To evaluate the repeat structures
a. Define work area.
The work area is a field string. Its structure is identical to that of the field group.
b. Use a DO LOOP to divide the repeat structure into segments and make it
available for
processing in the work area, one field group (block) at a time.
Repeat Structures Evaluation(II)
* Define work area
DATA: BEGIN OF VACATION,
UAR LIKE P0005-UAR01, "Leave type
UAN LIKE P0005-UAN01, "Leave entitlement
UBE LIKE P0005-UBE01, "Start date
UEN LIKE P0005-UEN01, "End date
UAB LIKE P0005-UAB01, "Leave accounted
END OF VACATION.
GET PERNR.
RP-PROVIDE-FROM-LAST P0005 SPACE PN/BEGDA PN/ENDDA.
DO 6 TIMES VARYING VACATION
FROM P0005-UAR01 "Starting point
NEXT P0005-UAR02. "Increment
If p0005-xyz then ... endif.
ENDDO.

3) Processing 'Time Data'.

Dependence of time data on validity period


Importing time data
Processing time data using internal tables
Time Data and Validity Period
Time data always applies to a specific validity period.
The validity periods of different types of time data are not always the same as the

date selection period specified in the selection screen.


Date selection period |---------------|
Leave |-------------|
PROVIDE in this case is therefore not used for time infotypes.
Importing Time Data
GET PERNR reads all time infotypes from the lowest to highest system data, not
only those within the date selection period.
To prevent memory overload, add MODE N to the infotype declaration. This
prevents the logical database from importing all data into infotype tables at GET
PERNR.
Use macro RP-READ-ALL-TIME-ITY to fill infotype table.
INFOTYPES: 2001 MODE N.
GET PERNR.
RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.
LOOP AT P0021.
If P0021-XYZ = ' '. A=B. Endif.
ENDLOOP.
Processing Time Data
Once data is imported into infotype tables, you can use an internal table to process
the interested data.
DATA: BEGIN OF ITAB OCCURS 0,
BUKRS LIKE P0001-BUKRS, "COMPANY
WERKS LIKE P0001-WERKS, "PERSONNEL AREA
AWART LIKE P2001-AWART, "ABS./ATTEND. TYPE
ASWTG LIKE P2001-ASWTG, "ABS./ATTEND. DAYS
END OF ITAB.
GET PERNR.
RP-PROVIDE-FROM-LAST P0001 SAPCE PN/BEGDA PN/ENDDA.
CLEAR ITAB.
ITAB-BUKRS = P0001-BURKS. ITAB-WERKS = P0001-WERKS.
RP-READ-ALL-TIME-ITY PN/BEGDA PN/ENDDA.
LOOP AT P2001.
ITAB-AWART = P2001-AWART. ITAB-ASWTG = P2001-ASWTG.
COLLECT ITAB. (OR: APPEND ITAB.)
ENDLOOP.

4) Database Tables in HR
Personnel Administration (PA) - master and time data infotype tables (transparent
tables).
PAnnnn: e.g. PA0001 for infotype 0001
Personnel Development (PD) - Org Unit, Job, Position, etc. (transparent tables).
HRPnnnn: e.g. HRP1000 for infotype 1000
Time/Travel expense/Payroll/Applicant Tracking data/HR work areas/Documents

(cluster
PCLn: e.g. PCL2 for time/payroll results.
Cluster Table
Cluster tables combine the data from several tables with identical (or almost
identical) keys
into one physical record on the database.
. Data is written to a database in compressed form.
Retrieval of data is very fast if the primary key is known.
Cluster tables are defined in the data dictionary as transparent tables.
External programs can NOT interpret the data in a cluster table.
Special language elements EXPORT TO DATABASE, IMPORT TO DATABASE and
DELETE
FROM DATABASE are used to process data in the cluster tables.
PCL1
PCL2
PCL3
PCL4

Database for HR work area;


Accounting Results (time, travel expense and payroll);
Applicant tracking data;
Documents, Payroll year-end Tax data

Database Tables PCLn


PCLn database tables are divided into subareas known as data clusters.
Data Clusters are identified by a two-character code. e.g RU for US payroll result,
B2 for
time evaluation result...
Each HR subarea has its own cluster.
Each subarea has its own key.
Database Table PCL1
The database table PCL1 contains the following data areas:
B1 time events/PDC
G1 group incentive wages
L1 individual incentive wages
PC personal calendar
TE travel expenses/payroll results
TS travel expenses/master data
TX infotype texts
ZI PDC interface -> cost account
Database Table PCL2
The database table PCL2 contains the following data areas:
B2 time accounting results
CD cluster directory of the CD manager
PS generated schemas
PT texts for generated schemas
RX payroll accounting results/international
Rn payroll accounting results/country-specific ( n = HR country indicator )
ZL personal work schedule
Database Table PCL3
The database table PCL3 contains the following data areas:
AP action log / time schedule
TY texts for applicant data infotypes

Data Management of PCLn


The ABAP commands IMPORT and EXPORT are used for management of read/write
to
database tables PCLn.
A unique key has to be used when reading data from or writing data to the PCLn.
Field Name KEY Length Text
MANDT X 3 Client
RELID X 2 Relation ID (RU,B2..)
SRTFD X 40 Work Area Key
SRTF2 X 4 Sort key for dup. key
Cluster Definition
The data definition of a work area for PCLn is specified in separate programs which
comply
with fixed naming conventions.
They are defined as INCLUDE programs (RPCnxxy0). The following naming
convention applies:
n = 1 or 2 (PCL1 or PCL2)
xx = Relation ID (e.g. RX)
y = 0 for international clusters or country indicator (T500L) for different country
cluster
Exporting Data (I)
The EXPORT command causes one or more 'xy' KEY data objects to be written to
cluster xy.
The cluster definition is integrated with the INCLUDE statement.
REPORT ZHREXPRT.
TABLES: PCLn.
INCLUDE: RPCnxxy0. "Cluster definition
* Fill cluster KEY
xy-key-field = <value>.
* Fill data object
....
* Export record
EXPORT TABLE1 TO DATABASE PCLn(xy) ID xy-KEY.
IF SY-SUBRC EQ 0.
WRITE: / 'Update successful'.
ENDIF.
Exporting Data (II)
. Export data using macro RP-EXP-Cn-xy.
When data records are exported using macro, they are not written to the database
but to a
main memory buffer.
To save data, use the PREPARE_UPDATE routine with the USING parameter 'V'.
REPORT ZHREXPRT.
*Buffer definition
INCLUDE RPPPXD00. INCLUDE RPPPXM00. "Buffer management
DATA: BEGIN OF COMMON PART 'BUFFER'.

INCLUDE RPPPXD10.
DATA: END OF COMMON PART 'BUFFER'.
...
RP-EXP-Cn-xy.
IF SY-SUBRC EQ 0.
PERFORM PREPARE_UPDATE USING 'V'..
ENDIF.
Importing Data (I)
The IMPORT command causes data objects with the specified key values to be read
from
PCLn.
If the import is successful, SY-SUBRC is 0; if not, it is 4.
REPORT RPIMPORT.
TABLES: PCLn.
INCLUDE RPCnxxy0. "Cluster definition
* Fill cluster Key
* Import record
IMPORT TABLE1 FROM DATABASE PCLn(xy) ID xy-KEY.
IF SY-SUBRC EQ 0.
* Display data object
ENDIF.
Importing data (II)
Import data using macro RP-IMP-Cn-xy.
Check return code SY-SUBRC. If 0, it is successful. If 4, error.
Need include buffer management routines RPPPXM00
REPORT RPIMPORT.
*Buffer definition
INCLUDE RPPPXD00.
DATA: BEGIN OF COMMON PART 'BUFFER'.
INCLUDE RPPPXD10.
DATA: END OF COMMON PART 'BUFFER'.
*import data to buffer
RP-IMP-Cn-xy.
....
*Buffer management routines
INCLUDE RPPPXM00.
Cluster Authorization
Simple EXPORT/IMPORT statement does not check for cluster authorization.
Use EXPORT/IMPORT via buffer, the buffer management routines check for cluster
authorization.
Payroll Results (I)
Payroll results are stored in cluster Rn of PCL2 as field string and internal tables.
n - country identifier.
Standard reports read the results from cluster Rn. Report RPCLSTRn lists all payroll

results;
report RPCEDTn0 lists the results on a payroll form.
Payroll Results (II)
The cluster definition of payroll results is stored in two INLCUDE reports:
include: rpc2rx09. "Definition Cluster Ru (I)
include: rpc2ruu0. "Definition Cluster Ru (II)
The first INCLUDE defines the country-independent part; The second INCLUDE
defines the country-specific part (US).
The cluster key is stored in the field string RX-KEY.
Payroll Results (III)
All the field string and internal tables stored in PCL2 are defined in the ABAP/4
dictionary. This
allows you to use the same structures in different definitions and nonetheless
maintain data
consistency.
The structures for cluster definition comply with the name convention PCnnn.
Unfortunately,
'nnn' can be any set of alphanumeric characters.
*Key definition
DATA: BEGIN OF RX-KEY.
INCLUDE STRUCTURE PC200.
DATA: END OF RX-KEY.
*Payroll directory
DATA: BEGIN OF RGDIR OCCURS 100.
INCLUDE STRUCTURE PC261.
DATA: END OF RGDIR.
Payroll Cluster Directory
To read payroll results, you need two keys: pernr and seqno
. You can get SEQNO by importing the cluster directory (CD) first.
REPORT ZHRIMPRT.
TABLES: PERNR, PCL1, PCL2.
INLCUDE: rpc2cd09. "definition cluster CD
PARAMETERS: PERSON LIKE PERNR-PERNR.
...
RP-INIT-BUFFER.
*Import cluster Directory
CD-KEY-PERNR = PERNR-PERNR.
RP-IMP-C2-CU.
CHECK SY-SUBRC = 0.
LOOP AT RGDIR.
RX-KEY-PERNR = PERSON.
UNPACK RGDIR-SEQNR TO RX-KEY-SEQNO.
*Import data from PCL2
RP-IMP-C2-RU.

INLCUDE: RPPPXM00. "PCL1/PCL2 BUFFER HANDLING


Function Module (I)
CD_EVALUATION_PERIODS
After importing the payroll directory, which record to read is up to the programmer.
Each payroll result has a status.
'P' - previous result
'A' - current (actual) result
'O' - old result
Function module CD_EVALUATION_PERIODS will restore the payroll result status for
a period
when that payroll is initially run. It also will select all the relevant periods to be
evaluated.
Function Module (II)
CD_EVALUATION_PERIODS
call function 'CD_EVALUATION_PERIODS'
exporting
bonus_date = ref_periods-bondt
inper_modif = pn-permo
inper = ref_periods-inper
pay_type = ref_periods-payty
pay_ident = ref_periods-payid
tables
rgdir = rgdir
evpdir = evp
iabkrs = pnpabkrs
exceptions
no_record_found = 1.
Authorization Check
Authorization for Persons
In the authorization check for persons, the system determines whether the user
has the
authorizations required for the organizational features of the employees selected
with
GET PERNR.
Employees for which the user has no authorization are skipped and appear in a list
at the end
of the report.
Authorization object: 'HR: Master data'
Authorization for Data
In the authorization check for data, the system determines whether the user is
authorized to
read the infotypes specified in the report.
If the authorization for a particular infotype is missing, the evaluation is terminated
and an error
message is displayed.
Deactivating the Authorization Check

In certain reports, it may be useful to deactivate the authorization check in order to


improve
performance. (e.g. when running payroll)
You can store this information in the object 'HR: Reporting'.

TOOLS FOR ABAPERS:


TRANSCTIONS:
SCAM CATT Management
SCAT Computer Aided Test Tool
SE09 Workbench Organizer
SE10 Customizing Organizer
SE11 ABAP/4 Dictionary Maintenance
SE12 ABAP/4 Dictionary Display
SE13 Maintain Technical Settings (Tables)
SE14 Utilities for Dictionary Tables
SE15 ABAP/4 Repository Information System
SE16 Data Browser
SE17 General Table Display
SE30 ABAP/4 Runtime Analysis
SE32 ABAP/4 Text Element Maintenance
SE35 ABAP/4 Dialog Modules
SE36 ABAP/4: Logical Databases
SE37 ABAP/4 Function Modules
SE38 ABAP/4 Program Development
SE39 Splitscreen Editor: Program Compare
SE41 Menu Painter
SE43 Maintain Area Menu
SE51 Screen Painter
SE54 Generate View Maintenance Module
SE61 R/3 Documentation
SE62 Industry utilities
SE63 Translation
SE64 Terminology
SE65 R/3 document. short text statistics
SE66 R/3 Documentation Statistics (Test!)
SE68 Translation Administration
SE71 SAPscript layout set
SE72 SAPscript styles
SE73 SAPscript font maintenance (revised)
SE74 SAPscript format conversion
SE75 SAPscript Settings
SE76 SAPscript Translation Layout Sets
SE77 SAPscript Translation Styles
SE80 ABAP/4 Development Workbench
SE81 SAP Application Hierarchy
SE82 Customer Application Hierarchy
SE84 ABAP/4 Repository Information System
SE85 ABAP/4 Dictionary Information System
SE86 ABAP/4 Repository Information System

SE87 Data Modeler Information System


SE88 Development Coordination Info System
SE91 Maintain Messages
SE92 Maintain system log messages
SE93 Maintain Transaction Codes
SEU Object Browser
SHD0 Transaction variant maintenance
SQ00 ABAP/4 Query: Start Queries
SQ01 ABAP/4 Query: Maintain Queries
SQ02 ABAP/4 Query: Maintain Funct. Areas
SQ03 ABAP/4 Query: Maintain User Groups
SQ07 ABAP/4 Query: Language Comparison

KEYWORDS:
Keywords
, [, ], {, }
*, "
**
+, -, *, /
->, =>, ->>, ~, ?=
ABS
ACOS
ADD
ADD-CORRESPONDING
ADJACENT DUPLICATES
AND
ANY TABLE
APPEND
ASIN
ASSIGN
AT
ATAN
AUTHORITY-CHECK
AVG
BACK
BETWEEN
BINARY SEARCH
BIT-NOT
BIT-AND
BIT-OR
BIT-XOR
SET BIT
GET BIT
BLANK LINES
BREAK-POINT
C
CA
CALL
CASE

Description
Syntax conventions, Syntax notation
Comments
Arithm. Operator: Exponentiation (COMPUTE)
Arithmetical operators (COMPUTE)
Operators in ABAP Objects
Mathematical function: Absolute amount
COMPUTE)
Mathematical function: Cosine arc (COMPUTE)
Add
Field string addition
Delete duplicates from internal table (DELETE)
Comparison operator: and
Generic table type for internal tables
Append line to internaltable
Mathematical function: Sine arc (COMPUTE)
Assign field symbol
Event, control break, field group determination
Mathematical function: Tangent arc
Check authorization
Aggregate expression: Average (SELECT)
Positioning in list
Relational operator: Between
Binary read of internaltable (READ TABLE)
Bit calculation operator: NOT (COMPUTE)
Bit calculation operator: AND (COMPUTE)
Bit calculation operator: OR (COMPUTE)
Bit calculation operator: AND/OR (COMPUTE)
Set bit of an X field
Read bit of an X field
Switch on blank lines in list
Stop processing in debug mode
Data type for fixed-length character string
Contains any characters -Relational operator
forstring comparison
Call external component
Begin case distinction

CATCH
Exception handling (catch runtime errors)
CEIL
Mathematical function: Smallest whole value
CENTERED
Output format: Centered(WRITE)
CHECK
Check condition
CHECKBOX
Display as checkbox
PARAMETERS ... AS CHECKBOX
on the selection screen
WRITE ... AS CHECKBOX
in a list
CLASS
Definition of a class
CLASS-DATA
Static attributes in classes
CLASS-METHODS
Static methods in classes
CLASS-EVENTS
Static events in classes
CLASS-POOL
Introduction for type Kprograms
CLEAR
Initialize data object
CLIENT
Client handling when
DELETE ... CLIENT SPECIFIED
deleting from a database
EXPORT ... TO DATABASE ...
Storing a data cluster
CLIENT
IMPORT ... FROM DATABASE ...
Reading a data cluster
CLIENT
EXPORT ... TO SHARED BUFFER ...
Storing a data cluster
CLIENT
IMPORT ... FROM SHARED
Reading a data cluster
BUFFER ... CLIENT
INSERT ... CLIENT SPECIFIED
inserting into a database
MODIFY ... CLIENT SPECIFIED
Insert/Modify in database(s)
SELECT ... CLIENT SPECIFIED
reading from a database
UPDATE ... CLIENT SPECIFIED
updating a database
CLOSE
Close file/cursor
Contains Not Only - Relational operator for
CN
character comparison:
CNT
Field groups: Number ofdifferent values
Contains Only - Relational operator for character
CO
comparison:
CODE PAGE
Character set
TRANSLATE ... FROM/TOCODE
Translate character codes
PAGE
COLLECT
Internal table: Add entries
COLOR
Output format: Color (FORMAT)
COMMENT
Comment on selection screen
SELECTION-SCREEN COMMENT
Generate comment
COMMIT
Close processing unit
COMMUNICATION
Data exchange
COMPUTE
Perform calculations
CONCATENATE
Concatenate character fields
CONDENSE
Condense character fields
CONSTANTS
Defing constants
CONTEXTS
Communicate contexts
CONTINUE
Exit current loop pass
CONTROLS
Define controls for visualization
CONVERT
Convert fields
COS
Mathematical function: Cosine (COMPUTE)

COSH
COUNT
COUNTRY
CP
DATABASE
CREATE
CS
CURRENCY
CURSOR
CLOSE
FETCH NEXT CURSOR
GET CURSOR FIELD
OPEN CURSOR
SET CURSOR
CUSTOMER-FUNCTION
DATA
DATABASE
DELETE FROM DATABASE
EXPORT ... TO DATABASE
IMPORT ... FROM DATABASE
DATASET
CLOSE DATASET
DELETE DATASET
EXPORT ... TO DATASET
IMPORT ... FROM DATASET
OPEN DATASET Open file
READ DATASET
TRANSFER
DECIMALS
DEFINE
DELETE
DEMAND
DESCRIBE
DIALOG
DISTINCT
SELECT DISTINCT
AVG( DISTINCT ... )
COUNT( DISTINCT ... )
MAX( DISTINCT ... )
MIN( DISTINCT ... )
SUM( DISTINCT ... )
DIV
DIVIDE
DIVIDE-CORRESPONDINGField
string division
DO
DYNPRO
Screen

Mathematical function: Hyperbola cosine


(COMPUTE)
Aggregate expression: Count (SELECT)
Set country ID (SET)
Relational operator forcharacter comparison:
Contains Pattern
Generate an object or data object
Contains character - Relational operator
forcharacter comparison
Output format: Correct format for currency
(WRITE)
Cursor
Close database cursor
Read lines with a database cursor
Get field name
Open database cursor
Position cursor
Call customer enhancement
Define data
Data cluster
Delete from a database table
Store in a databasetable
Read from a database table
Sequential file
Close file
Delete file
Store data cluster in file
Read data cluster from file
Open file
Read from a file
Output to a file
Output format: Places after the decimal point (WRITE)
Define macro
Delete from tables or from objects
Request information from a context
Determine attributes ofdata objects
Call a dialog module (CALL)
Duplicates
Selection set without duplicates
Average without duplicates (SELECT)
Sequential file
Maximum without duplicates (SELECT)
Minimum without duplicates (SELECT)
Sum without duplicates (SELECT)
Arithmetic operator: Whole number division
Divide
Field string division
Loop
Screen

DELETE DYNPRO Delete


EXPORT DYNPRO Export
GENERATE DYNPRO Generate
IMPORT DYNPRO Import
SYNTAX-CHECK FOR DYNPRO
Check
EDITOR-CALL
ELSE
ELSEIF
END-OF-DEFINITION
END-OF-PAGE
END-OF-SELECTION
ENDAT
ENDCASE
ENDCATCH
ENDDO
ENDEXEC
ENDFORM
ENDFUNCTION
ENDIF
ENDINTERFACE
ENDLOOP
ENDMODULE
ENDON
ENDPROVIDE
ENDSELECT
ENDWHILE
EQ
EXEC SQL
EXIT
EXP
EXPONENT
EXPORT
EXTENDED CHECK
EXTRACT
FETCH
FIELD-GROUPS
FIELD-SYMBOLS
FLOOR
FORM
FORMAT
FOR UPDATE
FRAC
FREE
FUNCTION
CALL FUNCTION
FUNCTION-POOL
GE
GENERATE
GET

Delete
Export
Generate
Import
Check
Call editor
Query
Query
End of a macro definition
Event: End of page handling in lists
Event: After processingof all records in a LDB
End of an event introduced by AT
End of case distinction
End of exception handling
End of a DO loop
End of a Native SQL statement
End of a subroutine
End of a function module
End of a query
End of an interface definition
End of a LOOP
End of a module definition
End of a conditional statement
End of a PROVIDE loop
End of a SELECT loop
End of a WHILE loop
Relational operator: Equals
Native SQL statement
Exit loop or terminate processing
Mathematical function: Exponential function
Output format: Exponentdisplay (WRITE)
Export data
Switch extended syntax check on/off (SET)
Generate extract dataset
Read line from a database table
Define field groups
Define field symbols
Mathematical function:Largest whole value
Define subroutine
Output format for lists
Read database table with lock (SELECT)
Mathematical function: Fraction (COMPUTE)
Release resources no longer needed
Define function module
Call function module
Introduction for type Fprograms
Relational operator: Greater than or equal
Generate a program or screen
Event, read settings

GT
HASHED TABLE
HEADER LINE
HELP-ID
DESCRIBE FIELD ... HELP-ID
HELP-REQUEST
PARAMETERS ... HELP-REQUEST
SELECT-OPTIONS ... HELPREQUEST
HIDE
HOTSPOT
ICON
IF
IMPORT
IN
INCLUDE
INDEX
INDEX TABLE
DELETE ... INDEX
INSERT ... INDEX
MODIFY ... INDEX
READ TABLE ... INDEX
INFOTYPES
INITIAL
INITIAL SIZE
INITIALIZATION
INPUT
INSERT
INTENSIFIED
INTERFACE
INTERFACES
INTERFACE-POOL
INVERSE
IS
IS ASSIGNED
IS INITIAL
IS REQUESTED
parameter
JOIN
LANGUAGE
LE
LEAVE
LEFT-JUSTIFIED
LIKE
TYPES ... LIKE
DATA ... LIKE
LINE
MODIFY LINE
READ LINE

Relational operator: Greater than


Table type for internalhashed tables
Define an internal table with header line (DATA)
Help ID for F1 help
Determine help ID
Self-programmed help (F1)
for parameters
for selection options
Store line information
Output format: Hotspot,interaction by simple mouse click (FORMAT)
Icons in lists
Query
Import data or a screen
Relational operator: Selection criterion
Include program components
Line index in an internal table
Delete line
Insert line
Modify line
Read line
Declare HR info type
Relational operator: Initial value
Define an internal table type (TYPES)
Event: Before display of the selection screen
Output format: Ready for input (FORMAT)
Insert into tables or objects
Output format: Intensified (FORMAT)
Definition of an interface
Class component interface
Introduction fortype J programs
Output format: Inverse (FORMAT)
Relational operator
Relational operator: Is the field symbol
assigned?
Relational operator: Initial value
Relational operator: Existence of a formal
Join (SELECT)
Set language for text elements (SET)
Relational operator: Less than or equal
Leave processing
Output format: Left-justified (WRITE)
Use an existing field as areference
Create a type
Create a field
Line in a list
Modify line
Read line

LINE-COUNT
LINE-SIZE
LIST-PROCESSING
LOAD
LOAD-OF-PROGRAM
LOCAL
LOCAL COPY
LOCALE
SET LOCALE
GET LOCALE
LOG
Logical condition
SELECT ... WHERE
UPDATE ... WHERE
DELETE ... WHERE
SELECT ... FROM ... ON

Number of lines per page (NEW-PAGE)


Line size (NEW-PAGE)
List processing (LEAVE)
Load program componentsin internal table
Execution at load time
Rescue actual parameters of a subroutine
Assign local copy to a field symbol
Set text environment (SET)
Set text environment
Determine text environment
Mathematical function: Natural logarithm
(COMPUTE)

when reading database tables


when changing database tables
when deleting fromdatabase tables
when reading usinga join
Mathematical function: Base 10 logarithm
LOG10
(COMPUTE)
LOOP
Loop
LT
Relational operator: Less than
Relational operator: Byte contains zeros and
M
ones
MARGIN
List output: Distance from edge (SET)
MATCHCODE
Matchcode handling
PARAMETERS ... MATCHCODE
for parameters
SELECT-OPTIONS ... MATCHCODE for selection options
MAX
Aggregate expression: Maximum (SELECT)
MEMORY
ABAP/4 memory
EXPORT ... TO MEMORY
Roll out data to memory
IMPORT ... FROM MEMORY
Restore data from memory
MESSAGE
Output message
MESSAGE-ID
Specify message class (REPORT)
METHOD
Definition of a method
METHODS
Class component method
MIN
Aggregate expression: Minimum (SELECT)
MOD
Arithmetic operator: Remainder after division
(COMPUTE)
MODIFY
Modify tables or objects
MODULE
Flow logic: Module
MOVE
Assignment
MOVE-CORRESPONDING
Component-by-component assignment
MULTIPLY
Multiply
MULTIPLY-CORRESPONDING
Field string multiplication
NA
Relational operator forcharacter comparison:
Contains not any characters
NE
Relational operator: Not equal
NEW-LINE
List processing: New line
NEW-PAGE
List processing: New page
NODES
Interface work area forlogical databases
NO-GAP
Output format: Leave nogaps (WRITE)

NO-HEADING
NO-SCROLLING
NO-SIGN
NO-TITLE
NO-ZERO
NON-UNIQUE
TYPES
DATA
NP
NS
O
OBJECT
CREATE OBJECT
FREE OBJECT
OCCURS
TYPES
DATA
ON CHANGE
OPEN
OR
ORDER BY
OVERLAY
PACK
PARAMETER
GET
SET
PARAMETERS
PERFORM
PF-STATUS
POSITION
PRINT
PRINT-CONTROL
PRIVATE
PROGRAM
LEAVE PROGRAM
PROPERTY
GET PROPERTY
SET PROPERTY
PROVIDE
PUT
RADIOBUTTON
RAISE
RAISING
RANGES
READ
RECEIVE
REFRESH

Display no column headers (NEW-PAGE)


Do not scroll line (NEW-LINE)
Output format: No preceding signs (WRITE)
Do not display standardpage header (NEWPAGE)
Output format: No leading zeros (WRITE)
Defines an
internal table type
internal table object
Relational operator forcharacter comparison:
Does not contain pattern
Relational operator forcharacter comparison:
Does not contain character
Relational operator: Byte positions occupied by1
External object
Generate
Release
Defines an
internal table type
internal table object
Control break
Open file/cursor
Relational operator: OR
Sort table rows (SELECT)
Overlay character fields
Conversion
Parameter in global SAP memory
Read parameter
Set parameter
Define report parameters
Execute subroutine
Set GUI status
List processing: Defineoutput position
Print formatting (NEW-PAGE)
Define print format
Class area not visible from outside
Introduction for type Mand S programs
Leave program
Object property
Get property
Set property
Internal tables: Interval-related processing
Trigger event
Radio button (PARAMETERS)
Raise exceptions and events
Raise error message in function module
Define internal table for selection criterion
Read tables or objects
Receive results (RFC)
Delete internal table

REFRESH CONTROL
REJECT
REPLACE
REPORT
DELETE REPORT
EDITOR-CALL FOR REPORT
INSERT REPORT
READ REPORT
RESERVE
RESET
RIGHT-JUSTIFIED
ROLLBACK
ROUND
RTTI
RUN TIME ANALYZER
SCAN
SCREEN
CALL SCREEN
SET SCREEN
LEAVE SCREEN
LEAVE TO SCREEN
LOOP AT SCREEN
MODIFY SCREEN
SCROLL
SCROLL-BOUNDARY
SEARCH
SELECT
SELECT-OPTIONS
SELECTION-SCREEN
AT SELECTION-SCREENEvent:
SHARED BUFFER
DELETE FROM SHARED BUFFER
EXPORT ... TO SHARED BUFFER
IMPORT ... FROM SHARED BUFFER
SELECTION-TABLE
SET
SHIFT
SIGN
SIN
SINGLE
SINH
SKIP
SORT
SORTED TABLE
SPLIT
SQRT
STANDARD TABLE
START-OF-SELECTION
STATICS

Initialize control
Do not process current database line further
Replace characters
Introduction for type 1programs
Delete program
Call ABAP program editor
Insert program in library
Read program
List processing: Conditional new page
Output format: Reset all formats (FORMAT)
Output format: Right justified (WRITE)
Roll back database changes
Output format: Scaled (WRITE)
Runtime type identification
Activate/Deactivate runtime analysis (SET)
Analyze ABAP/4 source code
Screen
Call screen
Set next screen
Leave screen
Branch to a screen
Loop through screen fields
Modify screen fields
List processing: Scroll
List processing: Fix lead columns (SET)
Find character
Read database table
Define selection criterion
Design selection screen
After editing ofselection screen
Cross-transaction application buffer
delete from application buffer
Store data in application buffer
Read data from application buffer
Selection table (SUBMIT)
Set different processing parameters
Move character
Mathematical function: Sign (COMPUTE)
Mathematical function: Sine (COMPUTE)
Select single record (SELECT)
Mathematical function: Hyperbola sine
(COMPUTE)
List processing: Outputblank line
Sort internal table or extract dataset
Table type for internaltables that are always kept
Split character fields
Mathematical function: Square root (COMPUTE)
Table type for standardinternal tables
Event: Before first access to LDB
Define static data

STOP
STRING
STRLEN
STRUCTURE
INCLUDE STRUCTURE
SUBMIT
SUBTRACT
SUBTRACT-CORRESPONDING
SUM
SELECT ... SUM
SUPPLY
SUPPRESS DIALOG
SYMBOL
SYNTAX-CHECK
SYNTAX-TRACE
SYSTEM-CALL
SYSTEM-EXCEPTIONS
TABLE LINE
TABLE_LINE
TABLES
TABLE
DELETE ... FROM TABLE
INSERT ... FROM TABLE
MODIFY ... FROM TABLE
UPDATE ... FROM TABLE
SELECT ... INTO TABLE
TAN
TANH
TEXT
CONVERT TEXT
SORT itab AS TEXT
SORT AS TEXT
TEXTPOOL
DELETE TEXTPOOL
INSERT TEXTPOOL
READ TEXTPOOL
TIME
GET RUN TIME
GET TIME
SET RUN TIME ANALYZER
TIME STAMP
GET TIME STAMP
CONVERT TIME STAMP
WRITE f TIME ZONE
TITLEBAR
TOP-OF-PAGE
TRANSACTION
CALL TRANSACTION
LEAVE TO TRANSACTION

Stop data selection (LDB)


Data type for variable-length character sequence
Character function: Current length (COMPUTE)
Data structure
Use structure
Program call
Subtract
Field string subtraction
Calculate control total
Aggregate expression: Total
Supply context key fields
Suppress dialog
Output as symbol (WRITE)
Syntax check for programs and screens
Syntax check log
Call to various system services
Catch runtime errors (CATCH)
Unstructured lines in internal tables
Unstructured lines in internal tables
Declare database table
Set or array operations for database tables
Delete block of lines
Insert block of lines
Insert/update block of lines
Update block of lines
Copy block of lines to internal table
Mathematical function: Tangent (COMPUTE)
Mathematical function: Hyperbola tangent
(COMPUTE)
Locale-specific
Set format
Sort an internal table
Sort an extract dataset
Text elements
Delete
Insert
Read
Time measurement
Get runtime
Get time
Switch runtime analysison/off
Time stamp
Get time stamp
Convert time stamps to date/time
Output of time stamps to lists
Set screen title (SET)
Event: Top of page handling in lists
SAP transaction
Call
Leave to

TRANSFER
TRANSLATE
TRANSPORTING
MODIFY ... TRANSPORTING
READ ... TRANSPORTING
LOOP ... TRANSPORTING
TRUNC
TYPE
TYPES ... TYPE
DATA ... TYPE
TYPE-POOL
TYPE-POOLS
TYPES
ULINE
UNDER
UNIQUE
TYPES
DATA
UNIT
UNPACK
UPDATE
USER-COMMAND
USING
USING
USING EDIT MASK
VALUE-REQUEST
PARAMETERS ... VALUE-REQUEST
SELECT-OPTIONS ... VALUEREQUEST
WHEN
SELECT ... WHERE
UPDATE ... WHERE
DELETE ... WHERE
LOOP AT ... WHERE
DELETE ... WHERE
WHILE
WINDOW
WITH-TITLE
WORK
COMMIT WORK
ROLLBACK WORK
WRITE
WRITE TO
X
XSTRING
Z

Output to file
Character conversion incharacter fields
Selective field transport
Modify lines of an internal table
Read lines of an internal table
Loop through an internal table
Mathematical function: Whole number part
(COMPUTE)
Define a type
Define a type
Define a field
Introduction for type Tprograms
Include type group
Define types
List processing: Underscore
Output format: One under the other (WRITE)
Define an
internal table type
internal table object
Output format: Unit (WRITE)
Conversion
Update database table
List processing: Execute command immediately
(SET)
Use parameter or format
Parameter of a subroutine
Output format: Use template (WRITE)
Self-programmed value help(F4)
for parameters
for selection options
Case distinction
when reading from databasetables
when changing database tables
when deleting database tables
when looping at internal tables
when deleting from internal tables
Loop
List processing: Outputin window
Output standard page header (NEW-PAGE)
Processing unit
Close unit
Close unit, but undo changes
List processing: Output
Correct type output in a variable
Data type for fixed-length byte sequence
Data type for variable-length byte sequence
Relational bit operator: Bit positions occupiedby

ABAP SYSTEM FIELDS:


ABAP/4 System fields
ABCDE
APPLI
BATCH
BATZD
BATZM
BATZO
BATZS
BATZW
BINPT
BREP4
BSPLD
CALLD
CALLR
CCURS
CCURT
CDATE
COLNO
CPAGE
CPROG
CTABL
CTYPE
CUCOL
CUROW
DATAR
DATLO
DATUM
DATUT
DAYST
DBCNT
DBNAM
DBSYS
DCSYS
DSNAM
DYNGR
DYNNR
FDAYW
FDPOS
FMKEY
HOST

Constant: Alphabet (A,B,C,...)


SAP applications
Background active (X)
Background SUBMIT: Daily
Background SUBMIT: Monthly
Background SUBMIT: Once
Background SUBMIT: Immediately
Background SUBMIT: Weekly
Batch input active (X)
Background SUBMIT: Root name of
request report
Background SUBMIT: List output to spool
CALL mode active (X)
Print: ID for print dialog function
Rate specification/result field (CURRENCY
CONVERT)
Table rate from currency conversion
Date of rate from currency conversion
Current column during list creation
Current page number
Runtime: Main program
Exchange rate table from currency
conversion
Exchange rate type 'M','B','G' from
CURRENCY CONVERSION
Cursor position (column)
Cursor position (line)
Flag: Data received
Local date for user
System: Date
Global date related to UTC (GMT)
Summertime active ? ('daylight saving
time')
Number of elements in edited dataset with
DB operations
Logical database for ABAP/4 program
System: Database system
System: Dialog system
Runtime: Name of dataset for spool output
Screen group of current screen
Number of current screen
Factory calendar weekday
Location of a string
Current function code menu
Host

INDEX
LANGU
LDBPG
LILLI
LINCT
LINNO
LINSZ
LISEL
LISTI
LOCDB
LOCOP
LOOPC
LSIND
LSTAT
MACDB
MACOL
MANDT
MARKY
MAROW
MODNO
MSGID
MSGLI
MSGNO
MSGTY
MSGV1
MSGV2
MSGV3
MSGV4
OPSYS
PAART
PAGCT
PAGNO
PDEST
PEXPI
PFKEY
PLIST
PRABT
PRBIG
PRCOP
PRDSN
PREFX
PRIMM
PRNEW
PRREC

Number of loop passes


SAP logon language key
Program: ABAP/4 database program for
SY-DBNAM
Number of current list line
Number of list lines
Current line for list creation
Line size of list
Interact.: Selected line
Number of current list line
Local database exists
Local database operation
Number of LOOP lines at screen step loop
Number of secondary list
Interact.: Status information for each list
level
Program: Name of file for matchcode
access
Number of columns from SET MARGIN
Client number from SAP logon
Current line character for MARK
No. of lines from SET MARGIN statement
Number of alternative modi
Message ID
Interact.: Message line (line 23)
Message number
Message type (E,I.W,...)
Message variable
Message variable
Message variable
Message variable
System: Operating system
Print: Format
Page size of list from REPORT statement
Runtime: Current page in list
Print: Output device
Print: Spool retention period
Runtime: Current F key status
Print: Name of spool request (list name)
Print: Department on cover sheet
Print: Selection cover sheet
Print: Number of copies
Print: Name of spool dataset
ABAP/4 prefix for background jobs
Print: Print immediately
Print: New spool request (list)
Print: Recipient

PRREL
PRTXT
REPID
RTITL
SAPRL
SCOLS
SLSET
SPONO
SPONR
SROWS
STACO
STARO
STEPL
SUBRC
SUBTY
SYSID
TABIX
TCODE
TFDSN
TFILL
TIMLO
TIMUT
TITLE
TLENG
TMAXL
TNAME
TOCCU
TPAGI
TSTLO
TSTUT
TTABC
TTABI
TVAR0
TVAR1

Print: Delete after printing


Print: Text for cover sheet
Program: Name of ABAP/4 program
Print: Report title of program to be printed
System: SAP Release
Columns on screen
Name of selection set
Runtime: Spool number for list output
Runtime: Spool number from TRANSFER statement
Lines on screen
Interact.: List displayed from column
Interact.: Page displayed from line
Number of LOOP line at screen step
Return value after specific ABAP/4 statements
ABAP/4: Call type for SUBMIT
System: SAP System ID
Runtime: Current line of an internal table
Session: Current transaction code
Runtime: Dataset for data extracts
Current number of entries in internal table
Local time for user
Global time related to UTC (GMT)
Title of ABAP/4 program
Line width of an internal table
Maximum number of entries in internal table (?)
Name of internal table after an access (?)
OCCURS parameter with internal tables
Flag indicating roll-out of internal table to paging area (?)
Timestamp (date and time) for user
Timestamp (date and time) related to UTC (GMT)
Number of line last read in an internal table (?)
Offset of internal table in roll area (?)
Runtime: Text variable for ABAP/4 text elements
Runtime: Text variable for ABAP/4 text elements

EXAMPLES:
System fields I
Program code
REPORT ZBCTCB93 NO STANDARD PAGE HEADING.
DETAIL.
WRITE: /5 'Logon name of the user:
WRITE: /5 'Logon client:
WRITE: /5 'Logon language:

' RIGHT-JUSTIFIED, 40 SY-UNAME.


' RIGHT-JUSTIFIED, 40 SY-MANDT.
' RIGHT-JUSTIFIED, 40 SY-LANGU.

WRITE: /5 'Current date:


' RIGHT-JUSTIFIED, 40 SY-DATUM.
WRITE: /5 'Current time:
' RIGHT-JUSTIFIED, 40 SY-UZEIT.
WRITE: /5 'Current transaction:
' RIGHT-JUSTIFIED, 40 SY-TCODE.
WRITE: /5 'Main program:
' RIGHT-JUSTIFIED, 40 SY-CPROG.
SKIP.
WRITE: /5 'SAP System ID:
' RIGHT-JUSTIFIED, 40 SY-SYSID.
WRITE: /5 'SAP Release:
' RIGHT-JUSTIFIED, 40 SY-SAPRL.
WRITE: /5 'Host:
' RIGHT-JUSTIFIED, 40 SY-HOST.
WRITE: /5 'Operating system:
' RIGHT-JUSTIFIED, 40 SY-OPSYS.
WRITE: /5 'Database system:
' RIGHT-JUSTIFIED, 40 SY-DBSYS.
SKIP TO LINE 20. POSITION 10.
WRITE: SY-COLNO, ',', SY-LINNO, 'Cursor position (column, row).'.
WRITE: 'New:', SY-COLNO,',',SY-LINNO.
SKIP.
SY-ULINE = '------ Underline ------'.
ULINE (23).
WRITE: /5 'Vertical bar:', SY-VLINE.
TOP-OF-PAGE.
DETAIL.
WRITE: 2 'Report Title: ', SY-TITLE(20).
WRITE: 'Page Number: ', SY-PAGNO.
SKIP.

System fields II
Program code
REPORT ZBCTCB92.
TABLES: T000.
DATA: BEGIN OF T OCCURS 0,
FIELD(10),
END OF T.
DATA: NUM TYPE N.
DETAIL.
* sy-linct and sy-linsz describes a page of the list
WRITE: / 'Example of sy-linct and sy-linsz'.
SKIP.
WRITE: / SY-LINCT, 'line and', (3) SY-LINSZ, 'column is a page'.
* sy-index works in do-enddo and while-endwhile loops.
* it contains the number of loop passes.
WRITE: /'Example of sy-index'.
SKIP.
DO 5 TIMES.
WRITE: SY-INDEX.
ENDDO.
* sy-tabix is the index number of the currently processed row

* for an internal table


SKIP.
WRITE: /'Example of sy-tabix'.
SKIP.
T-FIELD = 'One'. APPEND T.
T-FIELD = 'Two'. APPEND T.
T-FIELD = 'Three'. APPEND T.
T-FIELD = 'Four'. APPEND T.
T-FIELD = 'Five'. APPEND T.
WRITE: /'Example of sy-tabix I'.
SKIP.
LOOP AT T.
WRITE: / SY-TABIX, T-FIELD.
ENDLOOP.
*sy-fdpos contains off-set after string comparison and search operations
SKIP.
WRITE: /'Example of sy-fdpos'.
SKIP.
CLEAR T.
SEARCH T FOR 're'.
READ TABLE T INDEX SY-TABIX.
WRITE: / SY-TABIX, T-FIELD.
SKIP.
WRITE: /9 'At the example of sy-tabix, Row', (3) SY-TABIX, ',' ,
'keyword ''re'' found at off-set position:', (3) SY-FDPOS.
SKIP.
* sy-dbcnt contains the number of selected records.
* sy-subrc is 0 if an operation was successful.
WRITE: /'Example of sy-dbcnt and sy-subrc I'.
SKIP.
SELECT * FROM T000 WHERE MANDT BETWEEN '000' AND '066'.
WRITE: /10 'Mandant:', T000-MANDT.
ENDSELECT.
WRITE: /12 'Number of selected records:', SY-DBCNT CENTERED.
WRITE: /12 'Return code: ' RIGHT-JUSTIFIED, SY-SUBRC .
SKIP.
WRITE: /'Example of sy-dbcnt and sy-subrc II: don't find records'.
SKIP.
SELECT * FROM T000 WHERE MANDT EQ -1.
ENDSELECT.
WRITE: /12 'Number of selected records:', SY-DBCNT CENTERED.
WRITE: /12 'Return code: ' RIGHT-JUSTIFIED, SY-SUBRC.

System fields III

Program code
REPORT ZBCTCB90 NO STANDARD PAGE HEADING
LINE-COUNT 20 LINE-SIZE 255.
TABLES: T000.
DETAIL.
DO 5 TIMES.
SELECT * FROM T000.
WRITE: / T000-MANDT, T000-MTEXT.
ENDSELECT.
NEW-PAGE.
ENDDO.
TOP-OF-PAGE.
WRITE: / 'Page', SY-PAGNO.
AT LINE-SELECTION.
DETAIL.
* SY-LSIND is the index of the current list
WRITE: / 'SY-LSIND:', SY-LSIND LEFT-JUSTIFIED.
* SY-LISTI is the index of the previous list
WRITE: / 'SY-LISTI:', SY-LISTI LEFT-JUSTIFIED.
* SY-LILLI is the number of the selected line in the absolute list
WRITE: / 'SY-LILLI:', SY-LILLI LEFT-JUSTIFIED.
* SY-CUROW is the position of the selected line on the screen
WRITE: / 'SY-CUROW:', SY-CUROW LEFT-JUSTIFIED.
* SY-CUCOL is the position of the cursor in the window
WRITE: / 'SY-CUCOL:', SY-CUCOL LEFT-JUSTIFIED.
SKIP.
WRITE: / 'SY-CPAGE and SY-STAR0 do not depend on the cursor
position'.
SKIP.
* SY-CPAGE is the currently displayed page of the list
WRITE: / 'SY-CPAGE:', SY-CPAGE LEFT-JUSTIFIED.
* SY-STARO is the number of the topmost actual list line displayed
* on the current page.
WRITE: / 'SY-STARO:', SY-STARO LEFT-JUSTIFIED.
SKIP.
* SY-STACO is the number of the first displayed column on the
* screen. Scroll the list right with the scrollbar to test it
WRITE: / 'SY-STACO:', SY-STACO LEFT-JUSTIFIED.
SKIP.
* contents of the selected line
WRITE: / 'SY-LISEL:', SY-LISEL.

System fields V
Program code

REPORT ZBCTCB93 NO STANDARD PAGE HEADING.


PARAMETERS: TEST.
DATA: SESSION TYPE I.
DATA: BEGIN OF T_TSTCT OCCURS 10.
INCLUDE STRUCTURE TSTCT.
DATA: END OF T_TSTCT.
DETAIL.
SESSION = SY-MODNO + 1.
SET MARGIN 5 3.
* The report must have a selection screen and from there execute+print
* should be called the SET MARGIN to take effect.
WRITE: / 'Number of this session:', SESSION.
WRITE: / 'List starts from the ', SY-MACOL, ',', SY-MAROW, 'upper-left
corner.'.
SKIP.
WRITE: / 'This is the', SY-FDAYW, '. workday of the week.'.
APPEND T_TSTCT.
APPEND T_TSTCT.
APPEND T_TSTCT.
DESCRIBE TABLE T_TSTCT.
WRITE: / 'Line width of internal table: 1 (lang) + 4 (tcode) + 36 (text) =', SYTLENG.
WRITE: / 'OCCURS parameter:', SY-TOCCU.
WRITE: / 'Number of entries in internal table:', SY-TFILL.

System fields IV
Program code
REPORT ZBCTCB99 NO STANDARD PAGE HEADING.
PARAMETERS: TEST.
DETAIL.
IF SY-BATCH EQ SPACE.
WRITE: / 'Report was started on-line'.
WRITE: / 'Using variant:', SY-SLSET.
ELSE.
WRITE: / 'Report was started in background'.
ENDIF.

System fields VI
SY-DATAR
In transaction programming this field indicates the change of data on the
screen. In the PBO part you may set default values of the input fields of

the dynpro. In the PAI part you can check if they were changed. If SYDATAR is set, then the user has modified or entered new data on the
screen.
SY-BINPT
This field indicates if the transaction was called in a Batch Input session or
by an online user.To test it, a batch input session must be created. From
Release 3.1g the next procedure can be used.
Create a report which displays this system field
Create a Transaction code for this report
Use transaction SHDB to record a the previous transaction
Press the Overview button and choose the 'generate
program' function.
Running the previously generated program it will create a
Batch Input session
Now call transaction SM35 and process the created Batch
Input in foreground. It should display an 'X' for system
field SY-BINPT.
SY-CALLD
This field indicates if the transaction was called from another transaction.
Create a report which displays this system field
Create a Transaction code for this report
Create a new report containing the next ABAP command:
CALL TRANSACTION tcode. Where tcode is the
Transaction code you created. When you run this report, it
should display an 'X' for system field SY-CALLD.

System fields VIII


REPORT ZSYSTEM LINE-SIZE 255.
TABLES: T100.
* Batch-input data
DATA: BEGIN OF G_BDCDATA OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF G_BDCDATA.
DATA: G_MESSAGE(200).
PERFORM FILL_BDCDATA.
CALL TRANSACTION 'FI01' USING G_BDCDATA MODE 'N'.
* of course it is nicer with a message itab, but this example
* should also demostrate the use of system variables.
SELECT SINGLE * FROM T100 WHERE
SPRSL = 'E'

AND ARBGB = SY-MSGID


AND MSGNR = SY-MSGNO.
G_MESSAGE = T100-TEXT.
PERFORM REPLACE_PARAMETERS USING
SY-MSGV2
SY-MSGV3
SY-MSGV4
CHANGING G_MESSAGE.

SY-MSGV1

WRITE: / 'System variables:'.


SKIP.
WRITE: / '
Sy-msgty:', SY-MSGTY.
WRITE: / '
Sy-msgid:', SY-MSGID.
WRITE: / '
Sy-msgno:', SY-MSGNO.
WRITE: / '
Sy-msgv1:', SY-MSGV1.
WRITE: / '
Sy-msgv2:', SY-MSGV2.
WRITE: / '
Sy-msgv3:', SY-MSGV3.
WRITE: / '
Sy-msgv4:', SY-MSGV4.
SKIP.
WRITE: / 'The transaction was called with a wrong country code.'.
WRITE: / 'The error message should be either that or that you have'.
WRITE: / ' no authorisation to execute the transaction'.
SKIP.
WRITE: / 'Message:'.
SKIP.
WRITE: / SY-MSGTY, G_MESSAGE.
*---------------------------------------------------------------------*
*
Build up the BDC-table
*
*---------------------------------------------------------------------*
FORM FILL_BDCDATA.
REFRESH G_BDCDATA.
PERFORM BDC_DYNPRO USING 'SAPMF02B' '0100'.
PERFORM BDC_FIELD USING 'BNKA-BANKS' 'ZZZ'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' 'QQQQQ'.
ENDFORM.
*---------------------------------------------------------------------*
*
FORM BDC_DYNPRO
*
*---------------------------------------------------------------------*
*
Batchinput: Start new Dynpro
*
*---------------------------------------------------------------------*
FORM BDC_DYNPRO USING P_PROGRAM P_DYNPRO.

CLEAR G_BDCDATA.
G_BDCDATA-PROGRAM = P_PROGRAM.
G_BDCDATA-DYNPRO = P_DYNPRO.
G_BDCDATA-DYNBEGIN = 'X'.
APPEND G_BDCDATA.
ENDFORM.
" BDC_DYNPRO
*---------------------------------------------------------------------*
*
FORM BDC_FIELD
*
*---------------------------------------------------------------------*
*
Batchinput: Feld hinzufugen
*
*---------------------------------------------------------------------*
FORM BDC_FIELD USING P_FNAM P_FVAL.
CLEAR G_BDCDATA.
G_BDCDATA-FNAM = P_FNAM.
G_BDCDATA-FVAL = P_FVAL.
APPEND G_BDCDATA.
ENDFORM.
" BDC_FIELD
*---------------------------------------------------------------------*
*
FORM REPLACE_PARAMETERS
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
* --> P_PAR_1
*
* --> P_PAR_2
*
* --> P_PAR_3
*
* --> P_PAR_4
*
* --> P_MESSAGE
*
*---------------------------------------------------------------------*
FORM REPLACE_PARAMETERS USING P_PAR_1
P_PAR_2
P_PAR_3
P_PAR_4
CHANGING P_MESSAGE.
* erst mal pruefen, ob numerierte Parameter verwendet wurden
DO.
REPLACE '&1' WITH P_PAR_1 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&2' WITH P_PAR_2 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.

ENDIF.
ENDDO.
DO.
REPLACE '&3' WITH P_PAR_3 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&4' WITH P_PAR_4 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
* falls keine numerierten Parameter vorh., ersetzen wie gehabt
REPLACE '&' WITH P_PAR_1 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_2 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_3 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_4 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.

"replace_parameters

SAMPLE REPORTS:

List program with column settings


Create Extract Dataset

Load a database table from a UNIX file

Interactive Reporting

SQL Syntax

SQL programming

ABAP

1) It's the first formatted list

report zbctcb98 no standard page heading line-size 90 line-count 120.


parameters: column type i default 40.
data: num2 type i value 2.
data: counter type i value 1.
check column ge 0 and column le 40.
do.
write: /2(4) counter, 15 'example', 23(4) num2,
o

at column 'hello world' intensified off.


add 1 to counter.
check counter eq 161.
exit.
enddo.
top-of-page.
write: /2 'Page:', 8(4) sy-pagno, 40 'Third Example', 70 sy-datum.
uline.
write: /2 'Counter', 15 'Text', 23 'Number',

at column 'Introduction' intensified off.


uline.
Try out the SHOW SY command in the editor command line. The SHOW
command describes the fields of database tables, views and structures. With
the SHOW SY command you can see the fields of the SYSTEM structure.
These fields are updated at run time. In this example we used the fields sypagno and sy-datum.

2) Q.Write a program that lists the Vendors and their Accounting documents.

Create extract dataset from KDF logical database. Loop through the dataset to create
the required report. Don't list those vendors which has no documents.
Creating Extract Dataset
Your code should be like this.
report zfwr0001 no standard page heading.
tables: lfa1, bsik.
field-groups: header, item1, item2.
insert lfa1-lifnr bsik-belnr into header.
insert lfa1-land1 lfa1-name1 into item1.

insert bsik-belnr bsik-budat into item2.


start-of-selection.
get lfa1.
....extract item1.
get bsik.
....extract item2.
end-of-selection.
loop.
....at item1 with item2.
........skip.
........write:/ 'Vendor number:', 28 'Name:', 56 'City:'.
........write: 16 lfa1-lifnr, 33(20) lfa1-name1, 62(20) lfa1-ort01.
........write:/ 'Document no.', 15 'Date'.
....endat.
....at item2.
........write:/ bsik-belnr, 13 bsik-budat.
....endat.
endloop.
Additional task:
Don't forget to set the Logical database to KDF on the "Program Attributes"
screen.
Result:
Vendor number: 100124 Name:Coca Cola City: New York
Document no. Date
1800000316 01/08/1997
Vendor number: 100126 Name: Universal Studios City: Los Angeles
Document no. Date
1800000109 12/02/1996
1800000341 01/10/1997
1800000321 01/14/1997

3) Q.Write a program to load a database table from a UNIX file


WRITE A PROGRAM TO LOAD A DATABASE TABLE FROM A UNIX FILE

report zmjud001 no standard page heading.


tables: z_mver.
parameters: test(60) lower case default '/dir/judit.txt'.
data: begin of unix_intab occurs 100,
field(53),
end of unix_intab.
data: msg(60).
***open the unix file
open dataset test for input in text mode message msg.
if sy-subrc <> 0.
write: / msg.
exit.
endif.
***load the unix file into an internal table

do.
read dataset test into unix_intab.
if sy-subrc ne 0.
exit.
else.
append unix_intab.
endif.
enddo.
close dataset test.
***to process the data. load the database table
loop at unix_intab.
z_mver-mandt = sy-mandt.
z_mver-matnr = unix_intab-field(10).
translate z_mver-matnr to upper case.
z_mver-werks = unix_intab-field+10(4).
translate z_mver-werks to upper case.
z_mver-gjahr = sy-datum(4).
z_mver-perkz = 'M'.
z_mver-mgv01 = unix_intab-field+14(13).
z_mver-mgv02 = unix_intab-field+27(13).
z_mver-mgv03 = unix_intab-field+40(13).
* to check the data on the screen (this is just for checking
purpose)
write: / z_mver-mandt, z_mver-matnr, z_mver-werks, z_mvergjahr,
z_mver-perkz, z_mver-mgv01,
z_mver-mgv02, z_mver-mgv03.
insert z_mver client specified.
*if the data already had been in table z_mver then sy-subrc
will not be
*equal with zero. (this can be *interesting for you - (this list is
*not necessary but it maybe useful for you)
if sy-subrc ne 0.
write:/ z_mver-matnr, z_mver-werks.
endif.
endloop.
NOTES:
1. This solution is recommended only if the database table is
NOT a standard SAP database table .
2. In the above mentioned unix file record's size is 53 bytes.
Every record in the unix file as the same size:
10 bytes for material
04 bytes for plant
13 bytes for corrected consumption for January
13 bytes for corrected consumption for February
13 bytes for corrected consumption for March
3. Table Z_MVER
This table was created to store the consumption values for first quarter of the
year.

Fields

Data Element
mandt
mandt
matnr
matnr
werks
werks
gjahr
gjahr
perkz
perkz
mgv01
mgvbr
mgv02
mgvbr
mgv03
mgvbr

4) Q. List the first 100 purchase requsitions at the plant 'PL01' (table EBAN). Then
make it possible to change the purchase requisition itself from the list by clicking
twice on the row or by using a push-button.
Interactive Reporting
In the purchasing (MM modul) you can process the purchase requisitions. The
purchase requisitions define primarily the need for a material/service. List the first
100 purchase requsitions at the plant 'PL01' (table EBAN). Then make it possible to
change the purchase requisition itself from the list by clicking twice on the row or by
using a push-button.
ADDITIONAL REQUIREMENTS TO THE LIST:
1. CONTENT: PURCHASE REQUISITION NUMBER, ITEM NUMBER, DOCUMENT TYPE,
MATERIAL, QUANTITY, UNIT OF MEASURE

2. LAYOUT: MAIN HEADER SHOULD INCLUDE


PROGRAM NAME, COMPANY NAME, PLANT, PURCHASE GROUP, CREATION DATE,
PAGE NUMBER
3. ONE PAGE SHOULD HAVE 50 LINE ITEM

report zmjud001 no standard page heading line-size 85 line-count 50.


* DATA /TABLES DECLARATION*
tables: eban.
data: prog_nam(8).
data: begin of pur_req occurs 100,
o

ekgrp like eban-ekgrp,


werks like eban-werks,
banfn like eban-banfn,
bnfpo like eban-bnfpo,
bsart like eban-bsart,
estkz like eban-estkz,
matnr like eban-matnr,
menge like eban-menge,
meins like eban-meins,
numb(3) type n.
data: end of pur_req.
* THE REPORT HEADER
prog_nam = sy-repid.
top-of-page.
perform header_write.
* SELECTION
start-of-selection.
pur_req-numb = 1.
* SELECT ONLY THOSE FIELDS THAT WILL BE USED FROM THE TABLE
EBAN, AND ONLY
*THE FIRST100 RECORDS OF THE THE PLANT 'PL01'
select banfn bnfpo bsart ekgrp matnr werks menge meins frgdt estkz

into corresponding fields of eban from eban up to 100 rows


where bsart = 'NB' "document type 'NB' = purchase requisition
and werks = 'PL01'
and statu = 'N' "processing status
and loekz = ' '. "deletion indicator
* THE SELECTED RECORDS SHOULD BE APPENDED TO INTERNAL
TABLE 'PUR_REQ'

pur_req-banfn = eban-banfn.
pur_req-matnr = eban-matnr.
pur_req-werks = eban-werks.
pur_req-ekgrp = eban-ekgrp.

pur_req-bnfpo = eban-bnfpo.
pur_req-bsart = eban-bsart.
pur_req-menge = eban-menge.
pur_req-meins = eban-meins.
pur_req-estkz = eban-estkz.
append pur_req.
pur_req-numb = pur_req-numb + 1.
endselect.
* CHECK WHETHER THE TABLE EBAN CONTAINS ANY PURCHASE
REQUISITIONS
if sy-subrc ne 0.
write: / 'No Purchase Requisition found.'.
endif.
* PROCESS THE INTERNAL TABLE; WRITE OUT THE
REQUIRED FIELDS AND HIDE THE
*FIELDS YOU ARE GOING TO USE LATER
loop at pur_req.
write: /1 pur_req-numb, 9 pur_req-banfn, 21 pur_reqbnfpo, 31 pur_req-bsart, 41 pur_req-matnr,
61 pur_req-menge unit pur_req-meins, 82 pur_reqmeins.
hide: pur_req-matnr, pur_req-werks, pur_req-banfn.
endloop.
clear pur_req-banfn. clear pur_req-matnr. clear pur_reqwerks.
* IN THE MENU PAINTER (SE41) CREATE A STATUS TO
YOUR PROGRAM. HERE YOU CAN
*DEFINE THE PUSH-BUTTON
set pf-status 'basic'.
* CHOOSE A REQUISITION (WITH DOUBLE CLICKING
OR PUSH-BUTTON) IN THE LIST! THE
*PURCHASE REQUISITION IS GOING TO COME UP
at line-selection.
if pur_req-banfn <> space.
set parameter id 'BAN' field pur_req-banfn. "
parameter id for pruchase req. number
call transaction 'ME52' and skip first screen. "trans.
code 'ME52': Change Purchase Requis.
clear pur_req-banfn. clear pur_req-matnr.
clear pur_req-werks.
endif.
* FORM THE HEADER
form header_write.
write: / prog_nam, 32 'FUN-FACTORY',
/ 'Purch.Gr.:', pur_req-ekgrp, 26 'Purchase
Requisition List',
61 'As Of Date:', 75 sy-datum,
/ 'Plant:', pur_req-werks, 61 'Page:', 75 sypagno.
uline.
write: / text-001,
/ text-002.
uline.

endform.

NOTES:
1. PUSH-BUTTON DEFINITION (SE11)

In the Menu Painter a status must be created where you can maintain
the function keys

2. MAINTAIN THE TEXT ELEMENT TO THE HEADER OF THE LIST

(SE38 choose the object component 'TEXT ELEMENTS' at the first


screen, then the'TEXT SYMBOLS'. Here you can add a number (I.E.
001) to 'TEXT SYMBOL' and write the header title into the text field like
this:

001
Numb.__Requisition__Item___Document_____Material_________________Q
uantity_Unit_of
002 _________Number_____Num______Type____________Measure
THE FIRST 15 LINE ITEMS OF THE RESULT AND THE HEADERS:
ZMJUD001
FUN-FACTORY
Purch. Gr.: 001 Purchase Requisition List
As Of Date: 05/09/1997
Plant: D031
Page: 1
------------------------------------------------------------------------Numb. Requisition Item Document Material
Quantity Unit of
Number
Num
Type
Measure
------------------------------------------------------------------------1
10049227
00010 NB
11141-030
23.000 CS
2
10049223
00010 NB
11141-030
23.000 CS
3
10049225
00010 NB
11141-030
13.000 CS
4
10049226
00010 NB
11141-030
9.000 CS
5
10049224
00010 NB
11141-030
23.000 CS
6
10049222
00010 NB
11141-030
23.000 CS
7
10049221
00010 NB
11141-030
38.000 CS
8
10049228
00010 NB
11141-030
23.000 CS
9
10049229
00010 NB
11141-030
23.000 CS
10
10049230
00010 NB
11141-030
22.000 CS
11
10049231
00010 NB
11141-030
24.000 CS
12
10049232
00010 NB
11141-030
24.000 CS
13
10049233
00010 NB
11141-030
24.000 CS
14
10049234
00010 NB
11141-030
23.000 CS
15
10049235
00010 NB
11141-030
5.000 CS

5) SAP's OPEN SQL, syntax of the SELECT statement

Basic form:
SELECT result FROM source [INTO target] [WHERE condition] [GROUP BY fields]
[ORDER BY order].
SELECT clause
Variants:
1. SELECT [SINGLE [FOR UPDATE] DISTINCT] *
2. SELECT [SINGLE [FOR UPDATE] DISTINCT] s1 ... sn
3. SELECT [SINGLE [FOR UPDATE] DISTINCT] (itab)
FROM clause
Variants:
1. ... FROM dbtab

Additions:
1. ... CLIENT SPECIFIED
2. ... BYPASSING BUFFER
3. ... UP TO n ROWS
2. ... FROM (dbtabname)

Additions:
1. ... CLIENT SPECIFIED
2. ... BYPASSING BUFFER
3. ... UP TO n ROWS
INTO target
(This form of the FROM clause works only in conjunction with the INTO
clause.)
INTO clause
Variants:
1. ... INTO wa
2. ... INTO CORRESPONDING FIELDS OF wa
3. ... INTO (f1, ..., fn)
4. ... INTO TABLE itab
5. ... INTO CORRESPONDING FIELDS OF TABLE itab
6. ... APPENDING TABLE itab
7. ... APPENDING CORRESPONDING FIELDS OF TABLE itab
WHERE clause
Variants:
1. ... WHERE f op g
2. ... WHERE f [NOT] BETWEEN g1 AND g2
3. ... WHERE f [NOT] LIKE g
4. ... WHERE f [NOT] IN (g1, ..., gn)
5. ... WHERE f [NOT] IN itab
6. ... WHERE f IS [NOT] NULL
7. ... WHERE NOT cond
8. ... WHERE cond1 AND cond2
9. ... WHERE cond1 OR cond2
10. ... WHERE (itab)
11. ... WHERE cond AND (itab)
12. ... FOR ALL ENTRIES IN itab WHERE cond

Operator
EQ or =
NE or < >
LT or <
LE or < =
GT or >
GE or >=

Meaning
equal to
not
equal to
less than
less than
or equal
to
greater
than
greater
than or
equal to

GROUP-BY clause
Variants:
1. ... GROUP BY f1 ... fn
2. ... GROUP BY (itab)
ORDER-BY clause
Variants:
1. ... ORDER BY PRIMARY KEY
2. ... ORDER BY f1 ... fn
3. ... ORDER BY (itab)

6) Q. Select those MM tables which are language dependant (For example you
want to translate the customizing in two languages)
Language dependent MM tables

report zbctcb96.
tables: dd03l, tadir.
data: counter type i value 1.
select * from tadir where pgmid eq 'R3TR' and
o

object eq 'TABL' and


devclass like 'M%'.
select * from dd03l where tabname eq tadir-obj_name and

o
( fieldname like 'SPRA%' or fieldname like 'LANG%' ).
write: / counter, dd03l-tabname, dd03l-fieldname.
add 1 to counter.
exit.

endselect.
endselect.
The TADIR contains the development objects.
All the 'table' objects are selected which are in an MM development class
(MM development classes begin with 'M').
The DD03L table contains the fields of the database tables.
Just those tables are selected, which has a field beginning with either 'SPRA'
or 'LANG'.
( 'language' is 'Sprache' in german).
Performance considerations in this example:
How frequently runs the report?

This report was used only once . I have tried to run it in dialog and
finished without 'time out error'.
Performance optimization is not necessary.

Is DD03L and TADIR buffered and how many records are in the tables?

You find it in /Development Workbench/ABAP 4 Dictionary, Table


Display, /Goto/Technical settings
Expected size in
Records
310,000 24,000,000

Table

Buffering

DDL03L

No Buffering

TADIR

Buffering Single
92,000 - 370,000
Records

Both are large tables with no or poor buffering.


A good performance can be only expected when you use indexed fields of the
tables.
Are the selection fields indexed?

The primary key fields are always indexed. Other fields are indexed
through additional index files.
From the Table Display, /Goto/Indexes.

7) Q. Choose a transaction and write a Batch Input program with 'Call Transaction'.
Do not use the Messagetab feature of 'Call Transaction'. In this case the last error
message will be at the SY-MSG* system fields. Recreate the complete error message
from table T100!
BDC program using Call Trasaction

REPORT ZSYSTEM LINE-SIZE 255.


TABLES: T100.
* Batch-input data
DATA: BEGIN OF G_BDCDATA OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF G_BDCDATA.
DATA: G_MESSAGE(200).
PERFORM FILL_BDCDATA.
CALL TRANSACTION 'FI01' USING G_BDCDATA MODE 'N'.
* of course it is nicer with a message itab, but this example
* should also demostrate the use of system variables.
SELECT SINGLE * FROM T100 WHERE
SPRSL = 'E'
AND ARBGB = SY-MSGID
AND MSGNR = SY-MSGNO.
G_MESSAGE = T100-TEXT.
PERFORM REPLACE_PARAMETERS USING
SY-MSGV2
SY-MSGV3
SY-MSGV4
CHANGING G_MESSAGE.
WRITE:
SKIP.
WRITE:
WRITE:
WRITE:
WRITE:
WRITE:
WRITE:
WRITE:
SKIP.
WRITE:
WRITE:
WRITE:
SKIP.
WRITE:
SKIP.
WRITE:

SY-MSGV1

/ 'System variables:'.
/
/
/
/
/
/
/

'
'
'
'
'
'
'

Sy-msgty:', SY-MSGTY.
Sy-msgid:', SY-MSGID.
Sy-msgno:', SY-MSGNO.
Sy-msgv1:', SY-MSGV1.
Sy-msgv2:', SY-MSGV2.
Sy-msgv3:', SY-MSGV3.
Sy-msgv4:', SY-MSGV4.

/ 'The transaction was called with a wrong country code.'.


/ 'The error message should be either that or that you have'.
/ ' no authorisation to execute the transaction'.
/ 'Message:'.
/ SY-MSGTY, G_MESSAGE.

*---------------------------------------------------------------------*
*
Build up the BDC-table
*
*---------------------------------------------------------------------*
FORM FILL_BDCDATA.
REFRESH G_BDCDATA.
PERFORM BDC_DYNPRO USING 'SAPMF02B' '0100'.
PERFORM BDC_FIELD USING 'BNKA-BANKS' 'ZZZ'.
PERFORM BDC_FIELD USING 'BDC_OKCODE' 'QQQQQ'.

ENDFORM.
*---------------------------------------------------------------------*
*
FORM BDC_DYNPRO
*
*---------------------------------------------------------------------*
*
Batchinput: Start new Dynpro
*
*---------------------------------------------------------------------*
FORM BDC_DYNPRO USING P_PROGRAM P_DYNPRO.
CLEAR G_BDCDATA.
G_BDCDATA-PROGRAM = P_PROGRAM.
G_BDCDATA-DYNPRO = P_DYNPRO.
G_BDCDATA-DYNBEGIN = 'X'.
APPEND G_BDCDATA.
ENDFORM.
" BDC_DYNPRO
*---------------------------------------------------------------------*
*
FORM BDC_FIELD
*
*---------------------------------------------------------------------*
*
Batchinput: Feld hinzufugen
*
*---------------------------------------------------------------------*
FORM BDC_FIELD USING P_FNAM P_FVAL.
CLEAR G_BDCDATA.
G_BDCDATA-FNAM = P_FNAM.
G_BDCDATA-FVAL = P_FVAL.
APPEND G_BDCDATA.
ENDFORM.
" BDC_FIELD
*---------------------------------------------------------------------*
*
FORM REPLACE_PARAMETERS
*
*---------------------------------------------------------------------*
*
........
*
*---------------------------------------------------------------------*
* --> P_PAR_1
*
* --> P_PAR_2
*
* --> P_PAR_3
*
* --> P_PAR_4
*
* --> P_MESSAGE
*
*---------------------------------------------------------------------*
FORM REPLACE_PARAMETERS USING P_PAR_1
P_PAR_2
P_PAR_3
P_PAR_4
CHANGING P_MESSAGE.
* erst mal pruefen, ob numerierte Parameter verwendet wurden
DO.
REPLACE '&1' WITH P_PAR_1 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&2' WITH P_PAR_2 INTO P_MESSAGE.

IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&3' WITH P_PAR_3 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
DO.
REPLACE '&4' WITH P_PAR_4 INTO P_MESSAGE.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
* falls keine numerierten Parameter vorh., ersetzen wie gehabt
REPLACE '&' WITH P_PAR_1 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_2 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_3 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
IF SY-SUBRC EQ 0.
REPLACE '&' WITH P_PAR_4 INTO P_MESSAGE.
CONDENSE P_MESSAGE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.

"replace_parameters

Anda mungkin juga menyukai