View previous topic :: View next topic
|
Author |
Message |
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
Hi All,
Can you please let me know how to remove NULL values from a file using sort.
My input file is LRECL=708 and its FB file.
EX:- When i browse
Code: |
aaaa...xxxx....b0b..vvvvvvv.......
CCCc...xxxx....b0b..vvvvvvvccc....
bbbbbbbb........ddddddddddddd......
xx.........v....v....vvvvv...........bb... |
Out put should be
Code: |
aaaa xxxx b0b vvvvvvv
CCCc xxxx b0b vvvvvvvccc
bbbbbbbb ddddddddddddd
xx v v vvvvv bb |
whic means NULL values might present in any position in record, inspite of position and length of NULL value it needs to be removed from record |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
mild suggestion...
review Your understanding of the "null value" concept...
there is no such a a thing as a null value, every byte of eight bit is a value,
even 00
nullness is a convention to indicate that a value is not provided
when You browse a dataset and You do not see anything, what You do not see
are either blanks or unprintable/undisplayable character
meditate a bit and repost with correct info |
|
Back to top |
|
|
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
Enrico,
Yes, That's right. The thing is my input file is geting generated some where from a table where some table fields are NULL's
They are generating the file and giving it to me, when i browse it it will be show as my input file which i pasted above.
I need to removes those dots and replace with spaces. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
what do You see when You try to browse with "hex on" |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
if this is a db2 dump,
the length of some of the 'unprintable' char seem very long,
perhaps some of the columns are numeric,
in which case I would go back to the dump and CAST those columns to char.
While you are at it, you can use a VALUE scalar function to return spaces for NULL columns. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
I know that I am right, but You do not seem to understand my point..
what is going to be the record layout of the file...
from the data posted just substituting blanks for unprintables will just yield garbage
looks like You are considering everything as char, what You see as dots (unprintables) might also be COMP values |
|
Back to top |
|
|
deepuvja
New User
Joined: 06 Mar 2008 Posts: 5 Location: chennai
|
|
|
|
Your query is not clear.
Is your data contain any hexa decimal(non-displayable ) characters?
or it contains only extra ' . ' as you shown in sample data.
If so we can change all . to spaces easily by using syncsort or dfsort
here is the code for it
Here i am trying to convert all . to spaces
hex value of . is 4b and for space is 40
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=MYIDSR.TEST.TEMP1,DISP=SHR
//SORTOUT DD DSN=MYIDSR.TEMP.TEST2,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,5),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
ALTSEQ CODE=(4B40)
OUTREC FIELDS=(1,708,TRAN=ALTSEQ)
/*
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
when browsing under ISPF dots are not dots... just unprintable/not_displayable chars
to find out the exact value You must browse in hex mode "hex on"
until the TS shows a HEX ON screen no suggestion can be made |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Hima1985,
Look at the syspunch dataset from the unload step. It WILL list all the columns which has a null value and their positions. Also note that REMOVE is quite different from REPLACE. If you don't want the trailing low values on a varchar column , all you need to do use a char function on that column and it would replace all the low values to a space.
Code: |
CHAR(VARCHAR COLUMN NAME) |
You dont even need a utility when everything can be done in DB2 itself |
|
Back to top |
|
|
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
Kolusu
Yes we can do that but my problem is i am not dumping it from a DB2 table, some one else doing it. they have pre designed program to do the same.....and they are not ready to change their codes for this...I need to find out a soulution
I am not sure what will be there...when ever i browse it shows like dots and i need to make it to spaces.... |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Hima1985 wrote: |
I am not sure what will be there...when ever i browse it shows like dots and i need to make it to spaces.... |
Hima1985,
Read what Enrico was trying to tell. Dots in browse mode can mean any thing.
ex .
1. open a empty file
2. Type HEX on at the command prompt
3. Insert a empty line
Code: |
----+----1
**********
4444444444
0000000000
|
3. Now overlay the top 4's with zero's and the last byte on lower with a 1C (which is +1 in packed decimal format)
like this
Code: |
----+----1
0000000001
000000000C
|
save this and re open the same in browse mode , you would see dots but if you replace all the dots to spaces you are making the actual packed decimal value invalid.
So you really need to understand what the dots mean and what you need to replace them with. Put a hex on the file and see the value in hex |
|
Back to top |
|
|
Hima1985
New User
Joined: 17 Apr 2009 Posts: 70 Location: India
|
|
|
|
Kolusu
Its showing like this
Code: |
0000000004
000000000F |
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
what You see is a packed ( comp-3 in COBOLESE ) number with a value of 4
investigate about...
the record layout ( the order in which the columns are unloaded )
the format of each column |
|
Back to top |
|
|
|