Padding String With Blank

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ganive
Participant
Posts: 18
Joined: Wed Sep 28, 2005 7:06 am

Padding String With Blank

Post by ganive »

Hi All,

I thought I had something very simple to do... but it's not !!

Here's the deal :
I have a dataset, containing string defined as CHAR.
Datas in these string have been TRIMMED.
I want to generate a flat file, fixed length, based on the structure of this Dataset... so I have to add 0,1 or more blank (space) to each field.
At the moment, I just take the Dataset and link it to a flat file.

I thought using the $APT_STRING_PADCHAR in the job creating the Flat File and setting it to " " (space value) would fill my field with blank. It's not.
I tried to set padchar options in the Flat File format properties, I tried in the column properties... nothing.
My Flat File is OK in windows environment, or in DS view data. My field are (seem to be) also padded with space when reading via notepad for example.
But in UNIX, there's no padding... it appears that it is filled with Null value, seen as space in Windows, not seen in UNIX.

Right now, I don't see any solution except propagating space by not "Trimming" my data... but it's not a good choice because of the join operations I have to use etc...

Have you got any advice to solve the Problem ?

ThanX
--------
GaNoU
--------
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

ganive,

if you go to your output stage, choose your column and right-click to enter the "edit row" you will have some string options on the fill character to use. I'm not at a PX computer now, so I can't tell you the exact attribute to set, but that is the correct window to make this output in the format that you wish.
ganive
Participant
Posts: 18
Joined: Wed Sep 28, 2005 7:06 am

Post by ganive »

I tried this already...
Padchar options, Fill char...
Unfortunately it doesn't work... it seems that having the TRIM operation put in a CHAR string has already filled my column with "Null" value :s
ArndW wrote:ganive,

if you go to your output stage, choose your column and right-click to enter the "edit row" you will have some string options on the fill character to use. I'm not at a PX computer now, so I can't tell you the exact attribute to set, but that is the correct window to make this output in the format that you wish.
--------
GaNoU
--------
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What about using VARCHAR() datatypes in the job as the result of a TRIM() and then letting the implicit conversion from varchar to char plus the output attributes take care of the padding?
ganive
Participant
Posts: 18
Joined: Wed Sep 28, 2005 7:06 am

Post by ganive »

Yes, I think it would have been the good way to realize our jobs.
A little bit more "difficult" to do now as we are not far from the end.

I've made a few test and it seems that putting the APT_STRING _PADCHAR option on the job where I put my TRIM value in the CHAR field is another way to solve the problem.

ThX
ArndW wrote:What about using VARCHAR() datatypes in the job as the result of a TRIM() and then letting the implicit conversion from varchar to char plus the output attributes take care of the padding?
--------
GaNoU
--------
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Ganive - excellent solution; somehow I got this thread mixed up with the other one currently running with a similar subject content and recalled that the $APT_STRING_PADCHAR didn't work so I didn't even consider that approach. You've got the best solution for your issue now, though.
ganive
Participant
Posts: 18
Joined: Wed Sep 28, 2005 7:06 am

Post by ganive »

By the way... Thanks a lot for the Help !!
ArndW wrote:Ganive - excellent solution; somehow I got this thread mixed up with the other one currently running with a similar subject content and recalled that the $APT_STRING_PADCHAR didn't work so I didn't even consider that approach. You've got the best solution for your issue now, though.
--------
GaNoU
--------
Post Reply