Problems with AS/400 ActiveX call 
Author Message
 Problems with AS/400 ActiveX call

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



Wed, 25 Jan 2006 10:17:15 GMT  
 Problems with AS/400 ActiveX call

Quote:

> 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.



Thu, 26 Jan 2006 09:36:25 GMT  
 Problems with AS/400 ActiveX call
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

==================================

Quote:


>>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.



Thu, 26 Jan 2006 15:53:24 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. AS/400, RPG/400, COBOL, CL/400

2. Rexx/400 & DB2/400

3. Old RM-COBOL UNIX programmer seeking info on move to COBOL/400 on AS/400

4. COBOL/400 on IBM AS/400

5. AS/400 / RPG/400

6. rpg/400 to cobol/400 conversion?

7. Logo on COBOL/400 Display Files on AS/400

8. AS/400 RPG/400 SPECIALISTEN

9. Python/400 for AS/400 OS v4r3

10. TCL on OS/400 (AS/400)?

11. AS/400 Cobol trying to call an ILE Cobol function in a service progam - Please help

12. Problems with Nanforum's FT_ONIDLE() + Inkey()>400

 

 
Powered by phpBB® Forum Software