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

Comparing between VBELN

Former Member
0 Likes
650

Hi,

I have to find a VBELN which have unless TWO 'Sales Document Item' (for example: POSNR=10,POSNR=20,POSNR=30) then i have to find the POSNR which have the same PS_PSP_PNR.

i did this:



SELECT PS_PSP_PNR  POSNR vbeln  FROM vbap
   into CORRESPONDING FIELDS OF TABLE l_vbap.
LOOP AT l_vbap INTO l_vbap-vbeln.

  indice  = indice + 1.

  AT END OF vbeln.
    CLEAR indice.
  ENDAT.

  if indice GT 1.
   ??????????????????????????????????????? 
    WRITE ' two OTP'.
    ELSEIF.

  ENDIF.
ENDLOOP.

can you help me to find the missing '???????'

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
596

Hi try this logic:


SELECT PS_PSP_PNR  POSNR vbeln  FROM vbap
   into CORRESPONDING FIELDS OF TABLE l_vbap.
   
sort  l_vbap by vbeln. 
LOOP AT l_vbap INTO w_vbap. "<< workarea for l_vbap
  
  indice  = indice + 1.
  if w_vbap-posnr = w_vbap-PS_PSP_PNR.
    append w_vbap-posnr to i_posnr. "<< Table to store similar posnr
  endif.
  AT END OF vbeln.

  if indice GT 1 and i_posnr[] is not initial.

    WRITE ' two OTP'.
 
  ENDIF.
   clear indice.
   refresh i_posnr.
  ENDAT.
 

ENDLOOP.

3 REPLIES 3
Read only

Former Member
0 Likes
597

Hi try this logic:


SELECT PS_PSP_PNR  POSNR vbeln  FROM vbap
   into CORRESPONDING FIELDS OF TABLE l_vbap.
   
sort  l_vbap by vbeln. 
LOOP AT l_vbap INTO w_vbap. "<< workarea for l_vbap
  
  indice  = indice + 1.
  if w_vbap-posnr = w_vbap-PS_PSP_PNR.
    append w_vbap-posnr to i_posnr. "<< Table to store similar posnr
  endif.
  AT END OF vbeln.

  if indice GT 1 and i_posnr[] is not initial.

    WRITE ' two OTP'.
 
  ENDIF.
   clear indice.
   refresh i_posnr.
  ENDAT.
 

ENDLOOP.

Read only

0 Likes
596

thanks for having seen my pb.

but i cannot execut the prog:

 

sort  l_vbap by vbeln.

data :w_vbap LIKE LINE OF l_vbap.

DATA: begin of i_posnr OCCURS 0,
  posnr TYPE posnr,
  END OF i_posnr.

LOOP AT l_vbap INTO w_vbap. "<< workarea for l_vbap

  indice  = indice + 1.
  if w_vbap-posnr = w_vbap-PS_PSP_PNR.
    append w_vbap-posnr to i_posnr. "<< Table to store similar posnr
  endif.
  AT END OF vbeln.

  if indice GT 1 and i_posnr[] is not initial.

    WRITE ' two OTP'.

  ENDIF.
   clear indice.
   clear i_posnr.
  ENDAT.


ENDLOOP.

any idea why it does not work?

Read only

Former Member
0 Likes
596

thanks for help