18.3.11

SAP Note 25144 - Freight conditions for milestone billing

Symptom:

During the partial delivery or milestone billing, condition values are generally distributed by quantity among the different billing documents. For freight conditions, you may not require this standard system behavior. For delivery-related billing (in this case, for freight condition HB00), this note results in the system not distributing the condition values to different billing documents; instead, the system transfers the total value of the header condition to the first item of the first billing document. However, the transfer to the first item is also performed if no milestone billing occurs.

Other terms

Freight conditions, HB00, milestone billing, partial delivery

Reason and Prerequisites

This is the standard system response. This is not an error.

Note that the solution described below is a modification that is not included in the standard system. Therefore, this note is not subject to maintenance and further development (see also Note 381348). Inquiries and problem messages concerning this subject are not covered by Support but are processed by Consulting, which is subject to a separate fee. The solution described here does not claim to be complete and may be unsuitable for some constellations and business processes that may occur. Known restrictions:

    1. This solution works only for condition types with the "Fixed Amount" calculation type. Furthermore, the relevant condition type must be set as a header condition and as a group condition to ensure that the total order value of the condition is correctly added to a billing item.
    2. The first item that is transferred to a billing document should not be free of charge because otherwise, no freight is calculated.
    3. Overdelivery and underdelivery are not covered by the solution described.
    4. The solution described in this note refers only to one specific freight condition.
    5. This solution cannot be used in the case of billing plans, since the determination of the proportional net item value for the billing document would be incorrect.
Solution

Use transaction SE37 to add the import parameter ORDER_NUMBER to the import/export parameters interface of the function module PRICING_COPY in the function pool SAPLV61A.

function pricing_copy.
*"---------------------------------------------------------------------
*"*"Globale Schnittstelle:
*" IMPORTING
*" CURRENCY_NEW LIKE KOMK-WAERK DEFAULT ' '
*" CURRENCY_NEW_DATE LIKE KOMK-PRSDT DEFAULT 0
*" CURRENCY_NEW_LOCAL LIKE KOMK-HWAER DEFAULT ' '
*" CURRENCY_NEW_RATE LIKE KOMK-KURRF DEFAULT 0
*" CURRENCY_NEW_TYPE LIKE KOMK-KURST DEFAULT 'M'
*" CURRENCY_OLD LIKE VBRK-WAERK DEFAULT ' '
*" DOCUMENT_NUMBER_FROM LIKE KONV-KNUMV
*" DOCUMENT_NUMBER_TO LIKE KONV-KNUMV
*" ITEM_NUMBER_FROM LIKE KONV-KPOSN
*" ITEM_NUMBER_TO LIKE KONV-KPOSN
*" MODE LIKE TVCPF-KNPRS
*" QUANTITY_NEW LIKE VBRP-FKLMG DEFAULT 0
*" QUANTITY_OLD LIKE VBRP-LMENG DEFAULT 0
*" VBTYP_NEW LIKE VBRK-VBTYP DEFAULT ' '
-----> ORDER_NUMBER LIKE VBRP-AUBEL DEFAULT ' '
*" TABLES
*" TKOMV STRUCTURE KOMV
*"---------------------------------------------------------------------

    1. Supply this parameter with "vbak-vbeln" in the program LV60AF0F:


013820 *---------------------------------------------------------------
013830 * FORM FAKTURAPOSI_LIEFERBEZOGEN
013840 *---------------------------------------------------------------
013850 * Erzeugen Fakturakopf und -position aus Lieferposition
013860 *---------------------------------------------------------------
013870 * --> LIKP Lieferscheinkopf
013880 * --> LIPS Lieferscheinposition
013890 * <-- XVBRK,XVBRP,....
013900 *---------------------------------------------------------------
013910
....
15820 * Copy conditions and call pricing
15830 if xvbrp-posar ne 'B'.
15840 call function 'PRICING_COPY'
15850 exporting
15860 currency_new = vbrk-waerk
15870 currency_new_date = vbrk-fkdat
15880 currency_new_local = t001-waers
15890 currency_new_rate = vbrk-kurrf
15900 currency_new_type = vbrk-kurst
15910 currency_old = vbak-waerk
15920 vbtyp_new = vbrk-vbtyp
15930 document_number_from = vbak-knumv
15940 document_number_to = beleg
15950 item_number_from = vbap-posnr
15960 item_number_to = xposnr
15970 mode = tvcpf-knprs
15980 quantity_new = vbrp-fklmg
15990 quantity_old = vbrp-lmeng
16000 order_number = vbak-vbeln <--------
16010 tables
16020 tkomv = xkomv.
16030 perform preisfindung using tvcpf-knprs.
16040 endif.

    2. To use the user exit 'userexit_pricing_copy', edit the program RV61AFZA.


<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<< start of insertion < < << <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tables: vbfa, vbak
vbrk.

data: begin of zitab1 occurs 20,
aubel like vbak-vbeln,
fkbel like vbak-vbeln,
storno_vorh,
kond_vorh,
end of zitab1.

data: begin of zitab2 occurs 5,
aubel like vbak-vbeln,
end of zitab2.

<<<<<<<<<<<<<<<< end of insertion <<< < <<<<<<<<<<<<<<<<<< < <<<<<<<<<< <<<
*---------------------------------------------------------------------*
* FORM USEREXIT_PRICING_COPY *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
form userexit_pricing_copy.

<<<<<<<<<<<<<<<< start of insertion < < <<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<
data: tabix like sy-tabix,
kond_vorh, rc.

data: begin of zitabkey_a,
aubel like vbak-vbeln,
end of zitabkey_a.

data: begin of zitabkey_b,
aubel like vbak-vbeln,
fkbel like vbak-vbeln,
end of zitabkey_b.

if quantity_old < 0.
quantity_old = - quantity_old.
endif.

* For condition HB00: change distribution to billing
if vbtyp_new = 'M' and
konv-kschl = 'HB00' and
not order_number is initial.

clear kond_vorh.
*konv = konv.

clear zitabkey_a.
zitabkey_a-aubel = order_number.
read table zitab2 with key zitabkey_a
binary search.

if sy-subrc ne 0. " HB00 not yet handled (copied)

read table zitab1 with key zitabkey_a
binary search.

if sy-subrc ne 0. " Flow not yet read

select * from vbfa where vbelv = order_number
and vbtyp_n = 'M'
and stufe = '01'.

clear zitabkey_b.
zitabkey_b-aubel = order_number.
zitabkey_b-fkbel = vbfa-vbeln.
read table zitab1 with key zitabkey_b
binary search.

if sy-subrc ne 0.
* setup table zitab1
clear zitab1.
zitab1-aubel = order_number.
zitab1-fkbel = vbfa-vbeln.
insert zitab1 index sy-tabix.
endif.
endselect.
* are there any cancellation documents?
select * from vbfa where vbelv = order_number
and vbtyp_n = 'N'
and stufe = '01'.
if vbrk-vbeln ne vbfa-vbeln.
select single * from vbrk where vbeln = vbfa-vbeln.
endif.
clear zitabkey_b.
zitabkey_b-aubel = order_number.
zitabkey_b-fkbel = vbrk-sfakn.
read table zitab1 with key zitabkey_b
binary search.
if sy-subrc = 0.
zitab1-storno_vorh = 'X'.
modify zitab1 index sy-tabix.
endif.
endselect.
loop at zitab1.
* does condition HB00 exist?
if zitab1-storno_vorh ne 'X'.

select single * from vbrk where vbeln = zitab1-fkbel.

select * from konv up to 1 rows
where knumv = vbrk-knumv
and kschl = 'HB00'.
endselect.
if sy-subrc = 0.
zitab1-kond_vorh = 'X'.
modify zitab1.
endif.
endif.
endloop.
endif.
* end of setup of table zitab1
else.
kond_vorh = 'J'.
endif.


if kond_vorh ne 'J'.
clear zitabkey_a.
zitabkey_a-aubel = order_number.
read table zitab1 with key zitabkey_a
binary search.
tabix = sy-tabix.
while sy-subrc = 0 and zitab1-aubel = order_number.
if zitab1-kond_vorh = 'X' and zitab1-storno_vorh = ' '.
kond_vorh = 'J'. exit.
endif.

tabix = tabix + 1.
read table zitab1 index tabix.
endwhile.
endif.

if kond_vorh ne 'J'.

read table zitab2 with key order_number
binary search.
if sy-subrc ne 0.
zitab2-aubel = order_number.
insert zitab2 index sy-tabix.
endif.
*konv-kwert = *konv-kbetr.
*********************************************************************
* currency conversion 24.01.1997
*********************************************************************
xkomv = *konv.
if ( currency_new ne *konv-waers and currency_new ne space ).
perform xkomv_kkurs_ermitteln.
*konv = xkomv.
if currency_new ne *konv-waers and
xkomv-kwert ne 0.
xkwert = xkomv-kwert.
if *konv-waers ne currency_new_local.
call function 'CONVERT_TO_LOCAL_CURRENCY'
exporting
date = currency_new_date
foreign_amount = xkwert
foreign_currency = *konv-waers
local_currency = currency_new_local
rate = *konv-kkurs
type_of_rate = kurstyp
importing
local_amount = xkwert
exceptions
no_rate_found = 4.
if sy-subrc ne 0.
*konv-kinak = 'X'.
endif.
endif.
if currency_new ne currency_new_local.
call function 'CONVERT_TO_FOREIGN_CURRENCY'
exporting
date = currency_new_date
local_amount = xkwert
foreign_currency = currency_new
local_currency = currency_new_local
rate = currency_new_rate
type_of_rate = kurstyp
importing
foreign_amount = xkwert
exceptions
no_rate_found = 4.
if sy-subrc ne 0.
*konv-kinak = 'X'.
endif.
endif.
*konv-kwert = xkwert.
endif.
endif.
**********************************************************************
* currency conversion
***********************************************************************
else.
clear: *konv-kbetr, *konv-kawrt, *konv-kwert.
endif.

quantity_old = - quantity_old. " protect against overwrite
konv = *konv.
konv-ksteu = 'E'.
endif.
<<<<<<<<<<<<<<<< end of insertion <<< < < << < < <<<<<<<<<<<<<<<<<<<<<<<<<<<

endform.

3. Generate the program SAPLV61A.

No comments:

Post a Comment