Routine called from job transformer -> abnormal terminati

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
Anthony1200
Premium Member
Premium Member
Posts: 28
Joined: Wed Mar 28, 2007 6:57 am
Location: Amsterdam

Routine called from job transformer -> abnormal terminati

Post by Anthony1200 »

Hi,

I have a Job (datastage 7.5.1a) that gets a jobname from a Oracle table
and then passes this jobname to a transformer. This transformer has
a routine in its stage variable, the result of this routine gets passed to a textfile.

The problem is that this gives me an Abnormal termination of stage error if i reset this job and then look in the from previous run entry i get this:
From previous run
DataStage Job 384 Phantom 536
Program "DSD.RUN": Line 2161, Variable previously undefined. Zero length string used.
Program "DSD.RUN": Line 2161, Variable previously undefined. Zero length string used.
Program "DSD.RUN": Line 2161, Variable previously undefined. Zero length string used.
Job Aborted after 1 errors logged.

So:
Oracle--->Transformer(with routine)---->Textfile

The code of the routine itself:
$INCLUDE DSINCLUDE JOBCONTROL.H
JobHandle = DSAttachJob(Arg1, DSJ.ERRWARN)
ReportText = DSMakeJobReport(JobHandle,2,"CRLF")
ErrCode = DSDetachJob(JobHandle)
Ans = ReportText

Can someone please help me?

Kind regards,
Anthony
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Can the routine be being passed the name of the job that is calling it? This is not allowed, you need to modify your code to include something like:

Code: Select all

   $INCLUDE DSINCLUDE JOBCONTROL.H 
   IF DSGetJobInfo(DSJ.ME,{can't recall the correct parameter}) = Arg1 THEN JobHandle = DSJ.ME ELSE JobHandle = DSAttachJob(Arg1, DSJ.ERRWARN) 
   ReportText = DSMakeJobReport(JobHandle,2,"CRLF") 
   IF DSGetJobInfo(DSJ.ME,{can't recall the correct parameter}) # Arg1 THEN ErrCode = DSDetachJob(JobHandle) 
   Ans = ReportText 
Anthony1200
Premium Member
Premium Member
Posts: 28
Joined: Wed Mar 28, 2007 6:57 am
Location: Amsterdam

Post by Anthony1200 »

Hi, thanks for your help!

Well its a list of jobs that don't include the name of the job that executes this routine.
When i open this routine and fill in a couple of job names they all give the desired XML result...

When i build a very simple job that looks like this:

Flatfile-------->Transformer------>flatfile

where:
The first flatfile contains 3 jobnames also used while testing the routine.
The transformer contains the call to the routine with the job name as parameter
The last flatfile (should) contain the result and is set to append.

When i start this job it gives me a warning in the log:
Abnormal termination of stage TestJob..JobReport detected

And the designer shows two red lines and a 0 for processed rows..
BUT when i look in the second flat file... It contains three XML reports :s
I'm getting confused ;)

Kind regards,
Anthony
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Might it be that not all arguments are being passed to the routine?

I always include traps for UnAssigned() and IsNull() for routine arguments in the routine code.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Anthony1200
Premium Member
Premium Member
Posts: 28
Joined: Wed Mar 28, 2007 6:57 am
Location: Amsterdam

Post by Anthony1200 »

Hi, again thanks for all the help i changed the routine to:
$INCLUDE DSINCLUDE JOBCONTROL.H
if Arg1 = '' or IsNull(Arg1) = 1 then Ans = 1 else Ans = 0
if Ans = 0 then
JobHandle = DSAttachJob(Arg1, DSJ.ERRWARN)
*ReportText = DSMakeJobReport(JobHandle,2,"LF")
ReportText = DSMakeJobReport(JobHandle,2,"CRLF")
ErrCode = DSDetachJob(JobHandle)
Ans = ReportText
end

But this still gives me an Abnormal termination of stage
The routine works when i press test and feed it some values (or none)

Any other tips or idea's ?

Oh this version has NLS installed

Kind regards,
Anthony
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Change the routine to have the first line do a "RETURN(1)" - that will mean the error is in the calling and return mechanism and not part of your code.
Anthony1200
Premium Member
Premium Member
Posts: 28
Joined: Wed Mar 28, 2007 6:57 am
Location: Amsterdam

Post by Anthony1200 »

Hi, thanks for the help!

Well if i change the code to:
RETURN(1)
$INCLUDE DSINCLUDE JOBCONTROL.H
if Arg1 = '' or IsNull(Arg1) = 1 then Ans = 1 else Ans = 0
if Ans = 0 then
JobHandle = DSAttachJob(Arg1, DSJ.ERRWARN)
*ReportText = DSMakeJobReport(JobHandle,2,"LF")
ReportText = DSMakeJobReport(JobHandle,2,"CRLF")
ErrCode = DSDetachJob(JobHandle)
Ans = ReportText
end

The job itself functions correctly, but the value returned is of cource not an XML report but the number 1 :)
Or is that not what u meant by RETURN(1) ?

Kind regards,
Anthony
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yep, that was what I wanted to check - we know now that the job itself can call and get a return value from the routine with no issues, so your error is coming from the routine.

Code: Select all

   $INCLUDE DSINCLUDE JOBCONTROL.H 
   CallingJobName = DSGetJobInfo(DSJ.ME,DSJ.JOBNAME)
   IF FIELD(Arg1,'.',1)=CallingJobName
   THEN
      Ans = DSMakeJobReport(DSJ.ME,2,"CRLF") 
   END
   ELSE
      JobHandle = DSAttachJob(Arg1, DSJ.ERRNONE)
      IF NUM(JobHandle) THEN Ans = DSMakeJobReport(JobHandle,2,"CRLF") 
                        ELSE Ans = 'Unable to open Job "':Arg1:'"'
      ErrCode = DSDetachJob(JobHandle) 
   END
Anthony1200
Premium Member
Premium Member
Posts: 28
Joined: Wed Mar 28, 2007 6:57 am
Location: Amsterdam

Post by Anthony1200 »

Hi Thanks for the help :) well I tried the new code and ran the Job but
it still gave me that Abnormal termination of stage error :(

When i tested the code with the TEST button it worked fine for existing job names but when i left the Argument empty or if u used an nonexisting job name it gave me the error:

TEST #4
*******

Arg1 = nonexistingjobname

Test completed.


Result = ERROR: Invalid job handle 0 (code=-1)

Kind regards,
Anthony
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

For test purposes try:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 
   CallingJobName = DSGetJobInfo(DSJ.ME,DSJ.JOBNAME) 
   IF FIELD(Arg1,'.',1)=CallingJobName 
   THEN 
      Ans = DSMakeJobReport(DSJ.ME,2,"CRLF") 
   END 
   ELSE 
      JobHandle = DSAttachJob(Arg1, DSJ.ERRNONE) 
      IF JobHandle>0 
      THEN
         CALL DSLogInfo('Job "':arg1:'" has status ':DSGetJobInfo(JobHandle,DSJ.JOBSTATUS),'')
         CALL DSLogInfo('Calling DSMakeJobReport with Handle "':JobHandle:'".','')
         Ans = DSMakeJobReport(JobHandle,2,"CRLF") 
      END
      ELSE Ans = 'Unable to open Job "':Arg1:'"' 
      ErrCode = DSDetachJob(JobHandle) 
   END

There is a correct way to check for opening a job, but I'm not at a system where I can check and this should work for test purposes.

Also, is it possible that the job you are checking is par
Anthony1200
Premium Member
Premium Member
Posts: 28
Joined: Wed Mar 28, 2007 6:57 am
Location: Amsterdam

Post by Anthony1200 »

Hi ArndW,

Thanks for your all your amazing help :) well I tried with the new code and
when I started it directly with the TEST button with some known jobs it worked fine, but when i started it from the Job itself I got the same Abnormal termination of stage error.

However there are 2 new entries in the joblog these are:
InitJobObjectJob..JobReport (): Job "StagingVerwJob" has status 99
InitJobObjectJob..JobReport (): Calling DSMakeJobReport with Handle "2".
Abnormal termination of stage InitJobObjectJob..JobReport detected


Where InitJobObjectJob is the jobname and JobReport the transformer that calls the routine.

The result I get with the Test button of the same job is:
Arg1 = StagingVerwJob

Test completed.

DSLogInfo called from :
Message to be logged is...
> Job "StagingVerwJob" has status 99
DSLogInfo called from :
Message to be logged is...
> Calling DSMakeJobReport with Handle "2".

Result = <?xml version="1.0" encoding="UTF-8"?>
..... Etc etc...

Does this logging help ? :)

Oh and what do you mean with "Also, is it possible that the job you are checking is par" ?

UPDATE:
The code does work on an AIX version of datastage :s but i still can't get it to work on Windows :s

When I make the Job wait (just a transformer with a textfile) and then check the jobs recources i can see this:
PID Context User Name Last Command Processed
128 Controller IBM_DS\dsadm PHANTOM SQUAWK DSD.StageRun testjob. testjob.Transformer_1 0/0/1 [DSD.RUN @ 0x302E]
1772 Transformer_1(Running) IBM_DS\dsadm DOS /cC:\Ascential\DataStage\Engine\bin\hostname [DSGetVarInfo @ 0x1412]


Kind regards,
Anthony


Last Update!!!!!
Hi I found the problem it was something stupid :)
I installed version 7.5.1A but it seems that i forgot to update 4 files:
DSGetLinkInfo.B
DSGetStageInfo.B
DSGetCustInfo.B
DSGetVarInfo.B


In the directorys:
root\Ascential\DataStage\Template\DSG_BP.O
root\Ascential\DataStage\Projects\projectname\DSG_BP.O

And again THANKS FOR AL YOUR HELP!!!! :) :)

Kind regards,
Anthony
Post Reply