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

Problem Data Selection

Former Member
0 Likes
471

Hi Experts,

I have one query. I have unique sales order in my table ITAB. Now my requirement is to find out the partner function SP & SH for all sales order available in ITAB.

For partner function I have appended both partner function in one range table having 2 values as above mentioned.

I wrote the below logic

LOOP AT ITAB INTO WA.

SELECT * FROM VBPA INTO CORRESPONDING FIELDS OF TABLE JTAB WHERE VBELN = WA-VBELN AND PARVW IN R_PARVW.

ENDLOOP.

I have checked the database table VBPA having entries for both partner function. But still after the loop I am getting only one value in internal table JTAB.

Any suggestion pls?

4 REPLIES 4
Read only

Former Member
0 Likes
452

Hii

Use this code:

Select * from VBPA into table JTAB for all entries in ITAB

where vbeln = it_vbeln and parvw in r_parvw.

This'll give you all the delivery num & partners

Cheers

RAvish

PS: Never use a select query inside a loop unless unavoidable.

Read only

Former Member
0 Likes
452

When you do Select ... into table .. statement, your internal table is refreshed for every statement, so it will have the results from just the last execution. thats the reason you are getting one entry as you are in a loop here.

Look at the answer above, and fix it./

Read only

Former Member
0 Likes
452

HI,

Instead of writing select in the loop try this way

SELECT * FROM VBPA INTO CORRESPONDING FIELDS OF TABLE JTAB

FOR ALL ENTRIES IN ITAB

WHERE VBELN = ITAB-VBELN AND PARVW IN R_PARVW

Read only

Former Member
0 Likes
452

Hi Neha,

I think you need to consider POSNR while selecting from VBPA table, then you can see more than one entry in the internal table for partner functions.

LOOP AT ITAB INTO WA.

SELECT * FROM VBPA INTO CORRESPONDING FIELDS OF TABLE JTAB WHERE VBELN = WA-VBELN and posnr = wa-posnr AND PARVW IN R_PARVW.

ENDLOOP.

Hope this helps

-Sujatha