IBM Support

Using the ASCII Transparency (ATRN) SCS Control to Pass ASCII Data to a Printer

Troubleshooting


Problem

This document provides information on using the ASCII Transparency (ATRN) and Transparent (TRN) SCS commands to pass ASCII or hexadecimal data to an ASCII printer.

Resolving The Problem

Note: This document was previously entitled Using SCS Transparency Controls to Pass Unprintable Characters to a Printer.

Caution: The information contained in this document has not been submitted to any formal review and is distributed on an as is basis without any warranty either expressed or implied. The use of this information or the implementation of any of these techniques is a user's responsibility and depends on the user's operational environment. While each item may have been reviewed by IBM for accuracy in a specific situation, there is no guarantee that the same or similar results may be obtained elsewhere. Users attempting to adapt these techniques to their own environment do so at their own risk.

The ASCII Transparency (ATRN) SCS command provides an application direct control over an ASCII printer by imbedding an ASCII printer data stream in an *SCS spooled file. The ASCII Transparency (ATRN) command consists of a X'03' followed by the length of the imbedded ASCII data (not including the X'03' or the length byte itself) specified in hexadecimal, followed by the raw ASCII data that is to be sent to the printer.

The Transparent (TRN) SCS command allows the printing of characters with values of hexadecimal 00 through 3F. The Transparent (TRN) command consists of a X'35' followed by the length of the imbedded hexadecimal data (not including the X'35' or the length byte itself), followed by the hexadecimal data that is to be sent to the printer.

Both the ASCII Transparency (ATRN) and Transparent (TRN) SCS commands allow you to up to 'FF'X or 255 bytes of print data that are not to be checked for printer data stream commands (the print data will be sent to the print "as is") so either command can be used to send ASCII printer commands to a printer.

The ASCII Transparency (ATRN) and Transparent (TRN) SCS commands can be used only when generating a spooled file with the Printer device type (DEVTYPE) parameter set to *SCS. They cannot be used when generating *AFPDS, *LINE, or *AFPDSLINE spooled files. The ATRN and TRN SCS commands cannot be used with *USERASCII spooled files either; *USERASCII spooled files consist of a complete ASCII printer data stream, so using the ATRN or TRN SCS commands would be unnecessary.

This document was last updated on 8 December 2014.

Note: The remainder of this document specifically mentions the ASCII Transparency (ATRN) SCS command, but the information applies to the Transparent (TRN) SCS command as well, except that the code for the TRN command is '35'X, not '03'X.






Unprintable Character Action (RPLUNPRT) Parameter in the Printer File

The data in the ATRN control contains unprintable characters that are below X'40', so the printer file used to generate the spooled file should be overridden or changed so the unprintable characters are not replaced with a printable character, such as a Space (X'40'). This can be done by using the Override with Printer File (OVRPRTF) or Change Printer File (CHGPRTF) command to set the Unprintable character action (RPLUNPRT) parameter to *NO, for example:

OVRPRTF FILE(*PRTF) RPLUNPRT(*NO) OVRSCOPE(*JOB)

CHGPRTF FILE(QSYSPRT) RPLUNPRT(*NO)

    • - Outputting the ASCII Transparency (ATRN) SCS Control in a COBOL Program



      If using COBOL programming, do the transparency data can be defined in the Data Section using the PIC structures. The hex value is represented in X"03xxxxx" (double quotes). This can be done at any level of data definition.


      • - Outputting the ASCII Transparency (ATRN) SCS Control in an RPG Program Using the BITON and BITOF Routines



        This is an example of coding an RPG/400 program to send ASCII transparency using the BITON and BITOF routines. This program allows hex values to be sent to an operating system spooled file. Make sure that the printer file is set up with the Unprintable character action (RPLUNPRT) parameter set to *NO.

        Note: This example works only for internally described PRTFs. External PRTFs should be able to work if the field can accept hex control code values.

        Review an example RPG program in the IBM® Redbooks™ IBM AS/400 Printing II, Section 12.6.2, Coding Font Changes for the 4019. It is using transparency and RPG CVTHXX subroutine.

              ****************************************************************
            FQSYSPRT O   F      19            PRINTER
             * A program to send a data stream to set a D/T4019 such that
             * it will carry out 'BEST FIT' font without giving an
             * operator 'Font Check' error.
             *
             * The data stream must be an ASCII data stream. The structure
             * is defined in the Laser Printer Technical Reference
             * (S5444226), P/N 1039154.
             *
             * As the AS400 is an EBCDIC system, we must precede the ASCII
             * stream by a sequence which instructs the D/T3477 to send the
             * following string unconverted: (X'03LL', where LL is the
             * length of the following string, in binary).
             * the RPLUNPRT parameter set to *NO.
             *
             * The full data stream will be:
             * X'03 11 1B 5B 4B 0C 00 FE 31 01 80 A1 01 8A 04 04 04 04 04'
            E                    CHR        19  1               DATA STREAM
             * Setup binary zeros variable.
            C                     BITOF'0123'    CHAR1   1
             * Initialize array to binary zeroes.
            C                     MOVE CHAR1     CHR
             * 1st 2 chars tell D/T3477 that this is an ASCII stream, to be
             * sent to the printer unconverted.
             * Note:  the bits are numbered 01234567 and read from left to
             *        right.  So turning on bits 6 & 7 => 11 => X'03',
             *        turning on 3 & 7 => 10001 => X'11', etc..
            C                     BITON'67'      CHR,1
            C                     BITON'37'      CHR,2
             * ESC . K
            C                     BITON'3467'    CHR,3
            C                     BITON'13467'   CHR,4
            C                     BITON'1467'    CHR,5
             * Length of following string.
            C                     BITON'45'      CHR,6
             * MODEQ
            C                     BITON'0123456' CHR,8
             * 49
            C                     BITON'237'     CHR,9
             * DSM
            C                     BITON'7'       CHR,10
             * DSOPT1
            C                     BITON'0'       CHR,11
             * DSOPT2 - Default font source. Bit (LAST) sets D/T4019 to
             *          ignore font errors.
             *
            C                     BITON'027'     CHR,12
             * DSOPT3 - Default font source.
            C                     BITON'7'       CHR,13
             * DSOPT4 - Default paper source drawer 2 (BITS 3 and 4).
             * Lower paper tray is tray 1 (BIT 6).
            C                     BITON'046'     CHR,14
             * DSOPT5 - Default forms type for manual paper feed
             *          (value 4 = A4).
            C                     BITON'5'       CHR,15
             * DSOPT6 - Default forms tray 1 (value 4 = A4)
            C                     BITON'5'       CHR,16
             * DSOPT7 - Default forms, tray 2 (value 4 = A4)
            C                     BITON'5'       CHR,17
             * DSOPT8 - Default forms, auto env feed (value 4 =
             *          DL - 4.33 * 8.66)
            C                     BITON'5'       CHR,18
             * DSOPT9 - Default forms, man env feed (value 4 =
             *          DL - 4.33 * 8.66)
            C                     BITON'5'       CHR,19
             * Write to file, and end program
            C                     EXCPTCONDIT
            C                     SETON                    LR
            C            EOJ      TAG                            +++ EOJ
            OQSYSPRT E                CONDIT
            O                         CHR
             ****************************************************************


        • - Outputting the ASCII Transparency (ATRN) SCS Control in an RPG Program Using Hexadecimal Characters and a Hexadecimal String



          This is an example of coding an RPG/400 program to send ASCII transparency using hexadecimal characters and a hexadecimal string. This program allows hex values to be sent to an operating system spooled file, just like the previous example; however, it does it without using the BITON and BITOF routines. As with the above example, make sure that the printer file is set up with the Unprintable character action (RPLUNPRT) parameter set to *NO.

                ************************************************************************
               *
               * THESE EXAMPLES ARE AN ALTERNATIVE TO USING BITON/BITOF FOR EMBEDDING

                * AN ASCII PRINTER DATA STREAM INTO AN OS/400 or i5/OS SPOOLED FILE.
                *
                * THE ISERIES AND AS/400 SYSTEMS ARE EBCDIC SYSTEMS, SO ANY ASCII
                * PRINTER DATA STREAMS MUST BE ENCAPSULATED INTO AN ASCII TRANSPARENCY
                * CONTROL (X'03LL'), WHERE THE LL IS THE LENGTH OF THE FOLLOWING ASCII
                * CHARACTER STRING, IN HEXADECIMAL.
                *
                * ALSO, THE OS/400 or i5/OS PRINTER FILE WHICH IS USED MUST HAVE THE UNPRINTABLE
                * CHARACTER ACTION (RPLUNPRT) PARAMETER SET TO *NO.
                *
               ************************************************************************
               *
               * EXAMPLE 1 -- USING A SERIES OF 1-BYTE HEXADECIMAL (HEX) CONSTANTS
               *
               * THIS IS AN IBM EXAMPLE THAT WAS REWRITTEN BY A CUSTOMER TO ELIMINATE
               * THE OLDER METHOD OF USING THE BITON AND BITOF ROUTINES.  THIS EXAMPLE
               * USES A SERIES OF 1-BYTE HEX CONSTANTS.

                *
              FQSYSPRT O   F     132            PRINTER
               * CHR 1 TELLS 3477 THAT THIS IS AN ASCII STREAM
              I              X'03'                 C         ASCII
               * CHR 2 LENGTH OF STREAM 17 LONG
              I              X'11'                 C         LENGTH
               * CHR 3 ESC KEY
              I              X'1B'                 C         ESC
               * CHR 4 DOLLAR SIGN
              I              X'5B'                 C         DOLLAR
               * CHR 5 DECIMAL POINT
              I              X'4B'                 C         DEC
               * CHR 6 LENGTH OF THE FOLLOWING STRING (12)
              I              X'0C'                 C         LNGTH2
               * CHR 7 UNKNOWN
              I              X'00'                 C         UNKNOW
               * CHR 8 MODEQ
              I              X'FE'                 C         MODEQ
               * CHR 9 FRTYN (DEC 49)
              I              X'31'                 C         FRTYN
               * CHR 10 DSM
              I              X'01'                 C         DSM
               * CHR 11 DSOPT1
              I              X'80'                 C         DSPOP1
               * CHR 12 DSOPT2 DEFAULT FONT SOURCE

                * BIT LAST SETS 4019 TO IGNORE FONT ERRORS
              I              X'A1'                 C         DSPOP2
               * CHR 13 DEFAULT FONT SOURCE
              I              X'01'                 C         FONT
               * CHR 14 DEFAULT PAPER SOURCE DRAWER 2
              I              X'8A'                 C         DWR2
               * CHR 15 DEFAULT FORMS TYPE FOR MANUAL PAPER FEED
              I              X'04'                 C         FTYPE
               * CHR 16 DEFAULT FORMS TRAY 1
              I              X'04'                 C         TRAY1
               * CHR 17 DEFAULT FORMS TRAY 2
              I              X'04'                 C         TRAY2
               * CHR 18 DEFAULT FORMS AUTO ENV FEED
              I              X'04'                 C         AENV
               * CHR 19 DEFAULT FORMS MAN ENV FEED
              I              X'04'                 C         MENV
              C                     EXCPTCONDIT
              C                     MOVE '1'       *INLR
              OQSYSPRT E                CONDIT
              O                         ASCII
              O                         LENGTH
              O                         ESC

               O                         DOLLAR
              O                         DEC
              O                         LNGTH2
              O                         UNKNOW
              O                         MODEQ
              O                         FRTYN
              O                         DSM
              O                         DSPOP1
              O                         DSPOP2
              O                         FONT
              O                         DWR2
              O                         FTYPE
              O                         TRAY1
              O                         TRAY2
              O                         AENV
              O                         MENV
               *
               ************************************************************************
               *
               * EXAMPLE 2 -- USING A SINGLE OF 1-BYTE HEXADECIMAL (HEX) CONSTANTS
               *
               *
               * THIS IS A MUCH SHORTER VERSION THAT CAN BE USED IF YOU WANT TO
               * SEND MULTIPLE STRINGS SUCH AS DIFFERENT FONTS OR BAR CODING.
               *
              FQSYSPRT O   F     132            PRINTER
               * ASCII TRANSPARENCY (ATRN) SCS CONTROL AS A STRING OF CHARACTERS

               I              X'03111B5B4B0C00FE31- C         HEX1
              I               '0180A1018A04040404-

               I               '04'
              C                     EXCPTCONDIT
              C                     MOVE '1'       *INLR
              OQSYSPRT E                CONDIT
              O                         HEX1


          • - TRNSPY (Transparency) DDS Keyword



            The TRNSPY (Transparency) DDS keyword is an option that can be used to embed ASCII printer commands or ASCII text in an ASCII Transparency (ATRN) SCS Control, without having to code for the ATRN control itself. The following information on the TRNSPY DDS keyword has been copied directly from the System i Programming DDS for Printer Files publication:

            7.1http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/rzakd/rzakd.pdf
            6.1http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/rzakd/rzakd.pdf
            5.4http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzakd/rzakd.pdf

            Note: The System i Programming DDS for Printer Files states that this keyword is supported only for the 5224 Printer and 5225 Printer, but it is also supported when using generating a spooled file with DEVTYPE(*SCS) and are using Host Print Transform (HPT) to print to an ASCII dot matrix or laser printer.

            TRNSPY (Transparency) Keyword in Printer Files

            This field-level keyword prevents code points that you have redefined (using the DFNCHR keyword) from being interpreted as SCS printer control commands when your program sends an output operation that prints the field that you are defining.

            This keyword has no parameters.

            If you do not specify the TRNSPY keyword for a field in which your program passes hexadecimal data to an SCS printer, code points can be interpreted as SCS commands that affect printer operation. A code point is one of the 256 values that you can assign to a character in a character set. On the operating system, a code point is identified by a 2-digit hexadecimal number.

            You must specify the TRNSPY keyword when you specify:

            oThe CVTDTA keyword in a printer file created with DEVTYPE(*SCS)
            oA hexadecimal value (with or without the DFT keyword explicitly specified)

            In a file created with DEVTYPE(*IPDS), you need not specify the TRNSPY keyword with the CVTDTA keyword. However, a warning message appears stating that the DEVTYPE should not be changed to *SCS.

            If you specify TRNSPY in a file created with DEVTYPE(*AFPDS), a warning message appears at creation time.

            The TRNSPY keyword is valid only when the data type is character.

            When you specify the TRNSPY keyword with the CVTDTA keyword, your program can place character data in the field. The i5/OS operating system converts it to hexadecimal data when the field is passed to the printer. Each pair of hexadecimal digits corresponds to a code point in the character set of your system. Using the DFNCHR keyword, you can define characters of your own design for the 5224 Printer or the 5225 Printer. Also, the printed length of the field is one-half the length you specify. Therefore, the length of the field must be an even number.

            If you specify the TRNSPY keyword without the CVTDTA keyword, the field length you specify is the printed length.

            This keyword is supported only for the 5224 Printer and the 5225 Printer. Option indicators are not valid for this keyword.

            Examples

            The following examples show how to specify the TRNSPY keyword.

            Example 1

            The following example shows how to specify the TRNSPY keyword with the CVTDTA keyword. When the program passes character data in a field, the operating system converts it to hexadecimal data.

            |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
            00010A          R RECORD                    SPACEB(1)
            00020A            FLD1          10         1TRNSPY CVTDTA
            00030A            FLD2          20         6TRNSPY CVTDTA
                 A

            The program can pass character data in FLD1 and FLD2. The operating system converts it to hexadecimal data for the printer. Only the characters 0 through 9 and A through F are valid. Blanks are not valid.

            The printed length of FLD1 and FLD2 is one-half the specified length (FLD1 is 5 positions long; FLD2 is 10 positions long).

            You must also specify the DFNCHR keyword with this DDS, in order to print user-defined characters.

            The following is how RECORD prints when the contents of FLD1 are ’C1C1C1C1C1’ and the contents of FLD2 are ’C2C2C2C2C2C2C2C2C2C2’:

            AAAAABBBBBBBBBB

            Example 2

            The following example shows how to specify the TRNSPY keyword without the CVTDTA keyword. In this example, your program must pass hexadecimal data in the field.

            |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
            00010A          R RECORD2                   SPACEB(1)
            00020A            FLD3           5         1TRNSPY
            00030A            FLD4          10         6TRNSPY
                A


            The program must pass hexadecimal data in FLD3 and FLD4. Only hexadecimal characters 0 through 9 and A through F are valid. Blanks are not valid. Without the CVTDTA keyword, the printed length of both fields is the specified length.


            Related Concepts

            For more information on the TRNSPY (Transparency) DDS keyword or the CVTDTA (Convert Data) DDS keyword, refer to the System i Programming DDS for Printer Files publication:

            7.1http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/rzakd/rzakd.pdf
            6.1http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/rzakd/rzakd.pdf
            5.4http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzakd/rzakd.pdf


            • - Outputting the ASCII Transparency (ATRN) SCS Control Using the TRNSPY (Transparency) DDS Keyword



              This is an example of coding an externally-described printer file to send an ASCII hexadecimal string using the TRNSPY (Transparency) DDS keyword.

              Coding Examples for the TRNSPY (Transparency) DDS keyword

              |...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
              00010A* COMPILE WITH RPLUNPRT = *NO
              00020A          R #NEWCK
              00030A*
              00040A* Paper source is tray two
              00050A* 1B 26 6C 31 48
              00060A* <esc>&l1H
              00070A                                     1X'1B266C3148'
              00080A                                      TRNSPY
              00090A*
              00100A* Paper orientation is portrait
              00110A* 1B 26 6C 30 4F
              00120A* <esc>&l0O
              00130A                                    10X'1B266C304F'
              00140A                                      TRNSPY
              00150A*
              00160A* Disable perforation skip
              00170A* 1B 26 6C 30 4C
              00180A* <esc>&l0L
              00190A                                    20X'1B266C304C'
              00100A                                      TRNSPY
              00210A*
              00220A* Top margin is line #1
              00230A* 1B 26 6C 31 45
              00240A* <esc>&l1E
              00250A                                    30X'1B266C3145'
              00260A                                      TRNSPY
              00270A*
              00280A* Select line printer font
              00290A* 1B 28 31 32 55 1B 28 73 30 70 31 30
              00300A* 2E 30 30 68 31 32 2E 31 32 76 30 73

              00310A* 30 62 38 30 54
              00320A* <esc>(12U<esc>(s0p10.00h12.12v0s0b80T
              00330A                                    40X'1B266C3145'
              00340A                                      TRNSPY
              00350A*
              00360A* Positioning data
              00370A* 1B 2A 70 35 30 78 35 30 59
              00380A* <esc>*p50x50Y
              00390A                                    60X'1B2A70353078353059'
              00400A                                      TRNSPY
              00410A*
              00420A* Carriage return and line feed
              00430A                                    80X'0D0A'
              00440A                                      TRNSPY
              00450A*
              00460A          R #ENDCK
              00470A*
              00480A* Reset printer
              00490A                                     1
              00500A                                      X'1B45'
              00510A                                      TRNSPY



              For additional information on coding examples from the DDS Reference, refer to the System i Programming DDS for Printer Files publication:

              7.1http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/rzakd/rzakd.pdf
              6.1http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/rzakd/rzakd.pdf
              5.4http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzakd/rzakd.pdf

            [{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]

            Historical Number

            8060018

            Document Information

            Modified date:
            18 December 2019

            UID

            nas8N1010220