can NOT set UserStatus via routine

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
abyss
Premium Member
Premium Member
Posts: 172
Joined: Thu May 22, 2014 12:43 am

can NOT set UserStatus via routine

Post by abyss »

Hi I have searched the form regrading to set userstatus but I still can NOT assign value to it!

I create a transform function type server routine the code as following:

Code: Select all

if Arg1 = 'Y' then 
Call DSSetUserStatus("Y");
Call DSLogInfo(DSGetJobInfo,"set_userstatus");
Ans = 'Y';
end else
Call DSSetUserStatus("N");
Call DSLogInfo(DSGetJobInfo,"set_userstatus");
Ans = 'N'
end
in the log DSGetJobInfo function return NULL value and the sequence job return error message: Variable '*.$UserStatus' never assigned a value.

thanks
Abyss
abyss
Premium Member
Premium Member
Posts: 172
Joined: Thu May 22, 2014 12:43 am

Post by abyss »

i call this routine in basic transformer stage derivation area
abyss
Premium Member
Premium Member
Posts: 172
Joined: Thu May 22, 2014 12:43 am

Post by abyss »

hey i think i find part of the problem, the job can compile now. new the problem is the routine never return 'Y' even argument Arg1 is 'Y', but in the test window if i specify the Arg1 is 'Y' then the routine returns Y
abyss
Premium Member
Premium Member
Posts: 172
Joined: Thu May 22, 2014 12:43 am

Post by abyss »

changed code to

Code: Select all

if Arg1 = "Y" then 
Call DSSetUserStatus("Y");
Call DSLogInfo(Arg1,"Arg1");
Call DSLogInfo(DSGetJobInfo(DSJ.ME, DSJ.JOBNAME),"userstatus");
Ans = 'Y';
END ELSE
Call DSSetUserStatus("N");
Call DSLogInfo(Arg1,"Arg1");
Call DSLogInfo(DSGetJobInfo(DSJ.ME, DSJ.JOBNAME),"userstatus");
Ans = 'N';
end
and i output the argument and return vale to a file, now the argument value is Y but return value still N. anyone know why?
and DSGetJobInfo(DSJ.ME, DSJ.JOBNAME) this statement doesn't work, but i copied it from user manual :(

thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:?

Why not simplify the code? You don't really need all that if-then-else.

Code: Select all

Call DSSetUserStatus(Arg1)
Call DSLogInfo(Arg1,"Arg1")
Call DSLogInfo(DSGetJobInfo(DSJ.ME, DSJ.JOBNAME),"userstatus")
Ans = Arg1
Tell us what "doesn't work" means here for the call to DSGetJobInfo. What actually gets logged?
Last edited by chulett on Wed Oct 19, 2016 6:56 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
abyss
Premium Member
Premium Member
Posts: 172
Joined: Thu May 22, 2014 12:43 am

Post by abyss »

ok, what's doesn't work:

i think the if statement doesn't work here, the job look like this
Image

the oracle stage only return one row with one value. smp_job_status is varchar type and length is 255
Image

in BASIC transformer stage I call a routine and pass smp_job_status as parameter
Image

in the output file as you can see the return value of routine return 'N'
Image

I think the problem is from if statement, control flow always get into the else part. but i don't know how to fix it. :?
abyss
Premium Member
Premium Member
Posts: 172
Joined: Thu May 22, 2014 12:43 am

Post by abyss »

changed code to

Code: Select all

if Arg1 = "Y" then 
Ans = 'Y'; 
END ELSE 
Ans = 'N'; 
end 
result still the same so the problem is from control flow. but on the test window it works

Image
grrrr
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

abyss wrote:I think the problem is from if statement, control flow always get into the else part. but i don't know how to fix it.
The simplest way? Get rid of it. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You also never clarified what actually gets logged in your original code, specifically the one with "userstatus" in it. Still curious about that. Since you said it didn't work.

Also, clarify something. You keep saying "BASIC Transformer" - that is a very specific stage in a Parallel job. This is actually just a "normal" transformer in a Server job, yes?
-craig

"You can never have too many knives" -- Logan Nine Fingers
abyss
Premium Member
Premium Member
Posts: 172
Joined: Thu May 22, 2014 12:43 am

Post by abyss »

his is actually just a "normal" transformer in a Server job, yes?
yes, sorry for the confusion.

change the code to

Code: Select all

Ans = Arg1
result is: Y

the change the code to

Code: Select all

if Arg1 = 'Y' then
Ans = 'Y';
end
it return NULL :evil:

WHY?
abyss
Premium Member
Premium Member
Posts: 172
Joined: Thu May 22, 2014 12:43 am

Post by abyss »

change the code to

Code: Select all

if Compare(Arg1, 'Y') = 0 then Ans = 'Y'
it still doesn't work! i am run out of plan, this is shit. why this software even can not let you write a if else statement!

chulett: if you think i can get rid of if statement, what's the way to work around it.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Let's start with: DataStage BASIC does not use semi-colon (or any other) statement terminators. Your code has a lot of empty comments in it.

DSSetUserStatus subroutine does not (despite what some help claims) store anything in the log. It is stored in the job's user status area, from which it can be retrieved in a sequence by accessing the Job activity's $UserStatus activity variable.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

abyss wrote:chulett: if you think i can get rid of if statement, what's the way to work around it.
Posted that in my first reply. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply