× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Tom - this looks like it will get me going!

(I was looking at 'Reference Modification' in the meantime, but it appears
to me the length operand cannot be a variable).
move SQL-STATEMENT-TEXT OF QZDA-SQL-FORMAT2 (1:SQL-STATEMENT-TEXT-LEN)
to ...

Thanks!

Scott



Tom Liotta
<qsrvbas@netscape
.net> To
Sent by: cobol400-l@xxxxxxxxxxxx
cobol400-l-bounce cc
s@xxxxxxxxxxxx
Subject
Re: [COBOL400-L] reference to
06/09/2009 04:34 variable fields in IBM copybooks
PM


Please respond to
COBOL Programming
on the
iSeries/AS400
<cobol400-l@midra
nge.com>






Scott Lindstrom wrote:

First - I reference these fields:

LIB-NAME OF QZDA-NDB-FORMAT2 (1)
LIB-NAME OF QZDA-NDB-FORMAT2 (2)
LIB-NAME OF QZDA-NDB-FORMAT2 (3)
LIB-NAME OF QZDA-NDB-FORMAT2 (4)
LIB-NAME OF QZDA-NDB-FORMAT2 (5)

This used to work but the copybook now is defined as:

05 NBR-OF-LIBRARIES PIC S9(00009) BINARY.
* Number of libraries in list
* 05 LIB-NAME PIC X(00010)
* OCCURS xxxxx TIMES.
* Varying number
* of library names

with LIB-NAME commented out. How can I readily access the first 'x'
number
of occurrences of LIB-NAME (up to 5 of them) so I can move these fields
to
the logfile record.

Scott:

This response needs to be short and quick, so I'll give the most
basic answer that I know.

1. Create a simple 77- or 01-level My-Ptr POINTER data item in the
WORKING-STORAGE Section.
2. Create a simple 01-level LIB-NAME pic X(10) item in the LINKAGE
Section.
3. SET My-Ptr TO ADDRESS OF NBR-OF-LIBRARIES
4. SET My-Ptr UP BY LENGTH OF NBR-OF-LIBRARIES

At that moment, My-Ptr should be pointing to the first byte of
whatever comes after NBR-OF-LIBRARIES.

5. SET ADDRESS OF LIB-NAME TO My-Ptr

At that moment, when you now reference LIB-NAME, you get the 10
bytes that follow NBR-OF-LIBRARIES in memory.

5. SET My-Ptr UP BY LENGTH OF LIB-NAME
6. SET ADDRESS OF LIB-NAME TO My-Ptr

You moved the pointer value 10 bytes further into memory; then you
applied that new address to the Linkage definition. At that moment,
when you now reference LIB-NAME, you get the 10 bytes that follow
the previous LIB-NAME in memory.

Each time you increment the pointer by the length of the field and
reassociate the new address, the definition moves forward. The
incrementing will naturally be in a loop controlled by
NBR-OF-LIBRARIES -- you can set the pointer beyond the memory
described by NBR-OF-LIBRARIES, but you don't actually want to use
any value of LIB-NAME from that address.

For the SQL-STATEMENT-TEXT, it's essentially the same. Make sure
it's defined as varying length so that the LENGTH OF fits each new
statement. (I can't recall if you need to add the 2-byte length or
if it's handled.)

Hope that gets you going.

Tom Liotta

--
Tom Liotta
The PowerTech Group, Inc.
19426 68th Avenue South
Kent, WA 98032
Phone 253-872-7788 x313
253-479-1416
Fax 253-872-7904
http://www.powertech.com
--
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing
list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/cobol400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2023 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.