Application Development and Automation 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: 
Read only

HR ABAP Doubt

Former Member
0 Likes
1,256

Hi,

I have two pieces of code and i thought they will do the same , but they have different outputs. Please let me know why i get different outputs.

code 1:

REPORT  ZBALAHRTEST.
data i type i.
nodes pernr.
INFOTYPES : 0000,0001,0002,0003,0004,0005,0006,0007.

get pernr.

if p0001-pernr = '0000001'.
   write : p0001-begda , p0001-endda.  
endif.

Output:

23.09.2008 31.12.9999

The second code.

REPORT  ZBALAHRTEST1.

tables pa0001.

SELECT * from pa0001 where pernr = '00000001'.
  write :/, pa0001-begda,pa0001-endda.
ENDSELECT.

Output:

01.06.2008 22.09.2008

23.09.2008 31.12.9999

does this mean get pernr retrieves only the latest record from the infotype.

Kindly help gurus.

Thanks in advance,

Bala

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,227

in the first case the program works with logical DB (Menu: Goto ==> Attributes), pls. have a look how the ldb selects the data!

10 REPLIES 10
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,228

in the first case the program works with logical DB (Menu: Goto ==> Attributes), pls. have a look how the ldb selects the data!

Read only

0 Likes
1,227

Thank you Eric...

Please can you help me find out how ldb works..

i will tell my understanding.

LDB uses joins to combine data from several tables.

is that so Eric.

Please help.

Thanks,

Bala.

Read only

0 Likes
1,227

>

> LDB uses joins to combine data from several tables.

this is not necessary the case (and I am almost 100% sure, that it is not the case here).

First check in the programm attributes, the name of the LDB. Display it in SE36 and have a look what it is doing. If stucked, just let me know, but I'll need the name of the LDB!

Read only

0 Likes
1,227

Hi Eric,

The LDB i am using is PNP.

thanks,

bala.

Read only

0 Likes
1,227

I don't know if you've given validity time on the selection screen, if not that simply the actual data is selected only, if yes, than accordingly to the selection screen.

Read only

0 Likes
1,227

The INFOTYPES:0001 statement declares an internal table p0001 of the dd structure p0001 with a header line.

The GET PERNR event loads the itab p0001 for each pernr, with all the relevant records that satisfy the selection screen crtireia & the inherent authorization checks built into the PNP.

When you simply access p0001-begda after get pernr, you will in fact get what is in the header.

If you loop at P0001, you will see all the records, that you got using the SELECT on PA0001.

Get it?

~Suresh

Read only

0 Likes
1,227

Hi see the code below.

REPORT  ZBALAHRINFOTYPES.

nodes pernr.

INFOTYPES : 0000.

get pernr.

write p0000-pernr.

If that is the case i should get only one pernr as output here. but in the output i get all pernr's

Kindly help.....

Thanks Bala.

Read only

0 Likes
1,227

Hi eric ,

The thing is i want to know what actually is what get pernr does.

GET pernr

I dont think it populates the tables p0000,p0001, ....... alone ,

but populates and loops through them

because the following code

nodes pernr.
INFOTYPES :0000.
get pernr.
WRITE p0000-pernr.

.

gives all the pernr in the system..

I dont worry about the output here or selections i make. i just want to know what

get pernr

does.I am a very much a beginner in abap. please help gurus.

Thanks in Advance,

Bala.

Read only

0 Likes
1,227

Bala: Suresh is right, I overlooked. The statement INFOTYPES 0001 defines an internal table (p0001) with header line, and the statement WRITE p0000-pernr actually prints the header line of this internal table.

"nodes pernr.

INFOTYPES :0000.

get pernr.

WRITE p0000-pernr.

gives all the pernr in the system.."

this is true, but it gives only one pernr at a time (works like a LOOP, the code after GET will run as many times, as number of employees are selected), you can check this easily in debug, just put a breakpoint on the WRITE

Read only

Former Member
0 Likes
1,227

>

> Hi,

>

> I have two pieces of code and i thought they will do the same , but they have different outputs. Please let me know why i get different outputs.

>

> code 1:

>

>

>

REPORT  ZBALAHRTEST.
> data i type i.
> nodes pernr.
> INFOTYPES : 0000,0001,0002,0003,0004,0005,0006,0007.
> 
> get pernr.
> 
> if p0001-pernr = '0000001'.
>    write : p0001-begda , p0001-endda.  
> endif.

>

> Output:

> 23.09.2008 31.12.9999

>

>

> The second code.

>

>

REPORT  ZBALAHRTEST1.
> 
> tables pa0001.
> 
> SELECT * from pa0001 where pernr = '00000001'.
>   write :/, pa0001-begda,pa0001-endda.
> ENDSELECT.

>

> Output:

>

>

> 01.06.2008 22.09.2008

>

> 23.09.2008 31.12.9999

>

> does this mean get pernr retrieves only the latest record from the infotype.

>

> Kindly help gurus.

>

> Thanks in advance,

> Bala

data i type i.
 nodes pernr.
 INFOTYPES : 0000,0001,0002,0003,0004,0005,0006,0007.
  get pernr.
     LOOP AT p0001.
       write:/  p0001-begda , p0001-endda. 
     ENDLOOP.

make this above change to your first code and check the results

the LDB populates the table P0001 with all the records of PA0001