ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

cl error

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

  • cl error

    Hi,

    How to avoid error 1. CPD0726-vriable declared but not referred to in a CL program ?

    also how to resolve2. 2. CPD0727 variable referred to but not declared?(this error specially is occurring when we are doing SBMJOB CMD (CLL PGM(X) PARM(&VAR1) &VAR2 &VAR3)
    Here this CPD0727 is appearing for &var3 which is even though declared but when compiling cl program then getting this error


    it's declared like below :-



    ************************************************** **


    DCL VAR(&VAR3) TYPE(*CHAR) STG(*DEFINED) +
    LEN(10) DEFVAR(&DATA_STRCT 6)


    3. why this error is appearing length specified is too long for variable type.

    SBMJOB CMD(CALL PGM(X) PARM(&VAR1 &VAR2 &VAR3 &VAR4 &VAR5)




    Thanks...

  • #2
    Hi,

    Please ignore these errors CPD0726 and CPD0727 I was able to resolve it but for this error " length specified is too long for variable type." I think it is appearing because one of these variable length is 220 and it's defined as decimal type which is causing this error how ever by changing it's type to character it can be avoided but my question is that in case if RPG program accepts that field as numeric as a parameter then what can we do ,i mean how can we pass this parameter?


    Thanks...

    Comment


    • #3
      If you call an RPG program from a CL program, you will have no trouble passing variables as parameters provided that both programs define the parameters identically.

      If the CL program submits an RPG program, that is another matter. The system treats the command as if you had typed it on a command line in a 5250 session and makes assumptions about the data types and sizes. How the CL variables are defined is ignored. This has been the case since the S/38 came on the market.

      Here's an article that may help:

      In my previous “Fundamentals” tips, I discussed the importance of making sure parameters are the correct size and how to correctly handle omitted parameters. In this tip I want to address what has to be the most frequently asked question about parameters. The most frequently asked parameter question comes in many forms, such as: “How


      Comment


      • #4
        actually it was a numeric field but when i am passing it to rpg program then my cl fails with error "cpd0727 variable is referred to but not declared " and another error "CPD0732 : Length specified is too long for variable type."

        just for more clarification in RPG there is a data structure subfield which is numeric and defined as followings in RPG program:-

        IDS1 DS 30

        I 1 10 var1
        I 11 20 var2
        I p 21 30 var3


        the error CPD0732 : Length specified is too long for variable type."
        is appearing in my CL program at below statement:-

        CAll PGM(ABC) PARM(&VAR1 &VAR2 &VAR3)


        and error cpd0727 variable is referred to but not declared is appearing in below statement in my CL program:-

        DCL VAR (&VAR3) TYPE(*DEC) STG(*DEFINED) +
        LEN(10) DEFVAR(&DS1 21)

        If I change variable3's type from numeric to character then this error disappears.

        So How can we avoid this error without actually changing variable3's data type here?



        Thanks much....



        Comment


        • #5
          The maximum length of a packed decimal value in CL is 15 digits. From 21 to 30 is 19 digits.

          Comment


          • #6
            21 to 30 is 10 digits only how did you calculate 19 digits here?


            Thanks...

            Comment


            • #7
              numeric data type, packed-decimal, data format, format, data, packed decimal format, array/table field, description, input field, output field, array, packed format, field, packed

              Comment


              • #8
                so if we can't use more than 15 digits then in this example how can we pass parameter whose data tupe is packed decimal ?


                Thanks much...

                Comment


                • #9
                  If you really need to use CL for this, and you really need to handle packed data with more than 15 digits, then you would to define the CL variable with type *CHAR and the byte length for the required number of digits. But then you would not be able to use it as a numeric field in CL.

                  If you really need support for packed numeric data with more than 15 digits, CL is probably not the best language to use.

                  Comment


                  • #10
                    "the byte length for the required number of digits."

                    do you mean to say that if i declare variable3 as mentioned in my previous post then it should be declared based on 2N-1 formula like below ( as variable 3 is of 10 length :-


                    DCL VAR (&VAR3) TYPE(*DEC) STG(*DEFINED) +
                    LEN(19) DEFVAR(&DS1 21)


                    Also does this 2n-1 is applicable for packe numeric values only or for character values also ?

                    I mean when i need to simply declare any variable as a character field with some length then also do we need to use this 2n-1 formula?


                    Thanks much...


                    Comment


                    • #11
                      It does not apply to any other data type. In general, if you want to define a character field of 10 bytes in CL, use type(*char) len(10).

                      I was talking about the case where CL does not allow you to define the field as type(*dec), because the length is greater than 15. In that case, you have to define the field as type(*char) with the same number of bytes as the RPG program has. (10 bytes for var3).

                      Do you really need to use CL for this? You will not be able to work with &var3 as a numeric value in the CL program.

                      Comment

                      Working...
                      X