I have some 100+ datasets which I need to find if they are on disk or tape. So I approached my storage management team and found that the disk datasets have device type as X'3010200F'
So my idea is to have all the datasets passed instream to SORT and attach LISTCAT to them and store the entries in an output dataset.
Now I will have the below info for every dataset
Code:
LISTCAT ENT('TEST.DSN') ALL
NONVSAM ------- TEST.DSN
IN-CAT --- BCS.GIO.VLB0102
HISTORY
DATASET-OWNER-----(NULL) CREATION--------2013.316
RELEASE----------------2 EXPIRATION------0000.000
VOLUMES
VOLSER------------C08964 DEVTYPE------X'3010200F'
From the output dataset I need to extract the dataset name and prepare a list in the output something like below with 3 fields. The dataset name, DEVTYPE(fro above), DISK if DEVTYPE equal to X'3010200F' else TAPE.
Code:
TEST.DSN X'3010200F' DISK
TEST.DSN2 X'78048081' TAPE
TEST.DSN3 X'78048092' TAPE
I can build sort card for attaching LIST ENT for every input dataset before it goes to IDCAMS to execute LISTCAT. But I need help in handling the output of IDCAMS since the dataset name stays in one line and it's DEVTYPE stays in another line.
Basically I need to group those 2 lines and verify the condition on DEVTYPE and build the final output record.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Use IFTHEN=(WHEN=GROUP to PUSH the DSN onto the subsequent records. IFTHEN=(WHEN=(logical-expression to identify the DEVTYPE and format your output. You can use INCLUDE COND= to get just those two records to start with for each LISTCAT output section, and then OUTFIL INCLUDE= to get the single record of the pair that you want (the first, the DSN, will not be required for your output).
The code has beautifully worked. I was actually expecting your response .
I have few questions on the code.
The group you used doesn't have an END. How did it realize where the group should end? Since my input has GDGs, seq files one after thye another. Eevery GDG will give all the generations and their own volumes which mean their device type.
When the output records being built are only of 80 bytes. How were you able to put data in byte 125.
Also I understood the trailer3 but not the sectiosn part. Can you please explain?
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
V S Amarendra Reddy wrote:
Kolusu,
The code has beautifully worked. I was actually expecting your response .
Bill gave enough hints for you to work on and so I just looked at this topic after you posted the solution. It would be easier for you to work on a solution and learn about DFSORT more and we are here to optimize that code you have.
V S Amarendra Reddy wrote:
I have few questions on the code.
The group you used doesn't have an END. How did it realize where the group should end? Since my input has GDGs, seq files one after thye another. Eevery GDG will give all the generations and their own volumes which mean their device type.
Well you used the INCLUDE cond to only include the Dataset name and Device type records. So you will ONLY get the Dataset name records and device type records. For every Dataset name you have device type and hence the end condition is NOT required.
V S Amarendra Reddy wrote:
When the output records being built are only of 80 bytes. How were you able to put data in byte 125.
Look at the OUTFIL statement where I built just 80x ie spaces. That will dictate the LRECL of the output dataset. OUTFIL acts on the final phase so whatever manipulations you do beyond the lrecl you will have access to those variables. Remove the OUTFIL statement and see the sysout and you will notice that the LRECL is 128 bytes.
V S Amarendra Reddy wrote:
Also I understood the trailer3 but not the sectiosn part. Can you please explain?
Thank you very much for the code.
The PUSH from WHEN=GROUP has pushed the dataset name and I used Sections on that so that for every dataset name you have keybreak and we will write out the fields specified in the Trailer3.