WRITE problem



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

WRITE problem

Postby GUI1504 » Fri Oct 08, 2010 9:52 pm

Hello guys, i'm trying to do a Balance Line and write in a external file. But i can't do this write, someone could help me?

The error is IGYPS2074-S "CADFINAL" was defined as a type that was invalid in this context. The statement was discarded.

COBOL]
       IDENTIFICATION DIVISION.
       PROGRAM-ID. BLNCLN.
      *
      *
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SPECIAL-NAMES. DECIMAL-POINT IS COMMA.
      *
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT CADASTRO ASSIGN TO CADASTRO.
           SELECT ATUALIZA ASSIGN TO ATUALIZA.
           SELECT CADFINAL ASSIGN TO CADFINAL.
      *
      *
       DATA DIVISION.
      *
       FILE SECTION.
       FD CADASTRO
           RECORDING MODE IS F.
       01 REG-CADASTRO PIC X(300).
      *    10 CD-EMP-COD    PIC 9(11).
      *    10 CD-DATA-INI   PIC 9(06).
      *    10 CD-DATA-FIM   PIC 9(08).
      *    10 CD-PLANO-DSCT PIC 9(09).
      *    10 CD-PLANO-CNSM PIC 9(09).
      *    10 CD-PLANO-TRFS PIC 9(09).
      *    10 CD-EMP-NOME   PIC X(40).
      *    10 CD-EMP-END    PIC X(60).
      *    10 CD-EMP-CEP    PIC 9(08).
      *    10 CD-EMP-CITY   PIC X(20).
      *    10 CD-EMP-UF     PIC X(02).
      *    10 FILLER        PIC X(116).
      *
       FD ATUALIZA
           RECORDING MODE IS F.
       01 REG-ATUALIZA PIC X(200).
      *    10 AT-FLAG       PIC X(01).
      *    10 AT-EMP-COD    PIC X(11).
      *    10 AT-EMP-NOME   PIC X(40).
      *    10 AT-EMP-END    PIC X(60).
      *    10 AT-EMP-CEP    PIC 9(08).
      *    10 AT-EMP-CITY   PIC X(20).
      *    10 AT-EMP-UF     PIC X(02).
      *    10 FILLER        PIC X(58).
      *
       FD CADFINAL
           RECORDING MODE IS F.
       01 REG-CADFINAL PIC X(300).
      *    10 CF-EMP-COD    PIC 9(11).
      *    10 CF-DATA-INI   PIC 9(06).
      *    10 CF-DATA-FIM   PIC 9(06).
      *    10 CF-PLANO-DSCT PIC 9(09).
      *    10 CF-PLANO-CNSM PIC 9(09).
      *    10 CF-PLANO-TRFS PIC 9(09).
      *    10 CF-EMP-NOME   PIC X(40).
      *    10 CF-EMP-END    PIC X(60).
      *    10 CF-EMP-CEP    PIC 9(08).
      *    10 CF-EMP-CITY   PIC X(20).
      *    10 CF-EMP-UF     PIC X(02).
      *    10 FILLER        PIC X(116).
      *
       WORKING-STORAGE SECTION.
      *
       01 WS-CADASTRO.
          10 CD-EMP-CODE   PIC 9(11).
          10 CD-DATA-INI   PIC 9(06).
          10 CD-DATA-FIM   PIC 9(08).
          10 CD-PLANO-DSCT PIC 9(09).
          10 CD-PLANO-CNSM PIC 9(09).
          10 CD-PLANO-TRFS PIC 9(09).
          10 CD-EMP-NOME   PIC X(40).
          10 CD-EMP-END    PIC X(60).
          10 CD-EMP-CEP    PIC 9(08).
          10 CD-EMP-CITY   PIC X(20).
          10 CD-EMP-UF     PIC X(02).
          10 FILLER        PIC X(116).
      *
       01 WS-ATUALIZA.
          10 AT-FLAG       PIC X(01).
          10 AT-EMP-CODE   PIC X(11).
          10 AT-EMP-NOME   PIC X(40).
          10 AT-EMP-END    PIC X(60).
          10 AT-EMP-CEP    PIC 9(08).
          10 AT-EMP-CITY   PIC X(20).
          10 AT-EMP-UF     PIC X(02).
          10 FILLER        PIC X(58).
      *
       01 WS-CADFINAL.
           10 CF-EMP-CODE   PIC 9(11).
           10 CF-DATA-INI   PIC 9(06).
           10 CF-DATA-FIM   PIC 9(06).
           10 CF-PLANO-DSCT PIC 9(09).
           10 CF-PLANO-CNSM PIC 9(09).
           10 CF-PLANO-TRFS PIC 9(09).
           10 CF-EMP-NOME   PIC X(40).
           10 CF-EMP-END    PIC X(60).
           10 CF-EMP-CEP    PIC 9(08).
           10 CF-EMP-CITY   PIC X(20).
           10 CF-EMP-UF     PIC X(02).
           10 FILLER        PIC X(116).
      *
       01 AUX-CADASTRO.
           10 AX-EMP-CODE   PIC 9(11).
           10 AX-DATA-INI   PIC 9(08).
           10 AX-DATA-FIM   PIC 9(06).
           10 AX-PLANO-DSCT PIC 9(09).
           10 AX-PLANO-CNSM PIC 9(09).
           10 AX-PLANO-TRFS PIC 9(09).
           10 AX-EMP-NOME   PIC X(40).
           10 AX-EMP-END    PIC X(60).
           10 AX-EMP-CEP    PIC 9(08).
           10 AX-EMP-CITY   PIC X(20).
           10 AX-EMP-UF     PIC X(02).
           10 FILLER        PIC X(116).
      *
       PROCEDURE DIVISION.
      *
       0000-MAIN.
           PERFORM 1000-OPEN
           PERFORM 2000-READ
           PERFORM 3000-PERFORM
           PERFORM 5000-FINAL
           STOP RUN
           .
      *
       1000-OPEN.
           PERFORM 1300-OPEN-CADASTRO
           PERFORM 1400-OPEN-ATUALIZA
           PERFORM 1500-OPEN-CADFINAL
           .
      *
       1300-OPEN-CADASTRO.
           OPEN INPUT CADASTRO
           .
      *
       1400-OPEN-ATUALIZA.
           OPEN INPUT ATUALIZA
           .
      *
       1500-OPEN-CADFINAL.
           OPEN OUTPUT CADFINAL
           .
      *
       2000-READ.
           READ CADASTRO INTO WS-CADASTRO
           READ ATUALIZA INTO WS-ATUALIZA
           .
      *
       3000-PERFORM.
           IF AT-EMP-CODE <= CD-EMP-CODE
              EVALUATE TRUE
              WHEN AT-FLAG = 'A'
                  MOVE WS-CADASTRO TO AUX-CADASTRO
                  MOVE AT-EMP-CODE TO AX-EMP-CODE
                  MOVE AT-EMP-NOME TO AX-EMP-NOME
                  MOVE AT-EMP-END TO AX-EMP-END
                  MOVE AT-EMP-CEP TO AX-EMP-CEP
                  MOVE AT-EMP-CITY TO AX-EMP-CITY
                  MOVE AT-EMP-UF TO AX-EMP-UF
                  WRITE CADFINAL FROM AUX-CADASTRO
              WHEN AT-FLAG = 'D'
                  WRITE CADFINAL FROM AUX-CADASTRO
              WHEN AT-FLAG = 'I'
                  WRITE CADFINAL FROM AUX-ATUALIZA
              END-EVALUATE
           ELSE
              WRITE WS-CADASTRO
              MOVE REG-CADASTRO TO AUX-CADASTRO
              MOVE AT-EMP-CODE TO AX-EMP-CODE
              MOVE AT-EMP-NOME TO AX-EMP-NOME
              MOVE AT-EMP-END TO AX-EMP-END
              MOVE AT-EMP-CEP TO AX-EMP-CEP
              MOVE AT-EMP-CITY TO AX-EMP-CITY
              MOVE AT-EMP-UF TO AX-EMP-UF
              WRITE CADFINAL
           END-IF
           .
       5000-FINAL.
           CLOSE CADASTRO
           CLOSE ATUALIZA
           CLOSE CADFINAL
           .


The Sysprint is too big, so i'll show just the error part

==000161==> IGYPS2074-S "CADFINAL" was defined as a type that was invalid in thi
                        statement was discarded.                               
                                                                               
  000162      1                WHEN AT-FLAG = 'D'                               
  000163      2                    WRITE CADFINAL FROM AUX-CADASTRO             
                                                                               
==000163==> IGYPS2074-S "CADFINAL" was defined as a type that was invalid in thi
                        statement was discarded.                               
                                                                               
PP 5655-G53 IBM Enterprise COBOL for z/OS  3.3.1               BLNCLN    Date 10
  LineID  PL SL  ----+-*A-1-B--+----2----+----3----+----4----+----5----+----6---
  000164      1                WHEN AT-FLAG = 'I'                               
  000165      2                    WRITE CADFINAL FROM AUX-ATUALIZA             
                                                                               
==000165==> IGYPS2074-S "CADFINAL" was defined as a type that was invalid in thi
                        statement was discarded.                               
                                                                               
==000165==> IGYPS2121-S "AUX-ATUALIZA" was not defined as a data-name.  The stat
                        discarded.                                             
GUI1504
 
Posts: 28
Joined: Fri Sep 03, 2010 10:40 pm
Location: Campinas, SP - Brazil
Has thanked: 0 time
Been thanked: 0 time

Re: WRITE problem

 

Re: WRITE problem

Postby MrSpock » Fri Oct 08, 2010 9:56 pm

You DO know that you READ files but you WRITE records, right?

I see your definition:

FD CADFINAL
RECORDING MODE IS F.
01 REG-CADFINAL PIC X(300).

but I don't see any 'WRITE REG-CADFINAL FROM ...' statements anywhere.
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: WRITE problem

Postby GUI1504 » Fri Oct 08, 2010 10:09 pm

OH! Thank you MrSpock! It's compile now!
GUI1504
 
Posts: 28
Joined: Fri Sep 03, 2010 10:40 pm
Location: Campinas, SP - Brazil
Has thanked: 0 time
Been thanked: 0 time

Re: WRITE problem

Postby Ferrari2010 » Fri Oct 08, 2010 10:52 pm

Yes,

Your WRITE statement should be WRITE REG-CADFINAL FROM AUX-CADASTRO.

Thanks,
Ferrari2010
 
Posts: 6
Joined: Fri Oct 08, 2010 8:31 pm
Has thanked: 0 time
Been thanked: 0 time

Re: WRITE problem

Postby dick scherrer » Sat Oct 09, 2010 1:46 am

Hello,

At a quick glance, i believe the "line balance" code will not work correctly for all conditions. . .

You need to handle 3 conditions - when the compare is equal, when the first file is greater than the second, and when the second file is greater than the first.

There is also the consideration if either file may contain duplicates.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: WRITE problem

Postby NicC » Sat Oct 09, 2010 10:33 am

GUI1504,

Have you now resolved your previous problem?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post