AS400 COBOL ILE Pointer not set for location referenced – Trigger

45 pts.
Tags:
COBOL Compiler
COBOL/400
ILE COBOL
Hello, Guys

I have been trying to run an ILE Cobol Trigger program, however it stops wiht the message below Pointer not set for location referenced. 

If when debbuging the system is able to resolve the address of the variable associated with the PF.

Hope someone can provide soime guidance.

The full error and code are listed below, and one of the source of the program can be found here at http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/dbp/rbafo.pdf.

Thanks,

Sam Faraday

                                                                                Message ID . . . . . . :   CPF8E17       Severity . . . . . . . :   40        Message type . . . . . :   Diagnostic                                         Date sent  . . . . . . :   11/09/09      Time sent  . . . . . . :   00:11:21                                                                                Message . . . . :   Pointer not set for location referenced.                  Cause . . . . . :   A pointer was used, either directly or as a basing          pointer, that has not been set to an address.                               Recovery  . . . :   Correct any errors and try your request again.                                                                                                                                                                      

*************** Beginning of data **********************************         IDENTIFICATION DIVISION.                                            PROGRAM-ID. UPDTRG3.                                              * * * * * * * * * * * * * * * * * * * * * * * * * * * * *           *  Program Name : UPDTRG                                    *       *                                                           *       *  This trigger program is called when a record is updated  *       *  in the ATMTRANS file.                                    *       *  This program will check the balance of ACCTS and         *       *  the total amount in ATMS.If either one of the amounts    *       *  is not enough to meet the withdrawal, an exception       *       *  message is signalled to the application.                 *       *  If both ACCTS and ATMS files have enough money, this     *       *  program will update both files to reflect the changes.   *       *                                                           *       *  ATMIDs of 10001 and 10002 will be updated in the ATMTRANS*       *  file with the following data:                            *

      *  file with the following data:                            *        *                                                           *        *  ATMID ACCTID TCODE AMOUNT                                *        *  --------------------------------                         *        *  10001 20001   W      25.00                               *        *  10002 20002   W     900.00                               *        *  10003 20003   D     500.00                               *        *                                                           *        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *        * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *          ENVIRONMENT DIVISION.                                                CONFIGURATION SECTION.                                                SOURCE-COMPUTER. IBM-ISERIES                                         OBJECT-COMPUTER. IBM-ISERIES.                                        SPECIAL-NAMES. I-O-FEEDBACK IS FEEDBACK-JUNK.                        INPUT-OUTPUT SECTION.                                                FILE-CONTROL.                                              

......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++            SELECT ACC-FILE ASSIGN TO DATABASE-ACCTS                                  ORGANIZATION IS INDEXED                                                 ACCESS IS RANDOM                                                        RECORD KEY IS ACCTN                                                     FILE STATUS IS STATUS-ERR1.                                                                                                                   SELECT ATM-FILE ASSIGN TO DATABASE-ATMS                                   ORGANIZATION IS INDEXED                                                 ACCESS IS RANDOM                                                        RECORD KEY IS ATMN                                                      FILE STATUS IS STATUS-ERR2.                                                                                                              *************************************************************           *      COMMITMENT CONTROL AREA.                             *           *************************************************************             I-O-CONTROL.                                                               COMMITMENT CONTROL FOR ATM-FILE, ACC-FILE.                                                                                          

......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                                                            *************************************************************        *      DATA DIVISION                                        *        *************************************************************                                                                               DATA DIVISION.                                                       FILE SECTION.                                                        FD ATM-FILE                                                             LABEL RECORDS ARE STANDARD.                                       01 ATM-REC.                                                          COPY DDS-ATMFILE OF ATMS.                                                                                                                 FD ACC-FILE                                                             LABEL RECORDS ARE STANDARD.                                       01 ACC-REC.                                                          COPY DDS-ACCFILE OF ACCTS.                                                                                                       

......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                                                                01 INPUT-RECORD.                                                          COPY DDS-TRANS OF ATMTRANS.                                                                                                                   05 OFFSET-NEW-REC  PIC 9(8) BINARY.                                                                                                             01 NUMBERS-1.                                                             03 NUM1 PIC 9(10).                                                      03 NUM2 PIC 9(10).                                                      03 NUM3 PIC 9(10).                                                                                                                            01 FEEDBACK-STUFF PIC X(500) VALUE SPACES.                                                                                                     *************************************************************           *      MESSAGE FOR SIGNALLING ANY TRIGGER ERROR             *           * - Define any message ID and message file in the following *           * message data.                                             *    

 

......*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+..       *************************************************************        01 SNDPGMMSG-PARMS.                                                 03 SND-MSG-ID PIC X(7) VALUE "TRG9999".                            03 SND-MSG-FILE PIC X(20) VALUE "MSGF LIB1 ".                      03 SND-MSG-DATA PIC X(25) VALUE "Trigger Error".                   03 SND-MSG-LEN PIC 9(8) BINARY VALUE 25.                           03 SND-MSG-TYPE PIC X(10) VALUE "*ESCAPE ".                        03 SND-PGM-QUEUE PIC X(10) VALUE "* ".                             03 SND-PGM-STACK-CNT PIC 9(8) BINARY VALUE 1.                      03 SND-MSG-KEY PIC X(4) VALUE " ".                                 03 SND-ERROR-CODE.                                                   05 PROVIDED PIC 9(8) BINARY VALUE 66.                              05 AVAILABLE PIC 9(8) BINARY VALUE 0.                              05 RTN-MSG-ID PIC X(7) VALUE " ".                                  05 FILLER PIC X(1) VALUE " ".                                      05 RTN-DATA PIC X(50) VALUE " ".                                                                                           

      *************************************************************          *   LINKAGE SECTION                                         *          *  PARM 1 is the trigger buffer                             *          *  PARM 2 is the length of the trigger buffer               *          *************************************************************           LINKAGE SECTION.                                                       01 PARM-1-AREA.                                                          03 FILE-NAME PIC X(10).                                                03 LIB-NAME PIC X(10).                                                 03 MEM-NAME PIC X(10).                                                 03 TRG-EVENT PIC X.                                                    03 TRG-TIME PIC X.                                                     03 CMT-LCK-LVL PIC X.                                                  03 FILLER PIC X(3).                                                    03 DATA-AREA-CCSID PIC 9(8) BINARY.                                    03 FILLER PIC X(8).                                                    03 DATA-OFFSET.                                              

......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++            05 OLD-REC-OFF PIC 9(8) BINARY.                                         05 OLD-REC-LEN PIC 9(8) BINARY.                                         05 OLD-REC-NULL-MAP PIC 9(8) BINARY.                                    05 OLD-REC-NULL-LEN PIC 9(8) BINARY.                                    05 NEW-REC-OFF PIC 9(8) BINARY.                                         05 NEW-REC-LEN PIC 9(8) BINARY.                                         05 NEW-REC-NULL-MAP PIC 9(8) BINARY.                                    05 NEW-REC-NULL-LEN PIC 9(8) BINARY.                                    05 FILLER PIC X(16).                                                  03 RECORD-JUNK.                                                           05 OLD-RECORD PIC X(16).                                                05 OLD-NULL-MAP PIC X(4).                                               05 NEW-RECORD PIC X(16).                                                05 NEW-NULL-MAP PIC X(4).                                                                                                                     01 PARM-2-AREA.                                                           03 TRGBUFL PIC X(2).                                        

......*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7        *************************************************************           * PROCEDURE DIVISION.                                       *           *************************************************************            PROCEDURE DIVISION USING PARM-1-AREA, PARM-2-AREA.                      MAIN-PROGRAM SECTION.                                                   000-MAIN-PROGRAM.                                                           OPEN I-O ATM-FILE.                                                      OPEN I-O ACC-FILE.                                                                                                                         *    MOVE 0 TO BAL.                                                                                                                             *************************************************************           *  SET UP THE OFFSET POINTER AND COPY THE NEW RECORD.       *           *************************************************************                ADD 1, NEW-REC-OFF GIVING OFFSET-NEW-REC.                                UNSTRING PARM-1-AREA                                                      INTO INPUT-RECORD                                        

......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++               WITH POINTER OFFSET-NEW-REC.                                         MOVE 0 TO BAL.                                                                                                                             *OLD    SET TEMP-PTR TO ADDRESS OF PARM-1-AREA.                         *OLD    SET TEMP-PTR UP BY NEW-REC-OFFSET.                              *OLD      SET ADDRESS OF INPUT-RECORD2 TO TEMP-PTR.                     *OLD    MOVE INPUT-RECORD2 TO INPUT-RECORD.                                                                                                     *************************************************************           *  READ THE RECORD FROM THE ACCTS FILE                      *           *************************************************************                MOVE ACCTID TO ACCTN.                                                   READ ACC-FILE                                                             INVALID KEY PERFORM 900-OOPS                                            NOT INVALID KEY PERFORM 500-ADJUST-ACCOUNT.                                                                                              *************************************************************    

......*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7       *  READ THE RECORD FROM THE ATMS FILE.                      *         *************************************************************              MOVE ATMID TO ATMN.                                                   READ ATM-FILE                                                            INVALID KEY PERFORM 950-OOPS                                          NOT INVALID KEY PERFORM 550-ADJUST-ATM-BAL.                        CLOSE ATM-FILE.                                                       CLOSE ACC-FILE.                                                       GOBACK.                                                                                                                                *************************************************************         *************************************************************         *************************************************************         *************************************************************         * THIS PROCEDURE IS USED IF THERE IS NOT ENOUGH MONEY IN THE*         * ACCTS FOR THE WITHDRAWAL.                                 *         *************************************************************  

......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++        200-NOT-ENOUGH-IN-ACC.                                                      DISPLAY "NOT ENOUGH MONEY IN ACCOUNT.".                                 CLOSE ATM-FILE.                                                         CLOSE ACC-FILE.                                                         PERFORM 999-SIGNAL-ESCAPE.                                              GOBACK.                                                                                                                                    *************************************************************           * THIS PROCEDURE IS USED IF THERE IS NOT ENOUGH MONEY IN THE*           * ATMS FOR THE WITHDRAWAL.                                  *           *************************************************************            250-NOT-ENOUGH-IN-ATM.                                                      DISPLAY "NOT ENOUGH MONEY IN ATM.".                                     CLOSE ATM-FILE.                                                         CLOSE ACC-FILE.                                                         PERFORM 999-SIGNAL-ESCAPE.                                              GOBACK.                                                                                                                             

......*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7        * THIS PROCEDURE IS USED TO ADJUST THE BALANCE FOR THE ACCOUNT OF       * THE PERSON WHO PERFORMED THE TRANSACTION.                             *************************************************************            500-ADJUST-ACCOUNT.                                                         IF TCODE = "W" THEN                                                       IF (BAL < AMOUNT) THEN                                                     PERFORM 200-NOT-ENOUGH-IN-ACC                                        ELSE                                                                       SUBTRACT AMOUNT FROM BAL                                                REWRITE ACC-REC                                                    ELSE IF TCODE = "D" THEN                                                  ADD AMOUNT TO BAL                                                       REWRITE ACC-REC                                                       ELSE DISPLAY "TRANSACTION CODE ERROR, CODE IS: ", TCODE.                                                                                   *************************************************************           * THIS PROCEDURE IS USED TO ADJUST THE BALANCE OF THE ATM FILE   

......*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+...       * FOR THE AMOUNT OF MONEY IN ATM AFTER A TRANSACTION.                *************************************************************         550-ADJUST-ATM-BAL.                                                      IF TCODE = "W" THEN                                                     IF (ATMAMT < AMOUNT) THEN                                               PERFORM 250-NOT-ENOUGH-IN-ATM                                     ELSE                                                                    SUBTRACT AMOUNT FROM ATMAMT                                          REWRITE ATM-REC                                                ELSE IF TCODE = "D" THEN                                                ADD AMOUNT TO ATMAMT                                                 REWRITE ATM-REC                                                   ELSE DISPLAY "TRANSACTION CODE ERROR, CODE IS: ", TCODE.                                                                             *************************************************************        * THIS PROCEDURE IS USED IF THERE THE KEY VALUE THAT IS USED IS       * NOT FOUND IN THE ACCTS FILE.                                

......*. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7        *************************************************************            900-OOPS.                                                                   DISPLAY "INVALID KEY: ", ACCTN, " ACCOUNT FILE STATUS: ",                 STATUS-ERR1.                                                          CLOSE ATM-FILE.                                                         CLOSE ACC-FILE.                                                         PERFORM 999-SIGNAL-ESCAPE.                                              GOBACK.                                                                                                                                    *************************************************************           * THIS PROCEDURE IS USED IF THERE THE KEY VALUE THAT IS USED IS         * NOT FOUND IN THE ATM FILE.                                            *************************************************************            950-OOPS.                                                                   DISPLAY "INVALID KEY: ", ATMN, " ATM FILE STATUS: ",                       STATUS-ERR2.                                                         CLOSE ATM-FILE.                                             

......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++            CLOSE ACC-FILE.                                                    PERFORM 999-SIGNAL-ESCAPE.                                         GOBACK.                                                                                                                          *************************************************************       * SIGNAL ESCAPE TO THE APPLICATIONP                                *************************************************************         999-SIGNAL-ESCAPE.                                                                                                                        CALL "QMHSNDPM" USING SND-MSG-ID,                                                      SND-MSG-FILE,                                                      SND-MSG-DATA,                                                      SND-MSG-LEN,                                                       SND-MSG-TYPE,                                                      SND-PGM-QUEUE,                                                     SND-PGM-STACK-CNT,                                                 SND-MSG-KEY,                      

......-A+++B+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                 SND-ERROR-CODE.                               *DISPLAY RTN-MSG-ID.                                                    *DISPLAY RTN-DATA.                                                                                                                       



Software/Hardware used:
AS400 ILE COBOL
ASKED: November 8, 2009  11:32 PM
UPDATED: November 9, 2009  4:04 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

There are important things that you don’t show, and what you do show is almost unreadable.

However, it looks as if your trigger buffer has an 03-level item named RECORD-JUNK at the end of the 01-level item named PARM-1-AREA. And that’s going to be incorrect in many cases; you have it defined at a fixed location, but the location will change depending on a number of circumstances.

The error that you show is probably caused by the attempt to UNSTRING the incorrectly defined PARM-1-AREA into INPUT-RECORD. But without showing what INPUT-RECORD looks like, that’s just an educated guess.

If INPUT-RECORD only defines enough space to hold PARM-1-AREA through NEW-REC-NULL-LEN, the UNSTRING will probably be reliable. If INPUT-RECORD is longer than that, then errors such as CPF8E17 will show up at unpredictable times.

I can see that this is derived from the IBM example, but it has been modified and the modifications won’t work. The IBM example sets the addresses of the buffer record areas where your code assumes that the buffer record areas will always be at fixed memory locations in the linkage areas. They won’t be.

Follow what the IBM example does. In particular, look closely at the changes that you made. That’s where the problem is.

Tom

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
    Just wondering, did you create a trigger on the file and then add/change/delete (based on the trigger rules) a record from the file to "run an ILE Cobol Trigger program"? Phil
    48,595 pointsBadges:
    report
  • Saurater
    Hi , Philip After creating the file, JRN and JRNRCV, you create a program, like the one I have posted above,teh start STRCMTCTL, then add the program to the file with ADDPFTRG, then run it. The errors is raised at run time, when updating the file that triggers the program
    45 pointsBadges:
    report
  • Saurater
    Hi, Tom and Philip Thanks for you helps. I have found out the root cause. Just had to recompile the program with : Activation group . . . . . . . . ACTGRP > *CALLER A small change was also made to the PARM1 item. Sam Faraday
    45 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following