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: 

INSERT custom table strange behave

Former Member

Hi Experts,

I am facing some issue with INSERT entries into custom tables.

FIDCCP02 idoc (Inbound) processing through RDBAPP01 report. I have created Custom function process code and Function module. My requirement is based on some calculation it will update 3 custom tables. When i run the more idoc through this report 2 tables are getting updated and last table is not getting inserted. this behavior only happens for some idocs and some time. when i reprocess the same idoc again all the 3 tables are getting inserted . After insert Catch is handled and error meesage also handled. i could not find the pattern when it goes error.

6 REPLIES 6

0 Kudos

Hi Vinuta,

Can you please check the internal table which is updating custom table has unique primary key values. Also have your written code to update the Custom table, if yes debug your code to check the same. Generally SAP code will not interfere with Custom Code. There could be one more reason, Some idoc's are not having information which i needed to update your 3rd table.

Hope this is helpful.

Best Regards,

Navin Fernandes

0 Kudos

Internal table is filling unique primary key values ( in my case document number and line item is the key field in custom table.) each idoc is having one document at a time and internal table also filling one document details once and it get insert at each document. after insert i have used commit work. if i try to run the same idoc through we19 and process these 3 custom tables are inserted with values.

0 Kudos

Vinuta,

Also analyse the entries from the internal table that got failed to INSERT in the Z table.ie Compare the ITAB entries with similar existing entries keeping in mind the Primary key relationship.

Is it updating properly when you are processing a single IDOC but failing when you are processing multiple IDOCs ?

K.Kiran.

0 Kudos

when we are processing bulk idocs through RDBAPP01 report, some idocs we are facing this issue. But processcode(custom function module related to this idoc) will run for each idoc processing. INSERT is happening in custom function module.

roberto_forti
Contributor

Hi Vinuta Hegde,

About your issue - "Custom Function Module updating 3 custom tables".

SAP has best practices for working with this scenario as below.

1. Create a new one specific custom (Z_INSERT_DB_TABLE) Function Module (abap-fm-update-module.png) which has been flagged as "update function modules".

2. Inside the new one FM (Z_UPDT_DB_TABLE) implement the ABAP code "PERFORM insert_db_table ON COMMIT." and encapsulates INSERT database statement for custom tables without COMMIT WORK but you can check sy-subrc after each INSERT.

FORM insert_db_table.

INSERT z_xpto FROM TABLE gt_xpto[].

IF sy-subrc NE 0.
MESSAGE ...
ENDIF.

ENDFORM.

3. After calling FM (Z_UPDT_DB_TABLE) trigger the COMMIT WORK.

Let me know the results.

Regards,

0 Kudos

Thank you for your detail description. This issue is resolved by uncomment the COMMIT WORK in function module.Each IDOC processing CUSTOM TABLE is getting INSERT the records and implicit commit is taking care by sap standard it self. When i removed explicit commit after insert statement everything working.