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: 

How to Use Bapi - " BAPI_PRICES_CONDITIONS "

Former Member
0 Kudos

Hi Gurus,

Can any one please let us know how we can use <b>BAPI_PRICES_CONDITIONS</b> for either creating or changing Price Conditions.

Please see my code below for creating Price condition :-

Please correct it and send me the code for both <b>changing</b> and <b>creating</b> price condition.

&----


*& Report ZAVI_BAPI_TEST

*&

&----


*&

*&

&----


REPORT zavi_bapi_test.

DATA: table1 TYPE STANDARD TABLE OF bapicondct,

table2 TYPE STANDARD TABLE OF bapicondhd,

table3 TYPE STANDARD TABLE OF bapicondit,

table4 TYPE STANDARD TABLE OF bapicondqs,

table5 TYPE STANDARD TABLE OF bapicondvs,

table6 TYPE STANDARD TABLE OF bapiret2,

table7 TYPE STANDARD TABLE OF bapiknumhs,

table8 TYPE STANDARD TABLE OF cnd_mem_initial,

ret TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.

DATA: wtable1 TYPE bapicondct,

wtable2 TYPE bapicondhd,

wtable3 TYPE bapicondit,

wtable4 TYPE bapicondqs,

wtable5 TYPE bapicondvs,

wtable6 TYPE bapiret2,

wtable7 TYPE bapiknumhs,

wtable8 TYPE cnd_mem_initial.

wtable1-table_no = '305'.

wtable1-applicatio = 'V'.

wtable1-cond_type = 'ZFOR'.

wtable1-operation = '004'.

wtable1-varkey = '13001001EUR 000000000050068946'.

*wtable1-varkey = '0001010000000017000000000000000096'.

wtable1-valid_to = '99991231'.

wtable1-valid_from = '20071017'.

wtable1-cond_no = '0000007269'.

APPEND wtable1 TO table1.

wtable2-operation = '004'.

wtable2-cond_no = '0000007269'.

wtable2-created_by = sy-uname.

wtable2-creat_date = '20071017'.

wtable2-cond_usage = 'A'.

wtable2-table_no = '305'.

wtable2-applicatio = 'V'.

wtable2-cond_type = 'ZFOR'.

wtable2-varkey = '13001001EUR 000000000050068946'.

*wtable1-varkey = '0001010000000017000000000000000096'.

wtable2-valid_from = '20071017'.

wtable2-valid_to = '99981231'.

APPEND wtable2 TO table2.

wtable3-operation = '004'.

wtable3-cond_no = '0000007269'.

wtable3-cond_count = '01'.

wtable3-applicatio = 'V'.

wtable3-cond_type = 'ZFOR'.

wtable3-scaletype = 'A'.

wtable3-scalebasin = 'C'.

wtable3-scale_qty = '1'.

wtable3-cond_p_unt = '1'.

wtable3-cond_unit = 'EA'.

wtable3-calctypcon = 'C'.

wtable3-cond_value = '444'.

wtable3-condcurr = 'EUR'.

APPEND wtable3 TO table3.

CALL FUNCTION 'BAPI_PRICES_CONDITIONS'

  • EXPORTING

  • PI_initialmode = 'X'

  • PI_BLOCKNUMBER =

TABLES

ti_bapicondct = table1

ti_bapicondhd = table2

ti_bapicondit = table3

ti_bapicondqs = table4

ti_bapicondvs = table5

to_bapiret2 = table6

to_bapiknumhs = table7

to_mem_initial = table8

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 table6 WITH KEY type = 'E' TRANSPORTING NO FIELDS.

IF sy-subrc = 0.

LOOP AT table6 INTO ret.

WRITE: / ret-type, ret-message, ret-id, ret-log_no, ret-log_msg_no,

ret-message_v1, ret-message_v2, ret-message_v3, ret-message_v4,

ret-parameter,ret-row,ret-field.

ENDLOOP.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

*EXPORTING

  • WAIT =

IMPORTING

return = ret

.

ENDIF.

3 REPLIES 3

Former Member
0 Kudos

Check below link it is same

https://www.sdn.sap.com/irj/sdn/forums

Former Member
0 Kudos

Please refer to this code.....

wtable1-table_no = '306'.

wtable1-applicatio = 'V'.

wtable1-cond_type = 'ZPR0'.

wtable1-operation = '009'.

wtable1-varkey = '13001001USD 000000000050068946'.

wtable1-valid_to = '99991231'.

wtable1-valid_from = '20051101'.

wtable1-cond_no = '$000000001'.

APPEND wtable1 TO table1.

wtable2-operation = '009'.

wtable2-cond_no = '$000000001'.

wtable2-created_by = sy-uname.

wtable2-creat_date = '20051022'.

wtable2-cond_usage = 'A'.

wtable2-table_no = '110'.

wtable2-applicatio = 'V'.

wtable2-cond_type = 'ZPR0'.

wtable2-varkey = '13001001USD 000000000050068946'.

wtable2-valid_from = '20051101'.

wtable2-valid_to = '99991231'.

APPEND wtable2 TO table2.

wtable3-operation = '009'.

wtable3-cond_no = '$000000001'.

wtable3-cond_count = '01'.

wtable3-applicatio = 'V'.

wtable3-cond_type = 'ZPR0'.

wtable3-scaletype = 'A'.

wtable3-scalebasin = 'C'.

wtable3-scale_qty = '1'.

wtable3-cond_p_unt = '1'.

wtable3-cond_unit = 'EA'.

wtable3-calctypcon = 'C'.

wtable3-cond_value = '454'.

wtable3-condcurr = 'USD'.

APPEND wtable3 TO table3.

CALL FUNCTION 'BAPI_PRICES_CONDITIONS'

  • EXPORTING

  • PI_initialmode = 'X'

  • PI_BLOCKNUMBER =

TABLES

ti_bapicondct = table1

ti_bapicondhd = table2

ti_bapicondit = table3

ti_bapicondqs = table4

ti_bapicondvs = table5

to_bapiret2 = table6

to_bapiknumhs = table7

to_mem_initial = table8

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 table6 WITH KEY type = 'E' TRANSPORTING NO FIELDS.

IF sy-subrc = 0.

loop at table6 into ret.

write: / ret-type, ret-message, ret-id, RET-LOG_NO, RET-LOG_MSG_NO,

RET-MESSAGE_V1, RET-MESSAGE_V2, RET-MESSAGE_V3, RET-MESSAGE_V4,

RET-PARAMETER,RET-ROW,RET-FIELD.

endloop.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

*EXPORTING

  • WAIT =

IMPORTING

return = ret

.

ENDIF.

****************************************************************

Former Member
0 Kudos

Hi,

Check these threads which contain sample code . This will give you an idea.

Hope this helps.

ashish