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.
******* ************** Beginning of data ***************************** A R FMT01 A FLD1 10O CCSID(65535) A FLD2 7O CCSID(65535) A FLD3 20A ******* ***************** End of data ********************************
******* ************** Beginning of data ***************************** A R FMT01 A FLD1 10O VARLEN CCSID(65535) A FLD2 7O VARLEN CCSID(65535) A FLD3 20A ******* ***************** End of data ********************************
******* ************** Beginning of data ************************ A R FMT01 A FLD1 4G CCSID(65535) A FLD2 3G CCSID(65535) A FLD3 20A ******* ***************** End of data ***************************
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)