I took a stab at the method I suggested. First, I created a static VARA object with values in two columns:
| Key
| Value 1
| Value 2
|
|
|
|
| 1 | ABC | 1 |
|
|
|
| 2 | DEF | 1 |
|
|
|
| 3 | GHI | 2 |
|
|
|
| 4 | JKL | 3 |
|
|
|
| 5 | MNO | 5 |
|
|
|
| 6 | PQR | 8 |
|
|
|
| 7 | STU | 13 |
|
|
|
| 8 | VWX | 21 |
|
|
|
| 9 | YZ | 35 |
|
|
|
Next, I made an EXEC VARA:
https://us.v-cdn.net/5019921/uploads/editor/4j/91x7u09ir5sg.png" width="541">
Finally, I made the SCRI that the EXEC VARA will execute. Here was my first attempt:
:SET &Hnd1# = PREP_PROCESS_VAR(UC0.MAL.CREATE_PROCESS_TESTS.VARA_STATIC,,,2)
:PSET &Result# = SAVE_PROCESS(&Hnd1#)
:CLOSE_PROCESS &Hnd1#
:CLOSE_PROCESS &Result#
The idea is to use PREP_PROCESS_VAR to create a data sequence containing only the values from column 2, and then simply to save this data sequence for use by the SCRI. When I clicked the
Preview button, here were the results:
RESULT
| 1§§§ABC§§§1§§§§§§§§§§§§◻ |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
Obviously, something is not right. I tried specifying a different value than 2 for the
Column argument, and also tried omitting this argument altogether. Neither made a difference. Next, I tried using CREATE_PROCESS with the DUPLICATE option, to create a copy of the original data sequence:
:SET &Hnd1# = PREP_PROCESS_VAR(UC0.MAL.CREATE_PROCESS_TESTS.VARA_STATIC,,,)
:SET &Hnd2# = CREATE_PROCESS(DUPLICATE,&Hnd1#)
:PSET &Result# = SAVE_PROCESS(&Hnd2#)
:CLOSE_PROCESS &Hnd1#
:CLOSE_PROCESS &Hnd2#
:CLOSE_PROCESS &Result#
The results were unchanged. (Note by the way, that I am using :PSET instead of :SET. This is important. With just :SET, no results at all are returned.)
It seems that the
Column argument of PREP_PROCESS_VAR is ignored, or does not work as I would expect it to.
Next, I went ahead and did it the long way, parsing each line of the original STATIC VARA, extracting the value from the desired column, and one-by-one, putting these values into a new data sequence:
:Set &Counter# = 0
:SET &Hnd1# = PREP_PROCESS_VAR(UC0.MAL.CREATE_PROCESS_TESTS.VARA_STATIC,,,)
:PROCESS &Hnd1#
: SET &Counter# = &Counter# + 1
: IF &Counter# = 1
: SET &Hnd2# = CREATE_PROCESS(NEW)
: SET &RC# = PUT_PROCESS_LINE(&Hnd2#,"Value2")
: ENDIF
: SET &Column2Value# = GET_PROCESS_LINE(&Hnd1#,3)
: SET &RC# = PUT_PROCESS_LINE(&Hnd2#,&Column2Value#)
:ENDPROCESS
:IF &Counter# > 0
: PSET &Result# = SAVE_PROCESS(&Hnd2#)
:ENDIF
:CLOSE_PROCESS &Hnd1#
:CLOSE_PROCESS &Hnd2#
:CLOSE_PROCESS &Result#
This worked. Here are the results:
RESULT
| Value2
|
1
| 1
|
1 | 1 |
2 | 2 |
3 | 3 |
5 | 5 |
8 | 8 |
13 | 13 |
21 | 21 |
35 | 35 |
Note that there is an extra PUT_PROCESS_LINE command in the first iteration of the PROCESS loop (when the counter is equal to 1). This is important, because it inserts column headings.
This solution is a bit verbose, and I had hoped to find a more elegant approach that did not require creating extra data sequences. I do not know why the
Column argument of PREP_PROCESS_VAR does not work. Has anyone else had success with this?
And by the way, when this EXEC VARA is used as the data source for a combo box element in a prompt set, one of the duplicate '1' values is omitted, and only one of them appears in the list. I suppose this is because the items in a combo box list must be unique.