View previous topic :: View next topic
Author
Message
venugopal404 New User Joined: 14 Dec 2010Posts: 13 Location: hyderabad
Hi All..
We have a small requirement to add the amount field.position 86-100(15 bytes).but the problem is the amount fileds are not in a proper order and they are separated by commas.Sample data shown below.
Input file: FB, LRECL = 100..Declared as below..position 86-100
01 WS-AA.
05 FILLER PIC X(85).
05 TOTAL PIC ----,---,--9.99.
sample-data:
-1,280.00
-21,548.53
51,146.92
-3,165.24
-8,096.52
-193.41
Output File : FB,LRECL = 100..position 86-100
-00000001280.00
-00000021548.53
00000051146.92
-00000003165.24
-00000008096.52
-00000000193.41
after arranging in this way.we need to add these amounts and should display the sum at the bottom of the file under the same amount field.
Could some1 please help me out.
i have goggled and found a similar topic with the subject "Reformatting numeric data using sync sort" but this is working only when the field starts from 1st position if the file..in my input file the amount filed is at 86-100 position.
please help me out.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Why don't you try with the code that starts at position 1, and change it to your start and length?
Back to top
venugopal404 New User Joined: 14 Dec 2010Posts: 13 Location: hyderabad
Hi Bill.
We Need 3 steps in the JCL to Accomplish this task where in the first step,
i need to pull out the data from the input file (pos 86-100) to a temporary file..
in the second i need to do my reformatting and the third i need to put back the same in the main-file again.
Want to accomplish this in a single step using sort.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
Why do you believe you need to do this in 3 steps?
Why not try as Bill suggested and simply refer to the proper data positions instead of pos 1?
Maybe posting better sample input and desired output data would help.
Back to top
venugopal404 New User Joined: 14 Dec 2010Posts: 13 Location: hyderabad
Hi Dick/Bill..
Below is the piece of code which is working fine for the amounts in position 1-10.. and its working fine..
Code:
//STEP01 EXEC PGM=SORT
//SORTIN DD *
-213.45
9865.56
65654.98
-55455.65
-45545.56
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,10,SS,NE,C'.'),
OVERLAY=(8:C'.00',20X),HIT=NEXT),
IFTHEN=(WHEN=(1,10,SS,EQ,C'.'),
BUILD=(1:1,10,SQZ=(SHIFT=RIGHT)),HIT=NEXT),
IFTHEN=(WHEN=(25,1,CH,EQ,C' '),
FINDREP=(STARTPOS=1,ENDPOS=10,IN=C' ',OUT=C'0'),HIT=NEXT),
IFTHEN=(WHEN=(1,10,SS,EQ,C'-'),
OVERLAY=(1:C'-'),HIT=NEXT),
IFTHEN=(WHEN=(2,9,SS,EQ,C'-'),
FINDREP=(STARTPOS=2,ENDPOS=9,IN=C'-',OUT=C'0'),HIT=NEXT),
IFTHEN=(WHEN=(1,1,CH,NE,C'-'),
OVERLAY=(1:C' '))
output:
Code:
-000213.45
009865.56
065654.98
-055455.65
-045545.56
below is my sort card after changing according to my requirement.
Code:
OPTION COPY
INREC IFTHEN=(WHEN=(86,15,SS,NE,C'.'),
OVERLAY=(98:C'.00',20X),HIT=NEXT),
IFTHEN=(WHEN=(86,15,SS,EQ,C'.'),
BUILD=(86:1,15,SQZ=(SHIFT=RIGHT)),HIT=NEXT),
IFTHEN=(WHEN=(105,1,CH,EQ,C' '),
FINDREP=(STARTPOS=86,ENDPOS=100,IN=C' ',OUT=C'0'),HIT=NEXT),
IFTHEN=(WHEN=(86,15,SS,EQ,C'-'),
OVERLAY=(86:C'-'),HIT=NEXT),
IFTHEN=(WHEN=(87,14,SS,EQ,C'-'),
FINDREP=(STARTPOS=87,ENDPOS=99,IN=C'-',OUT=C'0'),HIT=NEXT),
IFTHEN=(WHEN=(86,1,CH,NE,C'-'),
OVERLAY=(86:C' '))
output error Message:
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Code:
OPTION COPY
INREC IFTHEN=(WHEN=(86,15,SS,NE,C'.'),
OVERLAY=(98:C'.00',20X),HIT=NEXT),
IFTHEN=(WHEN=(86,15,SS,EQ,C'.'),
BUILD=(86:1,15,SQZ=(SHIFT=RIGHT)),HIT=NEXT),
IFTHEN=(WHEN=(105,1,CH,EQ,C' '),
FINDREP=(STARTPOS=86,ENDPOS=100,IN=C' ',OUT=C'0'),HIT=NEXT)
IFTHEN=(WHEN=(86,15,SS,EQ,C'-'),
* -------> showing syntax error here
OVERLAY=(86:C'-'),HIT=NEXT),
IFTHEN=(WHEN=(87,14,SS,EQ,C'-'),
FINDREP=(STARTPOS=87,ENDPOS=99,IN=C'-',OUT=C'0'),HIT=NEXT),
IFTHEN=(WHEN=(86,1,CH,NE,C'-'),
OVERLAY=(86:C' '))
could you please help me.
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
how about the missing comma on the line above?
Back to top
venugopal404 New User Joined: 14 Dec 2010Posts: 13 Location: hyderabad
Dick,
My Aplogies..
there was a comma when i ran it..but while pasting here in the FORUM..i missed it in copy n paste.
below is the sort-card
Code:
OPTION COPY
INREC IFTHEN=(WHEN=(86,15,SS,NE,C'.'),
OVERLAY=(98:C'.00',20X),HIT=NEXT),
IFTHEN=(WHEN=(86,15,SS,EQ,C'.'),
BUILD=(86:1,15,SQZ=(SHIFT=RIGHT)),HIT=NEXT),
IFTHEN=(WHEN=(105,1,CH,EQ,C' '),
FINDREP=(STARTPOS=86,ENDPOS=100,IN=C' ',OUT=C'0'),HIT=NEXT),
IFTHEN=(WHEN=(86,15,SS,EQ,C'-'),
*
OVERLAY=(86:C'-'),HIT=NEXT),
IFTHEN=(WHEN=(87,14,SS,EQ,C'-'),
FINDREP=(STARTPOS=87,ENDPOS=99,IN=C'-',OUT=C'0'),HIT=NEXT),
IFTHEN=(WHEN=(86,1,CH,NE,C'-'),
OVERLAY=(86:C' '))
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
You have a Signed Free Format field, in DFSORT terms. I don't know if Syncsort has them, maybe that is the reason for the weirdness.
You "arrange in that way" with an appropriate EDIT mask.
If you want to then add them, and have the total at the end of the file, you should be able to do that with TRAILER1 and again using SFF.
I can't try this with Syncsort, and haven't tried it with DFSORT.
If the commas or decimal point give you problems despite SFF, you could try to FINDREP them to C''.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
what column does the last byte in this statement occupy ?
Code:
FINDREP=(STARTPOS=86,ENDPOS=100,IN=C' ',OUT=C'0'),HIT=NEXT),
Gerry
Back to top
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006Posts: 6966 Location: porcelain throne
hence the missing comma..........
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
See if this gets you somewhere:
Code:
//STEP0100 EXEC PGM=SORT
//CHKOUT DD DUMMY
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(20:1,14,SFF,
EDIT=(STTTTTTTTT.TT),SIGNS=(,-)))
OUTFIL REMOVECC,TRAILER1=(20:TOT=(20,13,SFF,
EDIT=(STTTTTTTTT.TT),SIGNS=(,-)))
//SORTIN DD *
-213.45
9,865.56
65,654.98
-55,455.65
-45,545.56
Gives:
Code:
-213.45 -000000213.45
9,865.56 000009865.56
65,654.98 000065654.98
-55,455.65 -000055455.65
-45,545.56 -000045545.56
-000025694.12
If you are just after the total, you don't even have to reformat the number, just go with the TRAILER1 with your original data.
Back to top
venugopal404 New User Joined: 14 Dec 2010Posts: 13 Location: hyderabad
Hi Bill..
The Above Piece of sort-card is working fine when the amount field is in first 15 bytes of the input file.In my case the amount field is present in 86-100 position.
could you please help me in modifying the above sort-card..
In the sort-card, where can i specify the starting position of the amount field in my case..
Back to top
venugopal404 New User Joined: 14 Dec 2010Posts: 13 Location: hyderabad
hello All..
below code is working fine for my requirement..
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(86:86,14,SFF,
EDIT=(STTTTTTTTT.TT),SIGNS=(,-)))
OUTFIL REMOVECC,TRAILER1=(86:TOT=(86,13,SFF,
EDIT=(STTTTTTTTT.TT),SIGNS=(,-)))
Thanks All for ur support and help...
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Good to hear it is working - thank you for letting us know
d
Back to top
Please enable JavaScript!