cancel
Showing results for 
Search instead for 
Did you mean: 

is there any BAPI to create condition table records in CRM?

Former Member
0 Kudos

Hi ,

   i want to find a BAPI to create condition table records in batch.

  could anyone help on this?

BR.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Gang Li,

I hope below code may helpful.

CONSTANTS: lc_kschl_z123 TYPE kscha VALUE 'Z123'.

DATA: lv_datum       TYPE sydatum,
lv_count       TYPE kopos,
lv_unit        TYPE kpein,
is_bapicondct  TYPE bapicondct,
is_bapicondhd  TYPE bapicondhd,
is_bapicondit  TYPE bapicondit,
it_bapicondct  TYPE STANDARD TABLE OF bapicondct,
it_bapicondhd  TYPE STANDARD TABLE OF bapicondhd,
it_bapicondit  TYPE STANDARD TABLE OF bapicondit,
it_bapicondqs  TYPE STANDARD TABLE OF bapicondqs,
it_bapicondvs  TYPE STANDARD TABLE OF bapicondvs,
it_bapiret2    TYPE STANDARD TABLE OF bapiret2,
is_bapiret2    TYPE bapiret2,
it_bapiknumhs  TYPE STANDARD TABLE OF bapiknumhs,
it_mem_initial TYPE STANDARD TABLE OF cnd_mem_initial.

lv_datum = sy-datum.
lv_count = 1.

LOOP AT gt_vbap INTO wa_vbap.

* BAPI Structure for Condition Tables
is_bapicondct-operation  = '009'.
is_bapicondct-table_no   = '700'.
is_bapicondct-applicatio = 'V'.
is_bapicondct-cond_usage = 'A'.
is_bapicondct-cond_type  = lc_kschl_z123.

"Set the varkey from A700 table key fields
CONCATENATE wa_vbap-vbeln wa_vbap-posnr
INTO is_bapicondct-varkey.

is_bapicondct-valid_to   = '12/31/2009'.
is_bapicondct-valid_from = lv_datum.
is_bapicondct-cond_no    = '$000000001'.

**** BAPI Structure of KONH with English Field Names
is_bapicondhd-operation  = '009'.
is_bapicondhd-cond_no    = '$000000001'.
is_bapicondhd-created_by = sy-uname.
is_bapicondhd-creat_date = sy-datum.
is_bapicondhd-cond_usage = 'A'.
is_bapicondhd-table_no   = '700'.
is_bapicondhd-applicatio = 'V'.
is_bapicondhd-cond_type  = lc_kschl_z123.
is_bapicondhd-varkey     = is_bapicondct-varkey.
is_bapicondhd-valid_to   = '12/31/2009'.
is_bapicondhd-valid_from = lv_datum.

*** BAPI Structure of KONP with English Field Names
CLEAR is_bapicondit.
is_bapicondit-operation  = '009'.
is_bapicondit-cond_no    = '$000000001'.
is_bapicondit-cond_count = lv_count.
is_bapicondit-applicatio = 'V'.
is_bapicondit-cond_type  = lc_kschl_z123.
is_bapicondit-scaletype  = 'A'.
is_bapicondit-scalebasin = 'B'.
ADD 1 TO is_bapicondit-scale_qty.
is_bapicondit-calctypcon = 'B'.
lv_unit = wa_vbap-kwmeng.
is_bapicondit-cond_p_unt = lv_unit.
is_bapicondit-cond_value = wa_vbap-value.
is_bapicondit-condcurr   = wa_vbap-waerk.

APPEND: is_bapicondct TO it_bapicondct,
is_bapicondhd TO it_bapicondhd,
is_bapicondit TO it_bapicondit.

ENDLOOP.

*** BAPI for pricing Condition Records
CALL FUNCTION 'BAPI_PRICES_CONDITIONS'
TABLES
ti_bapicondct  = it_bapicondct
ti_bapicondhd  = it_bapicondhd
ti_bapicondit  = it_bapicondit
ti_bapicondqs  = it_bapicondqs
ti_bapicondvs  = it_bapicondvs
to_bapiret2    = it_bapiret2
to_bapiknumhs  = it_bapiknumhs
to_mem_initial = it_mem_initial
EXCEPTIONS
update_error   = 1
OTHERS         = 2.

IF sy-subrc EQ 0.

WRITE: /1 'Return Messages for Condition create'(t03).
LOOP AT it_bapiret2 INTO is_bapiret2.
WRITE: /1 is_bapiret2-message.
ENDLOOP.
ULINE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait   = 'X'
IMPORTING
return = is_bapiret2.
ENDIF.

if the above code is not worked out check the below links.

this may help you.

http://scn.sap.com/message/8947465

http://www.qnasap.com/need-a-bapi-or-fm-for-changing-condition-record-valid-to-date-tcode-vk12/

Regards,

Hcl Innovators.