Skip to Content
0
Former Member
Jun 08, 2009 at 05:02 PM

How to get sales orders # when I have invoice number ??

105 Views

hi members,

need small help with this code.

I have a selected all the invoices from VBRK table and stored in it_vbrk and made second select statement to bring all the associated orders,

SELECT VBELN FKART NETWR KUNAG FROM VBRK
              INTO TABLE IT_VBRK  WHERE  FKART = 'ZF2' and 
                                                               RFBSK = 'A'.


IF NOT  IT_VBRK[]  IS INITIAL.
     SELECT VBELV VBELN FROM VBFA 
                                          INTO TABLE I_VBFA
                                          FOR ALL ENTRIES IN I_VBRK
                                          WHERE VBELN = I_VBRK-VBELN AND
                                          VBTYP_N = 'M' AND
                                          VBTYP_V = 'C'.
ENDIF.

But I am getting very few orders, Eg I have more than 10,000 invoices but I am getting 200 Orders.

What could be the problem.

When I Analyzed a further down and modify my second statement as ..

 
IF NOT  IT_VBRK[]  IS INITIAL.
     SELECT VBELV VBELN FROM VBFA 
                                          INTO TABLE I_VBFA
                                          FOR ALL ENTRIES IN I_VBRK
                                          WHERE VBELN = I_VBRK-VBELN AND
                                          VBTYP_N = 'M' AND
                                          VBTYP_V IN ('C','I','H')
ENDIF.

But I still think there is some problem with this code. Can you help me,

Thank you.

Madhu.