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

Question reg. select statement

Former Member
0 Likes
517

Hi,

I have a question reg. select statement.

1. If I want to select the records in table vbpa for two partner types (AG and WE), how to write the statement?

(I know how to get records based on just one partner type AG or WE by mentioning as below in where condition, but I am stuck how to get records for multipe partner types)

SELECT vbeln parvw adnr

FROM vbpa

INTO CORRESPONDING FIELDS OF TABLE itab_vbpa

WHERE vbeln = itab_likp-vbeln

AND posnr = '000000'

AND parvw = 'WE'.

Is this the way as below to get records for multiple partner types? but it's giving syntax error!

SELECT vbeln parvw adrnr

FROM vbpa

INTO CORRESPONDING FIELDS OF TABLE itab_vbpa

WHERE vbeln = itab_likp-vbeln

AND posnr = '000000'

AND parvw in ( WE, AG).

2. If I get all records in a table from vbpa and if I just want to loop on this table so I read only records for 'AG' and 'WE', how to achieve this?

Thanks for your input in advance.

3 REPLIES 3
Read only

former_member156446
Active Contributor
0 Likes
490
SELECT vbeln parvw adrnr
FROM vbpa
INTO CORRESPONDING FIELDS OF TABLE itab_vbpa
WHERE vbeln = itab_likp-vbeln
AND posnr = '000000'
AND parvw in ( 'WE', 'AG' ). "<<<<

read table itab_likp into wa_likp where parvw eq 'AG'.
if sy-subrc eq 0.
code....
endif.


read table itab_likp into wa_likp where parvw eq 'WE'.
if sy-subrc eq 0.
code....
endif.
"opps.. you wanted loop right!!
loop at itab_likp where parvw in ('WE','AG').
code....
endloop.

or 

loop at itab_likp.
if itab_likp-parvw eq 'WE' or itab_likp-parvw eq 'AG'.
code...
endif.
endloop.
Read only

Former Member
0 Likes
490

SELECT vbeln parvw adrnr

FROM vbpa

INTO CORRESPONDING FIELDS OF TABLE itab_vbpa

WHERE vbeln = itab_likp-vbeln

AND posnr = '000000'

AND parvw in ( WE, AG).

You forgot the quotes. try this

where parvw IN ('WE','AG').

Read only

0 Likes
490

Thanks for the answers.

Reg. the second one, is it possible to achieve this using loop statement? (instead of achieving this with 'read' statement multiple times)

Thanks again.