How do I capture the name of my source FILE thru datastage.

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
Shailendra
Participant
Posts: 40
Joined: Tue Nov 15, 2005 11:53 pm

How do I capture the name of my source FILE thru datastage.

Post by Shailendra »

Hi ,

I need to capture my source file name and pick the date from it and append to my target. I read in the forum that parallel sequential file stage has an option called "File Name Column" where it captures the file name.

Iam using server sequential stage. Is there any method to do this through datastage or any other suggestion is welcome.

File name that Iam reading data from is

20051231-235500_20060101-051404... I need to pick the date (ie)

"20051231" from the above file name.


Thanks in advance,
Shailendra
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 »

How is the source file being passed to the sequential file stage? It seems to me that your source file name is dynamic, meaning it is changing each time you run your job.

Are you passing the file name through a job parameter to the sequential file stage??

Please explain your job elaborately.

Thanks,
Naveen.
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
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 »

Hi Shailendra,

Welcome aboard!!! :lol: Didn't notice that this was your first post. :idea:

Naveen.
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
MaheshKumar Sugunaraj
Participant
Posts: 84
Joined: Thu Dec 04, 2003 9:55 pm

Post by MaheshKumar Sugunaraj »

Hi Shilendra,

Welcome aboard!!!

U could do this in the following way:

1. Use a Sequential file and in this check the option "Stage uses Filter Command",

2. then in the file path pass "/dev/null"

3. pass the filter command "ls -l <directorypath>/*", (Hopefully u have only one file coming)

4. Read the entire file

5. then u would be having the name the file and use Stage variable to extract the information u want and process accordingly.

The above should be ur frist step and then process the entrie file accordingly.

Hopefully the above helps. Best of luck :)

With Regards
Mahesh
MaheshKumar Sugunaraj
Participant
Posts: 84
Joined: Thu Dec 04, 2003 9:55 pm

Post by MaheshKumar Sugunaraj »

Hi Shilendra,

Welcome aboard!!!

U could do this in the following way:

1. Use a Sequential file and in this check the option "Stage uses Filter Command",

2. then in the file path pass "/dev/null"

3. pass the filter command "ls -l <directorypath>/*", (Hopefully u have only one file coming)

4. Read the entire file

5. then u would be having the name the file and use Stage variable to extract the information u want and process accordingly.

The above should be ur frist step and then process the entrie file accordingly.

Hopefully the above helps. Best of luck :)

With Regards
Mahesh
MaheshKumar Sugunaraj
Participant
Posts: 84
Joined: Thu Dec 04, 2003 9:55 pm

Post by MaheshKumar Sugunaraj »

Apologies for Posting twice.

Regards
Mahesh
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

MaheshKumar Sugunaraj wrote:Apologies for Posting twice.

Regards
Mahesh
You could have deleted the second one :wink:
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

The same can also be acheived by Before Job subroutine.
/path/ls -1 > {File Name}
And use this {File Name} in your input stages.
ls -1 would give you less work than ls -l.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Shailendra
Participant
Posts: 40
Joined: Tue Nov 15, 2005 11:53 pm

Post by Shailendra »

Hello Naveen and Mahesh,

Sorry for replying late. I didnt have a chance to check my email or the site. Thank you very much for your replies. I will try them out and let you know about it.
I have been working heavy on informatica but this my first time in Datastage. So will be logging into the site more often. Good to meet you guys.

Thanks again,
Shailendra
Post Reply