midrange.com code scratchpad
Name:
Build code
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
09/10/2014 07:33:08 pm
IP:
Logged
Description:
Main build code with added routine to determine ACMS data items
Code:
  1.       * BUILDRG -- Utility to build programs by searching for compile statements                    
  2.       *            in the source code.                                                              
  3.       *                                               SCK 11/05/2007                                
  4.       *       Matt Tyler : 09/10/2014  added code to handle look up of data items for CMS create command
  5.       *                                                                                             
  6.       * To compile this utility:                                                                    
  7.       *                                                                                             
  8.       *> CRTSQLRPGI OBJ(&L/BUILDRG) SRCFILE(&L/&F) DBGVIEW(&DV) OPTION(&EV)                         
  9.       *                                                                                             
  10.       *> CRTCMD CMD(&L/BUILD) PGM(*LIBL/BUILDRG) -                                                  
  11.       *>        MODE(*ALL) ALLOW(*ALL) -                                                            
  12.       *>        HLPPNLGRP(BUILDPG) HLPID(BUILD) -                                                   
  13.       *>        TEXT(&X)                                                                            
  14.       *                                                                                             
  15.       *       BUILDRG allows the following values to be substituted into                            
  16.       *            the command string:                                                              
  17.       *                                                                                             
  18.       *             &O      = Object library                                                        
  19.       *             &ON     = Object name                                                           
  20.       *             &F      = Source File                                                           
  21.       *             &L      = Source Library                                                        
  22.       *             &N      = Member name                                                           
  23.       *             &DV     = Debug View (ILE)                                                      
  24.       *             &OV     = Debug View (OPM)                                                      
  25.       *             &EV     = *EVENTF or *NOEVENTF                                                  
  26.       *             &R      = Replace *YES/*NO                                                      
  27.       *             &X      = Source member text (single quotes added)                              
  28.       *             &CMSIDLIB  = *IDLIB reference                                                   
  29.       *             &CMSOBJ    = Object name in 10 character form                                   
  30.       *             &CMSTYPE   = Object Type as reference by SRC mbr Type                           
  31.       *             &CMSFILE   = Source File                                                        
  32.       *             &CMSENV    = Compile Environment Type                                           
  33.       *             &CMSENVLIB = Compile Environment Lib                                            
  34.       *                                                                                             
  35.       *                                                                                             
  36.       /if defined(*CRTBNDRPG)                                                                       
  37.      H DFTACTGRP(*NO) ACTGRP(*CALLER)                                                               
  38.       /endif                                                                                        
  39.      H BNDDIR('QC2LE') OPTION(*SRCSTMT:*NODEBUGIO)                                                  
  40.                                                                                                     
  41.      FSOURCE    IF   F  256        DISK    EXTFILE(SrcFile)                                         
  42.      F                                     EXTMBR(SrcMbr)                                           
  43.      F                                     INFDS(SrcAttr)                                           
  44.      F                                     USROPN                                                   
  45.                                                                                                     
  46.      D BUILDRG         PR                                                                           
  47.      D   peObj                       20a   const                                                    
  48.      D   peSrcFile                   20a   const                                                    
  49.      D   peMbr                       10a   const                                                    
  50.      D   peDbgView                    7a   const                                                    
  51.      D   peReplace                    4a   const                                                    
  52.      D   peAllowF9                    4a   const                                                    
  53.      D   peOption                    10a   const                                                    
  54.      D   peUsecmscmd                  1a   const                                                    
  55.      D   peListings                   1a   const                                                    
  56.       ** This is equivalent to *ENTRY PLIST:                                                        
  57.      D BUILDRG         PI                                                                           
  58.      D   peObj                       20a   const                                                    
  59.      D   peSrcFile                   20a   const                                                    
  60.      D   peMbr                       10a   const                                                    
  61.      D   peDbgView                    7a   const                                                    
  62.      D   peReplace                    4a   const                                                    
  63.      D   peAllowF9                    4a   const                                                    
  64.      D   peOption                    10a   const                                                    
  65.      D   peUsecmscmd                  1a   const                                                    
  66.      D   peListings                   1a   const                                                    
  67.                                                                                                     
  68.      D QMHSNDPM        PR                  ExtPgm('QMHSNDPM')                                       
  69.      D   msgid                        7a   const                                                    
  70.      D   msgf                        20a   const                                                    
  71.      D   msgdta                   32702a   const options(*varsize)                                  
  72.      D   dtalen                      10i 0 const                                                    
  73.      D   msgtype                     10a   const                                                    
  74.      D   callstack                   10a   const                                                    
  75.      D   stackcount                  10i 0 const                                                    
  76.      D   msgkey                       4a                                                            
  77.      D   errorcode                    8a   const                                                    
  78.                                                                                                     
  79.      D QMHRSNEM        PR                  ExtPgm('QMHRSNEM')                                       
  80.      D   MsgKey                       4A   const                                                    
  81.      D   ErrorCode                    8A   const                                                    
  82.      D   ToStack                     10a   const                                                    
  83.      D   ToStackLen                  10i 0 const                                                    
  84.      D   ToStackFmt                   8a   const                                                    
  85.      D   FromStack                     *   const                                                    
  86.      D   FromStackCtr                10i 0 const                                                    
  87.                                                                                                     
  88.      D RSNM0100        ds                  qualified                                                
  89.      D   Count                       10i 0 inz(1)                                                   
  90.      D   modqual                     10a   inz('*NONE')                                             
  91.      D   pgmqual                     10a   inz('*NONE')                                             
  92.      D   len                         10i 0 inz(10)                                                  
  93.      D   ident                       10a   inz('*PGMBDY')                                           
  94.                                                                                                     
  95.      D QMHMOVPM        PR                  ExtPgm('QMHMOVPM')                                       
  96.      D   MsgKey                       4A   const                                                    
  97.      D   MsgTypes                    40A   const                                                    
  98.      D   NumMsgTypes                 10I 0 const                                                    
  99.      D   ToStack                     10A   const                                                    
  100.      D   ToStackCnt                  10I 0 const                                                    
  101.      D   ErrorCode                    8A   const                                                    
  102.                                                                                                     
  103.      D loadcmds        pr            10i 0                                                          
  104.      D   cmd                      32702a   varying dim(MAX_CMD)                                     
  105.      D dosubs          pr            10i 0                                                          
  106.      D   cmd                      32702a   varying                                                  
  107.      D runcmds         pr             1n                                                            
  108.      D   cmd                      32702a   varying dim(MAX_CMD)                                     
  109.      D   count                       10i 0 const                                                    
  110.      D getSrcMbr       PR             1n                                                            
  111.      D   SrcFile                     21a   const                                                    
  112.      D   SrcMbr                      10a   const                                                    
  113.      D   Text                        52a   varying options(*omit)                                   
  114.      D   Type                        10a   options(*omit)                                           
  115.      D   RtnLib                      10a   options(*omit)                                           
  116.      D replace         PR                                                                           
  117.      D   cmd                      32702a   varying                                                  
  118.      D   old                         10a   varying const                                            
  119.      D   new                         52a   varying const                                            
  120.      D defaultcmds     pr            10i 0                                                          
  121.      D   cmd                      32702a   varying dim(MAX_CMD)                                     
  122.      D   usecmscmd                     n                                                            
  123.      D liblist         pr            10i 0                                                          
  124.      D   Libl                        10a   dim(250)                                                 
  125.                                                                                                     
  126.      D Cms             Ds                  Qualified                                                
  127.      D  Idlib                        10A                                                            
  128.      D  Obj                          10A                                                            
  129.      D  Type                         10A                                                            
  130.      D  File                         10A                                                            
  131.      D  Env                           3A                                                            
  132.      D  Envlib                       10A                                                            
  133.      D  Grp                          10A                                                            
  134.      D  Prd                          10A                                                            
  135.      D  Rls                          10A                                                            
  136.                                                                                                     
  137.                                                                                                     
  138.      D lda            uds                  qualified dtaara(*LDA)                                   
  139.      D Lib                           10A                                                            
  140.      D Mbr                           10A                                                            
  141.                                                                                                     
  142.      D SrcAttr         ds                  qualified                                                
  143.      D   RecLen                       5I 0 overlay(SrcAttr:125)                                     
  144.      D MAX_CMD         c                   const(100)                                               
  145.                                                                                                     
  146.      D SrcLib          s             10a                                                            
  147.      D SrcObj          s             10a                                                            
  148.      D SrcFile         s             21a                                                            
  149.      D SrcMbr          s             10a                                                            
  150.      D SrcType         s             10a                                                            
  151.      D objname         s             10a                                                            
  152.      D objlib          s             10a                                                            
  153.                                                                                                     
  154.      D count           s             10i 0                                                          
  155.      D cmd             s          32702a   varying dim(MAX_CMD)                                     
  156.      D x               s             10i 0                                                          
  157.      D SrcText         s             52a   varying                                                  
  158.      D msgkey          s              4a                                                            
  159.      D msg             s            132a   varying                                                  
  160.      D usecmscmd       S               n                                                            
  161.                                                                                                     
  162.                                                                                                     
  163.       /free                                                                                         
  164.                                                                                                     
  165.                                                                                                     
  166.        exec sql                                                                                     
  167.          set option datfmt = *iso                                                                   
  168.                     ,alwcpydta = *yes                                                               
  169.                     ,closqlcsr = *endmod                                                            
  170.                     ,DLYPRP = *yes                                                                  
  171.                     ,commit = *none;                                                                
  172.                                                                                                     
  173.           SrcLib  = %subst(peSrcFile:11:10);                                                        
  174.           SrcObj  = %subst(peSrcFile:1:10);                                                         
  175.           SrcFile = %trim(SrcLib) + '/' + %trim(SrcObj);                                            
  176.           objlib  = %subst(peObj:11:10);                                                            
  177.           objname = %subst(peObj:1:10);                                                             
  178.           lda.lib = objlib;                                                                         
  179.           lda.mbr = objname;                                                                        
  180.                                                                                                     
  181.           if (peMbr = '*OBJ');                                                                      
  182.              SrcMbr = ObjName;                                                                      
  183.           else;                                                                                     
  184.              SrcMbr = peMbr;                                                                        
  185.           endif;                                                                                    
  186.                                                                                                     
  187.           getSrcMbr( SrcFile: SrcMbr: SrcText: SrcType: SrcLib);                                    
  188.           SrcFile = %trim(SrcLib) + '/' + %trim(SrcObj);                                            
  189.                                                                                                     
  190.                                                                                                     
  191.           if peUsecmscmd = '0';                                                                     
  192.             count = loadcmds(cmd);                                                                  
  193.           else;                                                                                     
  194.             count = 0;                                                                              
  195.           endif;                                                                                    
  196.           if (count = 0);                                                                           
  197.               msg = 'No compile instructions found. +                                               
  198.                      Default command used.';                                                        
  199.               if peUsecmscmd = '0';                                                                 
  200.                  QMHSNDPM( 'CPF9897'                                                                
  201.                          : 'QCPFMSG   *LIBL'                                                        
  202.                          : msg                                                                      
  203.                          : %len(msg)                                                                
  204.                          : '*COMP'                                                                  
  205.                          : '*PGMBDY'                                                                
  206.                          : 1                                                                        
  207.                          : msgkey                                                                   
  208.                          : *ALLx'00' );                                                             
  209.               endif;                                                                                
  210.               usecmscmd = lookupincms( objlib :objname :SrcType );                                  
  211.               count = defaultcmds( cmd :Usecmscmd );                                                
  212.           endif;                                                                                    
  213.                                                                                                     
  214.           for x = 1 to count;                                                                       
  215.              dosubs(cmd(x));                                                                        
  216.           endfor;                                                                                   
  217.                                                                                                     
  218.           if runcmds(cmd:count);                                                                    
  219.               msg = 'Commands in source code executed successfully.';                               
  220.               QMHSNDPM( 'CPF9897'                                                                   
  221.                       : 'QCPFMSG   *LIBL'                                                           
  222.                       : msg                                                                         
  223.                       : %len(msg)                                                                   
  224.                       : '*COMP'                                                                     
  225.                       : '*PGMBDY'                                                                   
  226.                       : 1                                                                           
  227.                       : msgkey                                                                      
  228.                       : *ALLx'00' );                                                                
  229.           endif;                                                                                    
  230.                                                                                                     
  231.           *inlr = *on;                                                                              
  232.           return;                                                                                   
  233.       /end-free                                                                                     
  234.                                                                                                     
  235.                                                                                                     
  236.       *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                   
  237.       * Load all of the build commands from the source member                                       
  238.       * into an array of commands.                                                                  
  239.       *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                   
  240.      P loadcmds        B                                                                            
  241.      D loadcmds        pi            10i 0                                                          
  242.      D   cmd                      32702a   varying dim(MAX_CMD)                                     
  243.                                                                                                     
  244.      D QMHRCVPM        PR                  ExtPgm('QMHRCVPM')                                       
  245.      D   rcvvar                   32767A   options(*varsize)                                        
  246.      D   rcvvarlen                   10i 0 const                                                    
  247.      D   format                       8a   const                                                    
  248.      D   stack                       10a   const                                                    
  249.      D   stackctr                    10i 0 const                                                    
  250.      D   type                        10a   const                                                    
  251.      D   msgkey                       4a   const                                                    
  252.      D   wait                        10i 0 const                                                    
  253.      D   action                      10a   const                                                    
  254.      D   errorcode                    8a   const                                                    
  255.                                                                                                     
  256.      D RCVM0100        ds                  qualified                                                
  257.      D   msgid                        7a   overlay(RCVM0100:13)                                     
  258.      D   msgkey                       4a   overlay(RCVM0100:22)                                     
  259.      D   msgdtalen                   10i 0 overlay(RCVM0100:45)                                     
  260.      D   msgdta                    8000a   overlay(RCVM0100:49)                                     
  261.                                                                                                     
  262.      D LINE            ds           256    qualified                                                
  263.      D   seq                          6a                                                            
  264.      D   date                         6a                                                            
  265.      D   data                       240a                                                            
  266.                                                                                                     
  267.      D id1             ds                                                                           
  268.      D                                1a   inz('*')                                                 
  269.      D                                1a   inz('>')                                                 
  270.      D id2             ds                                                                           
  271.      D                                1a   inz('<')                                                 
  272.      D                                1a   inz('*')                                                 
  273.      D pos             s             10i 0                                                          
  274.      D sublen          s             10i 0                                                          
  275.      D x               s             10i 0                                                          
  276.      D temp            s            240a   varying                                                  
  277.      D len             s             10i 0                                                          
  278.                                                                                                     
  279.       /free                                                                                         
  280.                                                                                                     
  281.           open SOURCE;                                                                              
  282.                                                                                                     
  283.           // Remove the "Buffer length longer than record"                                          
  284.           // message from the job log.                                                              
  285.                                                                                                     
  286.           QMHRCVPM( RCVM0100: %size(RCVM0100): 'RCVM0100'                                           
  287.                   : '*': 0: '*DIAG': *blanks                                                        
  288.                   : 0: '*REMOVE': x'00000008');                                                     
  289.                                                                                                     
  290.           // Scan through source for any commands to                                                
  291.           // build program with.                                                                    
  292.                                                                                                     
  293.           setll *start SOURCE;                                                                      
  294.           read SOURCE LINE;                                                                         
  295.                                                                                                     
  296.           dow not %eof(SOURCE);                                                                     
  297.                                                                                                     
  298.              // look for start identifier                                                           
  299.                                                                                                     
  300.              pos = %scan(id1:%subst(Line.data:1:SrcAttr.RecLen));                                   
  301.              if (pos>0);                                                                            
  302.                                                                                                     
  303.                   // extract everything after start id                                              
  304.                                                                                                     
  305.                   pos += %len(id1);                                                                 
  306.                   sublen = SrcAttr.reclen                                                           
  307.                          - %size(LINE.Seq)                                                          
  308.                          - %size(LINE.Date)                                                         
  309.                          - pos                                                                      
  310.                          + 1;                                                                       
  311.                   temp = %trim(%subst(line.data:pos:sublen));                                       
  312.                                                                                                     
  313.                   // if there's also an end id, strip if off.                                       
  314.                                                                                                     
  315.                   pos =%scan(id2: temp);                                                            
  316.                   if (pos>1);                                                                       
  317.                      temp = %trimr(%subst(temp:1:pos-1));                                           
  318.                   endif;                                                                            
  319.                                                                                                     
  320.                   // If line is not blank, add to the list of commands,                             
  321.                   // or to the end of the last command...                                           
  322.                                                                                                     
  323.                   if (%len(temp)>0 and temp<>*blanks);                                              
  324.                                                                                                     
  325.                       if (x>0 and %subst(cmd(x):%len(cmd(x)):1) = '-');                             
  326.                          len = %len(cmd(x)) - 1;                                                    
  327.                          %len(cmd(x)) = len;                                                        
  328.                          if (%subst(cmd(x):len:1) = ' ');                                           
  329.                             cmd(x) = %trimr(cmd(x)) + ' ' + temp;                                   
  330.                          else;                                                                      
  331.                             cmd(x) = cmd(x) + temp;                                                 
  332.                          endif;                                                                     
  333.                       else;                                                                         
  334.                          x = x + 1;                                                                 
  335.                          cmd(x) = temp;                                                             
  336.                       endif;                                                                        
  337.                                                                                                     
  338.                   endif;                                                                            
  339.              endif;                                                                                 
  340.                                                                                                     
  341.              read SOURCE LINE;                                                                      
  342.           enddo;                                                                                    
  343.                                                                                                     
  344.           close SOURCE;                                                                             
  345.           return x;                                                                                 
  346.       /end-free                                                                                     
  347.      P                 E                                                                            
  348.                                                                                                     
  349.                                                                                                     
  350.       *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                   
  351.       * dosubs(): This makes any necessary substitutions in the                                     
  352.       *           command that's to be run.                                                         
  353.       *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                   
  354.      P dosubs          B                                                                            
  355.      D dosubs          pi            10i 0                                                          
  356.      D   cmd                      32702a   varying                                                  
  357.                                                                                                     
  358.      D cmdname         s             10a                                                            
  359.      D temp            s                   like(cmd)                                                
  360.      D DbgView         s                   like(peDbgView)                                          
  361.      D OpmView         s                   like(peDbgView)                                          
  362.      D pos             s             10i 0                                                          
  363.       /free                                                                                         
  364.                                                                                                     
  365.         temp =  %xlate( 'abcdefghijklmnopqrstuvwxyz'                                                
  366.                       : 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'                                                
  367.                       : cmd );                                                                      
  368.                                                                                                     
  369.         pos = %scan(' ':temp);                                                                      
  370.         if (pos > 1);                                                                               
  371.            cmdname = %subst(temp:1:pos-1);                                                          
  372.         endif;                                                                                      
  373.                                                                                                     
  374.         //------------------------------------------------------------                              
  375.         // The embedded SQL precompiler only supports DBGVIEW(*SOURCE)                              
  376.         //  and DBGVIEW(*NONE) -- but it passes DBGVIEW(*ALL) to the                                
  377.         //  underlying HLL compiler.                                                                
  378.         //                                                                                          
  379.         // This works around this by switching the debug view to                                    
  380.         // *SOURCE when using the SQL precompiler.                                                  
  381.         //------------------------------------------------------------                              
  382.                                                                                                     
  383.         DbgView = peDbgView;                                                                        
  384.         if (%subst(cmdname:1:9) = 'CRTSQLRPG'                                                       
  385.              or %subst(cmdname:1:9) = 'CRTSQLCBL'                                                   
  386.              or %subst(cmdname:1:7) = 'CRTSQLC'                                                     
  387.              or cmdname = 'CRTSQLPLI');                                                             
  388.             if (DbgView='*STMT' or DbgView='*NONE');                                                
  389.                 DbgView='*NONE';                                                                    
  390.             else;                                                                                   
  391.                 DbgView='*SOURCE';                                                                  
  392.             endif;                                                                                  
  393.         endif;                                                                                      
  394.                                                                                                     
  395.                                                                                                     
  396.         //------------------------------------------------------------                              
  397.         // WDSC requires option(*EVENTF) in order to return info                                    
  398.         //  about why a compiler could not compile a program.                                       
  399.         //                                                                                          
  400.         // If *EVENTF is specified, but no OPTION() was found in                                    
  401.         // the commands listed in the source member, tack on the                                    
  402.         // OPTION(*EVENTF) parameter.                                                               
  403.         //------------------------------------------------------------                              
  404.                                                                                                     
  405.         if (peOption='*EVENTF');                                                                    
  406.             pos = %scan(' OPTION(': temp);                                                          
  407.             if (pos = 0);                                                                           
  408.                 if ( cmdname='CRTRPGMOD'                                                            
  409.                      or cmdname='CRTRPGPGM'                                                         
  410.                      or cmdname='CRTBNDRPG'                                                         
  411.                      or cmdname='CRTSQLRPGI'                                                        
  412.                      or cmdname='CRTCLMOD'                                                          
  413.                      or cmdname='CRTCLPGM'                                                          
  414.                      or cmdname='CRTBNDCL'                                                          
  415.                      or cmdname='CRTCBLMOD'                                                         
  416.                      or cmdname='CRTBNDCBL'                                                         
  417.                      or cmdname='CRTCPPMOD'                                                         
  418.                      or cmdname='CRTBNDCPP'                                                         
  419.                      or cmdname='CRTCMOD'                                                           
  420.                      or cmdname='CRTBNDC'                                                           
  421.                      or cmdname='CRTPF'                                                             
  422.                      or cmdname='CRTLF'                                                             
  423.                      or cmdname='CRTDSPF'                                                           
  424.                      or cmdname='CRTPRTF' );                                                        
  425.                    cmd += ' OPTION(*EVENTF)';                                                       
  426.                 endif;                                                                              
  427.             endif;                                                                                  
  428.         endif;                                                                                      
  429.                                                                                                     
  430.         //------------------------------------------------------------                              
  431.         //  OPM programs use OPTION(*SRCDBG) or OPTION(*LSTDBG)                                     
  432.         //      instead of DBGVIEW.                                                                 
  433.         //------------------------------------------------------------                              
  434.         select;                                                                                     
  435.         when DbgView = '*LIST' or DbgView='*ALL';                                                   
  436.           OpmView = '*LSTDBG';                                                                      
  437.         when DbgView = '*SOURCE';                                                                   
  438.           OpmView = '*SRCDBG';                                                                      
  439.         other;                                                                                      
  440.           OpmView = '*NOSRCDBG';                                                                    
  441.         endsl;                                                                                      
  442.                                                                                                     
  443.                                                                                                     
  444.         //------------------------------------------------------------                              
  445.         //  Replace the various variables in the commands with the                                  
  446.         //  proper values from this program.                                                        
  447.         //                                                                                          
  448.         //  Note: Longer variables should be replaced first, to                                     
  449.         //        avoid conflict.  For example, '&YYYY' contains                                    
  450.         //        the string '&YY', so if &YY was done first, the                                   
  451.         //        &YYYY would become 07YY and would never get the                                   
  452.         //        4-digit year.  So the longer ones must be done                                    
  453.         //        first.                                                                            
  454.         //------------------------------------------------------------                              
  455.                                                                                                     
  456.         replace(cmd: '&ON'    : %trim(objname)             );                                       
  457.         replace(cmd: '&DV'    : %trim(dbgview)             );                                       
  458.         replace(cmd: '&OV'    : %trim(OpmView)             );                                       
  459.         replace(cmd: '&EV'    : %trim(peOption)            );                                       
  460.         replace(cmd: '&O'     : %trim(objlib)              );                                       
  461.         replace(cmd: '&X'     : SrcText                    );                                       
  462.         replace(cmd: '&R'     : %trim(peReplace)           );                                       
  463.         replace(cmd: '&F'     : %trim(srcobj)              );                                       
  464.         replace(cmd: '&L'     : %trim(srclib)              );                                       
  465.         replace(cmd: '&N'     : %trim(srcmbr)              );                                       
  466.         replace(cmd: '&CMSIDLIB' : %trim(Cms.Idlib)            );                                   
  467.         replace(cmd: '&CMSOBJ'   : %trim(Cms.Obj)              );                                   
  468.         replace(cmd: '&CMSTYPE'  : %trim(Cms.Type)             );                                   
  469.         replace(cmd: '&CMSFILE'  : %trim(Cms.File)             );                                   
  470.         replace(cmd: '&CMSENVLIB': %trim(Cms.Envlib)           );                                   
  471.         replace(cmd: '&CMSENV'   : %trim(Cms.Env)              );                                   
  472.                                                                                                     
  473.         //------------------------------------------------------------                              
  474.         // Ask for a print or                                                                       
  475.         //------------------------------------------------------------                              
  476.                                                                                                     
  477.         if ( peListings = '1') and (%subst(cmdname:1:4) = 'ACMS');                                  
  478.              cmd += ' LISTING(*YES)';                                                               
  479.         elseif ( peListings = '0') and (%subst(cmdname:1:4) = 'ACMS');                              
  480.              cmd += ' LISTING(*NO)';                                                                
  481.         elseif ( peListings = '1') and  (cmdname = 'CRTSQLRPGI'                                     
  482.                                       or cmdname = 'CRTSQLCBLI'                                     
  483.                                       or cmdname = 'CRTSQLCI  '                                     
  484.                                       or %subst(cmdname:1:6) = 'CRTBND'                             
  485.                                       or cmdname = 'CRTSQLPLI');                                    
  486.              cmd += ' OUTPUT(*PRINT)';                                                              
  487.         elseif ( peListings = '0') and  (cmdname = 'CRTSQLRPGI'                                     
  488.                                       or cmdname = 'CRTSQLCBLI'                                     
  489.                                       or cmdname = 'CRTSQLCI  '                                     
  490.                                       or %subst(cmdname:1:6) = 'CRTBND'                             
  491.                                       or cmdname = 'CRTSQLPLI');                                    
  492.              cmd += ' OUTPUT(*NONE)';                                                               
  493.         endif;                                                                                      
  494.                                                                                                     
  495.         return 0;                                                                                   
  496.                                                                                                     
  497.         begsr *pssr;                                                                                
  498.             return -1;                                                                              
  499.         endsr;                                                                                      
  500.       /end-free                                                                                     
  501.      P                 E                                                                            
  502.                                                                                                     
  503.                                                                                                     
  504.                                                                                                     
  505.                                                                                                     
  506.       *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                   
  507.       * Get Infomration about the source member                                                     
  508.       *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                   
  509.      P getSrcMbr       B                                                                            
  510.      D getSrcMbr       PI             1n                                                            
  511.      D   SrcFile                     21a   const                                                    
  512.      D   SrcMbr                      10a   const                                                    
  513.      D   Text                        52a   varying options(*omit)                                   
  514.      D   Type                        10a   options(*omit)                                           
  515.      D   RtnLib                      10a   options(*omit)                                           
  516.                                                                                                     
  517.      D QUSRMBRD        PR                  EXTPGM('QUSRMBRD')                                       
  518.      D   RcvVar                   65535A   options(*varsize)                                        
  519.      D   RcvVarLen                   10i 0 const                                                    
  520.      D   Format                       8a   const                                                    
  521.      D   QualFile                    20a   const                                                    
  522.      D   MbrName                     10a   const                                                    
  523.      D   Override                     1a   const                                                    
  524.      D   ErrorCode                    8a                                                            
  525.                                                                                                     
  526.      D MBRD0100        ds           135    qualified                                                
  527.      D   Lib                         10a   overlay(MBRD0100:19)                                     
  528.      D   Type                        10a   overlay(MBRD0100:49)                                     
  529.      D   Text                        50a   overlay(MBRD0100:85)                                     
  530.                                                                                                     
  531.      D ErrCode         ds                  qualified                                                
  532.      D   Prov                        10i 0 inz(%size(ErrCode))                                      
  533.      D   Avail                       10i 0 inz(0)                                                   
  534.                                                                                                     
  535.      D pos             s             10i 0                                                          
  536.      D lib             s             10a                                                            
  537.      D obj             s             10a                                                            
  538.      D Quote           s              1a   inz('''') static                                         
  539.      D Libl            s             10a   dim(250)                                                 
  540.      D Found           s              1n   inz(*OFF)                                                
  541.       /free                                                                                         
  542.                                                                                                     
  543.          // Separate the library from the object name                                               
  544.                                                                                                     
  545.          pos = %scan('/': srcFile);                                                                 
  546.          if (pos>1 and pos<%len(srcFile));                                                          
  547.             lib = %subst(srcFile:1:pos-1);                                                          
  548.             obj = %subst(srcFile:pos+1);                                                            
  549.          else;                                                                                      
  550.             lib = '*LIBL';                                                                          
  551.             obj = %triml(srcFile);                                                                  
  552.          endif;                                                                                     
  553.                                                                                                     
  554.          // If the library name is '*LIBL' retrieve the                                             
  555.          // library list.                                                                           
  556.                                                                                                     
  557.          lib = %xlate('libl':'LIBL': lib);                                                          
  558.          if (lib = '*LIBL');                                                                        
  559.              count = liblist(libl);                                                                 
  560.          else;                                                                                      
  561.              count = 1;                                                                             
  562.              libl(1) = lib;                                                                         
  563.          endif;                                                                                     
  564.                                                                                                     
  565.                                                                                                     
  566.          // Search each library in the library list until the                                       
  567.          // member is found.                                                                        
  568.                                                                                                     
  569.          found = *OFF;                                                                              
  570.                                                                                                     
  571.          for x = 1 to count;                                                                        
  572.                                                                                                     
  573.             ErrCode.Avail = 0;                                                                      
  574.             QUSRMBRD( MBRD0100                                                                      
  575.                     : %size(MBRD0100)                                                               
  576.                     : 'MBRD0100'                                                                    
  577.                     : obj + libl(x)                                                                 
  578.                     : SrcMbr                                                                        
  579.                     : '0'                                                                           
  580.                     : ErrCode );                                                                    
  581.                                                                                                     
  582.             if (errCode.avail = 0);                                                                 
  583.                 found = *ON;                                                                        
  584.                 leave;                                                                              
  585.             endif;                                                                                  
  586.                                                                                                     
  587.          endfor;                                                                                    
  588.                                                                                                     
  589.          if (not found);                                                                            
  590.                                                                                                     
  591.             monitor;                                                                                
  592.                ErrCode.Prov = 0;                                                                    
  593.                QUSRMBRD( MBRD0100                                                                   
  594.                        : %size(MBRD0100)                                                            
  595.                        : 'MBRD0100'                                                                 
  596.                        : obj + '*LIBL'                                                              
  597.                        : SrcMbr                                                                     
  598.                        : '0'                                                                        
  599.                        : ErrCode );                                                                 
  600.                 found = *ON;                                                                        
  601.             on-error;                                                                               
  602.                 MBRD0100 = *blanks;                                                                 
  603.                 QMHMOVPM( *BLANKS                                                                   
  604.                         : '*COMP     *DIAG     *INFO'                                               
  605.                         : 3                                                                         
  606.                         : '*PGMBDY'                                                                 
  607.                         : 1                                                                         
  608.                         : x'00000000');                                                             
  609.                 QMHRSNEM( *BLANKS                                                                   
  610.                         : x'00000000'                                                               
  611.                         : RSNM0100                                                                  
  612.                         : %size(RSNM0100)                                                           
  613.                         : 'RSNM0100'                                                                
  614.                         : *NULL                                                                     
  615.                         : 0);                                                                       
  616.                 return *OFF;                                                                        
  617.             endmon;                                                                                 
  618.                                                                                                     
  619.          endif;                                                                                     
  620.                                                                                                     
  621.          if (%addr(text) <> *null);                                                                 
  622.              Text = Quote + %trimr(MBRD0100.Text) + Quote;                                          
  623.          endif;                                                                                     
  624.          if (%addr(Type) <> *null);                                                                 
  625.              Type = MBRD0100.Type;                                                                  
  626.          endif;                                                                                     
  627.          if (%addr(RtnLib) <> *null);                                                               
  628.              RtnLib = MBRD0100.Lib;                                                                 
  629.          endif;                                                                                     
  630.                                                                                                     
  631.          return found;                                                                              
  632.       /end-free                                                                                     
  633.      P                 E                                                                            
  634.                                                                                                     
  635.                                                                                                     
  636.       *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                   
  637.       * Replace(): replace old string with new string in cmd                                        
  638.       *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++                                   
  639.      P replace         B                                                                            
  640.      D replace         PI                                                                           
  641.      D   cmd                      32702a   varying                                                  
  642.      D   old                         10a   varying const                                            
  643.      D   new                         52a   vary
© 2004-2019 by midrange.com generated in 0.018s valid xhtml & css