IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SORT 3 files,extract specific fields and o/p as single rec


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Kiransr

New User


Joined: 22 Mar 2018
Posts: 5
Location: India

PostPosted: Fri Mar 23, 2018 10:54 am
Reply with quote

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.
Code:
ABCD
486
AB


Any help in here is highly appreciated.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Mar 23, 2018 11:47 am
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Fri Mar 23, 2018 7:21 pm
Reply with quote

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.
Code:
ABCD
486
AB


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. 36_8_9.gif

BTW: there is no clue - why any "SORT of three files" might be required???? icon_cry.gif

The first simple idea is, try to use an extremely primitive REXX code to do this.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Mar 23, 2018 10:42 pm
Reply with quote

I would rather get the requirements straight before jumping into conclusions.
Back to top
View user's profile Send private message
Kiransr

New User


Joined: 22 Mar 2018
Posts: 5
Location: India

PostPosted: Mon Mar 26, 2018 10:41 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Mon Mar 26, 2018 11:29 pm
Reply with quote

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
View user's profile Send private message
Kiransr

New User


Joined: 22 Mar 2018
Posts: 5
Location: India

PostPosted: Tue Mar 27, 2018 2:54 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Mar 27, 2018 3:13 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Mar 27, 2018 3:53 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Mar 27, 2018 5:58 pm
Reply with quote

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
View user's profile Send private message
Kiransr

New User


Joined: 22 Mar 2018
Posts: 5
Location: India

PostPosted: Tue Mar 27, 2018 9:49 pm
Reply with quote

@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 icon_smile.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Mar 27, 2018 10:23 pm
Reply with quote

Kiransr,

You're welcome. Just curious - the COMP, NUMB and SUITE, are these symbolic variables?
Back to top
View user's profile Send private message
Kiransr

New User


Joined: 22 Mar 2018
Posts: 5
Location: India

PostPosted: Wed Mar 28, 2018 2:04 pm
Reply with quote

@Arun Raj - Yes these are symbolic variables.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Wed Mar 28, 2018 7:10 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top