Field data split

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
badri
Participant
Posts: 19
Joined: Mon Jul 12, 2004 2:58 am

Field data split

Post 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)

:)
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post 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,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Well Guess that happens when no DS available and my memory core dumps :oops:
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Post Reply