View previous topic :: View next topic
Author
Message
darkstar13 New User Joined: 06 Nov 2008Posts: 46 Location: Manila, Philippines
Hi,
I have the following data that I want to reformat.
input
Code:
ARCA,ARCA,C,,0.00085
ARCA,ARCA,F,,0.003
ARCA,ARCA,G,,0.0005
ARCA,ARCA,L,,0.003
ARCA,ARCA,M,,-0.0015
desired output
Code:
ARCAARCAC 00008500
ARCAARCAF 00030000
ARCAARCAG 00005000
ARCAARCAL 00030000
ARCAARCAM 00015000-
I am using the following sort card
Code:
OPTION COPY
INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=4),
%02=(ENDBEFR=C',',FIXLEN=4),
%03=(ENDBEFR=C',',FIXLEN=2),
%04=(ENDBEFR=C',',FIXLEN=1),
%05=(ENDBEFR=C',',FIXLEN=8)),
BUILD=(%01,%02,%03,%04,%05,SFF,TO=ZD,LENGTH=8)
OUTREC FIELDS=(1,11,
(12,08,ZD,MUL,+1000),
EDIT=(TTTTTTTTS),SIGNS=(,,,-))
but I am ending up with the following:
Code:
ARCAARCAC 00085000
ARCAARCAF 00003000
ARCAARCAG 00005000
ARCAARCAL 00003000
ARCAARCAM 00015000-
It seems like since SFF does not retain decimal place, my data is getting messed up because my input file is not padded with zeroes. Is there a way to fix this?
Thanks.
Back to top
hailashwin New User Joined: 16 Oct 2008Posts: 74 Location: Boston
Please check if this works for you..
Code:
//SYSIN DD *
OPTION COPY
INREC FINDREP=(STARTPOS=14,ENDPOS=21,IN=C' ',OUT=C'0')
OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=4),
%02=(ENDBEFR=C',',FIXLEN=4),
%03=(ENDBEFR=C',',FIXLEN=2),
%04=(ENDBEFR=C',',FIXLEN=1),
%05=(ENDBEFR=C' ',FIXLEN=8)),
BUILD=(%01,%02,%03,%04,%05,SFF,TO=ZD,LENGTH=8)
OUTFIL BUILD=(1,11,12,8,ZD,MUL,+10,EDIT=(TTTTTTTTS),SIGNS=(,,,-))
//*
Output:
Code:
ARCAARCAC 00008500
ARCAARCAF 00030000
ARCAARCAG 00005000
ARCAARCAL 00030000
ARCAARCAM 00001500-
Thanks,
Ashwin.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
hailashwin, did you check that final figure?
darkstar13,
Having identified what is happening, it is only a small step to a resolution. If it can't be done one way, look for another.
Although the leading minus sign complicates, you can get rid of the "." with a simple rearrangement of data, and change trailing spaces to zero with FINDREP or by multiple IFTHENs, with perhaps other possibilities.
Back to top
bodatrinadh Active User Joined: 05 Jan 2007Posts: 101 Location: chennai (India)
Hi darkstar13,
You can try this -
Code:
//STEP1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ARCA,ARCA,C,,0.00085
ARCA,ARCA,F,,0.003
ARCA,ARCA,G,,0.0005
ARCA,ARCA,L,,0.003
ARCA,ARCA,M,,-0.0015
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=4),
%02=(ENDBEFR=C',',FIXLEN=4),
%03=(ENDBEFR=C',',FIXLEN=2),
%04=(ENDBEFR=C',',FIXLEN=1),
%05=(ENDBEFR=C'.',FIXLEN=2),
%06=(FIXLEN=5)),
OVERLAY=(%01,%02,%03,%04,%05,JFY=(SHIFT=RIGHT),
14:%06,ZD,EDIT=(TTTTT),10X,
12:12,08,JFY=(SHIFT=RIGHT),
12:12,08,SFF,TO=ZD,LENGTH=08)
OUTREC OVERLAY=(12:13,7,ZD,MUL,+100,EDIT=(TTTTTTTTS),SIGNS=(,,,-),10X)
And Output :-
Code:
ARCAARCAC 00008500
ARCAARCAF 00030000
ARCAARCAG 00005000
ARCAARCAL 00030000
ARCAARCAM 00015000-
Thanks
-3nadh
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
darkstar13,
Use the following DFSORT JCL which will give you the desired results. I assumed that your final number has S9V9(7) with trailing sign.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ARCA,ARCA,C,,0.00085
ARCA,ARCA,F,,0.003
ARCA,ARCA,G,,0.0005
ARCA,ARCA,L,,0.003
ARCA,ARCA,M,,-0.0015
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=4),
%02=(ENDBEFR=C',',FIXLEN=4),
%03=(ENDBEFR=C',',FIXLEN=2),
%04=(ENDBEFR=C',',FIXLEN=1),
%05=(ENDBEFR=C'.',FIXLEN=2),
%06=(FIXLEN=7)),
BUILD=(%01,%02,%03,%04,
%05,SFF,EDIT=(T),%06,TRAN=ALTSEQ,
%05,SFF,EDIT=(S),SIGNS=(,-))
ALTSEQ CODE=(40F0)
//*
The output from this is
Code:
ARCAARCAC 00008500
ARCAARCAF 00030000
ARCAARCAG 00005000
ARCAARCAL 00030000
ARCAARCAM 00015000-
Back to top
darkstar13 New User Joined: 06 Nov 2008Posts: 46 Location: Manila, Philippines
Hi Bodatrinadh, Skolusu,
Thanks a lot. It was a brilliant idea to parse using the decimal point ;)
I got the result that I wanted.
To Hailashwin and Bill, thanks for your reply. Your input is very much appreciated too. ;)
Back to top
Please enable JavaScript!