On 25/08/2007, at 8:41 AM, Walden H. Leverich wrote:

I know I can create a UUID using the _GENUUID mi function, and as
expected, that will return a 16-A field w/a UUID in it. However, I'd
like to store that as a character string in a table, preferable with the
"standard" format of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, like:
C7408D2A-973C-432A-A31A-ED98A88A9115, but just as hex characters would
be ok too, no dashes. Anyone have a simple way to accomplish this?

Since you are already using an MI function (well, built-in really) to generate the UUID use MI to convert to a hex string via CVTHC. That's step 1. Step 2 is to substring and concatenate to insert the dashes.

H OPTION(*SRCSTMT : *NODEBUGIO)
H DFTACTGRP(*NO) BNDDIR('QC2LE')

/copy rpgleinc,migenuuid
/copy rpgleinc,micvthc

D UUID_String S 36

/free
UUID_Bytes_Prov = %SIZE(UUID_Template_T);
UUID_Rsvd = *ALLX'00';
genUUID( UUID_Template_T );
cvthc( %ADDR(UUID_String) : %ADDR(UUID_UUID) : %LEN(UUID_UUID)*2 );
UUID_String = %SUBST(UUID_String:01:08) + '-' +
%SUBST(UUID_String:09:04) + '-' +
%SUBST(UUID_String:13:04) + '-' +
%SUBST(UUID_String:17:04) + '-' +
%SUBST(UUID_String:21:12);
dsply UUID_String;
/end-free

C SETON LR

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.