2008 Oct 23 3:58 PM
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
2008 Oct 23 4:02 PM
in the first case the program works with logical DB (Menu: Goto ==> Attributes), pls. have a look how the ldb selects the data!
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
2008 Oct 23 4:02 PM
in the first case the program works with logical DB (Menu: Goto ==> Attributes), pls. have a look how the ldb selects the data!
2008 Oct 23 4:05 PM
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.
2008 Oct 23 4:08 PM
>
> 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!
2008 Oct 23 4:11 PM
2008 Oct 23 4:24 PM
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.
2008 Oct 23 4:58 PM
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
2008 Oct 24 5:32 AM
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.
2008 Oct 24 5:40 AM
Hi eric ,
The thing is i want to know what actually is what get pernr does.
GET pernrI 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.
2008 Oct 24 7:58 AM
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
2008 Oct 23 4:17 PM
>
> 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