01-22-2008 8:08 AM
Splitting the invoice based on the material Document(ekbe-belnr). Suppose i have 3 material documents for one Purchase order. Based on the 3 material documents, it shpould create 3 invoices. So for this i created a routine. Its for billing document copy control. But my routine is combining all the material document quantities and it creating only one invoice but i required multiple invoices based on no of material document. i wrote code like this. Its urgent..
FORM daten_kopieren_901.
TABLES: kna1.
DATA : v_kunnr TYPE kunag,
v_katr2 TYPE katr2,
v_belnr TYPE ekbe-belnr,
v_bewtp TYPE ekbe-bewtp.
DATA: BEGIN OF it_zuk1,
modul(3) VALUE '904',
vtweg LIKE vbak-vtweg,
spart LIKE vbak-spart,
belnr LIKE ekbe-belnr,
vgbel LIKE vbrp-vgbel,
END OF it_zuk1.
TYPES:BEGIN OF t_ekbe,
belnr TYPE ekbe-belnr,
bewtp TYPE ekbe-bewtp,
flag TYPE c, "Rajiv
END OF t_ekbe.
TYPES:BEGIN OF t_vbap,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
END OF t_vbap.
TYPES:BEGIN OF t_vbep,
banfn TYPE vbep-banfn,
END OF t_vbep.
TYPES:BEGIN OF t_eban,
ebeln TYPE eban-ebeln,
ebelp TYPE eban-ebelp,
END OF t_eban.
STATICS:i_ekbe TYPE STANDARD TABLE OF t_ekbe.
DATA: wa_ekbe TYPE t_ekbe.
DATA: i_vbap TYPE STANDARD TABLE OF t_vbap.
DATA: i_vbep TYPE STANDARD TABLE OF t_vbep.
DATA: i_eban TYPE STANDARD TABLE OF t_eban.
SELECT vbeln posnr FROM vbap INTO TABLE i_vbap
WHERE vbeln = vbak-vbeln.
IF sy-subrc = 0.
SELECT banfn FROM vbep INTO TABLE i_vbep
FOR ALL ENTRIES IN i_vbap
WHERE vbeln = i_vbap-vbeln
AND posnr = i_vbap-posnr.
ENDIF.
IF sy-subrc = 0.
SELECT ebeln ebelp FROM eban INTO TABLE i_eban
FOR ALL ENTRIES IN i_vbep
WHERE banfn = i_vbep-banfn.
ENDIF.
IF sy-subrc = 0.
SELECT belnr bewtp FROM ekbe INTO TABLE i_ekbe
FOR ALL ENTRIES IN i_eban
WHERE ebeln = i_eban-ebeln
AND ebelp = i_eban-ebelp.
endif.
**
LOOP AT i_ekbe INTO wa_ekbe WHERE flag NE 'X'.
IF ( ( wa_ekbe-bewtp = 'E' ) OR ( wa_ekbe-bewtp = 'R' ) OR
( wa_ekbe-bewtp = 'Q' ) ).
it_zuk1-vtweg = vbak-vtweg.
it_zuk1-spart = vbak-spart.
it_zuk1-belnr = wa_ekbe-belnr.
it_zuk1-vgbel = vbrp-vgbel.
wa_ekbe-flag = 'X'.
MODIFY i_ekbe FROM wa_ekbe TRANSPORTING flag.
vbrk-zukri = it_zuk1.
EXIT.
ENDIF.
ENDLOOP.
REFRESH: i_vbap,i_vbep,i_eban,i_ekbe.
*
ENDFORM.
01-22-2008 8:37 AM
Hi,
Your routine will not work as you can only split invoices based on differences in the originating document. From your coding I guess you do order-related billing (and not delivery-related billing). This means you can either group orders to one invoice or split orders to multiple invoices.
Regards,
John.
01-22-2008 1:19 PM
Hi John,
Thanks for the reply. But our requirement is to create one unique invoice for one GR document. It is a third party sales scenario and billing will happen basing on a sales order but the quantity should be derived from the GR document and for n number of GR's we should have n number of invoices. Kinldy help us by suggesting is there in any alternative for this.
Regards,
Ramana
01-22-2008 2:24 PM
Hi Ramana,
I'm afraid this is not possible. Correct me if I'm wrong: You have a TPO scenario in which you create a purchase order for a sales order item. This purchase order may have multiple GR? As billing is based on the sales order position (which is only one) there is no way to split this one position into multiple lines for each GR. This would only work if there is a 1:1 relation between sales order item and GR!
Regards,
John.
01-01-2024 2:22 PM
Hi Ramana , I have also got the same requirement .
Did you find out the way to develop thsi requirement ??
01-03-2024 1:35 PM