Why not simply create the table with the number of rows already in it:

TABLE    CSECT
TABLERWS DC   Y(ROWCOUNT)
TABLEELN DC   Y(ROWLEN)
ROWLEN   EQU  80               (or whatever length you want)
TABLETBL DS   0H
         DC   CL(ROWLEN)'row 1'
         DC   CL(ROWLEN)'row 2'
         .
         .
         .
         DC   CL(ROWLEN)'last row'
ROWCOUNT EQU  (*-TABLETBL)/ROWLEN


Then, when the table is loaded and the address is available, simply equate the 
address to a value in the linkage section defined like this:

01  MYTABLE.
    05  TABLE-ROW-COUNT      PIC  S9(04) COMP.
    05  TABLE-ROW-SIZE       PIC  S((04) COMP.
    05  TABLE-ROW            OCCURS 1 TO you-supply-the-value
                             DEPENDING ON TABLE-ROW-COUNT.
        10  TABLE-ROW-DATA   PIC X(01)
                             OCCURS 1 TO you-supply-the-value
                             DEPENDING ON TABLE-ROW-SIZE.

Now the table is variable in row count and relatively "fixed length" by the 
setting of the TABLE-ROW-SIZE variable. I assume (careful there) that your 
table rows are fixed in nature? If not, then the definition gets a bit more 
complex, but should still be doable in COBOL.

Chuck

Charles (Chuck) Hardee
Senior Systems Engineer/Database Administration
EAS Information Technology

Thermo Fisher Scientific
300 Industry Drive | Pittsburgh, PA 15275
Phone +1 (724) 517-2633 | Mobile +1 (412) 877-2809 | FAX: +1 (412) 490-9230
[email protected]  | www.thermofisher.com

WORLDWIDE CONFIDENTIALITY NOTE: Dissemination, distribution or copying of this 
e-mail or the information herein by anyone other than the intended recipient, 
or an employee or agent of a system responsible for delivering the message to 
the intended recipient, is prohibited. If you are not the intended recipient, 
please inform the sender and delete all copies.


-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of Victor Gil
Sent: Thursday, December 10, 2015 10:42 AM
To: [email protected]
Subject: Re: Review My Program

David,

I really like your idea of such an Assembler suffix [never thought of it, 
prefix - yes, but suffix?] as the load point still points to the table top.

However, when such a "compiled table" also needs to be updatable [i.e. linked 
NORENT as RENT would load it into write-protected storage], placing executable 
instructions in it may only worsens the "step-on" exposure.

-Victor-        

============================================
I think the LE compliant Assembler wrapper is way over-the-top for this.
LE compliant Assembler is *vital* of course when *it* calls an LE-compliant
subroutine, but when Assembler is the callee and the code is *very* short
and simple, the overhead really serves no purpose.

I'd also make your assembler code a prefix to the table itself rather than
a separate module.  You describe the table as "... assembler" so you can
easily add a tiny bit of code to the table itself which can then tell COBOL
everything it needs to know -> table address, length, number of rows,
length of each row, etc, whatever you like.  All that information can
easily be determined at assembly time and returned to COBOL, thus not
obliging the caller to figure them out (and possibly getting them wrong!).
Now, instead of calling something else to load the table, you just call the
table itself, dynamically, which then both loads it *and* tells you
everything you need to know about it.
To accomplish what your example describes, you just need the table address
and number of rows.  So, assuming those criteria, I offer the the following
simplified example which does exactly the same thing:

IDENTIFICATION DIVISION.
PROGRAM-ID.  SIZETST.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  TABLE-DATA.
    05 TABLE-ADDRESS POINTER.
    05 ROWCNT PIC S9(9) COMP.
    05 XML1V2K PIC X(8) VALUE 'XML1V2K'.
LINKAGE SECTION.
01  MYTAB.
    05 MYROW PIC X(80)
    OCCURS 1 DEPENDING ON ROWCNT INDEXED BY ROWNBR.
PROCEDURE DIVISION.
    CALL XML1V2K USING TABLE-DATA
    SET ADDRESS OF MYTAB TO TABLE-ADDRESS
    PERFORM VARYING ROWNBR FROM 1 BY 1 UNTIL ROWNBR > ROWCNT
      DISPLAY MYROW(ROWNBR)
    END-PERFORM
    GOBACK.

Here is a sample table of nine 80-byte rows, with that "tiny bit" of
assembler code at the end which gives COBOL needs.

XML1V2K CSECT
XML1V2K RMODE ANY
ROW1 EQU *
  DC CL80'ROW1'
ROW2 EQU *
  DC CL80'ROW2'
  DC CL80'ROW3'
  DC CL80'ROW4'
  DC CL80'ROW5'
  DC CL80'ROW6'
  DC CL80'ROW7'
  DC CL80'ROW8'
  DC CL80'ROW9'
END  EQU *
TSIZ EQU END-ROW1
RSIZ EQU ROW2-ROW1
INIT CSECT
INIT RMODE ANY
     USING INIT,15
     L   1,0(,1)     R1 -> AREA TO RECEIVE TABLE ADDRESS, NBR OF ROWS
     LM  15,0,TBL@   R15 = TABLE ADDRESS, R0 = NBR OF ROWS
     STM 15,0,0(1)   STORE IN CALLERS RECEIVE AREA
     SR  15,15       SET R15 = 0
     BR  14          RETURN
TBL@ DC  A(ROW1)     ADDRESS OF FIRST ROW (I.E. TABLE ADDRESS)
ROWS DC  A(TSIZ/RSIZ) NBR OF ROWS = TABLE SIZE MINUS ROW SIZE
     END INIT

Note that the END INIT statement sets the entry point to INIT, the
assembler suffix code, but the load point (start of table) remains the
same.

Reply via email to