Problem in setting a job parameter

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
parag.s.27
Participant
Posts: 221
Joined: Fri Feb 17, 2006 3:38 am
Location: India
Contact:

Problem in setting a job parameter

Post by parag.s.27 »

Hello All,

I am having a requirement where i am getting a source flat file, in which there is a column which specifies the Material Type code.

Now i have to generate a new target file for each type of material type code.

So what i thought was that, if i can some how change the target file name which is given as a job parameter, at run time in a transformer then whenever the parameter is set the new file name will be there and hence a new target file will be generated.

But the problem is i am not able to set the parameter. Its giving errcode as -1. i am using it as.

i wrote a routine SETPARAM as

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 
ErrCode = DSSetParam (Jobhandle,ParamName,ParamValue);
Ans = ErrCode

then i called this routine in transformer as : -
SETPARAM(DSJ.ME,"TargetFileName","Value").

Here TargetFileName is the parameter name for my target file.

So i am getting the errcode as -1. Which i assume as of for BADHANDLE. Can anyone please suggest how can i go about it[/code]
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Is my understanding of your requirement right?


Source Flat File

Code: Select all



col_1          col_2       col_3         Material_Type_Code

1                  A             P                Metal
2                  B             Q                Cloth
3                  C             R                Leather
4                  D             S                Metal
5                  E             T                Stone
6                  F             U                Stone

If you input file is something similar to above. How are your expecting your output apart from the Material_Type_Code going into the file_name?

Whale.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

Hi,


It is possible to divide file into multiple file with combination aggregator stage and folder stage....


Thanks,
Anupam
parag.s.27
Participant
Posts: 221
Joined: Fri Feb 17, 2006 3:38 am
Location: India
Contact:

Post by parag.s.27 »

I_Server_Whale wrote:Is my understanding of your requirement right?


Source Flat File

Code: Select all



col_1          col_2       col_3         Material_Type_Code

1                  A             P                Metal
2                  B             Q                Cloth
3                  C             R                Leather
4                  D             S                Metal
5                  E             T                Stone
6                  F             U                Stone

If you input file is something similar to above. How are your expecting your output apart from the Material_Type_Code going into the file_name?

Whale.
I am setting the parameter as

Code: Select all

SETPARAM(DSJ.ME, TargetFileName,source.Material_Type_Code)
hence this will be called for every unique material_type_code for which a different code exists.
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
parag.s.27
Participant
Posts: 221
Joined: Fri Feb 17, 2006 3:38 am
Location: India
Contact:

Post by parag.s.27 »

sb_akarmarkar wrote:Hi,


It is possible to divide file into multiple file with combination aggregator stage and folder stage....


Thanks,
Anupam

Can you please specify How??


Thanks & regards
Parag
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
sb_akarmarkar
Participant
Posts: 232
Joined: Fri Sep 30, 2005 4:52 am
Contact:

Post by sb_akarmarkar »

Parag,

If data is huge we cant work with this. Better to create two jobs First jobs reads distinct of material code from file (use aggregator to get distinct) pass this value as parameter to second job use DSRunjob routine to trigger second job in first job transformer.
But need to think of performance....


Thanks,
Anupam
khaja.arshad
Participant
Posts: 30
Joined: Mon May 29, 2006 11:19 pm

Post by khaja.arshad »

Hi Anupam

Can You explain agai wt u r trying with varaibles V1,V2


Thanks
parag.s.27
Participant
Posts: 221
Joined: Fri Feb 17, 2006 3:38 am
Location: India
Contact:

Post by parag.s.27 »

khaja.arshad wrote:Hi Anupam

Can You explain agai wt u r trying with varaibles V1,V2


Thanks
Hi Arshad,

What Anupam wants to say is as follows.

Code: Select all

StgOldKey = StgNewKey
StgNewKey = Key

StageVar2 = StageVar3
StageVar1 = concate all columns in this var. as col1:col2...and so on
StageVar3 = if StgNewKey = StgOldKey Then StgRecord2:Char(10):StageVar1 Else StageVar1
and now finally print the value of StageVar2
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Problem in setting a job parameter

Post by chulett »

parag.s.27 wrote:So what i thought was that, if i can some how change the target file name which is given as a job parameter, at run time in a transformer then whenever the parameter is set the new file name will be there and hence a new target file will be generated.
Just in case it was not clear in the previous posts - this cannot be done on a number of levels. Not only can you not change job parameter values on the fly inside a running job, the Sequential File stage does not support dynamically changing the output filename during a job run in any fashion.

As noted, a Folder stage will allegedly handle that although I've never had a need to actually test or play with it as a target yet. The only stage I'm aware of that has that specific functionality is the XML Output stage. This can be used to create non-XML files with pass-through columns as long as you aren't all that picky about the names it chooses. :wink:

:idea: For another approach for this, some sort of 'post-processing' to split a single output file up into appropriate parts could be done. You could even handle this in a after-job sub routine, looping through a read of the first file and conditionally closing and opening new output files.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The original -1 (return status from DSSetParam) is DSJE.BADHANDLE. You had not successfully called DSAttachJob with JobHandle as the handle variable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
parag.s.27
Participant
Posts: 221
Joined: Fri Feb 17, 2006 3:38 am
Location: India
Contact:

Re: Problem in setting a job parameter

Post by parag.s.27 »

chulett wrote:
parag.s.27 wrote:So what i thought was that, if i can some how change the target file name which is given as a job parameter, at run time in a transformer then whenever the parameter is set the new file name will be there and hence a new target file will be generated.
Just in case it was not clear in the previous posts - this cannot be done on a number of levels. Not only can you not change job parameter values on the fly inside a running job, the Sequential File stage does not support dynamically changing the output filename during a job run in any fashion.

As noted, a Folder stage will allegedly handle that although I've never had a need to actually test or play with it as a target yet. The only stage I'm aware of that has that specific functionality is the XML Output stage. This can be used to create non-XML files with pass-through columns as long as you aren't all that picky about the names it chooses. :wink:

:idea: For another approach for this, some sort of 'post-processing' to split a single output file up into appropriate parts could be done. You could even handle this in a after-job sub routine, looping through a read of the first file and conditionally closing and opening new output files.

Hey thanks a lot to all.

This is finally working as per our need. We had to create a new file everytime a new header comes in the material source data.

We are having a structure as Header data then its corresponding multiple detail records and so on.

So using the folder stage its working great
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
Post Reply