sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Why does this constant have to be gloablly defined?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why does this constant have to be gloablly defined?

    I have a global /copy member "myMember" defining DS:
    Code:
    dcl-ds myDs     qualified template;
      myNum         packed(7);
    end-ds;
    I want to create varchars with the same length as that packed numeric. So I do this:
    Code:
    //global:
    /copy myMember;
    dcl-c fieldLen  const(%len(myDs.myNum));
    
    dcl-pr myProc;
      dcl-s myStr     varchar(fieldLen);
    ...
    end-pr;
    Define a constant as the length of the packed numeric, then define a varchar based on that constant.

    This works, as long as the constant is global.

    But if the constant is in the subprocedure instead:
    Code:
    //global:
    /copy myMember;
    
    dcl-pr myProc;
      dcl-c fieldLen  const(%len(myDs2.myNum));
      dcl-s myStr     varchar(fieldLen);
    ...
    end-pr;
    Then it fails to compile with error RNF3320 "The keyword parameter is not defined; keyword is ignored" on the constant definition line.

    But I don't see why this shouldn't work?


  • #2
    This may not solve your problem, but just ask the following questions:
    Why to define a constant locally?
    Does it make sense?

    Comment


    • #3
      It made sense because the constant was for a variable that was only local to the procedure, though there is no reason it couldn't be global.

      I was more curious if there was a reason why it had to be global that I was missing, or if it's a simple oversight in the compiler

      Comment


      • #4
        Originally posted by Vectorspace View Post
        ...

        I was more curious if there was a reason why it had to be global that I was missing, or if it's a simple oversight in the compiler
        Have you checked PTFs? I seem to recall a similar issue a way back. This may already have been fixed.

        Comment

        Working...
        X