Extract first record from multiple files



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Extract first record from multiple files

Postby Prasanna G » Wed Jan 13, 2021 2:14 pm

Hi

I have close to 25000+ flat files of different record lengths and record format (FB/VB). My requirement is to create a report with file name and 30 bytes of first record of corresponding file. If the input file is less than 30 bytes, the output record can be written with padded spaces.

Input:
TEST.OTHR.FILE1
TEST.OTHR.FILE2
TEST.OTHR.FILE3
TEST.OTHR.FILE4

Output report to be created in a file with the following as records in it:
TEST.OTHR.FILE1 - UHDR2021002
TEST.OTHR.FILE2 - …………..
TEST.OTHR.FILE3 - HEADER20210102
TEST.OTHR.FILE4 -
 


In the above example, TEST.OTHR.FILE2 has low values in it as the first record. TEST.OTHR.FILE4 is empty.
Is it possible to be done using DFSORT?

Thanks
Prasanna G
User avatar
Prasanna G
 
Posts: 71
Joined: Tue Apr 12, 2011 9:49 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Extract first record from multiple files

Postby NicC » Wed Jan 13, 2021 5:36 pm

With the aid of another program - yes. But, also, that other program could do it all.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Extract first record from multiple files

Postby Prasanna G » Wed Jan 13, 2021 7:50 pm

Is it not doable using DFSORT?
User avatar
Prasanna G
 
Posts: 71
Joined: Tue Apr 12, 2011 9:49 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Extract first record from multiple files

Postby NicC » Wed Jan 13, 2021 8:19 pm

Yes it is. But would you want to? You would need to run the step for each dataset (not file). Each execution would have a dataset as the SORTIN and its name would be passed via the JPy parameter. Simple enough to read one record, combine that with the JPy data and write out to SORTOUT. Subsequent executions would need a DISP=MOD on SORTOUT. Do that 2,500 times.

Or write a quick Rexx which will read a list of the dataset names and for each it would allocate the dataset, read one record and then create the output record. Do once,
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Extract first record from multiple files

Postby sergeyken » Wed Jan 13, 2021 9:16 pm

Prasanna G wrote:Is it not doable using DFSORT?

It is doable with DFSORT.
But it would be the same as hammering 2500 nails using a screwdriver.

The simplest way should be using REXX, as suggested above.
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 425
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times

Re: Extract first record from multiple files

Postby Prasanna G » Wed Jan 13, 2021 11:16 pm

Hi NicC

I was able to achieve my requirement by writing a simple rexx.

Thanks for you time.
User avatar
Prasanna G
 
Posts: 71
Joined: Tue Apr 12, 2011 9:49 pm
Has thanked: 1 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post