Page 1 of 1

need for loop in basic code

Posted: Wed Oct 18, 2006 9:59 am
by rajan.n
Hi frnds,
i need a BASIC code for the below senario.
i give a job name in run time.

i need job info like start time , end time, status of job , elapsed time.
up to here no prob. and in the same code

-- i need to extract all the stage name, stage start, end time , status code, row cont, and cpu time.

-- i need to extract link info.
-- i need to extract param info

i know am having all the basic functions availeble in help .
but

the logic is dsj.fullstagelist gives a comma separated list of all stages...
so i need to use ech and every stage name and get the info and store in a file like that for each stage ...link info...so we have to write 2 for loops here..
for ext ...
1st for loop
until end of file of fullstages list......
details of stage....
for each stage .....info value


can any body give this for loop code.
thanks a lot in advance.....

Posted: Wed Oct 18, 2006 10:37 am
by kcbland
Why not consider using dsjob with the reporting feature built into that?

Posted: Wed Oct 18, 2006 10:49 am
by rajan.n
Hi thnx for the responce,

i dint get u , can u pls clear me once again.

my req is to store all the job details..in one file, and stage details in one file and link details in one file...so i wil have to save allthese files seperately . at last will call them in a job and store in to tables.

thanks once again for ur early responce.

kcbland wrote:Why not consider using dsjob with the reporting feature built into that? ...

Posted: Wed Oct 18, 2006 12:44 pm
by kduke
Why not download EtlStats which does all this for you? EtlStats is a group of jobs which extracts row counts for any or all jobs in a project. It can also get all row counts and start and end times for every job in a sequence. There are lots of jobs and routines to show you how to do wat you are asking.

Posted: Wed Oct 18, 2006 10:16 pm
by rajan.n
Hey Duke,
first of all want to appriciate u for ur fantastic job done in the sites given below,its realy grt.
and as of my requirement is in parlell editioin.
what am goin to do is..to write a basic code and make it a after /before sub routine and trying to acess them in PX jobs, is my idea is corect. if so pls guide me in this issue.
once again thanx a lot for ur responce.
kduke wrote:Why not download EtlStats which does all this for you? EtlStats is a group of jobs which extracts row counts for any or all jobs in a project. It can also get all row counts and start and end times for every job in a sequence. There are lots of jobs and routines to show you how to do wat you are asking.

Posted: Wed Oct 18, 2006 11:37 pm
by ray.wurlod
So why did you post it in the server edition forum?

Posted: Thu Oct 19, 2006 12:28 am
by Kirtikumar
You can use the command mentioned in Kenneth's reply - dsjob.

In your Datastage home directory, go to bin and there you will find the dsjob command. There are lots of options and you can use dsjob -report in it as follows:
dsjob -report <Project> <Jobname>

It also has diff format of output. Check it out.

Posted: Thu Oct 19, 2006 1:06 am
by rajan.n
Hi ray since am creating a server routine which includes BASIC i want to post in server edition forum ,
i got an error while compiling my routine.
am using the Loop ...Repeat logic, inthat loop i have this code i have checked with out this code it compiles proper in a an another test routine, there shud be some mistake in this code...

If(OpenSeq DirName To R_FileName) = @TRUE

Then
WriteSeq Link_Row To R_FileName
Else

Openpath DirName to t.fvarR then
write Job_Row to t.fvarR, R_FileName else
call DSLogWarn("Failed to write file ":R_FileName:" to directory ":DirName, "LOG_DETAILS")
end
end
else
call DSLogWarn("Failed to open directory ":DirName, "LOG_DETAILS")
end

close t.fvarR
end



the error is.....

Repeat
^
"REPEAT" unexpected, Was expecting: Array Name, Variable name,

i guess there is a mistake at opening the files.....
the logic is ..if file is present ..then open and write...else create a file in dirpath..directory.

can any any body help me ,



kirithi ,
hi i have already tried using ds-job and had produced a xml file , which am unable to parse in the parallel edition i was stuck with issue .thats the reason i thot of creating a routine so that it creates all the files reagaring the job details and stage details , row details and pram details in diff files.






ray.wurlod wrote:So why did you post it in the server edition forum? ...

Posted: Thu Oct 19, 2006 8:46 am
by ray.wurlod
There are two loop constructs in BASIC; a counted (FOR..NEXT) loop used if the number of iterations required is known in advanced, and an uncounted (LOOP..REPEAT) loop used if the number of iterations required is not known in advance. The compiler has objected to a REPEAT statement that has no corresponding LOOP statement, and rightly so.

In your case, since you seem determined to re-invent this particular wheel, you have an indeterminate number of iterations - you do not know in advance how many active stages or links. Therefore you need code something like

Code: Select all

StageList = Convert(",", @FM, DSGetJobInfo(hJob, DSJ.STAGELIST))
Loop
   Remove StageName From StageList Setting MoreStages
   LinkList = Convert(",", @FM, DSGetStageInfo(hJob, StageName, DSJ.LINKLIST))
   Loop
      Remove LinkName From LinkList Setting MoreLinks
      RowCount = DSGetLinkInfo(hJob, StageName, LinkName, DSJ.LINKROWCOUNT)
      *  do what ever you want with the link row count
   While MoreLinks
   Repeat
While MoreStages
Repeat

Posted: Thu Oct 19, 2006 9:43 am
by kduke
EtlStats uses dsjob and works for parallel jobs. Vincent has modified the main job in EtlStats to aggregate all the row counts in one PX job run to get a true rows per second. I think I included this job. If not then I still have it so I can add it.

Posted: Fri Oct 20, 2006 12:39 am
by rajan.n
Hi duke, ray
thanks a lot for ur quick responce.
i got my routine working fine.
i was generating 4 files from this routine, that gives all the details for jobs,param, stages,link info.

and the problem with that loop is i had a "openseq " in that loop hence that was not working..i need to learn to make it work.

but still i have an issue with my seq file, my routine generates the file as following.
1,a,111|2,b,222|3,c,333|4,d,444| /* the pipe and the commas am generating thru routine i can change whah ever i want
so when i read the seq file i need to view the data as

no. name code
1 a 111
2 b 222
3 c 333
4 d 444


but i can read only first line like
no. name code
1 a 111


when i give final delimiter in record level '|' and field delemiter as comma its not working fine..!!
can u pls guide me what are theproperties to be set.
once again thanks a lot for ur responces.
the




kduke wrote:EtlStats uses dsjob and works for parallel jobs. Vincent has modified the main job in EtlStats to aggregate all the row counts in one PX job run to get a true rows per second. I think I included this job. If not then I still have it so I can add it.

Posted: Fri Oct 20, 2006 6:24 am
by DSguru2B
When you give the final delimiter as "|". That means, its the final delimiter for the record. You need a carrige return after that.
After a pipe, stick in Char(013):Char(010). Thats the carrige return for a dos file.

Posted: Fri Oct 20, 2006 6:34 am
by chulett
Actually, our friend created a new post in the EE forum asking this very question. It has been resolved there.

Posted: Fri Oct 20, 2006 6:40 am
by DSguru2B
O yea. I did go through that post but it never hit me. Still too early for me. :roll:

Posted: Fri Oct 20, 2006 8:59 am
by ray.wurlod
:idea: NEVER put OpenSeq inside a loop!