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 with select ... for all entries .

Former Member
0 Likes
805

Hi all,

This is the piece of code I have developed .

date1 = sy-datum - 89 .
date2 = sy-datum .

  SELECT vbeln FROM vbak INTO CORRESPONDING FIELDS OF TABLE i_vbak
  WHERE erdat >= date1 AND
        erdat <= sy-datum  AND
        vkorg IN s_vkorg .

  CHECK sy-subrc EQ 0 .

  SELECT kunnr FROM vbpa INTO CORRESPONDING FIELDS OF TABLE i_vbpa
  FOR ALL ENTRIES IN i_vbak
  WHERE vbeln = i_vbak-vbeln AND
               parvw = 'SH'  .

Given the criteria , the first select gets 439 records from the table VBAK which matches with the count from the table VBAK . The second select for all entries retuns sy-subrc as 4 where as I expect it should return 438 records from vbpa as per the given criteria . Can anyone please explaoi me where I am going wrong on the select statement .

Thanks ,

Daniel .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
750

Hi,

Instead of SH give WE for the ship to party..

SELECT kunnr FROM vbpa INTO CORRESPONDING FIELDS OF TABLE i_vbpa

FOR ALL ENTRIES IN i_vbak

WHERE vbeln = i_vbak-vbeln AND

parvw = '<b>WE</b>'

Thanks,

Naren

Hi,

Instead of SH give WE for the ship to party..

SELECT kunnr FROM vbpa INTO CORRESPONDING FIELDS OF TABLE i_vbpa

FOR ALL ENTRIES IN i_vbak

WHERE vbeln = i_vbak-vbeln AND

parvw = '<b>WE</b>'

Thanks,

Naren

5 REPLIES 5
Read only

Former Member
0 Likes
751

Hi,

Instead of SH give WE for the ship to party..

SELECT kunnr FROM vbpa INTO CORRESPONDING FIELDS OF TABLE i_vbpa

FOR ALL ENTRIES IN i_vbak

WHERE vbeln = i_vbak-vbeln AND

parvw = '<b>WE</b>'

Thanks,

Naren

Read only

0 Likes
750

Hi Narendra ,

It is returning some values , after giving "WE" instead of "SH" . But it is not matching with the record count form VBPA . I made a select on VBPA and I expect to get 438 records but it is giving only 123 entries . One thing I can observe is duplicates are not there in internal table . Can you please let me know what the issue could be .

Thanks ,

Daniel .

Read only

Former Member
0 Likes
750

FOR ALL ENTRIES gets rid of duplicate entries.

So modify i_vbpa and:

SELECT vbeln posnr parvw kunnr

FROM vbpa

INTO CORRESPONDING FIELDS OF TABLE i_vbpa

FOR ALL ENTRIES IN i_vbak

WHERE vbeln = i_vbak-vbeln

AND parvw = 'SH' .

Rob

Message was edited by:

Rob Burbank

Read only

Former Member
0 Likes
750

Hi,

As mentioned by Rob..WHen you are using FOR ALL ENTRIES..You have to give the key fields of the table VBPA..

SELECT <b>VBELN

POSNR

PARVW

kunnr</b>

FROM vbpa INTO CORRESPONDING FIELDS OF TABLE i_vbpa

FOR ALL ENTRIES IN i_vbak

WHERE vbeln = i_vbak-vbeln AND

parvw = <b>'WE'</b>

Thanks,

Naren

Read only

Former Member
0 Likes
750

Hello Daniel,

Whenever u r using for all entries always u should select all the<b> key</b> of the table.

So select all the key fields of vbpa.

If useful reward.

Vasanth