Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort Logic to extract data

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Tue Mar 01, 2016 1:22 am    Post subject: Sort Logic to extract data
Reply with quote

I am trying to work on logic to extract some data using SORT utility, but I am not getting the logic on how should I proceed.

My Input File Structure is like. File is VB 1500

Code:

RECDA124290927402HELLO
RECDB124290927402nfnlnflnlnlnln
RECDC1242909274anlnflnfnlnlnlni3oj
RECDD124290927402HOW
RECDA124290927402GOOD
RECDB124290927402nfnlnflnlnlnln
RECDC1242909274anlnflnfnlnlnlni3oj
RECDD124290927402MORNING


I know the starting characters for each record.

I want to capture records which are starting with RECDA and RECDD.
For RECDA I want to capture from BYTE 20 for 10 chars
For RECDB I want to capture from BYTE 30 for 10 chars

In final File I want both RECDA and RECDB on single line

Code:

HELLO HOW
GOOD MORNING
Back to top
View user's profile Send private message

kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 114
Location: Hyderabad

PostPosted: Tue Mar 01, 2016 9:58 am    Post subject:
Reply with quote

Try "resize..... using"
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Tue Mar 01, 2016 10:53 am    Post subject: Reply to: Sort Logic
Reply with quote

Sorry I am not sure I understood what u r trying to say
Back to top
View user's profile Send private message
kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 114
Location: Hyderabad

PostPosted: Tue Mar 01, 2016 11:32 am    Post subject:
Reply with quote

Please search for resize operator in icetool. That will help you achieve what you wanted.

Below is one way of doing it. You may tailor it per your needs.
Note that I used instream data, you may want to change the control card as you have a VB.

Since I have disp=mod for the output file, clear the contents with another step before executing this step.

Code:

//SORT1    EXEC PGM=ICETOOL                                   
//SORTIN   DD   *                                             
RECDA124290927402HELLO                                       
RECDB124290927402NFNLNFLNLNLNLN                               
RECDC1242909274ANLNFLNFNLNLNLNI3OJ                           
RECDA124290927402HOW                                         
RECDD124290927402GOOD                                         
RECDB124290927402NFNLNFLNLNLNLN                               
RECDC1242909274ANLNFLNFNLNLNLNI3OJ                           
RECDD124290927402MORNING                                     
/*                                                           
//TOOLMSG  DD   SYSOUT=*                                         
//DFSMSG   DD   SYSOUT=*                                         
//SEND1    DD   DSN=&&SEND1,SPACE=(CYL,(5,10)),DISP=(,PASS)       
//SEND2    DD   DSN=&&SEND2,SPACE=(CYL,(5,10)),DISP=(,PASS)       
//CATCH1   DD   DSN=*.SEND1,DISP=(OLD,PASS),VOL=REF=*.SEND1       
//CATCH2   DD   DSN=*.SEND2,DISP=(OLD,PASS),VOL=REF=*.SEND2       
//TOOLIN   DD   *                                                 
  COPY FROM(SORTIN) USING(CTL1)                                   
  RESIZE FROM(CATCH1) TO(OUTPUT1) TOLEN(70)                       
  RESIZE FROM(CATCH2) TO(OUTPUT1) TOLEN(70)                       
//*                                                               
//CTL1CNTL DD   *                                                 
 OUTFIL FNAMES=SEND1,BUILD=(18,10),INCLUDE=(1,5,CH,EQ,C'RECDA')   
 OUTFIL FNAMES=SEND2,BUILD=(18,10),INCLUDE=(1,5,CH,EQ,C'RECDD')   
/*                                                               
//OUTPUT1  DD   DISP=MOD,DSN=QUAL1.QUAL2.FILEFB70                     
//SORTOUT  DD   SYSOUT=*                                                                 
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 65
Location: India

PostPosted: Tue Mar 01, 2016 11:37 am    Post subject: Re: Sort Logic
Reply with quote

Hello,

scorp_rahul23 wrote:
I know the starting characters for each record.

I want to capture records which are starting with RECDA and RECDD.
For RECDA I want to capture from BYTE 20 for 10 chars
For RECDB I want to capture from BYTE 30 for 10 chars

In final File I want both RECDA and RECDB on single line


Quick question, will the records always occur in the order of '4', by that I mean, start with RECDA, then immediate next record RECDB, followed by RECDC and ending with RECDD; if the answer to this is yes, then a quick dirty solution would be:

a. Use RESIZE operator of DFSORT to bring RECDA - RECDD records in one single line; you would want to keep the RESIZE length as the maximum length of a given record (with padded spaces; but then I'd already said, this is a dirty solution icon_wink.gif ).
b. Once you have these four records grouped as one single record, PARSE the data to re-arrange it in your requisite format.

This should give you the desired output.

Hth.

<EDIT: Whups kranthikumarb and I posted almost at same time, my bad>
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Mar 01, 2016 1:24 pm    Post subject: Reply to: Sort Logic
Reply with quote

I think kranthikumarb has misread the question.

Abid Hasan's is more reasonable, except the records are variable-length and they need to be fixed-length for RESIZE. Should also incorporate part of this:

Use INCLUDE/OMIT COND= to get the records you want.

Use IFTHEN=(WHEN=GROUP for your first record of a pair, and PUSH the data that you want onto the second record along with a SEQ=1, with RECORDS=2. Since you have a large amount of data on a record that you do not need on your output, there should be plenty of opportunity to PUSH without needing to actually extend the records.

On OUTFIL, using INCLUDE/OMIT= to just pick up the SEQ equal to "2"s. Use BUILD to create your final output.

Note, if you needed to SORT the records (for some other reason) you'd drop off the unwanted data per record using BUILD in INREC, to save data poked into the SORT.
Back to top
View user's profile Send private message
kranthikumarb

Active User


Joined: 02 Jan 2009
Posts: 114
Location: Hyderabad

PostPosted: Tue Mar 01, 2016 1:39 pm    Post subject:
Reply with quote

Bill,

I am getting 10 bytes data from the input data in the first pass. So this is making it as fixed byte. I executed the sort step I gave and it is giving the required output.

I am not still clear on where I went wrong.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Mar 01, 2016 3:12 pm    Post subject: Reply to: Sort Logic
Reply with quote

You've missed the VB, so RESIZE won't work.

You have multiple passes of the data, where only one is needed.

The requirement is for data from different positions on the input depending on the record-type.

You've rearranged the input data, and, changed the input data so your solution will work.

Your CTL1CNTL is not valid (as posted).

You are not "making it as fixed", it is the fact that you are using fixed-length records as your input.
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Tue Mar 01, 2016 10:20 pm    Post subject: Reply to: Sort Logic
Reply with quote

Thanks Bill for your inputs. But I don't think I am still clear about how to proceed on this.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Mar 01, 2016 11:00 pm    Post subject: Reply to: Sort Logic
Reply with quote

You code an INCLUDE COND= for the records you want.

You use IFTHEN=(WHEN=GROUP and PUSH the data you want from the first record so that it appears on the second record, and SEQ=1.

Then an OUTFIL to INCLUDE= the second of the record of the group, which has on it all the data you want. Use BUILD to format the output how you want.

Exact details depend on your data. Are they always in the same order, both always present, only one of each, that type of stuff.
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Mon Mar 07, 2016 9:54 pm    Post subject: Reply to: Sort Logic to extract data
Reply with quote

Input File is
Code:

=COLS> ----+----1----+
****** ****************
000100 123 HEL00000100
000200 456 HOW00000200
000300 789 ARE00000300
000400 123 YOU00000400
000500 345 GOO00000500
000600 789 MOR00000600
****** ****************



I tried this but it is not correct. Can anyone help

Code:

//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  INCLUDE COND=(1,3,CH,EQ,C'123',OR,1,3,CH,EQ,C'789')   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'123'),     
        PUSH=(16:1,10)),                                 
  IFTHEN=(WHEN=GROUP,                                   
        BEGIN=(1,3,CH,EQ,C'789'),PUSH=(27:1,10))         
  OUTREC IFTHEN=(WHEN=(1,3,CH,EQ,C'123'),               
                 BUILD=(1,10)),                         
  OUTREC IFTHEN=(WHEN=(1,3,CH,EQ,C'789'),               
                 BUILD=(11,10))                         
/*                                                       
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Tue Mar 08, 2016 12:58 am    Post subject: Reply to: Sort Logic to extract data
Reply with quote

Tried one more idea, but this as well did not worked out

Code:

//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INCLUDE COND=(1,3,CH,EQ,C'123',OR,1,3,CH,EQ,C'789')           
  INREC IFTHEN=(WHEN=GROUP,RECORDS=1,BEGIN=(1,3,CH,EQ,C'123'),   
        PUSH=(16:1,10,SEQ=1))                                   
  OUTFIL INCLUDE=(1,3,CH,EQ,C'789'),BUILD=(16,15,X,5,5,80:X)     
/*                                                               
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 331
Location: USA

PostPosted: Tue Mar 08, 2016 1:55 am    Post subject: Reply to: Sort Logic to extract data
Reply with quote

Try this with your latest Sample data:
Code:
  SORT FIELDS=COPY
   INCLUDE COND=(1,3,CH,EQ,C'123',OR,1,3,CH,EQ,C'789')
   INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'123'),
         PUSH=(16:1,10))
   OUTFIL INCLUDE=(1,3,CH,EQ,C'789'),BUILD=(16,10,1,10)           

.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Tue Mar 08, 2016 5:22 am    Post subject: Reply to: Sort Logic to extract data
Reply with quote

scorp_rahul23,

What output do you expect for your latest sample?
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 Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us