Problems with AS/400 ActiveX call

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with AS/400 ActiveX call

Theo Pronk
Hi,

I'm working on a system that allows a PC client (Smalltalk) to connect
to an IBM AS/400 using the IBM supplied Client Access ToolKit.

It was quite simple to import the ActiveX components using the ActiveX
controls. Tried some simple interfacing like running a program on the
AS/400 from a workspace and creating an AS/400 data queue insetting data
and retrieving it again.

But accessing the DB2 SQL database is proving a bit harder. There is
very limited documentation unless you want to use C++ headers etc. The
was however an example using VB that uses the APIs in a similar way so I
tried logically converting the VB statements to Smalltalk in a
workspace.  Most calls are fine but when pointers are used I hit
problems. I've cut the VB code and the corresponding Smalltalk methods,
and the errors below for anyone who would like to help.

The VB sample code using the ActiveX API looks like this:
====start==============================================================
rc = mySql.cwbdbGetResultData(dataBuf(), dataLen, indicatorBuf(),
indicatorCount, sysErr)
====end==============================================================

The Smalltalk method generated when importing the AS/400 ActiveX
components looks like this:
====start==============================================================
cwbdbGetResultData: dataBuf dataLen: dataLen indicatorBuf: indicatorBuf
indicatorCount: indicatorCount errorMessage: errorMessage

        "Answer the <SDWORD> result of invoking the cwbdbGetResultData() method
of the COM object."

        ^(self invokeId: 23 withArguments:
                        ((Array new: 5)
                                basicAt: 1 put: dataBuf;
                                basicAt: 2 put: dataLen;
                                basicAt: 3 put: indicatorBuf;
                                basicAt: 4 put: indicatorCount;
                                basicAt: 5 put: errorMessage;
                                yourself))
====end==============================================================

The problems are with "dataBuf" and "indicatorBuf". I've tried various
methods of initializing eg: (l is the the retrieved length from a
previous call)

dataBuf:= (String new: l) asBSTR .
dataBuf:= (String new: l) asVariant.
dataBuf:= BSTR newSAFEARRAY: l.
dataBuf:= BSTR newBuffer.
dataBuf:= BSTR new asVariant.
dataBuf:= ExternalMemory new: l.

But I always get an HRESULT error (see below), I've tried debugging the
   variables in the wallback but I'm not sure which is what.
=======start=======================================
HRESULT Error: Type missmatch. (FACILITY_DISPATCH)

Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:flags:parms:retVal:
Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:flags:parms:
Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:withArguments:
Cwbautsv_DcwbDatabaseSQL>>cwbdbGetResultData:dataLen:indicatorBuf:indicatorCount:errorMessage:
UndefinedObject>>{unbound}doIt

=======end=======================================


Some of the variables that look like they could point to the problem are
"ex":
====start==================
an EXCEPINFO(wCode=0 bstrSource=a BSTR('') bstrDescription=a BSTR('')
bstrHelpFile=a BSTR('') dwHelpContext=0 pfnDeferredFillIn=an
ExternalAddress(NULL) scode=0)
====end==================

"params":
====start==================
a DISPPARAMS(rgvarg=a StructureArray(a VARIANT(dispatch: an IDispatch(an
ExternalAddress(16rE67590))) a VARIANT(sdword: 2200) a VARIANT(bstr: '')
a VARIANT(sdword: 5400) a VARIANT(bstr: '')) rgdispidNamedArgs=a
StructureArray(NULL) cArgs=5 cNamedArgs=0)
====end==================

"varRes":
====start==================
a VARIANT(nil: nil)
====end==================

"err":
====start==================
a DWORD(16r3)
====end==================

Any help would be much appreaciated.
Thank,
Theo


Reply | Threaded
Open this post in threaded view
|

Re: Problems with AS/400 ActiveX call

Jeffrey D. Panici-3
Theo <[hidden email]> wrote in message news:<bh1lcj$trhnj$[hidden email]>...

> Hi,
>
> I'm working on a system that allows a PC client (Smalltalk) to connect
> to an IBM AS/400 using the IBM supplied Client Access ToolKit.
>
> It was quite simple to import the ActiveX components using the ActiveX
> controls. Tried some simple interfacing like running a program on the
> AS/400 from a workspace and creating an AS/400 data queue insetting data
> and retrieving it again.
>
> But accessing the DB2 SQL database is proving a bit harder. There is
> very limited documentation unless you want to use C++ headers etc. The
> was however an example using VB that uses the APIs in a similar way so I
> tried logically converting the VB statements to Smalltalk in a
> workspace.  Most calls are fine but when pointers are used I hit
> problems. I've cut the VB code and the corresponding Smalltalk methods,
> and the errors below for anyone who would like to help.
>
> The VB sample code using the ActiveX API looks like this:
> ====start==============================================================
> rc = mySql.cwbdbGetResultData(dataBuf(), dataLen, indicatorBuf(),
> indicatorCount, sysErr)
> ====end==============================================================
>
> The Smalltalk method generated when importing the AS/400 ActiveX
> components looks like this:
> ====start==============================================================
> cwbdbGetResultData: dataBuf dataLen: dataLen indicatorBuf: indicatorBuf
> indicatorCount: indicatorCount errorMessage: errorMessage
>
> "Answer the <SDWORD> result of invoking the cwbdbGetResultData() method
> of the COM object."
>
> ^(self invokeId: 23 withArguments:
> ((Array new: 5)
> basicAt: 1 put: dataBuf;
> basicAt: 2 put: dataLen;
> basicAt: 3 put: indicatorBuf;
> basicAt: 4 put: indicatorCount;
> basicAt: 5 put: errorMessage;
> yourself))
> ====end==============================================================
>
> The problems are with "dataBuf" and "indicatorBuf". I've tried various
> methods of initializing eg: (l is the the retrieved length from a
> previous call)
>
> dataBuf:= (String new: l) asBSTR .
> dataBuf:= (String new: l) asVariant.
> dataBuf:= BSTR newSAFEARRAY: l.
> dataBuf:= BSTR newBuffer.
> dataBuf:= BSTR new asVariant.
> dataBuf:= ExternalMemory new: l.
>
> But I always get an HRESULT error (see below), I've tried debugging the
>    variables in the wallback but I'm not sure which is what.
> =======start=======================================
> HRESULT Error: Type missmatch. (FACILITY_DISPATCH)
>
> Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:flags:parms:retVal:
> Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:flags:parms:
> Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:withArguments:
> Cwbautsv_DcwbDatabaseSQL>>cwbdbGetResultData:dataLen:indicatorBuf:indicatorCount:errorMessage:
> UndefinedObject>>{unbound}doIt
>
> =======end=======================================
>
>
> Some of the variables that look like they could point to the problem are
> "ex":
> ====start==================
> an EXCEPINFO(wCode=0 bstrSource=a BSTR('') bstrDescription=a BSTR('')
> bstrHelpFile=a BSTR('') dwHelpContext=0 pfnDeferredFillIn=an
> ExternalAddress(NULL) scode=0)
> ====end==================
>
> "params":
> ====start==================
> a DISPPARAMS(rgvarg=a StructureArray(a VARIANT(dispatch: an IDispatch(an
> ExternalAddress(16rE67590))) a VARIANT(sdword: 2200) a VARIANT(bstr: '')
> a VARIANT(sdword: 5400) a VARIANT(bstr: '')) rgdispidNamedArgs=a
> StructureArray(NULL) cArgs=5 cNamedArgs=0)
> ====end==================
>
> "varRes":
> ====start==================
> a VARIANT(nil: nil)
> ====end==================
>
> "err":
> ====start==================
> a DWORD(16r3)
> ====end==================
>
> Any help would be much appreaciated.
> Thank,
> Theo

Theo --

It's been about three years since I've done any serious work on the
AS/400 but if my memory serves correctly there's an OLE DB driver
available. OLE DB has a nice COM interface that should easily
integrate with Dolphin.

I do know that this is an optional component during the Client Access
installation so you may not have it available.  If you can't find
anything you may want to run the Client Access setup again and install
this.

I made extensive use of the OLE DB driver at one point as a kind of
"middleware" to the AS/400.  Any program or command (this includes CL
and REXX) on the AS/400 is treated as a stored procedure by OLE DB.
Input parameters that you would type on the AS/400 command line are
bound as parameters in the OLE DB statement and results are returned
as a Recordset.  Of course, you can also query any tables (FILE)/views
(LOGICAL FILE) you've created as well.

Let me know if you're still having problems.

Regards,
Jeffrey D. Panici
Worker Bee Solutions, Inc.


Reply | Threaded
Open this post in threaded view
|

Re: Problems with AS/400 ActiveX call

Theo Pronk
Thanks Jeffrey,

ODBC
====
Looked at ODBC before, the problem is that it needs to be configured
specifically for AS/400. If there are more than one (AS/400) involved
I'm not confident that the users will do the right thing, so I prefer to
"encapsulate" that part of the system (a little OOP joke).

Problem solved
==============
I've solved the problem - silly me, the type wasn't a variable data type
but simply to do with input/output or bothways (ie "cwbrcInput,
cwbrcOutput or cwbrcInout" ).

Found it in an example C program also supplied with the toolkit.

Thanks to all who have been looking into this!

Regards,
Theo

==================================
Jeffrey D. Panici wrote:

> Theo <[hidden email]> wrote in message news:<bh1lcj$trhnj$[hidden email]>...
>
>>Hi,
>>
>>I'm working on a system that allows a PC client (Smalltalk) to connect
>>to an IBM AS/400 using the IBM supplied Client Access ToolKit.
>>
>>It was quite simple to import the ActiveX components using the ActiveX
>>controls. Tried some simple interfacing like running a program on the
>>AS/400 from a workspace and creating an AS/400 data queue insetting data
>>and retrieving it again.
>>
>>But accessing the DB2 SQL database is proving a bit harder. There is
>>very limited documentation unless you want to use C++ headers etc. The
>>was however an example using VB that uses the APIs in a similar way so I
>>tried logically converting the VB statements to Smalltalk in a
>>workspace.  Most calls are fine but when pointers are used I hit
>>problems. I've cut the VB code and the corresponding Smalltalk methods,
>>and the errors below for anyone who would like to help.
>>
>>The VB sample code using the ActiveX API looks like this:
>>====start==============================================================
>>rc = mySql.cwbdbGetResultData(dataBuf(), dataLen, indicatorBuf(),
>>indicatorCount, sysErr)
>>====end==============================================================
>>
>>The Smalltalk method generated when importing the AS/400 ActiveX
>>components looks like this:
>>====start==============================================================
>>cwbdbGetResultData: dataBuf dataLen: dataLen indicatorBuf: indicatorBuf
>>indicatorCount: indicatorCount errorMessage: errorMessage
>>
>> "Answer the <SDWORD> result of invoking the cwbdbGetResultData() method
>>of the COM object."
>>
>> ^(self invokeId: 23 withArguments:
>> ((Array new: 5)
>> basicAt: 1 put: dataBuf;
>> basicAt: 2 put: dataLen;
>> basicAt: 3 put: indicatorBuf;
>> basicAt: 4 put: indicatorCount;
>> basicAt: 5 put: errorMessage;
>> yourself))
>>====end==============================================================
>>
>>The problems are with "dataBuf" and "indicatorBuf". I've tried various
>>methods of initializing eg: (l is the the retrieved length from a
>>previous call)
>>
>>dataBuf:= (String new: l) asBSTR .
>>dataBuf:= (String new: l) asVariant.
>>dataBuf:= BSTR newSAFEARRAY: l.
>>dataBuf:= BSTR newBuffer.
>>dataBuf:= BSTR new asVariant.
>>dataBuf:= ExternalMemory new: l.
>>
>>But I always get an HRESULT error (see below), I've tried debugging the
>>   variables in the wallback but I'm not sure which is what.
>>=======start=======================================
>>HRESULT Error: Type missmatch. (FACILITY_DISPATCH)
>>
>>Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:flags:parms:retVal:
>>Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:flags:parms:
>>Cwbautsv_DcwbDatabaseSQL(IDispatch)>>invokeId:withArguments:
>>Cwbautsv_DcwbDatabaseSQL>>cwbdbGetResultData:dataLen:indicatorBuf:indicatorCount:errorMessage:
>>UndefinedObject>>{unbound}doIt
>>
>>=======end=======================================
>>
>>
>>Some of the variables that look like they could point to the problem are
>>"ex":
>>====start==================
>>an EXCEPINFO(wCode=0 bstrSource=a BSTR('') bstrDescription=a BSTR('')
>>bstrHelpFile=a BSTR('') dwHelpContext=0 pfnDeferredFillIn=an
>>ExternalAddress(NULL) scode=0)
>>====end==================
>>
>>"params":
>>====start==================
>>a DISPPARAMS(rgvarg=a StructureArray(a VARIANT(dispatch: an IDispatch(an
>>ExternalAddress(16rE67590))) a VARIANT(sdword: 2200) a VARIANT(bstr: '')
>>a VARIANT(sdword: 5400) a VARIANT(bstr: '')) rgdispidNamedArgs=a
>>StructureArray(NULL) cArgs=5 cNamedArgs=0)
>>====end==================
>>
>>"varRes":
>>====start==================
>>a VARIANT(nil: nil)
>>====end==================
>>
>>"err":
>>====start==================
>>a DWORD(16r3)
>>====end==================
>>
>>Any help would be much appreaciated.
>>Thank,
>>Theo
>
>
> Theo --
>
> It's been about three years since I've done any serious work on the
> AS/400 but if my memory serves correctly there's an OLE DB driver
> available. OLE DB has a nice COM interface that should easily
> integrate with Dolphin.
>
> I do know that this is an optional component during the Client Access
> installation so you may not have it available.  If you can't find
> anything you may want to run the Client Access setup again and install
> this.
>
> I made extensive use of the OLE DB driver at one point as a kind of
> "middleware" to the AS/400.  Any program or command (this includes CL
> and REXX) on the AS/400 is treated as a stored procedure by OLE DB.
> Input parameters that you would type on the AS/400 command line are
> bound as parameters in the OLE DB statement and results are returned
> as a Recordset.  Of course, you can also query any tables (FILE)/views
> (LOGICAL FILE) you've created as well.
>
> Let me know if you're still having problems.
>
> Regards,
> Jeffrey D. Panici
> Worker Bee Solutions, Inc.