-2

I am trying to get this move statement in 01-WS-PRINT REC to work but for some reason when i compile it says "MOVE" was invalid. Scanning was resumed at next....Thoughts?

01  WS-PRINT-REC
   10 M-DESC   PIC X(25).
   10 FILLER   PIC X(02).
   10 M-DATA   PIC X(25).
   MOVE 'STOCK SYMBOL' TO M-DESC.
   MOVE MK-SYMBOL TO M-DATA.
   PERFORM 700-PRINT-LINE.
Rob
  • 57
  • 9
  • I don't know cobol, but do you need a period after `MOVE MK-SYMBOL TO M-DATA`? – ooga Oct 27 '14 at 21:52
  • Thanks it wasnt that though – Rob Oct 27 '14 at 21:53
  • 1
    You can't put code in the working-storage section. – user207421 Oct 27 '14 at 22:06
  • 1
    Procedure code needs to be in the `PROCEDURE DIVISION`. Data definitions in the `DATA DIVISION`, and from the look of your data-names the `WORKING-STORAGE SECTION` within that. – Bill Woodger Oct 27 '14 at 22:17
  • 1
    If the code you have shown is contiguous, then you simply haven't understood the layout of a COBOL program so are destined for a Close as "simple typographical error". If the code is not contiguous, we need to see the separation and the exact error message, with the message number. Take those full-stop/periods off your procedure code, please. They've been out-of-date since 1985. – Bill Woodger Oct 27 '14 at 22:50
  • 1
    I've attempted to compile your code as shown. There is a full-stop/period missing from the end of the `01`. The `MOVE` indeed gets that message, as does the second `MOVE` and the `PERFORM`. You have colleagues. I suggest you ask for a simple working CICS program and use that as a base for what you want. Compare it to what you have. You've either never done a COBOL course, or you need a refresher. – Bill Woodger Oct 27 '14 at 23:09
  • 1
    To modify my earlier comment, use the full-stop/period style in the PROCEDURE DIVISION which is in use at your site for new. Some places are still stuck in the early 1980's, but consistency amongst programs is better than a mishmash. – Bill Woodger Oct 27 '14 at 23:11
  • 1
    I don't know how you got one Upvote for this, let alone two. If it is friend being kind, ask them to stop, please. – Bill Woodger Oct 28 '14 at 09:24

1 Answers1

3

COBOL programs are structured. There is a data division (divided in a working-storage section and a local-storage section). Your data declarations should be done there. Then you have a procedure division where you put your code (here the move statement).

You can't use "MOVE" in a data division. As you can't declare variable in a procedure division.

Moreover, as previously said, you shouldn't use a period at the end of each sentence.

For instance :

DATA DIVISION.
WORKING-STORAGE DIVISION.
01  WS-PRINT-REC
   10 M-DESC   PIC X(25).
   10 FILLER   PIC X(02).
   10 M-DATA   PIC X(25).

PROCEDURE DIVISION.

MAIN.

   MOVE 'STOCK SYMBOL'   TO M-DESC
   MOVE MK-SYMBOL        TO M-DATA

   PERFORM 700-PRINT-LINE
   .
  • Welcome along. You got an Upvote within minutes, unusual for this corner of StackOverflow. Much more common than use of the `LOCAL-STORAGE SECTION` is use of the `LINKAGE SECTION`. The `FILLER` without any value is bad practice for a print line. When you see questions which are a simple typo or lack of basic language knowledge, please don't answer the question until it is improved. You'll get an idea of this from the comments, and from a negative score on the question (though here the OP was even more lucky than you with Upvotes). – Bill Woodger Oct 28 '14 at 09:31