Menu

#23 COPY REPLACING error when using IN as replacement value

GC 3.2
closed
8
2023-07-07
2007-05-16
csaci
No

Several of our programs do a COPY ???? REPLACING 'XXX' BY IN.

When these programs are compiled the following error occurs.

CPBACH.cbl:199: Error: syntax error

Where line 198:199 is

   01  IN-RECORD.
       COPY CPWWPOST REPLACING 'POST' BY IN.

This syntax works on both z/OS and MicroFocus.

I'm thinking that since IN is a resevered word, it is being checked for when doing the replacing. Although, in this situation, IN is never used by itself in any of the fields once the copybook is expanded.

Related

Bugs: #22

Discussion

  • Roger While

    Roger While - 2007-06-09

    Logged In: YES
    user_id=1138256
    Originator: NO

    This was covered on the mailing list.
    Invalid syntax.
    Use psuedo-text replacement.
    ie.
    REPLACING =='POST'== BY ==IN==.
    This is ALWAYS compatible.

     
  • Simon Sobisch

    Simon Sobisch - 2016-06-03
    • summary: COPY REPLACING error when using IN as replacemnt value --> COPY REPLACING error when using IN as replacement value
    • status: closed --> accepted
    • Group: --> GC 2.0
    • Priority: 5 --> 8
     
  • Simon Sobisch

    Simon Sobisch - 2016-06-03

    I've rechecked this: All COBOL Standards allow the syntax

    COPY ... REPLACING word-1 | literal-1 BY word-2 | literal-2.
    

    with the explanation:

    Word-1 or word-2 may be any single COBOL word except 'COPY', the compiler directive indicator, or the comment indicator.

    Therefore: the sample is valid and while the workaround "pseudotext" always works it would be nice to fix this.

     
  • Simon Sobisch

    Simon Sobisch - 2017-12-25
    • assigned_to: Edward Hart
    • Group: GC 2.2 --> GC 3.x
     
  • Simon Sobisch

    Simon Sobisch - 2022-12-31
    • labels: --> cobc, REPLACING
    • assigned_to: Edward Hart --> Nicolas Berthier
     
  • Simon Sobisch

    Simon Sobisch - 2022-12-31

    This may be solved already, not checked yet.

     
  • Simon Sobisch

    Simon Sobisch - 2023-07-07
    • labels: cobc, REPLACING --> cobc, REPLACING, reserved words
    • assigned_to: Nicolas Berthier --> Simon Sobisch
     
  • Simon Sobisch

    Simon Sobisch - 2023-07-07

    Fixed with [r5111].

     

    Related

    Commit: [r5111]

  • Simon Sobisch

    Simon Sobisch - 2023-07-07
    • status: accepted --> closed
    • Group: GC 3.x --> GC 3.2
     
  • Nicolas Berthier

    @sf-mensch Apologies for not addressing this one before, I did not see it was assigned to me (I probably missed the notification — not really connected on a 31st December ;-) )

     
  • Nicolas Berthier

    @sf-mensch BTW I did not follow the recent changes in handling of REPLACE. But I'm a bit surprised REPLACING 'POST' BY PREFIX. should replace 'POST'-A with PREFIX-A (as in the new test in [r5111], where it's IN instead of PREFIX). At least I don't think it conforms to what ISO/ICE 2014 describes as a match in its text manipulation section (where the dash - is not to be considered a separator like : or ( and )).

     

    Related

    Commit: [r5111]

    • Simon Sobisch

      Simon Sobisch - 2023-07-07

      The dash would only match for LEADING.
      The reason that this works is that the first part is a literal used as pseudo word, which was a common solution for LEADING before ISO2002.

       

Log in to post a comment.