-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED] On
Behalf Of Clark Morris
Sent: Wednesday, October 18, 2006 6:17 PM
To: IBM-MAIN@BAMA.UA.EDU
Subject: Re: Quick I hope COBOL question

On 9 Oct 2006 14:24:46 -0700, in bit.listserv.ibm-main you wrote:

>I know this isn't the COBOL list. I'm not a COBOL programmer, so it all
>works out. I'm writing a quick COBOL test program. I've got a PIC X(64)
>field but the actual length of the data in the field is in a separate
S9(4)
>field. I want to display the real data and not whatever garbage might
be
>beyond the real data. Is there any easy way to do this?
DISPLAY Pic-X-64-field (1 : X-64-Actual-data-length).
<SNIP>

You might try something similar to the following:

05 PIC-VAR-MOVE         REDEFINES PIC-X-64-FIELD.
      07 FILLER         PIC X OCCURS DEPENDING ON
                        LENGTH-FIELD-S9.

Change the group level (05) to match the same level as the
PIC-X-64-FIELD. Then the LENGTH-FIELD-S9 becomes the name of the field
having the length in it.

Now this NEW group level, PIC-VAR-MOVE dynamically changes in size to
match the size of the table you have defined. So a MOVE using this as
the source will only move the number of bytes given by the length field.
You might also want to modify this to say "OCCURS 1 TO XX TIMES
DEPENDING ON..." to avoid an overflow condition.

Later,
Steve Thompson

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to