Encoding separators
To enable you to set encoding separators for outbound messages, elements (an
ENCODE
keyed list) are added into the
SEPCHARS
keyed list. This makes the new
SEPCHARS
look similar to this example:
{FIELD "XXX"}
{COMPONENT "XXX"}
{ESCAPE "XXX"}
{SEGMENT "XXX"}
{DECIMAL "XXX"}
{ENCODE
{
{FIELD "XXX"}
{COMPONENT "XXX"}
{ESCAPE "XXX"}
{SEGMENT "XXX"}
{DECIMAL "XXX"}
}
}
If you must change the segment separator of an outbound message, then set
the ENCODE.SEGMENT
value in an Xlate
CALL action, as in this example:
set sepchars [xpmmetaget $xlateId SEPCHARS] keylset sepchars
ENCODE.SEGMENT "\r\n"
xpmmetaset $xlateId SEPCHARS $sepchars
You can also set the
ENCODE.FIELD
,
ENCODE.COMPONENT
,
ENCODE.ESCAPE
, and
ENCODE.DECIMAL
values in an Xlate CALL action to encode.
For example, this is for encoding a UN/EDIFACT message using
SEGMENT
"$
" and
FIELD
"#
" in a Tcl
program:
set msgId [msgcreate]
msginsert $msgId "UNH+AA+AUTHOR’BGM++BB’DTM+CC’BUS+DD’"
set seps [msgmetaget $msgId SEPCHARS]
keylset seps ENCODE.FIELD "$"
keylset seps ENCODE.SEGMENT "#"
msgmetaset $msgId SEPCHARS $seps
set grmId [grmcreate -msg $msgId edifact 97B {} AUTHOR]
set msgId [grmencode $grmId]