Hi.
It depends on your company but probably is like this.
From TCK03 you get cost variant info.
"With these data you go into KEKO table (header data for calculate costs)
"You select like this:
clear keko.
select * from keko
where matnr = i_matnr
and werks = i_werks
and bzobj = tck03-bzobj
and kalka = tck03-kalka
and bwvar = tck03-bwvar
and loekz = space
and klvar = tck03-klvar
order by cpudt descending. "You need the most recent record
exit.
endselect.
"You get elements for calculate costs like this:
clear keph.
select * from keph
where bzobj = keko-bzobj
and kalnr = keko-kalnr
and kalka = keko-kalka
and kadky = keko-kadky
and tvers = keko-tvers
and bwvar = keko-bwvar
and kkzma = keko-kkzma
and kkzst = space
and kkzmm = space.
endselect.
IF sy-subrc NE 0 => Means NO CCST for input material
"Now you write your cost formula like this (Check TCKH3 table for combination)
i_ccst = ( keph-kst001 + " Raw material
keph-kst005 + "Fixed Cost Processing: Maintenance
keph-kst009 + "Fixed Cost Processing: staff
keph-kst013 + "Fixed Cost Processing: department costs
keph-kst017 + "Fixed Cost Processing: additional costs
keph-kst011 + "Cost processing variable: utilities
keph-kst015 + "Cost variable processing: disposal
keph-kst021 + "Cost processing variable: outsourcing
keph-kst007 + "Cost amortization process: line
keph-kst019 + "Processing fee amortization: department
keph-kst003 ). "Coatings
"Define a structure like this
data: begin of t_conversion occurs 0,
t_valuein type DEC15_4,
t_divin type konp-konwa,
t_valueout type DEC15_4,
t_divout type konp-konwa,
t_qty_in type kwmeng,
t_mis_in type vrkme,
t_qty_out type kwmeng,
t_mis_out type vrkme,
end of t_conversion.
"Find waerk to convert value (make a join between table if you want)
clear t001w.
select single * from t001w where werks eq i_werks. "Input Werks
IF sy-subrc EQ 0.
clear t001k.
select single * from t001k where bwkey eq t001w-bwkey.
IF sy-subrc EQ 0.
clear tka02.
select single * from tka02 where bukrs eq t001k-bukrs.
IF sy-subrc EQ 0.
clear tka01.
select single * from tka01 where kokrs eq tka02-kokrs.
if sy-subrc eq 0.
move tka01-waers to t_conversione-t_divin.. "
endif.
ENDIF.
ENDIF.
ENDIF.
" You get waerk out from move tvko-bukrs
select single * from t880 where rcomp eq tvko-bukrs. "(T880-CURR)
if sy-subrc eq 0.
move t880-curr to t_conversione-t_divout.
endif.
With t_conversione-t_divin and t_conversione-t_divout you can make your conversion of I_CCST
"For the quantity
clear mara.
select single * from mara where matnr eq i_matnr.
if sy-subrc eq 0.
move mara-meins to t_conversione-t_mis_out. "Base Unit Measure
endif.
move i_vrkme to t_conversione-t_mis_in. "BOM Unit measure (from BOM data
move i_kmpmg to t_conversione-t_qty_in. "Qtà nell DIBA (From BOM data
if t_conversione-t_mis_out ne t_conversione-t_mis_in and
not t_conversione-t_mis_out is initial and
not t_conversione-t_mis_in is initial and
not t_conversione-t_qty_in is initial.
perform convert_UM using i_matnr "Form with MM_ARRANG_QUANTITY_CONVERSION
t_conversione-t_qty_in
t_conversione-t_mis_in
t_conversione-t_mis_out
changing
t_conversione-t_qty_out.
elseif t_conversione-t_mis_out is initial.
raise NO_BASE_UM.
else.
t_conversione-t_qty_out = t_conversione-t_qty_in.
endif.
"Finally convert your Costs
if t_conversione-t_divout ne t_conversione-t_divin and
not t_conversione-t_divin is initial and
not t_conversione-t_divout is initial.
perform convert_waer using t_conversione-t_valuein
t_conversione-t_divin
t_conversione-t_divout
changing t_conversione-t_valueout.
else.
t_conversione-t_valueout = t_conversione-t_valuein.
endif.
* Product Cost divided lot = unit cost ....
IF NOT keko-losgr IS INITIAL. "Keko read in the beginning
t_conversione-t_valueout = t_conversione-t_valueout / keko-losgr. "Unit Cost
" Total product cost in company division
t_conversione-t_valueout = t_conversione-t_valueout * t_conversione-t_qty_out.
ENDIF.
You've finally your component value in t_conversione-t_valueout.
It's a little help
Hope to help
Bye