DBCS-graphic fields using FMTOPT(*MAP) or FMTOPT(*NOCHK)

 

You can use FMTOPT(*MAP) or FMTOPT(*NOCHK) for DBCS-graphic fields. The copy operation is handled differently according to your settings.

When mapping graphic fields to bracketed DBCS fields, shift-out and shift-in characters are added around the DBCS data. When mapping from bracketed-DBCS fields to graphic fields, the shift-out and shift-in characters are removed. For variable-length fields, the graphic field length is expressed in the number of DBCS characters and the bracketed DBCS length is expressed in number of bytes (including the shift-out and shift-in characters). This difference is accounted for when mapping variable-length graphic fields to or from variable bracketed DBCS fields.

When using the CPYF command with FMTOPT(*MAP) to copy a DBCS-open field to a graphic field, a conversion error occurs if the DBCS-open field contains any SBCS data (including blanks). When copying to a graphic field, it might be desirable to ignore trailing SBCS blanks that follow valid DBCS data (in a DBCS-open field). This allows the copy operation to be done without a conversion error. This type of copy can be done using a combination of the OPNQRYF and CPYFRMQRYF commands. The OPNQRYF command is used to remove trailing single-byte blanks and place the data into a variable-length DBCS-open field. The CPYFRMQRYF command with FMTOPT(*MAP) specified is used to copy the variable-length DBCS-open field to the graphic field.

For example, assume the DBCS-open fields in the file named FILEO are copied into graphic fields in the file named FILEG. An additional file (FILEV) must be created.

The DDS for the original from-file FILEO:

******* ************** Beginning of data *****************************
            A          R FMT01
            A            FLD1          10O         CCSID(65535)
            A            FLD2           7O         CCSID(65535)
            A            FLD3          20A ******* ***************** End of data ********************************

DDS for FILEV: This file's format will be specified on the OPNQRYF command FORMAT parameter. The only difference from FILEO is that the DBCS-open fields to be converted to graphic fields are defined to be variable length.

******* ************** Beginning of data *****************************
            A          R FMT01
            A            FLD1          10O         VARLEN CCSID(65535)
            A            FLD2           7O         VARLEN CCSID(65535)
            A            FLD3          20A ******* ***************** End of data ********************************

DDS for the new file FILEG: The graphic fields are defined as fixed length; however, they can be made variable length, if that is what you want.

******* ************** Beginning of data ************************
            A R FMT01 A FLD1 4G CCSID(65535) A FLD2 3G CCSID(65535) A FLD3 20A ******* ***************** End of data ***************************
The following commands are used to copy the data from the DBCS-open fields in FILEO to the graphic fields in FILEG:
CHGJOB CCSID(65535)
OPNQRYF FILE((MYLIB/FILEO)) FORMAT(MYLIB/FILEV *ONLY) MAPFLD((FLD1 '%STRIP(1/FLD1 *TRAIL)') (FLD2 '%STRIP(1/FLD2 *TRAIL)'))
CPYFRMQRYF FROMOPNID(FILEO) TOFILE(MYLIB/FILEG) MBROPT(*REPLACE) FMTOPT(*MAP)

 

Parent topic:

Specifying data for different field types and attributes