2011 Jun 30 9:24 AM
Hi there gurus,
I created a sales document with "BAPI_SALESORDER_CREATEFROMDAT2" and after the creation, there is the client need to modify some data. One of the possibilities is to change the PARTNER data.
I've combed the forum for some answers but none are working for me. I receive the "Workplace" short dump message:
Short text
The ABAP/4 Open SQL array insert results in duplicate database records.
The latest variant I'm using to change the partners is:
CLEAR ls_order_header_inx.
ls_order_header_inx-updateflag = 'U'.
ls_order_header_inx-sales_org = 'X'.
ls_order_header_inx-distr_chan = 'X'.
MOVE-CORRESPONDING ls_order_header_in TO ls_order_header_in_ch.
"RG1 - Partner old
ls_order_partners-partn_role = 'RG'.
SELECT SINGLE kunnr
FROM vbpa INTO ls_order_partners-partn_numb
WHERE vbeln = i_salesdocument
AND posnr = '0000'
AND parvw = 'RG'.
ls_order_partners-itm_number = '0000'.
APPEND ls_order_partners TO lt_order_partners.
ls_order_partners_updt-document = i_salesdocument.
ls_order_partners_updt-updateflag = 'U'.
ls_order_partners_updt-partn_role = 'RG'.
ls_order_partners_updt-p_numb_old = ls_order_partners-partn_numb.
ls_order_partners_updt-p_numb_new = i_kunnr_p.
APPEND ls_order_partners_updt TO lt_order_partners_updt.
"RG2 - Partner new
ls_order_partners-partn_role = 'RG'.
ls_order_partners-partn_numb = i_kunnr_p.
ls_order_partners-itm_number = '0000'.
APPEND ls_order_partners TO lt_order_partners.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = i_salesdocument
order_header_in = ls_order_header_in_ch
order_header_inx = ls_order_header_inx
TABLES
return = lt_return
order_item_in = lt_order_items_in
order_item_inx = lt_order_items_inx
partners = lt_order_partners
partnerchanges = lt_order_partners_updt
schedule_lines = lt_order_schedules_in
schedule_linesx = lt_order_schedules_inx
order_text = lt_order_text.
Although I receive a success message that the PO is saved, none of the data is changed. If I remove the "partner" data tables, everything works just perfect.
Can anyone shade some light into this ?
Thank you,
Marius
PS: For any other questions u might have, I'm right here in front of the monitor 😛 for the next hours 😛
Edited by: Marius Stoica on Jun 30, 2011 10:24 AM
2011 Jun 30 9:33 AM
Hi,
you should work with modify instead of append.
Regards
Nicole
2011 Jun 30 9:35 AM
2011 Jun 30 9:36 AM
No ... it has 2 lines .. let me debug it for you
1 RG RO1545TM01 000000 "<-- old
2 RG RO0003TM01 000000 "<-- new
Edited by: Marius Stoica on Jun 30, 2011 10:37 AM
2011 Jun 30 9:40 AM
After creation, can you try this 'BAPI_SALESORDER_CHANGE' for modification?
2011 Jun 30 9:42 AM
Yes, that's the function I'm using to change the document partners.
2011 Jun 30 9:52 AM
1 RG RO1545TM01 000000 "<-- old
do we need to update this record again? i think this is already in the database. is it trying to update the same record again and fails and results in dump?
2011 Jun 30 9:54 AM
In many examples that I've seen on this forum and on others, that line is there (the old) ... I'll try to delete it ... again 😛 and see if it works ...
NOPE. Same short dump.
Edited by: Marius Stoica on Jun 30, 2011 10:56 AM
2011 Jun 30 9:54 AM
Maybe, you don´t understand my first comment, but try to work with
MODIFY ......ls_order_partners .......
instead of
APPEND ls_order_partners TO lt_order_partners
Otherwise you put the same entrie a second time to the partner table.
Did you try this?
2011 Jun 30 9:58 AM
No Nicole. See my debugger snippet. I don't have 2 records (lines) with the same data. First line is for the old value, the second line is for the new value.
I've even deleted the first line ("the old" value line) and executed the program with only 1 line (the new value) and I receive the same short dump.
2011 Jun 30 10:04 AM
Hm,
but is it allowed in you system, to set more then 1 RG for one document? If not, you have duplicated datasets, because of the RG.
2011 Jun 30 10:06 AM
I have also tried with only 1 (one) partner "RG" .... I receive the same error message, same SHORT DUMP.
2011 Jun 30 10:12 AM
Maybe you should change the partner with MV45AFZZ. I did it a few years ago, and it is possible there.
2011 Jun 30 10:17 AM
That's a user exit program ... it's useful but not in this case. My FM that calls the BAPI it's a RFC called by a web shop. It gets really complicated to explain.
2011 Jun 30 10:28 AM
Hi,
Just a suggestion, try to remove PARTNERS parameter and only pass PARTNERCHANGES to the bapi.
Where are you populating i_kunnr_p.
Regards,
Nagaraj
2011 Jun 30 10:29 AM
I'll do that.
"i_kunnr_p" it's an input parameter to the function that calls the BAPI.
NOPE. Same Short Dmp
Edited by: Marius Stoica on Jun 30, 2011 11:31 AM
2011 Jun 30 1:09 PM
Hi,
Try this piece of code .. this should work. Make sure there is no duplication record.
CLEAR ls_order_header_inx.
ls_order_header_inx-updateflag = 'U'.
ls_order_header_inx-sales_org = 'X'.
ls_order_header_inx-distr_chan = 'X'.
MOVE-CORRESPONDING ls_order_header_in TO ls_order_header_in_ch.
SELECT SINGLE kunnr
FROM vbpa INTO ls_order_partners-partn_numb
WHERE vbeln = i_salesdocument
AND posnr = '0000'
AND parvw = 'RG'.
ls_order_partners_updt-document = i_salesdocument.
ls_order_partners_updt-updateflag = 'U'.
ls_order_partners_updt-partn_role = 'RG'.
ls_order_partners_updt-p_numb_old = ls_order_partners-partn_numb.
ls_order_partners_updt-p_numb_new = i_kunnr_p.
ls_order_partners_updt-itm_number = <sales order item>
APPEND ls_order_partners_updt TO lt_order_partners_updt.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = i_salesdocument
order_header_in = ls_order_header_in_ch
order_header_inx = ls_order_header_inx
TABLES
return = lt_return
order_item_in = lt_order_items_in
order_item_inx = lt_order_items_inx
partnerchanges = lt_order_partners_updt
schedule_lines = lt_order_schedules_in
schedule_linesx = lt_order_schedules_inx
order_text = lt_order_text.
Regards,
Nagaraj
2011 Jun 30 1:31 PM
Hi Kumar,
Adding the item number '0000' didn't solve anything ... still receiving the short dump
2011 Jun 30 2:27 PM
hi Marius,
You need to go back 1 step.
Put your breakpoint in MV45AFZZ userexit_save_document_prepare
check internal table XVBPA
use the UPDKZ flag and see why you have entries with I (insert)
If your XVBPA is ok at this point, check again at MV45AFZZ userexit_save_document
kind regards
Paul Quinn
2011 Jun 30 2:38 PM
Hi Paul,
For the moment the function works just fine. I can't reproduce the short dump any more .. and it makes me go crazy
IF it happens again, I'll be sure to do do as you suggested.
Thank you ALL for your quick responses.
I will probably come back (hopefully soon) in case "this" doesn't work ...
2011 Jun 30 10:05 AM
i would try to push the new value to lt_order_partner_upd.
however i am not sure what should be on in the lt_order_partner. I assume that when we trying to update it is not necessary to push the old values.
there is one more FM, which we have used for the changes 'SD_SALESDOCUMENT_CHANGE'
2011 Jun 30 12:47 PM
Hello Marius,
I have gone through the code pasted by you and I am not able to understand below code.
"RG1 - Partner old
ls_order_partners-partn_role = 'RG'.
SELECT SINGLE kunnr
FROM vbpa INTO ls_order_partners-partn_numb
WHERE vbeln = i_salesdocument
AND posnr = '0000'
AND parvw = 'RG'.
ls_order_partners-itm_number = '0000'.
APPEND ls_order_partners TO lt_order_partners.
why are you moving old Partner also in internal tabl? I guess you just need old part number for update in internal table lt_order_partners_updt.
Try removig this part and keep only new entry in both partner table. Just try.
Also please go through the short dump thoroghly in ST22. The short dump will have all important details. Specifically check where the short dump appearing. ( check for >>>>> icon before code)
Also did you tried doing change using VA02 for partner ?
Thanks
Vijay Bobde
2011 Jun 30 1:30 PM
Hi vijbobde,
I did both things ... removing the old, leaving only the new part ... also reading the ST22 short dump message.
The message only says that it's a duplicate thing error, and the removing thingie didn't solve a thing. I continuously receive the error.
2011 Jun 30 1:36 PM
Adding some details ...
The ST22 message short dump refers to the function "SD_PARTNER_UPDATE" that is used to change the partners details. The actual line is:
477 UPDATE (OBJECT) FROM TABLE DA_XVBPAU.
478 UPDATE VBPA3 FROM TABLE DA_XVBPA3U.
479
>>>>> INSERT (OBJECT) FROM TABLE DA_XVBPAI.
481 INSERT VBPA3 FROM TABLE DA_XVBPA3I.
None of the types of Break-points that I've learned (session bp, user bp, statement bp, function bp) breakes the run of the program at this point when I run my function or the BAPI. THe only way I could run this function is by SE37 BUT the result is neither a short dump, nor the modification of the lines.
2011 Jun 30 10:31 PM
Hi Mariu,
pass paramater partnerchanges only, not parameter partners.
Regards,
Clemens
2013 Jan 31 4:40 AM
Hi
Its a long time this thread was posted but just wanted to know if we have any solution to the OP's question.
We are having exact problem in our system.
Thanks
Bhanu