|
View previous topic :: View next topic
|
| Author |
Message |
scorp_rahul23
New User

Joined: 06 May 2008 Posts: 96 Location: Delhi
|
|
|
|
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 |
|
 |
kranthikumarb
Active User
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
|
|
|
|
| Try "resize..... using" |
|
| Back to top |
|
 |
scorp_rahul23
New User

Joined: 06 May 2008 Posts: 96 Location: Delhi
|
|
|
|
| Sorry I am not sure I understood what u r trying to say |
|
| Back to top |
|
 |
kranthikumarb
Active User
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
|
|
|
|
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 |
|
 |
Abid Hasan
New User
Joined: 25 Mar 2013 Posts: 88 Location: India
|
|
|
|
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 ).
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
kranthikumarb
Active User
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
scorp_rahul23
New User

Joined: 06 May 2008 Posts: 96 Location: Delhi
|
|
|
|
| Thanks Bill for your inputs. But I don't think I am still clear about how to proceed on this. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
scorp_rahul23
New User

Joined: 06 May 2008 Posts: 96 Location: Delhi
|
|
|
|
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 |
|
 |
scorp_rahul23
New User

Joined: 06 May 2008 Posts: 96 Location: Delhi
|
|
|
|
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 |
|
 |
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
scorp_rahul23,
What output do you expect for your latest sample? |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|