Add a specified time to variable and delay current job until that time

Use this program to add a specified time to variable and delay the current job until that time.

This Content Component encountered an error

Use this program to add a specified time to variable and delay the current job until that time.




ADDTME:     CMD        PROMPT('Add Time')                              
              PARM       KWD(HOURS) TYPE(*DEC) LEN(2) DFT(0) RANGE(0 +  
                           23) MIN(0) PROMPT('Nbr of hrs to add  (2 0)')
              PARM       KWD(MINUTES) TYPE(*DEC) LEN(2) RTNVAL(*NO) +   
                           DFT(0) RANGE(0 59) MIN(0) PROMPT('Nbr of +   
                           mins to add (2 0)')                          
              PARM       KWD(TODVAR) TYPE(*CHAR) LEN(6) RTNVAL(*YES) +  
                          MIN(1) PROMPT('New date variable  (6)')       
              PARM       KWD(TOTVAR) TYPE(*CHAR) LEN(6) RTNVAL(*YES) +  
                           MIN(1) PROMPT('New time variable  (6)')      

*************** Beginning of data ***************************
 ADDTME:     PGM        PARM(&HOURS &MINUTES &TODVAR &TOTVAR)
                                                             
             DCL        VAR(&MINUTES)   TYPE(*DEC)  LEN(2 0) 
             DCL        VAR(&HOURS)     TYPE(*DEC)  LEN(2 0) 
             DCL        VAR(&DATE)      TYPE(*CHAR) LEN(6)   
             DCL        VAR(&TODVAR)    TYPE(*CHAR) LEN(6)   
             DCL        VAR(&TOTVAR)    TYPE(*CHAR) LEN(6)   
             DCL        VAR(&TIME )     TYPE(*DEC)  LEN(6 0) 
             DCL        VAR(&HH   )     TYPE(*DEC)  LEN(2 0) 
             DCL        VAR(&MM   )     TYPE(*DEC)  LEN(2 0) 
             DCL        VAR(&SS   )     TYPE(*DEC)  LEN(2 0) 
             DCL        VAR(&AHH  )     TYPE(*CHAR) LEN(2)   
             DCL        VAR(&AMM  )     TYPE(*CHAR) LEN(2)   
             DCL        VAR(&ASS  )     TYPE(*CHAR) LEN(2)
                                                
    RTVSYSVAL   SYSVAL(QDATE  ) RTNVAR(&DATE)   
    RTVSYSVAL   SYSVAL(QHOUR  ) RTNVAR(&AHH)    
    RTVSYSVAL   SYSVAL(QMINUTE) RTNVAR(&AMM)    
    RTVSYSVAL   SYSVAL(QSECOND) RTNVAR(&ASS)    
                                                
    CHGVAR      VAR(&HH) VALUE(&AHH)            
    CHGVAR      VAR(&MM) VALUE(&AMM)            
    CHGVAR      VAR(&SS) VALUE(&ASS)            
                                                
    CHGVAR      VAR(&MM) VALUE(&MM + &MINUTES)

  IF COND(&MM *GE 60) THEN(DO)               
    CHGVAR      VAR(&MM) VALUE(&MM - 60)     
    CHGVAR      VAR(&HH) VALUE(&HH + 1)      
  ENDDO 

CHGVAR      VAR(&HH) VALUE(&HH + &HOURS) 
  

                                                                        
             IF COND(&HH *GE 24) THEN(DO)                               
               CHGVAR     VAR(&HH) VALUE(&HH - 24)                      
               ADDDAT     DAYS(1) TOVAR(&DATE)                          
             ENDDO                                                      
                                                                        
             CHGVAR     VAR(&TIME) VALUE(&HH * 10000 + &MM * 100 + +    
                           &SS)                                         
             CHGVAR     VAR(&TOTVAR) VALUE(&TIME)                       
             CHGVAR     VAR(&TODVAR) VALUE(&DATE)                       
                                                                        
 END:        ENDPGM                                                                       

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was first published in April 2004

Dig deeper on iSeries ILE programming

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close