Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SORT 3 files,extract specific fields and o/p as single rec

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: SORT 3 files,extract specific fields and o/p as single rec
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: 2448
Location: @my desk

PostPosted: Fri Mar 23, 2018 11:47 am    Post subject:
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

Active User


Joined: 29 Apr 2008
Posts: 388
Location: Maryland

PostPosted: Fri Mar 23, 2018 7:21 pm    Post subject: Re: SORT 3 files,extract specific fields and o/p as single rec
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: 2448
Location: @my desk

PostPosted: Fri Mar 23, 2018 10:42 pm    Post subject:
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    Post subject:
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

Active User


Joined: 29 Apr 2008
Posts: 388
Location: Maryland

PostPosted: Mon Mar 26, 2018 11:29 pm    Post subject:
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    Post subject:
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

Senior Member


Joined: 14 Mar 2007
Posts: 10543
Location: italy

PostPosted: Tue Mar 27, 2018 3:13 pm    Post subject: Reply to: SORT 3 files,extract specific fields and o/p as single rec
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: 2126
Location: UK

PostPosted: Tue Mar 27, 2018 3:53 pm    Post subject:
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: 2448
Location: @my desk

PostPosted: Tue Mar 27, 2018 5:58 pm    Post subject:
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    Post subject:
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: 2448
Location: @my desk

PostPosted: Tue Mar 27, 2018 10:23 pm    Post subject:
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    Post subject:
Reply with quote

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

Active User


Joined: 29 Apr 2008
Posts: 388
Location: Maryland

PostPosted: Wed Mar 28, 2018 7:10 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Joining 2 records to 1 using Sort cmuncan DFSORT/ICETOOL 1 Sat Dec 08, 2018 8:53 am
No new posts Storing SORTOF files in a PDS ajithajt SYNCSORT 3 Thu Dec 06, 2018 12:27 pm
No new posts Single step to take backup of multipl... Vignesh Sid JCL & VSAM 1 Thu Nov 29, 2018 8:12 pm
No new posts Will this code extract 1 byte from fi... pkmurali CLIST & REXX 8 Sat Nov 10, 2018 11:13 pm
No new posts Anyone know how to copy Unix files? John Poulakos JCL & VSAM 7 Wed Oct 10, 2018 12:57 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us