Solved

COBOL - How to copy a table to another one

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 62
VB 6.0 printer how to align 6 57
groupNoAdj 7 83
C# code editing and collaboration 3 98
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
A short article about problems I had with the new location API and permissions in Marshmallow
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

948 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now