Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Obtaining file information
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
pahiker

New User


Joined: 10 Aug 2012
Posts: 28
Location: USA

PostPosted: Tue Sep 27, 2016 7:25 pm    Post subject: Obtaining file information
Reply with quote

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
View user's profile Send private message

Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue Sep 27, 2016 8:16 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Sep 27, 2016 8:22 pm    Post subject:
Reply with quote

How would you get it in assembler? Would the same method work for a COBOL program?
Back to top
View user's profile Send private message
pahiker

New User


Joined: 10 Aug 2012
Posts: 28
Location: USA

PostPosted: Tue Sep 27, 2016 8:23 pm    Post subject:
Reply with quote

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
View user's profile Send private message
pahiker

New User


Joined: 10 Aug 2012
Posts: 28
Location: USA

PostPosted: Tue Sep 27, 2016 8:25 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Sep 27, 2016 8:39 pm    Post subject:
Reply with quote

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
View user's profile Send private message
pahiker

New User


Joined: 10 Aug 2012
Posts: 28
Location: USA

PostPosted: Tue Sep 27, 2016 8:41 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Sep 27, 2016 8:43 pm    Post subject:
Reply with quote

Quote:
How do I do that?

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
View user's profile Send private message
pahiker

New User


Joined: 10 Aug 2012
Posts: 28
Location: USA

PostPosted: Tue Sep 27, 2016 8:45 pm    Post subject:
Reply with quote

Nic Clouston wrote:
Quote:
How do I do that?

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Sep 27, 2016 8:46 pm    Post subject:
Reply with quote

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
View user's profile Send private message
pahiker

New User


Joined: 10 Aug 2012
Posts: 28
Location: USA

PostPosted: Tue Sep 27, 2016 8:51 pm    Post subject:
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Sep 27, 2016 8:58 pm    Post subject:
Reply with quote

http://www-03.ibm.com/systems/z/os/zos/library/bkserv/v2r2pdf/#IKJ
Back to top
View user's profile Send private message
pahiker

New User


Joined: 10 Aug 2012
Posts: 28
Location: USA

PostPosted: Tue Sep 27, 2016 9:24 pm    Post subject:
Reply with quote

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.


http://mainframe.elevengestures.com/catalog-search-iggcsi00-from-cobol/
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Sep 28, 2016 12:21 am    Post subject:
Reply with quote

I'm unsure, but check upon DSINFO too and may be less complex than IGGCSI00 structure.
Back to top
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 461
Location: The Universe

PostPosted: Wed Sep 28, 2016 7:15 am    Post subject:
Reply with quote

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 - http://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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Sep 28, 2016 8:08 am    Post subject:
Reply with quote

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
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 461
Location: The Universe

PostPosted: Wed Sep 28, 2016 10:43 am    Post subject:
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Wed Sep 28, 2016 4:05 pm    Post subject:
Reply with quote

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
View user's profile Send private message
pahiker

New User


Joined: 10 Aug 2012
Posts: 28
Location: USA

PostPosted: Wed Sep 28, 2016 4:21 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Wed Sep 28, 2016 6:36 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us