National groups
National groups, which are specified either
explicitly or implicitly with the GROUP-USAGE NATIONAL
clause,
contain only data items that have USAGE NATIONAL
.
In most cases, a national group item is processed as though it were
redefined as an elementary category national item described as PIC
N(m)
, where m is the
number of national (UTF-16) characters in the group.
For some operations
on national groups, however (just
as for some operations on alphanumeric groups), group semantics apply.
Such operations (for example, MOVE CORRESPONDING
and INITIALIZE
)
recognize or process the elementary items within the national group.
Where possible, use
national groups instead of alphanumeric groups that contain USAGE
NATIONAL
items. National groups provide several advantages
for the processing of national data compared to the processing of
national data within alphanumeric groups:
- When you move a national group to
a longer data item
that has
USAGE NATIONAL
, the receiving item is padded with national characters. By contrast, if you move an alphanumeric group that contains national characters to a longer alphanumeric group that contains national characters, alphanumeric spaces are used for padding. As a result, mishandling of data items could occur. - When you move a national group to a shorter data item
that has
USAGE NATIONAL
, the national group is truncated at national-character boundaries. By contrast, if you move an alphanumeric group that contains national characters to a shorter alphanumeric group that contains national characters, truncation might occur between the 2 bytes of a national character. - When you move a national group to a national-edited or numeric-edited item, the content of the group is edited. By contrast, if you move an alphanumeric group to an edited item, no editing takes place.
- When you use a national group as an operand in
a
STRING
,UNSTRING
, orINSPECT
statement:- The group content is processed as national characters rather than as single-byte characters.
TALLYING
andPOINTER
operands operate at the logical level of national characters.- The national group operand is supported with a mixture of other national operand types.
By contrast, if you use an alphanumeric group that contains national characters in these contexts, the characters are processed byte by byte. As a result, invalid handling or corruption of data could occur.
USAGE
NATIONAL
groups: A group item can specify the USAGE
NATIONAL
clause at the group level as a convenient shorthand
for the USAGE
of each of the elementary data items
within the group. Such a group is not a national group, however,
but an alphanumeric group, and behaves in many operations, such as
moves and compares, like an elementary data item of USAGE
DISPLAY
(except that no editing or conversion of data occurs).
Assigning values to group data items (MOVE)
Joining data items (STRING)
Splitting data items (UNSTRING)
Tallying and replacing data items (INSPECT)
Using national groups