Solved

COBOL - How to copy a table to another one

Posted on 2003-11-20
6
1,116 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

777 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