View previous topic :: View next topic
|
Author |
Message |
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
Tried adding the LRECL and RECFM to the DYNAMIC ALLOCATION string but got error:
FILE-NAME = PMNF.S.MNFD498.AICTRANS.BKUP.G0167V00')
ENV-VAR PASSED STRING = DALDUMMY=DSN('PMNF.S.MNFD498.AICTRANS.BKUP.G0167V00') LRECL(083) RECFM(FB) SHR
IGZ0251W An invalid keyword LRECL was found at position 61 in environment variable DALDUMMY while processing file
DYNAMIC-OPEN-FILE in program DYNALLTS.
***** OPEN ERROR, DSN= PMNF.S.MNFD498.AICTRANS.BKUP.G0167V00 ; STATUS = 98
I think this happens because we can only change the DD-to-DSN connection by updating this environment variable; but the LRECL and the RECFM have nothing to do with this connection and environment variable.
On the other issue (how to get the dynamic-file length):
Using the LENGTH COBOL special register on the FD's "01" definitely works. The 01-area (-3:2) technique only works for variable but we have fixed in our example.
I think the way to do this is to change RECORDING MODE TO U (which means Fixed or Variable and DON'T supply BLOCK CONTAINS because RECFM=U cannot have BLOCK CONTAINS) and then convert the 01-area to an occurs from 0 to 65535 depending on a working-storage halfword binary field ( S9(4) BINARY ) which you'll load with the highest-possible number that can fit in a halfword which is 65535 because you want max allocation for the I/O and because you don't want SOC4.
Then after a good OPEN and a good READ, the working-storage halfword binary field will contain the actual record length which you can then DISPLAY.
Check it out and let me know...thanks. |
|
Back to top |
|
|
galecra
New User
Joined: 11 Sep 2006 Posts: 33
|
|
|
|
Wow!...
I'll try to understand and code what you tell me...
Besides, while I try the solution you provided me, I have another question:
How could be done to get the name of a dataset from a DD?
I mean, for example, if there is some JCL like:
//pgm exec pgm=DDLOOKUP
//FILEIN DD DSN=dataset1,DISP=SHR
//FILEIN DD DSN=dataset2,DISP=SHR
//FILEIN DD DSN=dataset3,DISP=SHR
//FILEIN DD DSN=dataset4,DISP=SHR
and then I would like DDLOOKUP to iterate thru each FILEIN DD, get the DSN name and process it...
How could I do this?... it's also some sorta of dynamic allocation I guess..
We have these kind of JCLs created "on the fly" by COBOL programs, where the number of DDs is undefined but depend on the COBOL program logic that creates the JCL ...
I hope you can understand me... |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
First a clarification on my previous post:
In the program, after you convert to RECFM un-blocked and to the occurs-depending on that I gave you, you can pass any fixed or variable file into your program and open it--I think I might have mislead you into thinking that the input file has to be RECFM=U--it does NOT have to be RECFM=U. RECFM un-blocked in the program is a technique so that any type of file can be OPENed and READ.
I will answer your question in my next post. |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
Answer:
This code will display all of your DD's dataset names.
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGXX.
INSTALLATION.
AUTHOR. KEVIN.
DATE-WRITTEN. 11/07/2005.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
01 TCB-ADDRESS-POINTER.
05 TCB-ADDR-POINTER USAGE IS POINTER.
01 TIOT-SEG-POINT.
05 TIOT-SEG-POINTER USAGE IS POINTER.
05 TIOT-SEG-PNT REDEFINES TIOT-SEG-POINTER
PIC S9(9) COMP.
01 JFCB-POINT.
05 JFCB-POINTER USAGE IS POINTER.
05 JFCB-POINT-RED REDEFINES JFCB-POINTER.
10 FILLER PIC X.
10 JFCB-LOW-3 PIC X(3).
LINKAGE SECTION.
01 DDNAME-DSN-ARRAY.
05 DDNAME-DSN OCCURS 100 TIMES INDEXED BY NDX1.
10 DDA-DDNAME PIC X(8).
10 DDA-DSN PIC X(44).
01 TCB-POINTER USAGE IS POINTER.
01 TCB.
05 FILLER PIC X(12).
05 TIOT-POINTER USAGE IS POINTER.
01 TIOT-START PIC X(24).
01 TIOT-SEG.
05 TIO-LEN PIC X.
05 FILLER PIC X(3).
05 DD-NAME PIC X(8).
05 JFCB-ADDR PIC X(3).
01 JFCB.
05 FILLER PIC X(16).
05 DS-NAME PIC X(44).
PROCEDURE DIVISION USING DDNAME-DSN-ARRAY.
MOVE LOW-VALUES TO JFCB-POINT.
MOVE X'0000021C' TO TCB-ADDRESS-POINTER.
SET ADDRESS OF TCB-POINTER TO TCB-ADDR-POINTER.
SET ADDRESS OF TCB TO TCB-POINTER.
SET ADDRESS OF TIOT-START TO TIOT-POINTER.
SET TIOT-SEG-POINTER TO TIOT-POINTER.
ADD 24 TO TIOT-SEG-PNT.
SET ADDRESS OF TIOT-SEG TO TIOT-SEG-POINTER.
SET NDX1 TO 1.
PERFORM UNTIL TIO-LEN = LOW-VALUES OR NDX1 > 100
MOVE DD-NAME TO DDA-DDNAME(NDX1)
MOVE JFCB-ADDR TO JFCB-LOW-3
SET ADDRESS OF JFCB TO JFCB-POINTER
MOVE DS-NAME TO DDA-DSN(NDX1)
DISPLAY DDA-DDNAME(NDX1) DDA-DSN(NDX1)
ADD 20 TO TIOT-SEG-PNT
SET ADDRESS OF TIOT-SEG TO TIOT-SEG-POINTER
SET NDX1 UP BY 1
END-PERFORM.
GOBACK. |
|
Back to top |
|
|
galecra
New User
Joined: 11 Sep 2006 Posts: 33
|
|
|
|
well... I'm really learning...
before go and paste the code in a program, I would like to understand what it is doing, so... :
what is the TCB?
what is the TIOT?
what is the JFCB?
what does it reference X'0000021C' address? why it is hardcoded-fixed? is it the TCB always there?
Sorry for to many questions!!... |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
galecra wrote: |
well... I'm really learning...
before go and paste the code in a program, I would like to understand what it is doing, so... :
what is the TCB?
what is the TIOT?
what is the JFCB?
what does it reference X'0000021C' address? why it is hardcoded-fixed? is it the TCB always there?
Sorry for to many questions!!... |
if you have searched before asking... don't be sorried for that.
is this the case? |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
I actually got this code from prior posts.
They are internal MVS Control Blocks/Structures.
Don't worry about all of this coding--this is a "tried and true" method of "dumping/displaying" all of your JCL's DD-DSN assignments--I myself have used it for many years--it's just a black box that is always guarenteed to work.
To answer your question:
TCB = Task Control Block
TIOT = Task Input-Output Table
JFCB = Job File Control Block
TCB+21C points to TIOT.
TIOT contains an array of DD names.
TIOT points to the JFCB.
JFCB contains an array of DSN names.
As we bump the TIOT and the JFCB, we extract the DD-to-DSN assignments from your JCL.
Again, don't worry--just use it--it's always guarenteed to work. |
|
Back to top |
|
|
galecra
New User
Joined: 11 Sep 2006 Posts: 33
|
|
|
|
Where can I look at in order to get the whole layout of these structures(TCB, TIOT, JFCB)? , I mean, some online documentation or book...
Also, what is the relation between these structures and PUTENV? , is PUTENV updating some of these structures? (I think ASSIGN TO DYNAFILE as an additional DD to the TIOT and the DSN of the dynamic file as added to a JFCB entry...)
See you, |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
MVS Data Areas manual.
I think there's no relationship between MVS-control-blocks and PUTENV as PUTENV's requirement is "FILE MUST NOT EXIST IN THE JCL" and the MVS-control-blocks method ONLY looks at the JCL (aka TIOT); however, I'm not sure.
PUTENV is updating the environment variable that corresponds to the DDNAME in the SELECT/ASSIGN clause.
I'm pretty sure that this environment variable INITIALLY points to a NON-JCL allocation.
However, I'm not sure if AFTER you have a successful PUTENV as to whether or not this allocation is "added" to the JCL (aka TIOT)--however I can check this out for you and get back to you ! |
|
Back to top |
|
|
galecra
New User
Joined: 11 Sep 2006 Posts: 33
|
|
|
|
I tried the record format = U way and I still get 39 error.
Here is my coding, perhaps I made something wrong:
SELECT DYNA-FILE ASSIGN TO DYNAMIC1
FILE STATUS WS-FS-DYNA-FILE.
FD DYNA-FILE
RECORDING MODE IS U
RECORD IS VARYING IN SIZE FROM 1 TO 32767 CHARACTERS
DEPENDING ON WS-DYNA-FILE-INDEX.
01 DYNA-FILE-REC.
10 DYNA-FILE-REC-BYTE PIC X(1) OCCURS 32767 TIMES
DEPENDING ON
WS-DYNA-FILE-INDEX.
10 WS-DYNA-FILE-INDEX PIC 9(5) BINARY VALUE 32767.
And this is the Info of the files I'm trying to open dynamically:
Management class . . : TSOSMAL Allocated cylinders : 1
Storage class . . . : TSO Allocated extents . : 1
Volume serial . . . : TSS508
Device type . . . . : 3390
Data class . . . . . : **None** Current Utilization
Organization . . . : PS Used cylinders . . : 1
Record format . . . : FB Used extents . . . : 1
Record length . . . : 80
Block size . . . . : 27920
1st extent cylinders: 1
Secondary cylinders : 10
Data set name type : SMS Compressible : NO
I didn't use 65535 as I got a compiler error telling that the maximum value can be 32767...
Thanks! |
|
Back to top |
|
|
galecra
New User
Joined: 11 Sep 2006 Posts: 33
|
|
|
|
Sorry , the FD statement is:
FD DYNA-FILE
RECORDING MODE IS U
RECORD IS VARYING IN SIZE FROM 1 TO 32767 CHARACTERS
DEPENDING ON WS-DYNA-FILE-INDEX.
01 DYNA-FILE-REC.
10 DYNA-FILE-REC-BYTE PIC X(1) OCCURS 1 TO 32767 TIMES
DEPENDING ON
WS-DYNA-FILE-INDEX. |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
Sorry...no time for this today...have some deadlines to meet. |
|
Back to top |
|
|
galecra
New User
Joined: 11 Sep 2006 Posts: 33
|
|
|
|
Were you able to to look at the file status 39 issue? ... any advice to get rid of it? |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
Still lots of deadlines now...will be busy all night and all weekend...this is the life of a programmer ! |
|
Back to top |
|
|
galecra
New User
Joined: 11 Sep 2006 Posts: 33
|
|
|
|
ok, thanks! ... I'll wait so...
Let me know if you need some help! :-) ... |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
It was the Holidays and I was away and on Jan 2nd we were off due to market closed due to Gerard Ford; and I just got back and caught up.
Change "RECORD IS VARYING IN SIZE FROM 1 TO 32767 CHARACTERS"
(which means ONLY VARIABLE) to "RECORD CONTAINS 1 to 32767 CHARACTERS" (which means FIXED or VARIABLE which is what RECORDING MODE U means); and then re-run--problem should disappear. |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
Actually I just did some testing:
- I tried that fix and I got same result: the file-status = 39
- then I tried many other coding permutations and kept getting file-status = 39
Maybe you can have multiple different sized "01"'s in the "FD". One of the "01"'s would be the actual size of your fixed or variable sized file and the other one would have the max of 32K. Then you'd use the 01-area
(-3:2) to dump the record-length for the variable file; and you'd use the LENGTH OF special register to dump the record-length for the fixed file.
Can you please try this and let me know ?
I think this would probably work but then it would be too hard-coded and not the dynamic solution that we both desire.
Let me know. Thanks. Take care. |
|
Back to top |
|
|
galecra
New User
Joined: 11 Sep 2006 Posts: 33
|
|
|
|
well,.. I'm trying to orginize my ideas...
Actually, I was able to open the file if the file has been created Record format = U , for example doing
FD DYNA-FILE
RECORDING MODE IS U ( RECORDING MODE IS V also worked)
RECORD CONTAINS 1 TO 32767 CHARACTERS.
01 DYNA-FILE-REC.
But I was not able to open the file when the file has been created Record format = VB , neither as
FD DYNA-FILE
RECORDING MODE IS V
RECORD IS VARYING FROM 1 TO 32767
DEPENDING ON
WS-DYNA-FILE-INDEX.
01 DYNA-FILE-REC-MIN PIC X(1).
01 DYNA-FILE-REC-MAX PIC X(32767).
01 DYNA-FILE-REC PIC X(80).
Indeed, if with some FD declaration I would be able to open fixed, with another FD would be able to open variable, and with another FD declaration would be able to open U , then I could code 3 different SELECT clauses and 3 different PUTENV , one for each FD type, and try opening the file with each one until one doesn't fail... But I was not able to open VB ... also if the file is fixed but record length declared in FD is different from the one the file has been created, 39 error also...
Really, I would like to open any kind of file, of any length, just with a FD declaration, (or as few FD declarations as possible) , so the program is all the dynamic as possible...
I thought that with a RECORDING MODE V , RECORD CONTAINS x TO y , would be possible to open either fixed or variable files...
Well, I'm learning about all this stuff, and keep trying...
Please let me know if you find something...
See you |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
This knowledge is way beyond an Applications Programmer's job but here are 2 design ideas (and I've only read about them but I have never have done them):
1. Search your shop to see if they have an assembler program that CALLs SVC99 and that accepts parms. Figure out how to pass it parms for DDNAME and DSNAME and for DISP=SHR. Then CALL it with parms and test the return-code coming back and only proceed if return-code is OK.
Issues:
a. Does this process replace the COBOL Select/Assign/FD/"01" and the COBOL OPEN ?
I'm not sure.
b. Can you perform a COBOL READ against this SVC99 Allocation ?
I'm not sure.
Note: If you cannot find this SVC99 assembler program in your shop: Search the TSOTIMES WebSite for an article that has the SVC99 assembler code and make your own.
*** OR if you cannot find this SVC99 assembler program, then do this ***
2. Search this site for how to CALL REXX from COBOL (use an IRXJCL REXX which doesn't require the ISPF/TSO platform to be setup, NOT the IRXEXEC REXX). Create a REXX that allocates an existing dataset via supplying DDNAME, DSNAME and DISP(SHR).
Issues:
a. Does this process replace the COBOL Select/Assign/FD/"01" and the COBOL OPEN ?
I'm not sure.
b. Can you perform a COBOL READ against this REXX Allocation ?
I'm not sure. |
|
Back to top |
|
|
ruhamah lam
New User
Joined: 23 Jan 2007 Posts: 1 Location: hong kong
|
|
|
|
May I ask if "IBM Enterprise COBOL for z/OS 3.4.1" have the "PUTENV".
I want to dynamic allocate a certain file from a list of files if condition fullfilled. Before, I write a PL/I program to do it, but now I need to rewrite it to COBOL.
How do I convert it. Do COBOL have file variable concept ?
The code is simplified as follows.
Thx a lot
===============================================
DCL (FILE01,FILE02,FILE03,FILE04,FILE05)
KEYED SEQUENTIAL INPUT RECORD FILE ENV(VSAM ...);
DCL FILEMT(MXFILENO) FILE INIT (FILE01,FILE02,FILE03,FILE04,FILE05);
ON ENDFILE(FILEMT(1)) EOFSTMT(1) = '1'B;
ON ENDFILE(FILEMT(2)) EOFSTMT(2) = '1'B;
ON ENDFILE(FILEMT(3)) EOFSTMT(3) = '1'B;
ON ENDFILE(FILEMT(4)) EOFSTMT(4) = '1'B;
ON ENDFILE(FILEMT(5)) EOFSTMT(5) = '1'B;
DO WHILE (...);
......
OPEN FILE(FILEMT(CNT));
......
CALL DYNA_STMT(1,CNT);
/* an asembly user program to dynamic allocate file) */
......
READ FILE(FILEMT(CNT)) INTO(....) KEY(....);
END;
=============================================== |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
Please refer to my post dated Thu Nov 23, 2006 3:13 am (and other posts after that if you need to).
I don't know PL/1 but I know this COBOL example works as I've tested it on my system; and I've helped another poster get his code working on his system. |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
galecra wrote: |
I tried the record format = U way and I still get 39 error.
Here is my coding, perhaps I made something wrong:
SELECT DYNA-FILE ASSIGN TO DYNAMIC1
FILE STATUS WS-FS-DYNA-FILE.
FD DYNA-FILE
RECORDING MODE IS U
RECORD IS VARYING IN SIZE FROM 1 TO 32767 CHARACTERS
DEPENDING ON WS-DYNA-FILE-INDEX.
01 DYNA-FILE-REC.
10 DYNA-FILE-REC-BYTE PIC X(1) OCCURS 32767 TIMES
DEPENDING ON
WS-DYNA-FILE-INDEX.
10 WS-DYNA-FILE-INDEX PIC 9(5) BINARY VALUE 32767.
And this is the Info of the files I'm trying to open dynamically:
Management class . . : TSOSMAL Allocated cylinders : 1
Storage class . . . : TSO Allocated extents . : 1
Volume serial . . . : TSS508
Device type . . . . : 3390
Data class . . . . . : **None** Current Utilization
Organization . . . : PS Used cylinders . . : 1
Record format . . . : FB Used extents . . . : 1
Record length . . . : 80
Block size . . . . : 27920
1st extent cylinders: 1
Secondary cylinders : 10
Data set name type : SMS Compressible : NO
I didn't use 65535 as I got a compiler error telling that the maximum value can be 32767...
Thanks! |
I code 'record contains 0' in the fd statement and then make the 01 level in the fd statement contain more than enough bytes than I'll use. Then when I read the file I read it into a ws variable like this 'into ws-variable(1:ws-lenth) where ws-length is passed in the same manner I passed the dataset name.
Works great so far. |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
Great job and great tech tip.
Will try this out myself later tonight. |
|
Back to top |
|
|
adiovanni
New User
Joined: 22 Nov 2006 Posts: 40 Location: USA
|
|
|
|
Got the dynamic case of this utility to work thanks to your help.
For the dynamic file file-status, you must additionally say that the "04" file-status is OK; for example:
77 DALDUMMY-STATUS PIC X(02) VALUE SPACES.
88 DALDUMMY-STATUS-OK VALUE '00' '04'.
My FD:
FILE SECTION.
FD DYNAMIC-OPEN-FILE
RECORDING MODE IS U
RECORD CONTAINS 0 CHARACTERS
LABEL RECORDS ARE STANDARD.
01 DYNAMIC-OPEN-RECORD.
10 DYNA-FILE-REC-BYTE PIC X(001)
OCCURS 0 TO 32767 TIMES
DEPENDING ON
WS-DYNA-FILE-INDEX.
In my working-storage I have a copybook that I READ INTO which has an "01" level.
In my working-storage, I have:
77 WS-DYNA-FILE-INDEX PIC S9(5) BINARY VALUE +32767.
I could not say READ INTO working-storage-01-area (1:WS-DYNA-FILE-INDEX)--I got S0C4 in that case; rather I had to say READ INTO working-storage-01-area.
I tested this routine with different sized files and I was able to CALL-DYNALLOC/OPEN/READ/display-the-contents/CLOSE each of these files; hence this routine is now TOTALLY DYNAMIC.
Thanks for your help on this. Take care. |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
adiovanni wrote: |
Got the dynamic case of this utility to work thanks to your help.
For the dynamic file file-status, you must additionally say that the "04" file-status is OK; for example:
77 DALDUMMY-STATUS PIC X(02) VALUE SPACES.
88 DALDUMMY-STATUS-OK VALUE '00' '04'.
My FD:
FILE SECTION.
FD DYNAMIC-OPEN-FILE
RECORDING MODE IS U
RECORD CONTAINS 0 CHARACTERS
LABEL RECORDS ARE STANDARD.
01 DYNAMIC-OPEN-RECORD.
10 DYNA-FILE-REC-BYTE PIC X(001)
OCCURS 0 TO 32767 TIMES
DEPENDING ON
WS-DYNA-FILE-INDEX.
In my working-storage I have a copybook that I READ INTO which has an "01" level.
In my working-storage, I have:
77 WS-DYNA-FILE-INDEX PIC S9(5) BINARY VALUE +32767.
I could not say READ INTO working-storage-01-area (1:WS-DYNA-FILE-INDEX)--I got S0C4 in that case; rather I had to say READ INTO working-storage-01-area.
I tested this routine with different sized files and I was able to CALL-DYNALLOC/OPEN/READ/display-the-contents/CLOSE each of these files; hence this routine is now TOTALLY DYNAMIC.
Thanks for your help on this. Take care. |
I'll post a complete program as soon as I have time but you can do this with recording mode F. The trick is if the files you are going to read in have different lrecls, you need to call something like putenv. |
|
Back to top |
|
|
|