How to force an abend in a batch program?

 11 Replies
 0 Subscribed to this topic
 17 Subscribed to this forum
Sort:
Author
Messages
pbelsky
Veteran Member
Posts: 80
Veteran Member
    Can someone tell me where I can find out how to force an abend (needs recovery state) in a Lawson COBOL batch program? I have tried the error message APIs but they only print a message, do not force the pgm to abend. Lawson's precompiler will not allow me to populate RETURN-CODE or use STOP RUN. Thank you.
    Al Miller
    Basic Member
    Posts: 10
    Basic Member
      pbelsky,
      I've never seen an abend API, but I've accomplished the same by purposely performing an 820-STORE-(filename) without performing the required 800-CREATE-(filename) first.
      wilcoxmad
      Veteran Member
      Posts: 87
      Veteran Member
        COMPUTE WS-DUMMY = WS-DUMMY / 0.

        this will blow up a program.
        Roger French
        Veteran Member
        Posts: 549
        Veteran Member
          In my opinion, force abends is an ineffective and negative method for a COBOL program.

          Really, you want a COBOL batch program to logically, by it's code, go into Needs Recovery? Doesn't make sense to me.

          If you really want a 'stop' within the program, then try looking at GO TO's, meaning GO TO THE END of the program. Or use standard conditional loop logic. If done right the program will end cleanly and OK (not in needs recovery!).

          Forced abends will only give you misery.
          Sam Simpson
          Veteran Member
          Posts: 239
          Veteran Member
            What is the reason forcing the program into recovery mode? that is not standard programming methodology. Is the program looping or taking so long? Then cancel it from the scheduler. Are you trying to debug it? Try using display statements all over your program. I remember I once have a program that has many STOP RUNs but this program always write coded reasons and checksum informations into a log file which I can always look for reasons why the program stop.
            Al Miller
            Basic Member
            Posts: 10
            Basic Member
              I've coded AP Invoice interfaces for clients that were spec'ed for none of the transactions to be interfaced if any one record failed to "map" to a Lawson Vendor. The job was forced into recovery. Email alerts went out with an error report attachement. The users corrected "mapping" errors with a Lawson form, after which a request was sent to the Help Desk to recover the job. Everything worked seemlessly without any IT assistance.
              pbelsky
              Veteran Member
              Posts: 80
              Veteran Member
                Thanks very much for the info, guys! I was hoping there might be an API or something a bit more graceful, but it sounds from your suggestions like I will just have to make the program take a dive.
                 
                FYI for those curious as to why a developer would want to force an abend... My pre-Lawson world was a large DB2 shop. We would commonly code rollbacks+abends to keep a bad file from puking all over the database. This also allows you to restart your program in a spot other than the begining, which is a big deal when your files are large and your batch window is tight. Also, when a program is part of a larger job stream, it is common to code an abend in response to an error that will cause a mess in the next program down the line.

                Thank you again.
                pbelsky
                Veteran Member
                Posts: 80
                Veteran Member
                  Hi, just wanted to give you an update on this, in case anyone ever needs to force an abend. We are on Windows, 9.0.1.5 apps and 9.0.1.7 env, not sure if things work differently for others.

                  What I was trying to do was force an abend if a csv file was empty (to keep a subsequent transfer step from being run). I tried the good suggestions offered here, and believe it or not, they did not work. When I tried the 820-STORE method, Bismark would not let me compile. When I divided by zero, the program RAN CLEAN. I was stunned. 
                  I was going to try to force the program to read an array out of bounds, but I was too lazy to set it up
                   
                  I also learned that there doesn't seem to be anything that you can do to a csv that will cause your program to abend. I tried reading/closing it without opening it, reading past EOF, program did not care.

                  What I finally ended up doing was adding a sequential file to the program, and then issuing a READ for it without an OPEN.  
                  Riverboat Sam
                  New Member
                  Posts: 3
                  New Member
                    I have tried adding 1 to numeric variable that contains a space (S0C7), Dividing by zero (S0CB), and doing an Open of the same file twice. Job ran clean.  What scares the jeepers out of me is the S0C7 continuing to run.  No matter how well you vet your data, eventually you're going to get junk.  And continuing to run with junk in calculations... hey, what if the result is a few million dollars off, eh?  I cannot believe this is allowed to happen. It is totally unacceptable. 
                    pbelsky
                    Veteran Member
                    Posts: 80
                    Veteran Member
                      I know, I was totally freaked out!!!

                      It's not just awesome... It's LAWSOME.


                      Tim Autry
                      Basic Member
                      Posts: 6
                      Basic Member
                        If you are using MF-COBOL, this is a clean, forced abort called after you have displayed any/all error messages.

                        Program Working Storage - XXXWS
                        03 WS-RETURN-VALUE PIC 9(04) COMP-5 VALUE ZEROES.

                        Program Working Storage - XXXPD

                        MOVE 16 TO WS-RETURN-VALUE.
                        CALL "CBL_ABORT_RUN_UNIT" USING WS-RETURN-VALUE.

                        Tim Autry
                        Technical Support Analyst
                        Rexam Inc
                        Suite 340
                        4201 Congress St
                        Charlotte, NC 28209-4640
                        pbelsky
                        Veteran Member
                        Posts: 80
                        Veteran Member
                          WOW Tim! I came to Lawson from a mainframe shop, and you just opened up a whole new world of MF-COBOL for me

                          I was able to test your solution this morning, and it works perfectly on our system.

                          If anyone is interested, I found an alphabetical list of all the MF lib routines here: http://supportline.microf...03/rhcall17.htm#s001

                          List by function is here:
                          http://supportline.microf.../nx50ws03/sytocc.htm