Problem using Bapi_Salesorder_Change (VBAP-ABGRU)
Hello Guys,
I currently encounter a big issue using BAPI "Bapi_Salesorder_Change " in order to replace the value stored in field VBAP-ABGRU (from 01 to blank). The system does not make any change even if call function 'BAPI_TRANSACTION_COMMIT' is called.
Kind regards
Chris
Hi,
Please set: header_inx-updateflag = 'U' and
header_inx-ord_reason = 'X'.
Try with this code.
PARAMETERS:
p_or_res TYPE augru.
DATA : st_order_header_in TYPE bapisdh1.
DATA : st_order_header_inx TYPE bapisdh1x.
CLEAR st_order_header_in.
st_order_header_in-ord_reason = p_or_res.
CLEAR st_order_header_inx.
st_order_header_inx-updateflag = 'U'.
st_order_header_inx-ord_reason = 'X'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = vbeln
order_header_in = st_order_header_in
order_header_inx = st_order_header_inx.
Regards,
Neenu Jose.
Similar Messages
-
Problem using BAPI_SALESORDER_CHANGE
Hi Experts,
I am inserting the Item in Sales order by using BAPI_SALESORDER_CHANGE.
suppose there are 2 line item in sales i.e. 10 and 20 .
now i want to insert line item i.e. 30.
now the problem is that when i am trying to insert line item 30 it is getting inserted.
but i want to update the quantity for line item 30.
how to update the quantity of line item 30?
anybody have the solution?
Thanks in advance.
AbhishekHi,
Fill tables parameter ORDER_ITEM_IN and ORDER_ITEM_INX for the line item you want to update the quantity for the field would be TARGET_QTY and TARGET_QU
and in the ORDER_ITEM_INX have ITM_NUMBER = '30 the update indicator equal to 'X' and TARGET_QTY = 'X'and TARGET_QU eq 'X' and that should do it.
Regards,
Himanshu -
Delete pricing conditions line using BAPI_SALESORDER_CHANGE
Hi experts.
I've read the forum and OSS about this topic and don't have clear if it's possible to delete a price condition position (using BAPI). Using tx. VA02 I can delete pricing conditions, that's why I think should be possible.
We have a sales order created, and depending on the sold-to-party we have some discounts: RA00 (% discount) or RB00 (absolute discounts).
In some cases we need to insert/update or delete these pricing conditions. For insert/update, we don't have any problem using
BAPI_SALESORDER_CHANGE and setting the appropiate updateflag.
But... what would be the procedure to delete a discount, for example, RA00 fixed on a sales order? Has the logic_switch be informed specially?
wa_cond-itm_number = lt_cond-itm_number.
wa_cond-cond_type = lt_cond-cond_type.
APPEND wa_cond TO i_cond.
wa_condx-itm_number = lt_cond-itm_number.
wa_condx-cond_type = lt_cond-cond_type.
wa_condx-updateflag = 'D'.
APPEND wa_condx TO i_condx.
Lots of thanks.
JavierI am not positive on being able to delete a pricing condition through program.
Online when you try to change the pricing, SAP suggests us to redetermines the Pricing rather than just changing the values. And also the pricing condition config also plays a role... I think there was a setting which says Pricing condition to be manual which means you can add or delete the conditoin. -
Problem in updating Quantity using 'BAPI_SALESORDER_CHANGE'
Hi,
I am using Bapi_salesorder_change to update item quantity and reason for rejection.My code is as below.
MOVE c_u TO e_orderheader_inx-updateflag.
FREE i_orderitem_in.
MOVE newitem-posnr_ref TO e_orderitem_in-itm_number.
MOVE c_rej TO e_orderitem_in-reason_rej.
MOVE c_qt TO e_orderitem_in-target_qty.
APPEND e_orderitem_in TO i_orderitem_in.
FREE i_orderitem_inx.
MOVE newitem-posnr_ref TO e_orderitem_inx-itm_number .
MOVE c_u TO e_orderitem_inx-updateflag.
MOVE c_x TO e_orderitem_inx-reason_rej.
MOVE c_x TO e_orderitem_inx-target_qty .
APPEND e_orderitem_inx TO i_orderitem_inx.
FREE i_return.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = xvbak-vbeln
ORDER_HEADER_IN =
order_header_inx = e_orderheader_inx
TABLES
return = i_zbapiret2
order_item_in = i_orderitem_in
order_item_inx = i_orderitem_inx.
But in 'i_zbapiret2' iam getting the below errors.
1)Storage location BH in plant is not defined .
2) Error in ITEM_IN 000020
3) sales documnet 000078965 was not changed.
PLease help me to solve this problem.
Thanks in advance,
Sravanthi.Hi,
From the error message it seems that you dont have the storage location for the plant as you have passed to the BAPI check table 'T001L' to see if that storage location is there for the plant. If not then we need to maintain that.
Regards,
Himanshu -
Problem in using BAPI_SALESORDER_CHANGE
Hi,
We are using BAPI_SALESORDER_CHANGE for updating the delivery block information present in Shipping tab of sales order header.
We are updating the below parameters and then calling the bapi.
ls_header-DLV_BLOCK = 'Z1'.
ls_head_update-updateflag = 'U'.
ls_head_update-DLV_BLOCK = 'X'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = gs_vbak-vbeln
ORDER_HEADER_IN = ls_header
ORDER_HEADER_INX = ls_head_update
behave_when_error = ' '
int_number_assignment = ' '
TABLES
RETURN = lt_return.
But during execution we could see the messages in parameter return as below
ORDER_HEADER_IN has been processed successfully
No data was changed
But we want to update the delivery block with Z1 which is not happening.
Please let us know if we missed anything.
Thanks in advance,
PoornimaHI,
Check the tcode VA03 with the sales ordernumber before changing and after changing the sales order with delivery block.
Refer to this link..
BAPI_SALESORDER_CHANGE -
Problem in adding "Reason for Rejection" using BAPI_SALESORDER_CHANGE
Hi all,
I have a requirement to stop further processing of sales order by changing the reason for rejection at line item. I have done the code and passed the reason code in the item table to BAPI. The return message says the sales order ammended successsfully, but when i go and see the sales order I dont see it getting updated. when i go to check the order its throwing an error message "Update was terminated" Could some one please help in getting this solved.
The code is shown below
Populate the headerX details
it_bapisdh1x-updateflag = 'U'.
it_bapisdh1x-sales_org = 'X'.
it_bapisdh1x-distr_chan = 'X'.
it_bapisdh1x-division = 'X'.
it_bapisdh1x-purch_no_c = 'X'.
it_bapisdh1x-cust_group = 'X'.
Populate the header details
it_bapisdh1-sales_org = '1298'.
it_bapisdh1-distr_chan = '95'.
it_bapisdh1-division = '00'.
it_bapisdh1-purch_no_c = 'Test1'.
Partner Roles
it_bapiparnr-partn_role = 'AG'.
it_bapiparnr-partn_numb = '9820000049'.
it_bapiparnr-itm_number = '00000'.
APPEND it_bapiparnr.
it_bapiparnr-partn_role = 'WE'.
it_bapiparnr-partn_numb = '9820000049'.
it_bapiparnr-itm_number = '000000'.
APPEND it_bapiparnr.
it_bapisditmx-itm_number = '00010'.
it_bapisditmx-updateflag = 'U'.
it_bapisditmx-material = 'X'.
it_bapisditmx-cust_group = 'X'.
it_bapisditmx-reason_rej = 'X'.
APPEND it_bapisditmx.
it_bapisditm-itm_number = '00010'.
it_bapisditm-material = 'YAG'.
it_bapisditm-reason_rej = '01'.
APPEND it_bapisditm.
BREAK-POINT.
salesd = '4000004045'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = salesd
order_header_in = it_bapisdh1
order_header_inx = it_bapisdh1x
behave_when_error = ' '
int_number_assignment = ' '
TABLES
order_item_in = it_bapisditm
order_item_inx = it_bapisditmx
partners = it_bapiparnr
return = it_bapiret2.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
endif.When using BAPI_SALESORDER_CHANGE, you set the fields your are updating to 'X'. In the example you gave, you are trying to change the header data, material number, etc.
Try slimming it down to:
Populate the headerX details
it_bapisdh1x-updateflag = 'U'.
it_bapisditmx-itm_number = '00010'.
it_bapisditmx-updateflag = 'U'.
it_bapisditmx-reason_rej = 'X'.
APPEND it_bapisditmx.
it_bapisditm-itm_number = '00010'.
it_bapisditm-reason_rej = '01'.
APPEND it_bapisditm.
BREAK-POINT.
salesd = '4000004045'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = salesd
order_header_in = it_bapisdh1
order_header_inx = it_bapisdh1x
behave_when_error = ' '
int_number_assignment = ' '
TABLES
order_item_in = it_bapisditm
order_item_inx = it_bapisditmx
return = it_bapiret2.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
endif.
I hope this helps,
Mark -
Problem with updating pricing date using BAPI_SALESORDER_CHANGE
Hi,
I need to update pricing date on sales order (but only on item level).
I have been trying to use BAPI_SALESORDER_CHANGE but nothing changes.Bapi returns no errors, ends with success.
I hoped that bapi would change not only pricing date but also recalculate things the date affected.
Here is my code:
ls_head_inx-updateflag = 'U'.
ls_bapisdls-pricing = 'C'.
ls_item-itm_number = sales_order_posnr
ls_item-price_date = new_price_date
APPEND ls_item TO lt_item.
ls_item_inx-itm_number = sales_order_posnr
ls_item_inx-updateflag = 'U'.
ls_item_inx-price_date = 'X'.
APPEND ls_item_inx TO lt_item_inx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = sales_order
order_header_inx = ls_head_inx
logic_switch = ls_bapisdls
TABLES
return = lt_return
order_item_in = lt_item
order_item_inx = lt_item_inx
Thanks & Regards,
MarioMario,
I run same code as yours and work for me fine, able to update ITEM pricing date.
I suppose you are using BAPI_TRANSACTION_COMMIT after your BAPI call, then only it will work.
Also note that VBKD table stores this date for header and item. In my system, there are generally only header rows in that table, but a new item row gets generated when I change the item date with the BAPI to some other date. Also, this BAPI sometimes issues a W message instead of ERROR for something like non-existing items, so carefully check your RETURN table too.
'Item 000002 does not exist' as WARNING message, so might be considering it as a success.
If nothing works, try to do the same thing for the same data using VA02 and check . If that works, BAPI will work surely.
Regards,
Diwakar -
To delete sales order using BAPI_SALESORDER_CHANGE
HI ,
I am using BAPI_SALESORDER_CHANGE to delete a bulk of order lines for an order.But the issue is...the entries are deleted in VBEP and VBUP tables for all the order lines where in VBAP only few order lines are deleted.This is happening repeatedly.
I am passing data like this...
CLEAR: l_vbap_inx.
l_vbap_inx-itm_number = t_vbap-posnr. " will have value
l_vbap_inx-updateflag = 'D'.
APPEND l_vbap_inx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = i_vbeln "will have order number
order_header_inx = l_vbak_inx " will be paased with values 'U'
order_header_in = header "will not hold any value
simulation = i_simulate "space
TABLES
return = l_return
order_item_in = l_vbap "bulk of order lines with 'D' flag
order_item_inx = l_vbap_inx
extensionin = l_vbap_ext.
can you please suggest on this......
Thanks in advance.HI ,
Can any one of you please suggest me to amend the below given code which is used to delete bulk of order lines from VBAP table.presently it is deleting first few order lines from VBAP and all order lines from VBEP and VBUP tables.when i execute the same program for second time first left out order lines are getting deleted again.So..can any one please check the below code and suggest me something on this.
REFRESH: l_return, l_vbap, l_vbap_inx, l_vbap_ext.
IF xorder_delete = 'X'.
l_vbak_inx-updateflag = 'D'.
Even though all the order lines are to be deleted, the delete complete
order flag says don't delete the header data
IF i_cleanup = space.
l_vbak_inx-updateflag = 'U'.
PERFORM validate_line_count TABLES l_vbap_ext "iw150709
USING i_vbeln. "iw150709
ENDIF.
ELSE.
l_vbak_inx-updateflag = 'U'.
PERFORM validate_line_count TABLES l_vbap_ext "iw150709
USING i_vbeln. "iw150709
ENDIF.
LOOP AT t_vbap WHERE delete = 'X'.
CLEAR: l_vbap.
l_vbap-itm_number = t_vbap-posnr.
APPEND l_vbap.
CLEAR: l_vbap_inx.
l_vbap_inx-itm_number = t_vbap-posnr.
l_vbap_inx-updateflag = 'D'.
APPEND l_vbap_inx.
CLEAR: l_vbap_ext, l_extension_vbapx.
l_vbap_ext-structure = 'BAPE_VBAPX'.
l_extension_vbapx-vbeln = i_vbeln.
l_extension_vbapx-posnr = t_vbap-posnr.
l_extension_vbapx-zzco_reason = 'X'.
l_vbap_ext+30 = l_extension_vbapx.
APPEND l_vbap_ext.
CLEAR: l_vbap_ext, l_extension_vbap.
l_vbap_ext-structure = 'BAPE_VBAP'.
l_extension_vbap-vbeln = i_vbeln.
l_extension_vbap-posnr = t_vbap-posnr.
l_extension_vbap-zzco_reason = i_reason.
l_vbap_ext+30 = l_extension_vbap.
APPEND l_vbap_ext.
ENDLOOP.
Only call BAPI if NOT in test mode.
IF i_simulate = space.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = i_vbeln
order_header_inx = l_vbak_inx
order_header_in = header
simulation = i_simulate
TABLES
return = l_return
order_item_in = l_vbap
order_item_inx = l_vbap_inx
extensionin = l_vbap_ext.
ENDIF.
LOOP AT l_return WHERE type = 'E' OR type = 'A'.
MOVE-CORRESPONDING l_return TO t_messages.
t_messages-field = 'VBELN'.
APPEND t_messages.
ENDLOOP.
No ERRORs
IF sy-subrc <> 0.
IF i_simulate = space.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
IMPORTING
return = l_return.
Edited by: manj1325 on Apr 9, 2010 8:19 AM -
Using Bapi_salesorder_change adding a item, deleting a item,Quanty change
I need help on Bapi_salesorder_change.
I have a table control in which there will be data of a particular sales document no, items, quantity, sales unit. When user changes the quantity, or adds a line item or deletes a line item and the press the save button bapi_salesorder_change should trigger and should change the order as the user changes.
Can u help how to write code for this three conditions
1> adding line item.
2> deleting a line item.
3> changing the quantity.
using bapi_salesorder_change
Can i use the same bapi for three conditions?
Please help me in this as soon as possible.
I thank them in advanceHello Geeks,
i am using this bapi for updating my item quantity no....
but the bapi return msg say tat its not changing....
i think i may did some mistake pls anyone can rectify it....
i hv attached my code below......
*For line item
TYPES :BEGIN OF y_t_vbap,
vbeln TYPE vbeln_va, "sales Document
posnr TYPE posnr_va, "Item no of SD document
matnr TYPE matnr, "Material No
zmeng TYPE dzmeng , "Target qty in Sales unit
spart TYPE spart, "division
message TYPE BAPI_MSG,
kwmeng type kwmeng, "cummulative order qty
END OF y_t_vbap.
TYPES : y_t_itemin TYPE bapisditm,
y_t_return TYPE bapiret2,
y_t_headerx TYPE bapisdh1x.
TYPES: BEGIN OF y_t_logdata,
lno TYPE lineno, "Lineno
field TYPE fieldname, "Field Name
value TYPE lmon_fvalue, "Field Value
message TYPE bapi_msg, "Messages
END OF y_t_logdata.
Internal table declaration
DATA: "y_i_vbak TYPE STANDARD TABLE OF y_t_vbak,
y_i_vbap TYPE STANDARD TABLE OF y_t_vbap,
y_i_headerx TYPE STANDARD TABLE OF bapisdh1x,
y_i_itemin TYPE STANDARD TABLE OF bapisditm ,
y_i_iteminx TYPE STANDARD TABLE OF bapisditmx,
y_i_return TYPE STANDARD TABLE OF y_t_return,
y_i_logdata TYPE STANDARD TABLE OF y_t_logdata,
y_i_bapiret TYPE STANDARD TABLE OF bapiret2.
Table type declaration
TYPES: y_tt_vbap TYPE STANDARD TABLE OF y_t_vbap ,
y_tt_logdata TYPE STANDARD TABLE OF y_t_logdata.
Work Area declaration.
DATA: y_wa_vbap TYPE y_t_vbap,
y_wa_itemin TYPE bapisditm ,
y_wa_iteminx TYPE bapisditmx,
y_wa_headerx TYPE bapisdh1x,
y_wa_return TYPE y_t_return,
y_wa_logdata TYPE y_t_logdata,
y_wa_event TYPE slis_alv_event,
y_wa_event1 TYPE slis_t_event,
y_wa_bapiret TYPE bapiret2.
Variables declaration.
DATA: y_i_event TYPE slis_t_event,
y_v_success TYPE i , "For Success
y_v_error TYPE i , "For Error
y_v_sno TYPE char30 ,
y_v_eno TYPE char30 ,
y_v_msg TYPE char100 . "error msg
Constants declaration.
constants : y_k_x type char1 value 'X',
y_k_u type char1 value 'U',
y_k_e type char1 value 'E'.
SELECTION SCREEN LAYOUT
SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN: COMMENT 3(18) text-003.
PARAMETERS : y_p_vbln TYPE vbak-vbeln OBLIGATORY.
SELECTION-SCREEN: END OF LINE.
SELECTION-SCREEN : END OF BLOCK b1.
START-OF-SELECTION.
START-OF-SELECTION.
WRITE: text-002.
END-OF-SELECTION.
END-OF-SELECTION.
SELECT vbeln
posnr
matnr
zmeng
spart
FROM vbap
INTO TABLE y_i_vbap
WHERE vbeln = y_p_vbln.
LOOP AT y_i_vbap INTO y_wa_vbap.
y_wa_vbap-zmeng = 2 + y_wa_vbap-zmeng.
MODIFY y_i_vbap FROM y_wa_vbap INDEX sy-tabix.
ENDLOOP.
PERFORM y_f_update USING y_i_vbap.
*& Form y_f_update
POPULATE BAPI DATA AND RUN BAPI
FORM y_f_update USING y_p_vbap TYPE y_tt_vbap.
CLEAR: y_i_headerx, y_i_itemin, y_i_iteminx,
y_i_return, y_i_bapiret.
REFRESH: y_i_itemin, y_i_iteminx, y_i_return, y_i_bapiret.
LOOP AT y_i_vbap INTO y_wa_vbap.
MOVE y_wa_vbap-zmeng TO y_wa_itemin-target_qty.
MOVE y_wa_vbap-posnr TO y_wa_itemin-itm_number.
APPEND y_wa_itemin TO y_i_itemin.
ENDLOOP.
*Update the Bapi Itnernal tables
y_wa_headerx-updateflag = y_k_u .
APPEND y_wa_headerx TO y_i_headerx.
LOOP AT y_i_vbap INTO y_wa_vbap.
y_wa_iteminx-itm_number = y_wa_vbap-posnr.
y_wa_iteminx-target_qty = y_k_x .
y_wa_iteminx-updateflag = y_k_u .
APPEND y_wa_iteminx TO y_i_iteminx .
ENDLOOP .
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = y_wa_vbap-vbeln
order_header_inx = y_wa_headerx
TABLES
return = y_i_return
order_item_in = y_i_itemin
order_item_inx = y_i_iteminx.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CLEAR y_i_vbap.
IF y_i_return is not initial.
LOOP AT y_i_return INTO y_wa_return where TYPE = y_k_e .
MOVE y_wa_return-message TO y_wa_vbap-message .
Append y_wa_vbap to y_i_vbap.
y_v_success = y_v_success + 1.
ENDLOOP.
ENDIF.
y_wa_event-name = 'TOP_OF_PAGE'.
y_wa_event-form = 'Y_FD_TOP_OF_LIST'.
APPEND y_wa_event TO y_i_event.
CLEAR y_wa_event.
CALL FUNCTION 'ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_tabtypename1 = 'Y_T_VBAP'
it_events1 = y_i_event[]
TABLES
t_outtab1 = y_i_vbap[]
EXCEPTIONS
program_error = 1
maximum_of_appends_reached = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " y_f_vbap
*& Form Y_FD_TOP_OF_LIST
FORM y_fd_top_of_list.
MOVE: y_v_success TO y_v_sno,
y_v_error TO y_v_eno.
CONCATENATE text-002 y_v_sno '/' y_v_eno INTO y_v_msg SEPARATED BY
space.
CONDENSE y_v_msg.
WRITE / y_v_msg .
SKIP 1.
ENDFORM. "Y_FD_TOP_OF_LIST -
Dear all.
I need to put some value in the field ABGRU. When the configuration of the Item is not completed. I'm try to used the program MV45AFZZ and the exit FORM USEREXIT_SAVE_DOCUMENT and USEREXIT_MOVE_FIELD_TO_VBAP.
But i cant update the field. A Example off my code:
Case VBAK-AUART.
WHEN 'ZXXX'.
IF vbap-PSTYV eq 'ZYYY' and vbap-kondm eq '02' and
vbap-stman eq '1'.
move 'Z1' to vbap-abgru.
modify vbap.
ELSEIF vbap-PSTYV eq 'ZYYY' and vbap-kondm NE '02' and vbap-stman NE '1' and vbap-abgru EQ 'Z1'.
move '' to vbap-abgru.
modify vbap.
ENDIF.
ENDCASE.Hi Pedro
Stop! Your code is wrong: YOU CAN'T DIRECTLY UPDATE VBAP TABLE:
Case VBAK-AUART.
WHEN 'ZXXX'.
IF vbap-PSTYV eq 'ZYYY' and vbap-kondm eq '02' and
vbap-stman eq '1'.
move 'Z1' to vbap-abgru.
modify vbap. <----
ERROR
ELSEIF vbap-PSTYV eq 'ZYYY' and vbap-kondm NE '02' and vbap-stman NE '1' and vbap-abgru EQ 'Z1'.
move '' to vbap-abgru.
modify vbap. <----
ERROR
ENDIF.
ENDCASE.
If you use the routine USEREXIT_MOVE_FIELD_TO_VBAP you need only to transfer the data to VBAP without to update it:
Case VBAK-AUART.
WHEN 'ZXXX'.
IF vbap-PSTYV eq 'ZYYY' and vbap-kondm eq '02' and
vbap-stman eq '1'.
move 'Z1' to vbap-abgru.
ELSEIF vbap-PSTYV eq 'ZYYY' and vbap-kondm NE '02' and vbap-stman NE '1' and vbap-abgru EQ 'Z1'.
move '' to vbap-abgru.
ENDDIF.
WHEN OTHERS.
ENDCASE.
Don't use USEREXIT_SAVE_DOCUMENT, but if you need the exit USEREXIT_SAVE_DOCUMENT_PREPARE. Here you have to change the data in internal table XVBAP:
Case VBAK-AUART.
WHEN 'ZXXX'.
LOOP AT XVBAP.
IF Xvbap-PSTYV eq 'ZYYY' and Xvbap-kondm eq '02' and
Xvbap-stman eq '1'.
move 'Z1' to Xvbap-abgru.
ELSEIF Xvbap-PSTYV eq 'ZYYY' and Xvbap-kondm NE '02' and xvbap-stman NE '1' and xvbap-abgru EQ 'Z1'.
move '' to vbap-abgru.
ENDDIF.
MODIFY XVBAP.
Max
ENDLOOP.
WHEN OTHERS.
ENDCASE. -
How to update Billing Plan using BAPI_SALESORDER_CHANGE
Hi,
In my case initailly sales order header data is created and saved, with reference to SO Project is created and then item level data is updated.
So clients requirement is to create any upload programme which can use for mass upload.
i.e to develop a program to upload,
i) Items in Sales Order.
ii) Billing Plan & Pricing Conditions in SO
I am trying to use BAPI_SALESORDER_CHANGE for this requirement. Problem is in this scenerio user exit is already used which validate "Amount" at item level and "Bill. value" in Billing plan tab should be same.
As observed Billing plan data can not be updated using this BAPI.
Even I've tried to use BDC for this requirement, but as we need to double click on line item while updating billing plan data and conditions it does not work while recording.
Incase anyone have worked on similar scenerio and found out solution, please share all your inputs.
Warm Regards,
NitishHi,
The following code will take you to Billing plan tab in BDC.
PERFORM bdc_dynpro USING 'SAPMV45A' '0102'.
PERFORM bdc_field USING 'BDC_CURSOR'
'VBAK-VBELN'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_field USING 'VBAK-VBELN'
wa_vbap-vbeln.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=ITEM'.
PERFORM bdc_field USING 'BDC_CURSOR'
itemno . "'RV45A-MABNR(wa_vbap-posnr)'.
PERFORM bdc_dynpro USING 'SAPMV45A' '4003'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=T\06'.
PERFORM bdc_dynpro USING 'SAPLV60F' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
Regards,
P Gomatheeswaran -
Need to add new condition type using BAPI_SALESORDER_CHANGE
Hi all,
I am using BAPI_SALESORDER_CHANGE to add new condition type for an order item.
I am able to add it, but problem here is, that i want that condition type to be manually changable. Here, in BAPI, after execution, condition type field becomes disable.
My code is as follows:
MOVE 'B' TO wa_logic-pricing.
MOVE 'X' TO wa_logic-cond_handl.
wa_cond-itm_number = wa_vbap-posnr.
* wa_cond-cond_st_no = it_konv1-stunr.
* wa_cond-cond_count = it_konv1-zaehk.
wa_cond-cond_type = it_discount-kschl.
wa_cond-CONDORIGIN = 'C'.
APPEND wa_cond TO i_cond.
CLEAR: wa_cond.
wa_condx-itm_number = wa_vbap-posnr.
* wa_condx-cond_st_no = it_konv1-stunr.
* wa_condx-cond_count = it_konv1-zaehk.
wa_condx-cond_type = it_discount-kschl.
wa_condx-updateflag = 'I'.
wa_condx-COND_VALUE = 'X'.
APPEND wa_condx TO i_condx.
CLEAR: wa_condx.
FORM f_update_order .
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = salesdocument
order_header_in = wa_headerdata
order_header_inx = wa_headerdatax
logic_switch = wa_logic
TABLES
return = it_return
order_item_in = i_itemdata
order_item_inx = i_itemdatax
conditions_in = i_cond
conditions_inx = i_condx.
IF NOT it_return[] IS INITIAL.
PERFORM f_commit_or_rollback.
ENDIF.
ENDFORM.
Please let me know, if it could be achievable.
Best regards,
Meena
Moderator Message: Corrected the code tags. You need to use flower brackets.
Edited by: kishan P on Aug 25, 2010 6:04 PMHi,
This is the demo code i am writing:
Even Change manual entry field in BAPI did not helped me.
[code]REPORT ZTESTM1.
data: l_knumv type knumv.
DATA: it_return TYPE STANDARD TABLE OF bapiret2, "Internal table for t_txt_ret
wa_return type bapiret2.
data: begin of it_konv occurs 0.
include structure konv.
data: end of it_konv.
data: logic_switch type standard table of BAPISDLS,
wa_logic type BAPISDLS.
data:itemdata type STANDARD TABLE OF BAPISDITM,
wa_item type BAPISDITM.
data : salesorder type BAPIVBELN-VBELN.
data:itemdatax type STANDARD TABLE OF BAPISDITMx,
wa_itemx type BAPISDITMx.
data: wa_header type BAPISDH1,
wa_headerx type BAPISDH1X.
data: i_cond type STANDARD TABLE OF BAPICOND,
wa_cond type BAPICOND.
data: i_condx type STANDARD TABLE OF BAPICONDX,
wa_condx type BAPICONDX.
move '0060008601' to salesorder.
move '000010' TO wa_item-itm_number.
append wa_item to itemdata.
move ' ' to wa_header-BILL_BLOCK.
move 'U' to wa_headerx-UPDATEFLAG.
move 'X' to wa_headerx-BILL_BLOCK.
MOVE: 'U' to wa_itemx-UPDATEFLAG,
'000010' TO wa_itemx-itm_number.
append wa_itemx to itemdatax.
move 'B' to wa_logic-PRICING.
move 'X' to wa_logic-COND_HANDL.
select single knumv from vbak into l_knumv where vbeln = '0060008601' .
select * from konv into table it_konv where knumv = l_knumv and kposn = '000010'.
wa_cond-ITM_NUMBER = it_konv-kposn.
wa_cond-cond_type = 'Z550'.
wa_cond-CONDCHAMAN = 'X'.
append wa_cond to i_cond.
clear: wa_cond.
wa_condx-ITM_NUMBER = it_konv-kposn.
wa_condx-COND_TYPE = 'Z550'.
wa_condx-UPDATEFLAG = 'L'.
append wa_condx to i_condx.
clear: wa_condx.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = salesorder
ORDER_HEADER_IN = wa_header
order_header_inx = wa_headerx
LOGIC_SWITCH = wa_logic
tables
return = it_return
ORDER_ITEM_IN = itemdata
ORDER_ITEM_INX = itemdatax
CONDITIONS_IN = i_cond
CONDITIONS_INX = i_condx
EXTENSIONIN =
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.[code]
Thank you.
Meena -
How to used BAPI_SALESORDER_CHANGE to add items
Hi, I am trying to use the above bapi to add items to a sales order, but I can't get the qty to map across. I had the same problem using the create bapi whcih I resolved by populating the schedule tables, but in change this just causes an "unhandled exception" to occur, so i can;t even step into the FM to see the problem. Has anyone got any ideas.
s_header_inx-updateflag = 'U'.
* set item data
s_items-itm_number = s_stock-item_no.
s_items-material = s_stock-material_no.
s_items-target_qty = s_stock-quantity.
s_items-target_qu = s_stock-uom.
s_items-ref_doc = s_stock-agreement.
s_items-ref_doc_it = s_stock-agreement_item.
s_items-batch = s_stock-batch.
s_items-plant = s_stock-plant.
s_items-store_loc = s_stock-storage_location_no.
append s_items to it_items.
* set flag to add items (I)
s_itemsx-updateflag = insert.
s_itemsx-itm_number = s_items-itm_number.
s_itemsx-material = abap_true.
s_itemsx-target_qty = abap_true.
s_itemsx-ref_doc = abap_true.
s_itemsx-ref_doc_it = abap_true.
s_itemsx-batch = abap_true.
s_itemsx-plant = abap_true.
s_itemsx-store_loc = abap_true.
append s_itemsx to it_itemsx.
s_sched-itm_number = s_items-itm_number.
s_sched-sched_line = '0001'.
s_sched-REQ_DATE = sy-datum + 30.
s_sched-req_qty = s_items-target_qty.
append s_sched to it_sched.
* set flag to add items (I)
* s_schedx-updateflag = 'I'
s_schedx-itm_number = s_items-itm_number.
s_schedx-sched_line = '0001'.
s_schedx-REQ_DATE = 'X'.
s_schedx-req_qty = abap_true.
append s_schedx to it_schedx.
* Now call the BAPI to add the items
call function 'BAPI_SALESORDER_CHANGE'
exporting
salesdocument = me->number
* ORDER_HEADER_IN =
order_header_inx = s_header_inx
SIMULATION = ' '
* BEHAVE_WHEN_ERROR = 'P'
* INT_NUMBER_ASSIGNMENT = ' '
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
tables
return = it_return
order_item_in = it_items
order_item_inx = it_itemsx
* PARTNERS =
* PARTNERCHANGES =
* PARTNERADDRESSES =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
order_schedules_in = it_sched
order_schedules_inx = it_schedx
* ORDER_TEXT =
* ORDER_KEYS =
* CONDITIONS_IN =
* CONDITIONS_INX =
* EXTENSIONIN =hi,
BAPI_SALESORDER_CHANGE didn't work for me either though i'm 100% sure the bapi works
See SAP note 366265 which tells you how to fill the structures but
you can use your program which you used to create the sales order to change the order and all you need to
do is change a few parameters
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
SALESDOCUMENTIN = P_VBELN
ORDER_HEADER_IN = ORDER_HEADER_IN
ORDER_HEADER_INX = 'U'
(make sure your partners are blank, otherwise you'll get a duprec on VBPA)
-( PS , yes, i;m saying , see if BAPI_SALESORDER_CREATEFROMDAT2 works for you)
I hope this helps
Paul Q
Edited by: Paul Quinn on Jun 2, 2011 11:10 PM -
Update sales order using BAPI_SALESORDER_CHANGE --- URGENT!!!!
Hello,
<b> I want to update Batch, Pricing date, Header text & Item text using BAPI_SALESORDER_CHANGE.</b>
But i am not able to do it.
i have written a code, but it's still not updating:
PARAMETERS: p_vbeln LIKE vbak-vbeln.
TYPES: BEGIN OF t_return.
INCLUDE STRUCTURE bapiret2.
TYPES: END OF t_return.
TYPES: BEGIN OF t_order_item_in.
INCLUDE STRUCTURE bapisditm.
TYPES: END OF t_order_item_in.
TYPES: BEGIN OF t_order_item_inx.
INCLUDE STRUCTURE bapisditmx.
TYPES: END OF t_order_item_inx.
TYPES: BEGIN OF t_schedule_lines.
INCLUDE STRUCTURE bapischdl.
TYPES: END OF t_schedule_lines.
TYPES: BEGIN OF t_schedule_linesx.
INCLUDE STRUCTURE bapischdlx.
TYPES: END OF t_schedule_linesx.
TYPES: BEGIN OF t_order_text.
INCLUDE STRUCTURE bapisdtext.
TYPES: END OF t_order_text.
DATA: l_vbeln LIKE bapivbeln-vbeln,
i_order_header_inx LIKE bapisdh1x,
i_order_header_in LIKE bapisdh1,
i_return TYPE TABLE OF t_return,
i_order_item_in TYPE TABLE OF t_order_item_in,
wa_order_item_in LIKE LINE OF i_order_item_in,
i_order_item_inx TYPE TABLE OF t_order_item_inx,
wa_order_item_inx LIKE LINE OF i_order_item_inx,
i_schedule_lines TYPE TABLE OF t_schedule_lines,
wa_schedule_lines LIKE LINE OF i_schedule_lines,
i_schedule_linesx TYPE TABLE OF t_schedule_linesx,
wa_schedule_linesx LIKE LINE OF i_schedule_linesx,
i_order_text TYPE TABLE OF t_order_text,
wa_order_text LIKE LINE OF i_order_text,
w_return LIKE bapiret2,
l_date TYPE char10.
CLEAR l_vbeln.
l_vbeln = p_vbeln.
UPDATE REJECTION REASON IN SALES ORDER *
*WRITE sy-datum TO l_date.
i_order_header_inx-updateflag = 'U'.
REFRESH i_order_item_in.
CLEAR wa_order_item_in.
wa_order_item_in-itm_number = '000010'.
wa_order_item_in-batch = '2007450027'.
wa_order_item_in-price_date = sy-datum.
wa_order_item_in-reason_rej = '00'.
APPEND wa_order_item_in TO i_order_item_in.
REFRESH i_order_item_inx.
CLEAR wa_order_item_inx.
wa_order_item_inx-itm_number = '000010'.
wa_order_item_inx-updateflag = 'U'.
wa_order_item_in-batch = 'X'.
wa_order_item_in-price_date = 'X'.
wa_order_item_inx-reason_rej = 'X'.
APPEND wa_order_item_inx TO i_order_item_inx.
*wa_order_text-doc_number = l_vbeln.
**wa_order_text-TDOBJECT = 'EHSWA_MAN'.
***wa_order_text-text_id = '0001'.
**wa_order_text-TDTEXT = 'Header Texts'.
*wa_order_text-text_line = 'SYNGENTA HEADER'.
***wa_order_text-function = 'U'.
wa_order_text-doc_number = l_vbeln.
wa_order_text-itm_number = '000010'.
*wa_order_text-TDOBJECT = 'EBAN'.
wa_order_text-text_id = '0001'.
*wa_order_text-TDTEXT = 'Item text'.
wa_order_text-text_line = 'SYNGENTA TEXT'.
wa_order_text-function = '004'.
APPEND wa_order_text TO i_order_text.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = l_vbeln
ORDER_HEADER_IN =
order_header_inx = i_order_header_inx
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
NO_STATUS_BUF_INIT = ' '
TABLES
return = i_return
order_item_in = i_order_item_in
order_item_inx = i_order_item_inx
PARTNERS =
PARTNERCHANGES =
PARTNERADDRESSES =
ORDER_CFGS_REF =
ORDER_CFGS_INST =
ORDER_CFGS_PART_OF =
ORDER_CFGS_VALUE =
ORDER_CFGS_BLOB =
ORDER_CFGS_VK =
ORDER_CFGS_REFINST =
schedule_lines = i_schedule_lines
schedule_linesx = i_schedule_linesx
order_text = i_order_text
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = w_return.
ENDIF.
Please help out.
Please send the code of it.
Thanks in advance...START-OF-SELECTION.
Get Blocked Orders
PERFORM sub_select_orders.
PERFORM order_reason_for_reject.
END-OF-SELECTION.
Display output
PERFORM sub_display_output.
*& Form sub_select_orders
text
FORM sub_select_orders .
SELECT a~vbeln
a~erdat
a~erzet
a~auart
b~posnr
FROM ( vbak as A
INNER JOIN VBAP AS B
on Bvbeln = AVBELN )
INTO TABLE i_order_data
WHERE a~vbeln IN s_ordno AND
A~auart IN s_auart AND
A~erdat IN s_orddt AND
A~vkorg IN s_vkorg AND
A~vtweg IN s_vtweg AND
A~spart IN s_spart .
IF sy-subrc NE 0.
MESSAGE i001.
No data selected
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " sub_get_blocked_orders
*& Form order_reason_for_reject
text
--> p1 text
<-- p2 text
FORM order_reason_for_reject .
LOOP AT i_order_data INTO w_order_data.
w_output-vbeln = w_order_data-vbeln.
w_ordhdrx-updateflag = c_update.
Update Order Reason for rejection .
w_orditem-ITM_NUMBER = w_order_data-posnr.
w_orditem-reason_rej = p_abgru.
append w_orditem to i_orditem .
w_orditemx-ITM_NUMBER = w_order_data-posnr.
w_orditemx-updateflag = c_update.
w_orditemx-reason_rej = 'X'.
append w_orditemx to i_orditemx .
At end of vbeln .
w_output-vbeln = w_order_data-vbeln .
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = w_order_data-vbeln
order_header_in = w_ordhdr
order_header_inx = w_ordhdrx
TABLES
ORDER_ITEM_IN = i_orditem
ORDER_ITEM_INX = i_orditemx
return = i_bapiret.
READ TABLE i_bapiret WITH KEY type = c_error
TRANSPORTING NO FIELDS.
IF sy-subrc EQ '0'.
move 'Order Reason for rejection update Failed' to
w_output-message .
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_check
IMPORTING
return = i_return.
move 'Order Reason for rejection update successful' to
w_output-message .
endif .
refresh :i_orditemx , i_orditem .
Endat .
APPEND w_output TO i_output.
CLEAR w_output.
endloop .
ENDFORM. " order_reason_for_reject -
Problem with BAPI_SALESORDER_CHANGE ("Enter part 2 of the incoterms")
Hi,
I have a problem when I try to create Sales Order and change it with BAPI_SALESORDER_CHANGE.
Logic of my program is
1. Use BAPI_SALESDOCUMENT_COPY to copy data from Billing to Create SO
2. Use BAPI_SALESORDER_CHANGE to unblock Billing Block in Sales Order Created from step1
Problem occurs in step 2. Returning Bapi Error Message that "Enter part 2 of the Incoterms". I already check that after step 1 Sales Order already have incoterm2. And in step 2, I didn't send input parameter 'X' to update fiend incoterm2 (Table order_header_inx1).
I debug BAPI_SALESORDER_CHANGE and found that my error came from function 'SD_SALES_ITEM_MAINTAIN'. I think that this function is used for update item. I couldn't see why it gave me that error about INCOTERMS2 which is in header.
Have anyone ever been through the same problem before?
Thanks,
PavinI just found the cause of this problem and want to share in this topic.
Here is the process of BAPI_SALESORDER_CHANGE that cause my problem.
BAPI_SALESORDER_CHANGE -> SD_SALESDOCUMENT_CHANGE -> SD_SALES_ITEM_MAINTAIN -> perform vbkd-inco1_pruefen(sapfv45k) -> RV_INCOTERMS_CHECK
My problem occurs in Function RV_INCOTERMS_CHECK because value in field VBKD-INCO2 is missing. This case only happen when I try to create CFR SO with reference from EXW Billing.
Hope it's useful.
Regards,
Pavin
Edited by: Pavin P. on Apr 30, 2009 5:15 AM
Maybe you are looking for
-
SSL VPN IP Address Assignment from IAS radius server
Can I use SSL VPN IP Address Assignment from IAS radius server?it can be done with acs server.are there some differ from the acs and IAS?
-
The yellow padlock icon used to be in the far right bottom corner and it was in the closed position when you are on an encrypted page like when you are shopping. I no longer see it there and I want to know where you have hidden it, or is it no longer
-
Yesterday I had installed Adobe Creative Cloud. There is no Adobe Bridge App in the Adobe Application Manager?
-
When I hit the home key Firefox takes me back to my homepage (AOL) but also opens up a new Mozilla Firefox Start Page tab. I end up with a whole bunch of unwanted tabs. == This happened == Every time Firefox opened == always
-
Can anybody tell me how to create a dynamic array in Java??I dont want to fix size of array,it should take any number of values at runtime.Please tell me the syntax of using dynamic arrays.