View previous topic :: View next topic
|
Author |
Message |
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
I have a requirement where i have to fill up default values for some columns.
INPUT RECORD
Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6
****** ***************************** Top of Data ******************
000001 12/31/2010 22:00:00 +11111111.11111 ABCDEFGHI
000002 12/31/2010 22:00:00 178036.678 -12345678.12345 10 ABCDEFGHI
|
OUTPUT RECORD
Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6
****** ***************************** Top of Data ******************
000001 12/31/2010 22:00:00 0 +11111111.11111 0 ABCDEFGHI
000002 12/31/2010 22:00:00 178036.678 -12345678.12345 10 ABCDEFGHI |
The requirement is to put '0' (Zero) in the places 21-30 and 49-50 if there is a space in the specified positions. I want a generic step instead of coding all the positions and checking.
Is there something grouping we can do instead of coding separate IFTHEN statements as below? As there are many such columns to be checked.
Code: |
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(21,10,CH,EQ,C' '),
OVERLAY=(30:C'0')),
IFTHEN=(WHEN=(49,2,CH,EQ,C' '),
OVERLAY=(50:C'0')) |
LRECL of the file is 60.
This file will be used to load a DB2 table using load utility and the column is defined as "NOT NULL" so we are supposed to put zeros as the values.
Also can you please let me know if there is any option in the DB2 load utility to achieve the same.
Using DB2 V8 Zos. |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
We have SYncSort in our shop. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Is there something grouping we can do instead of coding separate IFTHEN statements as below? |
Huh. . .?
If you want to check 8 separate "things" what good would "grouping" do? |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Ok... Thanks for the reply... Also there is nothing in the Load utility to handle this? |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
Code: |
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(21,10,CH,EQ,C' '),
OVERLAY=(30:C'0')),
IFTHEN=(WHEN=(49,2,CH,EQ,C' '),
OVERLAY=(50:C'0'))
|
|
Doesn't this just put a single '0' in the last byte of each field?
Garry. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Checking the last field position of the fields for a space will do the job too. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Garry Carroll wrote: |
Quote: |
Code: |
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(21,10,CH,EQ,C' '),
OVERLAY=(30:C'0')),
IFTHEN=(WHEN=(49,2,CH,EQ,C' '),
OVERLAY=(50:C'0'))
|
|
Doesn't this just put a single '0' in the last byte of each field?
Garry. |
Yes, however it then matches TS's example of output. I don't go for holding numerics in effectively "edited" fields, but it is what he says he wants (for now). |
|
Back to top |
|
|
kratos86
Active User
Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
In order to validate more conditions for a single record, try HIT=NEXT parameter. The example which you showed does not bring you the specified output as it stops processing the validation once it encounters a true condition. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
PeterHolland wrote: |
Checking the last field position of the fields for a space will do the job too. |
Works in this sort of example. I always prefer to check the whole field in case it is happens to match on the one byte but the rest is garbled (I believe "junk values" is the contemporary description).
It's not just my day to be picky, I'm always picky :-) |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Bill,
pick someone else please |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Nobody else is being as useful as you are today, Peter (and I mean that genuinely, except about the "bubbles"). |
|
Back to top |
|
|
|