midrange.com code scratchpad
Name:
Create Program Call Beans
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
09/22/2009 01:38:45 pm
IP:
Logged
Description:
IsInBilling.java
BillingSystemException-t.java
Code:
  1. package paetec.com.www.wbs0004;
  2.  
  3. import paetec.com.www.wbs0004.BillingSystemException_t;
  4. import iseries.programcall.base.AbstractProgramCallBean;
  5. import com.ibm.as400.access.AS400Message;
  6. import com.ibm.as400.access.AS400;
  7. import com.ibm.as400.access.ServiceProgramCall;
  8. import com.ibm.as400.access.ProgramParameter;
  9. import com.ibm.as400.access.Trace;
  10. import iseries.programcall.base.RuntimeContext;
  11. import iseries.programcall.base.Constants;
  12. import iseries.programcall.base.Messages;
  13. import com.ibm.as400.access.AS400Text;
  14. import java.util.Hashtable;
  15.  
  16. /*
  17.  * <!-- begin-system-doc -->
  18.  * plugin: com.ibm.etools.iseries.javatools
  19.  * version: 7.5.3
  20.  * timestamp: 03:19:35 PM 2009/09/21
  21.  * pcml: paetec.com.www.wbs0004.wbs0004.pcml
  22.  * <!-- end-system-doc -->
  23.  * 
  24.  * Program call bean for invoking program /QSYS.LIB/%LIBL%.LIB/wbs0004.SRVPGM
  25.  */
  26. public class IsInBilling extends AbstractProgramCallBean
  27. {
  28.     private static final long serialVersionUID = 2960724315884918988L;
  29.  
  30.     // Program parameter: accountId.
  31.     private String accountId = "";
  32.  
  33.     // Program parameter: billing.
  34.     private String billing = "";
  35.  
  36.     // Program parameter: error.
  37.     private BillingSystemException_t error =  new BillingSystemException_t();
  38.  
  39.     // The runtime context
  40.     private static RuntimeContext rtContext = null;
  41.     static {
  42.         rtContext = RuntimeContext.getContext("/invoicePreviewPCW.config");
  43.     }
  44.  
  45.     public IsInBilling()
  46.     {
  47.         super(rtContext);
  48.         programPath = "/QSYS.LIB/%LIBL%.LIB/wbs0004.SRVPGM";
  49.     }
  50.  
  51.     /*
  52.      * Set the value of the program parameter: accountId.
  53.      * 
  54.      * @value The value of the parameter.
  55.      */
  56.     public void setAccountId(String value)
  57.     {
  58.         accountId = value;
  59.     }
  60.  
  61.     /*
  62.      * Get the value of the program parameter: accountId.
  63.      * 
  64.      * @return The value of the parameter.
  65.      */
  66.     public String getAccountId()
  67.     {
  68.         return accountId;
  69.     }
  70.  
  71.     /*
  72.      * Set the value of the program parameter: billing.
  73.      * 
  74.      * @value The value of the parameter.
  75.      */
  76.     public void setBilling(String value)
  77.     {
  78.         billing = value;
  79.     }
  80.  
  81.     /*
  82.      * Get the value of the program parameter: billing.
  83.      * 
  84.      * @return The value of the parameter.
  85.      */
  86.     public String getBilling()
  87.     {
  88.         return billing;
  89.     }
  90.  
  91.     /*
  92.      * Set the value of the program parameter: error.
  93.      * 
  94.      * @value The value of the parameter.
  95.      */
  96.     public void setError(BillingSystemException_t value)
  97.     {
  98.         error = value;
  99.     }
  100.  
  101.     /*
  102.      * Get the value of the program parameter: error.
  103.      * 
  104.      * @return The value of the parameter.
  105.      */
  106.     public BillingSystemException_t getError()
  107.     {
  108.         return error;
  109.     }
  110.  
  111.     /*
  112.      * Invoke the program and return the status parameter. 
  113.      * If the invoke fails, you can use the retrieveProgramCallException() 
  114.      * method to determine why the invoke failed.
  115.      * 
  116.      * @return  The value of the status parameter (if specified) is returned if the
  117.      * invoke was successful. Constants.FAILURE otherwise.
  118.      */
  119.     public String invokeReturnStatus()
  120.     {
  121.         if (!invoke()) {
  122.             return Constants.FAILURE;
  123.         }
  124.         return Constants.SUCCESS;
  125.     }
  126.  
  127.     /*
  128.      * Invoke the program. If the invoke fails, you can use the retrieveProgramCallException()
  129.      *  method to determine why the invoke failed. If the invoke is successful, the
  130.      * output paramters will be updated.
  131.      * 
  132.      * @return True if the program is invoked successfully. False otherwise.
  133.      */
  134.     public boolean invoke()
  135.     {
  136.         AS400 as400 = null;
  137.         try {
  138.             if (connection == null) {
  139.                 throw new Exception(Messages.getMsgText("NoConnection"));
  140.             }
  141.  
  142.             connection.setThreadSafe(false);
  143.             as400 = connection.getAS400();
  144.             ServiceProgramCall thePgm = new ServiceProgramCall(as400);
  145.             ProgramParameter[] parmList = new ProgramParameter[3];
  146.  
  147.             // Declare converters
  148.             AS400Text as400text1 = new AS400Text(16, as400);
  149.             AS400Text as400text3 = new AS400Text(512, as400);
  150.             AS400Text as400text2 = new AS400Text(1, as400);
  151.  
  152.             // Process input parameter accountId
  153.             parmList[0] =  new ProgramParameter();
  154.             parmList[0].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
  155.             int accountIdOutputsize = 16;
  156.             int accountIdSize = 16;
  157.             byte [] accountIdInputBuf = new byte[accountIdSize];
  158.             int accountIdInputBufOffset = 0;
  159.             as400text1.toBytes(trimRight(getAccountId()), accountIdInputBuf, accountIdInputBufOffset);
  160.             accountIdInputBufOffset += 16;
  161.             parmList[0].setInputData(accountIdInputBuf);
  162.  
  163.             // Process input parameter billing
  164.             parmList[1] =  new ProgramParameter();
  165.             parmList[1].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
  166.             int billingOutputsize = 1;
  167.             parmList[1].setOutputDataLength(billingOutputsize);
  168.  
  169.             // Process input parameter error
  170.             parmList[2] =  new ProgramParameter();
  171.             parmList[2].setParameterType(ProgramParameter.PASS_BY_REFERENCE);
  172.             int errorOutputsize = 512 + 512;
  173.             parmList[2].setOutputDataLength(errorOutputsize);
  174.  
  175.             // Invoke the program.
  176.             programException = null;
  177.             AS400Message[] myProgramMessages = null;
  178.             thePgm.setProgram(programPath, parmList);
  179.             thePgm.setThreadSafe(false);
  180.             thePgm.setProcedureName("ISINBILLING");
  181.             thePgm.setReturnValueFormat(ServiceProgramCall.NO_RETURN_VALUE);
  182.             if (!thePgm.run()) {
  183.                 myProgramMessages = thePgm.getMessageList();
  184.                 connection.releaseAS400();
  185.                 StringBuffer pgmMsgs = new StringBuffer();
  186.                 String NEW_LINE = System.getProperty("line.separator");
  187.                 pgmMsgs.append(Messages.getMsgText("InvocationFail") + NEW_LINE);
  188.                 for (int msg = 0; myProgramMessages != null && msg < myProgramMessages.length; msg++) {
  189.                     pgmMsgs.append(myProgramMessages[msg].toString() + NEW_LINE);
  190.                 }
  191.                 throw new java.lang.RuntimeException(pgmMsgs.toString());
  192.             }
  193.  
  194.             Hashtable offsetStack = new Hashtable();
  195.             int skipBytes = 0;
  196.             int offset = 0;
  197.             // Process output parameter billing
  198.             byte [] billingOutputBuf = parmList[1].getOutputData();
  199.             int billingOutputBufOffset = 0;
  200.             offset = 0;
  201.             skipBytes = 0;
  202.             offset = offset + skipBytes;
  203.             billingOutputBufOffset= offset;
  204.             if(offset + 1 > billingOutputBuf.length) {
  205.                 throw new java.lang.RuntimeException(Messages.getMsgText("InsufficientInputData"));
  206.             }
  207.             setBilling(trimRight((String)as400text2.toObject(billingOutputBuf,billingOutputBufOffset)));
  208.             billingOutputBufOffset += 1;
  209.             offset = billingOutputBufOffset;
  210.  
  211.             // Process output parameter error
  212.             byte [] errorOutputBuf = parmList[2].getOutputData();
  213.             int errorOutputBufOffset = 0;
  214.             offset = 0;
  215.             skipBytes = 0;
  216.             offsetStack.put("billingSystemException_t", new Integer(offset + skipBytes));
  217.             offset = offset + skipBytes;
  218.             setError( new BillingSystemException_t());
  219.             skipBytes = 0;
  220.             offset = offset + skipBytes;
  221.             errorOutputBufOffset= offset;
  222.             if(offset + 512 > errorOutputBuf.length) {
  223.                 throw new java.lang.RuntimeException(Messages.getMsgText("InsufficientInputData"));
  224.             }
  225.             getError().setERRORMESSAGE(trimRight((String)as400text3.toObject(errorOutputBuf,errorOutputBufOffset)));
  226.             errorOutputBufOffset += 512;
  227.             offset = errorOutputBufOffset;
  228.             skipBytes = 0;
  229.             offset = offset + skipBytes;
  230.             errorOutputBufOffset= offset;
  231.             if(offset + 512 > errorOutputBuf.length) {
  232.                 throw new java.lang.RuntimeException(Messages.getMsgText("InsufficientInputData"));
  233.             }
  234.             getError().setSTACKTRACE(trimRight((String)as400text3.toObject(errorOutputBuf,errorOutputBufOffset)));
  235.             errorOutputBufOffset += 512;
  236.             offset = errorOutputBufOffset;
  237.  
  238.             return true;
  239.  
  240.         } catch (Exception e) {
  241.             programException = e;
  242.             Trace.log(Trace.ERROR, e);
  243.             if (rtContext != null && rtContext.throwExceptionOnError()) {
  244.                 throw new java.lang.RuntimeException(e);
  245.             }
  246.         }
  247.         finally {
  248.             if (connection != null) {
  249.                 try { connection.releaseAS400(); } catch (Exception e) { Trace.log(Trace.ERROR, e); }
  250.             }
  251.         }
  252.         return false;
  253.     }
  254.  
  255.     /*
  256.      * Get the RuntimeContext for this program call bean.
  257.      * 
  258.      * @return The runtime context.
  259.      */
  260.     public static RuntimeContext getRuntimeContext()
  261.     {
  262.         return rtContext;
  263.     }
  264.  
  265. }
  266. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  267.  
  268. package paetec.com.www.wbs0004;
  269.  
  270.  
  271. /*
  272.  * <!-- begin-system-doc -->
  273.  * plugin: com.ibm.etools.iseries.javatools
  274.  * version: 7.5.3
  275.  * timestamp: 03:19:35 PM 2009/09/21
  276.  * pcml: paetec.com.www.wbs0004.wbs0004.pcml
  277.  * <!-- end-system-doc -->
  278.  * 
  279.  * Class for structure: billingSystemException_t
  280.  */
  281. public class BillingSystemException_t
  282. {
  283.     private static final long serialVersionUID = -3317366758747415735L;
  284.  
  285.     // Program parameter: ERRORMESSAGE.
  286.     private String ERRORMESSAGE = "";
  287.  
  288.     // Program parameter: STACKTRACE.
  289.     private String STACKTRACE = "";
  290.  
  291.     public BillingSystemException_t()
  292.     {
  293.         super();
  294.     }
  295.  
  296.     /*
  297.      * Set the value of the program parameter: ERRORMESSAGE.
  298.      * 
  299.      * @value The value of the parameter.
  300.      */
  301.     public void setERRORMESSAGE(String value)
  302.     {
  303.         ERRORMESSAGE = value;
  304.     }
  305.  
  306.     /*
  307.      * Get the value of the program parameter: ERRORMESSAGE.
  308.      * 
  309.      * @return The value of the parameter.
  310.      */
  311.     public String getERRORMESSAGE()
  312.     {
  313.         return ERRORMESSAGE;
  314.     }
  315.  
  316.     /*
  317.      * Set the value of the program parameter: STACKTRACE.
  318.      * 
  319.      * @value The value of the parameter.
  320.      */
  321.     public void setSTACKTRACE(String value)
  322.     {
  323.         STACKTRACE = value;
  324.     }
  325.  
  326.     /*
  327.      * Get the value of the program parameter: STACKTRACE.
  328.      * 
  329.      * @return The value of the parameter.
  330.      */
  331.     public String getSTACKTRACE()
  332.     {
  333.         return STACKTRACE;
  334.     }
  335.  
  336. }
  337.  
© 2004-2019 by midrange.com generated in 0.007s valid xhtml & css