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



Use pcml. It handles memory allocation and is much easier to use.

On Sat, Apr 2, 2022 at 4:49 PM Pete Helgren <pete@xxxxxxxxxx> wrote:

Tried and failed at this last fall but I am making another stab at it.
I am calling a DCM API from Java
("/QSYS.LIB/QICSS.LIB/QYCDRNWC.SRVPGM") The format is RNW0300. The part
that I am struggling with is that one of the parameters is a structure.
Like so (from docs):

Required Parameter Group:
1 Certificate request data Input Char(*)

2 Length of certificate request data Input Binary(4)

3 Format name Input Char(8)

4 Error Code I/O Char(*)

That first parameter is a structure (Format RNW0300). It looks like this:

Offset
Dec Hex Type Field
0 0 Binary (4) Offset to certificate path and file name
4 4 Binary (4) Length of certificate path and file name
Char (*) Certificate path and file name

I coded it in Java like so:

AS400DataType[] format = {
// 0 0 Binary (4) Offset to certificate path and file name
new AS400Bin4(),
// 4 4 Binary (4) Length of certificate path and file name
new AS400Bin4(),
// Char (*) Certificate path and file name
new AS400Text(certificate_path.length())
};

AS400Structure rnw0300 = new AS400Structure(format);

Then I set the parameter like this:

// Set up the parms
ProgramParameter[] parameterList = new ProgramParameter[4];
// 1 Certificate request data Input Char(*) the structure for format
RNW0300
parameterList[0] = new ProgramParameter(rnw0300.toBytes(new Object[]
{ 8, certificate_path.length(), certificate_path }));
// 2 Length of certificate request data Input Binary(4)
parameterList[1] = new ProgramParameter(new
AS400Bin4().toBytes(rnw0300.getByteLength()));
// 3 Format name Input Char(8)
parameterList[2] = new ProgramParameter(new
AS400Text(8).toBytes(apiFormat));
// 4 Error Code I/O Char(*)
ErrorCodeParameter ec = new ErrorCodeParameter(true, true);
parameterList[3] = ec;

When calling the service program I get this error returned:

AS400Message (ID: CPF9872 text: Program or service program QYCDRNWC in
library QICSS ended. Reason code
2.):com.ibm.as400.access.AS400Message@b7566fbf

The message description says this:

Message ID . . . . . . . . . : CPF9872

Message file . . . . . . . . : QCPFMSG

Library . . . . . . . . . : QSYS



Message . . . . : Program or service program &1 in library &2 ended.
Reason

code &3.

Cause . . . . . : The specified program or service program was ended due
to

one of the following:

1 -- A pointer was used that is not available for use while running
in the

current program state.

2 -- A pointer was used, either directly or as a basing pointer, that
has

not been set to an address.


So it seems to indicate that a pointer isn't properly set. Not sure
which parameter it is complaining about but my guess is that it is the
structure reference.

Bit of a noob at this but it seems pretty simple. Do you see anything
that is radically wrong? I couldn't find a good example of passing a
AS400Structure as an input parameter....(perhaps my assumption that that
is the issue is wrong)

--
Pete Helgren
www.petesworkshop.com
GIAC Secure Software Programmer-Java
AWS Certified Cloud Practitioner
Microsoft Certified: Azure Fundamentals
Twitter - Sys_i_Geek IBM_i_Geek
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing
list
To post a message email: JAVA400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/java400-l.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com


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.