目的:利用ENFORM 去找出資料,但條件是變動的

Sol : ENFORM + TACL

TACL  program :ENFUTLFO

Usage : Obey ENFUTLFO

------ Pgm Begin----------------

#SET #INFORMAT TACL

 #PUSH #INLINEPREFIX

  INLPREFIX +

 comment  trandate = today - 3

 #push juldayno yy mm dd hour  trandate mmdd

 #setmany juldayno, [#interprettimestamp [#juliantimestamp]]

 #set juldayno [#compute juldayno - 3]

 #setmany yy mm dd, [#interpretjuliandayno [juldayno]]

 #set trandate [#compute yy * 10000 + mm * 100 + dd]

 #output [trandate]

 comment get UTLF backup file

 #setmany juldayno, [#interprettimestamp [#juliantimestamp]]

 #set juldayno [#compute juldayno - 1]

 #setmany yy mm dd, [#interpretjuliandayno [juldayno]]

 #set mmdd [#COMPUTE mm * 100 + dd]

 #output [mmdd]

 [#IF [mmdd] < 1000

    |THEN|

    FUP /INLINE/

    + dup $PROD4.UB12BKUP.UT0[mmdd],$WORK.UB12ENF.UTLFDATA,SOURCEDATE,PURGE

    + EXIT

    |ELSE|

    FUP /INLINE/

    + dup $PROD4.UB12BKUP.UT[mmdd],$WORK.UB12ENF.UTLFDATA,SOURCEDATE,PURGE

    + EXIT

 ]

 PARAM  u-date [trandate]

 FUP PURGEDATA   $WORK.RAY.rptutlf

 ENFORM /IN UTLFO,out $s1.#ENFUTLF/

-----------PGM End -------------------

Enform :因為使用PARAM ,所以要變成 Compiled query file.

作法:

1.ENFORM

2.?COMPILE ENFUTLF TO UTLFO

------- PGM Bgegin -----------------

?DICTIONARY $PROD4.UB12DDLB;

 ?ASSIGN TLF-RECORD,$WORK.UB12ENF.UTLFDATA,SHARED;

 ?ASSIGN MER-RECORD,$PROD1.UB12CTLP.MER,SHARED;

 ?ASSIGN QUERY-REPORT-LISTING,$WORK.RAY.rptutlf;

 OPEN TLF-RECORD,MER-RECORD;

 LINK TLF-RECORD.PROD-POS.MER-ID TO MER-RECORD.MER-KEY;

 DECLARE CNT-REC AS i6;

 SET CNT-REC      TO 0;

 SET @DATE-FORMAT TO "M2/D2/Y2";

 SET @SUMMARY-ONLY TO ON;

 PARAM u-date  INTERNAL I8;

 TITLE "@ENFUTLF" TAB 17,"DATE: ",@DATE AS DATE *,SPACE 24,

       "UNION BANK OF TAIWAN",SPACE 17,"PRINT DATA: ",@DATE AS DATE *,

       SPACE 3,"PAGE: " @PAGENO,

 SUBTITLE "ENFORM-EDC三天以上未結帳報表"

 LIST BY TLF-RECORD.PROD-POS.MER-ID               HEADING "MER-ID",";",

            BY TLF-RECORD.TERM-KEY.TERM-ID              HEADING "TERM",";",

            BY DESC TLF-RECORD.SYS-DATE.TRAN-DATE       HEADING "TRAN-DATE",";",

         TERM-RETR-NUM  OF TLF-RETR-TERM-KEY      HEADING "RETR",";",

         MER-RECORD.MER-SHORT-NAME                HEADING "NAME",";",

       COUNT (TLF-RECORD.TERM-KEY.TERM-ID OVER TLF-RECORD.TERM-KEY.TERM-ID)

         AS M<Z,ZZ9>  HEADING "COUNT",";",

         CNT-REC := (CNT-REC +1) CUM              HEADING "NO",SPACE 1

 WHERE   TLF-RECORD.SYS-DATE.TRAN-DATE  < u-date  AND

         MER-RECORD.REC-IN-USE = "Y"

 CENTER ALL,

 AT END PRINT

  space 54, "*** END OF REPORT ***";

 ?EXIT

-----------Pgm End ------------------------------------