转自 http://blog.csdn.net/zeewjj/article/details/7941525
REPORT ztest.
DATA:l_kbetr LIKE konp-kbetr.
l_kbetr = '999999'.
*UPDATE konp SET kbetr = l_kbetr WHERE knumh = '0002394137'.
DATA:it_condct LIKE TABLE OF bapicondct WITH HEADER LINE,
it_condhd LIKE TABLE OF bapicondhd WITH HEADER LINE,
it_condit LIKE TABLE OF bapicondit WITH HEADER LINE,
it_condqs LIKE TABLE OF bapicondqs WITH HEADER LINE,
it_condvs LIKE TABLE OF bapicondvs WITH HEADER LINE,
it_ret_mes LIKE TABLE OF bapiret2 WITH HEADER LINE,
it_knumhs LIKE TABLE OF bapiknumhs WITH HEADER LINE,
it_mem_initial LIKE TABLE OF cnd_mem_initial WITH HEADER LINE.
*& 条件价格赋值,需要填充TI_BAPICONDCT,TI_BAPICONDHD,TI_BAPICONDIT.
it_condct-table_no = '017'.
it_condct-cond_usage = 'A'.
it_condct-cond_type = 'PB00'.
it_condct-applicatio = 'M'.
it_condct-operation = '004'.
it_condct-cond_no = '0002394137'.
it_condct-valid_from = 20090907.
it_condct-valid_to = 99991231.
DATA:l_lifnr LIKE eina-lifnr,
l_matnr LIKE eina-matnr,
l_key LIKE bapicondct-varkey.
l_lifnr = '0000001108'.
l_matnr = '5940-01972'.
CONCATENATE l_lifnr l_matnr INTO l_key.
CONCATENATE l_key '1000' INTO l_key SEPARATED BY ''.
CONCATENATE l_key '1000' '0' INTO l_key.
it_condct-varkey = l_key.
APPEND it_condct.
it_condhd-cond_no = '0002394137'.
it_condhd-operation = '004'.
it_condhd-cond_usage = 'A'.
it_condhd-table_no = '017'.
it_condhd-applicatio = 'M'.
it_condhd-cond_type = 'PB00'.
it_condhd-varkey = l_key.
it_condhd-valid_from = 20090907.
it_condhd-valid_to = 99991231.
APPEND it_condhd.
it_condit-cond_no = '0002394137'.
it_condit-operation = '004'.
it_condit-cond_count = '01'.
it_condit-applicatio = 'M'.
it_condit-cond_type = 'PB00'.
it_condit-scaletype = 'A'.
it_condit-conditidx = '01'.
it_condit-cond_p_unt = '1'.
it_condit-cond_unit = 'SET'.
PERFORM convert_into_input CHANGING it_condit-cond_unit.
it_condit-calctypcon = 'C'.
it_condit-exclusion = 'X'.
it_condit-pmnttrms = ''.
it_condit-condcurr = 'CNY'.
it_condit-cond_value = l_kbetr.
APPEND it_condit.
CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
TABLES
ti_bapicondct = it_condct
ti_bapicondhd = it_condhd
ti_bapicondit = it_condit
ti_bapicondqs = it_condqs
ti_bapicondvs = it_condvs
to_bapiret2 = it_ret_mes
to_bapiknumhs = it_knumhs
to_mem_initial = it_mem_initial
EXCEPTIONS
update_error = 1
OTHERS = 2.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
DATA:it_einex LIKE TABLE OF eine WITH HEADER LINE,
it_einax LIKE TABLE OF eina WITH HEADER LINE,
it_einay LIKE TABLE OF eina WITH HEADER LINE ,
it_einey LIKE TABLE OF eine WITH HEADER LINE,
it_reg_eina LIKE TABLE OF eina WITH HEADER LINE.
SELECT SINGLE *
INTO it_einay
FROM eina
WHERE infnr = '5300268905'.
it_einax = it_einay.
it_reg_eina = it_einax.
SELECT *
INTO TABLE it_einey
FROM eine
WHERE infnr = '5300268905'.
LOOP AT it_einey.
it_einex = it_einey.
it_einex-netpr = l_kbetr.
it_einex-effpr = l_kbetr.
APPEND it_einex.
ENDLOOP.
CALL FUNCTION 'ME_UPDATE_INFORECORD' IN UPDATE TASK
EXPORTING
xeina = it_einax
xeine = it_einex
yeina = it_einay
yeine = it_einey
reg_eina = it_reg_eina.
CLASS cl_badi_mm DEFINITION LOAD.
DATA:l_exit TYPE REF TO if_ex_me_inforec_send.
DATA:it_eina_n TYPE mmpr_einau,
it_eina_o TYPE mmpr_eina,
it_eine_n TYPE mmpr_eineu,
it_eine_o TYPE mmpr_eine ,
wa_eina_n LIKE LINE OF it_eina_n,
wa_eine_n LIKE LINE OF it_eine_n,
wa_eina_o LIKE LINE OF it_eina_o,
wa_eine_o LIKE LINE OF it_eine_o.
DATA: maxmenge LIKE ekpo-menge VALUE '9999999999'.
l_exit ?= cl_badi_mm=>get_instance( 'ME_INFOREC_SEND' ).
IF NOT l_exit IS INITIAL.
IF NOT it_einax IS INITIAL.
MOVE-CORRESPONDING it_einax TO wa_eina_n.
APPEND wa_eina_n TO it_eina_n.
MOVE-CORRESPONDING it_einax TO wa_eina_o.
APPEND wa_eina_o TO it_eina_o.
ENDIF.
IF NOT it_einex IS INITIAL.
MOVE-CORRESPONDING it_einex TO wa_eine_n.
MOVE 'U' TO wa_eine_n-kz.
APPEND wa_eine_n TO it_eine_n.
MOVE-CORRESPONDING it_einey TO wa_eine_o.
APPEND wa_eine_o TO it_eine_o.
ENDIF.
CALL METHOD l_exit->send_changes
EXPORTING
n_eina = it_eina_n
o_eina = it_eina_o
n_eine = it_eine_n
o_eine = it_eine_o
EXCEPTIONS
error_in_send = 1.
ENDIF.
COMMIT WORK.
*&---------------------------------------------------------------------*
*& Form CONVERT_INTO_INPUT
*&---------------------------------------------------------------------*
转载于:https://www.cnblogs.com/rainysblog/p/4224736.html