Solved

COBOL - How to copy a table to another one

Posted on 2003-11-20
6
1,177 Views
Last Modified: 2013-11-25
Hi

I need to Know how to copy a table to another one in COBOL

for exemple


I have this table

File definition section

FD  EMPLOYEES
           LABEL RECORDS ARE STANDARD.
01 FD-EMPLOYEE.
  05 EMPLOYEE-ID  PIC X(12) VALUE SPACES.
  05 EMPLOYEE-POINT  PIC 999V9 OCCURS
                                   25 TIMES   VALUE 0.

working storage
WS  EMPLOYEES
01 WS-EMPLOYEE.
  05 EMPLOYEE-ID  PIC X(12) VALUE SPACES.
  05 EMPLOYEE-POINT  PIC 999V9 OCCURS
                                   25 TIMES   VALUE 0.


After I used a perform function to enter the 25 values, how can I copy the WS table to the FD table
0
Comment
Question by:C-begin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 250 total points
ID: 9792622
Oh goodness, this takes me back far too many years.

First off, I would have thought that, since the structures are identical you could just:

MOVE WS-EMPLOYEE TO FD-EMPLOYEE.

If that's not the case, then:

01 POINT-IDX PIC 9(8) COMP.

MOVE EMPLOYEE-ID OF WS-EMPLOYEE to EMPLOYEE-ID OF FD-EMPLOYEE.
PERFORM VARYING POINT-IDX FROM 1 BY 1 UNTIL POINT-IDX>25
               MOVE EMPLOYEE-POINT(POINT-IDX) OF WS-EMPLOYEE TO EMPLOYEE-POINT(POINT-IDX) OF FD_EMPLOYEE.
               END-PERFORM.
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9796651
C-begin,
    I have to agree with cookre, but would like to add that in the perform where you load the first table, you could load the second as well by adding a line similar to the following to the end of it.


    EMPLOYEE-POINT(CURR) OF WS-EMPLOYEE TO EMPLOYEE-POINT(CURR) OF FD_EMPLOYEE


Dang123
0
 
LVL 10

Expert Comment

by:ADSaunders
ID: 9797547
Takes me back too (20 years) but isn't there a MOVE CORRESPONDING statement:
MOVE CORRESPONDING WS-EMPLOYEE TO FD-EMPLOYEE.

.. Alan
0
 
LVL 22

Expert Comment

by:cookre
ID: 9889021
How's it going?
0
 
LVL 10

Expert Comment

by:ADSaunders
ID: 10320316
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Starting up a Project

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question