Page 1 of 1

How to find EOF using DataStage

Posted: Sun Feb 25, 2007 11:37 pm
by parag.s.27
Hello All,

Can you please tell me, whether there is any inbuilt function or routine in DS to find the end-of-file. Currently I am not able to find an economical way.

I am using ExecDOS before stage subroutine and calling a batch file that finds the EOF, also it is doing same in Command Stage, but the problem is, how can I use the output of this DOS command in my transformer.

For e.g. I have to find the EOF and then in the next line I have to insert some identification flag. so that when next time the data gets appended to this file, I'll be using the flag to define the constraints in the transformer.

Posted: Mon Feb 26, 2007 4:08 am
by ArndW
The normal method of reading a sequential file in a DataStage job does not let you append a row easily using that methodology.
This can be done with a simple command at DOS or UNIX, you can also open and append data to a sequential file from inside a DataStage routine (using OPENSEQ and SEEK)

Posted: Mon Feb 26, 2007 1:44 pm
by DSguru2B
Run the OS level command using DSExecute() in a routine. Reference that routine inside the transformer.

Posted: Mon Feb 26, 2007 5:39 pm
by kumar_s
You are appending a flag to a file. Like
Cat 'Flag' >> File.
You can use tail command to read the last line in CommandActivity and use the CommandOutput to pass the value as parameter to the job.

Posted: Mon Feb 26, 2007 11:44 pm
by parag.s.27
DSguru2B wrote:Run the OS level command using DSExecute() in a routine. Reference that routine inside the transformer.
I have tried a similar approach like calling the command in command stage and then the COMMANT.OUTPUT value of command stage is fed to transformer directly.

It is throwing an error of Command not recognized as internal or external command. But when i run the same command from DOS prompt, it works fine. Is it like DS supports a particular version of DOS

Posted: Mon Feb 26, 2007 11:57 pm
by chulett
parag.s.27 wrote:Is it like DS supports a particular version of DOS
No, it just leverages whatever it is you got. Post your command.

Posted: Tue Feb 27, 2007 2:17 am
by parag.s.27
chulett wrote:
parag.s.27 wrote:Is it like DS supports a particular version of DOS
No, it just leverages whatever it is you got. Post your command. ...
Hi,

I am using the command as

Code: Select all

cd\

FIND /N /C "WRI001" c:\Parag\sage_dovegate_inddata_sales_ledger.rpt >> c:\Parag\cmdout.txt
here WRIoo1 is the flag value.

Posted: Tue Feb 27, 2007 9:34 am
by DSguru2B
Can you wrap that command in a .cmd or .bat file and execute that bat file from DSExecute()?

Posted: Wed Feb 28, 2007 11:15 am
by asitagrawal
Open the file using OpenSeq.
Use SEEK to move the pointer to EOF.

Refer BASIC guide for more details.

Posted: Wed Feb 28, 2007 3:09 pm
by ray.wurlod
Not a good solution, because the file variable that you SEEK to eof only has scope within the routine. The OP's requirement was to "find" eof (whatever that means - I have no idea). You could get the size of the file (from DIR) and use that, I guess, as the address of EOF. But what purpose will it serve?