Posted: Wed Oct 15, 2003 10:52 am Post subject: Checkpoint-Commit-Restart
Hi Friends,
Thanks a lot! Kolusu for your great answers for my previous questions.
Please provide me the code for Checkpoint-Commit Restart for Cobol-Db2 Program.
Whether I need to create separate table for storing the values of the counter which I am incrementing and storing after each commit.
Or else Storing in a File will do. Some persons told that it is not advisable to store it in File. But here, Creating a Separate table will be a big task it seems and will be done only when required and if there is no other option.
Please let me also know the required fields to be put in that.
I thought of adding following Columns:
Counter, Program-Name, Para-Name, Timestamp
This Counter will be used to start the Program next time when it abends in between.
Previously the programs where taking very less time.So I never used the Commit-Retart logic and now this Checkpoint needs to be implemented as this Program is taking long time.
I got some Cobol-Db2-IMS Program which I tried to implement and I was not able to understand the IMS but compiled, binded my program with that properly but run time(S04C ERROR)error was there(I created similar PSB and all).
As I was not knowing much about IMS and there are IMS input file in that and I was using Flat Files for my Program. So it might be the problem.
For Restarting the Program from the abend,
I also want to know how to avoid the read (Input /Output Operation) till that pointer for which I have read already and inserted, if it is PS File as it is not indexed one.
and also for the table, I am using the cursor to take the records from the table but next time when it is restarted I want to avoid fetching the n no. of records which I already have fetched and updated.
Please let me know.
Thanks in advance. _________________ Have a Great Day.
Thanks & Regards,
Jai
Since you are using IMS for check point restarting, there are some things which need to be done before you run your program.
1.Create the PSB and it should be gened by your local-dba.The DBA will also do the ACBGEN.
PSB is a control block that contains all database program communication blocks (DB PCB) that exist for a single application program. DB PCBs define which segments in a database an application can access.
In your case you will GSAM databases since your input file is a flat file.In PSB definition you will define your GSAM databases as follows
Code:
PCB TYPE=GSAM,DBDNAME=INPUT1,PROCOPT=GS
....
PCB TYPE=GSAM,DBDNAME=OUTPUT1,PROCOPT=LS
...
Notice the PROCOPT on the definition , GS is used for input files so as to read sequentially LS is used for output files so as to load sequentially
Now the programming part.
There will be checkpoint-save-area in the program. so you include all your variables in that area.If your input file is the driver file for the program then I would recommend that you
declare the file in there.
Code:
01 CHECKPOINT-RESTART-ID PIC X(12) VALUE SPACES.
01 CHECKPOINT-MAX-SEG-LENGTH PIC S9(8) COMP VALUE +2000.
01 CHECKPOINT-LENGTH PIC S9(8) COMP.
01 CHECKPOINT-START-AREA PIC X(32) VALUE
'XXXX CHECKPOINT START AREA XXXX'.
01 CHECKPOINT-START PIC X(08) VALUE 'XXXXXXXX'.
01 CHECKPOINT-ID.
03 CHECKPOINT-SYSTEM PIC X(03) VALUE '???'.
03 CHECKPOINT-INCREMENT PIC 9(05) VALUE ZERO.
01 CHECKPOINT-COUNT PIC 9(05) VALUE ZERO.
01 CHECKPOINT-COUNT-TOT PIC 9(05) VALUE ZERO.
PROCEDURE DIVISION USING PCB-IO
PCB-IO-ALT
D02PCHKP-PCB
INPUT1-PCB
OUTPUT1-PCB
PERFORM 5000-GET-RESTART-ID
IF CHECKPOINT-RESTART-ID = SPACES
PERFORM 10000-START-FROM-BEGINNING
ELSE
PERFORM 15000-RESTART-FROM-CHECKPOINT
END-IF
PERFORM 20000-MAIN-PROCESS UNTIL S-INPUT1-EOF = 'Y'
.
05000-GET-RESTART-ID.
***************************************************************
** THE FOLLOWING PROCESS GETS THE RESTART-ID **
***************************************************************
CALL 'TSIMSLEN' USING CHECKPOINT-START
CHECKPOINT-END
CHECKPOINT-LENGTH
MOVE SPACES TO CHECKPOINT-RESTART-ID
CALL 'CBLTDLI' USING XRST
PCB-IO
CHECKPOINT-MAX-SEG-LENGTH
CHECKPOINT-RESTART-ID
CHECKPOINT-LENGTH
CHECKPOINT-START
EVALUATE PCB-IO-STATUS
WHEN ' '
CONTINUE
WHEN OTHER
MOVE '05000' TO WS-ABEND-PARAGRAPH
MOVE XRST TO DLI-ERROR-FUNCTION
MOVE PCB-IO-LTERM-NAME TO DLI-ERROR-DBD
MOVE PCB-IO-STATUS TO DLI-ERROR-STATUS
MOVE PCB-IO-USERID TO DLI-ERROR-SEG
PERFORM ABEND
END-EVALUATE
.
10000-START-FROM-BEGINNING.
***************************************************************
** THE FOLLOWING PROCESS '10000-START-FROM-BEGINNING' **
** WILL BE EXECUTED AT NORMAL START. **
***************************************************************
DISPLAY 'STARTING FROM BEGNINNING'
MOVE FUNCTION CURRENT-DATE (1: 8) TO CHECKPOINT-DATE
ACCEPT CHECKPOINT-TIME FROM TIME
PERFORM 50000-READ-INPUT-FILE
.
15000-RESTART-FROM-CHECKPOINT.
***************************************************************
* THE FOLLOWING PROCESS '16000-RESTART-FROM-CHECKPOINT' **
* WILL BE EXECUTED AT RESTART. **
***************************************************************
DISPLAY 'THE PROGRAM RESTARING FROM CHECKPOINT ID:' CHECKPOINT-RESTART-ID
PERFORM 50000-READ-INPUT-FILE
.
20000-MAIN-PROCESS.
***************************************************************
* THE FOLLOWING PROCESS IS BUSINESS PROCESSING SECTION **
***************************************************************
PERFORM 60000-OPEN-CURSOR
PERFORM 65000-FETCH-CURSOR
PERFORM UNTIL S-EOF-CURSOR = 'Y'
PERFORM 30000-BUSINEESS-PROCESS
PEFORM 55000-WRITE-OUTPUT-RECORD
PERFORM 65000-FETCH-CURSOR
END-PERFORM
PERFORM 70000-CLOSE-CURSOR
PERFORM 75000-TAKE-A-CHECKPOINT
PERFORM 80000-INIT-WORKING-AREAS
PERFORM 50000-READ-INPUT-FILE
.
50000-READ-INPUT-FILE.
*****************************************************************
* THIS PARAGRAPH IS PERFORMED TO READ A RECORD FROM THE INPUT *
* DRIVER FILE. *
*****************************************************************
CALL 'CBLTDLI' USING GN
INPUT1-PCB
INPUT-DRIVER-REC
EVALUATE INPUT1-STATUS
WHEN SPACES
MOVE INPUT-KEY TO W-INPUT-KEY
ADD +1 TO A-CP-INPUT-RECS-READ
WHEN 'GB'
MOVE 'Y' E TO S-INPUT-EOF
WHEN OTHER
MOVE 'IMS' TO WS-ABEND-TYPE
MOVE '50000' TO WS-ABEND-PARAGRAPH
MOVE 'GN' TO DLI-ERROR-FUNCTION
MOVE INPUT1-STATUS TO DLI-ERROR-STATUS
MOVE INPUT1-DBD-NAME TO DLI-ERROR-DBD
MOVE INPUT1-SEG-NAME TO DLI-ERROR-SEG
MOVE INPUT1-SEG-LEVEL
TO DLI-ERROR-LEVEL
MOVE INPUT1-KEY-FEEDBACK
TO DLI-ERROR-KEY
PERFORM ABEND
END-EVALUATE
.
Thanks a lot! for such a detailed explanation.
Your Code seems to be somewhat similar to the code which I got, so didn't changed that as it would take time for me to change again.
But PSB part is different as the code which I got involves input from GSAM FIle and inserting into the DB2 Table.
It is like below:
***************************** Top of Data ******************************
TITLE 'ASSEMBLE OF PSBNAME=CMTBL '
* DSNAME=IMSVS.IMSN.PSBLIB
* VOL=ITSA01
***********************************************************************
* PCB NUMBER 1 GSAM NUMBER 1
***********************************************************************
PCB TYPE=GSAM, C
NAME=GSM0601, C
PROCOPT=GS
PSBGEN PSBNAME=CMTBL, C
LANG=ASSEM, C
CMPAT=YES
END
**************************** Bottom of Data ****************************
What I did for my Program is just changed the name of PSBNAME
But as I have input as Flat Files , I think I am getting S04C error. I couldn't proceed further.
You also suggested the code for PSB as
ode:
PCB TYPE=GSAM,DBDNAME=INPUT1,PROCOPT=GS
....
PCB TYPE=GSAM,DBDNAME=OUTPUT1,PROCOPT=LS
...
I am confused here as all are Type=GSAM
and mine is Flat File.
Whether this is necessary for just including Commit-Restart Logic.
Or please send me the code for Normal Cobol-DB2 Program's Checkpoint-commit-restart.
Please let me know.
Thanks in advance. _________________ Have a Great Day.
Thanks & Regards,
Jai
GSAM is a very much similar to a regular sequential file which has no segments, no keys, and no parentage.
so you can give your flat file to the ddname GSM0601 and to read it follow 50000 paragraph in my example.Since you do not have any output file you don't need the GSAM DATABASE declaration OUTPUT1.
Before you run your program, you need to make changes to your PSB.You need to change your the 3rd line from bottom to refer cobol as language.once you change it your DBA must re-gen the psb.You can remove the reference to C language if you are not using it.
I thought to implement the cobol or DB2 stuff for commit - restart but some body told that in IMS it takes care of positioning the cursor to the record where it abended (for input Flat Files)so suggested to follow that. But getting stuck up at run time. Please help me.
That is not the reference to C language but the Continuation Character at end, While Copying it just merged with the other characters.
I am getting the User Abend U3057.
Code:
**************
CEE3250C The system or user abend U3057 R=NULL was issued.
From compile unit CMTBL1 at entry point CMTBL1 at statement 1640 at compile unit offset +00002EAA at address
3F05E67A.
**************
And at statement 1640 the sentence is as follwos:
001640 1 CALL 'DSNHLI' USING SQL-PLIST2
This abend mainly tells for the IMS-DB2 Connection Problem.
Compiling and binding is fine and while running it is giving this error.
While Compiling, I gave IMS Attach as 'Y' in changeman.
Ravikumar,
Please find below the JCL
**********************
*****
JOB
*****
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Mon Oct 27, 2003 5:51 am Post subject:
Jai,
check if you binding the program to the correct region.If you are indeed binding to the correct region , then check CLASS=0 in your job card is attached to DB2.
Also shouldn't you be running the program in BMP mode? i.e
Joined: 29 Jun 2004 Posts: 106 Topics: 41 Location: Bangalore, INDIA
Posted: Tue Nov 09, 2004 4:49 am Post subject:
Hi Board,
Thanks to Kolusu for giving his strong support for updating our skills. In our Installation we are having BMP jobs to insert the Data into IMS Database. The data will be supplied through the GDG Version File. CHECKPOINT and RESTART Logic have been implemented in these UPLOADING COBOL Programs.
If there is any abend occurs while uploading the data then while restarting the JOB again we will take the last checkpoint and pass it to the DFSRRC00 as a PARM and restart it.
But here I have doubt that when HALF of the File have been read and it has been uploaded to IMS Database. Then it is abended. When we are restarting it again is that file needs to Re-read again to reach to the point where it is abended. Otherwise automatically it will be handled through IMS itself. Please clarify. _________________ Best Regards,
----------------
Rammohan Pabba
Software Engineer
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Tue Nov 09, 2004 5:52 am Post subject:
Ramu_mohan21,
Quote:
But here I have doubt that when HALF of the File have been read and it has been uploaded to IMS Database. Then it is abended. When we are restarting it again is that file needs to Re-read again to reach to the point where it is abended. Otherwise automatically it will be handled through IMS itself. Please clarify
Are you reading the GDG as a GSAM database or a normal sequential file? If it is GSAM database then IMS automatically maintains pointers and subsquent reads will result in reading the key after the last checkpoint.
If you are reading the GDG as a flat file then you need to code yourself the logic to store the checkpoint key and re-position your file after the abend, while restarting.
Joined: 29 Jun 2004 Posts: 106 Topics: 41 Location: Bangalore, INDIA
Posted: Tue Nov 09, 2004 6:46 am Post subject:
Hi Kolusu,
Quote:
Are you reading the GDG as a GSAM database or a normal sequential file?
Please can you tell me that How can we distinguish Reading GDG as a GSAM Database (or) Normal Sequential File. (Please don't mind if it is a fundamental doubt)
I feel that in our installaction we are using GDG as a normal sequential file. But I am not sure. I will let you know very soon. _________________ Best Regards,
----------------
Rammohan Pabba
Software Engineer
Joined: 29 Jun 2004 Posts: 106 Topics: 41 Location: Bangalore, INDIA
Posted: Tue Nov 09, 2004 6:50 am Post subject:
Hi Kolusu,
Quote:
If you are reading the GDG as a flat file then you need to code yourself the logic to store the checkpoint key and re-position your file after the abend, while restarting.
If programmer explicitly using this logic within in the program itself what is the use of Checkpoint-Restart Logic. I mean this logic can be utilized ONLY to store the required working storage section variable to the log file(In the case of flat file). Am I Right? _________________ Best Regards,
----------------
Rammohan Pabba
Software Engineer
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Tue Nov 09, 2004 9:01 am Post subject:
ramu_mohan21,
Quote:
Please can you tell me that How can we distinguish Reading GDG as a GSAM Database (or) Normal Sequential File. (Please don't mind if it is a fundamental doubt)
Look at the read statement for the file in question. If it is using an IMS call then, it is a GSAM database
EX:
Code:
CALL 'CBLTDLI' USING GN
JCL-DDNAME-PCB
RECORD-LAYOUT
If the program is reading the file using the regular cobol read as shown below then you are reading the file as a flat file
Code:
READ INPUT-FILE
AT END
MOVE C-TRUE TO S-EOF-INPUT-FILE
END-READ
Quote:
If programmer explicitly using this logic within in the program itself what is the use of Checkpoint-Restart Logic. I mean this logic can be utilized ONLY to store the required working storage section variable to the log file(In the case of flat file). Am I Right?
Well the programmer can code the checkpoint-restart logic and store the variables. But you will have a lot of overhead.
Ex: program is reading 4 files with 5 million in each file and writting out another 5 files.
Now let us say the program abended after processing 4.5 million. Now since you stored the last key read you need to open all the files once again and just keep on reading the 4.5 million records once again from the beginning.
Handling the output files is much more difficult. you need to delete the output records which are written from the last checkpoint to the record where your program abended. Let us say your commit is set for every 1000 records read. Now your program reads in a record and does some calculations and writes out the record. Now your program abended in record # 1800, you need to delete all the records from 1001 to 1799 at the time of restart as you saved the key after commiting for every 1000 records.
Joined: 29 Jun 2004 Posts: 106 Topics: 41 Location: Bangalore, INDIA
Posted: Wed Nov 10, 2004 8:03 am Post subject:
Hi Kolusu,
Thank you very much for giving clear explanation. I have got very good concept. I checked in our installaction that we are using the GDG Version as a GSAM file. _________________ Best Regards,
----------------
Rammohan Pabba
Software Engineer
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum