1
|
define temp-table udftest
|
2
|
field id as integer
|
3
|
field fdate as date
|
4
|
field fmt as character
|
5
|
field fstr-result as character
|
6
|
index pk as primary id
|
7
|
.
|
8
|
|
9
|
OUTPUT TO available.txt.
|
10
|
|
11
|
create udftest. id = 1. fdate = date(07, 19, 2021). fmt = '999999'. fstr-result = "071921".
|
12
|
create udftest. id = 2. fdate = date(07, 05, 2021). fmt = '99999'. fstr-result = ?.
|
13
|
|
14
|
message "After create:" AVAILABLE udftest.
|
15
|
|
16
|
run test(?, ?) NO-ERROR.
|
17
|
|
18
|
run test(date(07, 05, 2021), '99999') NO-ERROR.
|
19
|
run test(date(07, 19, 2021), '999999') NO-ERROR.
|
20
|
run test(date(07, 05, 2021), '99999') NO-ERROR.
|
21
|
|
22
|
message 'done'.
|
23
|
|
24
|
procedure test:
|
25
|
def input param val as date.
|
26
|
def input param fmt as char.
|
27
|
def var err-flag as logical init true.
|
28
|
def var nmsg as integer no-undo.
|
29
|
message "test(" val "," fmt ")".
|
30
|
inner:
|
31
|
do on stop undo, leave inner:
|
32
|
FIND FIRST udftest
|
33
|
WHERE udftest.fdate = val
|
34
|
AND udftest.fmt = fmt
|
35
|
AND string(fdate, fmt) = udftest.fstr-result
|
36
|
NO-ERROR
|
37
|
.
|
38
|
err-flag = false.
|
39
|
end.
|
40
|
message "After find - ERROR:" ERROR-STATUS:ERROR
|
41
|
"NUM-MESSAGES:" ERROR-STATUS:NUM-MESSAGES
|
42
|
"AVAILABLE:" AVAILABLE udftest
|
43
|
"err-flag:" err-flag.
|
44
|
IF ERROR-STATUS:NUM-MESSAGES > 0 THEN DO:
|
45
|
do nmsg = 1 to ERROR-STATUS:NUM-MESSAGES:
|
46
|
message "***" ERROR-STATUS:GET-NUMBER(nmsg) ':' ERROR-STATUS:GET-MESSAGE(nmsg).
|
47
|
end.
|
48
|
END.
|
49
|
end.
|
50
|
OUTPUT CLOSE.
|