How to Capture File Name from Sequential File Stage

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

dilsere2
Participant
Posts: 15
Joined: Tue Nov 30, 2004 8:13 am

How to Capture File Name from Sequential File Stage

Post by dilsere2 »

Hi Guys,

I need to capture File Name from Sequential File stage by any means. Its little tough because I am not passing the file name as parameter it's hard-coded along with path. Any info will be appericated.

thanks,
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,

Are you saying that you have to capture the filename from the path name?

For ex:

Code: Select all


Path= c:\xyz\abc\pqr\filename.ext

If thats the case, then you use the DCOUNT function to count the delimiter "\" and then use the FIELD function to extract the last field which is nothing but the filename .

Let me know how it went.

Thanks!
Naveen.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

There is no API for requesting such information. The only thing you can do is trick the job into telling you this information thru the job log, which you can then query using the API DSGetLogSummary. Unfortunately, most of those messages tend to be fatal.

I think you need to revisit why the file name is not parameterized and shared with other processes. Your task is most difficult.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
dilsere2
Participant
Posts: 15
Joined: Tue Nov 30, 2004 8:13 am

How to Capture File Name from Sequential File Stage

Post by dilsere2 »

kcbland wrote:There is no API for requesting such information. The only thing you can do is trick the job into telling you this information thru the job log, which you can then query using the API DSGetLogSummary. Unfortunately, most of those messages tend to be fatal.

I think you need to revisit why the file name is not parameterized and shared with other processes. Your task is most difficult.
The job log doesn't tell what is the output file name that you have defined inside the stage....
np
manteena
Premium Member
Premium Member
Posts: 38
Joined: Thu Feb 10, 2005 1:43 pm
Location: USA

Post by manteena »

Hardcode the filename as the stage name, then get the stage name with DSGetStageInfo....... :lol:
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

manteena wrote:Hardcode the filename as the stage name, then get the stage name with DSGetStageInfo....... :lol:
Cheater, I assumed the file is fully qualified and stage/link names can't have slashes, dashes, dots, just underscores.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Re: How to Capture File Name from Sequential File Stage

Post by kcbland »

dilsere2 wrote: The job log doesn't tell what is the output file name that you have defined inside the stage....
It does if the file to be opened can't be opened, or there's some other catastrophic issue, hence my reply that the file name only shows up under tragic circumstances.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
dilsere2
Participant
Posts: 15
Joined: Tue Nov 30, 2004 8:13 am

Re: How to Capture File Name from Sequential File Stage

Post by dilsere2 »

kcbland wrote:
dilsere2 wrote: The job log doesn't tell what is the output file name that you have defined inside the stage....
It does if the file to be opened can't be opened, or there's some other catastrophic issue, hence my reply that the file name only shows up under tragic circumstances.
Tell what you think of this? After job is sucessfully completed i will write a BASIC codoe to export the file to get dsx file name then write script to pharse out the FileName...You guys have any other ideas...
np
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Why does this sound like a variable value everytime the job runs, but is hardcoded? This makes no sense. Is someone changing this filename, compiling it, and running it? Can you at least get them to write it to an empty directory and then assume anything in that directory is the file you want?
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
manteena
Premium Member
Premium Member
Posts: 38
Joined: Thu Feb 10, 2005 1:43 pm
Location: USA

Post by manteena »

An XML job report will give you the file name with Directory name of the source or target file stages....try to read this report for filename...

NO CHEATING :wink:
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

manteena wrote:An XML job report will give you the file name with Directory name of the source or target file stages....try to read this report for filename...

NO CHEATING :wink:
You might just have the winning suggestion! :D
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Code: Select all

select 
   EVAL DS_JOBOBJECTS."@RECORD<6>" AS FILE_NAME FMT '45L',
   DS_JOBS.NAME AS JOB_NAME FMT '35L', 
   DS_JOBOBJECTS.NAME AS LINK_NAME FMT '35L'
from 
   DS_JOBOBJECTS, 
   DS_JOBS
where 
   DS_JOBOBJECTS.OLETYPE in ('CSeqOutput','CSeqInput') 
   and DS_JOBOBJECTS.OBJIDNO = DS_JOBS.JOBNO 
group by 
   FILE_NAME, 
   JOB_NAME,
   LINK_NAME
;
Mamu Kim
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

In addition to Kim Duke's SQL statement, add jobno filter in the WHERE clause to give you the file name for that job, which you are looking for.

HTWH.

Regards
Saravanan
dilsere2
Participant
Posts: 15
Joined: Tue Nov 30, 2004 8:13 am

Post by dilsere2 »

elavenil wrote:In addition to Kim Duke's SQL statement, add jobno filter in the WHERE clause to give you the file name for that job, which you are looking for.

HTWH.

Regards
Saravanan
This is an SQL statement..how do i do this in Datastage?
np
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Do a search on TCL commands and telnet.
Mamu Kim
Post Reply