‎2005 Dec 12 3:17 PM
I have a program that creates a short dump in the background when I call a function module more than once in the same program.
Basically what I do is call BUPR_RELATIONSHIP_CREATE
for each relationship I need to create in our CRM system.
I even do a COMMIT WORK AND WAIT after each call, however I get a short dump of DUPLICATE key insert (SAPSQL_ARRAY_INSERT_DUPREC)
Looking at SAP's own code where the dump occurs, SAP have commented out the line:
INSERT BUT051 FROM TABLE LT_BUT051 ACCEPTING DUPLICATE KEYS.
Here is an excerpt of the code from my program:
CALL FUNCTION 'BUPR_RELATIONSHIP_CREATE'
EXPORTING
iv_partner_1 = '0010003939'
iv_partner_2 = '0010008090'
iv_relationship = 'ZUR010'
iv_date_from = '00010101'
iv_date_to = '99991231'
iv_testrun = ' '
iv_x_save = 'X'
TABLES
et_return = gt_return.
PERFORM disp_error USING gs_warning.
COMMIT WORK AND WAIT.
CALL FUNCTION 'BUPR_RELATIONSHIP_CREATE'
EXPORTING
iv_partner_1 = '0010003939'
iv_partner_2 = '0010004555'
iv_relationship = 'ZUR010'
iv_date_from = '00010101'
iv_date_to = '99991231'
iv_testrun = ' '
iv_x_save = 'X'
TABLES
et_return = gt_return.
PERFORM disp_error USING gs_warning.
COMMIT WORK AND WAIT.
Can anyone offer any advice?
Many Thanks
David
‎2005 Dec 12 5:06 PM
Did you get this error the very first time you ran your program? Check in the table <b>BUT051</b> whether an entry already exists for the combination you are trying to create!
Execute function module <b>BUPR_RELATIONSHIP_CHECK_EXIST</b> for the same set of keys and see what message you get in the bapi return parameter.
‎2005 Dec 12 3:39 PM
SAP hasn't released this BAPI (at least not in our <b>SRM</b> system). But it's used in method if_crm_bsp_model_access_il~modify. So you might look there to see how it is used.
Rob
‎2005 Dec 12 5:06 PM
Did you get this error the very first time you ran your program? Check in the table <b>BUT051</b> whether an entry already exists for the combination you are trying to create!
Execute function module <b>BUPR_RELATIONSHIP_CHECK_EXIST</b> for the same set of keys and see what message you get in the bapi return parameter.
‎2005 Dec 12 5:42 PM
I checked, the entry did not exist.
From further debugging this, it appears that if you call this function module multiple times with a COMMIt at the end each time, the memory does not get cleared.
For example BUPR_RELATIONSHIP_CREATE calls BUS_BAPI_SAVE which takes no parameters.
This calls BUR_BUPR_UPDATE.
The first time BUPR_RELATIONSHIP_CREATE is called, in BUR_BUPR_UPDATE internal table lt_but051 contains one entry, the first one. This relationship is then created and a COMMIT takes place.
The program then calls BUPR_RELATIONSHIP_CREATE to create the second relationship. When BUR_BUPR_UPDATE is called again, there are 2 entries in internal table lt_but051.
It then tries to create the relationships based on what is in this internal table.
Because the first entry has already been created, the short dump occurs and the second entry therefore does not get created.
SAP have commented out a piece of code previously and replaced it with new code, I guess this was to fix a bug. However I get a short dump.
See below from BUR_BUPR_UPDATE :
INSERT BUT051 FROM TABLE LT_BUT051 ACCEPTING DUPLICATE KEYS.
IF SY-SUBRC <> 0.
UPDATE BUT051 FROM TABLE LT_BUT051.
ENDIF.
INSERT but051 FROM TABLE lt_but051.
IF sy-subrc <> 0.
MESSAGE a855 WITH gc_tname_but051 ' ' ' ' ' '.
ENDIF.
‎2005 Dec 12 6:10 PM
Ok..I understand...so the itab in BUR_BUPR_UPDATE has to be cleared everytime we call this FM!
Do you know what is the use of export parameter <b>iv_x_save</b>? May be try setting it to blank: <b>iv_x_save = ''</b>
‎2005 Dec 13 9:32 AM
Sam,
iv_x_save = ' ' tells the fcn module not to actually make the change.
This is empty when IV_TESTRUN = 'X' and vice versa.
Rgds
David
‎2007 Mar 07 5:12 AM
‎2008 Feb 19 3:43 PM
Hi ,
This is a SAP Bug probably. Use function module BAPI_TRANSACTION_COMMIT instead of commit work statement or CALL FUNCTION 'BUFFER_REFRESH_ALL' after commit work. This solves the issue.
Regards,
Vin
‎2011 Feb 24 1:49 PM
It may help to call the FM 'BUR_BUPR_EVENT_DLVE2' after completing all updates by FMs from function group BUD3 including those by BUR_BUPR_UPDATE. But be aware of locks' releases within FM '..._DLVE2'!
‎2011 Feb 24 2:30 PM
Hi David,
for BAPI, you should use funtion BAPI_TRANSACTION_COMMIT with parameter work = 'X' only. ASlso check the existence of the relationship before trying to create.
Regards,
Clemens