Sie sind auf Seite 1von 3

One Line Item per invoice

Posted on August 21, 2007 by jiteshdua


There is a standard routine provided by SAP for this. We just need to assign rou
tine 6 at (copy control delivery to billing) data transfer VBRK/VBRP and maintai
n TVKO_MAXBI (Max no. of line items in invoice) = 1.
Purpose
This is an example of a data transfer routine. FORM routines for data transfer
allow you to fine tune the transferred fields during the copying process. This
requirement is used to limit the number of line items allowed in any single bill
ing document.
Example
In some countries there are government regulations that state that there is a li
mit as to the maximum number of lines that can be in any single invoice document
. In order to insure that this regulation is adhered to, this requirement can b
e assigned to the billing item category and the appropriate limits maintained in
configuration.
Procedure
Define a max number of line items in the IMG and then force an automat
ic split based on this using a copy control routine, email me if you have any pr
oblems, details are below.
IMG
Sales & Distribution>Billing>Billing Documents>Country Specific Features>Maintai
n Maximum Number of Billing Items
Enter the country code creating billng document and the Max allowed number of bi
lling items (note problem is on the FI side so I d advise 450 items or less).
In the copy control routine from your Delivery Doc or Sales Doc to your billing
type at item category level enter the following code to force a split based on t
he max number of items you ve defined. Adjust to suit any other internal requireme
nts. This is SAP standard and works fine.
*
*
* Data transfer for delivery related billing *
*
*
*
*
*
*
*
*
*
*
*

*
FORM DATEN_KOPIEREN_633 *
*
> VBAK Order header KUAGV View Sold-to *
VBAP Order item KURGV View Payer *
VBKD Business data order KUREV View Bill-to *
LIKP Delivery header KUWEV View Ship-to *
LIPS Delivery item *
*

DATA: BEGIN OF ZUK2,


MODUL(3) VALUE 006 ,
VTWEG LIKE VBAK-VTWEG,
SPART LIKE VBAK-SPART,
VGBEL LIKE VBRP-VGBEL,
BILLNO LIKE TVKO-MAXBI,
END OF ZUK2.
DATA: BEGIN OF J_1B_SIZE_SPLIT2 OCCURS 0,
KUNRG LIKE VBRK-KUNRG,
KUNAG LIKE VBRK-KUNAG,

ZTERM LIKE VBRK-ZTERM.


INCLUDE STRUCTURE ZUK2.
DATA: ITEMNO LIKE TVKO-MAXBI.
DATA: END OF J_1B_SIZE_SPLIT2.
DATA: J_1B_SIZE_COPY2 LIKE J_1B_SIZE_SPLIT2.
*
*
*
*
*
*
*
*
*
*
*

*
FORM DATEN_KOPIEREN_633 *
*
This is a clone of routine 003. *
It will ensure that *
*
one billing document can only have one reference document *
the sum of item volumes will not exceed the amount *
specified in the number of billing doc. items for the *
sales organization (TVKO-MAXBI) *
*

FORM DATEN_KOPIEREN_633.
CLEAR: VBRK-EXPKZ, VBRK-EXNUM.
VBRK-BZIRK
VBRK-KDGRP
VBRK-KONDA
VBRK-REGIO
VBRK-PLTYP

=
=
=
=
=

SPACE.
SPACE.
SPACE.
SPACE.
SPACE.

* If maximum number of billing items active


IF NOT TVKO-MAXBI IS INITIAL.
* Get billing doc. item number split data
READ TABLE J_1B_SIZE_SPLIT2
WITH KEY KUNRG = VBRK-KUNRG
KUNAG = VBRK-KUNAG
ZTERM = VBRK-ZTERM
VGBEL = VBRP-VGBEL.
IF SY-SUBRC <> 0.
CLEAR J_1B_SIZE_SPLIT2.
MOVE-CORRESPONDING VBRK TO J_1B_SIZE_SPLIT2.
MOVE-CORRESPONDING VBRP TO J_1B_SIZE_SPLIT2.
ENDIF.
* Check number of billing items against max. defined by tvko-maxbi
IF J_1B_SIZE_SPLIT2-ITEMNO < TVKO-MAXBI.
J_1B_SIZE_SPLIT2-ITEMNO
= J_1B_SIZE_SPLIT2-ITEMNO + 1.
ELSE.
J_1B_SIZE_SPLIT2-BILLNO
= J_1B_SIZE_SPLIT2-BILLNO + 1.
J_1B_SIZE_SPLIT2-ITEMNO = 1.
ENDIF.
* Store actual billing document counter and item counter
READ TABLE J_1B_SIZE_SPLIT2 INTO J_1B_SIZE_COPY2
WITH KEY KUNRG = VBRK-KUNRG
KUNAG = VBRK-KUNAG
ZTERM = VBRK-ZTERM
VGBEL = VBRP-VGBEL.
IF SY-SUBRC = 0.

MODIFY J_1B_SIZE_SPLIT2
TRANSPORTING ITEMNO BILLNO
WHERE KUNRG = VBRK-KUNRG
AND KUNAG = VBRK-KUNAG
AND ZTERM = VBRK-ZTERM
AND VGBEL = VBRP-VGBEL.
ELSE.
APPEND J_1B_SIZE_SPLIT2.
ENDIF.
* Add billing doc. number to split criteria
ZUK2-BILLNO = J_1B_SIZE_SPLIT2-BILLNO.
ENDIF.
* End of billing document split by number of allowed items
ZUK2-VTWEG = VBAK-VTWEG.
ZUK2-SPART = VBRP-SPART.
IF KURGV-PERFK = SPACE.
ZUK2-VGBEL = VBRP-VGBEL.
ENDIF.
VBRK-ZUKRI = ZUK2.
VBRK-KUNAG = VBRK-KUNRG.
ENDFORM.

Das könnte Ihnen auch gefallen