• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

Calling BSFN form AS400

SJavadia

Active Member
List,

We have a table which we would like to put a trigger on. every time a record
is added to this table we would like it to call a OneWorld Master BSFN. we
have tried the RUNUBE from CLP, Then in UBE we call the desired function but
it seems to be very slow in our case, 2 min for 2 records.
We are now trying to Run the BSFN directly by a AS400 DB2 trigger every time
a record is written to the file on AS400. The natural thing to do is use a
OW trigger but we found that the OW trigger is not very reliable and it also
seems that it does not recognise any records written to the file by any
other way than OW (i.e. A CL or RPG programme) so the trigger doesn't
execute.
Has anyone experienced this before? or you may have done something similar
which may help us?

Any help is very much appreciated,

Thanks,

Shahroz.
OW B7332, SP 11.1, NT, AS400 4.4


Shahroz Javadian
OneWorld AP
sjavadia@calorgas.co.uk
00 44 1926 318745

----------------------------------------------------------------------------
--------------------------
The contents of this e-mail are confidential and it is intended for the
recipient at the e-mail address to which it has been addressed. This e-mail
may not be disclosed to or used by anyone other than the addressee nor may
it be copied or forwarded to third parties without the express permission of
Calor. Calor disclaim all liability for any statements made by the sender
which do not directly concern the business of Calor and Calor denies any
contracts purported to be concluded on behalf of Calor by means of an e-mail
communication.

Neither Calor nor the sender accepts any responsibility or liability for
viruses and it is the responsibility of the recipient to scan this e-mail
and any attachments to satisfy itself that the e-mail is virus free.

If this e-mail is received in error, please contact Calor
(HTTP:\\www.calorgas.co.uk) on (0)1926 330088 quoting the name of the sender
and the addressee and then both delete it from your system and from your
deleted items folder.
----------------------------------------------------------------------------
--------------------------
 

WhippingBoy

VIP Member
Get the Interoperability Programming Guide from the KG. That doc tells you how to initialize a OW session so you can call BSFNs directly. What you really need is a BhvrCom to pass to the functions. That doc tells you how to get one.

So, you'll need to make a C program on the AS/400 that is called by the trigger. It will sign onto OW, get the right handles and then call your BSFN. Lastly, it will sign out of OW. You'll want to do timed trials though, because signing in/out takes time.

You may be better served by a program that does it's work directly, without OWs involvement.

Darren Ricciardi - OneWorld Whipping Boy
 

SJavadia

Active Member
Thanks for your suggestion. Unfortunately we are using RPG on AS400, that
means as well as our RPG expert we need a C expert as well to sort out the
interaction between C and RPG, which we don't have. :(
The BSFN is very complicated and calls few other BSFNs itself so it is not
possible to replicate it's work by a RPG or C programmes given the time
scales that we are dealing with.

I'll let you know of any progress and thanks for replying.

Cheers,

Shahroz.
OW 7332, SP11.1, AS400, NT
----------------------------
Shahroz Javadian
OneWorld AP
sjavadia@calorgas.co.uk
01926) 31 8745
----------------------------
 

WhippingBoy

VIP Member
Re: RE: Calling BSFN form AS400

Well, this may help anyway. I highly recommend sending your current RPG expert to at least one C class (not C++). OneWorld IS C code, so you'd be doing the business a favor by having knowledgeable people.


Here's some code to illustrate how calling functions is done.

First. . sign into OneWorld. This gets the required "hEnv", "hUser" and "lpBhvrCom" handles. These are the only things you need for calling the functions. . . .see, it's easy.
/*****************************/
sprintf(szEnv,"%s",CLogon.sOWEnviron.GetBuffer(11));
sprintf(szUser,"%s",CLogon.sOWUserID.GetBuffer(11));
sprintf(szPwd,"%s",CLogon.sOWPassword.GetBuffer(11));

//Log Onto the system.
if(hEnv==NULL)
{
if((rcode=JDB_InitEnvOvr(&hEnv,szEnv,szUser,szPwd))!=TRUE)
{
MessageBox("Could not Log On to OneWorld","Error");
return FALSE;;
}
}

if(hUser==NULL)
{
if((rcode=JDB_InitUser(hEnv,&hUser,NULL,JDEDB_COMMIT_AUTO))!=TRUE)
{
JDB_FreeEnv(hEnv);
MessageBox("Could not Log On to OneWorld","Error");

return FALSE;;
}
}

if(lpBhvrCom==NULL)
jdeCreateBusinessFunctionParms(hUser,&lpBhvrCom,(LPVOID*)&lpVoid);
/*****************************/


Now call your business function. Here you see that I'm checking that the logon was successful, then I fill the functions data structure (parm list for you RPGers). Lastly, I invoke the function:

/*****************************/
if(OWLogon()==FALSE)
return;

memset(&dsCCEmail,'\0',sizeof(dsCCEmail));

sprintf(dsCCEmail.szEmailAddress,"%s",CEmail.sEmailAddress.GetBuffer(1));
sprintf(dsCCEmail.szEmailSubject,"%s",CEmail.sEmailSubject.GetBuffer(1));

BOOL bEmpty=CEmail.sEmailPriority.IsEmpty();
if(!bEmpty)
dsCCEmail.cEmailPriority=CEmail.sEmailPriority.GetAt(0);


jdeCallObject("EmailCreditCardOrders", NULL,
lpBhvrCom,lpVoid,(LPVOID)&dsCCEmail,
(CALLMAP *)NULL,(int)0,(char *)NULL,
(char *)NULL,(int)0);

/*****************************/

Now, the function you're calling may return something in the &dsCCEmail structure, or there may be some errors set. In case of the latter, you can call another function that reports on the errors. I don't have that code infront of me unfortunately.

Lastly, sign out of OneWorld by releasing the handles we retrieved earlier:

/*****************************/
if(lpBhvrCom!=NULL)
{
jdeFreeBusinessFunctionParms(lpBhvrCom,lpVoid);
lpBhvrCom=NULL;
lpVoid=NULL;
}
if(hUser!=NULL)
{
JDB_FreeUser(hUser);
hUser=NULL;
}
if(hEnv!=NULL)
{
// Freeing the environment

JDB_FreeEnv(hEnv);
hEnv=NULL;
}
/*****************************/

Cake. . .:)

Now, the savvy reader will notice that there's a fair amount of code here that only works on a client. That's true, but that same savvy person could easily convert this to an AS/400 friendly program.

Good Luck!


Darren Ricciardi - OneWorld Whipping Boy

Looking for work in Amsterdam
 
Top