trimming line terminator

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

trimming line terminator

Post by allavivek »

Hi All,

I was trying to trim line terminator that was causing my sequence to get aborted..

In sequence i am using loop through list of items.The last field is taking line terminator and causing termination...

I tried convert(@FM,",", Execute_Command.$CommandOutput)
before loop activity but it didnt work...

How to remove line terminator??

thnak you
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

I even tried

Convert(@FM,',',Trim(Execute_Command.$CommandOutput," "))

not working still


Any suggestions
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Please explain what "didn't work" entails? Your first expression should have removed the terminator, but replaced it with a comma. What command are you executing?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

Hi ray,

basically i was reading delimited values from file to loop to perform list loop.

When it comes to last field the sequence is getting executed.

......execute_command1 --->start loop---->user variable----->execute command2 ---->stop------

The execute command 2 was getting failed because of last field because of extra termination character ...

so i added user variable activity and tried to remove the extra character of last field....

is this correct approach or i should do any thing to get my loop finish succesfully....

thank you..
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In your post, "termination character" means what? An extra comma on the end of the loop list or a trailing Field Mark there from the Execute Command?
-craig

"You can never have too many knives" -- Logan Nine Fingers
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

Chulett,

Im my file i have like

aaa,bbb,ccc

while processing loop for values aaa,bbb it was processing good but for ccc the sequence is getting failed...

in loop iam having execute command as ...

. somescript param1 param2

the error coming was..

command : . somescript param1
reply: param2
execution failed.

What i thought was along with ccc , termination char was coming which was leading failure of sequence...

How to get rid of this??
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Doesn't really answer the question, I'm afraid. Can you post your actual, unedited error message?
-craig

"You can never have too many knives" -- Logan Nine Fingers
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

Sorry chulett , actually i was out of my office yesterday so i couldnt post error message..

seq_xxxxxxxxxxxxx..JobControl (@yyyyyy): Executed: . script.ksh BEGIN param1 param2 param3 30 param4 param5
Reply= param6 param7 seq_xxxxxxxxxxxxx
Output from command ====>

seq_xxxxxxxxx..JobControl (@yyyyyyy): Command . did not finish OK, reply = '-1'

param5 contains values from loop....for last value in loop sequence is getting aborted..


Any suggestions please....
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do you have the 'automatically handle' option turned on? It considers any 'non-zero' return code to be a failure. What happens if you turn that off if on?
-craig

"You can never have too many knives" -- Logan Nine Fingers
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

Hi chulett,

I turned off the "automatically handle option" , but the error persists..

i was using

..execute command....>user variable--->statr loop---->command---->stop....

In user variable iam giving
convert(@FM,'',Execute_Command.$CommandOutput)

Is this correct way to handle...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes - *if* that is the problem. However, doesn't sound like it is. What is your script actually doing? What kind of status does it return? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

Hi chulett,

My script is reporting event to log database.it is working fine for all iterations..but for last one its getting failed..

Any suggestions..
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

Hi chulett,

On searching this forum i found

"Trim the final field mark from the command's output and convert the other field marks to a printable delimiter "


Can you tell me the funtion for the above statement...

thank you..
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

CONVERT(@FM,CHAR(10),FIELD(Execute_Command.$CommandOutput,@FM,1,DCOUNT(Execute_Command.$CommandOutput,@FM)-1))

This removes the last field then converts all field marks into char(10)
allavivek
Premium Member
Premium Member
Posts: 211
Joined: Sat May 01, 2010 5:07 pm

Post by allavivek »

Hi andrw ,

I tried your code but it didnt worked...

Thank you..
Post Reply