Skip to main content
EliasFernandez
Participating Frequently
Nov 13, 2026 7:37 PM UTC
Question

Virtual Attribute Does Not Work for me

Please, observe this virtual attribute

 

:ED DICT COR-DATA TEST
Top of "TEST" in "DICT COR-DATA",

001: I
002: SUBR('-OCONVS', F21, TRANS("ENCLOSURE",F20,2,"X"))
003:
004: XXXX
005: 15R
006: M
007: ASSOC_20

This is about file COR-DATA, COR-DATA HAS A MULTIVALUE on attribute 20 and attribute 21; 20 has correspondence types as ALPHA BETA WHATEVER and 21 has money in internal format. My idea is dealing with multivalues 20 21 keeping in mind that file ENCLOSURE attribute 2 has a money conversion like MR2  or MR2, or MR4, etc.

 This is my problem

 

:ED DICT COR-DATA TEST
Top of "TEST" in "DICT COR-DATA", 14 lines, 156 characters.
*--: P
001: I
002: SUBR('-OCONVS', F21, TRANS("ENCLOSURE",F20,2,"X"))
003:
004: XXXX
005: 15R
006: M
007: ASSOC_20

 

LIST COR-DATA F20 F21 TEST 14:34:38 Nov 13 2026 1
COR-DATA.. ENCLOSURES..... ENC_VALUE........... XXXX...........

WQ6843     MB                             10001            0.00
           MB                             10002            0.00
           MB                             10003            0.00
           MB                             10004            0.00
           MB                             10005            0.00
           MB                             10006            0.00
           MB                             10007            0.00

all virtual     TEST returns 0.00 instead as 123.40 OR 3,457.56   

10 replies

Jon Card
Inspiring
Nov 13, 2026 8:27 PM UTC

it looks to me like you this incorrect

SUBR('-OCONVS', F21, TRANS("ENCLOSURE",F20,2,"X"))

try this

TRANS("ENCLOSURE",F20,2,"X");SUBR('-OCONVS', F21, @1)

 

Jonathan Smith
Rocketeer
Nov 13, 2026 9:09 PM UTC

This seems straight forward or I may be missing something as your description is missing quite a lot.

Here is my worked example to show you.

:LIST-ITEM COR.DATA.TEST
      1
001 ALPHA BETA
002 10001 10002


 1 record(s) listed.

So before any adding in the next step it shows

LIST COR.DATA.TEST ENC ENC.KEY 20:53:58 13 Nov 2026 1
COR.DATA.TEST Enclosure. ENC_KEY...

1             ALPHA           10001
              BETA            10002
1 record listed

:LIST-ITEM COR.DATA.TEST
      1
001 ALPHA BETA
002 10001 10002


 1 record(s) listed.

So before any adding in the next step it shows

LIST COR.DATA.TEST ENC ENC.KEY 20:53:58 13 Nov 2026 1
COR.DATA.TEST Enclosure. ENC_KEY...

1             ALPHA           10001
              BETA            10002
1 record listed

LIST ENCLOSURES ENC.VALUE 20:56:44 13 Nov 2026 1
ENCLOSURES Value.....

10001          435.12
10002          123.45
2 records listed

:LIST-ITEM ENCLOSURES
      10001
001 43512

      10002
001 12345

AE DICT COR.DATA.TEST ENC.VALUE ENC.INFO
< 1 > Top of "ENC.VALUE" in "DICT COR.DATA.TEST", 7 lines, 66 characters.
*--: P
001: I
002: TRANS("ENCLOSURES",ENC.KEY,1,"X")
003: MD2,
004: ENC_VALUE
005: 10R
006: MV
007: ENC.INFO

LIST COR.DATA.TEST ENC ENC.KEY ENC.VALUE 21:03:51 13 Nov 2026 1
COR.DATA.TEST Enclosure. ENC_KEY... ENC_VALUE.

1             ALPHA           10001     435.12
              BETA            10002     123.45
1 record listed

 

LIST ENCLOSURES ENC.VALUE 20:56:44 13 Nov 2026 1
ENCLOSURES Value.....

10001          435.12
10002          123.45
2 records listed

:LIST-ITEM ENCLOSURES
      10001
001 43512

      10002
001 12345

AE DICT COR.DATA.TEST ENC.VALUE ENC.INFO
< 1 > Top of "ENC.VALUE" in "DICT COR.DATA.TEST", 7 lines, 66 characters.
*--: P
001: I
002: TRANS("ENCLOSURES",ENC.KEY,1,"X")
003: MD2,
004: ENC_VALUE
005: 10R
006: MV
007: ENC.INFO

LIST COR.DATA.TEST ENC ENC.KEY ENC.VALUE 21:03:51 13 Nov 2026 1
COR.DATA.TEST Enclosure. ENC_KEY... ENC_VALUE.

1             ALPHA           10001     435.12
              BETA            10002     123.45
1 record listed

 

If I have missed something maybe if you show us the actual file structures involved it would help.

 

Rocket Software - Senior Principal Technical Support Engineer - UniData ATS
EliasFernandez
Participating Frequently
Nov 16, 2026 6:20 PM UTC

Jon Card,

 

Thanks, 

 

This is what I get:

 

LIST COR-DATA F20 F21 13:52:17 Nov 16 2026 1
COR-DATA.. ENCLOSURES..... ENC_VALUE...........

WQ6843     MB                             10001
           MB                             10002
           MB                             10003
           MB                             10004
           MB                             10005
           MB                             10006
           MB                             10007
           MB                             10008
           MB                             10009

 

The second column has the internal for  money, dates, etc. These internals are to be translated into external formats via file ENCLOSURE: the structure is

 

<1> Enclosure description.

<2> Conversion code to translate COR-DATA<21> into its external value

ENCLOSURE has these conversion codes

<2> = Conversion code as  MD2; MD2; MD4; MD4; D/; etc.

 

The question is to build a virtual attribute that includes ENCLOSURE<2> in order to have a listing as:

 

WQ6843     MB                             10001
           MB                             100.02  if ENCLOSURE<2> is MD2
           MB                             100.03  if ENCLOSURE<2> is MD2
           MB                             10.004  if ENCLOSURE<2> is MD2
           MB                             1.0005  if ENCLOSURE<2> is MD4
           MB                             10,006.77 if ENCLOSURE<2> is MD2,
           MB                             ETC.

 

I fully appreciate your help,

 

Elias

EliasFernandez
Participating Frequently
Nov 23, 2026 6:40 PM UTC

In  02: SUBR('-OCONVS', F21, TRANS("ENCLOSURE",F20,2,"X"))  the part TRANS("ENCLOSURE",F20,2,"X") works when it deals with dates, but not with number conversion, as in 12345 “MR2” = 123.45

Brian Speirs
Participating Frequently
Nov 25, 2026 3:37 AM UTC

If you really want this type of functionality, you will probably have to write a “User-defined conversion”. See here for some details: https://docs.rocketsoftware.com/bundle/universepickusers_ug_1431/page/topics/guide_for_pick_users/user_exit_codes_qlx1687883591803.html

Say you call your subroutine MDXXX, then you would reference this as:  UMDXXX in the conversion field of your dictionary.

Cheers,

Brian

EliasFernandez
Participating Frequently
Nov 30, 2026 6:24 PM UTC

Thanks, Brian.

 

The interesting thing is that the sub above mentioned works for dates conversions, but not for money, e.g., 10000 to 100.00 through MD2

Why?

 

Thanks again.

Elias

Brian Speirs
Participating Frequently
Dec 1, 2026 9:21 PM UTC

OK. I had a bit of play around, and got the following working. Note that the file names and structures aren't quite the same as yours, but it should be easy to adapt:

list cor.data type ivalue
COR.DATA.. Type. Internal.
Value....
WQ6843 MB1 10001
MB2 10002
MB3 10003
MB4 10004
MB5 10005
MB6 10006
MB7 10007
MB8 10008
MB9 10009

The 'types' are defined in file 'COR.TYPES':

sort cor.types description aconv
COR.TYPES. Type description......... Type......
Conversion
MB1 Type MB1 MR0Z,
MB2 Type MB2 MR1Z,
MB3 Type MB3 MR2Z,
MB4 Type MB4 MR4Z,
MB5 Type MB5 MR13Z,
MB6 Type MB6 DL
MB7 Type MB7 D4-
MB8 Type MB8 MTS
MB9 Type MB9 T2,2

Now, we write a subroutine to do the conversions:

SUBROUTINE COR.VALUE(ans, value, type)
ans = ''
dcv = DCOUNT(value<1>, @VM)
FOR vno = 1 TO dcv
avalue = value<1, vno>
atype = type<1, vno>
aconv = TRANS('COR.TYPES', atype, 2, 'X')
ans<1, vno> = OCONV(avalue, aconv)
IF STATUS() THEN EXIT
NEXT vno
RETURN
END

And write a dictionary item to use the subroutine:

DICT COR.DATA VALUE
1: I
2: SUBR('COR.VALUE', IVALUE, TYPE)
3:
4: Value
5: 12L
6: M
7: A-TV

And now we list the output:

LIST COR.DATA TYPE IVALUE VALUE
COR.DATA.. Type. Internal. Value.......
Value....
WQ6843 MB1 10001 10,001
MB2 10002 1,000.2
MB3 10003 100.03
MB4 10004 1.0004
MB5 10005 10.0
MB6 10006 24 May 1995
MB7 10007 25-05-1995
MB8 10008 02:46:48
MB9 10009 00

I have done this on OpenQM, but it should work just the same on UniData.

Cheers,

Brian

EliasFernandez
Participating Frequently
Dec 2, 2026 3:09 PM UTC

Thanks Brian. Nice.

 

My question was more directed to glitches in UNIDATA supplied utilities. The manual states:

 


For multi-valued fields:


SUBR(’-OCONVS’, expr, conv.code)  

 

where the manufacturer (UNIDATA- ROCKET) may have a bug here (to be reported.)

 


 

Brian Speirs
Participating Frequently
Dec 2, 2026 6:49 PM UTC

I think that what you are wanting is outside the design parameters of the multi-value system.

The point of the ‘S’ functions - like OCONVS - is that they work with a complete set of multi-values at once rather than iteratively working through the values like a PICK system does. And if you are converting all the values at once, that implies you are applying a single conversion code - not a dynamically derived conversion code for each value.

You could perhaps argue that ‘conv.code’ should allow a matching array of conversion codes - but that would be really difficult because ‘conv.code’ can already be multi-valued whereby the ‘expr’ values are converted by each code in succession. If you were to pass an array of conversions to your array of values to be converted, you would need to figure out how to allow multiple conversion codes per value as well as your desired behaviour of having a different set of conversions for each value.

Cheers,

Brian

EliasFernandez
Participating Frequently
Dec 2, 2026 8:37 PM UTC

Whatever it may be, in ONLY FAILS when the conversion code is MD as in MD2  or MD2, or MD4 etc.

CodeFormat
D     System date.   WORKS
MX   Hexadecimal. WORKS
MCL Lowercase  WORKS when given alpha strings
MO Octal. WORKS
MT System time.  WORKS
MCU Uppercase  WORKS when given alpha strings.