global_userid within session trigger

Sonja

New Member
Hello,

i have a session trigger which looks like:

on write of ro_det old buffer bu-ro_det do:
.............
display global_userid.
end.

Problem is that i am not able to show the global_userid.
When i add program mfdeclre.i or when i try to define global_userid i get the error message that variable global_userid is already defined.
If i do not define the variable then it's unknown.

Is there anybody who has a solution for that ?

Thanks
Sonja
 

bulklodd

Member
you should make it shared in your program but i think it's already shared, just check it.

Code:
define new shared variable global_userid as character.

After that you can include its definition in your trigger like that

Code:
define shared variable global_userid as character.

HTH
 

Sonja

New Member
Oops, i was inattentive

what do you mean by that


it has the unknown value or your code just isn't compiled?

When i don't define the variable global_userid it brings out an error message which says that the variable isn't defined yet.

When i define the variable global_userid it brings out an error message which sys that the variable is already defined
 

lord_icon

Member
Progress usage.
If a var is referenced that has not been defined then the result is unknown - a ? is returned to the Progress compiler. The Progress compiler WILL continue to iterate through the program src, setting the value requested as a "?"
Hope this helps
 

bulklodd

Member
When i don't define the variable global_userid it brings out an error message which says that the variable isn't defined yet.

When i define the variable global_userid it brings out an error message which sys that the variable is already defined

It looks odd. Try to compile your trigger with preprocess option
Code:
COMPILE <triggername.p> PREPROCESS <triggername.pre>.
and then try to find out the definition of global_userid in triggername.pre file. It must help to understand the situation. Post its definition(s) here.
 

Casper

ProgressTalk.com Moderator
Staff member
This parameter has got nothing to do with compilation, but on the other hand it's not still clear is Sonja talking about compiletime or runtime error?

Ah you're right. :) I assumed it was a runtime error, but that still isn't clear....

Casper.
 

Sonja

New Member
It looks odd. Try to compile your trigger with preprocess option
Code:
COMPILE <triggername.p> PREPROCESS <triggername.pre>.
and then try to find out the definition of global_userid in triggername.pre file. It must help to understand the situation. Post its definition(s) here.

Hello,

variable global_userid is defined in mfdeclre.i which is included in program rwromt.p. My trigger shell program runs 'before' and therefore needs a definition for variable global_userid.

My program is as follows:

on write of ro_det old buffer bu-ro_det do:
.......
end.
{rwromt.p}

When i do this compile i get following error message:
** Unknown Field or Variable name - global_userid. (201) ¦
¦ ** /gactest/gacdevl/qad90ges4/ge/src/shrwromt.p Could not understand line ¦
¦ 29. (196)



When i try to include a variable definition for global_userid anywhere before or within my shell program i get following error message when compiling:

Duplicate variable name--global_userid. (218) ¦
¦ ** /qad90ges4/ge/src/mfdeclre.i Could not understand line 68. (196)

Do you have any idea how i could solve that problem ?

I really appreciate your help
Sonja
 

bulklodd

Member
It's difficult to say definitely without having a look at the code but first of all I'd try the following cases:

Code:
[COLOR=#008000]{rwromt.p}[/COLOR]
[COLOR=#ff0000]on write of ro_det old buffer bu-ro_det do:
.......[/COLOR]
[COLOR=red]end.[/COLOR]

or

Code:
[COLOR=#ff0000]on write of ro_det old buffer bu-ro_det do:[/COLOR]
[COLOR=#ff0000][COLOR=#008000]{rwromt.p}[/COLOR]

.......[/COLOR]
[COLOR=red]end.[/COLOR]

or

Code:
[COLOR=#ff0000]on write of ro_det old buffer bu-ro_det do:[/COLOR]
[COLOR=#ff0000][COLOR=#008000]{mfdeclre.i}[/COLOR]

.......[/COLOR]
[COLOR=red]end.[/COLOR]
[COLOR=#008000]{rwromt.p}[/COLOR]

and so on...

HTH
 

Sonja

New Member
It's difficult to say definitely without having a look at the code but first of all I'd try the following cases:

Code:
[COLOR=#008000]{rwromt.p}[/COLOR]
[COLOR=#ff0000]on write of ro_det old buffer bu-ro_det do:
.......[/COLOR]
[COLOR=red]end.[/COLOR]

or

Code:
[COLOR=#ff0000]on write of ro_det old buffer bu-ro_det do:[/COLOR]
[COLOR=#ff0000][COLOR=#008000]{rwromt.p}[/COLOR]
 
.......[/COLOR]
[COLOR=red]end.[/COLOR]

or

Code:
[COLOR=#ff0000]on write of ro_det old buffer bu-ro_det do:[/COLOR]
[COLOR=#ff0000][COLOR=#008000]{mfdeclre.i}[/COLOR]
 
.......[/COLOR]
[COLOR=red]end.[/COLOR]
[COLOR=#008000]{rwromt.p}[/COLOR]

and so on...

HTH


Sorry, but all of that is not working.

My program looks like following (very simple):

define var filename as char format "x(50)".
filename = "/spool/gac/rout/routtrack" + string(month(today))
+ string(year(today)) + ".txt".

on write of ro_det old buffer bu-ro_det do:
output to value (filename) append.

if bu-ro_det.ro_mch_op <> ro_det.ro_mch_op then
put
global_userid "|"
ro_det.ro_routing "|"
ro_det.ro_op "|"
ro_det.ro_start "|"
......................
................
put skip.
output close.
end.
{rwromt.p}

Any more ideas ?
 

bulklodd

Member
There's the common way to do such things:

i.e. you've got an include with the definitions:

mfdeclre.i
Code:
[COLOR=#008000]DEFINE SHARED VARIABLE global_userid AS CHARACTER  NO-UNDO.[/COLOR]

You should add the following code there
Code:
&IF DEFINED(GLOBAL_USERID) = 0 &THEN
DEFINE SHARED VARIABLE global_userid AS CHARACTER  NO-UNDO.
&GLOBAL-DEFINE GLOBAL_USERID
&ENDIF

and your code should look like that

Code:
on write of ro_det old buffer bu-ro_det do:
 
&IF DEFINED(GLOBAL_USERID) = 0 &THEN
DEFINE SHARED VARIABLE global_userid AS CHARACTER  NO-UNDO.
&GLOBAL-DEFINE GLOBAL_USERID
&ENDIF
 
end.

pay attention it makes sense if global_userid is SHARED variable.

but i suppose mfdeclre.i already contains the stuff which can help you to achive that without any modification.
 

Casper

ProgressTalk.com Moderator
Staff member
DO while error:
Make a preprocessed output.
Open that in procedure editor.
check syntax.
correct the mistake.
end.

It's hard to guess what's wrong if I don't see the entire code. But the only reason at the moment I can think of is that the variable global_userid gives this error is that it is defined within your procedure, but after the on write bla bla stuff. So if you define it in there the compiler says it's already defined.

Casper.
 

Sonja

New Member
There's the common way to do such things:

i.e. you've got an include with the definitions:

mfdeclre.i
Code:
[COLOR=#008000]DEFINE SHARED VARIABLE global_userid AS CHARACTER  NO-UNDO.[/COLOR]

You should add the following code there
Code:
&IF DEFINED(GLOBAL_USERID) = 0 &THEN
DEFINE SHARED VARIABLE global_userid AS CHARACTER  NO-UNDO.
&GLOBAL-DEFINE GLOBAL_USERID
&ENDIF

and your code should look like that

Code:
on write of ro_det old buffer bu-ro_det do:
 
&IF DEFINED(GLOBAL_USERID) = 0 &THEN
DEFINE SHARED VARIABLE global_userid AS CHARACTER  NO-UNDO.
&GLOBAL-DEFINE GLOBAL_USERID
&ENDIF
 
end.

pay attention it makes sense if global_userid is SHARED variable.

but i suppose mfdeclre.i already contains the stuff which can help you to achive that without any modification.

Received error message:
Cannot define shared variables in a trigger. (3341)
 

bulklodd

Member
oops, sorry

Code:
[LEFT]&IF DEFINED(GLOBAL_USERID) = 0 &THEN
DEFINE SHARED VARIABLE global_userid AS CHARACTER  NO-UNDO.
&GLOBAL-DEFINE GLOBAL_USERID
&ENDIF

on write of ro_det old buffer bu-ro_det do:
 
 
end.[/LEFT]
 

Casper

ProgressTalk.com Moderator
Staff member
Received error message:
Cannot define shared variables in a trigger. (3341)

First you have to define your variables, then you can write the trigger(s). After that you can write your code.

I still think the solution bulklodd gave you isn't nessecary. (I suppose the include mfdeclr.i is used in many places, so you should always think of the impact it has if you change an include). If you review your code carefully then the problem shouldn't be that hard to find.

But ok, that's my opinion.


Regards,

Casper.
 

Sonja

New Member
oops, sorry

Code:
[LEFT]&IF DEFINED(GLOBAL_USERID) = 0 &THEN
DEFINE SHARED VARIABLE global_userid AS CHARACTER  NO-UNDO.
&GLOBAL-DEFINE GLOBAL_USERID
&ENDIF[/LEFT]
 
[LEFT]on write of ro_det old buffer bu-ro_det do:[/LEFT]
 
 
[LEFT]end.[/LEFT]

I can do a compile without any error message, but when i start my program now, it doesn't come up within MFGPRO
Following error comes up:
Conflict in extent, datatype, or undo status for shared global_userid.

Same problem when i remove the undo.
 

bulklodd

Member
please, post here global_userid definition from mfdeclre.i because it's impossible to give you an exact answer without knowing its definition.
 
I think one way of doing it is to define global_userid as a shared variable in some global include file, then make sure the include file is included at the start of all your programs. That way, it is defined once per program and is always available.

Then, your trigger code can access the variable from the code.

So, from my system, I have two include files globuser.i and globusrv.i, with the following code in globuser.i:

&if defined (global_userid) &then
{globusrv.i &new=""}
&else
{globusrv.i &new="new global"}
if global_userid = "" then do:
run uuserid.p (
output global_userid,
output global_username,
output this_dummy,
output this_dummy,
output this_dummy).
if global_username = "" or global_username = "NOT KNOWN" then global_username = global_userid.
end.

Disregarding what uuserid.p does (it takes the username from the O/S), globusrv.i is a small include file that contains definitions of the shared variables:
define {&new} shared variable global_userid as character label "User" no-undo.
define {&new} shared variable global_username as character label "Name" no-undo.
/* etc. */

So, you would put the include file at the start of the program, before the trigger section, that way the variable is always defined, and defined only once in the program so it shouldn't fall over. Something like this:

/* Defines the global_userid */
{globuser.i}

define var filename as char format "x(50)".
filename = "/spool/gac/rout/routtrack" + string(month(today))
+ string(year(today)) + ".txt".

on write of ro_det old buffer bu-ro_det do:
output to value (filename) append.

if bu-ro_det.ro_mch_op <> ro_det.ro_mch_op then
put
global_userid "|"
/* global_userid is already defined above so it should work */
ro_det.ro_routing "|"
ro_det.ro_op "|"
ro_det.ro_start "|"
......................
................
put skip.
output close.
end.

/* End of example */


> I can do a compile without any error message, but when i start my program now, it doesn't come up within
> MFGPRO
> Following error comes up:
> Conflict in extent, datatype, or undo status for shared global_userid.
> Same problem when i remove the undo.


That's probably because global_userid is defined somewhere else slightly differently. That's why it is a good idea to store the definition in an include file and call the include file from many programs - the definition does not change. Of course, it means that you have to recompile a lot of programs if you change the include file.


Hope that helps.

Simon


 
Top