cancel
Showing results for 
Search instead for 
Did you mean: 

Reading cost components of an item in VA01...

Former Member
0 Kudos
403

Hi,

We have some complex requirement to calculate an item price based on some components of cost calculation and markup. That varies based on some criteria. We have to use a pricing formula exit to provide such indirect functionality.

Cost is provided in a condition say EK01. In va01, after costing an item cost in being saved in buffer. It is not going to be saved in tables KEKO & KEPH unless you save the order. My question is:

- How to read cost from buffer? or

- is there any function module that i can provide the item detail and it returns back cost components?

Any help is appreciated...

Thanks in advance,

Accepted Solutions (0)

Answers (1)

Answers (1)

Frank711
Explorer

Hi,

I add some code that I used to get the data from cost calculation. The code contains function modules and the import statement to get the data from memory or datebase.

  • Einzelkalkulation der Hauptposition lesen

CALL FUNCTION 'K_UNITCOSTING_MEMORY_ADRESS'

EXPORTING

lednr_imp = '00'

bzobj_imp = '4'

kalnr_imp = xvbap-kalnr

kalka_imp = '15'

kadky_imp = '00000000'

tvers_imp = '01'

bwvar_imp = ' '

kkzma_imp = ' '

IMPORTING

memory_adress_exp = ik_memadress

EXCEPTIONS

OTHERS = 1.

CHECK sy-subrc = 0.

CALL FUNCTION 'K_UNITCOSTING_LOCATION_DETECT'

EXPORTING

key_fully_qualified_imp = 'X'

bzobj_imp = '4'

kalnr_imp = xvbap-kalnr

kalka_imp = '15'

kadky_imp = '00000000'

tvers_imp = '01'

bwvar_imp = ' '

kkzma_imp = ' '

IMPORTING

costing_in_memory_exp = ik_mem

costing_on_database_exp = ik_db

memory_adress_exp = ik_memadress

EXCEPTIONS

klvar_not_defined = 1

OTHERS = 2.

CHECK sy-subrc = 0.

  • Einzelkalkulation aus Memory übernehmen

IF ik_mem = 'X'.

IMPORT sav_khs1 TO ik_khs1

t_sav_kis1 TO ik_kis1

t_sav_ckip TO ik_ckip

FROM MEMORY ID ik_memadress.

IF sy-subrc NE 0.

MESSAGE e015 RAISING import_failed.

ENDIF.

  • Einzelkalkulation von Datenbank lesen

ELSEIF ik_db = 'X'.

CALL FUNCTION 'K_UNITCOSTING_READ'

EXPORTING

fel_bwvar = ' '

fel_bzobj = '4'

fel_kadky = '00000000'

fel_kalka = '15'

fel_kalnr = xvbap-kalnr

fel_kkzma = ' '

fel_lednr = '00'

fel_spras = sy-langu

fel_tvers = '01'

IMPORTING

fel_khs1 = ik_khs1

TABLES

fel_tab_ckit = ik_ckit

fel_tab_kis1 = ik_kis1

EXCEPTIONS

fel_not_found = 1

OTHERS = 2.

  • Einzelkalkualtion ist noch nicht angelegt

ELSEIF ik_mem IS INITIAL AND

ik_db IS INITIAL.

CONTINUE.

ENDIF.

  • Steuerdaten aus Customizing für Einzelkalkulation

CALL FUNCTION 'KKEK_TCK_TABLES_READ'

EXPORTING

klvar_imp = ik_khs1-kkart

werks_imp = xvbap-werks

flg_set_klvar_for_valuation = '1'

IMPORTING

tck01_exp = w_tck01

tck03_exp = w_tck03

tck04_exp = w_tck04

tck05_exp = w_tck05

tck22_exp = w_tck22

tck23_exp = w_tck23

EXCEPTIONS

record_not_found_tck01 = 08

record_not_found_tck03 = 10

record_not_found_tck05 = 12

record_not_found_tck22 = 14

OTHERS = 0.

*

Former Member
0 Kudos

Thanks alot Frank. BUT could you please clearify where this code should be added. Because there are unknow fields and table.

You help is greatly appreciated.

Thanks alot.

ChristianFi
Active Participant
0 Kudos

Try also these:

CALL FUNCTION 'CK_F_KEKOKEY_SD_POS_READ'

CALL FUNCTION 'CK_F_KEKO_KEPH_DIRECT_READ'

Christian

Frank711
Explorer
0 Kudos

Hi,

the code is added in the user exit userexit_save_document_prepare in program SAPMV45A. Most of the fields and tables are declared local in the exit as needed for the funtion modules interfaces.