Solved

COBOL - How to copy a table to another one

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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 …

747 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

9 Experts available now in Live!

Get 1:1 Help Now