need for loop in basic code

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
rajan.n
Premium Member
Premium Member
Posts: 96
Joined: Mon Oct 09, 2006 7:47 am

need for loop in basic code

Post 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.....
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Why not consider using dsjob with the reporting feature built into that?
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
rajan.n
Premium Member
Premium Member
Posts: 96
Joined: Mon Oct 09, 2006 7:47 am

Post 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? ...
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post 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.
Mamu Kim
rajan.n
Premium Member
Premium Member
Posts: 96
Joined: Mon Oct 09, 2006 7:47 am

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

So why did you post it in the server edition forum?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Kirtikumar
Participant
Posts: 437
Joined: Fri Oct 15, 2004 6:13 am
Location: Pune, India

Post 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.
Regards,
S. Kirtikumar.
rajan.n
Premium Member
Premium Member
Posts: 96
Joined: Mon Oct 09, 2006 7:47 am

Post 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? ...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post 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.
Mamu Kim
rajan.n
Premium Member
Premium Member
Posts: 96
Joined: Mon Oct 09, 2006 7:47 am

Post 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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Actually, our friend created a new post in the EE forum asking this very question. It has been resolved there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

O yea. I did go through that post but it never hit me. Still too early for me. :roll:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:idea: NEVER put OpenSeq inside a loop!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply