View previous topic :: View next topic
|
Author |
Message |
rajatbagga
Active User
Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Hello,
I have a file which contains a record like :-
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
12345ABC4500012HMK9000212HBK9700019HMU9300018HMK60
|
Its actually occurrence of one group field WS-RECORD 100 times
Code: |
WS-RECORD W 10 A
WS-AMT WS-RECORD 05 N
WS-ID WS-RECORD 03 A
WS-SD WS-RECORD 02 N |
Required Output:-
Code: |
12345ABC45
00012HMK90
00212HBK97
00019HMU93
00018HMK60
|
How can we achieve the above output using DFSORT..
Thank You,
Rajat |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
this may assist
Code: |
//SORT0001 EXEC PGM=SORT
//SORTIN DD *
12345ABC4500012HMK9000212HBK9700019HMU9300018HMK60
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(1,10,/,11,10,/,21,10,/,31,10,/,41,10)
/*
|
Gerry |
|
Back to top |
|
|
rajatbagga
Active User
Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Cool.. That is exactly what i wanted .. Thank you |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
rajatbagga,
Quote: |
Its actually occurrence of one group field WS-RECORD 100 times |
Alternatively you can also use RESIZE operator which makes it easy to code and maintain. Based on above comment, I am assuming your input is FB/1000 and you are trying to split that into 10 byte records each.
Code: |
//STEP0001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD YOUR INPUT FB/1000
//OUT DD YOUR OUTPUT FB/10
//TOOLIN DD *
RESIZE FROM(IN) TO(OUT) TOLEN(10)
/* |
Thanks, |
|
Back to top |
|
|
rajatbagga
Active User
Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Thanks , but this field occurs 100 times from position 101 and ends at 1101, after this there few other fields. The total record length of my file is 1800/FB. Is it possible to use RESIZE in this case?
thank you,
Rajat |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
rajatbagga,
Had you mentioned this earlier, it would have been easier to test one solution only. See if below works.
Code: |
//STEP0001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DISP=SHR,DSN=your input FB/1800
//OUT DD YOUR OUTPUT FB/10
//TOOLIN DD *
RESIZE FROM(IN) TO(OUT) TOLEN(10) USING(CTL1)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=OUT,STARTREC=11,ENDREC=110
/* |
Thanks, |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
sqlcode1,
what happens if you have more than 1 record?
rajatbagga wrote: |
but this field occurs 100 times from position 101 and ends at 1101, after this there few other fields. The total record length of my file is 1800/FB. Is it possible to use RESIZE in this case? |
rajatbagga,
The following RESIZE operator gives you the desired results.
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=Your input Fb 1800 byte file,DISP=SHR
//OUT DD SYSOUT=*
//TOOLIN DD *
RESIZE FROM(IN) TO(OUT) TOLEN(10) USING(CTL1)
//CTL1CNTL DD *
INREC BUILD=(101,1000)
//* |
|
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Skolusu,
Grrrr..on myself.. I tested with 1 record only.
Thanks, |
|
Back to top |
|
|
rajatbagga
Active User
Joined: 11 Mar 2007 Posts: 199 Location: india
|
|
|
|
Thanks Skolusu,
I tried the RESIZE option its all doing good. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rajatbagga,
Since the input data is an occurs field , there is a chance that it might have spaces. You can eliminate those unwanted records in the same step itself by adding the following statement after the INREC statement. I assumed that you are validating a character field.
Code: |
OUTFIL OMIT=(1,10,CH,EQ,C' ')
|
|
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Hi,
I have a similar requirement where I want to do the same thing. But my file is comma delimited. Everytime a Comma is found the row should be written to next line.
How SORT will be able to do this? |
|
Back to top |
|
|
kratos86
Active User
Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
If the values are in fixed position you can do it in one build statement. If not try PARSE feature. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
And, next time, start a new topic. Different scenario, different keyword. |
|
Back to top |
|
|
|