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: 

inserting Condition price using BAPI_SALESORDER_CHANGE

Former Member
0 Kudos

Hi all,

I have been asked to develop a ZVa02 transaction. For that, I want to insert condition price using the BAPI_SALESORDER_CHANGE.

Please let me know, what are all the inputs I need to give.

Thanks,

Rajan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

The following is working code for updating pricing conditions.

U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.

U can find these parameters for a particular condition type in table KONV.

&----


*& Form saveTransactionJOCR

&----


text

-


--> p1 text

<-- p2 text

-


FORM saveTransactionJOCR .

data: salesdocument like BAPIVBELN-VBELN,

order_header_inx like bapisdh1x,

order_header_in like bapisdh1,

return type standard table of bapiret2 with header line,

conditions_in type standard table of bapicond with header line,

conditions_inx type standard table of bapicondx with header line,

logic_switch like BAPISDLS,

step_nr like conditions_in-cond_st_no,

item_nr like conditions_in-itm_number,

cond_count like conditions_in-cond_count,

cond_type like conditions_in-cond_type.

salesdocument = wa_order_information-VBELN.

LOGIC_SWITCH-COND_HANDL = 'X'.

order_header_inx-updateflag = 'U'.

conditions

clear conditions_in[].

clear conditions_inx[].

clear: step_nr,

item_nr,

cond_count,

cond_type.

step_nr = '710'.

item_nr = '000000'.

cond_count = '01'.

cond_type = 'ZCP2'.

CONDITIONS_IN-ITM_NUMBER = item_nr.

conditions_in-cond_st_no = step_nr.

CONDITIONS_IN-COND_COUNT = cond_count.

CONDITIONS_IN-COND_TYPE = cond_type.

CONDITIONS_IN-COND_VALUE = 666.

CONDITIONS_IN-CURRENCY = 'EUR'.

append conditions_in.

CONDITIONS_INX-ITM_NUMBER = item_nr.

conditions_inx-cond_st_no = step_nr.

CONDITIONS_INX-COND_COUNT = cond_count.

CONDITIONS_INX-COND_TYPE = cond_type.

CONDITIONS_INX-UPDATEFLAG = 'U'.

CONDITIONS_INX-COND_VALUE = 'X'.

CONDITIONS_INX-CURRENCY = 'X'.

append conditions_inx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = salesdocument

ORDER_HEADER_IN = order_header_in

ORDER_HEADER_INX = order_header_inx

LOGIC_SWITCH = logic_switch

TABLES

RETURN = return

CONDITIONS_IN = conditions_in

CONDITIONS_INX = conditions_inx

.

if return-type ne 'E'.

commit work and wait.

endif.

ENDFORM. " saveTransactionJOCR

I hope this works for u too.

Thanks,

Asit Purbey.

Edited by: Asit Purbey on Mar 9, 2009 6:34 AM

2 REPLIES 2

Former Member
0 Kudos

hi,

check below sample code, very important here is to set variable

LOGIC_SWITCH-COND_HANDL = 'X'.

regards, darek


  REFRESH: order_conditions_in, order_conditions_inx, order_items_in.
  DATA: pos_main LIKE vbap OCCURS 0 WITH HEADER LINE,
        pos_sub  LIKE vbap OCCURS 0 WITH HEADER LINE,
        zzkonv   LIKE konv OCCURS 0 WITH HEADER LINE,
        zzvbak   LIKE vbak.

  SELECT SINGLE * FROM vbak INTO zzvbak WHERE vbeln EQ salesdocument.
  CHECK sy-subrc EQ 0.

  SELECT * FROM vbap INTO TABLE pos_main WHERE vbeln EQ salesdocument.
  CHECK sy-subrc EQ 0.

  SELECT * FROM konv INTO TABLE zzkonv WHERE knumv EQ zzvbak-knumv.
  CHECK sy-subrc EQ 0.

  pos_sub[] = pos_main[].
  LOOP AT pos_main.
    CHECK not pos_main-posex is initial.
    read table order2_conditions_in
        with key itm_number = pos_main-posnr.
    CHECK sy-subrc EQ 0.
    order_conditions_in = order2_conditions_in.
    LOOP AT pos_sub WHERE uepos = pos_main-posnr.
      order_conditions_in-itm_number = pos_sub-posnr.
      MOVE-CORRESPONDING order_conditions_in TO order_conditions_inx.
      LOOP AT zzkonv WHERE
          kposn = pos_sub-posnr AND
          kschl = order_conditions_in-cond_type.
      ENDLOOP.
      IF sy-subrc EQ 0.
        order_conditions_in-COND_ST_NO  = zzkonv-stunr.
        order_conditions_in-COND_COUNT  = zzkonv-zaehk.
        MOVE-CORRESPONDING order_conditions_in TO order_conditions_inx.

        order_conditions_in-CONDORIGIN  = 'C'.
        order_conditions_in-cond_no     = zzkonv-knumh.
        order_conditions_in-COND_UPDAT  = 'X'.
        CLEAR: order_conditions_in-CURRENCY.
        APPEND order_conditions_in.

        order_conditions_inx-UPDATEFLAG = 'U'.
        order_conditions_inx-COND_VALUE = 'X'.
        order_conditions_inx-COND_P_UNT = ''.
        APPEND order_conditions_inx.
      ELSE.
        order_conditions_inx-UPDATEFLAG = 'I'.
        CLEAR: order_conditions_in-CURRENCY,
               order_conditions_in-COND_COUNT.
        APPEND order_conditions_in.
        APPEND order_conditions_inx.
      ENDIF.
    ENDLOOP.
  ENDLOOP.

  DATA: LOGIC_SWITCH LIKE  BAPISDLS.
  LOGIC_SWITCH-COND_HANDL = 'X'.
  order_header_inx-updateflag = 'U'.
  CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
      salesdocument    = salesdocument
      order_header_inx = order_header_inx
      LOGIC_SWITCH     = LOGIC_SWITCH
    TABLES
      return           = return
      conditions_in    = order_conditions_in
      conditions_inx   = order_conditions_inx.

Former Member
0 Kudos

Hi,

The following is working code for updating pricing conditions.

U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.

U can find these parameters for a particular condition type in table KONV.

&----


*& Form saveTransactionJOCR

&----


text

-


--> p1 text

<-- p2 text

-


FORM saveTransactionJOCR .

data: salesdocument like BAPIVBELN-VBELN,

order_header_inx like bapisdh1x,

order_header_in like bapisdh1,

return type standard table of bapiret2 with header line,

conditions_in type standard table of bapicond with header line,

conditions_inx type standard table of bapicondx with header line,

logic_switch like BAPISDLS,

step_nr like conditions_in-cond_st_no,

item_nr like conditions_in-itm_number,

cond_count like conditions_in-cond_count,

cond_type like conditions_in-cond_type.

salesdocument = wa_order_information-VBELN.

LOGIC_SWITCH-COND_HANDL = 'X'.

order_header_inx-updateflag = 'U'.

conditions

clear conditions_in[].

clear conditions_inx[].

clear: step_nr,

item_nr,

cond_count,

cond_type.

step_nr = '710'.

item_nr = '000000'.

cond_count = '01'.

cond_type = 'ZCP2'.

CONDITIONS_IN-ITM_NUMBER = item_nr.

conditions_in-cond_st_no = step_nr.

CONDITIONS_IN-COND_COUNT = cond_count.

CONDITIONS_IN-COND_TYPE = cond_type.

CONDITIONS_IN-COND_VALUE = 666.

CONDITIONS_IN-CURRENCY = 'EUR'.

append conditions_in.

CONDITIONS_INX-ITM_NUMBER = item_nr.

conditions_inx-cond_st_no = step_nr.

CONDITIONS_INX-COND_COUNT = cond_count.

CONDITIONS_INX-COND_TYPE = cond_type.

CONDITIONS_INX-UPDATEFLAG = 'U'.

CONDITIONS_INX-COND_VALUE = 'X'.

CONDITIONS_INX-CURRENCY = 'X'.

append conditions_inx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = salesdocument

ORDER_HEADER_IN = order_header_in

ORDER_HEADER_INX = order_header_inx

LOGIC_SWITCH = logic_switch

TABLES

RETURN = return

CONDITIONS_IN = conditions_in

CONDITIONS_INX = conditions_inx

.

if return-type ne 'E'.

commit work and wait.

endif.

ENDFORM. " saveTransactionJOCR

I hope this works for u too.

Thanks,

Asit Purbey.

Edited by: Asit Purbey on Mar 9, 2009 6:34 AM