×
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.
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
As an Amazon Associate we earn from qualifying purchases.