View previous topic :: View next topic
|
Author |
Message |
karthik_sripal
New User
Joined: 28 Mar 2008 Posts: 69 Location: 125.16.180.5
|
|
|
|
Hi all,
I have Requirement in which i have a comma separated file like
Code: |
****** ***************************** Top of Data ******************************
000001 ALPHA;BETA;OMEGA
****** **************************** Bottom of Data ****************************
|
and want my output file like
Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
****** ***************************** Top of Data *****************************
000001 ALPHA BETA OMEGA
****** **************************** Bottom of Data ***************************
|
where each of my copybook element length is 10. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
I would use Rexx, myself.
It can probably be done using sort -- either DFSORT or SyncSort. Frank Yaeger, Kolusu, and Alissa Margulies are the experts in these utilities; I will leave it to them for the moment to explain how to so do it.
I do not think that this can be done via File-AID or StarTool, not easily at any rate, although if someone more experienced with these tools thinks differently, I will acquiesce in this matter. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Since I am in a good mood and no pain to speak of today, I will provide the Rexx. Note that there is no error checking to speak of; it assumes the length of each token is less than 10 bytes, and that the delimiter is always a semi-colon.
Code: |
/* Rexx */
trace i
arg in out .
"ALLOC DA(" || in || ") FI(TOOLIN) SHR"
"ALLOC DA(" || out || ") FI(TOOLOUT) OLD"
"EXECIO 1 DISKR TOOLIN"
do while (rc=0)
outbuf = ''
pull inbuf
p = pos(';',inbuf)
do while (p¬=0)
car = substr(inbuf,1,p-1)
inbuf = substr(inbuf,p+1)
outbuf = outbuf || car || repeat(10-length(car))
p = pos(';',inbuf)
end
outbuf = outbuf || inbuf
push outbuf
"EXECIO 1 DISKW TOOLOUT"
"EXECIO 1 DISKR TOOLIN"
end
exit 0
/*********************************************************************/
/* */
/* repeat */
/* */
/*********************************************************************/
repeat: procedure
trace o
arg how_many, what
if ((what="WHAT") | (what='')) then
what = ' '
result = ''
do i = 1 to how_many
result = result || what
end
trace o
return result
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
my preferred coding would be ...
Code: |
istring = "abcd;efg;hkj;lmnopqrst"
ostring = ""
do while istring <> ""
parse var istring token ";" istring
ostring = ostring || left(token,10)
end
|
tested |
|
Back to top |
|
|
karthik_sripal
New User
Joined: 28 Mar 2008 Posts: 69 Location: 125.16.180.5
|
|
|
|
Thanks for the information Akatsukami and enrico-sorichetti.It has been helpful |
|
Back to top |
|
|
karthik_sripal
New User
Joined: 28 Mar 2008 Posts: 69 Location: 125.16.180.5
|
|
Back to top |
|
|
Uday Kumar R
New User
Joined: 07 Nov 2007 Posts: 27 Location: Mumbai
|
|
|
|
Hello,
Hope this help.
//STEP01 EXEC PGM=SORT
//SORTIN DD DSN=input dataset name
//SORTOUT DD DSN=output dataset name%
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC PARSE=(%01=(ENDBEFR=C';',FIXLEN=10),
%02=(ENDBEFR=C';',FIXLEN=10),
%03=(ENDBEFR=C';',FIXLEN=10),
BUILD=(%01,%02,%03)
/*
Regards,
Uday |
|
Back to top |
|
|
karthik_sripal
New User
Joined: 28 Mar 2008 Posts: 69 Location: 125.16.180.5
|
|
|
|
Thanks Uday.
Perfectly fits ..kinda thing i have been lookin for .. Now am planning to get this sortcard generated dynamically based on the Inputs like num of fields and its length and delimiter .. and sub this sort job via REXX and put it in lime light.. ;)
I definetly think that it would be helpful. Wish me luck |
|
Back to top |
|
|
Uday Kumar R
New User
Joined: 07 Nov 2007 Posts: 27 Location: Mumbai
|
|
|
|
You are right Karthik. By assuming each line has 3 words which are seperated by ";" i have coded the above logic. If there are 4 words the sort card skips the last word and produces erreneous results. I forgot to mention this. My apologies. Please take care of the length and change susequently the PARSE parameters (%) in the sort card. All the best.
Regards,
Uday |
|
Back to top |
|
|
|