Thanks all! It's been working for over a week now <g>. It's one DISPLAY statement in a 200-line test program, and hopefully it's about the last COBOL program I have to write, so hopefully the way I did it (per the first suggestion received here) is good enough.
The below example is more or less the way I was trying to do it before I gave up and asked the question. My COBOL education stopped in about 1980* and so I was vaguely familiar with OCCURS DEPENDING but not the (from : to) substring function. Charles *No Steve, I don't need a class. <g> -----Original Message----- From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED] On Behalf Of Thompson, Steve (SCI TW) Sent: Thursday, October 19, 2006 6:21 AM To: IBM-MAIN@BAMA.UA.EDU Subject: Re: Quick I hope COBOL question -----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. ---------------------------------------------------------------------- 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