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.
cancel
Showing results for 
Search instead for 
Did you mean: 

HR_READ_INFOTYPE in OO context

former_member360630
Discoverer
0 Kudos
197

Hy everyone,

I stumbled upon a problem and I kindly ask for your advice. Here is the context:

- I am inside a BADI implementation

- need to read the 0001 HR infotype for a given PERNR and target TARGETDATE, specifically I need the BTRTL and PERSK fields.

I used to do this in 'normal' ABAP programs with something like:

____________________

INFOTYPES: 0001.

...(some other code)...

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = pernr

infty = '0001'

begdata = TARGETDATE

enddata = TARGETDATE

TABLES infty_tab = p0001.

tempBTRTL = p0001-BTRTL.

tempPERSK = p0001-PERSK.

_____________________

Now using this code is not allowed (INFOTYPES is not allowed in OO context).

Tried to declare DATA: p0001 TYPE TABLE OF p0001 INITIAL SIZE 0. => but then cannot access fields BTRTL or PERSK because p0001 has no header line. (also header line is not allowed in OO context).

Can you help with suggesting how to get the required info?

1 ACCEPTED SOLUTION

Former Member
56

ABAP objects not use internal tables with header line. Because of this you need to create the table without header line and a workarea for manage data. For example

data lt_p0001 type standard table of p0001.

data wa_p0001 type p0001.

loop at lt_p0001 into wa_p0001.

endloop.

read table lt_p0001 into wa_p0001 index 1.

2 REPLIES 2

Former Member
57

ABAP objects not use internal tables with header line. Because of this you need to create the table without header line and a workarea for manage data. For example

data lt_p0001 type standard table of p0001.

data wa_p0001 type p0001.

loop at lt_p0001 into wa_p0001.

endloop.

read table lt_p0001 into wa_p0001 index 1.

danilo_henriques
Explorer
0 Kudos
56

DATA: t_0001 type table of p0001,

w_0001 type p0001.

LOOP AT p0001 INTO w_p0001.

ENDLOOP.