|
This is a snippet from a program I wrote a while back. It is a method to create a workorder that returns an int (status). I ran it as an application and another version as a servlet. It calls a CL to setup the environment on the 400 which then passes the input parms to an rpg program. On a 620 there were no speed problems. Also wrote and tested on a pc with the jdk1.2 and ported to the 400 under 1.1.7 and it ran with no problems. A couple of quirks. I have a continue in the IOException catch because for some reason the call didn't happen on the first try being run as a servlet. Java programs cannot cross activation groups. So if your rpg is in a named act group the program will not run. I had to bind all of the modules by copy. CLLE, RPGLE into 1 program object that was called. The date is REALLY a packed decimal on the 400 (LEGACY). HTH Dan /***************************************************************** ***************************************************************** C R E A T E ******************************************************************/ public int create(String POnumber, String SKU, String SewPlant, BigDecimal Quantity, BigDecimal DueDate ) { int workorder = 0; String action = "A"; String user = "SOURCING"; String sDueDate; ProgramParameter[] crtpList = new ProgramParameter[8]; if ( (POnumber.length() < 1) || (POnumber.length() > 15) ) return PO_INVALID; else { POnumber = POnumber.toUpperCase(); AS400Text tPOnumber = new AS400Text(15); byte[] bPOnumber = tPOnumber.toBytes(POnumber); crtpList[0] = new ProgramParameter(bPOnumber); } if ( SKU.length() != 10 ) return SKU_INVALID; else { SKU = SKU.toUpperCase(); AS400Text tSKU = new AS400Text(10); byte[] bSKU = tSKU.toBytes(SKU); crtpList[1] = new ProgramParameter(bSKU); } if ( (SewPlant.length() != 2) ) return SEW_PLANT_INVALID; else { AS400Text tSewPlant = new AS400Text(4); byte[] bSewPlant = tSewPlant.toBytes(SewPlant); crtpList[2] = new ProgramParameter(bSewPlant); } if ( Quantity.intValue() < 1 ) return QUANTITY_INVALID; else { AS400PackedDecimal pQuantity = new AS400PackedDecimal(7,0); byte[] bQuantity = pQuantity.toBytes(Quantity); crtpList[3] = new ProgramParameter(bQuantity); } sDueDate = DueDate.toString(); if ( sDueDate.length() != 8 ) return DUE_DATE_INVALID; else { AS400PackedDecimal pDueDate = new AS400PackedDecimal(8,0); byte[] bDueDate = pDueDate.toBytes(DueDate); crtpList[4] = new ProgramParameter(bDueDate); } AS400Text tAction = new AS400Text(1); byte[] bAction = tAction.toBytes(action); crtpList[5] = new ProgramParameter(bAction); AS400Text tUser = new AS400Text(10); byte[] bUser = tUser.toBytes(user); crtpList[6] = new ProgramParameter(bUser); /* this is the workorder that will be returned from the program if success then the workorder will be > 0 */ crtpList[7] = new ProgramParameter(4); runCreate: for( int i=0; i < 2; i++ ) { try { as400 = new AS400("as400name", "", ""); ProgramCall crtPGM = new ProgramCall(as400, "/QSYS.LIB/OPOBJ.LIB/OPLB0499.PGM", crtpList); if ( crtPGM.run() == true ) { AS400Bin4 bin4Converter = new AS400Bin4(); byte[] bHr = crtpList[7].getOutputData(); workorder = bin4Converter.toInt(bHr); as400.disconnectAllServices(); return workorder; } else return CREATE_PROGRAM_ERROR; } catch(ErrorCompletingRequestException e) { as400.disconnectAllServices(); if ( i < 2 ) continue runCreate; return WO_SYSTEM_ERROR; } // this is the timeout exception that occurs for whatever reason. catch(IOException e) { as400.disconnectAllServices(); if ( i < 2 ) continue runCreate; return WO_SYSTEM_ERROR; } catch(AS400SecurityException e) { as400.disconnectAllServices(); return WO_SYSTEM_ERROR; } catch(ObjectDoesNotExistException e) { as400.disconnectAllServices(); return WO_SYSTEM_ERROR; } catch(java.lang.InterruptedException e) { as400.disconnectAllServices(); return WO_SYSTEM_ERROR; } } // end for return WO_SYSTEM_ERROR; } // end create > -----Original Message----- > From: Eric Merritt <cyberlync@yahoo.com> > To: JAVA400-L@midrange.com <JAVA400-L@midrange.com> > Date: Friday, March 30, 2001 11:11 AM > Subject: Re: ProgramCall and ProgramParameter > classes > > > >Robert, > > > > If I might be so bold, Program calls using the > >AS/400 tool box can tend to be a little slow. I > always > >suggest you bundle up your native programs on the > 400 > >as SQL stored procedures and call them via JDBC. > Then > >not only do you get a little faster resonse, you > get > >an open service that is callable by any program > >includeing Java. (And you get to remain platform > >independant) > > > >--- Robert Upshall <rupshall@hotmail.com> wrote: > >> Hi, > >> > >> I am attempting to convert my code to use > >> ProgramCall instead of > >> CommandCall, the command call worked fine now we > >> need to pass values back so > >> we will need to take advantage of > ProgramParameter > >> class. > >> > >> Could somebody tell me how I would convert the > >> CommandCall code below into > >> ProgramCall. > >> > >> // start code snipet > >> /* > >> CommandCall cmd = new CommandCall(srvb); > >> > >> // run the command > >> cmd.run( > >> "CALL GBTINET/GCPLIINET PARM('" > >> + pGroup > >> + "' '" > >> + pSin > >> + "' '" > >> + pClass > >> + "' '" > >> + pTypKey > >> + "')"); > >> > >> // get the message list which contains the result > of > >> the command. > >> AS400Message[] messageList = > cmd.getMessageList(); > >> */ > >> // end code snipet > >> > >> > >> Thanks in advance for any help > >> > >> Robert > >> > >_______________________________________________________________________ __ > >> Get Your Private, Free E-mail from MSN Hotmail at > >> http://www.hotmail.com. > >> > >> +--- > >> | 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 > >> +--- > > > > > >===== > >Eric Merritt > >Information Systems Consultant > >McCormack & Associates, Inc. > >Rock Hill, South Carolina > >(V) 803-327-3358 X 225 > >eric@mccinc.com > >http://www.mccinc.com/ > > > >__________________________________________________ > >Do You Yahoo!? > >Get email at your own domain with Yahoo! Mail. > >http://personal.mail.yahoo.com/?.refer=text > >+--- > >| 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 > +--- ===== Eric Merritt Information Systems Consultant McCormack & Associates, Inc. Rock Hill, South Carolina (V) 803-327-3358 X 225 eric@mccinc.com http://www.mccinc.com/ __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/?.refer=text +--- | 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 +---
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.