• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

SAP error handling

Hello,

I have a spreadsheet with a list of document numbers. I have vba code that runs a specific transaction code in SAP, pulls up the first document, then prints the invoice attached to that document, then moves on to the next record. I have a snag when the document doesn't have an invoice attached.

Currently the code just moves on to the next record, but I want it to note in the spreadsheet that that invoice didn't print.

What I've tried: after pulling up the document, go into invoice details so you can pull the doc number and put it in the spreadsheet for confirmation. If there's no invoice attached, I get an error. That's cool, On Error to the rescue, but that leads to another problem. I have error handling that says mark the line as 'notprinted' on the spreadsheet, F3 (back up) in SAP so it's ready for the next document number, then loop back around and start over with the next document number. That works great once, but then it appears the error handling is turned off.

I have read that I need "resume"/"resume next" in there after "on error", but if I put that in the code will try to pick up right where it left off after an error. I need it to start over at the beginning with the next document number.

I have tried putting in err.clear in my error handling code, but that doesn't seem to change anything. Nor does On Error GoTo 0.

In short, how do I tell it "ok, forget that error and move on to the next document number"?
 
ok, I think I have it sorted... I put a line number (26) in front of the first line after Do and then in my error handling I changed "Resume Next" to "Resume 26" and now it seems to be working as I intended.
 
Back
Top