Is there a command that can cause a delay in the execution of code ?
Announcement
Collapse
No announcement yet.
delay in RPG/LE
Collapse
X
-
Re: delay in RPG/LE
using dlyjob
Code:d waittime s 3 inz('900') d cmdstring s 256 d cmdlength s 15 5 c eval cmdstring = 'dlyjob ' + waittime c eval cmdlength = %len(%trim(cmdstring)) * * * do your program stuff here * c call(e) 'QCMDEXC' c parm cmdstring c parm cmdlength * c eval *inlr = *on
PHP Code:~
H Option( *SrcStmt: *NoDebugIo ) BndDir( 'QC2LE' )
*=======================================================================
* PROGRAM -
* PURPOSE -
* WRITTEN -
* AUTHOR -
*
* PROGRAM DESCRIPTION
* This program will send/receive all EDI documents delay a period of time
* then run again.
*
*
* INDICATOR USAGE
* n/a
*
*=======================================================================
*
* Field Definitions.
*
d Company s 2 inz('15')
d CmdLength s 15 5
d CmdString s 256
d Count s 4 0
d DelayMinutes s 4 0 inz(7200)
d Loop s 1 inz('Y')
d Message s 100A varying
d MsgKey s 4A
d MsgQ s 20A dim(1) inz('*SYSOPR')
d Network s 2
d PassCompany s 2
d Q s 1 inz('''')
d Ran852 s 1
d Reply s 100A
d SessionType s 1 inz('3')
d OutNetwork s 2 inz('IX')
d QMHSNDM PR ExtPgm('QMHSNDM')
d MsgID 7A const
d QualMsgF 20A const
d MsgTxt 32767A const options(*varsize)
d MsgTxtLen 10I 0 const
d MsgType 10A const
d MsgQueues 20A const dim(50) options(*varsize)
d NumQueues 10I 0 const
d RpyQueue 20A const
d MsgKey 4A
d ErrorCode 8000A options(*varsize)
d CCSID 10I 0 const options(*nopass)
d ErrorCode ds qualified
d BytesProv 10I 0 inz(0)
d BytesAvail 10I 0 inz(0)
*
d sleep pr 10i 0 ExtProc( 'sleep' )
d seconds 10u 0 Value
*
* Program Info
*
d PgmInfo SDS
d @PgmName 1 10
d @Parms 37 39 0
d @MsgID 40 46
d @JobName 244 253
d @UserId 254 263
d @JobNumber 264 269 0
*==========================================================
* MAIN LINE
*==========================================================
c exsr Hskpg
c dow Loop = 'Y'
*
c eval Message = 'Starting EDI p' +
c 'rocesses ' +
c 'Time: ' + %char(%time())
c exsr $SendMessage
*
* process the inbound documents
*
c call(e) 'EDI0024C0'
c callp sleep(120 )
*
c call(e) 'EDI0044C0'
c parm Company
c callp sleep(120 )
*
c call(e) 'EDI0010C01'
c callp sleep(120 )
*
* only run this once a day!
*
c if Ran852 = *blanks
c call(e) 'EDI0043C0'
c parm Company
c callp sleep(120 )
c eval Ran852 = 'Y'
c endif
*
c call(e) 'EDI0048C0'
c parm Company
c callp sleep(120 )
*
c call(e) 'EDI0042C0'
c callp sleep(120 )
*
* CALL PGM(CED8622B) PARM(IX '2')
c call(e) 'CED8622B'
c parm OutNetwork
c parm SessionType
*
* ending edi processing
*
c eval Message = 'Ending EDI p' +
c 'rocesses ' +
c 'Time: ' + %char(%time())
c exsr $SendMessage
c callp sleep( 7200 )
c enddo
*
c eval *inlr = *on
*
/free
//-------------------------------------------
// $SendMessage - send the message to QSYSOPR
//-------------------------------------------
begsr $SendMessage;
QMHSNDM( *blanks
: *blanks
: Message
: %len(Message)
: '*INFO'
: MsgQ
: %elem(MsgQ)
: '*PGMQ'
: MsgKey
: ErrorCode );
endsr;
/end-free
*=================================================
* Hskpg - One time run House keeping subroutine
*=================================================
c Hskpg begsr
*
* addlible edi4xxpgm
*
c eval cmdstring = 'addlible edi4xxpgm'
c eval cmdlength = %len(%trim(cmdstring))
*
c call(e) 'QCMDEXC'
c parm CmdString
c parm CmdLength
*
*
* addlible edi4xxdta
*
c eval cmdstring = 'addlible edi4xxdta'
c eval cmdlength = %len(%trim(cmdstring))
*
c call(e) 'QCMDEXC'
c parm CmdString
c parm CmdLength
*
c endsr
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
Comment
-
Re: delay in RPG/LE
Originally posted by jamief View Postusing dlyjob
Code:d waittime s 3 inz('900') d cmdstring s 256 d cmdlength s 15 5 c eval cmdstring = 'dlyjob ' + waittime c eval cmdlength = %len(%trim(cmdstring)) * * * do your program stuff here * c call(e) 'QCMDEXC' c parm cmdstring c parm cmdlength * c eval *inlr = *on
PHP Code:~
H Option( *SrcStmt: *NoDebugIo ) BndDir( 'QC2LE' )
*=======================================================================
* PROGRAM -
* PURPOSE -
* WRITTEN -
* AUTHOR -
*
* PROGRAM DESCRIPTION
* This program will send/receive all EDI documents delay a period of time
* then run again.
*
*
* INDICATOR USAGE
* n/a
*
*=======================================================================
*
* Field Definitions.
*
d Company s 2 inz('15')
d CmdLength s 15 5
d CmdString s 256
d Count s 4 0
d DelayMinutes s 4 0 inz(7200)
d Loop s 1 inz('Y')
d Message s 100A varying
d MsgKey s 4A
d MsgQ s 20A dim(1) inz('*SYSOPR')
d Network s 2
d PassCompany s 2
d Q s 1 inz('''')
d Ran852 s 1
d Reply s 100A
d SessionType s 1 inz('3')
d OutNetwork s 2 inz('IX')
d QMHSNDM PR ExtPgm('QMHSNDM')
d MsgID 7A const
d QualMsgF 20A const
d MsgTxt 32767A const options(*varsize)
d MsgTxtLen 10I 0 const
d MsgType 10A const
d MsgQueues 20A const dim(50) options(*varsize)
d NumQueues 10I 0 const
d RpyQueue 20A const
d MsgKey 4A
d ErrorCode 8000A options(*varsize)
d CCSID 10I 0 const options(*nopass)
d ErrorCode ds qualified
d BytesProv 10I 0 inz(0)
d BytesAvail 10I 0 inz(0)
*
d sleep pr 10i 0 ExtProc( 'sleep' )
d seconds 10u 0 Value
*
* Program Info
*
d PgmInfo SDS
d @PgmName 1 10
d @Parms 37 39 0
d @MsgID 40 46
d @JobName 244 253
d @UserId 254 263
d @JobNumber 264 269 0
*==========================================================
* MAIN LINE
*==========================================================
c exsr Hskpg
c dow Loop = 'Y'
*
c eval Message = 'Starting EDI p' +
c 'rocesses ' +
c 'Time: ' + %char(%time())
c exsr $SendMessage
*
* process the inbound documents
*
c call(e) 'EDI0024C0'
c callp sleep(120 )
*
c call(e) 'EDI0044C0'
c parm Company
c callp sleep(120 )
*
c call(e) 'EDI0010C01'
c callp sleep(120 )
*
* only run this once a day!
*
c if Ran852 = *blanks
c call(e) 'EDI0043C0'
c parm Company
c callp sleep(120 )
c eval Ran852 = 'Y'
c endif
*
c call(e) 'EDI0048C0'
c parm Company
c callp sleep(120 )
*
c call(e) 'EDI0042C0'
c callp sleep(120 )
*
* CALL PGM(CED8622B) PARM(IX '2')
c call(e) 'CED8622B'
c parm OutNetwork
c parm SessionType
*
* ending edi processing
*
c eval Message = 'Ending EDI p' +
c 'rocesses ' +
c 'Time: ' + %char(%time())
c exsr $SendMessage
c callp sleep( 7200 )
c enddo
*
c eval *inlr = *on
*
/free
//-------------------------------------------
// $SendMessage - send the message to QSYSOPR
//-------------------------------------------
begsr $SendMessage;
QMHSNDM( *blanks
: *blanks
: Message
: %len(Message)
: '*INFO'
: MsgQ
: %elem(MsgQ)
: '*PGMQ'
: MsgKey
: ErrorCode );
endsr;
/end-free
*=================================================
* Hskpg - One time run House keeping subroutine
*=================================================
c Hskpg begsr
*
* addlible edi4xxpgm
*
c eval cmdstring = 'addlible edi4xxpgm'
c eval cmdlength = %len(%trim(cmdstring))
*
c call(e) 'QCMDEXC'
c parm CmdString
c parm CmdLength
*
*
* addlible edi4xxdta
*
c eval cmdstring = 'addlible edi4xxdta'
c eval cmdlength = %len(%trim(cmdstring))
*
c call(e) 'QCMDEXC'
c parm CmdString
c parm CmdLength
*
c endsr
I'm using the ChkIfsObj2 sub procedure to check for it's existance, but I want to delay a few seconds and loop until it's available.
This whole process will be repeated several hundred times (create report, create pdf, send e-mail). So I would like for this to be as efficient as possible.
BTW - I see you are using Inovis EDI software
Thanks
Comment
-
Re: delay in RPG/LE
they are the same under the covers. neither is "more efficient" a delay is a delay is a delay...( i suppose if 1/100th of a nanosecond response time is a big deal the sleep API might be the best option...)I'm not anti-social, I just don't like people -Tommy Holden
Comment
-
Re: delay in RPG/LE
I like to use the api (sleep), I guess the difference is that its a direct call and can be monitored for specific errors ??
while the DLYJOB is called via QCMDEXEC...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
Comment
-
Re: delay in RPG/LE
Originally posted by jamief View PostI like to use the api (sleep), I guess the difference is that its a direct call and can be monitored for specific errors ??
while the DLYJOB is called via QCMDEXEC...I'm not anti-social, I just don't like people -Tommy Holden
Comment
-
Re: delay in RPG/LE
Thanks for your help! I went with the QCMDEXC method since I was already using it in this pgm. Here's what I came up with.
Code:for x = 1 to 10; if ChkIfsObj2(%trim(Stmf):ObjType:NbrBytes:C_Errno:C_ErrText) = *on; leave; else; cmdstring = 'dlyjob 6'; qcmdexc(cmdstring:%len(cmdstring)); endif; endfor;
Comment
Comment