View previous topic :: View next topic
Author
Message
op New User Joined: 31 Oct 2006Posts: 48 Location: Chennai
Hi,
When using inrec in sort, i want to use IFTHEN and INREC fields at the same time.
For example,
If my input file(FB, LRECL=9) is:
UTHHJKADF
GTHMNGAVF
KGHGAJYUN
In the output file it should be as:
1st byte should be:
'1' IF 1,1,CH,EQ,C'U'
'2' IF 2,1,CH,EQ,C'T'
'3' IF 3,1,CH,EQ,C'H'
and the record as in input file will be placed in output file from position 2.
i.e. the output should be
1UTHHJKADF
2GTHMNGAVF
3KGHGAJYUN
The actual conditions i use are so huge, i planned to use
INREC IFTHEN to overlay the TEXT at the 1st position.
Now, HOW can i use INREC to place the input file record from position 2.
Your timely help will be highly appreciated.
Regards,
OP
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
For each IFTHEN clause, you must use BUILD or OVERLAY to specify the action to be taken when the WHEN condition is satisfied. In your case, you would use BUILD in each IFTHEN clause. Here's a DFSORT job that will do what you asked for:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/9)
//SORTOUT DD DSN=... output file (FB/10)
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'U'),BUILD=(C'1',1,9)),
IFTHEN=(WHEN=(2,1,CH,EQ,C'T'),BUILD=(C'2',1,9)),
IFTHEN=(WHEN=(3,1,CH,EQ,C'H'),BUILD=(C'3',1,9))
/*
Back to top
op New User Joined: 31 Oct 2006Posts: 48 Location: Chennai
Hi Yaeger,
Thanks a lot for the reply.
I want to write all the records that are not selected by any IFTHEN condition to other file. How do i do it?
Please help.
Regards,
OP
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Quote:
I want to write all the records that are not selected by any IFTHEN condition to other file.
Here's a DFSORT job that will do it:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/9)
//OUT1 DD DSN=... output file1 (FB/10)
//OUT2 DD DSN=... output file2 (FB/9)
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=11,
IFTHEN=(WHEN=(1,1,CH,EQ,C'U'),BUILD=(C'1',1,9)),
IFTHEN=(WHEN=(2,1,CH,EQ,C'T'),BUILD=(C'2',1,9)),
IFTHEN=(WHEN=(3,1,CH,EQ,C'H'),BUILD=(C'3',1,9)),
IFTHEN=(WHEN=NONE,BUILD=(1,9,11:C'N'))
OUTFIL FNAMES=OUT1,INCLUDE=(11,1,CH,NE,C'N'),
BUILD=(1,10)
OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,9)
/*
Back to top
Please enable JavaScript!