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: 

Problem with Multiple record creation using BAPI BAPI_PRICES_CONDITION

Former Member
0 Kudos

Hi,

I am working on IS Media Sales And Distribution wherein i am using BAPI BAPI_PRICES_CONDITION for condition record creation in TCODE JC9B. I am able to create one record using this BAPI for one sales promotion but having problem while creation of multiple records for the same sales promotion wherein my internal table have multiple records. It gives me error that data in BAPICONDIT is missing.

I am aatching followig code for reference

BAPI have field of varkey which i am filling as combination of sales org. + distn channel + sales promotion + delivery type

In this varkey delivery type is changing for sales promotion Can be said that one sales promotion can have multiple delivery type .

Am i giving the correct varkey for each itration of internal table ?

I am attaching code for reference.

Here loop it_cond contain one promotion and multiple delivery type.

sales org distn ch promotion delivery

0100 01 zsalesprom 03

0100 01 zsalesprom z3

LOOP AT it_cond INTO wa_cond.

  • Get next condition number

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = '01'

object = 'KONH'

  • QUANTITY = '1'

  • SUBOBJECT = ' '

  • TOYEAR = '0000'

  • IGNORE_BUFFER = ' '

IMPORTING

number = number

  • QUANTITY =

  • RETURNCODE =

  • EXCEPTIONS

  • INTERVAL_NOT_FOUND = 1

  • NUMBER_RANGE_NOT_INTERN = 2

  • OBJECT_NOT_FOUND = 3

  • QUANTITY_IS_0 = 4

  • QUANTITY_IS_NOT_1 = 5

  • INTERVAL_OVERFLOW = 6

  • BUFFER_OVERFLOW = 7

  • OTHERS = 8

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Here i am concacating varkey for each new delivery

CLEAR : l_min,l_length,l_var.

CONCATENATE wa_cond-vkorg wa_cond-vtweg wa_cond-wrbakt INTO l_var.

l_length = STRLEN( l_var ).

IF l_var+14(2) IS INITIAL.

WRITE wa_cond-lifart TO L_VAR+14.

l_length = STRLEN( l_var ).

ENDIF.

W_LINE = W_LINE + 1.

*First table in BAPI

wa_bapicondct-operation = '009'.

wa_bapicondct-cond_usage = 'A'.

wa_bapicondct-table_no = '506'.

wa_bapicondct-applicatio = 'J0'.

wa_bapicondct-cond_type = 'RATE'.

wa_bapicondct-varkey = l_var.

wa_bapicondct-valid_to = wa_cond-datbi.

wa_bapicondct-valid_from = wa_cond-datab.

wa_bapicondct-cond_no = number. "

APPEND wa_bapicondct TO it_bapicondct.

*Second table in BAPI

wa_bapicondhd-operation = '009'.

wa_bapicondhd-cond_no = number.

wa_bapicondhd-cond_usage = 'A'.

wa_bapicondhd-table_no = '506'.

  • wa_bapicondhd-created_by = sy-uname.

  • wa_bapicondhd-creat_date = sy-datum.

wa_bapicondhd-applicatio = 'J0'.

wa_bapicondhd-cond_type = 'RATE'.

wa_bapicondhd-varkey = l_var.

wa_bapicondhd-valid_from = wa_cond-datab.

wa_bapicondhd-valid_to = wa_cond-datbi.

APPEND wa_bapicondhd TO it_bapicondhd.

*Third table in BAPI

wa_bapicondit-operation = '009'.

wa_bapicondit-cond_no = number.

wa_bapicondit-cond_count = wa_cond-cond_count.

wa_bapicondit-applicatio = 'J0'.

wa_bapicondit-cond_type = 'RATE'.

wa_bapicondit-calctypcon = 'C'.

  • wa_bapicondit-scaletype = 'A'.

wa_bapicondit-cond_value = wa_cond-kbetr.

wa_bapicondit-condcurr = wa_cond-konwa.

wa_bapicondit-promotion = wa_cond-wrbakt.

APPEND wa_bapicondit TO it_bapicondit.

*Fourth table in BAPI

wa_bapicondqs-operation = '009'.

wa_bapicondqs-cond_no = number.

wa_bapicondqs-cond_count = wa_cond-cond_count.

wa_bapicondqs-currency = wa_cond-kbetr.

wa_bapicondqs-condcurr = wa_cond-konwa.

  • wa_bapicondqs-cond_unit = 'EA'.

wa_bapicondqs-LINE_NO = W_LINE."'0001'.

APPEND wa_bapicondqs TO it_bapicondqs.

*Fifth table in BAPI

wa_bapicondvs-operation = '009'.

wa_bapicondvs-cond_no = number.

wa_bapicondvs-cond_count = wa_cond-cond_count.

wa_bapicondvs-currenckey = wa_cond-konwa.

wa_bapicondvs-currenciso = wa_cond-konwa.

  • wa_bapicondvs-currency = wa_cond-kbetr.

  • wa_bapicondvs-condcurr = wa_cond-konwa.

    • wa_bapicondvs-curren_iso = wa_cond-konwa.

  • wa_bapicondvs-LINE_NO = W_LINE."'0001'.

APPEND wa_bapicondvs TO it_bapicondvs.

CALL FUNCTION 'BAPI_PRICES_CONDITIONS'

  • EXPORTING

  • PI_INITIALMODE = ' '

  • PI_BLOCKNUMBER =

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_cnd_mem_initial

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.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

  • IMPORTING

  • RETURN =

.

CLEAR : wa_bapicondct,wa_bapicondhd,wa_bapicondvs,wa_bapicondqs.

CLEAR : wa_bapicondit.

ENDLOOP.

ENDIF.

ENDIF.

Kindly Suggest.

Thanks

Parag

1 REPLY 1

Former Member
0 Kudos

Solved By myself

There is problem while passing data to internal table for item level