IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Replace Spaces occuring between ? & | with X'00'


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 34
Location: Pune

PostPosted: Sat Apr 26, 2008 2:15 pm
Reply with quote

Hi,
I have an I/p file whose fields are delimited by '|'. This file is unloaded from a table which has nullable fields. So if a particular field has null value
in the table, the corresponding value of it in file after download is spaces
with Null indicator(?) at end of that field.

My task requires to replace the spaces of these fields with X'00' . Please note that the spaces of Nullable fields only need to be replaced and there
will be no spaces /null character in the last field as it contains System date.

Eg:
21|asc| ?| | ?|25-04-2008

Need to replace the spaces of 3rd and 5th field only.
The requirement in a nutshell is how do i replace spaces between ? and |.
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Sat Apr 26, 2008 3:42 pm
Reply with quote

Hi Puspojit,

Try this below Sort Card

Code:
OPTION COPY                                 
ALTSEQ CODE=(4000)                           
OUTREC FIELDS=(1:1,7,8:8,1,TRAN=ALTSEQ,9:9,4,
               13:13,1,TRAN=ALTSEQ,14:14,12)



Thanks
Sai
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Apr 26, 2008 4:25 pm
Reply with quote

why don't you use a CASE in the unload to populate with zero when null?
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 34
Location: Pune

PostPosted: Sat Apr 26, 2008 6:04 pm
Reply with quote

Hi Sai,

Thanks for the sort card....it works fine but it would not give the desired result for those nullable fields which have spaces as their value with Null Indicator set off.

Eg : 1|asc| ?| | ?|2500000100
1|asc| | | |2500000100


My requirement is that only the third and fifth field of first record be replaced with X'00' as it has Null Indicator(?) but the second record should not get replaced with X'00' as Null indicator is absent there.

Thus I think there needs to be a condition that shall check that the spaces are between | and ? before replacing them......Please correct me if I am wrong......

Thanks and Regards.
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 34
Location: Pune

PostPosted: Sat Apr 26, 2008 6:59 pm
Reply with quote

Hi Dick,

I have not used CASE over here because I want to replace the whole length of 50 bytes(say) for a Nullable field with 50 X'00'....Now this is only possible if I write X'00' 50 times because I guess I cant use the Padding option in the Case statement .....Please give me an example if you think it is possible with the case statement .....I had used the below statement

CASE WHEN NME_MIDDLE IS NULL THEN X'00'
ELSE NME_MIDDLE END

This would fill only one X'00' for that column, the rest shall contain spaces......My requirement is that all the 50 bytes for this field should
be filled with X'00'.....I hope I am clear with my requirement

Thanks in advance....
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Apr 26, 2008 7:05 pm
Reply with quote

Quote:
Now this is only possible if I write X'00' 50 times because I guess


... that will the fastest and less straining solution for your fingers
You have already typed more than 98 zeroes
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 34
Location: Pune

PostPosted: Mon Apr 28, 2008 3:32 pm
Reply with quote

Hi Enrico Sorichetti ......

I tried this statement for my requirement

CASE WHEN NME_MIDDLE IS NULL THEN REPEAT(X'00',50)
ELSE NME_MIDDLE END

It works fine but I do not understand how do I use the same statement for a Decimal/date column which are nullable ? Here it works fine as this column is declared as Varchar. Please note that I want to move only Low values(to all columns. irrespective of their types) to the fields having null value in table.

I got my answer by using Case statement(for char fields) and the sort card(for numeric/date fields) given by Sai....Its a bit lenghthy indeed but gives me the desired results.....Please let me know whether there is a shorter and smarter approach

Regards,
Puspojit.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Apr 28, 2008 11:38 pm
Reply with quote

Puspojit,

If you have used DSNTIAUL program to unload the records from the table, all nullable columns are unloaded with X'00' and there is no need for you to change anything.
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 34
Location: Pune

PostPosted: Tue Apr 29, 2008 11:19 am
Reply with quote

Thanks for the info.....I will try the same .
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 34
Location: Pune

PostPosted: Tue Apr 29, 2008 11:40 am
Reply with quote

Would there be any performance issue if I use DSNTIAUL instead of
INZUTILB ?

Regards,
Puspojit
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Tue Apr 29, 2008 4:40 pm
Reply with quote

Hi Puspojit,

Try the below Sort Card


Code:
INREC IFTHEN=(WHEN=(9,1,BI,EQ,X'6F'),             
           BUILD=(1:1,7,8:X'00',9:9,17),HIT=NEXT),
      IFTHEN=(WHEN=(14,1,BI,EQ,X'6F'),           
           BUILD=(1:1,12,13:X'00',14:14,17))     
SORT FIELDS=COPY                                 


Thanks
Sai
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Apr 29, 2008 9:04 pm
Reply with quote

Puspojit,

INZUTILB also can pad binary zeroes for null columns and it performs much better than DSNTIAUL.

Saiprasadh,

You are only considering 2 columns with null values. and OP seems to have more than that. Aslo you are only padding 1 byte with binary zeros where as OP wants all the bytes of null able columns to be padded with binary zeros.
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 34
Location: Pune

PostPosted: Wed Apr 30, 2008 9:57 am
Reply with quote

Quote:

INZUTILB also can pad binary zeroes for null columns


Hello,
I am sorry but I tried to do the same (albeit,using case statement) but got error for date fields( Error code -311). However I achieved the results
of moving Low-values to Numeric field by Casting them as char and then applying case statement. Eg:

Code:

CASE WHEN CAST(NUM_TENANT AS CHAR(2)) IS NULL THEN REPEAT(X'00',2)
ELSE CAST(NUM_TENANT AS CHAR(5)) END


But I am sure by you meant some other process of achieving the results
since you mentioned "padding".But Padding would pad low values to all
the values occuring in the nullable column.....Please correct me if I am wrong.

I am eager to use the High performance unload utility....Could you please
remove this stumble in my path ?
icon_question.gif
Thanks and Regards,
Puspojit.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top