midrange.com code scratchpad
Name:
RPGIV Java interface V6.1
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
06/12/2009 12:58:57 pm
IP:
Logged
Description:
Fixed version of http://code.midrange.com/795c6c994c.html
Code:
  1.                                                                          
  2.                                                                                                      
  3.      /*============================================================================================= 
  4.      /*   Notes                                                                                      
  5.      /*============================================================================================= 
  6.                                                                                                      
  7.      /* Compile with ACTGRP(TESTRC)                                                                  
  8.                                                                                                      
  9.      /*============================================================================================= 
  10.      /*   Control Specifications                                                                     
  11.      /*============================================================================================= 
  12.                                                                                                     
  13.      H Option(*NODEBUGIO)                                                                            
  14.      H ExtBinInt                                                                                     
  15.      H BndDir('MCSERV')                                                                              
  16.                                                                                                      
  17.                                                                                                      
  18.      /*============================================================================================= 
  19.      /*   File Specifications                                                                        
  20.      /*============================================================================================= 
  21.                                                                                                      
  22.      FUTPMODE   IF   E             Disk    UsrOpn                                                    
  23.                                                                                                      
  24.      /*============================================================================================= 
  25.      /*   Prototype Specifications                                                                   
  26.      /*============================================================================================= 
  27.                                                                                                      
  28.                                                                                                      
  29.                                                                                                      
  30.      D testaccc2...                                                                                  
  31.      D                 PR                  ExtPgm('TESTACCC2')                                       
  32.                                                                                                      
  33.      D setAcctCodesInRevChain...                                                                     
  34.      D                 PR              N   ExtProc(*JAVA :                                           
  35.      D                                             'com.paetec.oss.accm.+                            
  36.      D                                              AcctCodeChangesInterface' :                      
  37.      D                                              'setAcctCodesInRevChain')                        
  38.      D                                 O   Class(*JAVA : 'java.lang.String')    Customer Number      
  39.      D                                     Const                                                     
  40.      D                               10I 0 Value                                Account Code Length  
  41.      D                               20I 0 Dim(132000)                          Account Code(s)      
  42.      D                                     Options(*VARSIZE)                                         
  43.      D                                     Const                                                     
  44.      D                                 O   Class(*JAVA : 'java.lang.String')    Name(s)              
  45.      D                                     Dim(132000)                                               
  46.      D                                     Options(*VARSIZE)                                         
  47.      D                                     Const                                                     
  48.      D                                 O   Class(*JAVA : 'java.lang.String')    Department(s)        
  49.      D                                     Dim(132000)                                               
  50.      D                                     Options(*VARSIZE)                                         
  51.      D                                     Const                                                     
  52.      D                                 O   Class(*JAVA : 'java.lang.String')    Region(s)            
  53.      D                                     Dim(132000)                                               
  54.      D                                     Options(*VARSIZE)                                         
  55.      D                                     Const                                                     
  56.                                                                                                      
  57.      D bindInterface...                                                                              
  58.      D                 PR              O   ExtProc(*JAVA :                                           
  59.      D                                             'com.paetec.oss.accm.+                            
  60.      D                                              AcctCodeChanges+                                 
  61.      D                                                ServiceHelper' :                               
  62.      D                                             'bind')                                           
  63.      D                                     Class(*JAVA :                                             
  64.      D                                           'com.paetec.oss.accm.+                              
  65.      D                                            AcctCodeChangesInterface')                         
  66.      D                                     Static                                                    
  67.      D                                 O   Class(*JAVA : 'java.lang.String')    URL                  
  68.      D                                     Const                                                     
  69.                                                                                                      
  70.      D constructJString...                                                                           
  71.      D                 PR              O   ExtProc(*JAVA :                                           
  72.      D                                             'java.lang.String' :                              
  73.      D                                             *CONSTRUCTOR)                                     
  74.      D                          1048576A   Varying                                                   
  75.      D                                     Const                                                     
  76.                                                                                                      
  77.      D jStringToRString...                                                                           
  78.      D                 PR       1048576A   ExtProc(*JAVA :                                           
  79.      D                                             'java.lang.String' :                              
  80.      D                                             'getBytes')                                       
  81.      D                                     Varying                                                   
  82.                                                                                                      
  83.                                                                                                      
  84.      /*============================================================================================= 
  85.      /*   Data Specifications                                                                        
  86.      /*============================================================================================= 
  87.                                                                                                      
  88.       /Include QRpgCbSrc,DQUsec                                                                      
  89.       /Include QRpgCbSrc,DQMhSndPm                                                                   
  90.       /Include QRpgCbSrc,DUserCh                                                                     
  91.                                                                                                      
  92.       /Include QRpgCbSrc,UNISTD.H                                                                    
  93.       /Include QRpgCbSrc,SVS9990                                                                     
  94.       /Include QRpgCbSrc,SVS9998                                                                     
  95.       /Include QRpgCbSrc,SVS9999                                                                     
  96.                                                                                                      
  97.      /*--------------------------------------------------------------------------------------------- 
  98.      /*   Data Structure Specifications                                                              
  99.      /*--------------------------------------------------------------------------------------------- 
  100.                                                                                                      
  101.      D classPaths      DS                  LikeDs(JVMClassPathsTemplate)                             
  102.      D properties      DS                  LikeDs(JVMPropertiesTemplate)                             
  103.                                                                                                      
  104.      /*--------------------------------------------------------------------------------------------- 
  105.      /*   Array Specifications                                                                       
  106.      /*--------------------------------------------------------------------------------------------- 
  107.                                                                                                      
  108.                                                                                                      
  109.      /*--------------------------------------------------------------------------------------------- 
  110.      /*   Indicator Specifications                                                                   
  111.      /*--------------------------------------------------------------------------------------------- 
  112.                                                                                                      
  113.      D globalInit      S               N                                                             
  114.                                                                                                      
  115.      /*--------------------------------------------------------------------------------------------- 
  116.      /*   Display Indicator Specifications                                                           
  117.      /*--------------------------------------------------------------------------------------------- 
  118.                                                                                                      
  119.                                                                                                      
  120.      /*--------------------------------------------------------------------------------------------- 
  121.      /*   Standalone Data Specifications                                                             
  122.      /*--------------------------------------------------------------------------------------------- 
  123.                                                                                                      
  124.      D x               S             10I 0                                                           
  125.      D count           S             10I 0                                                           
  126.      D message         S            128A   Varying                                                   
  127.      D applicationDir  S             50A   Varying                                                   
  128.      D                                     Inz('/Applications/')                                     
  129.      D root            S             10A   Varying                                                   
  130.                                                                                                      
  131.      D custAcctNum     S               O   Class(*JAVA : 'java.lang.String')                         
  132.      D acctCodeLength  S             10I 0                                                           
  133.      D acctCodes       S             20I 0 Dim(132000)                                               
  134.      D acctCodeNames   S               O   Class(*JAVA : 'java.lang.String')                         
  135.      D                                     Dim(132000)                                               
  136.      D acctCodeDepts   S               O   Class(*JAVA : 'java.lang.String')                         
  137.      D                                     Dim(132000)                                               
  138.      D acctCodeRegions...                                                                            
  139.      D                 S               O   Class(*JAVA : 'java.lang.String')                         
  140.      D                                     Dim(132000)                                               
  141.      D response        S               N                                                             
  142.      D interface       S               O   Class(*JAVA :                                             
  143.      D                                           'com.paetec.oss.accm.+                              
  144.      D                                            AcctCodeChangesInterface')                         
  145.                                                                                                      
  146.      D url             S               O   Class(*JAVA : 'java.lang.String')                         
  147.                                                                                                      
  148.      /*--------------------------------------------------------------------------------------------- 
  149.      /*   Constant Specifications                                                                    
  150.      /*--------------------------------------------------------------------------------------------- 
  151.                                                                                                      
  152.                                                                                                      
  153.      /*============================================================================================= 
  154.      /*   Program *Entry                                                                             
  155.      /*============================================================================================= 
  156.                                                                                                      
  157.      D testaccc2...                                                                                  
  158.      D                 PI                                                                            
  159.                                                                                                      
  160.      /*============================================================================================= 
  161.      /* MainLine                                                                                     
  162.      /*============================================================================================= 
  163.                                                                                                      
  164.       /Free                                                                                          
  165.                                                                                                      
  166.        ExSr initialize;                                                                              
  167.                                                                                                      
  168.        custAcctNum = constructJString('4362642');                                                    
  169.                                                                                                      
  170.        acctCodeLength = 11;                                                                          
  171.                                                                                                      
  172.        //load the arrays.                                                                            
  173.        For x = 1 to 3;                                                                               
  174.           acctCodes(x) = x;                                                                          
  175.                                                                                                      
  176.           acctCodeNames(x) = constructJString('Tim ' + %Char(x));                                    
  177.                                                                                                      
  178.           acctCodeDepts(x) = constructJString('1');                                                  
  179.                                                                                                      
  180.           acctCodeRegions(x) = constructJString('1');                                                
  181.        EndFor;                                                                                       
  182.                                                                                                      
  183.        url = ConstructJString('http://uxra120.paetec.com:+                                           
  184.                                6230/WebService/AcctCodeChangesService.wsdl');                        
  185.                                                                                                      
  186.        interface = bindInterface(url);                                                               
  187.                                                                                                      
  188.        response = setAcctCodesInRevChain(interface :                                                 
  189.                                          custAcctNum :                                               
  190.                                          acctCodeLength :                                            
  191.                                          acctCodes :                                                 
  192.                                          acctCodeNames :                                             
  193.                                          acctCodeDepts :                                             
  194.                                          acctCodeRegions);                                           
  195.                                                                                                      
  196.                                                                                                      
  197.        freeLocalJReference(custAcctNum);                                                             
  198.                                                                                                      
  199.        For x = 1 to 3;                                                                               
  200.                                                                                                      
  201.           freeLocalJReference(acctCodeNames(x));                                                     
  202.                                                                                                      
  203.           freeLocalJReference(acctCodeDepts(x));                                                     
  204.                                                                                                      
  205.           freeLocalJReference(acctCodeRegions(x));                                                   
  206.        EndFor;                                                                                       
  207.                                                                                                      
  208.        freeLocalJReference(interface);                                                               
  209.        freeLocalJReference(url);                                                                     
  210.                                                                                                      
  211.        ExSr ExitProcedure;                                                                           
  212.                                                                                                      
  213.                                                                                                      
  214.        //=========================================================================================== 
  215.        //   Initialize Directory Root                                                                
  216.        //=========================================================================================== 
  217.                                                                                                      
  218.        BegSr initializeRoot;                                                                         
  219.                                                                                                      
  220.           If Not %Open(UTPMODE);                                                                     
  221.              Open UTPMODE;                                                                           
  222.           EndIf;                                                                                     
  223.                                                                                                      
  224.           Read UTPMODE;                                                                              
  225.                                                                                                      
  226.           Close UTPMODE;                                                                             
  227.                                                                                                      
  228.           Select;                                                                                    
  229.                                                                                                      
  230.           When BLMODE = 'PRD';                                                                       
  231.              applicationDir += 'PRD/RevChainAccountCodes/';                                          
  232.              root = '/Prod';                                                                         
  233.                                                                                                      
  234.           When BLMODE = 'TRN';                                                                       
  235.              applicationDir += 'TRN/RevChainAccountCodes/';                                          
  236.              root = '/TRN';                                                                          
  237.                                                                                                      
  238.           When BLMODE = 'TQA';                                                                       
  239.              applicationDir += 'TQA/RevChainAccountCodes/';                                          
  240.              root = '/TQA';                                                                          
  241.                                                                                                      
  242.           When BLMODE = 'DEV';                                                                       
  243.              applicationDir += 'TST/RevChainAccountCodes/';                                          
  244.              root = '/Test';                                                                         
  245.                                                                                                      
  246.           EndSl;                                                                                     
  247.                                                                                                      
  248.        EndSr;                                                                                        
  249.        //=========================================================================================== 
  250.        // Initilizing Subroutine                                                                     
  251.        //=========================================================================================== 
  252.                                                                                                      
  253.        BegSr initialize;                                                                             
  254.                                                                                                      
  255.           If Not globalInit;                                                                         
  256.              globalInit = *ON;                                                                       
  257.              sndPm_Data_Length = 500;                                                                
  258.              usec_Data_Length = 500;                                                                 
  259.                                                                                                      
  260.              /Include QRpgCbSrc,ZQUsec                                                               
  261.              /Include QRpgCbSrc,ZQMhSndPm                                                            
  262.              /Include QRpgCbSrc,ZUserCh                                                              
  263.                                                                                                      
  264.              ExSr initializeRoot;                                                                    
  265.           EndIf;                                                                                     
  266.                                                                                                      
  267.           If setJmp(jumpPoint) = 1;                                                                  
  268.              ExSr exitProcedure;                                                                     
  269.              Return;                                                                                 
  270.           EndIf;                                                                                     
  271.                                                                                                      
  272.           sndPM_Msg_Type = '*ESCAPE';                                                                
  273.                                                                                                      
  274.           userCHConditionHandler = %PAddr('USERCONDITIONHANDLER001');                                
  275.           registerConditionHandler(userCHConditionHandler : userCHBase : *OMIT);                     
  276.                                                                                                      
  277.           userCH.errorBase = usec_Base;                                                              
  278.                                                                                                      
  279.           // Change Current Directory to Application Directory                                       
  280.           If chdir(applicationDir) < 0;                                                              
  281.              errNoTrap(errNo() : 'chdir(' + applicationDir + ')');                                   
  282.           EndIf;                                                                                     
  283.                                                                                                      
  284.           // Start JVM                                                                               
  285.           ClassPaths.Path(1) = applicationDir;                                                       
  286.           ClassPaths.Path(2) = applicationDir + 'GLUE-ALL.jar';                                      
  287.           ClassPaths.Path(3) = applicationDir + 'WebService.jar';                                    
  288.                                                                                                      
  289.           ClassPaths.Count = 3;                                                                      
  290.                                                                                                      
  291.           //properties.Property(1) = 'app=BridgeXmlClient';                                          
  292.           //properties.Property(2) = 'runtime.properties.impl=com.paetec.+                           
  293.           //                          properties.FileRuntimePropertiesImpl';                         
  294.           //properties.Property(3) = 'runtime.properties.file.path=+                                 
  295.           //                          config/runtime.properties';                                    
  296.                                                                                                      
  297.           properties.Count = 0;                                                                      
  298.                                                                                                      
  299.           startJVM(JVMVersion6_64 :                                                                  
  300.                    ClassPaths :                                                                      
  301.                    properties :                                                                      
  302.                    applicationDir +                                                                  
  303.                      'Logs/stdout-' + %Char(%Timestamp()) + '.txt' :                                 
  304.                    applicationDir +                                                                  
  305.                     'Logs/stderr-' + %Char(%Timestamp()) + '.txt' :                                  
  306.                    *ON);                                                                             
  307.                                                                                                      
  308.        EndSr;                                                                                        
  309.                                                                                                      
  310.        //=========================================================================================== 
  311.        //   Exit Procedure                                                                           
  312.        //=========================================================================================== 
  313.                                                                                                      
  314.        BegSr ExitProcedure;                                                                          
  315.                                                                                                      
  316.           unRegisterConditionHandler(userCHConditionHandler : *OMIT);                                
  317.                                                                                                      
  318.           *INLR = *ON;                                                                               
  319.           Return;                                                                                    
  320.                                                                                                      
  321.        EndSr;                                                                                        
  322.                                                                                                      
  323.       /End-Free                                                                                      
  324.                                                                                                      
  325.      /*============================================================================================= 
  326.  
© 2004-2019 by midrange.com generated in 0.038s valid xhtml & css