View previous topic :: View next topic
|
Author |
Message |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
Is there a way to obtain file information from inside a cobol program? Specifically, I'm looking to obtain the creation date of the file. I know I can access from inside an assembler program, but wasn't sure if there was a place that Cobol kept that stuff. |
|
Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3087 Location: NYC,USA
|
|
|
|
Easiest way is, add a Header to the file which contains Creation Date or add another step before Cobol routine executes which puts the creation date into another file and feed that to the Cobol routine. |
|
Back to top |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
How would you get it in assembler? Would the same method work for a COBOL program? |
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
Rohit Umarjikar wrote: |
Easiest way is, add a Header to the file which contains Creation Date or add another step before Cobol routine executes which puts the creation date into another file and feed that to the Cobol routine. |
yeah, that's not an option. The file does not originate from programs under our control, so adding the date to the file won't work. The other option would require operator intervention prior to the job running, also not an option. |
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
Robert Sample wrote: |
How would you get it in assembler? Would the same method work for a COBOL program? |
In BAL, when you open the file the file information is placed in the file definition area, which can be accessed. I don't know if that can be done in Cobol, which is why I am asking. |
|
Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
You could call IDCAMS from within your COBOL program and extract the information that you want from that. Or, if you don't like doing that then run the IDCAMS as a separate step and parse the output as yet another step.
But it is bad design if your dataset (not file) does not have control information on it especially when coming from external sources. There should be no problem raising a change request. In fact, if the auditors knew about it they would probably insist. |
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
Nic Clouston wrote: |
You could call IDCAMS from within your COBOL program and extract the information that you want from that. |
How do I do that?
The file is created on our system, but the application is a package, so we cannot make changes. |
|
Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Like I did for a PL/1 program - you read the manuals and try it out.
For the other concern - get whoever produces the dataset to 'massage' it after creation to add the required information. |
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
Nic Clouston wrote: |
Like I did for a PL/1 program - you read the manuals and try it out. |
If I had the manuals that tell that, I wouldn't have had to post. |
|
Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
The manuals are easily available on this forum and the internet in general. But they should be accessible to you on your intranet. |
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
Nic Clouston wrote: |
The manuals are easily available on this forum and the internet in general. But they should be accessible to you on your intranet. |
Thus far, on this forum, I've found other posts where they are actually trying to help the poster with links to the information. Unfortunately, the links are no longer valid, and everyone says that LISTCAT cannot be called. |
|
Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10896 Location: italy
|
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
enrico-sorichetti wrote: |
http://www-03.ibm.com/systems/z/os/zos/library/bkserv/v2r2pdf/#IKJ |
Thanks. I found this on another forum, apparently there is a catalog search routine (IGGCSI00) that returns all the information I could get in BAL.
Here is the link to the site that has the instructions.
mainframe.elevengestures.com/catalog-search-iggcsi00-from-cobol/ |
|
Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3087 Location: NYC,USA
|
|
|
|
I'm unsure, but check upon DSINFO too and may be less complex than IGGCSI00 structure. |
|
Back to top |
|
 |
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
pahiker wrote: |
Nic Clouston wrote: |
The manuals are easily available on this forum and the internet in general. But they should be accessible to you on your intranet. |
Thus far, on this forum, I've found other posts where they are actually trying to help the poster with links to the information. Unfortunately, the links are no longer valid, and everyone says that LISTCAT cannot be called. |
Technically, LISTCAT can be called as a TSO command processor, but doing that from Cobol is probably beyond the skill set of a neophyte.
This link - publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DGT2I2A1/D.0?SHELF=dgt2bkb2&DT=20120126090739 - will take you directly to the instructions to invoke IDCAMS from a program. Technically it's slightly out of date, but I think it will still work. It hasn't changed in years. IGGCSI00 may be easier. I've done IDCAMS before from Assembler.
This is the code to get the creation date directly. It's callable from Cobol. I think the routine is Language Environment compatible, though not LE compliant. It's followed by a unit test routine that can run in TSO.
Code: |
GETCRDT RSECT
GETCRDT AMODE 31
GETCRDT RMODE ANY
PUSH PRINT
PRINT NOGEN
DSCB DSECT
IECSDSL1 1
DCBD DSORG=QS,DEVD=DA
WA DSECT
DWORK DS D
OPARMS RDJFCB *-*,MF=L
OPARM EQU OPARMS,*-OPARMS
ADCBS DCB DSORG=PS,MACRF=R,DDNAME=FILLMEIN,EXLST=*-*
ADCB EQU ADCBS,*-ADCBS
XLIST DS A
JFCB DS 0XL176
IEFJFCBN ,
CAMLSTS CAMLST SEARCH,*-*,*-*,*-*
CAMLST EQU CAMLSTS,*-CAMLSTS
DSCBAREA DS XL140,0D
WASIZE EQU *-WA
POP PRINT
EJECT
GETCRDT RSECT
USING WA,8
USING IHADCB,ADCB
USING DSCB,DSCBAREA-(DS1FMTID-DSCB)
USING *,9
SAVE (14,12),,'GETCRDT &SYSDATE &SYSTIME'
LR 9,15
LM 2,4,0(1)
LA 7,WASIZE
GETMAIN R,LV=(7)
LR 6,1
LR 8,1
SR 15,15
MVCL 6,14
MVC ADCB,MASTDCB
MVC DCBDDNAM,0(2)
MVC OPARM,MASTOPEN
MVC CAMLST,MASTCAML
LA 0,XLIST
ICM 0,B'1000',DCBEXLST
ST 0,DCBEXLST
LA 0,JFCB
ST 0,XLIST
MVI XLIST,X'80'+7
RDJFCB ADCB,MF=(E,OPARM)
LA 0,4
LTR 15,15
BNZ EXIT
LA 15,JFCBDSNM
LA 0,JFCBVOLS
LA 1,DSCBAREA
STM 15,1,CAMLST+4
SR 0,0
OBTAIN CAMLST
LA 0,8
LTR 15,15
BNZ EXIT
SR 0,0
SR 1,1
IC 0,DS1CREDT
MHI 0,1000
ICM 1,B'0011',DS1CREDT+1
AR 1,0
CVD 1,DWORK
MVC 0(4,3),DWORK+4
SR 0,0
EXIT ST 0,0(,4)
LA 0,WASIZE
FREEMAIN R,LV=(0),A=(8)
RETURN (14,12)
PUSH PRINT
PRINT NOGEN
MASTOPEN RDJFCB *-*,MF=L
MASTDCB DCB DSORG=PS,MACRF=R,DDNAME=FILLMEIN,EXLST=*-*
MASTCAML CAMLST SEARCH,*-*,*-*,*-*
POP PRINT
DC 0D'0'
END
TEST CSECT
USING *,12
SAVE (14,12),,*
LR 12,15
LA 15,SAVEAREA
ST 13,4(,15)
ST 15,8(,13)
LR 13,15
CALL GETCRDT,(DDNAME,CRDT,RC)
L 15,RC
CVD 15,64(,13)
UNPK LRC,64(8,13)
OI LRC+L'LRC-1,X'F0'
UNPK LCRDT,CRDT
OI LCRDT+L'LCRDT-1,X'F0'
LA 0,L'MSG
LA 1,MSG
TPUT (1),(0),R
L 13,4(,13)
RETURN (14,12),T,RC=0
SAVEAREA DC 9D'0'
RC DC F'0'
CRDT DC PL4'0'
MSG DC 0C'DDNAME=DDDDDDDD RC=NN CREDT=CYYDDD',C'DDNAME='
DDNAME DC CL8'SYSHELP',C' RC='
LRC DC C'NN',C' CREDT='
LCRDT DC C'CYYDDD',0D'0'
END TEST |
|
|
Back to top |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
IGGCSI00 can be called from COBOL and DSCRDT2 is the field name for the create date. The format requires some conversion to get a usable date but the manual describes the format quite well. Googling iggcsi00 cobol returns about 335 results and one of them has sample COBOL code. |
|
Back to top |
|
 |
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
One caution: the date you get from IGGCSI00 or IDCAMS is the date the data set was cataloged, which may not be the date the data set was created. |
|
Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
I never mentioned calling LISTCAT - I said IDCAMS. The links to the manuals are not invalid - I have just successfully navigated to the COBOL llanguge reference manual although I did not spot the AMS (iei IDCAMS) manual there so you would have to try the IBM documentation site. |
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
Thanks everyone. I got CSI working, but it is a bit of coding. I tried looking for DSINFO, as Rohit suggested, but every link I come up with from IBM.01 goes to "bad link" pages, I'm guessing that they are no longer supporting the call? Haven't found anyone who posted actual code on using it. |
|
Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Quote: |
I tried looking for DSINFO |
Not very hard obviously. I put DSINFO into Google and the very first link took me to the information.[/quote] |
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
Nic Clouston wrote: |
Quote: |
I tried looking for DSINFO |
Not very hard obviously. I put DSINFO into Google and the very first link took me to the information. |
Gee, I guess our searches are different. When I put DSNINFO in my first few results are:
DNA info in NY
Micorsoft sp_dsninfo
REXXTOOLS
Microsoft
WEB SQL
Microsoft
So, maybe I did try hard, because I had to go through several pages before I came up with the links I did. |
|
Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10896 Location: italy
|
|
|
|
if You had used DSINFO instead of DSNINFO ...
my first two pages ( after that I got bored )
reported only TSO/ISPF/REXX/zOS related links |
|
Back to top |
|
 |
pahiker
New User
Joined: 10 Aug 2012 Posts: 51 Location: USA
|
|
|
|
enrico-sorichetti wrote: |
if You had used DSINFO instead of DSNINFO ...
my first two pages ( after that I got bored )
reported only TSO/ISPF/REXX/zOS related links |
yeah, that made a difference, now I have
dsinfo.com
citrix
dsinfosolutions.com
3dsinfo.com
microsoft
etc.
Thanks for all the help. |
|
Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10896 Location: italy
|
|
|
|
why not add something IBM specific DSINFO TSO ? |
|
Back to top |
|
 |
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
Another example of how critical correct spelling is. |
|
Back to top |
|
 |
|
|