In our shop, we run a nightly cycle to manipulate our data. We have added many new jobs to the nightly job stream; however, not all the jobs are run every night. In an effort to have one main CL program drive all the programs that need to be submitted each night of the week, we have developed the CL program DOW001CL shown in 4 to allow us to determine what day of the week it is on a given day. Before you run this program for the first time, you'll need to create a 20-byte character data area called DAYOFWEEK. When you create this data area, load it with the day of the week in positions 1-10, the Julian date in positions 11-15, and the relative day of the week in position 20. For example, you could use the following command:
In our shop, we run a nightly cycle to manipulate our data. We have added many new jobs to the nightly job stream; however, not all the jobs are run every night. In an effort to have one main CL program drive all the programs that need to be submitted each night of the week, we have developed the CL program DOW001CL shown in Figure 4 to allow us to determine what day of the week it is on a given day. Before you run this program for the first time, you'll need to create a 20-byte character data area called DAYOFWEEK. When you create this data area, load it with the day of the week in positions 1-10, the Julian date in positions 11-15, and the relative day of the week in position 20. For example, you could use the following command:
CRTDTAARA DTAARA(xxx/DAYOFWEEK) + TYPE(*CHAR) LEN(20) + VALUE('MONDAY 95212 1') In this case, we're using Monday, July 31, 1995, as the starting date. Any past date will do as long as the day of the week you pick occurred on the Julian date specified and the relative day of the week (position 20) coincides with the other fields. After you create this data area, you can call the DOW001CL program at the beginning of your nightly job. Then you can retrieve the data from the data area into a variable in your program and use it to determine the day of the week as shown in the example in 5.
In this case, we're using Monday, July 31, 1995, as the starting date. Any past date will do as long as the day of the week you pick occurred on the Julian date specified and the relative day of the week (position 20) coincides with the other fields. After you create this data area, you can call the DOW001CL program at the beginning of your nightly job. Then you can retrieve the data from the data area into a variable in your program and use it to determine the day of the week as shown in the example in Figure 5.
? Neely Loring
TechTalk: Day of Week Calculation
Figure 4: CL Program DOW001CL
/*===============================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/DOW001CL) SRCFILE(XXX/QCLSRC) */ /* */ /*===============================================================*/ PGM DCL VAR(&JULDAYC) TYPE(*CHAR) LEN(5) DCL VAR(&SYSDATE) TYPE(*CHAR) LEN(6) DCL VAR(&SYSJULDATE) TYPE(*CHAR) LEN(5) DCL VAR(&SYSJULDATC) TYPE(*DEC) LEN(5 0) DCL VAR(&CALCDATE) TYPE(*DEC) LEN(2 0) DCL VAR(&DAYCALCC) TYPE(*CHAR) LEN(1) DCL VAR(&DAYCALC) TYPE(*DEC) LEN(1 0) DCL VAR(&JULDATE) TYPE(*DEC) LEN(5 0) RTVDTAARA DTAARA(DAYOFWEEK (11 5)) RTNVAR(&JULDAYC) RTVSYSVAL SYSVAL(QDATE) RTNVAR(&SYSDATE) RTVDTAARA DTAARA(DAYOFWEEK (20 1)) RTNVAR(&DAYCALCC) CHGVAR VAR(&DAYCALC) VALUE(&DAYCALCC) CHGVAR VAR(&JULDATE) VALUE(&JULDAYC) CVTDAT DATE(&SYSDATE) TOVAR(&SYSJULDATE) + FROMFMT(*MDY) TOFMT(*JUL) TOSEP(*NONE) CHGDTAARA DTAARA(DAYOFWEEK (11 5)) VALUE(&SYSJULDATE) CHGVAR VAR(&SYSJULDATC) VALUE(&SYSJULDATE) CHGVAR VAR(&CALCDATE) VALUE(&SYSJULDATC - &JULDATE) MONMSG MSGID(CPF0000) IF COND(&CALCDATE *EQ 0) THEN(GOTO CMDLBL(ENDPGM)) IF COND(&CALCDATE *NE 0) THEN(DO) CHGVAR VAR(&DAYCALC) VALUE(&CALCDATE + &DAYCALC) MONMSG MSGID(CPF0000) ENDDO IF COND(&DAYCALC *GT 7) THEN(DO) CHGVAR VAR(&DAYCALC) VALUE(&DAYCALC - 7) ENDDO IF COND(&DAYCALC *EQ 1) THEN(DO) CHGDTAARA DTAARA(DAYOFWEEK (1 10)) VALUE('MONDAY') ENDDO IF COND(&DAYCALC *EQ 2) THEN(DO) CHGDTAARA DTAARA(DAYOFWEEK (1 10)) VALUE('TUESDAY') ENDDO IF COND(&DAYCALC *EQ 3) THEN(DO) CHGDTAARA DTAARA(DAYOFWEEK (1 10)) VALUE('WEDNESDAY') ENDDO IF COND(&DAYCALC *EQ 4) THEN(DO) CHGDTAARA DTAARA(DAYOFWEEK (1 10)) VALUE('THURSDAY') ENDDO IF COND(&DAYCALC *EQ 5) THEN(DO) CHGDTAARA DTAARA(DAYOFWEEK (1 10)) VALUE('FRIDAY') ENDDO IF COND(&DAYCALC *EQ 6) THEN(DO) CHGDTAARA DTAARA(DAYOFWEEK (1 10)) VALUE('SATURDAY') ENDDO IF COND(&DAYCALC *EQ 7) THEN(DO) CHGDTAARA DTAARA(DAYOFWEEK (1 10)) VALUE('SUNDAY') ENDDO CHGVAR VAR(&DAYCALCC) VALUE(&DAYCALC) CHGDTAARA DTAARA(DAYOFWEEK (20 1)) VALUE(&DAYCALCC) ENDPGM: ENDPGM
TechTalk: Day of Week Calculation
Figure 5: Example CL Program
PGM DCL VAR(&DAYOFWEEK) TYPE(*CHAR) LEN(10) CALL PGM(DOW001CL) RTVDTAARA DTAARA(DAYOFWEEK (1 10)) RTNVAR(&DAYOFWEEK) IF COND(&DAYOFWEEK *EQ 'MONDAY') THEN(DO) . . . ENDDO IF COND(&DAYOFWEEK *EQ 'TUESDAY') THEN(DO) . . . ENDDO ENDPGM
Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:
LATEST COMMENTS
MC Press Online