SCS Control Codes in ASCII Applications

The SNA Character Set (SCS or LU1) printer data stream is a combination of EBCDIC characters and control sequences. Controls are one or more bytes long; some are fixed-length and others are variable-length, with a length byte included in the sequence. Each control sequence begins with a control code byte.

The SCS control code byte values are not printable characters in EBCDIC. However, many of them are printable characters in ASCII, so it is impossible to distinguish them from normal text in the output stream. This is not a problem for a EBCDIC application program, since it will send the normal text as EBCDIC, but currently Enterprise Server for .NET CICS does not support EBCDIC applications.

To enable SCS printing from ASCII applications (the only type supported in this release), Enterprise Server for .NET has mapped several of the SCS control codes to non-printable ASCII values. Programs that use those codes must be changed to use the ASCII alternatives. Typically those codes appear as hard-coded hexadecimal values in a program's data or procedure division. When translating the values, it is important to understand the SCS control sequences, since only the control code value (and not the rest of the sequence for that control code) should be changed.

Example: Single-byte control sequence

The SCS LF (Line Feed) control code is a single-byte sequence: the only byte in the sequence is the LF code itself. The LF code is x'25' in EBCDIC, but in ASCII that code point is the percent symbol ("%"), so we must use a different value in ASCII applications. Enterprise Server for .NET defines SCS LF as x'0a' for ASCII programs.

For example, an application might use the LF control code this way:

01  ws-lf  PIC X VALUE X'25'.
...
PERFORM VARYING ws-idx FROM 1 BY 1 UNTIL ws-idx = ws-idx-max
	EXEC CICS SEND FROM(ws-lines(ws-idx)) LENGTH(78) END-EXEC
	EXEC CICS SEND FROM(ws-lf) LENGTH(1) END-EXEC
END-PERFORM

This code fragment sends a series of lines of output to the printer, with LF codes after each line. In this case, you would identify the use of the x'25' control code in the definition of the ws-lf item and change it to x'0a'.

Example: Variable-length control sequence

SCS uses the TRN (Transparent) control code to send data verbatim to the printer. Applications often use TRN to send printer escape sequences to control printer functions such as font selection and page setup. In SCS the TRN control code is followed by a length byte and a variable number of data bytes. When translating SCS control sequences for ASCII programs, it's important to translate only the control code and not any of the bytes in the rest of the sequence.

The TRN code value is x'35', which is the ASCII "5" character, so for ASCII programs it must be replaced with x'03'. But the length byte N that follows it must be left unchanged, as must the next N bytes.

For example, an application might have a hard-coded printer control sequence in working storage like this:

03  FILLER   PIC X(6)  VALUE   X'35041B283855'.          
03  FILLER   PIC X(7)  VALUE   X'35051B28733050'.        

Those two data items each define an SCS TRN sequence. The first has the control code, a length byte indicating the sequence has 4 more bytes, and the 4 bytes of data. The second is similar but has 5 bytes of data. Here the two sequences are easy to identify because the programmer has made them separate values. However, they could have been entered as a single data item:

03  FILLER   PIC X(6)  VALUE   X'35041B28385535051B28733050'.        

(The x'35' TRN codes have been bolded to show the two control sequences.)

In either case, the two TRN code bytes need to be changed to x'03', but if x'35' happened to appear within the data for either sequence, it would not be changed. So the second example would become:

03  FILLER   PIC X(6)  VALUE   X'03041B28385503051B28733050'.        

This is a case where it is necessary to understand the SCS code sequences in order to translate them correctly.