REPORT ztest_vk11 .
tables:konh ,A941.
data: lt_bapicondct type bapicondct occurs 0 , "
wa_bapicondct type bapicondct ,
lt_bapicondhd type bapicondhd occurs 0 , "
wa_bapicondhd type bapicondhd ,
lt_bapicondit type bapicondit occurs 0 ,
wa_bapicondit type bapicondit ,
lt_bapicondqs type bapicondqs occurs 0 ,
wa_bapicondqs type bapicondqs ,
lt_bapicondvs type bapicondvs occurs 0 ,
wa_bapicondvs type bapicondvs .
data: lt_bapiret2 type bapiret2 occurs 0 .
data: ret type bapiret2 .
data: lt_bapiknumhs type bapiknumhs occurs 0 .
data: lt_mem_initial type cnd_mem_initial occurs 0 .
data: h_varkey(100),
h_cond_unit type meins .
selection-screen begin of block bk1 with frame title text_001 .
parameters: i_kschl like A941-kschl, "条件类型
i_matnr like mvke-matnr,
i_vkorg like mvke-vkorg,
i_vtweg like mvke-vtweg,
i_kbetr like konp-kbetr. "定价值
select-options: I_qsdat for konh-datab. "定价的有效期范围
selection-screen end of block bk1 .
concatenate i_vkorg i_vtweg 'Y5' i_matnr into h_varkey .
select single meins from mara
into h_cond_unit where matnr = i_matnr .
if sy-subrc <> 0.
raise vkorgerror .
endif.
*condition table 已条件表A941为例
wa_bapicondct-table_no = '941'.
wa_bapicondct-applicatio = 'V'.
wa_bapicondct-cond_usage = 'A'. "条件表用途 ‘A' 定价
wa_bapicondct-cond_type = i_kschl. "定价条件
wa_bapicondct-operation = '009'. "消息功能 : 003 DEL ; 004 MODIFY ;005 REPLACE 009 INITIAL
*wa_bapicondct-operation = '004'. "更改
wa_bapicondct-varkey = h_varkey.
wa_bapicondct-valid_to = '99991231'.
wa_bapicondct-valid_from = i_qsdat-low.
wa_bapicondct-cond_no = '$000000001'. "创建
*wa_bapicondct-cond_no = '0003224015'. "更改
APPEND wa_bapicondct TO lt_bapicondct.
*KONH
wa_bapicondhd-operation = '009'.
*wa_bapicondhd-operation = '004'.
wa_bapicondhd-cond_no = '$000000001'.
*wa_bapicondhd-cond_no = '0003224015'.
wa_bapicondhd-created_by = sy-uname.
wa_bapicondhd-creat_date = sy-datum.
wa_bapicondhd-cond_usage = 'A'.
wa_bapicondhd-table_no = '941'.
wa_bapicondhd-applicatio = 'V'.
wa_bapicondhd-cond_type = i_kschl.
wa_bapicondhd-varkey = h_varkey.
wa_bapicondhd-valid_from = i_qsdat-low.
wa_bapicondhd-valid_to = i_qsdat-high.
append wa_bapicondhd to lt_bapicondhd .
*KONP
*wa_bapicondit-operation = '004'. "修改
wa_bapicondit-operation = '009'. "创建
wa_bapicondit-cond_no = '$000000001'.
*wa_bapicondit-cond_no = '0003224015'.
wa_bapicondit-cond_count = '01'. "条件序列号
wa_bapicondit-applicatio = 'V'.
wa_bapicondit-cond_type = i_kschl. "条件类型
wa_bapicondit-scaletype = 'A'. "STFKZ Staffelsoort
wa_bapicondit-scalebasin = ''. "KZBZG Teken:rekeneenheid " wa_bapicondit-scalebasin = 'C'. 存在数量等级
wa_bapicondit-scale_qty = '0'. "KSTBM Conditiestaffelbasis hoeveelheid
wa_bapicondit-cond_p_unt = '1'. "KPEIN prijseenheid
wa_bapicondit-cond_unit = h_cond_unit. "KMEIN Conditie-hoeveelheidseenheid
wa_bapicondit-calctypcon = 'C'. "KRECH Conditie-rekenregel
wa_bapicondit-cond_value = i_kbetr.
wa_bapicondit-condcurr = 'RMB'.
APPEND wa_bapicondit to lt_bapicondit .
CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
* EXPORTING
* PI_INITIALMODE = ' '
* PI_BLOCKNUMBER =
* PI_PHYSICAL_DELETION =
TABLES
ti_bapicondct = lt_bapicondct
ti_bapicondhd = lt_bapicondhd
ti_bapicondit = lt_bapicondit
ti_bapicondqs = lt_bapicondqs
ti_bapicondvs = lt_bapicondvs
to_bapiret2 = lt_bapiret2
to_bapiknumhs = lt_bapiknumhs
to_mem_initial = lt_mem_initial
EXCEPTIONS
UPDATE_ERROR = 1
OTHERS = 2
.
break-point.
IF sy-subrc <> 0.
write : 'SOMETHING UNEXCEPTED HAPPENDS!' .
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
IMPORTING
RETURN = RET
.
SAP VK11 使用函数BAPI_PRICES_CONDITIONS物料价格创建/更改
最新推荐文章于 2023-12-08 15:52:27 发布