View previous topic :: View next topic
Author
Message
raj_mainframe08 New User Joined: 11 Sep 2007Posts: 65 Location: Gurgaon
I am trying to work on following
Expand the 3rd byte from 1 to 3 bytes and if in the input file at the 3rd position its 0 or * then put 000 or ***
For example
Input file
Output file should be
Code:
AB000CD
ABC DE
AB***CD
I can do that in 2 steps
Step 1 SORT card. This will insert 2 spaces after position 3
Code:
OPTION COPY
INREC FIELDS=(1:1,3,6:4,2)
Step2
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(3,1,CH,EQ,C'0'),OVERLAY=(4:C'00')),
IFTHEN=(WHEN=(3,1,CH,EQ,C'*'),OVERLAY=(4:C'**'))
Can this be done in one step? May be through icetool or DFSORT. Please advice
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
just run step2 and use build instead of overlay.
Gerry
Back to top
raj_mainframe08 New User Joined: 11 Sep 2007Posts: 65 Location: Gurgaon
Hi,
If i used only BUILD as below without running STEP 1 as below
Code:
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(3,1,CH,EQ,C'0'),BUILD=(4:C'00')),
IFTHEN=(WHEN=(3,1,CH,EQ,C'*'),BUILD=(4:C'**'))
I am getting following
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
try this
Code:
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(3,1,CH,EQ,C'0'),BUILD=(1,3,4:C'00',4,2)),
IFTHEN=(WHEN=(3,1,CH,EQ,C'*'),BUILD=(1,3,4:C'**',4,2)),
IFTHEN=(WHEN=NONE,
BUILD=(1,3,4:C' ',4,2))
Gerry
Back to top
raj_mainframe08 New User Joined: 11 Sep 2007Posts: 65 Location: Gurgaon
Hi,
Thanks for this. This is working but its not working on records having values not equal to * or 0. Example
should give i.e 2 spaces in the 2nd record
Code:
AB000CD
ABC DE
AB***CD
But with the above code, i am getting i.e. no spaces in the 2nd record
Code:
AB000CD
ABCDE
AB***CD
Can there be Not equal to * or 0 condition that can be put[/code]
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
check my code again.
Gerry
Back to top
raj_mainframe08 New User Joined: 11 Sep 2007Posts: 65 Location: Gurgaon
Hi Gerry,
Many many thanks. Its worked. I learned about BUILD today. I also tried with following code and i am getting the same results
Code:
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(3,1,CH,EQ,C'0'),BUILD=(1,3,4:C'00',4,2)),
IFTHEN=(WHEN=(3,1,CH,EQ,C'*'),BUILD=(1,3,4:C'**',4,2)),
IFTHEN=(WHEN=(3,1,CH,NE,C'*',OR,3,1,CH,NE,C'0'),
BUILD=(1,3,4:C' ',4,2))
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
You could try this. For each record it repeats the third byte to positions four and five. Then using SS it tests for not 0 or * and puts two blanks in positions four and five for all but 0 and *.
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,3,3,1,3,1,4,2)),
IFTHEN=(WHEN=(3,1,SS,NE,C'0,*'),
OVERLAY=(4:2X))
There is now only one reference to 0 or * and if the values have to be changed/extended the changes to the code are minimal.
Using symbols/SYMNAMES would clarify what it is doing and reduce potential maintenance issues.
Back to top
madprasy New User Joined: 08 Apr 2008Posts: 34 Location: Chennai
Bill Woodger - Superb..!!
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
Quote:
Then using SS it tests for not 0 or * and puts two blanks in positions four and five for all but 0 and *.
this should really read
Quote:
Then using SS it tests for not 0 or * or , and puts two blanks in positions four and five for all but 0 and * and ,.
Personally I'm against using SS with multiple selections in the same statement.
Gerry
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Hi,
I'm not sure what you think it should be saying.
(x,1,SS,EQ,C'0,*') will be true for 0 or *.
(x,1,SS,NE,C'0,*') will be true for everything except 0 or *.
The comma is just a separator for the values.
For me the SS with multiple values is poweful. Multiple values can be tested for without worry about OR or AND or multiple IF statements. Like an 88 in COBOL with multiple values. Simplifies things.
The simplification attempted here was different: to only have the "0" or "*" appear once in the code. When the code is changed, it is much more difficult to get it wrong - as it remove the chance of testing for one value and setting another.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi Bill,
SS doesn't really use the separator as a separator. It's just another character
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,3,3,1,3,1,4,2)),
IFTHEN=(WHEN=(3,1,SS,NE,C'0,*'),
OVERLAY=(4:2X))
The above code equates to
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,3,3,1,3,1,4,2)),
IFTHEN=(WHEN=(3,1,CH,NE,C'0',&,
3,1,CH,NE,C',',&,
3,1,CH,NE,C'*'),
OVERLAY=(4:2X))
Gerry
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Hi Gerry,
Do you have a reference for that? The sperator needn't be a comma, it can be anything which is not required in the test. But a seperator is needed as a separator, otherwise the orther SS test will be done.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Arriving slowly at what you mean Gerry. Some interesting effects.
The separator used can be any character - just make sure it cannot appear in the data being searched.
If the separator does/can exist in the data being searched, you can/will get unintended results. It is in the manual, under INCLUDE.
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Hi Gerry,
Thanks. Good to see an explanation. I wad hondered about the results I had found at your prompting.
Back to top
Please enable JavaScript!