Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

provide statement(hr abap)

Former Member
0 Kudos

hi guys ...

how can i read employees in abap hr when based on dates ...condition is

i want all the employees greater than equal to beginning date and between enddate.

i just need the programming statement to retrive the right data..



Former Member
0 Kudos


select * from PA0000 into table it_pa0000

where pernr in s_pernr

and endda >= beginning_date(s_date-low)

and begda <= end_date. (s_date-high)

0 Kudos


thanks for ur reply...

iam using

provide * from p0002 BETWEEN qppnp-begda AND qppnp-endda

where qppnp-begda <= qppnp-endda.

to get all the employees from begininning date and before end date..

do u think its write..or i have to modify anything

plz advise


0 Kudos

Every record has two dates .. begda and endda ...

Where begda is always <= endda (we need not explicitly write

the condition for that) for a particular record.

If UR using ..

provide * from p0002 BETWEEN qppnp-begda AND qppnp-endda.

U get records where

begda lies between qppnp-begda AND qppnp-endda and

endda lies between qppnp-begda AND qppnp-endda and

begda <= endda .. for all the records in P0002 ..

No need to write any other statements ...

0 Kudos

hi thanks once agen

but i want including the startdate and before end date.....not between start date and date endate

for eg

if i have





my output should be like




u see wot i mean..please advise


0 Kudos

U'll get the data between start and end dates only ...

For ex: If U have ..

Begda Endda

01/01/2001 12/31/2001

01/01/2002 12/31/2002

01/01/2003 12/31/2003

01/01/2004 12/31/2004

01/01/2005 12/31/2005

And if U have qppnp-begda = 01/01/2001

and qppnp-endda = 01/31/2005

I think what U expect is all the 5 records above ...

But Provide gives U only 4 records ...

Reason is qppnp-endda = 01/31/2005 .. and Provide gets

data where endda is in between 01/01/2001 and 01/31/2005

If U want all the 5 records .. then loop at the internal table U

have only for the Begda condition ...

where begda <= qppnp-endda

0 Kudos

thanks once agen..

i know wot u mean but provide doesnt work for condition(i think) it needs between...wot statement shud i have to write to satisfy the condition...

sorry! im greek to this hr thing


0 Kudos

I think U already have the data in your internal table ..

say P0001 loop at that ..

loop at p0001 where

begda between qppnp-begda AND qppnp-endda.


Former Member
0 Kudos



1. PROVIDE { FIELDS {*|{compi}}

FROM itabj INTO waj VALID flagj

BOUNDS intlim1j AND intlim2j

WHERE log_expj }

BETWEEN extlim1 AND extlim2


2. PROVIDE { {*|{compi}}

FROM itabj }

BETWEEN extlim1 AND extlim2.


Special join for internal tables. Variant 1 is the universally applicable form of the PROVIDE statement. Variant 2 is a short form of variant 1 that is not permitted in ABAP Objects.

Variant 1

PROVIDE { FIELDS {*|{compi}}

FROM itabj INTO waj VALID flagj

BOUNDS intlim1j AND intlim2j

WHERE log_expj }

BETWEEN extlim1 AND extlim2



The statements PROVIDE and ENDPROVIDE define a loop through a statement block. In this loop, any number of internal tables itabj are processed together. A single table can appear several times. For every table itabj you must specify a FIELDS clause. After FIELDS you must specify the character * for all components or a list compi for specific components of the relevant table. The names of the components compi can only be specified directly.

To be able to process internal tables using PROVIDE, all tables itabj must be fully typed index tables and contain two special columns that have the same data type (d, i, n, or t) for all relevant tables. For every table you must specify the names intlim1 and intlim2 of these columns using the BOUNDS addition.

The columns intlim1 and intlim2 in every row of the relevant internal tables must contain values that can be interpreted as limits of closed intervals. Within a table, the intervals specified in these columns must not overlap and must be sorted in ascending order. The intervals therefore make up a unique key for every row.

For every table you must specify a work area waj compatible with the row type and a variable flagj, for which a character-type data type with length 1 is expected. In the PROVIDE loop, the components specified after FIELDS are filled with values in the relevant work areas waj for every specified internal table. The variable flagj is also filled. A single work area waj or variable flagj cannot be specified more than once.

With the BETWEEN addition you must specify an interval extlim1, extlim2. It must be possible to convert the data objects extlim1 and extlim2 into the data types of the respective columns intlim1 and intlim2 of the individual tables.

The interval limits intlim1j and intlim2j for every row of all relevant internal tables itabj that are within the closed interval made up by extlim1 and extlim2 divide the latter into new intervals and every interval limit closes one interval in the original direction. If, within a relevant table, a lower interval limit follows an upper interval limit with no space or gap between them and the components of the corresponding rows specified after FIELDS have the same content, the two interval limits are combined and the corresponding interval limits intlim2j and intlim1j are ignored for the new intervals.

For every interval that is created in such a way and overlaps with at least one of the intervals of a table involved, the PROVIDE loop is passed once. The components of every work area waj specified after FIELDS and the variable flagj are filled with values as follows:

The components intlim1 and intlim2 of every work area waj are filled with the interval limits of the current interval.

If the current interval overlaps with one of the intervals of an involved table, the remaining components of the corresponding work area are assigned the contents of the relevant components of this table row and the variable flagj is set to the value "X". Otherwise, the work area components and the variable flagj are set to their initial value.

Except for intlim1j and intlim2j, the components not specified after FIELDS are always set to their initial value. The components intlim1j and intlim2j are always assigned.

The ABAP runtime environment checks for every table involved, whether the condition of sorted and non-overlapping intervals is met within the interval made up by extlim1 and extlim2 and, if necessary, triggers an exception that can be handled.

If the INCLUDING GAPS addition is specified, the system passes the PROVIDE loop for every interval, that is also when the current interval does not overlap with at least one of the intervals of an involved table. In the latter case, the variable flagj is of initial value for every relevant table.

You can use the WHERE addition to specify a condition for every table involved. After WHERE, you can specify any logical expression log_exp; the first operand of every comparison must be a component of the relevant table. Here it is not possible to specify a component using character-type data objects in brackets. The table entries, for which the condition is not met are ignored by the PROVIDE loop.


The system fields sy-subrc and sy-tabix are set to the value 0 before every loop pass and at ENDPROVIDE. Only if the loop is not passed once, is sy-subrc set to 4 at ENDPROVIDE.

The relevant internal tables should not be modified in the PROVIDE loop.

The WHERE condition can be used to remove overlaps between the tables involved or ensure the sorting of the intervals.


col1 TYPE i, 
col2 TYPE i, 
col3 TYPE string, 
END OF wa1. 

col1 TYPE i, 
col2 TYPE i, 
col3 TYPE string, 
END OF wa2. 


DATA: flag1(1) TYPE c, 
flag2(1) TYPE c. 

wa1-col1 = 1. 
wa1-col2 = 6. 
wa1-col3 = 'Itab1 Int1'. 
APPEND wa1 TO itab1. 

wa1-col1 = 9. 
wa1-col2 = 12. 
wa1-col3 = 'Itab1 Int2'. 
APPEND wa1 TO itab1. 

wa2-col1 = 4. 
wa2-col2 = 11. 
wa2-col3 = 'Itab2 Int1'. 
APPEND wa2 TO itab2. 

FROM itab1 
INTO wa1 
VALID flag1 
BOUNDS col1 AND col2 
FIELDS col3 
FROM itab2 
INTO wa2 
VALID flag2 
BOUNDS col1 AND col2 
WRITE: / wa1-col1, wa1-col2, wa1-col3, flag1. 
WRITE: / wa2-col1, wa2-col2, wa2-col3, flag2. 

Reward points if useful.

Former Member
0 Kudos

Hi Sudheer,

Best Solution I can suggest you to read employees from HR Database is use Logical Database. (PNP). You can define thin in your attribute.

Declare all the infotypes from which you want to fetch the data.

For e.g.

Infotypes: 0001, " Organizational

0002. "Personnel.

then after start-of-selection event you need to use macro.


Which will fill the internal table value for the infotypes declared. This will be only sigle employee info at a time as it runs in a loop for all the employee.

Do not forget to write end-of-selection event as 'get pernr' and end-of-selection runs in a loop.

For getting the current info about the employee you can use macro.

rp-provide-from-last p0001 space sy-datum sy-datum.

this will give you the current info about the employee only if it is active as on today's date. Replace sy-datum with your date if you want the info on your date.

Hope this may atleadt help you to know atleast the basics that how is employee data retirved in HR ABAP.

Jayant Sahu

Former Member
0 Kudos


Please refer to the sample code below:

REPORT zpsol010.                                               

*-- Declaration                                                

TABLES: pernr.                                                 

INFOTYPES: 0002.                     "Personal Data            

SELECT-OPTIONS: language FOR p0002-sprsl.                                                                                
*-- Selection screen                                           


  pnptimed = 'D'.                                                                                
*-- Processing                                                  

GET pernr.                                                     

  PROVIDE * FROM p0002 BETWEEN pn-begda AND pn-endda.          

    CHECK language.                                            

    WRITE: / p0002-pernr,                                      









Sriram Ponna.

Former Member
0 Kudos

You should read from Infotype 0000 instead of 0002, because Infotype 0002 is not mandatory (ie an employee could exist in the system but doesnt have that Infotype).

Besides, if you need to exclude inactive employees in Infotype 0000 you have the data to do it.

Best regards