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

Need help with a SELECT statement

former_member367551
Participant
0 Likes
1,199

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!

12 REPLIES 12
Read only

Former Member
0 Likes
1,167

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

Read only

Former Member
0 Likes
1,167

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.

Read only

0 Likes
1,167

Thanks very much for the helpful answers. It's clear enough already right now.

Read only

Former Member
0 Likes
1,167

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

Read only

Former Member
0 Likes
1,167
SELECT SINGLE STAT2 FROM PA0000 INTO PA0000-STAT2

Here 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

Read only

Former Member
0 Likes
1,167

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

Read only

Former Member
0 Likes
1,167

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

Read only

Former Member
0 Likes
1,167

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

Read only

Former Member
0 Likes
1,167

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.

Read only

Former Member
0 Likes
1,167

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

Read only

Former Member
0 Likes
1,167
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.

Read only

Former Member
0 Likes
1,167

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