ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problem with READ in RPGLE

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

  • Problem with READ in RPGLE

    Hi, hope you can help me because I'm facing a problem never seen...
    I've written a very short program in RPGLE:

    Code:
     
    H DECEDIT('0,') DATEDIT(*YMD/) 
    FCCRTM IF E K DISK 
    * 
    C *loval Setll CCRTM 
    C Read CCRTM 
    C Dow not %eof 
    ............................
    C Read CCRTM 
    C Enddo 
    * 
    C Eval *inlr=*on
    If I debug the program I see the read instruction working (%eof indicator is off) BUT no value is readen from the file.

    I've found out that if BEFORE the setll I set ALL the fields to a default value, than the read instruction works fine.
    If I set to a default value only some fields (I've tried with the first 4 fields of the file) than the read instruction reads ONLY those 4 fields, nothing more....

    Where's the problem??? Consider that I'm working on a new machine (OS 6.1) and this is new for me, but I've never seen this behaviour before....

    Could anyone please help me?? This file counts 118 fileds and it's frustrating!!!!
    Thanks....

  • #2
    Re: Problem with READ in RPGLE

    change *loval to *start and give it a try please

    also check to see if the key is DESCENDING.... that will get ya!

    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Problem with READ in RPGLE

      Tried with *START and it behaves the same....
      I've compiled the program with option *DEBUGIO and noticed that during debug it "jumps" only once over the F spec. This is also strange, isn't it??

      File is keyed ASCENDING.... thanks.... :-))

      Any other idea???? I'm getting fool around this!!!!

      Comment


      • #4
        Re: Problem with READ in RPGLE

        Are all the PTFs up to date ?
        Philippe

        Comment


        • #5
          Re: Problem with READ in RPGLE

          I cannot be absolutely sure about this (I'm not authorised to check), but I'm enough sure that the PTFs have been all installed...

          Comment


          • #6
            Re: Problem with READ in RPGLE

            I dont use DATEDIT(*YMD/) is it possible there is a badly formated date @ the first record?
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: Problem with READ in RPGLE

              make sure that the compile options are not set to *NOUNREF. if OPTION(*NOUNREF) is used on the compile then you'll only see fields that are actually used in the program (which explains why you see them if you set them to a default value.). the read is successful but you will not see any values from the read since the fields are not explicitly referenced in the program.

              directly from the CRTBNDRPG command's help screens:
              Code:
              *NOUNREF                                                 
                  Unreferenced data items are not included in the      
                  compiled module.  This reduces the amount storage    
                  used, allowing a larger program to be compiled.  You                                                          
                  cannot look at or assign to an unreferenced data item 
                  during debugging when the *NOUNREF option is chosen.  
                  The unreferenced data items still appear in the       
                  cross-reference listings produced by specifying       
                  OPTION(*XREF).
              Last edited by tomholden; December 3, 2010, 10:10 AM. Reason: added help text
              I'm not anti-social, I just don't like people -Tommy Holden

              Comment


              • #8
                Re: Problem with READ in RPGLE

                try removing the setll altogether its not even needed cause you are doing a strain UP --- read.

                jamie
                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment


                • #9
                  Re: Problem with READ in RPGLE

                  If it's Keyed .. are you sure it has a "K" in the F-Specs?

                  Comment


                  • #10
                    Re: Problem with READ in RPGLE

                    Code:
                    C Dow not %eof 
                    ............................
                    C Read CCRTM
                    What do you hide beneath the ...................... ? Show the missing code please.
                    Philippe

                    Comment


                    • #11
                      Re: Problem with READ in RPGLE

                      Do you need to put the filename as part of the %eof statement - I only do the Free stuff and that's what I do for that and it works, I'm not old enough to know about that fixed format stuff ...

                      Code:
                       /Free
                            Setll *Start CCRTM; 
                            Read CCRTM;
                            Dow Not %eof(CCRTM);
                              ...... 
                              Read CCRTM; 
                            EndDo; 
                       /End-Free
                      Greg Craill: "Life's hard - Get a helmet !!"

                      Comment


                      • #12
                        Re: Problem with READ in RPGLE

                        I have to be straight and say I was dubious to begin with, so I created a quick 8 line rpgle program using exactly what you've given just changing to a file name of my own.

                        Compile with no special options others than source debug. Start debug and step in. Yes none of my eval statements return any value at any point, yet I can see the rrn incrementing, i.e. the file being read.

                        I tried all the suggestions above, remove the setll, ensuring the F spec is keyed, definitely in ascending, removed the H spec with the datedit, I don't have the *NOUNREF on my V5R4, and just for completeness I included the file name in the %eof.

                        So I see what you see, or don't see as it were.

                        Then I created a data structure in my d specs with all the fields of the file to see if this reference would make a difference. No good, still my debug evals return blanks/zero instead of expected values.

                        Then I inserted a C spec "clear dsTest".. putting in my made up data structure name to clear.

                        Back in to debug and hey presto "eval RTFLD1" gives me content.

                        I removed my made up data structure and changed the clear to be clear file record format name thinking the C spec reference must be enough. Back to no values.

                        So only with defining all the fields in D specs and having a C spec action against the fields am I able to see the contents in debug?

                        I'm lost now.
                        the smoking gnu

                        Comment


                        • #13
                          Re: Problem with READ in RPGLE

                          I try to answer to all of you....

                          I'm sure the compiling option is *UNREF.
                          There's absolutely no code hidden behind the dots (I have to write a subroutine of course, but did not yet....) the code you read is the code I'm compiling.
                          The file is keyed and that's why I put the K in the F spec.
                          The specification of the file in the %eof function is ininfluent (I've tried to cancel it but nothing changes).

                          I'm almost happy the Chris had the same problem.... I'm feeling so STUPID!!!!
                          You're right Chris, if I define a DS in the D specs and reset it at the beginning the problem is solved, but this looks like the program doesn't prepare a memory area to read the data. It's like I have to prepare it inside the program.... Did you ever see this problem???

                          Thanks a lot!!

                          Comment


                          • #14
                            Re: Problem with READ in RPGLE

                            Hi

                            If field is not used in a program and still need to see its content, then use EVAL %VAR(FIELD). To see all fields in program use EVAL %LOCALVARS.

                            Hope this will be any help.
                            Last edited by Zdenko; December 6, 2010, 06:45 AM.
                            LP Zdenko

                            Comment


                            • #15
                              Re: Problem with READ in RPGLE

                              What the Heck is that code for if no use of any fields ?
                              Last edited by Mercury; December 6, 2010, 06:33 AM.
                              Philippe

                              Comment

                              Working...
                              X