ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

*rnf5377

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

  • *rnf5377

    Hi,

    How to avoid *RNF5377 error for fully free format RPGLE Code:-



    td=%subst(fld1:4:2)+ '/' %subst(fld1:7:2) +
    - '/' +%subst=%date(td);



    Thanks ...

  • #2
    You have multiple errors here.

    I don't know what you mean by %subst=%date(td) - it doesn't make sense. You didn't deine any positions for the substring and %date produces an ISO date and you can't take a substring of a date.

    You also appear to be missing a "+" between '/' and %subst... and you have a spurious - sign at the start of the second row.

    Apart from that it looks fine <grin>

    Comment


    • #3
      Please ignore last post with respect to code statement and refer below for the same.


      td=%subst(fld1:4:2)+ '/' %subst(fld1:7:2) +
      - '/' +%subst(fld1:2:2);

      what corrections should I do in above statement to avoid this error(*RNF5377)?


      Could you please reply by posting correct statement to remove this *RNF5377 error ?



      Thanks ....





      Comment


      • #4
        Between '/' and %subst is missing "+" and the minus at the begin of the second line is not necessary.
        Try the following:

        td=%subst(fld1:4:2)+ '/' + %subst(fld1:7:2) +
        '/' +%subst(fld1:2:2);

        Comment


        • #5
          The corrections I noted earlier re the missing + and the spurious still apply.

          Comment


          • #6
            i tried below but still same error:-

            td=%subst(fld1:4:2)+ '/' + %subst(fld1:7:2) +
            '/' +%subst(fld1:2:2);


            Thnks...

            Comment


            • #7
              ... how is td defined? Is it a date or is it a character field?
              In either way YYYY/MM/DD or YYYY/DD/MM is an invalid date format. Valid date formats with a 4 digit year are:
              YYYY-MM-DD
              MM/DD/YYYY
              DD.MM.YYYY

              Birgitta

              Comment


              • #8
                td is defined as charater fiel with 10 length if this line gets executed properly then idea is to do like this workdate=%date(td);

                but td=%subst(fld1:4:2)+ '/' + %subst(fld1:7:2) +
                '/' +%subst(fld1:2:2);


                but as above td statement in ptd=%subst(fld1:4:2)+ '/' + %subst(fld1:7:2) +
                '/' +%subst(fld1:2:2);
                ) it self giving that RNF5377 error currently.


                Thanks....

                Comment


                • #9
                  Originally posted by John192 View Post
                  td is defined as charater fiel with 10 length if this line gets executed properly then idea is to do like this workdate=%date(td);

                  but td=%subst(fld1:4:2)+ '/' + %subst(fld1:7:2) +
                  '/' +%subst(fld1:2:2);


                  but as above td statement in ptd=%subst(fld1:4:2)+ '/' + %subst(fld1:7:2) +
                  '/' +%subst(fld1:2:2);
                  ) it self giving that RNF5377 error currently.


                  Thanks....

                  I meant as error RNF5377 is coming in this statement td=%subst(fld1:4:2)+ '/' + %subst(fld1:7:2) +
                  '/' +%subst(fld1:2:2);
                  )

                  So unable to execute next statement workdate =%date(td)


                  Idea is to convert a field which is defined as numeric in file and having a length of 7 in a system date format(IBM i default system date format MM/DD/YY so that we could compare CYY/MM/DD date field in a file (which is defined as numeric and of length 7) with current system date.


                  Thanks much...

                  Comment


                  • John192
                    John192 commented
                    Editing a comment
                    Idea is to convert a field which is defined as numeric in a file and having a length of 7 and which has date data in it ( multiple dates in CYY/MM/DD format in it )

                    into a system date format(IBM i default system date format MM/DD/YY so that we could compare CYY/MM/DD date field in a file (which is defined as numeric and of length 7) with current system date.



                    Thanks...

                • #10
                  If you only want to compare a 7 digit numeric date with a real date, then convert the numeric date into a real date and finally compare it with another date:
                  Code:
                  DCL-S CvtDate Date;
                  
                  CvtDate = %Date(Num7Date: *CYMD);
                  If CvtDate = %Date();  //CvtDate = Current Date
                     //DoWhatever you want
                  EndIf;
                  If it is already a date the date format doen't matter. Under the cover a date is a numeric value (scaliger no) that is finally compared. The date format is used to make this scaliger no readable (even though RPG converts the scaliger no into a character representation).

                  Comment


                  • #11
                    Originally posted by B.Hauser View Post
                    If you only want to compare a 7 digit numeric date with a real date, then convert the numeric date into a real date and finally compare it with another date:
                    Code:
                    DCL-S CvtDate Date;
                    
                    CvtDate = %Date(Num7Date: *CYMD);
                    If CvtDate = %Date(); //CvtDate = Current Date
                    //DoWhatever you want
                    EndIf;
                    If it is already a date the date format doen't matter. Under the cover a date is a numeric value (scaliger no) that is finally compared. The date format is used to make this scaliger no readable (even though RPG converts the scaliger no into a character representation).
                    problem here is that this numeric field which has data data in it is a field of a file not a standalone field as mentioned in above example.

                    So for this case what can we do?


                    Thanks...

                    Comment


                    • #12
                      So what is the problem?
                      You read the date into a numeric variable if you are working with native I/O ... then convert the content of this variable/column into a real date (into a different variable) and then compare the different variable

                      Comment


                      • #13
                        John, when asking about an error message from the compiler, it would be helpful if you would initially post enough code that we could try to compile it ourselves without having to ask about how to define the variables.

                        Comment


                        • #14
                          As Birgitta said, if fld1 is a 7-digit numeric field in CMMDDYY format, use %date(fld1 : *CMDY).

                          I don't understand what you mean by this:
                          problem here is that this numeric field which has data data in it is a field of a file not a standalone field as mentioned in above example.

                          Comment

                          Working...
                          X