Member
| I use the below code for control_type '055' to extract the term and the dates. The technique should transfer to your control_type. Most of the code in the define relates to the term, so you can discard that if you are only after the dates.
[code] -****************************************************************** -* GET DATA FROM THE ACRTTBL FILE. * -* Use some trickery to get the term, session, start, end dts * -* term is pos 6-8 in control key, session in pos 9. But the data -* is stored as bit data, so special focus defines are needed to -* reconstruct the actual print characters. The dates are stored -* as packed data, but focus can't directly unpack the db2 fields -* stored as character strings, thus we use substr(hex(...)) to -* get the dates -* -* CONTROL_KEY HEX_END_DT HEX_END_DT2 -* ----------- ---------- ----------- -* 202043323030343151202020202020 020040301F 20040301 -* 202043323030343152202020202020 020040109F 20040109 -* 202043323030343141202020202020 020040120F 20040120 -*****************************************************************
SQL DB2 SET CURRENT SCHEMA PRODADM; SQL DB2 SELECT substr(CONTROL_KEY,6,4) as control_key, substr(hex(SUBSTR(CONTROL_DATA,1,5)),2,8) AS START_DT, substr(hex(SUBSTR(CONTROL_DATA,6,5)),2,8) AS END_DT FROM sis_control_tb where control_type = '055' and substr(control_key,6,3) between '&TRM1' and '&TRM6' and substr(control_key,9,1) > ' ' ; TABLE FILE SQLOUT PRINT CONTROL_KEY START_DT END_DT ON TABLE HOLD AS HOLDCAL END -RUN
DEFINE FILE HOLDCAL CONTROLKEY/A08=CONTROL_KEY;
CA1/A1=SUBSTR ( 8, CONTROLKEY , 1, 1, 1, 'A1'); CB1/A1=SUBSTR ( 8, CONTROLKEY , 2, 2, 1, 'A1'); CH21/I2=(EDIT(CA1) * 16 )+ EDIT(CB1); CHAR1/A1=HEXBYT(CH21,'A1');
CA2/A1=SUBSTR ( 8, CONTROLKEY , 3, 3, 1, 'A1'); CB2/A1=SUBSTR ( 8, CONTROLKEY , 4, 4, 1, 'A1'); CH22/I2=(EDIT(CA2) * 16 )+ EDIT(CB2); CHAR2/A1=HEXBYT(CH22,'A1');
CA3/A1=SUBSTR ( 8, CONTROLKEY , 5, 5, 1, 'A1'); CB3/A1=SUBSTR ( 8, CONTROLKEY , 6, 6, 1, 'A1'); CH23/I2=(EDIT(CA3) * 16 )+ EDIT(CB3); CHAR3/A1=HEXBYT(CH23,'A1');
CA4/A1=SUBSTR ( 8, CONTROLKEY , 7, 7, 1, 'A1'); CB4/A1=SUBSTR ( 8, CONTROLKEY , 8, 8, 1, 'A1'); CH24/I2=IF CB4 EQ 'A' THEN (EDIT(CA4) * 16 )+ 10 ELSE IF CB4 EQ 'B' THEN (EDIT(CA4) * 16 )+ 11 ELSE IF CB4 EQ 'C' THEN (EDIT(CA4) * 16 )+ 12 ELSE IF CB4 EQ 'D' THEN (EDIT(CA4) * 16 )+ 13 ELSE IF CB4 EQ 'E' THEN (EDIT(CA4) * 16 )+ 14 ELSE IF CB4 EQ 'F' THEN (EDIT(CA4) * 16 )+ 15 ELSE (EDIT(CA4) * 16 )+ EDIT(CB4);
CHAR4/A1=HEXBYT(CH24,'A1');
TERM/A3 =CHAR1 | CHAR2 | CHAR3; SESSION/A1=CHAR4;
START_YYMD/I8YYMD = EDIT(START_DT) ; END_YYMD/I8YYMD = EDIT(END_DT) ; CAL_START/MDYY = START_YYMD; CAL_END/MDYY = END_YYMD; VALIDTERM/I5 = CHKFMT(3, TERM, '999', VALIDTERM); END
[\code] |