ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Expansion on the check if job interactive or batch.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Expansion on the check if job interactive or batch.

    This example created a set of values to be passed as a parmameter.

    the program when interactive builds the parm string.
    Once build it submits itself ..........
    then in batch it used the built string to process ???

    PHP Code:
    ~

          *
          *  
    entry plist
          
    *
         
    d BATCH           pr
         d  Items                       350a   Options
    ( *VarSize )

         
    d BATCH           pi
         d  Items                       350a   Options
    ( *VarSize )

          *
          * 
    Variable Definition
          
    *
         
    d CmdLength       s             15  5 inz(0)
         
    d CmdString       s           5000    inz(*blanks)
         
    d count           s              4  0
         d Format          s              8
         d KeySize         s              7
         d LenStr          s              4  0
         d P
    #              s              3  0
         
    d Q               s              1    inz('''')
         
    d RcvVarLen       s             10i 0
         d selected        s              4  0
          
    *
          * 
    Program Info
          
    *
         
    d                SDS
         d  
    @PGM                 001    010
         d  
    @PARMS               037    039  0
         d  
    @MSGDTA               91    170
         d  
    @MSGID               171    174
         d  
    @JOB                 244    253
         d  
    @USER                254    263
         d  
    @JOB#                264    269  0

         
    d dsJobDta        ds
         d  dsJobBytesRtn                10I 0
         d  dsJobBytesAvl                10I 0
         d  dsJobName                    10A
         d  dsJobUser                    10A
         d  dsJobNumber                   6A
         d  dsJobIntern                  16A
         d  dsJobStatus                  10A
         d  dsJobType                     1A
         d  dsJobSubtype                  1A
         d  dsJobReserv1                  2A
         d  dsJobRunPty                  10I 0
         d  dsJobTimeSlc                 10I 0
         d  dsJobDftWait                 10I 0
         d  dsJobPurge                   10A

         d  parm           ds           350    qualified
         d  fullstring                    7    dim
    (50)
         
    d  material                      3    overlay(fullstring:1)
         
    d  analysis                      4    overlay(fullstring:4)

          
    //
          //  external calls
          //

         
    d $command        pr                  extpgm('QCMDEXC')
         
    d   command                   5000    options(*varsize)
         
    d   Length                      15  5

         d $jobinfo        pr                  extpgm
    ('QUSRJOBI')
         
    d   DsJob                             like(DsJobDta)
         
    d   Length                      10i 0 const
         
    d   APIFormat                    8    const
         
    d   ApiJob                      26    const
         
    d   InternJob                   16    const


          /
    Free

            
    //--------------------------------------------------------
            // MAIN PROGRAM
            //--------------------------------------------------------

                
    exsr  Hskpg;
                  if 
    DSJOBTYPE 'I';



                     
    clear count;
                     
    clear parm;
                     
    clear p#;

                       
    for count 1 to 5;
                         
    P# +=1;
                           
    select;
                             
    when count 1.;
                               
    parm.fullstring(P#) = 'abc' + 'xyxr';
                             
    when count 2.;
                               
    parm.fullstring(P#) = '1MA' + 'XD$%';
                             
    when count 3.;
                               
    parm.fullstring(P#) = '333' + '1ANA';
                             
    when count 4.;
                               
    parm.fullstring(P#) = 'qwe' + 'RT66';
                             
    when count 5.;
                               
    parm.fullstring(P#) = 'PPP' + 'AxED';
                           
    endsl;
                       endfor;



                  
    // submit thyself to batch


                       
    cmdstring 'sbmjob cmd(call pgm(' + %trim(@PGM) +
                                   
    ') PARM(' ++ %trim(parm) + +
                                   
    '))  JOB(' +
                                   %
    trim(@PGM) +  ') JOBQ(QINTER)';

                       
    cmdlength = %len(%trim(cmdstring));
                       
    $command (cmdstring:cmdlength);

                  else;
                  endif;


                 *
    inlr = *on;


            
    //--------------------------------------------------------
            // Hskpg - one time run subroutine
            //--------------------------------------------------------

                 
    begsr Hskpg;




                  
    // determine if this job is interactive or batch

                       
    RcvVarLen = %Size(DsJobDta);
                       
    Format 'JOBI0100';

                      
    $jobinfo(dsjobdta rcvvarlen Format '*' ' ');

                         if 
    DSJOBTYPE 'I';
                         else;
                           
    // do batch stuff
                           
    parm Items;
                         endif;



                 
    endsr;
          /
    End-Free 
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com
Working...
X