ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

readc subfile issue

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

  • readc subfile issue

    i am having a bit of an issue with what i am trying to do. i have a display screen that searches for records, once found it populates them into a subfile in a second display screen. That part works great, i have a option field that allows a user to select a record in the subfile. Once selected i open a third display screen that shows detailed information about that record as well as allows for updating. I am using a readc to detect what record has been selected, it populates the values from the sub field correctly but i cant seem to chain correctly to gather the detailed information pertaining to the correct selection. It simply shows the last record in the subfiles details.

    in my physical file i have it keyed by actno, in my logical i have it keyed by zip and actno.

    PHP Code:
     begsr
    readc subfile
    ;
    dow not %eof;
      
    chain (zip:actnologicalfile;
      if %
    found(logicalfile);
         
    exfmt scrn3 (update)
         
    update
      
    endif;
    readc subfile;
    enddo
    i know i need to chain back to the main file to get the rest of the detail data that corresponds to each record.

  • #2
    Re: readc subfile issue

    what about sflnxtchg..........

    Comment


    • #3
      Re: readc subfile issue

      sflnxtchg is not an issue related to processing the first time. sflnxtchg allows you to control which records will be read the second time.

      Comment


      • #4
        Re: readc subfile issue

        I assume the fields zip and actno exist in your subfile format correct? If so, then your logic looks right to me. Can you post the display file dds?

        Comment


        • #5
          Re: readc subfile issue

          PHP Code:
          0001.00       display file inqdspf1coded to load subfile and update cust                 100608                                 
          0002.00      a                                      indara                                   100609                                 
          0003.00      a                                      ca03
          (03 'f3=exit')                       100608                                 
          0004.00      a                                      ca12
          (12 'f12=cancel')                    100610                                 
          0005.00      a                                      ref
          (customers)                           100614                                 
          0006.00                                                                                      100609                                 
          0007.00      a          r custinq                                                            100610                                 
          0008.00      a                                      blink                                    100610                                 
          0009.00      a                                  1 28
          'customer inquiry'                       100610                                 
          0010.00      a                                  3  2
          'type value, then enter.'                100610                                 
          0010.01      a                                                                               100610                                 
          0010.02      a                                  5  5
          'zip code . . . . '                      100610                                 
          0010.03      a            zip            5a  i  5 24                                         100615                                 
          0010.05      a n90                                  dspatr
          (ul)                               100615                                 
          0010.06      a n90                                  dspatr
          (hi)                               100615                                 
          0010.11      a  90                                  errmsg
          ('zip not found' 90)               100610                                 
          0019.01      a                                 23  2
          'f3=exit'                                100609                                 
          0020.00      a          r sflcust                   sfl                                      100610                                 
          0020.01      a            xpick          1a  i  4  2dspatr
          (pc)                               100610                                 
          0021.00      a            actno     r        o  4 14                                         100610                                 
          0022.00      a            lname     r   10   o  4 23                                         100616                                 
          0022.05      a                                                                               100614                                 
          0026.00      a          r ctlcust                   sflctl
          (sflcust)                          100610                                 
          0027.00      a                                      sflpag
          (15)                               100610                                 
          0028.00      a                                      sflsiz
          (80)                               100610                                 
          0029.00      a  50                                  sflclr                                   100610                                 
          0030.00      a  51                                  sfldspctl                                100610                                 
          0031.00      a  51                                  sfldsp                                   100610                                 
          0032.00      a                                      overlay                                  100610                                 
          0033.00      a            zip            5a  o  1 28                                         100615                                 
          0033.01      a                                                                               100614                                 
          0033.02      a                                  1 35
          'zip code info'                          100610                                 
          0033.03      a                                  3  2
          'select'                                 100614                                 
          0034.00      a                                  3 14
          'account#'                               100614                                 
          0035.00      a                                  3 23
          'last name'                              100614                                 
          0038.01      a          r custedit                                                           100610                                 
          0038.02      a                                                                               100610                                 
          0038.03      a                                  3 14
          'account#'                               100614                                 
          0038.04      a                                  3 23
          'last name'                              100614                                 
          0038.05      a                                  3 36
          'first name'                             100614                                 
          0038.06      a                                  3 49
          'city'                                   100614                                 
          0038.07      a                                  3 62
          'state'                                  100614                                 
          0038.08      a                                  3 68
          'zip'                                    100614                                 
          0038.09      a            actno     r        o  4 14                                         100615                                 
          0038.10      a            lname     r   10   b  4 23                                         100616                                 
          0038.14      a            fname     r   10   b  4 36                                         100616                                 
          0038.15      a            city      r   10   b  4 49                                         100616                                 
          0038.16      a            state     r    2   b  4 62                                         100616                                 
          0038.17      a            zip       r    5      4 68                                         100616                                 
          0038.18      a                                                                               100610                                 
          0039.00      a          r footer                                                             100615                                 
          0039.01      a                                 20  2
          'page up/down to scroll'                 100615                                 
          0040.00      a                                 21  2
          'select a record & press enter.'         100615                                 
          0041.00      a                                 23  2
          'f3=exit   f12=cancel'                   100610                                 
          0042.00      a                                                                               100610                                 
          0043.00      a                                                                               100610 
          Last edited by FaStOnE; June 14, 2010, 04:30 PM.

          Comment


          • #6
            Re: readc subfile issue

            shouldn't you be using zipno instead of zip???
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Re: readc subfile issue

              I thought that at first, but i was following an example from a text book. The field in the physical file is zip the field in the display file and in the chain is zipno so i assumed the two had to be different. I changed it, but for some reason when i chain multiple fields it still throws the errors at compile.

              Comment


              • #8
                Re: readc subfile issue

                zipno has to be used for the chain from what i can see. why? because that's the field in your SFL record! the zip field is only used a) when you load the subfile (which is why the value of zip is the last record since the value hasn't changed! zipno is the actual value you are wanting to retrieve from the file so that is what you should use. (but remember the value of zip will reflect the last record received from the chain when the READC loop is processed. one other thing to look for that could be your compile error, zipno must match the field definition in the LF if not then you'll get the "mismatched" keys error.
                I'm not anti-social, I just don't like people -Tommy Holden

                Comment


                • #9
                  Re: readc subfile issue

                  I guess i must have worded it wrong. Zipno works fine in a chain. However its a common field when i try to chain in combination, is when the issue arises. It runs through the readc loop and it returns the proper actno that was selected, but the rest of the info like name address etc belongs to the last record that was loaded in the subfile. I was trying to chain (zipno:actno) logicalfile; and it would not allow it. The compile issue only arises when i try to chain on more then one field. Yes both fields i am trying to chain are keyed in the logicalfile and the logicalfile is keyed in fspec.

                  ulitmatley i wanted to open a screen search for zipcode
                  load subfile for that zipcode that shows actnumbers
                  select a opt field to open that record for editing in a new screen and update

                  it works except the last part opens the right actno but the displayed information like names, and addresses are always the last record that was loaded into the subfile.

                  in the example john @ 333 street acct number is 78901 i selected 45678 and it displayed that acct number.

                  example
                  screen 1
                  opt acct
                  _ 12345
                  X 45678
                  _ 78901

                  screen 2

                  Acct name address
                  45678 john 333 street

                  Comment


                  • #10
                    Re: readc subfile issue

                    are the screen fields in the "scrn3" the same as the field names in the file? if not then you'll have to move the file's fields to the screen's field. another way to handle this (providing you aren't updating the file) is to forget the chain and just add hidden fields on the subfile record containing the name, address, etc you want displayed on scrn3. that way the READC will "auto-magically" load the values for you.
                    I'm not anti-social, I just don't like people -Tommy Holden

                    Comment


                    • #11
                      Re: readc subfile issue

                      i did want to update. I tried both setting the fields in screen 3 to the same as the file, and also setting them to be different in the subfile by saving to new variables on load then saving back before update. i thought about doing it with hidden, but i am not getting the right results they do display correctly if i display all the information in the subfile. However even if they are fully displayed in the subfile correctly once i select one and readc it only pulls the marked records acctno not the correct name or address.

                      Comment


                      • #12
                        Re: readc subfile issue

                        well i finally got it to work by adding a c spec keylist with the same keys in the logical file that i was trying to key with in the same order. If anyone know why i would love to figure it out.

                        Comment


                        • #13
                          Re: readc subfile issue

                          it shouldn't matter if it's a key list or in-line keys. the net effect is the same (and the underlying code should be the same). perhaps there's something else that was out of kilter and you corrected it by accident when you made your changes this time? was the program compiled to run in a named activation group, *caller, etc? if so then it's possible you weren't picking up your changes to the program since it "old" copy was still resident in memory.
                          I'm not anti-social, I just don't like people -Tommy Holden

                          Comment


                          • #14
                            Re: readc subfile issue

                            i dont know about the activation group not sure how to check that, but the first example works second ones will not compile. and those are the names of the fields in the logical file.

                            example1
                            ___________________________________________
                            c key1 klist
                            c kfld zip
                            c kfld actno

                            chain key1 customersl;
                            ___________________________________________

                            example 2

                            chain (actno:zip) customersl;
                            chain (zip:actno) customersl;

                            Comment


                            • #15
                              Re: readc subfile issue

                              chain (zip:actno) customersl;

                              that one should compile based on your key list....i can see the chain (actno:zip) customersl; not compiling if the field definitions aren't the same.
                              I'm not anti-social, I just don't like people -Tommy Holden

                              Comment

                              Working...
                              X