2013 Mar 20 12:41 PM
Hi Gurus,
Can you please help me to develop this logic :
Select vbelv posnv vbeln posnn vbtyp_n vbtyp_v
From vbfa into corresponding fields of table lt_vbfa1
For all entries in lt_vbfa
Where vbelv = lt_vbfa-vbelv “getting the reference sales order number here
Vbtyp_n = 'M' “subsequent document category should be invoice
vbeln Not Equal To is_bil_invoice-it_gen-bil_number “ Do not consider items that are billed on this invoice.
If I did like this it throwing an error:
Select vbelv posnv vbeln posnn vbtyp_n vbtyp_v
From vbfa into corresponding fields of table lt_vbfa1
For all entries in lt_vbfa
Where vbelv = lt_vbfa-vbelv “getting the reference sales order number here
Vbtyp_n = 'M' .
Delete lt_vbfa1 where vbeln ne is_bil_invoice-it_gen-bil_number.
because is_bil_invoice-it_gen is also an internal table.
please help me.
thanks.
2013 Mar 20 1:17 PM
Hi Kittu,
I think performance wise the second option will be better.
But still if u want to go with the first option, then you can create a range table for it_gen-bil_number.
Then loop at is_bil_invoice and fill the range table and pass it in the SELECT query.
Select vbelv posnv vbeln posnn vbtyp_n vbtyp_v
From vbfa into corresponding fields of table lt_vbfa1
For all entries in lt_vbfa
Where vbelv = lt_vbfa-vbelv “getting the reference sales order number here
Vbtyp_n = 'M' “subsequent document category should be invoice
vbeln NOT IN r_bil_number “ Do not consider items that are billed on this invoice.
Regards,
Santanu Mohapatra.
2013 Mar 20 2:08 PM
Hi Santanu,
Can you please explain what you are saying. Can you please give me the code
. And I am saying above mentioned 2 procedures are throwing errors.
Thanks.
2013 Mar 20 2:59 PM
Hi Kittu,
You cant use the DELETE command in that manner.
Take all the bill numbers from is_bil_invoice-it_gen-bil_number internal table into an internal table(say it_temp).
loop at it_temp.
read table lt_vbfa1 with key vbeln = it_temp-bil_number.
if sy-subrc ne 0.
delete lt_vbfa1 where vbeln = it_temp-bil_number.
endif.
endloop.
Regards,
Mahidhar.
2013 Mar 20 3:15 PM
1) Check if the order of fields in the select statement is the same as in your internal table.
2) You cannot delete directly from an internal table.
copy is_bil_invoice table into another internal table with same structure. (lt_temp)
lt_temp[] = ls_bill_invoice_table[].
sort lt_temp by bill_number and delete adjacent duplicates. Now you will have unique bil_numbers.
loop at lt_vbfa.
l_index = sy-tabix.
read lt_temp with billing_number = lt_vbfa-billing_numebr.
if sy-subrc NE 0.
delete lt_vbfa index l_index.
endif.
clear: l_index ....etc.,
endloop.