05-12-2007 3:39 PM
Hi all!
does anyone know what are the steps to retrieve from SAP price per unit value that customer was invoiced?
I am writing Z program for retrieving price per unit (for example per kilogram) in order to calculate debit/credit memo invoice for the customer.
To achieve this I have the following information:
customer nr
material nr
amount of units (for example amount of kilograms)
invoice nr
pricelist nr
so price per unit value is missing here... if I have it I could multiply it with amount of units and get the result I need...
Award points are waiting!
BR, M.
05-12-2007 5:20 PM
Hi
All price related data will be stored in KONV table
Take the VBRK-KNUMV table field and pass it to KONV-KNUMV and take the KBETR field which gives the rate Amount.
If you won't get.
Take the billing Qty and the Net amount fields for that billing document
and divide the amount with qty to get the Unit rate .
Reward points if useful
Regards
Anji
05-12-2007 5:20 PM
Hi
All price related data will be stored in KONV table
Take the VBRK-KNUMV table field and pass it to KONV-KNUMV and take the KBETR field which gives the rate Amount.
If you won't get.
Take the billing Qty and the Net amount fields for that billing document
and divide the amount with qty to get the Unit rate .
Reward points if useful
Regards
Anji
05-13-2007 6:13 PM
Hello Anji!
thanks for your input!
... but where pricelists are used here? I guess I have to use pricelists as they contain different values.
I will try to be more precise. Here is what I have:
KNA1-KUNNR Customer Number 1
by the way, would be great if you know what are other tables using with KUNNR
T189-PLTYP Price list type
A006-PLTYP Table for sales area, pricelist and material connection
MARA-MATNR Material nr
BSEG-BELNR Invoice nr
KONH-KNUMH Number of suplier
Having this information I have to find out what is the current rate for each MARA-MATNR to the KNA1-KUNNR and I guess A006-PLTYP has to be used here as well...
I need to have the current rate of materials in order to calculate the difference from the invoiced value (I need to prepare creadit or debit memo invoice).
If something is not explained good - please let me know.
BR, M.
05-13-2007 7:24 PM
Get the data from A004 and A005 tables...
See below example code material price per unit :
Get the data from A004 table to get KNUMH
Added new field Sales Unit - Seshu 01/09/2006
refresh : i_a004.
clear : i_a004.
data : lv_kbetr like konp-kbetr," Condition value
lv_KPEIN like konp-kpein , "per
lv_KMEIN like konp-KMEIN. " Sales Unit
select * from a004 into table i_a004
where matnr = i_join-matnr
and vkorg = '0001'
and vtweg = '01'.
if sy-subrc eq 0.
sort i_a004 by DATAB descending.
Get the Latetest Date
read table i_a004 with key matnr = i_join-matnr
vkorg = '0001'
vtweg = '01'
binary search.
Get the Sales Value
select single kbetr KPEIN KMEIN from konp
into (lv_kbetr,lv_KPEIN, lv_KMEIN)
where knumh = i_a004-knumh
and kappl = i_a004-kappl
and kschl = i_a004-kschl.
if sy-subrc eq 0.
i_output-kbetr = lv_kbetr / lv_KPEIN.
i_output-KMEIN = lv_KMEIN.
endif.
endif.
clear : lv_kbetr,
lv_kpein,
lv_KMEIN.
Reward Points if it is useful
Thanks
Seshu
05-14-2007 12:09 PM
Thanks for reply Seshu.
But how pricelist PLTYP is involved in the code you provided?
BR, M.
05-14-2007 12:24 PM
Try FM PRICING, since I know that handles customer specific pricing. Sticking a breakpoint on it and creating/changing a salesorder will let you see how SAP calls it.
05-14-2007 1:18 PM
maybe this would help but I do not have enough time to analyze FM PRICING...
who else wants reward points?
BR, M.