Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way within COBOL to obtain external file name? 1

Status
Not open for further replies.

dchristensen

IS-IT--Management
Sep 22, 2002
74
US
Is there a way that I can access the external file name of a file used within my COBOL program? My assign statement uses soemthing like UT-S-INFILE. I tried using ACCEPT/DISPLAY syntax like you would with Micro Focus COBOL on a PC, but that syntax isn't allowed in Z/OS COBOL.

If there is a system function I can call to get the information, please pass that along.
 
I assume you are on the mainfraim. The system function is RDJFCB (Read Job File Control Block). I don't know if you can access it from COBOL. Many years ago, I wrote an assembler sub-program that I could call from COBOL to do this.
 
The french program claims in its comments that it search in the MVS memory the job name and all DDNAMEs of the current program's files.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Cant you just make some job control code that runs the program and just edit it before you run the job? That is how we use to accept parameters on our Mainframe. It actually used Accept but it was from the JCL. Dont know how this works in an MVS Environment. We used VSE/ESA.

If you do not like my post feel free to point out your opinion or my errors.
 
Try this...

Write a subroutine with this code...
LINKAGE SECTION.
01 L-FD-DATA.
03 FILLER PIC X(40).
03 L-FD-NAME PIC X(08).
01 L-FILE-NAME PIC X(08).
PROCEDURE DIVISION USING L-FD-DATA L-FILE-NAME.
1000-GET-NAME.
MOVE L-FD-NAME TO L-FILE-NAME.
GOBACK.

Your program will then issue a call with the file name as the first parameter and an 8-byte area as the second. It will return the assignment (external) name.

SELECT I-DATA-FILE ASSIGN TO INFILE.
.
.
.
03 SA-FILE-NAME PIC X(08).
.
.
.
CALL 'subprog' USING I-DATA-FILE SA-FILE-NAME.

Upon return SA-FILE-NAME contains the value 'INFILE '.
 
Thanks to everyone for responding. I've been out of town for a few days and this is my first chance to look at postings to the thread.

I have a program that will be used multiple times during nightly processing to access files using a common record format to split the files into collections of related records. I want to be able to generate log records from each run that identify the physical file processed during each invocation of the program. Hopefully one of the programs posted will allow me to do that programmatically.

Thanks again for your time and trouble.

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top