|
View previous topic :: View next topic
|
| Author |
Message |
rocky_balboa
New User

Joined: 24 Mar 2010 Posts: 61 Location: Cape of Good Hope
|
|
|
|
Hi ,
I am trying to code an OUTREC on OUTFIL but unable to. I am creating a SORT card which will validate the header and trailer and depending on validation failure OUTREC into the HEADER error file or the TRAILER error file accordingly.
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1001:SEQNUM,11,ZD)),
IFTHEN=(WHEN=(1,1,ZD,EQ,9),
OVERLAY=(1001:1001,11,ZD,SUB,+2,M10,LENGTH=11))
OUTFIL FNAMES=HEADER,INCLUDE=((1001,11,ZD,EQ,1),AND,
((1,1,CH,NE,C'0'),OR,
((23,8,CH,LT,DATE1-2),OR,
(23,8,CH,GT,DATE1+2)))), <-this comma-
OUTREC IFTHEN=(WHEN=(1,1,CH,NE,C'0'),
OVERLAY=(1:C'HEADER RECORD TYPE IS NOT 0',53X)),
IFTHEN=(WHEN=((23,8,CH,LT,DATE1-2),OR,
(23,8,CH,GT,DATE1+2)),
OVERLAY=(1:C'HEADER DATE IS INVALID*****',53X))
OUTFIL FNAMES=TRAILER,INCLUDE=((1,1,ZD,EQ,9),AND,
(3,11,ZD,EQ,1001,11,ZD),AND,
(1001,11,ZD,GT,0))
|
When I put a comma as indicated it says me a syntax error and when I remove the comma it works fine but the problem in that case is that I can code only one OUTREC.
How do I code so that I can have 2 files in the o/p where in I can code the conditions for header and trailer error file separately.
Regards |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Firstly, read this.
Is it any clearer?
You've fallen into the unintended trap of thinking that just because OUTFIL has OUTREC, the OUTREC on OUTFIL must be the same as OUTREC.
If you want to use IFTHEN on OUTFIL, just use it. OUTREC on OUTIL means BUILD, so just use BUILD.
| Code: |
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1001:SEQNUM,11,ZD)),
IFTHEN=(WHEN=(1,1,ZD,EQ,9),
OVERLAY=(1001:1001,11,ZD,SUB,+2,M10,LENGTH=11))
OUTFIL FNAMES=HEADER,INCLUDE=((1001,11,ZD,EQ,1),AND,
((1,1,CH,NE,C'0'),OR,
((23,8,CH,LT,DATE1-2),OR,
(23,8,CH,GT,DATE1+2)))),
IFTHEN=(WHEN=(1,1,CH,NE,C'0'),
OVERLAY=(1:C'HEADER RECORD TYPE IS NOT 0',53X)),
IFTHEN=(WHEN=((23,8,CH,LT,DATE1-2),OR,
(23,8,CH,GT,DATE1+2)),
OVERLAY=(1:C'HEADER DATE IS INVALID*****',53X))
OUTFIL FNAMES=TRAILER,INCLUDE=((1,1,ZD,EQ,9),AND,
(3,11,ZD,EQ,1001,11,ZD),AND,
(1001,11,ZD,GT,0)) |
And, does this bit look simpler?
| Code: |
OUTFIL FNAMES=HEADER,
INCLUDE=(1001,11,ZD,EQ,1,
AND,
(1,1,CH,NE,C'0',
OR,
23,8,CH,LT,DATE1-2,
OR,
23,8,CH,GT,DATE1+2)), |
Some people "like" the ANDs and ORs at the "end" of a line, some at the beginning. If they are on a line of their own they are at both the end and the beginning. Use indentation to express your intent (easier then for someone to read (and note if it is wrong). Don't use brackets where not needed (SORT "parses" its control cards by knowing what may come next, the individual conditional elements of INCLUDE/OMIT COND/= do not need brackets). |
|
| Back to top |
|
 |
rocky_balboa
New User

Joined: 24 Mar 2010 Posts: 61 Location: Cape of Good Hope
|
|
|
|
| I am still not clear with restrictions on OUTREC on OUTFIL or under what circumstances it cannot be used. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OUTREC, as in the statement OUTREC, like you tried to use it, can never be used on OUTFIL.
Never.
What is the OUTREC on OUTFIL? It is a parameter of OUTFIL. That is something entirely different from a statement.
The OUTREC parameter is part of OUTFIL.
The OUTREC statement, is a statement, like INREC and INCLUDE and SORT and MERGE and SUM and OUTFIL.
If you use BUILD on OUTFIL instead of OUTREC on OUTFIL, any confusion disappears.
If you want to be about to do on OUTFIL what you can do on OUTREC (or INREC) then it is easy. You just do it in the same way.
| Code: |
INREC BUILD=...
OUTREC BUILD=...
OUTFIL BUILD=... |
Especially instead of:
| Code: |
INREC FIELDS=...
OUTREC FIELDS=...
OUTFIL OUTREC=... |
On the OUTFIL OUTREC=, note the =. Note that the OUTREC statement doesn't have an =. That is because they are two entirely different things, which use the same letters of the alphabet in the same under but are otherwise unconnected. It is known as "overloading".
It is the "old" way of coding it, and it will be supported for ever (so that old code is not required to be changed).
I've already shown you what your code should look like. If there is still a problem, you're going to have to explain it clearly. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|