View previous topic :: View next topic |
Author |
Message |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Fri May 02, 2008 1:14 pm Post subject: retrieve input file creation date from COBOL program |
|
|
Hello,
A co-worker asked me today if there is a way to find out what the creation date is of a file being pulled into a DD in a COBOL program.
I told him that as far as I know, there isn't a way to do it directly from COBOL. The only thing he could do is run a LISTVTOC or LISTCTLG step prior to executing the COBOL program and feed the listing from those utilities into the COBOL program.
Does anyone have any ideas ?
Thanks... |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Fri May 02, 2008 3:43 pm Post subject: |
|
|
Thanks...
Actually I did find that document and I did show it to him....
I think the problem might be that he needs to know exactly 'which' dataset is allocated to his DDNAME. I think we may have a utility to do that, though.
Once we get a handle to the dataset name, then I'm thinking that calling out to IDCAMS would then give us access to the information he's looking for....
I'll check back later. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
|
Posted: Fri May 02, 2008 6:41 pm Post subject: |
|
|
tcurrier,
Some time back I had a cobol program which reads the control blocks and displays the ddname info. Here is the code and see if it works. (I haven't used for a long time)
The main program which calls the subroutine DDNAME by passing the DDNAME
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. MAINDD.
AUTHOR. KOLUSU.
DATE-COMPILED.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INPUT-FILE
ASSIGN TO INDD
ORGANIZATION IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD INPUT-FILE
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS IN-REC.
01 IN-REC PIC X(80).
WORKING-STORAGE SECTION.
01 WS-PGM PIC X(8) VALUE 'DDNAME'.
01 GET-COMM-AREA.
10 GET-JOB-NAME PIC X(08).
10 GET-STEP-NAME PIC X(08).
10 GET-DD-NAME PIC X(08).
10 GET-DS-NAME PIC X(44).
10 GET-GDG-OR-MEMBER PIC X(08).
10 GET-CATALOG-IND PIC X(01).
88 GET-FILE-IS-CATALOGED VALUE 'Y'.
10 GET-FILE-TYPE PIC X(01).
88 GET-FILE-IS-GDG VALUE 'G'.
88 GET-FILE-IS-JES VALUE 'J'.
88 GET-FILE-IS-PDS VALUE 'P'.
88 GET-FILE-IS-REGULAR VALUE 'R'.
10 GET-VOLUME-COUNT PIC 9(01).
10 GET-VOLUMES PIC X(30).
PROCEDURE DIVISION.
MOVE 'INDD' TO GET-DD-NAME.
CALL WS-PGM USING GET-COMM-AREA.
DISPLAY 'THE JOBNAME IS : ' GET-JOB-NAME
DISPLAY 'THE STEPNAME IS : ' GET-STEP-NAME
DISPLAY 'THE DDNAME IS : ' GET-DD-NAME
DISPLAY 'THE DSNAME IS : ' GET-DS-NAME
DISPLAY 'THE GDG OR MEM IS : ' GET-GDG-OR-MEMBER.
DISPLAY 'THE CATALOG IND : ' GET-CATALOG-IND
DISPLAY 'THE FILETYPE IS : ' GET-FILE-TYPE
DISPLAY 'THE VOLUME COUNT : ' GET-VOLUME-COUNT
DISPLAY 'THE VOLUMES ARE : ' GET-VOLUMES
GOBACK.
/* |
The subprogram which gets the actual DD info
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. DDNAME.
AUTHOR. KOLUSU.
*****************************************************************
** **
** THE PROGRAM RETRIEVES THE PASSED DDNAME INFORMATION FROM **
** THE CONTROL BLOCKS AND RETURN THE VALUES TO THE CALLER. **
** **
** THIS PROGRAM ONLY CHECKS THE DDNAMES RELATED THE JOB STEP **
** AND ONLY GIVES THE FIRST DDNAME IN CASE OF CONCATENATED **
** DATASETS. **
** **
*****************************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 DDN-SUBSCRIPTS-POINTERS.
10 DDN-TCB-ADDR-POINTER-X.
15 DDN-TCB-ADDR-POINTER POINTER.
10 DDN-TIOT-SEG-POINTER POINTER.
10 DDN-TIOT-BINARY REDEFINES DDN-TIOT-SEG-POINTER
PIC S9(09) COMP.
10 DDN-JFCB-POINTER POINTER.
10 DDN-JFCB-X REDEFINES DDN-JFCB-POINTER.
15 FILLER PIC X(01).
15 DDN-JFCB-LOWER-3 PIC X(03).
01 WORK-FIELDS.
10 WORK-BINARY-2 PIC S9(04) COMP VALUE ZERO.
10 FILLER REDEFINES WORK-BINARY-2.
15 WORK-BINARY-2L PIC X(01).
15 WORK-BINARY-2R PIC X(01).
01 S-MAIN-PROCESS-DONE PIC X(01) VALUE 'N'.
LINKAGE SECTION.
01 LINK-COMM-AREA.
10 LINK-JOB-NAME PIC X(08).
10 LINK-STEP-NAME PIC X(08).
10 LINK-DD-NAME PIC X(08).
10 LINK-DS-NAME PIC X(44).
10 LINK-GDG-OR-MEMBER PIC X(08).
10 LINK-CATALOG-IND PIC X(01).
10 LINK-FILE-TYPE PIC X(01).
10 LINK-VOLUME-COUNT PIC 9(01).
10 LINK-VOLUMES PIC X(30).
01 L02-TCB-POINTER POINTER.
01 L03-TCB.
10 FILLER PIC X(012).
10 L03-TIOT-POINTER POINTER.
01 L04-TIOT.
10 L04-JOB-NAME PIC X(08).
10 L04-STEP-NAME PIC X(08).
01 L04-TIOT-START PIC X(24).
01 L04-TIOT-SEGMENT.
10 L04-TIOT-LENGTH PIC X(01).
10 FILLER PIC X(03).
10 L04-DD-NAME PIC X(08).
10 L04-JFCB-ADDRESS PIC X(03).
01 L05-JFCB.
10 FILLER PIC X(16).
10 L05-DS-NAME PIC X(44).
10 L05-GDG-OR-MEMBER PIC X(08).
10 L05-DMI-BYTE PIC X(01).
10 FILLER PIC X(33).
10 L05-DSTYPE-BYTE PIC X(01).
10 FILLER PIC X(30).
10 L05-VOLUME-COUNT-BYTE PIC X(01).
10 L05-VOLUME-LIST PIC X(30).
PROCEDURE DIVISION USING LINK-COMM-AREA.
PERFORM 1000-INIT-VALIDATE-INPUT
PERFORM UNTIL S-MAIN-PROCESS-DONE = 'Y'
PERFORM 2000-SET-UP-ADDRESS
PERFORM 3000-GET-DD-INFO
END-PERFORM
GOBACK.
1000-INIT-VALIDATE-INPUT.
****************************************************************
** INITIALIZE AND VALIDATE THE INPUT PARMS **
****************************************************************
INITIALIZE LINK-DS-NAME
LINK-GDG-OR-MEMBER
LINK-CATALOG-IND
LINK-FILE-TYPE
LINK-VOLUME-COUNT
LINK-VOLUMES
IF LINK-DD-NAME = SPACES OR LOW-VALUES OR HIGH-VALUES
DISPLAY 'SUPPLY PROPER DDNAME '
MOVE 'Y' TO S-MAIN-PROCESS-DONE
END-IF
.
2000-SET-UP-ADDRESS.
****************************************************************
** SET UP THE ADDRESS. **
****************************************************************
MOVE X'0000021C' TO DDN-TCB-ADDR-POINTER-X
SET ADDRESS OF L02-TCB-POINTER TO DDN-TCB-ADDR-POINTER
SET ADDRESS OF L03-TCB TO L02-TCB-POINTER
SET ADDRESS OF L04-TIOT TO L03-TIOT-POINTER
MOVE L04-JOB-NAME TO LINK-JOB-NAME
MOVE L04-STEP-NAME TO LINK-STEP-NAME
MOVE LOW-VALUES TO DDN-JFCB-X.
SET ADDRESS OF L04-TIOT-START TO L03-TIOT-POINTER
SET DDN-TIOT-SEG-POINTER TO L03-TIOT-POINTER
ADD 24 TO DDN-TIOT-BINARY
SET ADDRESS OF L04-TIOT-SEGMENT TO DDN-TIOT-SEG-POINTER
.
3000-GET-DD-INFO.
****************************************************************
** LOOP THROUGH ALL POINTERS TO THE DD NAMES. **
** WHEN WE GET A MATCH, MOVE IN ALL THE FILE DATA AND EXIT. **
****************************************************************
PERFORM UNTIL L04-TIOT-LENGTH = LOW-VALUES
OR S-MAIN-PROCESS-DONE = 'Y'
MOVE L04-JFCB-ADDRESS TO DDN-JFCB-LOWER-3
SET ADDRESS OF L05-JFCB TO DDN-JFCB-POINTER
IF L04-DD-NAME = LINK-DD-NAME
MOVE L04-DD-NAME TO LINK-DD-NAME
MOVE L05-DS-NAME TO LINK-DS-NAME
MOVE L05-GDG-OR-MEMBER TO LINK-GDG-OR-MEMBER
IF L05-DMI-BYTE > X'79' AND < X'90'
MOVE 'Y' TO LINK-CATALOG-IND
ELSE
MOVE 'N' TO LINK-CATALOG-IND
END-IF
EVALUATE TRUE
WHEN L05-DSTYPE-BYTE = X'00'
MOVE 'R' TO LINK-FILE-TYPE
WHEN L05-DSTYPE-BYTE = X'01'
MOVE 'P' TO LINK-FILE-TYPE
WHEN L05-DSTYPE-BYTE = X'02'
MOVE 'G' TO LINK-FILE-TYPE
WHEN L05-DSTYPE-BYTE > X'19' AND
L05-DSTYPE-BYTE < X'30'
MOVE 'J' TO LINK-FILE-TYPE
WHEN OTHER
MOVE '?' TO LINK-FILE-TYPE
END-EVALUATE
MOVE L05-VOLUME-COUNT-BYTE TO WORK-BINARY-2R
MOVE WORK-BINARY-2 TO LINK-VOLUME-COUNT
MOVE L05-VOLUME-LIST TO LINK-VOLUMES
MOVE 'Y' TO S-MAIN-PROCESS-DONE
ELSE
ADD 20 TO DDN-TIOT-BINARY
SET ADDRESS OF L04-TIOT-SEGMENT
TO DDN-TIOT-SEG-POINTER
END-IF
END-PERFORM
.
/*
|
Hope this helps....
Cheers |
|
Back to top |
|
 |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Fri May 02, 2008 7:41 pm Post subject: |
|
|
I did find our program that does the same thing, thanks...
I got the call to IDCAMS from COBOL to work also....
I just need to convert the creation date that's being displayed by IDCAMS from Julian to Gregorian.
Otherwise, it's beautiful.... Absolutely beautiful ! |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
|
Posted: Sat May 03, 2008 1:26 pm Post subject: |
|
|
tcurrier wrote: |
I just need to convert the creation date that's being displayed by IDCAMS from Julian to Gregorian.
|
Cobol has the intrinsic functions which can convert a julian date to gregorian date and vice versa.
Check this link
http://www.mvsforums.com/helpboards/viewtopic.php?p=10911#10911
Hope this helps...
Cheers
kolusu |
|
Back to top |
|
 |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Sat May 03, 2008 2:53 pm Post subject: |
|
|
Kolosu,
Thanks for everything.... We have a vendor program that performs some more complicated date functions, but it's good to know that these intrinsic COBOL functions are available when I need them. They're a lot easier to use.
I'm trying out your DDNAME program now... |
|
Back to top |
|
 |
|
|