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

Select query error

Former Member
0 Likes
1,245

Hello Friends,

Is this query is correct? actually I am getting error.

Is there any other way to write this query?... pls reply me.

SELECT VBELN POSNN FROM VBFA

INTO (PT_PONO-EBELN, L_POSNR)

WHERE VBELV = PT_VBAP-VBELN

AND POSNV = PT_VBAP-POSNR

AND VBTYP_N = GC_DOC_PO.

Regards,

Shreekant

12 REPLIES 12
Read only

Former Member
0 Likes
1,202

In your query:

SELECT VBELN POSNN FROM VBFA

INTO (PT_PONO-EBELN, L_POSNR)

WHERE VBELV = PT_VBAP-VBELN

AND POSNV = PT_VBAP-POSNR

AND VBTYP_N = GC_DOC_PO.

What is the type of the variable PT_PONO-EBELN?

Hope it should be the same type as that of VBFA-VBELN.

Read only

Former Member
0 Likes
1,202

hi shreekant

try to change this PT_VBAP-VBELN,PT_VBAP-POSNR......

try to give the correct where condition.

thanks and regards\

shyam,

Read only

Former Member
0 Likes
1,202

could u please tell wht error is displayed

Read only

former_member198270
Active Contributor
0 Likes
1,202

Hi Shree ,

write your select query in this format

SELECT matnr mtart meins INTO (it_matrec-matnr , it_matrec-mtart ,

it_matrec-meins )

FROM mara

WHERE matnr IN s_matnr.

Check for proper where condition .

Reward points if helpful .....

Regards,

Amber Soni

Message was edited by:

amber soni

Read only

Former Member
0 Likes
1,202

Hi shree,

try this

SELECT VBELN POSNN FROM VBFA
INTO (PT_PONO-EBELN  L_POSNR)

WHERE VBELV = PT_VBAP-VBELN   AND 
             POSNV = PT_VBAP-POSNR  AND
            VBTYP_N = GC_DOC_PO.

If it hasnt worked plz specify me which type of error u got

Reward if helpfull

Regards

Pavan

Read only

Former Member
0 Likes
1,202

Hi,

For the query that not use all key, you should use the format:

select XXX XXX

into ( XXX XXX)

up to 1 rows

where XXX.

endselect.

Read only

Former Member
0 Likes
1,202

hi

good

you have not mentioned what kind of error you r getting in this query,check with following things

1- check the condition that you have given in the into statement

2- check with the where and and conditions

thanks

mrutyun^

Read only

Former Member
0 Likes
1,202

Hi Shree,

Just check the data types of the variable in where condition.

Regards,

Suresh

Read only

Former Member
0 Likes
1,202

Hi Shreekant,

<b>

Reason for getting error in your SELECT query is:</b>

Yes it definetely throw error because there may be a choice of multiple records satisfying the WHERE condition, but you used Work area instead if you TABLE.

Suppose if you want only single record which satisfy the condition use either

1. SELECT SINGLE or

2. SELECT ... FROM .... UPTO 1 rows.

Also check also type mismatch i.e., whether your are pushing value into the correct dataobject or table.

<b>

Reward all helpful answers</b>

Regards,

V.Raghavender.

Read only

Former Member
0 Likes
1,202

try this select query.

declare internal table

data : begin of it_final,

vbeln like vbfa-vbeln,

posnn like vbfa-posnn,

ebeln like vbfa-ebeln,

vbelv like <tablename>-<fieldname>,

posnv like <tablename>-fieldname>,

vbtyp_n like <tablename>-fieldname>,

end of it_final.

include all the fields in final table which are used in the program.

then we can use select statement as

select vbeln posnn from vbfa into corresponding fields of table it_final

WHERE VBELV = PT_VBAP-VBELN

AND POSNV = PT_VBAP-POSNR

AND VBTYP_N = GC_DOC_PO.

in write satement we can give whichever fields we like to see in o/p

write 😕 it_final-vbeln,

it_final-posnn.

if u find this as helpful please reward with points

Read only

0 Likes
1,202

Hello Friends,

Thank you very much to all!... The issue is resolved.

Actuually the select statement is correct, only the thing is I did't declared "VBAP-POSNR"...

Also I have awarded some points...

Regards,

Shreekant

Read only

Former Member
0 Likes
1,202

Thanks to all.