11-22-2007 9:17 AM
Hi guys,
I am having a problem with my current dev. I am using BAPI_SALESORDER_CHANGE to change the sold-to of a sales order.
However, I am getting error message: "You cannot change entry in partner function XX".
Can anyone help me on this?
Thanks!
jac
11-27-2007 9:27 AM
Hi Pavan,
I am sorry i was not able to reply sooner. I just got back from leave. I still haven't solved my problem on the BAPI.
I am not angry... I really appreciate your help on this...
I am still working on the dev... I will update you if I find answers.. thanks a lot
Regards,
Jac
11-22-2007 11:34 AM
hi,
salesorderpartners like bapiparnr occurs 0 with header line,
salesorderpartners-partn_role = 'X'.
salesorderpartners-partn_numb = 'X'.
append salesorderpartners.
make sure that above four lines are their in your code
regards,
pavan
11-23-2007 3:18 AM
Hi pavan,
thanks for your reply. can you tell me what those lines are for? i do not have them in my code. i added them but still there is no progress.
here is a part of the code i am using:
CLEAR partners.
MOVE vbeln TO partners-document.
MOVE xt_vbpa-posnr TO partners-itm_number.
MOVE 'U' TO partners-updateflag.
MOVE 'AG' TO partners-partn_role.
MOVE xt_data-kunnr1 TO partners-p_numb_old.
MOVE g_data_wa-kunnr1 TO partners-p_numb_new.
APPEND partners.
this is what i pass to the partnerchanges in the tables of BAPI_SALESORDER_CHANGE.
thanks for your help...
jac
11-23-2007 5:12 AM
hi,
u need update structure to update partner, i.e ) BAPIPARNRC
CLEAR partners.
MOVE vbeln TO partners-document.
MOVE xt_vbpa-posnr TO partners-itm_number.
MOVE 'U' TO partners-updateflag.
MOVE 'AG' TO partners-partn_role.
MOVE xt_data-kunnr1 TO partners-p_numb_old.
MOVE g_data_wa-kunnr1 TO partners-p_numb_new.
APPEND partners.
create a structure with bapiparnrc with name i_bapiparnrc
i_bapiparnrc-updateflag = 'U'
i_bapiparnrc-document = 'X'
i_bapiparnrc-itm_number = 'X'
i_bapiparnrc-itm_number = 'X'
i_bapiparnrc-P_num_old = 'X'
i_bapiparnrc-P_num_new = 'X'
append i_bapiparnrc.
This will tell the program which fields you are will to change or update
regards,
pavan
11-23-2007 8:32 AM
Hi pavan,
thanks again. the structure of the table partners is bapiparnrc. do you mean that i have to append another line with fields to be updated = 'X' and append it to table partners?
jac
11-23-2007 9:12 AM
hi,
REPORT ZMYBAPI2 .
data : ordervbeln like bapivbeln occurs 0 with header line,
order_header_in like bapisdh1 occurs 0 with header line,
order_header_ix like bapisdh1x occurs 0 with header line.
data : order_items_in like bapisditm occurs 0 with header line,
order_items_ix like bapisditmx occurs 0 with header line.
data : order_partners like bapiparnr occurs 0 with header line.
data : return1 like bapiret2 occurs 0 with header line.
data : w_vbeln like bapivbeln occurs 0 with header line.
data:
order_schedules_in like bapischdl occurs 0 with header line,
order_schedules_inx like bapischdlx occurs 0 with header line.
order_header_in-sales_org = 'JNJ1'.
order_header_in-distr_chan = '02'.
order_header_in-division = 'J1'.
order_header_in-sales_off = 'JNJ1'.
order_header_in-purch_no_c = 'testbapipo'.
order_header_in-purch_date = sy-datum.
order_header_in-req_date_h = sy-datum.
append order_header_in.
order_items_in-material = '000000000000000727'.
order_items_in-plant = 'JNJ1'.
append order_items_in.
order_partners-partn_role = 'AG'.
order_partners-partn_numb = '0000000011'.
append order_partners.
order_schedules_in-itm_number = '10'.
order_schedules_in-req_qty = '10'.
append order_schedules_in.
*Updating the indices
order_header_ix-updateflag = 'U'.
order_header_ix-sales_org = 'X'.
order_header_ix-distr_chan = 'X'.
order_header_ix-division = 'X'.
order_header_ix-sales_off = 'X'.
order_header_ix-purch_no_c = 'X'.
order_header_ix-purch_date = 'X'.
order_header_ix-req_date_h = 'X'.
append order_header_ix.
order_items_ix-updateflag = 'U'.
order_items_ix-material = 'X'.
order_items_ix-plant = 'X'.
order_items_ix-division = 'X'.
order_items_ix-target_qu = 'X'.
append order_items_ix.
order_schedules_inx-updateflag = 'U'.
order_schedules_inx-itm_number = 'X'.
order_schedules_inx-req_qty = 'x'.
append order_schedules_inx.
call function 'BAPI_SALESORDER_CHANGE'
exporting
salesdocument =
ORDER_HEADER_IN = order_header_in
order_header_inx = order_header_ix
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
tables
return = return1
ORDER_ITEM_IN = order_items_in
ORDER_ITEM_INX = order_items_ix
PARTNERS = order_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 = order_schedules_in
SCHEDULE_LINESX =
ORDER_TEXT =
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
.
if sy-subrc ne 0.
write: return1-message,return1-number,return1-type.
else.
write: return1-message,return1-number,return1-type.
call function 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
endif.
This may give an idea, This program written on 4.6B.
still u r problem not solved, please post the code
regards,
pavan
11-23-2007 9:33 AM
Hi Pavan,
I am not getting the error message now. But still the data of the sales order is not updated when viewed in va03.
here is the part of the code i am using for the bapi_salesorder_change part.
partners1 like bapiparnr.
partners like bapiparnrc.
CLEAR partners1.
MOVE 'AG' TO partners1-partn_role.
MOVE g_data_wa-kunnr1 TO partners1-partn_numb.
APPEND partners1.
clear partners.
MOVE 'U' TO partners-updateflag.
MOVE 'AG' TO partners-partn_role.
APPEND partners.
Change the sales document
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = vbeln
order_header_in = header
order_header_inx = headerx
TABLES
return = return
order_item_in = items
order_item_inx = itemsx
schedule_lines = schedule
schedule_linesx = schedulx
partners = partners1
partnerchanges = partners
order_text = texts.
thanks so much for your help with this pavan i really appreciate it
11-23-2007 9:46 AM
hi
CLEAR partners1.
MOVE 'AG' TO partners1-partn_role.
<b>MOVE g_data_wa-kunnr1 TO partners1-partn_numb.</b> i think u need to pass old and new numbers here
APPEND partners1.
clear partners.
MOVE 'U' TO partners-updateflag.
MOVE 'AG' TO partners-partn_role.<b> Move 'X' to partners-partn_role</b>
APPEND partners.
try with bold one and let me know
regards,
pavan
Message was edited by:
pavan kumar pisipati
11-23-2007 9:52 AM
hi pavan,
what i get now upon saving is an information box that says "New pricing carried out". and then a message that changes were saved. However when i try to view the sales doc in va03, there is an express information box saying: Express document "Update was terminated" received from author "Jacqueline GO"
thanks again for the help...
11-23-2007 10:09 AM
hi,
i worked on bapi's one year back, i did the same scenario, but i am not used both structures, as i give the example to you, kindly do trial and error methods by my removing either of structure and let me know.
i am trying on behalf here
i am feeling shame, for u r thanks, don't say thanks every time. say once and final when u r problem solved
regards,
pavan
11-23-2007 10:55 AM
Hi,
I tried to use only the structure bapiparnr and i think it is worse because i dont get the information box either and the sales doc is still not updated.
when i add the structure bapiparnrc, i get the information box and the email that the action was terminated.
11-23-2007 10:59 AM
hi
so, bapiparnrc in this structure, remove the statement which i made with 'X' for partner role and introdue
partner_numb_old, partner_num_new
kindly first try with hot code and then implement with u r requirement
regards,
pavan
11-23-2007 11:05 AM
hi,
data : ordervbeln like bapivbeln occurs 0 with header line,
order_header_in like bapisdh1 occurs 0 with header line,
order_header_ix like bapisdh1x occurs 0 with header line.
data : order_items_in like bapisditm occurs 0 with header line,
order_items_ix like bapisditmx occurs 0 with header line.
data : order_partners like bapiparnr occurs 0 with header line.
data : return1 like bapiret2 occurs 0 with header line.
data : w_vbeln like bapivbeln occurs 0 with header line.
data:
order_schedules_in like bapischdl occurs 0 with header line,
order_schedules_inx like bapischdlx occurs 0 with header line.
order_header_in-sales_org = 'JNJ1'.
order_header_in-distr_chan = '02'.
order_header_in-division = 'J1'.
order_header_in-sales_off = 'JNJ1'.
order_header_in-purch_no_c = 'testbapipo'.
order_header_in-purch_date = sy-datum.
order_header_in-req_date_h = sy-datum.
append order_header_in.
order_items_in-material = '000000000000000727'.
order_items_in-plant = 'JNJ1'.
append order_items_in.
order_partners-partn_role = 'AG'.
order_partners-partn_numb = '0000000011'.
append order_partners.
order_schedules_in-itm_number = '10'.
order_schedules_in-req_qty = '10'.
append order_schedules_in.
*Updating the indices
order_header_ix-updateflag = 'U'.
order_header_ix-sales_org = 'X'.
order_header_ix-distr_chan = 'X'.
order_header_ix-division = 'X'.
order_header_ix-sales_off = 'X'.
order_header_ix-purch_no_c = 'X'.
order_header_ix-purch_date = 'X'.
order_header_ix-req_date_h = 'X'.
append order_header_ix.
order_items_ix-updateflag = 'U'.
order_items_ix-material = 'X'.
order_items_ix-plant = 'X'.
order_items_ix-division = 'X'.
order_items_ix-target_qu = 'X'.
append order_items_ix.
order_schedules_inx-updateflag = 'U'.
order_schedules_inx-itm_number = 'X'.
order_schedules_inx-req_qty = 'x'.
append order_schedules_inx.
call function 'BAPI_SALESORDER_CHANGE'
exporting
salesdocument = ordervbeln
ORDER_HEADER_IN = order_header_in
order_header_inx = order_header_ix
SIMULATION =
BEHAVE_WHEN_ERROR = ' '
INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH =
tables
return = return1
ORDER_ITEM_IN = order_items_in
ORDER_ITEM_INX = order_items_ix
PARTNERS = order_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 = order_schedules_in
SCHEDULE_LINESX =
ORDER_TEXT =
ORDER_KEYS =
CONDITIONS_IN =
CONDITIONS_INX =
EXTENSIONIN =
.
if sy-subrc ne 0.
write: return1-message,return1-number,return1-type.
else.
write: return1-message,return1-number,return1-type.
call function 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
RETURN =
.
endif.
This code working with me successfully. why not at u r end i am not getting
11-23-2007 11:29 AM
Hi,
i tried this for bapiparnrc:
clear partners.
MOVE 'U' TO partners-updateflag.
MOVE 'AG' TO partners-partn_role.
MOVE xt_data-kunnr1 TO partners-p_numb_old.
MOVE g_data_wa-kunnr1 TO partners-p_numb_new.
APPEND partners.
error message: insufficient parameters passed.
Actually, there is no error message issued. in fact, information message saying that updates have been saved is displayed. but the sales doc is not updated. i am very confused already.
11-23-2007 11:37 AM
pass partner roles also
clear partners.
MOVE 'U' TO partners-updateflag.
MOVE 'AG' TO partners-partn_role.
MOVE xt_data-kunnr1 TO partners-p_numb_old.
MOVE g_data_wa-kunnr1 TO partners-p_numb_new.
APPEND partners.
it need to now which has to be modified so move parter role
don't worry, we are very much to the solution.
regards,
pavan
Message was edited by:
pavan kumar pisipati
11-23-2007 11:46 AM
hi,
i already tried that, but still, sales doc is still not updated.
11-23-2007 12:21 PM
hi
don't get angry on mine, kindly go through this with cool head
The BAPI Change modifies an existing instance of a SAP Business Object, for example, one specific purchase order.
As the Change BAPI can carry out changes to existing data, a Change BAPI must be able to identify fields that have been modified and fields that have stayed the same.
Using an initial value is no solution because an initial value could also represent a valid new value. Moreover, in the ABAP programming language or on other development platforms you cannot assign the value "null" to all data types in order to mark fields and thus indicate that the remaining fields contain update values.
Features
Two different approaches can be used to identify fields containing values that have been modified in a Change BAPI:
Flagging fields to identify those fields containing modified values
Comparing fields to identify those fields containing modified values
1. Flagging Fields to Identify Those Fields Containing Modified Values
In this approach parameter fields containing modified values are identified by a suitable flag in an additional "change parameter".
An additional change parameter must be created with the same number of fields and the same field names for every parameter in the BAPI containing modified field values.
When the BAPI is called, the fields in the additional change parameter whose counterparts in the corresponding parameter contain modifications, must be marked with an update flag.
That way the BAPI can identify both modified and unmodified fields in the parameter.
Follow the conventions below when you create change parameters to identify modified fields:
The name of the additional change parameter consists of the parameter name with the suffix "X". For instance, if the parameter is called EquiSales, the name of the additional change parameter is EquiSalesX.
The additional change parameter must contain exactly the same number of fields and the same field names as the parameter. You must use the data element BAPIUPDATE as the data element for the update fields. This can have the following values:
- 'X'
This value means that the corresponding parameter field contains a modified value.
- ' ' (no value)
This means that the corresponding parameter field does not have to be updated.
If the parameter is a table, the additional change parameter must also be a table.
A Change BAPI is used to change the value of the existing distribution channel (Distr_Chan) to Distr_Chan="US". The program objects in the R/3 System affected by this change are:
Program Object Name
SAP Business Object
BAPI
Parameter
Fields in parameter
EquiSales
Change parameter that identifies modified fields
Fields in EquiSalesX PieceOfEquipment
Change
EquiSales
SalesOrg='abcd'
Distr_Chan='US'
Division='efgh'
...
EquiSalesX
SalesOrg=' '
Distr_Chan='X'
Division=' '
In the parameter EquiSalesX the value in the field Distr_Chan is 'X'. This indicates that the field Distr_Chan of the parameter EquiSales contains a modified value.
The BAPI Change then overwrites the existing value in the field Distr_Chan with the current value in the field Distr_Chan in the parameter EquiSales.
2. Comparing Fields to Identify Those Fields Containing Modified Values
In this approach parameter fields containing modified values are identified by comparing them with the fields in an additional "compare parameter":
An additional compare parameter must be created with the same structure for each BAPI parameter containing update values.
When the Change BAPI is called all relevant fields in the compare parameter must be filled with the data at the time the database is read. This data could be, for example, the result of a previous GetDetail BAPI call.
The fields of the corresponding parameter may contain modified values.
The data in the compare parameter can first be checked against the current database contents to ascertain whether it has changed in the meantime. This way any database changes made between the time the data was read and the time the database is updated can be identified.
Then, the data in the compare parameter can be compared field by field with the data in the corresponding parameter. If data in any field is different then the field contains data that must be changed.
When you create compare parameters follow these conventions:
The name of the additional compare parameter consists of the parameter name with the suffix "X". For instance, if the parameter is called EquiSales, the name of the additional compare parameter is EquiSalesX.
The additional compare parameter must contain exactly the same fields and the same structure as the parameter.
regards,
pavan
11-23-2007 12:34 PM
hi,
try by passing item number to this structure or for both the structures.
regards,
pavan
Message was edited by:
pavan kumar pisipati
11-27-2007 9:27 AM
Hi Pavan,
I am sorry i was not able to reply sooner. I just got back from leave. I still haven't solved my problem on the BAPI.
I am not angry... I really appreciate your help on this...
I am still working on the dev... I will update you if I find answers.. thanks a lot
Regards,
Jac
11-27-2007 10:24 AM
hi,
i am not sure, i am putting a note, you should have bapi commit function after change function
make sure of it
regards,
pavan
01-05-2022 5:14 PM
Not is posible.
This is a restriction in BAPI processing in ECC, Sold-to party cannot be changed in ECC
https://launchpad.support.sap.com/#/notes/1614247
Regards,
Ricardo R.