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: 

Fail safe logic needed for purchase order upload program

Former Member
0 Kudos

Hello all,

i am working on creating PO's by reading data from a text file. I need to implement fail safe logic in it, which is to make sure this program uploads all the records in the text file successfully. For example, i have 1000 records in my text file and while running the upload program if the program times out while creating the 500th PO or if SAP is down at that time, then we have 499 PO's created and 501 yet to be created. But if we run the same program again, we will generate duplicate PO's for 499 again. I want to avoid this kind of problem.

How do i implement this idea?

Kindly guide me on this.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can use BAPI_PO_CREATE to create the PO and then choose one of the two options.

1. Commit work if all the PO's are successfully created or else Rollback work.

2. Commit successfull POs one by one and write / download an error file ( in same structure as original file but with only error records ) for error cases.

Further you correct the generated error file and process it again ( not the original file ).

Thanks,

Ram

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I would suggest trying to create a Batch Input Session.

If a po would error out, then the session will flag it. You can re-run the session and it will only process the ones that had errors.

Regards,

Rich Heilman

Former Member
0 Kudos

You can use BAPI_PO_CREATE to create the PO and then choose one of the two options.

1. Commit work if all the PO's are successfully created or else Rollback work.

2. Commit successfull POs one by one and write / download an error file ( in same structure as original file but with only error records ) for error cases.

Further you correct the generated error file and process it again ( not the original file ).

Thanks,

Ram

0 Kudos

Hello,

Thanks for the information.

I am doing commit work as and when the PO's are getting created.

And i am ok if the Data has error the user will change the error and do me21n manually as i will report out what all the records that has error with the error messages.

My concern is, what should i do when my program times out or sap is down or power goes off...etc while doing the upload. for example if i have to upload 100 records and while uploding the 50th record , something goes wrong so i need to restart the upload again, but at this time i will be creating duplicate POs , any idea on this.

Thanks.

Karan

0 Kudos

Ok ..

Then I would suggest you use Application Log to keep the success and error messages of PO processing.

You can check trsnaction SLG0 and create your own application log object.

Then you need to use FMs BAL_LOG_* to crate and add messages to it.

This way you will have a facility to check as which of your records are converted to PO for a run.

In case SAP gets down in between , still you can find the details using Xn SLG1 and then accordingly remove the records from your file which are already converted to PO.

Thanks,

Ram