View previous topic :: View next topic
|
Author |
Message |
Kiransr
New User
Joined: 22 Mar 2018 Posts: 5 Location: India
|
|
|
|
Hi All,
I have below requirement to extract specific fields from 3 input files and write to output file as a single record. All 3 files have only 1 record each
Input file1 record -
Code: |
//SET1 SET COMP=ABCD - LRECL 80 FB |
Input file2 record -
Code: |
//SET2 SET NUMB=486 - LRECL 80 FB |
Input file3 record -
Code: |
//SET3 SET SUITE=AB - LRECL 80 FB |
My output should be a single record with value
Code: |
ABCD486AB - LRECL 80 FB |
That is I need to extract the values after the '=' sign from all 3 files and write as a single record in output file.
I tried INREC parse STARTAFT='=' and ENDBFR=' ' to extract the fileds but while building the outrec the records are written as 3 separate records.
Any help in here is highly appreciated. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Kiransr - Welcome to the forums.
The values that you are trying to extract from each record, are those of fixed length (including the trailing blanks)?
Please use Code tags to preserve alignment of sample data/code. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2019 Location: USA
|
|
|
|
Kiransr wrote: |
Hi All,
I have below requirement to extract specific fields from 3 input files and write to output file as a single record. All 3 files have only 1 record each
Input file1 record -
Code: |
//SET1 SET COMP=ABCD - LRECL 80 FB |
Input file2 record -
Code: |
//SET2 SET NUMB=486 - LRECL 80 FB |
Input file3 record -
Code: |
//SET3 SET SUITE=AB - LRECL 80 FB |
My output should be a single record with value
Code: |
ABCD486AB - LRECL 80 FB |
That is I need to extract the values after the '=' sign from all 3 files and write as a single record in output file.
I tried INREC parse STARTAFT='=' and ENDBFR=' ' to extract the fileds but while building the outrec the records are written as 3 separate records.
Any help in here is highly appreciated. |
This approach resembles attempts to hammer nails with such tool as electric drill. It is possible but... it gives the full picture of the experience in IT technologies.
BTW: there is no clue - why any "SORT of three files" might be required????
The first simple idea is, try to use an extremely primitive REXX code to do this. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
I would rather get the requirements straight before jumping into conclusions. |
|
Back to top |
|
|
Kiransr
New User
Joined: 22 Mar 2018 Posts: 5 Location: India
|
|
|
|
Thanks for your reply.
My client do not favor REXX so I was forced to find an alternate solution for this.
My requirement here is to put a validation step in an existing batch suite.
To do so I need to get the values from the 3 input files(parmcards of 80 LRECL) I had mentioned before in a single record format.
That is I need to
-Extract ABCD from first file fixed length always 4 chars.
-Extract 486 from second file fixed length always 3 chars.
-Extract AB from third file fixed length always 2 chars.
The trailing spaces can be ignored I am concerned only about the value.
Output file should have all these values in a single record.
That is ABCD486AB with trailing spaces/without(no significance). |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2019 Location: USA
|
|
|
|
It is still not clear:
1) are there any other records in three input datasets except those three lines in the given examples?
2) what, and why needs to be "sorted in three input DATASETS"? |
|
Back to top |
|
|
Kiransr
New User
Joined: 22 Mar 2018 Posts: 5 Location: India
|
|
|
|
Please note that each file has and always will have only 1 record each as mentioned in the samples above.
There are no records other than the 3 lines given in sample.
These files are part of a batch suite and therefore the values 'ABCD','486','AB' in each file changes with each suite run but the length of these values remains the same.
To quote again my requirement is to extract these values from the fixed length files(LRECL=80) to an output file of fixed length(LRECL=80) in the format ABCD486AB so that I can apply a validation step to the batch suite.
Hope you are now clear with the requirement.
I understand that using SORT in this case is quite mean but as I mentioned before REXX is not favored in my organization and I don't know any other method to get this done.
Looking forward for a better alternative in case this can be done without using SORT. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
use a concatenated dd to have the three datasets look as one
parse - to reformat the record to a fixed format and isolate the relevant data
push - to populate next record ( with the proper offset and lengths )
the last record will contain the all the data You need
a build with proper offset and length will give You the result You want
Quote: |
... better alternative in case this can be done without using SORT. |
write a program in the language endorsed by Your organisation
a hand written program will be able to implement more complex logic, record, data handling
than a general purpose utility |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Quote: |
so that I can apply a validation step to the batch suite. |
Why not have your validation step do the extract? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Kiransr,
Besides the above suggestions, you could also use RESIZE to read a concatenated input (3 input data sets) and then create a single record output like this:
Code: |
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DISP=SHR,DSN= Input1 [FB/80]
// DD DISP=SHR,DSN= Input2 [FB/80]
// DD DISP=SHR,DSN= Input3 [FB/80]
//OUT DD SYSOUT=*
//TOOLIN DD *
RESIZE FROM(IN) TO(OUT) TOLEN(12) USING(CTL1)
//CTL1CNTL DD *
INREC PARSE=(%01=(STARTAFT=C'=',FIXLEN=4)),
BUILD=(%01)
OUTFIL BUILD=(1,7,9,2,80:X) |
|
|
Back to top |
|
|
Kiransr
New User
Joined: 22 Mar 2018 Posts: 5 Location: India
|
|
|
|
@Arun Raj - Thanks dude. You are the man I was looking for. You got exactly what I was looking for.
Thank you all for your suggestions.
Great response on my first ever post in this forum.
Looking forward to learn more from you guys |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Kiransr,
You're welcome. Just curious - the COMP, NUMB and SUITE, are these symbolic variables? |
|
Back to top |
|
|
Kiransr
New User
Joined: 22 Mar 2018 Posts: 5 Location: India
|
|
|
|
@Arun Raj - Yes these are symbolic variables. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2019 Location: USA
|
|
|
|
Kiransr wrote: |
@Arun Raj - Yes these are symbolic variables. |
Those things can be symbolic variables ONLY when used as SET statements in the middle of correct JCL deck.
As the only record of a separate dataset - neither of them can be considered as symbolic variable. |
|
Back to top |
|
|
|