Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI_PRICES_CONDITIONS

Former Member
0 Kudos

I have implemented a code based on some code samples about BAPI_PRICES_CONDITIONS in this forum but it doesn't work.

It doesn't return any error but doesn't create any reg condition.

Any help? My code:

wtabla1-table_no = my-kotabnr.

wtabla1-applicatio = 'V'.

wtabla1-cond_type = my-kschl.

wtabla1-operation = '009'.

wtabla1-varkey = g_vakey.

wtabla1-valid_to = my-datbi.

wtabla1-valid_from = my-datab.

wtabla1-cond_no = knumh_new.

APPEND wtabla1 TO tabla1.

wtabla2-operation = '009'.

wtabla2-cond_no = knumh_new.

wtabla2-created_by = sy-uname.

wtabla2-creat_date = sy-datum.

wtabla2-cond_usage = 'A'.

wtabla2-table_no = my-kotabnr.

wtabla2-applicatio = 'V'.

wtabla2-cond_type = my-kschl.

wtabla2-varkey = g_vakey.

wtabla2-valid_from = my-datab.

wtabla2-valid_to = my-datbi..

APPEND wtabla2 TO tabla2.

wtabla3-operation = '009'.

wtabla3-cond_no = knumh_new.

wtabla3-cond_count = my-kopos.

wtabla3-applicatio = 'V'.

wtabla3-cond_type = my-kschl.

wtabla3-scaletype = my-stfkz.

wtabla3-scalebasin = my-kzbzg.

wtabla3-scale_qty = my-kstbm.

wtabla3-cond_p_unt = my-kpein.

wtabla3-cond_unit = my-kmein.

wtabla3-calctypcon = my-krech.

wtabla3-cond_value = my-kbetr.

wtabla3-condcurr = my-konwa.

APPEND wtabla3 TO tabla3.

CALL FUNCTION 'BAPI_PRICES_CONDITIONS'

  • EXPORTING

  • PI_INITIALMODE = ' '

  • PI_BLOCKNUMBER =

TABLES

ti_bapicondct = tabla1

ti_bapicondhd = tabla2

ti_bapicondit = tabla3

ti_bapicondqs = tabla4

ti_bapicondvs = tabla5

to_bapiret2 = tabla6

to_bapiknumhs = tabla7

to_mem_initial = tabla8

EXCEPTIONS

update_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

READ TABLE tabla6 WITH KEY type = 'E' TRANSPORTING NO FIELDS.

IF sy-subrc = 0.

LOOP AT tabla6 INTO wtabla6.

WRITE: / wtabla6-type, wtabla6-message, wtabla6-id,

wtabla6-log_no, wtabla6-log_msg_no,

wtabla6-message_v1, wtabla6-message_v2,

wtabla6-message_v3, wtabla6-message_v4,

wtabla6-parameter,wtabla6-row,wtabla6-field.

ENDLOOP.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

*EXPORTING

  • WAIT =

IMPORTING

return = wtabla6.

ENDIF.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I dont see much problem with the code except for 2 fields.

g_vakey - this shd only contain the fields that are subscribed in the condition table.

knumh_new - You will have to generate a new number everytime you want to create a condition record. you can use the FM NUMBER_GET_NEXT with Object as 'KONH' and Interval as '01'.

3 REPLIES 3

Former Member
0 Kudos

Hi,

I dont see much problem with the code except for 2 fields.

g_vakey - this shd only contain the fields that are subscribed in the condition table.

knumh_new - You will have to generate a new number everytime you want to create a condition record. you can use the FM NUMBER_GET_NEXT with Object as 'KONH' and Interval as '01'.

0 Kudos

[I dont see much problem with the code except for 2 fields.

g_vakey - this shd only contain the fields that are subscribed in the condition table.

knumh_new - You will have to generate a new number everytime you want to create a condition record. you can use the FM NUMBER_GET_NEXT with Object as 'KONH' and Interval as '01'. ]

Yes, I create g_vakey depended on the fields in the condition table and I generate knumh_new in this way:

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = '01'

object = 'KONH'

IMPORTING

number = knumh_new

EXCEPTIONS

OTHERS = 1.

0 Kudos

I have written following code in my program and its working.

The Condition table consists of following fields.

MANDT

KAPPL

KSCHL

VKORG

VTWEG

WERKS

MATNR

KFRST

DATBI

DATAB

KBSTAT

KNUMH

________________

CLEAR wa_a926.

wa_a926-vkorg = 'ZDOM'.

wa_a926-vtweg = '90'.

wa_a926-matnr = wa_ycpr-matnr.

wa_a926-werks = wa_ycpr-werks.

CLEAR wa_condct.

wa_condct-table_no = '926'.

wa_condct-cond_usage = 'A'.

wa_condct-applicatio = 'V'.

wa_condct-cond_type = 'YCPR'.

wa_condct-operation = '009'.

wa_condct-varkey = wa_a926.

wa_condct-valid_to = '99991231'.

wa_condct-valid_from = syst-datum.

wa_condct-cond_no = w_knumh.

APPEND wa_condct TO t_condct.

CLEAR wa_condhd.

wa_condhd-operation = '009'.

wa_condhd-cond_no = w_knumh.

wa_condhd-created_by = syst-uname.

wa_condhd-creat_date = syst-datum.

wa_condhd-cond_usage = 'A'.

wa_condhd-table_no = '926'.

wa_condhd-applicatio = 'V'.

wa_condhd-cond_type = 'YCPR'.

wa_condhd-varkey = wa_a926.

wa_condhd-valid_from = syst-datum.

wa_condhd-valid_to = '99991231'.

APPEND wa_condhd TO t_condhd.

CLEAR wa_condit.

w_cond_cnt = w_cond_cnt + 1.

CLEAR : wa_mtart.

READ TABLE t_mtart INTO wa_mtart

WITH KEY matnr = wa_ycpr-matnr.

wa_condit-operation = '009'.

wa_condit-cond_no = w_knumh.

wa_condit-cond_count = w_cond_cnt.

wa_condit-applicatio = 'V'.

wa_condit-cond_type = 'YCPR'.

wa_condit-scaletype = space.

wa_condit-scalebasin = 'C'.

wa_condit-scale_qty = '1'.

wa_condit-cond_p_unt = '1'.

wa_condit-cond_unit = wa_mtart-meins.

wa_condit-calctypcon = 'C'.

wa_condit-cond_value = wa_ycpr-exval.

wa_condit-condcurr = 'INR'.

APPEND wa_condit TO t_condit.

CALL FUNCTION 'BAPI_PRICES_CONDITIONS'

TABLES

ti_bapicondct = t_condct

ti_bapicondhd = t_condhd

ti_bapicondit = t_condit

ti_bapicondqs = t_condqs

ti_bapicondvs = t_condvs

to_bapiret2 = t_retcon

to_bapiknumhs = t_knumhs

to_mem_initial = t_mem

EXCEPTIONS

update_error = 1

OTHERS = 2.

IF syst-subrc IS INITIAL.

READ TABLE t_retcon INTO wa_return

WITH KEY type = 'E'.

IF NOT syst-subrc IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

ENDIF.

regards,

Mahesh