Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Moving a occurs array of 30 chars to occurs array of 20

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

New User


Joined: 19 Dec 2009
Posts: 16
Location: Mumbai

PostPosted: Wed Aug 31, 2011 5:41 pm    Post subject: Moving a occurs array of 30 chars to occurs array of 20
Reply with quote

Hi,

i needed a solution for a problem.

I have table1
Code:

W-TABLE1 OCCURS 10                         
                            INDEXED BY W-TABLE1-IND.     
       07 W-field1                         PIC X(30).



and table2
Code:

W-TABLE2 OCCURS 15                         
                            INDEXED BY W-TABLE2-IND.     
       07 W-field2                         PIC X(20).



Now i have to move table1 data to table2 in such a way that 1st 20 of table 1 should be moved to 1st of table2 and the reamining 10 of table1 to the next element in table2, and then start with second record of table1 such that it fits in the reamining 10 of table2, and so on.

Please suggest me a solution for this. I have a bigger table than this which will contains data upto 4000 characters.


I have thought of pseudocode of first moving table1 to a string with length of 600 then cutting the slices and moving into table2. But for my actual length of 4000 i fear the string might be too long.

Thanks in advance..
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 31, 2011 6:09 pm    Post subject:
Reply with quote

you are accomplishing nothing by placing the OCCURS clause on the high level element.

typical rookie 'save a couple lines of typing' trick.

define you working-storage as:
Code:

01  BIG-AREA.
    03 TABLE-1-AREA.
       05  W-TABLE1                OCCURS 10
                                   INDEXED BY W-TABLE1-IND.
           07  W-FIELD1            PIC X(30).
    03 TABLE-1-AREA-RED
       REDEFINES
       TABLE-1-AREA.
       05  W-TABLE1A.
           07  W-FIELD1A           OCCURS 15
                                   INDEXED BY W-TABLE1A-IND
                                   PIC X(20).
    03 TABLE-2-AREA.
       05  W-TABLE2                OCCURS 15
                                   INDEXED BY W-TABLE2-IND.
           07  W-FIELD2            PIC X(30).


then your code is easy:
Code:

PERFORM VARYING W-TABLE1A-IND
           FROM 1
             BY 1
          UNTIL W-TABLE1A-IND > 15
   SET W-TABLE2-IND  TO W-TABLE1A-IND
   MOVE W-FIELD1A  (W-TABLE1A-IND)
     TO W-FIELD2   (W-TABLE2-IND)
END-PERFORM


you were trapped by your inability to professionally define Working-Storage
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Aug 31, 2011 6:15 pm    Post subject:
Reply with quote

I suggest you pre process this file in SORT

If you have DFSORT installed at your shop RESIZE operator will do this job very easily.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1218
Location: Israel

PostPosted: Wed Aug 31, 2011 6:17 pm    Post subject: Reply to: Moving a occurs array of 30 chars to occurs array
Reply with quote

Levels of W-TABLE1 and W-TABLE2 is missing.
I will assume they are not at level 01:
Code:
01  W-TABLE1-AREA.
    03 W-TABLE1 OCCURS 10                         
                            INDEXED BY W-TABLE1-IND.     
       07 W-field1                         PIC X(30).

01  W-TABLE2-AREA.
    03 W-TABLE2 OCCURS 15                         
                            INDEXED BY W-TABLE2-IND.     
       07 W-field2                         PIC X(20).

PROCEDURE DIVISION.
...
    MOVE W-TABLE1-AREA TO W-TABLE2-AREA !!!
That should do the trick !!! (and correct me if I am wrong)
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Aug 31, 2011 6:29 pm    Post subject:
Reply with quote

Quote:
That should do the trick !!!
Yes .. That should..
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1218
Location: Israel

PostPosted: Wed Aug 31, 2011 6:48 pm    Post subject:
Reply with quote

rackshit wrote:
I have a bigger table than this which will contains data upto 4000 characters.

Now we have to see if this solution fits the real definition...
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Aug 31, 2011 8:05 pm    Post subject: Reply to: Moving a occurs array of 30 chars to occurs array
Reply with quote

As Marso has pointed out, each of the tables is 300 bytes long. Just move one to the other.

This will work with whatever size tables or items the compiler allows, which you can check in the manual but I'm sure they will be sufficient for any requirment that you have.
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 51
Location: New York

PostPosted: Wed Aug 31, 2011 8:12 pm    Post subject:
Reply with quote

When someone CANNOT see what MARSO saw -- I wonder why Mr. Rackshit has a job (I assume) and so many of my friends are out of work. A simple understanding of how our templates (01 group levels and 05, 10, 15 elementary levels) form and reform the data items that we deal with -- doesn't seem to be in Mr. Rackshit's question.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Aug 31, 2011 8:45 pm    Post subject: Reply to: Moving a occurs array of 30 chars to occurs array
Reply with quote

Plus, even you don't need the data simultaneously, you can just use REDEFINES and no MOVEs at all.
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 51
Location: New York

PostPosted: Wed Aug 31, 2011 10:04 pm    Post subject:
Reply with quote

WOW -- I guess we get caught up in seeing things ONLY one way.

icon_redface.gif


No moves, just redefines --- saves TIME spent moving data around
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Sep 01, 2011 12:24 pm    Post subject:
Reply with quote

Still wondering about the purpose of the question. Did a 20-byte table get loaded, then "used" as a 30-byte table (like in a sub-program), then need to get "put back" to it's original state?

Looking back, I see dbz got the redefines first and then (maybe, I'm no mind-reader, can only intuit) decided TS must then want to do something with the 20-byte data, so stuffed it into a new 30x15 table. I should have looked at the code, not just dismiss it when I saw the loop.
Back to top
View user's profile Send private message
rackshit

New User


Joined: 19 Dec 2009
Posts: 16
Location: Mumbai

PostPosted: Thu Sep 01, 2011 1:49 pm    Post subject: Reply to: Moving a occurs array of 30 chars to occurs array
Reply with quote

Thanks All, for your valuable answers i ve got answer to my question although I had not put the tables in correct way ..

as far as the need is concerned, below is the need:

i have IMS db where one segment has one field with length of 30 and this same field is to be copied to another segment with field having length of 20. And the information which is to be copied/updated is distributed across no. of occurrences of 30 length variable. So first it is unloaded in table1 and then when the information is contiguous i will redefine as said above to table2 and update it in segment2 across successive fields of length 20 (for different occurrences).

at the time of its creation decades back this database had the above layout. the segment having field of 30 length is a kind of lookup table and the segment having field of length 20 is actually data stored.

Still in coding phase, will put problems and solutions of wat m doing/find while i move to compilation and testing.. watch out for this space..

Aim is learning and sharing !! Thanks
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 Moving a PD to PD spoorni DFSORT/ICETOOL 8 Fri Oct 07, 2016 9:52 pm
No new posts Moving character data to smallint in db2 rikdeb DB2 5 Thu Jul 14, 2016 12:38 am
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts MOVING COMP-3 into binary akodakka COBOL Programming 2 Tue Dec 01, 2015 5:02 pm
No new posts CICS- Moving to High availability vicky10001 CICS 8 Fri Oct 23, 2015 7:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us