|
1/ I remove the keyword "Value" of the parameter "String" in the service program. 2/ Change the parameter property ProgramParameter.PASS_BY_VALUE to ProgramParameter.PASS_BY_REFERENCE 3/ The service program runs fine. However the class Temp can not receive the correct returned value - it only displays either -1 or 0. I do not know where to download the redbook to set the service program to accept the returned value. In Dave sample, it sets for ServiceProgramCall.NO_RETURN_VALUE. In the Temp class, the parameter property is not setup. sPGMCall = new ServiceProgramCall(system,"/QSYS.LIB/QTOCNETSTS.SRVPGM", "QtocLstNetIfc", ServiceProgramCall.NO_RETURN_VALUE,parms); CL "Price, Chris" <chris_price@nsb.co.uk>@midrange.com on 08/22/2001 03:12:36 AM Please respond to java400-l@midrange.com Sent by: java400-l-admin@midrange.com To: "'java400-l@midrange.com'" <java400-l@midrange.com> cc: Subject: RE: AS400 Toolbox problems - ServiceProgramCall Dave, No - due to time pressures I couldn't wait for answers, so I've converted my service program call to a regular program call. This is not a long-term solution however, as we cannot create program objects for every RPG procedure, just so they can be called by Java clients. As I said in my original post, I couldn't get passing by reference to work either (this was my first choice!) It would helpful if restrictions like "ServiceProgramCall supports pass by value only for integer values" was mentioned in the toolbox documentation. In general I have found the toolbox documentation for ProgramCall & ServiceProgramCall to be very poor - none of the "examples" will compile, and even if they did, cannot be run on anyold AS400, as the example programs are not shipped in the ADTSLAB library, as they are for other examples in the toolbox. Soldiering on... Chris. -----Original Message----- From: Dave Wall [mailto:dawall@us.ibm.com] Sent: 21 August 2001 17:05 To: 'JAVA400-L@midrange.com' Subject: RE: AS400 Toolbox problems - ServiceProgramCall Chris, were you able to get your example working? My RPG contacts finally returned by note and they were able to get your example to work by changing your RPG code to say the character parameter is pass by reference. It turns out that Toolbox ServiceProgramCall supports pass by value only for integer values. I found out that with RPG, large structures / strings can be pass by value. These parameters will not work through the Toolbox object. They must be changed to be pass by reference. David Wall AS/400 Toolbox for Java ----- Forwarded by Dave Wall/Rochester/IBM on 08/14/2001 03:18 PM ----- "Price, Chris" <chris_price@nsb.c To: "'JAVA400-L@midrange.com'" <JAVA400-L@midrange.com> o.uk> cc: Sent by: Subject: RE: AS400 Toolbox problems - ServiceProgramCall owner-java400-l@mi drange.com 08/14/2001 10:18 AM Please respond to JAVA400-L Thanks for your example. Unfortunately it didn't work on my system as we don't seem to have a QTOCNETSTS service program. I'm trying to call my own service program, written in RPG IV. The Java class sets the String input parameter to a test value, and calls the procedure. The procedure compares the passed in string to a value, and if the same returns 99, otherwise returns -1. If written as a service program, the return value is always -1. Yet if I convert the service program into a program, making the nessesscary changes to the class, the return value is 99. Here's a sample of my Java & RPG code: public class Temp { public static void main(String[] parameters) { AS400 as400 = new AS400(); QSYSObjectPathName sprogramName = new QSYSObjectPathName("R1005DVOBJ", "CJPTEST", "SRVPGM"); ServiceProgramCall spgm = new ServiceProgramCall(as400); //Service Program Call try { // One Parameter - String in. Returns short ProgramParameter[] parmlist = new ProgramParameter[1]; AS400Text text1 = new AS400Text(10, as400); byte[] text = text1.toBytes("CHRISPRICE"); // parmlist[0] = new ProgramParameter(text); parmlist[0] = new ProgramParameter(); parmlist[0].setInputData(text); parmlist[0].setParameterType(ProgramParameter.PASS_BY_VALUE); //run the serivce program spgm.setProgram(sprogramName.getPath(), parmlist); spgm.setProcedureName("CJPTEST_PROC"); if (spgm.run() != true) { AS400Message[] msgList = spgm.getMessageList(); System.out.println("The program did not run. AS/400 messages:"); for (int i = 0; i < msgList.length; i++) { System.out.println(msgList[i].getText()); } } else { AS400Bin2 as400Int = new AS400Bin2(); byte[] as400Data = spgm.getReturnValue(); short result = as400Int.toShort(as400Data, 0); System.out.println("Service Program Call Result is : " + result); } } catch (Exception e) { System.out.println("Service Program call failed"); System.out.println(e); } System.exit(0); } } The very simple RPG module: D CJPTEST_PROC PR 5I 0 D String 10 Value P CJPTEST_PROC B Export D PI 5I 0 D String 10 Value C If String = 'CHRISPRICE' C Return 99 C Else C Return -1 C Endif -----Original Message----- From: Dave Wall [mailto:dawall@us.ibm.com] Sent: 14 August 2001 15:45 To: JAVA400-L@midrange.com Subject: Re: AS400 Toolbox problems - ServiceProgramCall Here is code to call entry point QtocLstNetIfc in service program QTOCNETSTS. The entry point takes three parameters -- two strings (passed by reference) and the error code. The strings are converted from Unicode to EBCDIC before being sent to the server. When calling programs or service programs, pay particular attention to lengths. The Toolbox client passes data to the program call server who dumps the data in one big buffer. It then passes pointers to that buffer or pulls data out of the buffer when calling the service program. If a length is off the wrong data will be passed, but since all data comes out of one big buffer you may not get a addressing errors (trying to get to memory you don't own). You will just get bad data. Are you trying to call an OS/400 service program or one of your own? Some Toolbox objects are implemented by calling OS/400 service programs via ServiceProgramCall so I know it can work. AS400 system = new AS400(); // The first parm is 20 characters, 10 chars of user space followed by 10 chars of library. // Create a converter for 20 chars. AS400Text char20 = new AS400Text(20, system); // The second parm is the format name (8 chars). Create a converter. AS400Text char8 = new AS400Text(8, system); // Create program parameters ProgramParameter[] parms = new ProgramParameter[3]; // First parm is qualified user space CHAR(20) // CHAR(0-9) is the user space name // CHAR(10-19) is the library name String qSpace = "DAW DAW "; // First parm is the library qualified UserSpace parms[0] = new ProgramParameter(char20.toBytes(qSpace)); parms[0].setParameterType(ProgramParameter.PASS_BY_REFERENCE); // Second parm is the format parms[1] = new ProgramParameter(char8.toBytes("NIFC0100")); parms[1].setParameterType(ProgramParameter.PASS_BY_REFERENCE); // Last parm is the error code. We pass an array of 0x00s so messages are returned. byte[] bytes = new byte[32]; parms[2] = new ProgramParameter(bytes, 32); parms[2].setParameterType(ProgramParameter.PASS_BY_REFERENCE); ServiceProgramCall sPGMCall = null; System.out.println("About to create the program"); sPGMCall = new ServiceProgramCall(system, "/QSYS.LIB/QTOCNETSTS.SRVPGM", "QtocLstNetIfc", ServiceProgramCall.NO_RETURN_VALUE, parms); System.out.println(sPGMCall.run()); AS400Message[] ml = sPGMCall.getMessageList(); for (int i=0; i<ml.length; i++) System.out.println(ml[i].getID() + ": " + ml[i].getText()); David Wall 553-5329 AS/400 Toolbox for Java "Price, Chris" <chris_price@nsb.c To: "'java400-l@midrange.com'" <java400-l@midrange.com> o.uk> cc: Sent by: Subject: AS400 Toolbox problems - ServiceProgramCall owner-java400-l@mi drange.com 08/14/2001 05:31 AM Please respond to JAVA400-L Has anyone successfully managed to call a procedure in a service program, using the ServiceProgramCall class? I'm having major problems getting this to work: Passing by reference doesn't work at all - get null pointer errors in the procedure. Passing by value works for integers, but Strings get garbled. I thought this might be a CCSID problem, but the same code works fine for a ProgramCall. Does anyone have any working examples using this class, there aren't any that I can find in the toolbox documentation. Confused, Chris. =======DISCLAIMER======= This email transmission and any attachments may contain confidential information which is legally privileged. You are also notified that the contents of this email and any which you may send in reply, may be viewed by authorised personnel on behalf of NSB Retail Systems Plc or its subsidiaries (the Company) in accordance with the Company's Information Access Policy. The content of this email is always subject to contract. The information is intended only for the individual or entities to whom it is addressed. If you are not an intended recipient please contact me immediately and you are hereby notified that any disclosure, copying, distribution, storage on any medium or use of the information contained in this transmission is strictly prohibited. +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- =======DISCLAIMER======= This email transmission and any attachments may contain confidential information which is legally privileged. You are also notified that the contents of this email and any which you may send in reply, may be viewed by authorised personnel on behalf of NSB Retail Systems Plc or its subsidiaries (the Company) in accordance with the Company's Information Access Policy. The content of this email is always subject to contract. The information is intended only for the individual or entities to whom it is addressed. If you are not an intended recipient please contact me immediately and you are hereby notified that any disclosure, copying, distribution, storage on any medium or use of the information contained in this transmission is strictly prohibited. +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com
As an Amazon Associate we earn from qualifying purchases.
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.