IBMi (AS400) fans only * How to add/subtract days to a date from CL (CONTROL LANGUAGE)
#IBMiSample
This is a CLLE! Compile with:
CRTBNDCL PGM(DATEDISPLC) SRCFILE(QCLSRC) SRCMBR(DATEDISPLC)
DATEDISPLC.CLLE
/**************************************************************/
/* add/subtract days to a date */
/* Try with: CALL DATEDISPLC PARM('270219' X'0000005F') */
/**************************************************************/
PGM PARM(&DATE &DISPLACEM)
DCL VAR(&DATE) TYPE(*CHAR) LEN(6)
DCL VAR(&DISPLACEM) TYPE(*DEC) LEN(6 0)
DCL VAR(&LILIAN) TYPE(*CHAR) LEN(4)
CALLPRC PRC(CEEDAYS) PARM((&DATE) ('DDMMYY') +
(&LILIAN) (*OMIT))
CHGVAR VAR(%BIN(&LILIAN)) VALUE(%BIN(&LILIAN) + +
&DISPLACEM)
CALLPRC PRC(CEEDATE) PARM((&LILIAN) ('DDMMYY') +
(&DATE) (*OMIT))
SNDUSRMSG MSG(&DATE) MSGTYPE(*INFO)
Another way if you have date TYPE(*DEC) (this is the most usual format)
DATEDISPLC.CLLE
/**************************************************************/
/* add/subtract days to a date */
/* Try with: CALL DATEDISPLC PARM('270219' X'0000005F') */
/**************************************************************/
PGM PARM(&DATE0 &DISPLACEM)
DCL VAR(&DATE0) TYPE(*DEC) LEN(6 0)
DCL VAR(&DATE) TYPE(*CHAR) LEN(6)
DCL VAR(&DISPLACEM) TYPE(*DEC) LEN(6 0)
DCL VAR(&LILIAN) TYPE(*CHAR) LEN(4)
CHGVAR VAR((&DATE)) VALUE(&DATE0)
CALLPRC PRC(CEEDAYS) PARM((&DATE) ('DDMMYY') +
(&LILIAN) (*OMIT))
CHGVAR VAR(%BIN(&LILIAN)) VALUE(%BIN(&LILIAN) + +
&DISPLACEM)
CALLPRC PRC(CEEDATE) PARM((&LILIAN) ('DDMMYY') +
(&DATE) (*OMIT))
CHGVAR VAR((&DATE0)) VALUE(&DATE)
SNDUSRMSG MSG(&DATE) MSGTYPE(*INFO)
ENDPGM
I appreciate all the comments made on this blog.
Comments
Post a Comment