‎2008 Aug 28 8:15 AM
Dear forumers,
I'm a newbie in ABAP and I'm trying to figure out what the following line means (in bold letters):-
SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2
WHERE PERNR = ITAB_DATA-STAFF_NO.
Does this mean that the single data from the STAT2 field is selected and then placed back into the same field (doesn't quite makes sense, right)?
Please help and many thanks in advance!
‎2008 Aug 28 8:19 AM
Hi Deborah Tan,
SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2
WHERE PERNR = ITAB_DATA-STAFF_NO.it nothing but selecting single STAT2 value from the database and storing in field PA0000-STAT2.
please place the cursor on the SELECT statement and press F1 then you get the required help regarding the SELECT statement and the syntax also.
Best regards,
raam
‎2008 Aug 28 8:19 AM
yes..it means that a single data record is selected.
but it does not mean that it is placed back in the same table field....
when you delcare PA0000 in your program, it is a local work area (memory area) which has the same structure as the table PA0000.
So the INTO PA0000-STAT2 means that the data from the database table are placed in the local work area in the program which has the same name as the database table. if you see the program carefully, PA0000 must have been declared like a work area of the table PA0000 in the dictionary.
‎2008 Aug 28 8:51 AM
Thanks very much for the helpful answers. It's clear enough already right now.
‎2008 Aug 28 8:20 AM
Hi,
Here in this Select statement -
A single value is reterived from the table but placed in PA0000-STAT2
which I think might be a parameter in the screen.
Check your report.
Hope it helps.
award points if helps
‎2008 Aug 28 8:20 AM
SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2Here PA0000-STAT2 is your destinition work area to store data from infotype PA0000. PA0000 stores employee master data.
by using SELECT SINGLE you are instructing the sytem to store the first available value of STAT2 data into PA0000-STAT2 which satisfies your where condition.
Regards,
anirban
‎2008 Aug 28 8:21 AM
Hi Deborah,
SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2
PA0000 in PA0000-STAT2 might be the work area and you are sleecting into work area.
Regards,
Chandra Sekhar
‎2008 Aug 28 8:22 AM
Hey Tan
Your understanding is correct it doesnot make any sense because your are putting a select on PA0000-stat2 which is a data base table and in INTO your are using the same table .
You cnt update like this you need to declare a variable lets say stat of type pa000-stat2
and in INTO clause pass the variable
ALSO for HR please go ahead with logical databases .
One thing more as u r new forumer . Please close yout question once your problem is solved
~hitesh
‎2008 Aug 28 8:22 AM
hi,
If you look at the syntax we are extracting STAT2 from PA0000 which is a table and we are placing it in PA0000-STAT2.
PA0000 is also a header line structure for the table PA0000.
Regards
Sumit Agarwal
‎2008 Aug 28 8:23 AM
Hi Deborah,
As also said by others it will retrieve single data from PA0000
and place it to PA0000-STAT2. Generally we do this for the selection screen validation.
With luck,
Pritam.
‎2008 Aug 28 8:24 AM
Hi deborah,
The name in the INTO clause PA0000-STAT2 is a Workarea....
So you will get a single matching STAT2 value satisfying your condition in PA0000-STAT2.
Hope you are clear now...
Regards
Karthik D
‎2008 Aug 28 8:27 AM
SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2
WHERE PERNR = ITAB_DATA-STAFF_NO.
Does this mean that the single data from the STAT2 field is selected and then placed back into the same field (doesn't quite makes sense, right)?it sense very much right.
have you heared about table buffer concept?
here this concept exactly comes.
try with this below code:
TABLES:pa0000."tables must be decleare
SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2.
write:PA0000-STAT2.and since you are using select single than you should be use much key as much possible for getting accurate data.other wise system will pick first data which match your where condition.
Amit.
‎2008 Aug 28 8:43 AM
well thats actually one of the reasons why declaring itabs with headerline is obsolete.
Newbies cant read such a cryptic code and you proved it