Submitting a UBE under another user profile

sati

Well Known Member
Hi List

We are currently running a UBE to print immediate using a C business function via the jdeLaunchUBEEx API. There is a requirement for this to be submitted under a generic profile, so my question is can the parameters in the API be set/changed such that the UBE will be submitted under this generic user profile ?

Many Thanks.
 
The only way to do this was suggested by a JDEList guru; in essence you insert a record in the scheduled jobs table.
 
See post 134026 Re: Create an ad-hoc scheduled job

Here is Sef's reply:
I have had a little play a while ago with inserting records in the job scheduler via sql:
insert into sys7334.f91320 values ('MANUAL SCHEDULE',datediff(n,'1970-01-01 00:00:00',getutcdate())+1,'01',
0,0,' ',' ',' ',0,0,0,' ','JDE','SQL','ENTERPRISE',107001, 222222)
In principle it worked but I haven't put this into a production environment as yet.
You could call an external SQL or create a bsfn or just mod the ER and achieve the same result.
Rgds, Sef
--------------------
Sef van den Nieuwelaar
Australia
 
Hi Adrian

Thanks for your response.

We are running R43500 with print immediate in the background when a user approves a requisition and then there is some workflow handled within Create!Form to send out the merged pdf to a user. The problem is we have security over R43500 allowing only a certain no of users access - so if a user who has not got access to R43500 approves a requisition, we have a violation error. Executing R43500 under the SCHEDULE profile would solve this problem.

So that is the background and we also have data selection on R43500 passed through the data structure, so I'm not too sure if simply adding a record to F91320 would solve my problem - but please correct me if it can.

Thanks yet again.
 
I see, your life gets so complicated.
You just need an extra step - another version that gets its processing options updated, and you'll use those processing options to build the Data Selection, instead of using the data structure
tongue.gif

Next, inserting this version into F91320 might solve your problem - but please correct me if it cannot
grin.gif
 
But will this run with print immediate
wink.gif
??
Yet another twist in the tail !!
 
In Xe you have all or nothing, right? And if you use createform! I guess it is turned on "nothing"
tongue.gif
oops
blush.gif
 
Hi Adrian

We don't have it turned on and hence I'm using actually calling the C bsfn to launch the UBE with print immediate - looks like I might need to explore a different avenue.

Thanks for you help.
 
Hi Sati,

Perhaps you could try this ...

In your BSFN where the UBE is launched with the API ..

/* These are for your surrogate user*/
HENV hEnv = NULL;
HUSER hUser2 = NULL;
LPBHVRCOM lpBhvrCom2 = NULL;
LPVOID lpVoid2 = NULL;

JDB_InitEnvOvr( &hEnv, "yourenv", "newser", "pwd");
JDB_InitUser(hEnv,&hUser2, "test", JDEDB_COMMIT_AUTO);
jdeCreateBusinessFunctionParms(hUser2, &lpBhvrCom2, &lpVoid2);

jdeLaunchUBEEx(hUser2, PUBEVAR, lpVoid2, lpBhvrCom2);

jdeFreeBusinessFunctionParms(lpBhvrCom2, lpVoid2);
JDB_FreeUser(hUser2);
JDB_FreeEnv(hEnv);

Don't take the above code literally (i.e. put your own environment stuff and your PUBEVAR), but the idea is to allocate an environment within the BSFN to act like another user. It worked with a simple test on standalone where I called GetAuditInfo and it returned the surrogate user.

It's a hack, but we've done worse
wink.gif
 
Craig's solution looks like a good one, but I had another idea that may be simpler...if it happens to work, of course
smile.gif


How about trying this prior to calling jdeLaunchUBEEx:
strncpy(lpBhvrCom->SysPref.szUserName, (const char *)"NewUser\0", sizeof(lpBhvrCom->SysPref.szUserName));

I have no idea if that user would actually carry over into a submitted job's environment, but it's worth a try. If it does happen to work, you'll probably want to restore the username after.

Good luck.
 
Hi JMR

Unfortunately your solution did not work, however Craig's solution works like a treat.

Thanks Graig ...
 
I was wondering if you could give an example of the values of the parameters.

JDB_InitEnvOvr( &hEnv, "yourenv", "newser", "pwd");
JDB_InitUser(hEnv,&hUser2, "test", JDEDB_COMMIT_AUTO);
jdeLaunchUBEEx(hUser2, PUBEVAR, lpVoid2, lpBhvrCom2);



What does the yourenv need to be for a DV environment? for example just DV811 or does there need to be additional info.

I assume newser is the original login and pwd

Then init user 'test' is the override user id?

for the jdeLaunch.... What will PUBEVAR be set to? for example my UBE is TEST and the version is TEST. What's the syntax to get the program name and version correct?

Sorry I'm not a C programmer and just do a little to get by.

Thanks!
 
Sorry I am not a C programmer; I am trying (pretty hard) to make your suggested solution work for me, but I get so many errors when building the BSFN ... please find attached my code.
I just want to launch R09801 (to post PO cancelled lines, to get rid of the commited amounts that mess-up our job costs).
Thank you!
 

Attachments

  • 143428-B5509801.txt
    9.6 KB · Views: 111
Hi Adrian,

Before we delve into the code ... are you interested in submitting this UBE as a specific user ID? The example above was to address that case. Either way, we can get you sorted.

Craig
 
Hi Craig,
I want to launch R09801 from P43214.
As per CSox, I am not allowed to post to GL (run R09801), therefore I am interested in submitting R09801 as anOther user.
And I want to be able to pass the user to the BSFN.
Thank you,
 
Add two parms to the data structure:
szEnvironment
szPassword

and pass them from your app. Make sure you paste the updated data structure back into you header file.

See the updated code attached. Copy just the function code back into your source and try compiling. Post the compiler errors after running busbuild. (I didn't compile, just updated the code so I'm sure I missed something)

Craig
 

Attachments

  • 143462-B5509801.txt
    9.9 KB · Views: 109
Done! Here's the new code and compiling errors at the bottom.
 

Attachments

  • 143463-20090224 B5509801 w Comp Err.txt
    12.6 KB · Views: 184
Hi Adrian

Have a look at the attached - changes are in red, give it a go and let us know how you get on.
 

Attachments

  • 143484-Bus.doc
    43 KB · Views: 153
Yesss! Craig helped me with the code and attached is the final revision, tested, works OK on the App Server.
Thank you Craig!
 

Attachments

  • 143504-20090225 B5509801 10AM.txt
    10 KB · Views: 146
Hi there

I was going to post this very question myself but saw this thread:

I have replicated this but my first call to the API fails
I do pass in USER and PSWD but the API just fails

I am trying this on local DV thin

If I get this to work, will it on the enterprise server?

Or would I be right in thinking this will never work on my FAT client anyway?

Thanks


John
 
Back
Top