You can use variable-length fields in combination with DBCS-graphic data types, to specify variable-length DBCS-graphic data. To specify variable-length DBCS-graphic data, specify *VARCHAR and *PICXGRAPHIC for the CVTOPT parameter of the CRTCBLMOD or CRTBNDCBL commands, or the VARCHAR and CVTPICXGRAPHIC options for the PROCESS statement.
If you specify any of the following: CVTOPT(*NOVARCHAR *NOPICGGRAPHIC), CVTOPT(*NOVARCHAR *PICGGRAPHIC), CVTOPT(*NOVARCHAR *NOPICXGRAPHIC) or CVTOPT(*NOVARCHAR *PICXGRAPHIC) and the ILE COBOL compiler encounters a variable-length DBCS-graphic data item, the resulting program contains the following:
06 FILLER PIC X(2n+2). * (Variable-length field)
where n is the number of characters in the DDS field.
If you specify CVTOPT(*VARCHAR *NOPICGGRAPHIC) or CVTOPT(*VARCHAR *NOPICXGRAPHIC), and the ILE COBOL compiler encounters a variable-length DBCS-graphic data item, the resulting program contains the following:
06 NAME * (Variable-length field) 49 NAME-LENGTH PIC S9(4) COMP-4. * (Number of 2-byte characters) 49 FILLER PIC X(2n).
where n is the number of DBCS characters in the DDS field.
If you specify CVTOPT(*VARCHAR *PICXGRAPHIC), and the ILE COBOL compiler encounters a variable-length DBCS-graphic data item, the resulting program contains the following:
06 NAME * (Variable-length field) 49 NAME-LENGTH PIC S9(4) COMP-4. * (Number of 2-byte characters) 49 NAME-DATA PIC X(2n).
where n is the number of DBCS characters in the DDS field.
If you specify CVTOPT(*VARCHAR *PICGGRAPHIC), and the ILE COBOL compiler encounters a variable-length DBCS-graphic data item, the resulting program contains the following:
06 NAME * (Variable-length field) 49 NAME-LENGTH PIC S9(4) COMP-4. * (Number of 2-byte characters) 49 NAME-DATA PIC G(n) DISPLAY-1.
where n is the number of DBCS characters in the DDS field.
Figure 111 shows an example of a DDS file that defines a variable-length DBCS-graphic data item. Figure 112 shows the ILE COBOL program using a Format 2 COPY statement with *PICXGRAPHIC and the resulting listing when the program is compiled. Figure 113 shows the ILE COBOL program using variable length DBCS-graphic data items with *PICGGRAPHIC.
Figure 111. DDS File Defining a Variable-Length Graphic Data Field
....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R SAMPLEFILE A* A VARITEM 100 VARLEN A* A TIMEITEM T TIMFMT(*HMS) A DATEITEM L DATFMT(*YMD) A TIMESTAMP Z A* A GRAPHITEM 100G A VGRAPHITEM 100G VARLEN |
Figure 112. ILE COBOL Program Using Variable-Length DBCS-Graphic Data Items and *PICXGRAPHIC
5722WDS V5R3M0 030905 LN IBM ILE COBOL CBLGUIDE/PGM1 ISERIES1 03/09/15 14:31:24 Page 2 S o u r c e STMT PL SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 000100 process varchar datetime cvtpicxgraphic 1 000200 Identification division. 2 000300 Program-id. pgm1. 000400 3 000500 Environment division. 4 000600 Configuration section. 5 000700 Source-computer. ibm-iSeries 6 000800 Object-computer. ibm-iSeries 7 000900 Input-output section. 8 001000 File-control. 9 001100 Select file1 10 001200 assign to database-samplefi 00/08/15 11 001300 organization is sequential 12 001400 access is sequential 13 001500 file status is fs1. 001600 14 001700 Data division. 15 001800 File section. 16 001900 fd file1. 17 002000 01 record1. 002100 copy dds-all-formats of samplefi. 00/08/15 18 +000001 05 SAMPLEFI-RECORD PIC X(546). <-ALL-FMTS +000002* I-O FORMAT:SAMPLEFILE FROM FILE SAMPLEFI OF LIBRARY CBLGUIDE <-ALL-FMTS +000003* <-ALL-FMTS 19 +000004 05 SAMPLEFILE REDEFINES SAMPLEFI-RECORD. <-ALL-FMTS 20 +000005 06 VARITEM. <-ALL-FMTS +000006* (Variable length field) <-ALL-FMTS 21 +000007 49 VARITEM-LENGTH PIC S9(4) COMP-4. <-ALL-FMTS 22 +000008 49 VARITEM-DATA PIC X(100). <-ALL-FMTS 23 +000009 06 TIMEITEM PIC X(8). <-ALL-FMTS +000010* (Time field) <-ALL-FMTS 24 +000011 06 DATEITEM PIC X(8). <-ALL-FMTS +000012* (Date field) <-ALL-FMTS 25 +000013 06 TIMESTAMP PIC X(26). <-ALL-FMTS +000014* (Timestamp field) <-ALL-FMTS 26 +000015 06 GRAPHITEM PIC X(200). <-ALL-FMTS +000016* (Graphic field) <-ALL-FMTS 27 +000017 06 VGRAPHITEM. <-ALL-FMTS +000018* (Variable length field) <-ALL-FMTS 28 +000019 49 VGRAPHITEM-LENGTH <-ALL-FMTS +000020 PIC S9(4) COMP-4. <-ALL-FMTS +000021* (Number of 2 byte Characters) <-ALL-FMTS 29 +000022 49 VGRAPHITEM-DATA PIC X(200). <-ALL-FMTS +000023* (Graphic field) <-ALL-FMTS 30 002200 Working-Storage section. 31 002300 77 fs1 pic x(2). 002400 32 002500 Procedure division. 002600 Mainline. 33 002700 stop run. * * * * * E N D O F S O U R C E * * * * * |
Figure 113. ILE COBOL Program Using Variable-Length DBCS-Graphic Data Items and *PICGGRAPHIC
5722WDS V5R3M0 030905 LN IBM ILE COBOL CBLGUIDE/DBCSPICG ISERIES1 03/09/05 14:48:02 Page 3 S o u r c e STMT PL SEQNBR -A 1 B..+....2....+....3....+....4....+....5....+....6....+....7..IDENTFCN S COPYNAME CHG DATE 000100 process varchar datetime cvtpicggraphic 00/08/21 1 000200 Identification division. 2 000300 Program-id. dbcspicg. 00/08/21 000400 3 000500 Environment division. 4 000600 Configuration section. 5 000700 Source-computer. ibm-iSeries 6 000800 Object-computer. ibm-iSeries 7 000900 Input-output section. 8 001000 File-control. 9 001100 Select file1 10 001200 assign to database-samplefi 00/08/15 11 001300 organization is sequential 12 001400 access is sequential 13 001500 file status is fs1. 001600 14 001700 Data division. 15 001800 File section. 16 001900 fd file1. 17 002000 01 record1. 002100 copy dds-all-formats of samplefi. 00/08/15 18 +000001 05 SAMPLEFI-RECORD PIC X(546). <-ALL-FMTS +000002* I-O FORMAT:SAMPLEFILE FROM FILE SAMPLEFI OF LIBRARY CBLGUIDE <-ALL-FMTS +000003* <-ALL-FMTS 19 +000004 05 SAMPLEFILE REDEFINES SAMPLEFI-RECORD. <-ALL-FMTS 20 +000005 06 VARITEM. <-ALL-FMTS +000006* (Variable length field) <-ALL-FMTS 21 +000007 49 VARITEM-LENGTH PIC S9(4) COMP-4. <-ALL-FMTS 22 +000008 49 VARITEM-DATA PIC X(100). <-ALL-FMTS 23 +000009 06 TIMEITEM PIC X(8). <-ALL-FMTS +000010* (Time field) <-ALL-FMTS 24 +000011 06 DATEITEM PIC X(8). <-ALL-FMTS +000012* (Date field) <-ALL-FMTS 25 +000013 06 TIMESTAMP PIC X(26). <-ALL-FMTS +000014* (Timestamp field) <-ALL-FMTS 26 +000015 06 GRAPHITEM PIC G(100) DISPLAY-1. <-ALL-FMTS +000016* (Graphic field) <-ALL-FMTS 27 +000017 06 VGRAPHITEM. <-ALL-FMTS +000018* (Variable length field) <-ALL-FMTS 28 +000019 49 VGRAPHITEM-LENGTH <-ALL-FMTS +000020 PIC S9(4) COMP-4. <-ALL-FMTS +000021* (Number of 2 byte Characters) <-ALL-FMTS 29 +000022 49 VGRAPHITEM-DATA PIC G(100) DISPLAY-1. <-ALL-FMTS +000023* (Graphic field) <-ALL-FMTS 30 002200 Working-Storage section. 31 002300 77 fs1 pic x(2). 002400 32 002500 Procedure division. 002600 Mainline. 33 002700 stop run. * * * * * E N D O F S O U R C E * * * * * |
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.