Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
The CICS Application Programming Reference (manuals link at the top of the page) is pretty clear:
Quote:
FLENGTH(data-area)
As an input field, FLENGTH specifies, as a fullword binary value, the length of the data to be read. As an output field, FLENGTH returns the length of the data in the container. Whether FLENGTH is an input or an output field depends on which of the INTO, SET, or NODATA options you specify.
INTO option
specified FLENGTH is both an input and an output field.
On input, FLENGTH specifies the maximum length of the data that the program accepts. If the value specified is less than zero, zero is assumed. If the length of the data exceeds the value specified, the data is truncated to that value and the LENGERR condition occurs.
FLENGTH need not be specified if the length can be generated by the compiler from the INTO variable. If you specify both INTO and FLENGTH, FLENGTH specifies the maximum length of the data that the program accepts.
On output (that is, on completion of the retrieval operation) CICS sets the data area, if specified, to the actual length of the data in the container. If the container holds character data that has been converted from one CCSID to another, this is the length of the data after conversion.
Since your code has INTO, FLENGTH is being treated as an input field. The length of data being passed is longer than the length you set in FLENGTH, so you get the LENGERR condition. So you ignore the length error (or whatever you want to do in this case), and the program continues -- it cannot use any of the data in what you called copybook B, but so what? It obviously does not need that data.
FLENGTH(data-area)
As an input field, FLENGTH specifies, as a fullword binary value, the length of the data to be read
As specified in the Manual, FLENGTH specifies the length of the data to be read.
In my case, i have said FLENGTH (LENGTH OF INP-CONTAINER-DATA) . In program B, the length of INP-CONTAINER-DATA is nothing but the length of Copybook A alone.
In the 'INTO' also i have specified only the Copybook A contents. Then why it is giving me LENGTHERR?
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
From my manual post earlier (emphasis added):
Quote:
If the length of the data exceeds the value specified, the data is truncated to that value and the LENGERR condition occurs.
The actual length of the container data is longer than the length you specified in FLENGTH. This causes the LENGERR condition. You can either specify a longer length in FLENGTH, or you can handle the LENGERR condition. CICS can tell that the length of data in the container is longer than your FLENGTH value, so your only other choice would be to not have so much data put in the container.
In your program B, you say the length is the length of INP-CONTAINER-AREA but CICS could tell that the data written (by program A, I assume) was actually longer than you specified. As long as your program B does not reflect the actual, true length of the data written, it will continue to get LENGERR conditions.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
You could try setting FLENGTH to 16777215. LENGERR will continue to occur as long as the length you set is less than the actual length of the container.