× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Larry, even though C is asking for pointers, remember that RPG passes by reference automatically. The net effect is that you simply define these as very long character fields, and just pass the variable references normally. There's a guide (Written by Barbara Morris) that covers some of the quirks of converting C prototypes to RPG...

http://www.opensource400.org/callc.html


D VprtXML PR EXTPROC('VprtXML')
D pConn * value
D pSession *
D pXmlBuf 65500a options(*varsize)
D pXmlResult 65500a options(*varsize)
D pResultSize 10I 0


To make this work, lets create your local vars... Making assumptions as to the size of the vars to define...

D ConnHdl S *
D SessHdl S *
D BufferIN S 4096a
D BufferOUT S 4096a
D BufferOUTSize S 10i 0 Inz(%size(BufferOUT))

/free
ConnHdl = SomeFunctionToOpenConnection();
VprtXML( ConnHdl : SessHdl
: BufferIN : BufferOUT : BufferOUTSize);



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Larry Moore
Sent: Tuesday, September 17, 2013 4:05 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: RE: Convert C Prototype to RPG

Thanks Eric. I was unable to find the size of the xml fields in the H
file and Vertex says it can be whatever size I need it.

"It is whatever size the caller creates it as.
The program which calls VprtXML creates pXmlBuf, of whatever
size should seem sufficient to hold the input request. The input XML is
delimited with a hex 0x00 character (the null character) at the
tail end."

The fields are pointers so I assume that I just pass the size of my
field to the api. If the prototype is incorrect will the program
compile and run without errors? I'm able to call the api but it returns
no results and there are no messages in the joblog. I'm not sure if
it's an issue with the prototype or if I'm just not passing the correct
data to the api.

Here's how I have it defined:

D VprtXML PR EXTPROC('VprtXML')
D pConn * value
D pSession *
D pXmlBuf * value
D pXmlResult *
D pResultSize 10I 0


Thanks




-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of DeLong, Eric
Sent: Monday, September 16, 2013 5:01 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: RE: Convert C Prototype to RPG

Larry,

I don't work with that particular product, but I do work with a C-based
product from Vertex... My rpg prototypes for these C functions follow a
pattern more like this...

Connection handles are usually just pointers, as it appears is the
session handle... Session handle is expected to be I/O, so you cannot
use Const or Value... I have had some odd issues with CWIDEN, so my
prototypes do not use this feature. I believe Vertex typically write
their APIs to use FIXED STORAGE LENGTHS for character data, so it's
imperative to declare your local storage for passing Character data to
be of the length specified in the Vertex C include member. They
typically have some constants defined for the "storage length" used for
character data fields. Check your C prototypes in the product's H file.
If the field is expected to pass 30 bytes, the C prototype typically
defines the storage length to be 31. I presume this is one extra byte
initialized to null character (x'00) so that their functions will accept
fixed length OR varying length C Character strings...

Here's my take on your prototype...

D VprtXML PR EXTPROC('VprtXML')

D pConn * value

D pSession *

D pXmlBuf 65500a

D pXmlResult 65500a

D pResultSize 10I 0


The sizing of the xml fields is unknown, so those may need to be sized
differently depending on the C includes specifying a storage length for
these.

Hope I didn't get this too wrong, but without seeing the H includes,
it's nearly impossible to clarify...

Hth,
-Eric DeLong

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Larry Moore
Sent: Monday, September 16, 2013 2:20 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Convert C Prototype to RPG

I need to interface our payroll program with Vertex Q Series payroll tax
software. The Vertex functions are written in C and our payroll programs
are in RPG. I am not proficient in the C language and Vertex support
doesn't know RPG so I'm struggling to prototype their functions in my
program. Has anyone integrated with Vertex using their Enhance
Integration XML api's?



Here's the definition of one of their functions:



Parameter Use Description


---------- ----
-----------------------------------------

lConnHdl I The connection
handle returned from VprtOpenPRT

Session I/O Pointer to the
session handle, which will hold the context for this session. Should be
initialized to NULL before the first call.

XmlBuf I Character string
containing XML request

XmlResult O Pointer to character
string where the result will be stored


pResultSize I On input, the size of
the XmlResult buffer


PREFIX int POSTFIX VprtXML(tVprtConn lConnHdl, void **pSession, char
*XmlBuf, char *XmlResult, long *pResultSize);




Here's an example of what I tried but it doesn't appear to be correct
because nothing happens when I execute. Any suggestions? I am able to
open a connection to the database and create the connection handle using
another api.



D VprtXML PR EXTPROC(*CWIDEN: 'VprtXML')

D pConn * value options(*string)

D pSession * value options(*string)

D pXmlBuf * value options(*string)

D pXmlResult * value options(*string)

D pResultSize 10I 0



xml = '<QUERY> ' +

'<PAYDATE>20130901</PAYDATE> ' +

'<GEOSTATE>39</GEOSTATE> ' +

'<GEOCNTY>129</GEOCNTY> ' +

'<GEOCITY>2560</GEOCITY> ' +

'<TAXID>537</TAXID> ' +

'<GET> ' +

'<TAXNAMES/> ' +

'</GET> ' +

'</QUERY>' + NULL;



xml = cvtCCSID( xml: 819: NULL);

pConnection = %addr(lConHnd);

pSession = %addr(session);

pXmlBuf = %addr(xml);





VprtXML(pConnection: pSession: pXmlBuf: pXmlResult:
pResultSize);



Thanks,



Larry Moore * Covenant Transportation Group * Systems Analyst *
423.463.3374




______________________________________________________________________
This communication and the information transmitted is intended solely
for the individual or entity to which it is addressed and may contain
confidential and/or privileged material. Any review, retransmission,
dissemination or other use of or taking action in reliance upon this
information by persons or entities other than the intended recipient is
prohibited. If you have received this email in error please contact the
sender immediately and delete the material from any computer. As a
recipient of this email, you are responsible for screening its contents
and the contents of any attachments for the presence of viruses.
Covenant Transportation Group, Inc. and it's subsidiary Covenant
Transport, Inc. accept no liability for any damages caused by any virus
transmitted by this email.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.


______________________________________________________________________
This e-mail has been scanned by MCI Managed Email Content Service, using
Skeptic(tm) technology powered by MessageLabs. For more information on
MCI's Managed Email Content Service, visit http://www.mci.com.
______________________________________________________________________

______________________________________________________________________
This communication and the information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender immediately and delete the material from any computer. As a recipient of this email, you are responsible for screening its contents and the contents of any attachments for the presence of viruses. Covenant Transportation Group, Inc. and it's subsidiary Covenant Transport, Inc. accept no liability for any damages caused by any virus transmitted by this email.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.