|
View previous topic :: View next topic
|
| Author |
Message |
SiFocusUK
New User
Joined: 21 Jun 2007 Posts: 6 Location: Essex, UK
|
|
|
|
Hi,
I have a problem/dilemma which we are hoping can be accomodated in DFSORT but havent been able to successfully resolve it yet.
There is already a sort in place to split a file and accumulate a count on the trailers of the 2 outputs so we would like to add this in for tidyness rather than create a new step.
We have an incoming file with an amount and a credit/debit flag i.e.
xxxxxC00000000000000100xxxxxxxxxx
xxxxxC00000000000000200xxxxxxxxxx
xxxxxC00000000000000500xxxxxxxxxx
xxxxxD00000000000000200xxxxxxxxxx
xxxxxC00000000000000100xxxxxxxxxx
the trailer on the file has 2 fields (one credit and one debit) that we would like to accumulate the totals into.
It sounded pretty simple but i'm afraid i have to admit is got us foxed.
In the example above the trailer would read:
TLRxx00000000000000900x00000000000000200xxxxx
Any assistance would be grately appreciated!
Many Thanks,
Simon |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Can you show the code that is not working, and let us know what it is doing instead? |
|
| Back to top |
|
 |
SiFocusUK
New User
Joined: 21 Jun 2007 Posts: 6 Location: Essex, UK
|
|
|
|
The code we have tried just gives us operand errors or invalid syntax. At the moment its only been added for SORTOF01. The lines with # are what i've added although i'm not sure if SUM will work but TOTAL/SUBTOTAL etc dont seem to either.
| Code: |
SORT FIELDS=(COPY)
OUTFIL FNAMES=SORTOF01,
IFOUTLEN=150,
INCLUDE=(1,2,SS,EQ,C'00,99',OR,(66,3,SS,EQ,C'100,240')),
IFTHEN=(WHEN=(1,2,CH,NE,C'00'),
OVERLAY=(151:SEQNUM,9,ZD,START=0),HIT=NEXT),
# IFTHEN=(WHEN=(25,1,CH,EQ,C'D'),
# SUM FIELDS=(171,17,26,17),FORMAT=ZD),
# IFTHEN=(WHEN=(25,1,CH,EQ,C'C'),
# SUM FIELDS=(191,17,26,17),FORMAT=ZD),
IFTHEN=(WHEN=(1,2,CH,EQ,C'99'),
OVERLAY=(24:151,9),
# OVERLAY=(33:171,17),
# OVERLAY=(50:191,17))
OUTFIL FNAMES=SORTOF02,
IFOUTLEN=150,
INCLUDE=(1,2,SS,EQ,C'00,99',OR,(66,3,SS,EQ,C'300')),
IFTHEN=(WHEN=(1,2,CH,NE,C'00'),
OVERLAY=(161:SEQNUM,9,ZD,START=0),HIT=NEXT),
IFTHEN=(WHEN=(1,2,CH,EQ,C'99'),
OVERLAY=(24:161,9))
|
Thank you  |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, yes, it is not possible to make up your own syntax.
The SUM cannot be part of an IFTHEN.
You later have multiple OVERLAYs on an IFTHEN. You can't do that, but you can specify multiple columns in a single OVERLAY.
You do need to extend the record, with the credit value in one place and zero in another for credits and vice-versa for debits. You should then be able to get the TRAILER1 TOTALing for those two fields.
Since you are only processing 00 and 99 types, there may be benefit in
| Code: |
| INCLUDE COND=(1,2,SS,EQ,C'01,99') |
Get's rid of any other records as early as possible, and allows simplification of your OUTFIL INCLUDE. Won't make much difference to resource use for a COPY operation, but neater to be consistent. |
|
| Back to top |
|
 |
SiFocusUK
New User
Joined: 21 Jun 2007 Posts: 6 Location: Essex, UK
|
|
|
|
thank you.
I've been doing a bit more and some digging as well and i think i've come up with something that should give us what we want... but it still doesnt work.
I'm using this:
| Code: |
SORT FIELDS=(COPY)
OUTFIL FNAMES=SORTOF01,
IFOUTLEN=150,
INCLUDE=(1,2,SS,EQ,C'00,99',OR,(66,3,SS,EQ,C'100,240')),
IFTHEN=(WHEN=(1,2,CH,NE,C'00',AND,(25,1,CH,EQ,C'D')),
OVERLAY=(171:26,17,191:+0,TO=ZD,LENGTH=17)),
IFTHEN=(WHEN=(1,2,CH,NE,C'00',AND,(25,1,CH,EQ,C'C')),
OVERLAY=(191:26,17,171:+0,TO=ZD,LENGTH=17)),
IFTRAIL=(HD=YES,TRLID=(1,2,CH,EQ,C'99'),
TRLUPD=(24:COUNT=(EDIT=(TTTTTTTTT)),
33:TOT=(171,17,ZD,LENGTH=17),
50:TOT=(191,17,ZD,LENGTH=17)))
|
but getting
| Code: |
ICE027A 9 END OF SORTOF01 FIELD BEYOND MAXIMUM RECORD LENGTH
|
Must be something to do with the OVERLAYs outside the input record length but i'm not sure what. Do i have to use BUILD instead ? |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| To check the processing, you can extend the IFOUTLEN to include the extended fields. It should now run, but you don't want the records that long... |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| OK, TRLUPD is not going to work as-is because it uses values which are present on input to OUTFIL. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It is not clear if you have a trailer on you input, your sample doesn't show it.
If you use TRAILER1, you should be able to get at the extended fields to generate the trailers.
If you have a trailer on the input, move your "processing" to OUTREC, then IFTRAIL will have access to the extended fields which are input to OUTFIL. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|