Solved

COBOL - How to copy a table to another one

Posted on 2003-11-20
6
1,145 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 87
Windows and other UI names - The Proper names for the Various elements! 1 120
AutoIncrement column based of FK 11 64
Java Inheritance super keyword use 8 40
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This is an explanation of a simple data model to help parse a JSON feed
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

730 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