Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
efficient table copy in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 31
Location: brisbane

PostPosted: Sun May 26, 2013 4:32 am    Post subject: efficient table copy in COBOL
Reply with quote

Hi,

I need to initialize a 64x64 table with constant values, each being in range 00 to 63. My target data structure (which I CAN'T change) looks like:

Code:
01  OUT-GROUP-MULT-1-0001RG.
    03 OUT-GROUP-MULT-1-0001MA   PIC S9(4)
    03 OUT-GROUP-MULT-1-0001MX   REDEFINES
       OUT-GROUP-MULT-1-0001MA   PIC X(4).
    03 OUT-GROUP-MULT-1-0001   OCCURS 64.
       05 OUT-GROUP-MULT-1-0001AC  PIC X(1).
       05 OUT-GROUP-MULT-2-0002RG.
         07  OUT-GROUP-MULT-2-0002MA PIC S9(4).
         07  OUT-GROUP-MULT-2-0002MX REDEFINES
                OUT-GROUP-MULT-2-0002MA PIC X(4).
         07  OUT-GROUP-MULT-2-0002  OCCURS 64.
            09  OUT-GROUP-MULT-2-0002AC  PIC X(1)
            09  OUT-GROUP-MULT-ITEM-0001EV.
               11  IEF-SUPPLIED-0001ET.
                  13 COUNT-0001AS  PIC X(1).
                  13 COUNT-0001   PIC S9(9). <====THIS IS WHERE THE VALUES GO.
                  13 COUNT-0001XX REDEFINES COUNT-0001 PIC X(9).



this table get's initialized, and then i need to map the constant values into count-0001.


my approach is do initialize a simpler structure, then copy from this to the target. Eg use something like:


Code:
       01  RS1-TABLE.
* there will be 128 filler rows
            05  FILLER   PIC X(32)     VALUE "14323555......3223".
            05  FILLER   PIC X(32)     VALUE "01020304......6565".
            05  FILLER   PIC X(32)     VALUE "84854954......6544".
...   
            05  FILLER   PIC X(32)     VALUE "01020366......0910".
        01  RS2-TABLE REDEFINES RS1-TABLE
            05  RS2-ROW OCCURS 64 TIMES.
                10  RS2-COL OCCURS 64 TIMES.
                    15  RS2-VALUE  PIC 99.



This will probably work OK, but is there a more elegant / more efficient solution?

Code'd and aligned somewhat
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Sun May 26, 2013 1:21 pm    Post subject: Reply to: efficient table copy in COBOL
Reply with quote

Please use the Code tags to preserve space, use the Preview button to review until correct before posting. Do not use tabs.

All three tables are different lengths. The values that you have are for what purpose? I may be being dense, but I don't see how anything in your second table (except OCCURS 64) relates to your first table.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Sun May 26, 2013 6:34 pm    Post subject:
Reply with quote

In COBOL, you can intiialize a table manually (which in your case would require 4096 MOVE statements per variable), or use VALUE statements as you have posted, or you can read the table values from a file and load them into the table. Your posted solution is as good as the other two.

Quote:
This will probably work OK, but is there a more elegant / more efficient solution?
Elegance is in the eye of the beholder, so that part of your question is not answerable. And in this time of mainframes running tens of millions to hundreds of millions of COBOL statements per second of CPU time, why would you even think of efficiency at this point? The ONLY time you should EVER be concerned with efficiency is if the program is not completing within the amount of time it has for execution -- period.
Back to top
View user's profile Send private message
AntonioS

New User


Joined: 27 Mar 2012
Posts: 8
Location: EU

PostPosted: Sun May 26, 2013 7:07 pm    Post subject: Reply to: efficient table copy in COBOL
Reply with quote

As Bill already stated, in the code you posted, the field formats do not match. This means that you would fill your array element by element at its lowest level which I find neither elegant nor efficient. :-)

My approach would be to use loop to fill the first 64 inner elements, then move the first outer element to the remainder of the array, like so:

Code:
 
repeat varying i-inner from 1 by 1
until i-inner > 64
  compute COUNT-0001 (1 i-inner) = i-inner - 1
end-repeat

repeat varying i-outer from 2 by 1
until i-outer > 64
  move OUT-GROUP-MULT-2-0002 (1) to OUT-GROUP-MULT-2-0002 (i-outer)
end-repeat



An additional structure would not necessarily be required for this. Of course, if you need to do the initialization multiple times, it may be advisable to use an additional structure, so the first loop needs to be executed only once.

HTH!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us