Page 1 of 1

Field data split

Posted: Tue Nov 16, 2004 12:40 am
by badri
Hi,

Source has 'desc1' field that contains 6000 characters (max) and that need to be split into several records of 100 chars each

ex. 1 Record ('desc1' - 720 characters) => 8 Records (7 records with 100 characters each and 8th record will contain 20 characters)

:)

Posted: Tue Nov 16, 2004 6:41 am
by roy
Hi,
I think you might find a routine to do this is apropriate.
simply concatenate the field delimiter after every 100 characters.
I think something like a:

Code: Select all

newStr = ''
fieldDelimiter = "," * change this to fit your delimiter
strLength = Len(str)
idx =0
for i = 0 to strLen step 100
  If i <= strLen And i > 0 Then newStr := fieldDelimiter
  newStr := str[1+i,100]
  idx = i+1
next i
newStr := str[idx,strLength - idx]
probably you'll need to debug this code since it is spontanious code, not debuged or syntax proof!

IHTH,

Posted: Tue Nov 16, 2004 2:48 pm
by ray.wurlod
Roy has tried to write the Fold() or Fmt() function, which already exist as intrinsic DataStage BASIC functions to do exactly what you ask.

Use this design.

Code: Select all

   source  ----->  Transformer  ----->  SeqFile  ----->  (more)
Read one column from source.

In the Transformer stage apply the Fold() function, then convert field marks to column separator characters.
Convert(@FM, "|", Fold(InLink.SourceCol, 100))
or
Convert(@TM, "|", Fmt(InLink.SourceCol, "100L"))

Write one column to the Sequential File stage, with 000 as the delimiter character, and 000 as the quote character.

Read from the Sequential File stage using "|" as the delimiter character.

Posted: Tue Nov 16, 2004 3:28 pm
by roy
Well Guess that happens when no DS available and my memory core dumps :oops: