ABAP (Advanced Business Application Programming) is a programming language for developing applications for the SAP R/3 system, a widely-installed business application subsystem. The latest version, ABAP Objects, is object-oriented programming. SAP will run applications written using ABAP/4, the earlier ABAP version, as well as applications using ABAP Objects. SAP's original business model for R/3 was developed before the idea of an object-oriented model was widespread. The transition to the object-oriented model reflects an increased customer demand for it. ABAP Objects uses a single inheritance model and full support for object features such as encapsulation, polymorphism, and persistence. ABAP (Advanced Business Application Programming, originally Allgemeiner Berichts-Aufbereitungs-Prozessor , German for "general report creation processor" [1] ) is a high-level programming language created by the German software company SAP . It is currently positioned, alongside the more recently introduced Java , as the language for programming the SAP Application Server , part of its NetWeaver platform for building business applications. [edit ]Introduction ABAP is one of the many application-specific fourth-generation languages (4GLs ) first developed in the 1980s . It was originally the report language for SAP R/2 , a platform that enabled large corporations to build mainframe business applications for materials management and financial and management accounting. ABAP used to be an abbreviation of Allgemeiner BerichtsAufbereitungsProzessor, German for "generic report preparation processor", but was later renamed to the English Advanced Business Application Programming. ABAP was one of the first languages to include the concept of Logical Databases (LDBs), which provides a high level of abstraction from the basic database level(s).
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
ABAP (Advanced Business Application Programming) is a programming language for developing applications for the SAP R/3 system, a widely-installed business application subsystem. The latest version, ABAP Objects, is object-oriented programming. SAP will run applications written using ABAP/4, the earlier ABAP version, as well as applications using ABAP Objects.
SAP's original business model for R/3 was developed before the idea of an object-oriented model was widespread. The transition to the object-oriented model reflects an increased customer demand for it. ABAP Objects uses a single inheritance model and full support for object features such as encapsulation, polymorphism, and persistence.
ABAP (Advanced Business Application Programming, originally Allgemeiner Berichts-Aufbereitungs-Prozessor, German for "general report creation processor"[1]) is a high-level programming language created by the German softwarecompany SAP. It is currently positioned, alongside the more recently introducedJava, as the language for programming the SAP Application Server, part of itsNetWeaver platform for building business applications.
[edit]Introduction
ABAP is one of the many application-specific fourth-generation languages (4GLs) first developed in
the 1980s. It was originally the report language for SAP R/2, a platform that enabled large corporations to
build mainframe business applications for materials management and financial and management
accounting.
ABAP used to be an abbreviation of Allgemeiner BerichtsAufbereitungsProzessor, German for "generic
report preparation processor", but was later renamed to the
English Advanced Business Application Programming. ABAP was one of the first languages to include
the concept of Logical Databases (LDBs), which provides a high level of abstraction from the basic
database level(s).
The ABAP programming language was originally used by developers to develop the SAP R/3 platform. It
was also intended to be used by SAP customers to enhance SAP applications – customers can develop
custom reports and interfaces with ABAP programming. The language is fairly easy to learn[opinion] for
programmers but it is not a tool for direct use by non-programmers. Knowledge of relational database
design and preferably also of object-oriented concepts is necessary to create ABAP programs.
ABAP remains as the language for creating programs for the client-server R/3 system, which SAP first
released in 1992. As computer hardware evolved through the 1990s, more and more of SAP's
applications and systems were written in ABAP. By 2001, all but the most basic functions were written in
ABAP. In 1999, SAP released an object-oriented extension to ABAP called ABAP Objects, along with R/3
release 4.6.
SAP's current development platform NetWeaver supports both ABAP and Java.
In a chain statement, the first part (before the colon) is not limited to the statement name alone. The entire
common part of the consecutive statements can be placed before the colon. Example:
REPLACE 'A' WITH 'B' INTO LASTNAME.
REPLACE 'A' WITH 'B' INTO FIRSTNAME.
REPLACE 'A' WITH 'B' INTO CITYNAME.
could be rewritten in chained form as:
REPLACE 'A' WITH 'B' INTO: LASTNAME, FIRSTNAME, CITYNAME.
[edit]Comments
ABAP has 2 ways of defining text as a comment:
An asterisk (*) in the leftmost column of a line makes the entire line a comment
A double quotation mark (") anywhere on a line makes the rest of that line a comment
Example:
***************************************
** Program: BOOKINGS **
** Author: Joe Byte, 07-Jul-2007 **
***************************************
REPORT BOOKINGS.
* Read flight bookings from the database
SELECT * FROM FLIGHTINFO
WHERE CLASS = 'Y' "Y = economy
OR CLASS = 'C'. "C = business
(...)
[edit]Data types and variables
ABAP provides a set of built-in data types. In addition, every structure, table, view or data element defined
in the ABAP Dictionary can be used to type a variable. Also, object classes and interfaces can be used as
types.
The built-in data types are:
Type Description
I Integer (4-bytes)
P Packed decimal
F Floating point
N Character numeric
C Character
D Date
T Time
X Hexadecimal (raw byte)
STRING Variable-length string
XSTRIN
GVariable-length raw byte array
Date variables or constants (type D) contain the number of days since January 1, AD 1. Time variables or
constants (type T) contain the number of seconds since midnight. A special characteristic of both types is
that they can be accessed both as integers and as character strings (with internal format "YYYYMMDD"
for dates and "hhmmss" for times), which makes date/time handling very easy. For example, the code
snippet below calculates the last day of the previous month (note: SY-DATUM is a system-defined
variable containing the current date):
DATA LAST_EOM TYPE D. "last end-of-month date
* Start from today's date
LAST_EOM = SY-DATUM.
* Set characters 6 and 7 (0-relative) of the YYYYMMDD string to "01",
* giving the first day of the current month
LAST_EOM+6(2) = '01'.
* Subtract one day
LAST_EOM = LAST_EOM - 1.
WRITE: 'Last day of previous month was', LAST_EOM.
All ABAP variables must be explicitly declared in order to be used. Normally all declarations are placed at
the top of the code module (program, subroutine, function) before the first executable statement; this
placement is a convention and not an enforced syntax rule. The declaration consists of the name, type,
length (where applicable), additional modifiers (e.g. the number of implied decimals for a packed decimal
field) and optionally an initial value:
* Primitive types:
DATA: COUNTER TYPE I,
VALIDITY TYPE I VALUE 60,
TAXRATE(3) TYPE P DECIMALS 1,
LASTNAME(20) TYPE C,
DESCRIPTION TYPE STRING.
* Dictionary types:
DATA: ORIGIN TYPE COUNTRY.
* Internal table:
DATA: T_FLIGHTS TYPE TABLE OF FLIGHTINFO,
T_LOOKUP TYPE HASHED TABLE OF FLT_LOOKUP.
* Objects:
DATA: BOOKING TYPE REF TO CL_FLT_BOOKING.
Notice the use of the colon to chain together consecutive DATA statements.
[edit]ABAP Objects
The ABAP language supports object-oriented programming, through a feature known as "ABAP Objects".[2] This helps to simplify applications and make them more controllable.
ABAP Objects is fully compatible with the existing language, so one can use existing statements and
modularization units in programs that use ABAP Objects, and can also use ABAP Objects in existing
ABAP programs. Syntax checking is stronger in ABAP Objects programs, and some syntactical forms
(usually older ones) of certain statements are not permitted.
[edit]ABAP statements – an overview
In contrast with languages like C/C++ or Java, which define a limited set of language-specific statements
and provide most functionality via libraries, ABAP contains an extensive body of built-in statements.
These statements often support many options, which explains why ABAP programs look "verbose",
especially when compared with programs written in C, C++ or Java.
This section lists some of the most important statements in the language, subdivided by function. Both the
statements listed here and the subdivision used are fairly arbitrary and by no means exhaustive.
[edit]Declarative statements
These statements define data types or declare data objects which are used by the other statements in a
program or routine. The collected declarative statements in a program or routine make up its declaration
These statements produce or format output. They appear mainly in reports, less so in module pools.
Examples are:
WRITE, FORMAT, SKIP, ULINE, MESSAGE, NEW-PAGE, FREE
[edit]Internal tables in ABAP
Internal tables are an extremely important feature of the ABAP language. An internal table is defined as a
vector of structs in C++ or a vector of objects in Java. The main difference with these languages is that
ABAP provides a collection of statements to easily access and manipulate the contents of internal tables.
Note that ABAP does not support arrays; the only way to define a multi-element data object is to use an
internal table.[citation needed]
[edit]See also
HR CLUSTER TABLES
Payroll Custer Tables 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 - Database for HR work area; (long text, etc)PCL2 - Accounting Results (time, travel expense and payroll); (payroll results)PCL3 - Applicant tracking data; PCL4 - Documents, Payroll year-end Tax data (change logs, etc)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, TX for long text, LA for change logs.
Each HR subarea has its own cluster.
Each subarea has its own key.
Database Table PCL1The 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 .
SRTFD (PSKEY) = pernr (8) info type (4) subtype (4) obj id (2) lock (1) endda (8) begda (8) seqnr (3)Database Table PCL2The 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 indicatorRU for US payroll result)
ZL personal work schedule
SRTFD (PC200) = pernr (8) sequence (5)Database Table PCL3The database table PCL3 contains the following data areas: AP action log / time schedule
TY texts for applicant data infotypes
Database Table PCL4The database table PCL4 contains the following data areas: LA change logs (long term documents)
SA Short-Term Documents for HR Master Data
SB Short-Term Documents for Applicant Master
SRTFD (PC400) = trans class always A for master data (1) pernr (8) info type (4) modified date (8) modified time (8) seqnr (4)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.
o MANDT(3) client
o RELID (2) cluster ID (RU,TX, LA..)
o SRTFD (40) Work Area Key
o SRTF2 (4) Sort key for dup. key
Cluster DefinitionNaming convention for INCLUDES when defining clusters. These INCLUDES will define the work area key above and the cluster data that is returned from an IMPORT:
RPCnxxy0n = 1, 2, 3 or 4 (for PCL1, PCL2, PCL3, PCL4) xx = cluster ID y = country grouping (0 for international otherwise country indicator T500L)Description of Cluster Data using Cluster RX as an Example The data description is stored in the include RPC2RX00 in accordance with the above naming conventions. RPC1TX00 - Long text cluster ID in table PCL1
RPC2RUU0 - Payroll results for the US cluster ID in table PCL2
RPC4LA00 - Change log cluster ID in table PCL4
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 ZRPIMPORT. TABLES: PCLn. INCLUDE RPCnxxy0. "Cluster definition * Fill cluster Key * Import record IMPORT TABLE1 FROM DATABASE PCLn(xx) ID xx-KEY. IF SY-SUBRC EQ 0. * Display data object ENDIF.See sample program for long text.
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 ZRPIMPORT. *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.
rpcbdt00 - include needed for importing from database PCL4(la) (Change log cluster ID)When we upgraded to ERP2005, we encountered a problem because a couple of our programs tested the version (VERNR) number to determine which structure the detail used. The SAP include program, RPCBDT00, indicates that VERNR 01 & 02 use the same structure which is PC404. Therefore, we made our programs match SAP.
The following concepts are defined in ABAP HR which is different with other modules.
1) Use of Infotypes2) The use of Logical Database3) Use of Macros and Provide statement4) Storage and Access of data5) Authorization checksThere is nothing much difference between abap and hr abap. The way we retrieve the data from data base is deferent.In general ABAP data is stored in Tables, but coming to HR ABAP employee data is sorted through Infotypes. The way we retrieve the data from infotypes is deferent in hr abap.
In general ABAP we use Logical data base very rare, as in HR ABAP most of the programs use Logical data base to select data from Infotypes by using Get event.
In ABAP we use read statement to read particular record, still in HR ABAP we do use read statement apart from that we have Macros and provide statement.
Macro is pre defined code (like function module) which reads data from internal table (internal infotype) based on dates.
Provide statement is like Select statement but selects data from internal table
Storage and access of data in hr abap is completely deferent in hr abap comparing with ABAP. We use transaction code PA20 and PA30 to maintain data in infotypes.
PA20 is display mode and PA30 is change mode. We can create, change, display, copy, and delete in infotypes with PA30 transaction.
For Infotypes authorizations can be maintained infotype and subtype (field) level as HR data is more sensitive and secrete.
Will discuss in detail of above bullet points as a separately.
Related Posts
Evaluating Repetitive Structures in HR ABAP Programming SAP ABAP HR Program code using LDB PNP SAP HR ABAP Interview Faq’s Personnel Administration (PA): Introduction on SAP HR module Useful Transaction codes in SAP HR module Macros in HR-ABAP programming What is Logical Database ?
Creation of Custom Infotype in HR ABAP Step By Step process to create Custom Infotype For list of Online
Training Courses look at the above SAP TRAINING page. Go to Transaction PM01 to Create custom Infotype. Enter the custom Infotype number to be created. The number should be between the customer name space 9001 – 9999. This is the no. range interval [...]
Posted in Infotypes by: admin
11 Comments
20MAY
Evaluating Repetitive Structures in HR ABAP Programming
Before writing this post I would like to thank Manoj kumar, ShivrajSinha, Santhosh Somasekharan, Amolkumar Patil, Vishal Jindal, Bijay Kumar Barik, Devi, who has referred Abaphr.com in SAP SDN Forum. In many master data Infotypes, data is entered in table form. This, for example, allows you to enter up to forty different wage types and [...]
Posted in Programs by: admin 2 Comments
14
FEB
SAP ABAP HR Program code using LDB PNP Here is a basic abap hr program with screen shots step by step for
learners who are having knowledge of abap. This is a basic program but you can use this template for every abap hr program and add if and else conditions change the Infotype numbers and field names based on your requirement. Initially [...]
Posted in Programs by: admin
23 Comments
14SEP
SAP HR ABAP Interview Faq’s sap hr abap interview questions Posted in ABAP HR, FAQ's by: admin
30 Comments
26JAN
Personnel Administration (PA): PA involves administrating employee data, commonly referred to Master
Data. Master Data contains all employee data used in HR processing. Master Data includes Personal (Eg. address), Organizational (Position description), Benefits (Insurance, Pension), Time & Payroll. Master Data is stored in Infotypes. Infotypes are tables (for user Data entry screen) that contain logically related employee data. [...]
Posted in FAQ's by: admin
3 Comments
26JAN
Introduction on SAP HR module The SAP HR module enables companies to effectively manage
information about the people in their organization. It is integrated with other SAP modules and external systems. From the Organization Management perspective, companies can model a business hierarchy, the relationships of employees to various business units and the reporting structure among employees. The Personnel Administration (PA) [...]
Posted in ABAP HR by: admin
6 Comments
18JAN
Useful Transaction codes in SAP HR module Master Data PA10 Personnel File PA20 Display HR
Master Data PA30 Maintain HR Master Data PA40 Personnel Events PA41 Change Hiring Data PA42 Fast Data Entry for Events PRMD Maintain HR Master Data PRMF Travel Expenses: Feature TRVFD PRML Set Country Grouping via Popup PRMM Personnel Events PRMO Travel Expenses: Feature TRVCO PRMP Travel Expenses: [...]
Posted in ABAP HR by: admin
1 Comment
22DEC
Macros in HR-ABAP programming Most commonly used Macros in ABAP-HR ? Macro contains some part of
source code which it will be useful for number of applications.( Like function modules ) Generally we use two macros in ABAP-HR or SAP-HR RP-PROVIDE-FROM-LAST RP-PROVIDE-FROM-FRST Ex: RP-PROVIDE-FROM-LAST P0000 SPACE PN-BEGDA PN-ENDDA. IF PN-SW-FOUND = 1. WRITE YOUR CONDITION. ENDIF. The macro RP-PROVIDE-FROM-LAST [...]
Posted in ABAP HR by: admin
2 Comments
16DEC
What is Logical Database ? Logical database in SAP The LDB is special type of ABAP program that
combines the contents of certain related database tables and retrieve some related data and make it available to application programs. In other words, a LDB is a method by which ABAP programs read and process the data. The sequence in which the [...]
Posted in ABAP HR by: admin
4 Comments
24NOV
Infotype 402 and Payroll results Payroll results can be held in infotype 402, for this we need to do some
configuration. IMG Menu path – Personnel Admin –> Personnel Management –> HRIS –> Payroll Results. Define Evaluation Results: The evaluation wage type is the name of the field – note it is not the actual wage type. The cumulation can [...]
Posted in Infotypes by: hivamsi
1 Comment Next Entries »
20NOV
Difference between ABAP and HR ABAP ABAP vs HR ABAP The following concepts are defined in ABAP HR which
is different with other modules. 1) Use of Infotypes 2) The use of Logical Database 3) Use of Macros and Provide statement 4) Storage and Access of data 5) Authorization checks
Posted in ABAP HR by: admin
3 Comments
11NOV
More information on sap hr-abap infotypes More information on SAP hr abap infotypes: Infotype data is period-
based (time-dependent), in other words, it is only valid for specific periods. For this reason, each record has a start date and an end date. The database does not normally contain only one record for each infotype and personnel number but several records with different [...]
Posted in Infotypes by: admin
No Comments
10NOV
ABAP vs HR-ABAP What is the difference between abap and abap hr? The following
concepts are defined in ABAP HR which is different with other modules . n Use of Infotypes n The use ofLogical Database n Use of Macros and Provide statement n Storage and Access of data n Authorization checks
Posted in ABAP HR by: admin
No Comments
06NOV
Infotype concept in sap hr, Creation of infotype, Enhancement of infotype
What is Infotype? Infotypes are information units through which we can enter the data into tables. The Infotypes are used to group related data fields together. In general words its data entry screen from where we can store the data into tables. Naming conversion of infotype is four digits numerical. Each infotype will have corresponding [...]
Posted in Infotypes by: admin
11 Comments
03NOV
Useful function modules in ABAP-HR RS_PROGRAM_CHECK_NAME: To check program names if you are
generating them. RS_CORR_INSERT : To insert the correction request in the repository. REPS_OBJECT_ACTIVATE: To activate repository objects, for example – to activate a newly generated program. RS_DELETE_PROGRAM: To delete the program. RS_ACCESS_PERMISSION: To lock or unlock a program. Function Modules related toDate and Time [...]
SAP ABAP HR Program code using LDB PNP Here is a basic abap hr program with screen shots step by step for
learners who are having knowledge of abap. This is a basic program but you can use this template for every abap hr program and add if and else conditions change the Infotype numbers and field names based on your requirement.
Initially I don’t want to confuse the readers adding more coding at first program. All the scenarios are covered in next posts one by one by using the same program template.
Requirement: Select the data from Infotypes using logical database PNP (with out single select statement) and display in report. Fields like
Personnel number, Action Type, Reason for Action, Payroll area, Personnel ID Number
Infotypes Used: 0000, 0001, 0002. Macros used: RP-PROVIDE-FROM-LAST P0000 SPACE PN-BEGDA PN-ENDDA. RP-PROVIDE-FROM-LAST P0001 SPACE PN-BEGDA PN-ENDDA. RP-PROVIDE-FROM-LAST P0002 SPACE PN-BEGDA PN-ENDDA. Selection screen: There is selection screen is defined in this program but by using logical
Steps: 1) Go to se38 transaction 2) Enter the program name ZABAPHROVERVIEW and press on create 3) Enter the TITLE name, select TYPE as executable program, and
LOGICAL DATA BASE AS PNP.
4) Press on save button. And use the below code and execute you will get standard selection
screen.
Standard selection screen:
Enter the personnel number and execute the program report display is ready for you…:)
Don’t you feel abap hr is easy…. Incase any question use the below comments section…..