CK11,CK11N 成本估算数据读取
CK11 数据读取
在程序使用中有时需要临时取成本估计的过程结果数据,此时的估算数据尚未保存至数据库,无法通过函数CK_F_CSTG_STRUCTURE_EXPLOSION 取得,可使用CK_F_MATERIAL_CALC进行先计算出中间结果,再经过相应转换可得出相要的结果。
以下是步骤展示:
第一步:使用CK_F_MATERIAL_CALC 计算中间结果
第二步:使用类cl_costing_persistence方法 costing_read_simple 转换明细数据
第三步:对明细结果进行第二步循环,展出整个成本结果数据。
单层读取样例如下(程序可直接运行):
REPORT zcf_ck11.
PARAMETERS:
klvar LIKE keko-klvar DEFAULT 'OP01',
matnr LIKE mara-matnr DEFAULT '404014305000',
werks LIKE marc-werks DEFAULT '8100',
*LOSGR LIKE KEKO-LOSGR
tvers LIKE keko-tvers DEFAULT '01',
*STLAN LIKE CKI64A-STLAN
*STALT LIKE CKI64A-STALT
*PLNTY LIKE CKI64A-PLNTY
*PLNNR LIKE CKI64A-PLNNR
*PLNAL LIKE CKI64A-PLNAL
kadat LIKE cki64a-kadat DEFAULT sy-datum,
*BIDAT LIKE CKI64A-BIDAT
*ALDAT LIKE CKI64A-ALDAT
bwdat LIKE cki64a-bwdat DEFAULT sy-datum,
*UEBID LIKE CKI64A-UEBID
*KALNR_BA LIKE CKI64A-KALNR_BA
*KALSM LIKE KEKO-KALSM
s_dunkel TYPE c DEFAULT 'X',
s_update TYPE c DEFAULT 'S'.
* s_no_commit TYPE c defult 'X'.
*S_REPETITIVE TYPE C SPACE
*S_SNGL_LOCK TYPE C 'X'
*U_KALSM TYPE XFELD SPACE
DATA: f_keko_exp LIKE keko.
DATA: t_keph_exp LIKE keph OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CK_F_MATERIAL_CALC'
EXPORTING
klvar = 'OP01'
matnr = matnr
werks = werks
* LOSGR =
tvers = tvers
* STLAN =
* STALT =
* PLNTY =
* PLNNR =
* PLNAL =
kadat = kadat
* BIDAT =
* ALDAT =
bwdat = bwdat
* UEBID =
* KALNR_BA =
* KALSM =
s_dunkel = s_dunkel
s_update = s_update
s_no_commit = 'X'
* S_REPETITIVE = ' '
* S_SNGL_LOCK = 'X'
* U_KALSM = ' '
IMPORTING
f_keko_exp = f_keko_exp
TABLES
t_keph_exp = t_keph_exp
EXCEPTIONS
wrong_call = 1
keph_not_found = 2
locked = 3
OTHERS = 4.
DATA: g_persistence_manager TYPE REF TO cl_costing_persistence.
IF g_persistence_manager IS INITIAL.
CALL METHOD cl_costing_persistence=>create
IMPORTING
ex_costing_persistence = g_persistence_manager.
ENDIF.
DATA: l_ckkekokey TYPE ckkekokey.
DATA: l_itemization TYPE kkek0_uc.
DATA: l_ccs TYPE ckf_keko_keph.
MOVE-CORRESPONDING f_keko_exp TO l_ckkekokey.
CALL METHOD g_persistence_manager->costing_read_simple
EXPORTING
im_kekokey = l_ckkekokey
im_read_mode = '0' "all locations
IMPORTING
ex_itemization = l_itemization
ex_ccs = l_ccs.
高度中可查看到L_ITEMIZATION-T_KIS1就是我们想要的结果