SAP HR , ABAP HR Material, Tutorials and SAP Trainings

20
May

Evaluating Repetitive Structures in SAP 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  http://abaphr.com in www.sdn.sap.com.

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 their amounts. By scrolling, you can enter up to forty wage types. The structure of the wage type line is stored in the Infotype structure P0008, and the individual fields are numbered from one to forty. This means that each field of the wage type table is defined.

A loop offers a more streamlined method of evaluation. Here, one line of the repeat structure is evaluated each time the loop is executed

As SAP consultant you might know the structures. But what is the repetitive structures?. The sentence it self explains that in a structure, some fields are available multiple times with the sequence number change, like fieldname01, fieldname02, fieldname03 etc…

For example In Master data Infotypes we have:
Infotype 0008 (Basic Pay)
Infotype 0025 (Appraisals)
Infotype 0041 (Date Specifications)
Infotype 0052 (Wage Maintenance)

If we look at Infotype 0008 below fields are getting repeated 40 times (Lower versions of SAP only 20 times like 4.6C).

LGA01 – wage type1
BET01 – wage type Amount
ANZ01 – Number
EIN01 – Time/Measurement Unit
OPK01 – Operation Indicator for Wage Types

LGA02 – wage type2
BET02 – wage type amount
ANZ02 – Number
EIN02 – Time/Measurement Unit
OPK02 – Operation Indicator for Wage Types

Till

LGA40 – wage type40
BET40 – wage type amount
ANZ40 – Number
EIN40 – Time/Measurement Unit
OPK40 – Operation Indicator for Wage Types

For the above scenario we have multiple wage types for one Personnel number for one particular period. Viz.. Basic Pay, House rent allowance, conveyance, special allowance, car allowance, salary exempt, salary non exempt (All these are wage types).
For the above scenario wage types are stored in LGA01, LGA02, LGA03, LGA04, LGA05, LGA06, LGA07, and its amount correspondingly BET01, BET02, BET03, BET04, BET05, BET06, BET07. This is the brief overview about repetitive structures in SAP.

Now as a technical consultant your job starts. How do you read the data form repetitive structure Infotypes. For example we need to select basic wage from Infotype 0008 and display in report. We are not sure in which field the basic wage is going to be stored like it might be in LGA01 or LGA02 or LGA03 or LGA04. Here my question is, are we going to check 40 time IF condition for each field (LGA01 to LGA40). My answer is No. We have syntax in ABAP by using that we can achieve out target very easily.

Before going forward if you are new to ABAP HR, please go through the below Link:

SAP ABAP HR Program code using LDB PNP

The following Report shows you how to access these data fields. The example determines the wage type and its amount for particular period.

Data declarations: The required data declarations are first made at the beginning of the
Report. Fields LGART and BETRG are required to read the repetitive structures.

Tables: PERNR is used to get the standard selection screen as well work area.
Declare Tables: PERNR and press F8 you will get standard selection screen.

Infotypes: when we declare tables at the runtime of program will have work area the same way, when we declare Infotypes, will have internal table (we call as internal Infotype) with header with the structure of associated Infotype.

Macros:
You often only require the most recent or earliest Infotype record, not all Infotype records. In this case, use one of the following statements:

RP_PROVIDE_FROM_LAST Pnnnn SPACE PN-BEGDA PN-ENDDA.

These statements make the most recent or earliest record in the PN/BEGDA to PN/ENDDA data selection period available in the structure Pnnnn for infotype nnnn.
If the infotype has subtypes, replace the SPACE parameter by the appropriate subtype number.
When a record has been successfully read, the return code PNP-SW-FOUND = 1 is returned.


Related Posts

Leave a Reply

© 2010 SAP HR , ABAP HR Material, Tutorials and SAP Trainings | Entries (RSS) and Comments (RSS)

Design by Web4 Wordpress Themes, © SAP HR , ABAP HR Material, Tutorials and SAP Trainings 2010 | Theme design by Data sub systems.