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: 

BAPI_SALESORDER_CHANGE ... Short Dump "SAPSQL_ARRAY_INSERT_DUPREC"

Former Member
0 Kudos

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

25 REPLIES 25

Former Member
0 Kudos

Hi,

you should work with modify instead of append.

Regards

Nicole

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

Does lt_order_partners has duplicate records?

Former Member
0 Kudos

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

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

After creation, can you try this 'BAPI_SALESORDER_CHANGE' for modification?

Former Member
0 Kudos

Yes, that's the function I'm using to change the document partners.

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

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?

Former Member
0 Kudos

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

Former Member
0 Kudos

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?

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

I have also tried with only 1 (one) partner "RG" .... I receive the same error message, same SHORT DUMP.

Former Member
0 Kudos

Maybe you should change the partner with MV45AFZZ. I did it a few years ago, and it is possible there.

Former Member
0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

Hi Kumar,

Adding the item number '0000' didn't solve anything ... still receiving the short dump

0 Kudos

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

Former Member
0 Kudos

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 ...

shahid
Product and Topic Expert
Product and Topic Expert
0 Kudos

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'

Former Member
0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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.

Clemenss
Active Contributor
0 Kudos

Hi Mariu,

pass paramater partnerchanges only, not parameter partners.

Regards,

Clemens

Former Member
0 Kudos

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