Here's a JOBI that will expand status ranges like the ones in
ZUTYP_STATUSRANGE
.
EBM.ENUMERATE_TASK_STATUS_RANGE.JOBI
:SET &INPUT_STRING# = &INPUT_STRING#
! For testing:
!:SET &INPUT_STRING# = "1550,1541,1542,1545,1546,1551-1564,1566-1576,1578-1583,1590-1593,1682,1685,1686,1701"
:PRINT "Input string : &INPUT_STRING#"
:SET &OUTPUT_STRING# = ""
:DEFINE &STRING_ARRAY#, string, 200
:FILL &STRING_ARRAY#[] = STR_SPLIT(&INPUT_STRING#,",")
:SET &COUNTER# = 1
:SET &LENGTH# = LENGTH(&STRING_ARRAY#[])
:WHILE &COUNTER# <= &LENGTH#
: SET &ELEMENT# = &STRING_ARRAY#[&COUNTER#]
: IF &ELEMENT# <> ""
: SET &COUNTER# = FORMAT(&COUNTER#,"0")
!: PRINT "Array element &COUNTER# : &ELEMENT#"
: SET &IS_STATUS_RANGE# = STR_MATCH(&ELEMENT#,"????-????","*","?")
: IF &IS_STATUS_RANGE# = "Y"
!: PRINT "Element appears to be a range."
: SET &LOWER_BOUND# = STR_CUT(&ELEMENT#,1,4)
: SET &UPPER_BOUND# = STR_CUT(&ELEMENT#,6,4)
!: PRINT "Lower bound : &LOWER_BOUND#"
!: PRINT "UPPER bound : &UPPER_BOUND#"
: SET &LOWER_BOUND_NUMERIC# = ISNUMERIC(&LOWER_BOUND#)
: SET &UPPER_BOUND_NUMERIC# = ISNUMERIC(&UPPER_BOUND#)
: IF &LOWER_BOUND_NUMERIC# <> "Y"
: PRINT "WARNING: Lower bound of range &ELEMENT#, &LOWER_BOUND#, is not numeric."
: ENDIF
: IF &UPPER_BOUND_NUMERIC# <> "Y"
: PRINT "WARNING: Upper bound of range &ELEMENT#, &UPPER_BOUND#, is not numeric."
: ENDIF
: SET &RANGE_ELEMENT# = &LOWER_BOUND#
: WHILE &RANGE_ELEMENT# < &UPPER_BOUND#
: SET &RANGE_ELEMENT# = FORMAT(&RANGE_ELEMENT#)
: IF &OUTPUT_STRING# = ""
: SET &OUTPUT_STRING# = "&RANGE_ELEMENT#"
: ELSE
: SET &OUTPUT_STRING# = "&OUTPUT_STRING#,&RANGE_ELEMENT#"
: ENDIF
: SET &RANGE_ELEMENT# = &RANGE_ELEMENT# + 1
: ENDWHILE
: ELSE
: IF &OUTPUT_STRING# = ""
: SET &OUTPUT_STRING# = "&ELEMENT#"
: ELSE
: SET &OUTPUT_STRING# = "&OUTPUT_STRING#,&ELEMENT#"
: ENDIF
: ENDIF
: ENDIF
: SET &COUNTER# = &COUNTER# + 1
:ENDWHILE
:PRINT "Output string : &OUTPUT_STRING#"
(Higher Logic corrupts the indentation. There's not much I can do about that.)
Enjoy!
Original Message:
Sent: Nov 18, 2022 04:19 PM
From: Michael Lowry
Subject: AE REST API quirks
I'm working on implementing Dependencies between UC4 systems, and have decided to use the REST API to query the status of tasks in the remote (predecessor) UC4 system. I've noticed a couple of quirks with the GET /executions API.
- The name parameter doesn't work with object names that contain the # character.
- The status parameter accepts either a comma-delimited list (documented) or a range separated by a dash (undocumented). However, the two cannot be combined. So 1900-1999 works, but 1900-1999,1899 does not.
I'm not sure what to do about the first obstacle. Using HTML entities to escape the # character does not appear to help.
The latter limitation is particularly annoying, because I was hoping to be able to recreate in a prompt set most of the options one can specify in external dependencies. For Expected task status, I can display a combo box with exactly the same condition/state names as in the AWI, using an SQL query like this:
SELECT ZUTYP_STATUS FROM UC_ZUTYP
WHERE ZUTYP_ISALIVE = 0
ORDER BY ZUTYP_STATUS ASC
Then I can fetch the ZUTYP_STATUSRANGE
that corresponds to the user's choice. But it's not very useful if I can't reliably pass it to the executions REST API. The ANY_OK_OR_UNBLOCKED
status - probably the one chosen most often - corresponds to status codes 1900-1999 and 1899.
Is there a way around this other than expanding the ranges into comma-delimited lists?