6.4 Translation Rules for Strings

When planning the interaction between the ATMI platform and host applications, consideration must be given to the programming languages in which the applications are written. A character string is represented differently in the COBOL language than in the C language and associated ATMI platform VIEW buffer. The following listing demonstrates the three ways that the same two strings are coded (string1 and string2).

Listing Three Representations of Strings

C Structure:

struct text
{

       char      rbufsize[5];
       char      testnum[2];
       char      sendnum;
       char      sysid[4];
       char      textfld[10];
       char      string1[10];
       char      string2[16];
};

VIEW text

#type    cname    fbname    count    flag    size    null
char     rbufsize    -        5       -        -      -
char     testnum     -        2       -        -      -
char     sendnum     -        1       -        -      -
char     sysid       -        4       -        -      -
char     textfld     -        10      -        -      -
string   string1     -        1       -        10     -
string   string2     -        1       -        16     -
END

COBOL Record
      01 TEXT.
         05   RBUFSIZEPIC X(5).
         05   TEXTNUMPIC X(2).
         05   SENDNUM PIC X.
         05   SYSID PIC X(4).
         05   STRING1 PIC X(9).
         05   STRING2PIC X(15).

The listing shows that, in the C structure and VIEW buffer, the sizes of string1 and string2 are represented as 10 and 16 characters, respectively. However, in the COBOL record, the sizes are 9 and 15 characters, respectively. This incompatibility can cause code misalignment between C and COBOL programs if not anticipated in the source code.

To avoid such incompatibilities, the Gateway provides a software option to control the mapping of string data between C and COBOL applications. This option enables you to automatically compensate for the differences in null termination and padding characteristics of the two languages.

Note:

The option affects string fields in the ATMI platform VIEW buffers only. STRING buffers are not affected by this switch.