ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Reading a file by %kds

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

  • Reading a file by %kds

    Code:
         FARACUST   IF   E             DISK
         FARBSHIPA  IF   E           K DISK
         D custkeyDS     e ds                  extname(aracustd:*key)
    
          *
          *   read all records from the customer file it is non-keyed
          *   use the logical file over the customer file (aracustd) which
          *   is keyed by the sold to number.  use the %kds which again is
          *   sold to number and read all the shipto associated.
          *
          /free
    
            read ARACUST;
              dow not%eof(ARACUST);
               setll %kds(CustKeyDs) ARBSHIPA;
               reade %kds(CustKeyDs) ARBSHIPA;
    
                 dow not%eof(ARBSHIPA);
                   //
                   //  do something with the shipto's
                   //
                   reade %kds(CustKeyDs) ARBSHIPA;
                 enddo;
    
               read ARACUST;
              enddo;
            *inlr = *on;
          /End-Free
    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

  • #2
    Re: Reading a file by %kds

    i like me these way do programs, where i get information the format of sentences and examples more complex...

    thank you

    Comment


    • #3
      Re: Reading a file by %kds

      Jamie, how many fields are in the "aracustd"? If it is only a couple I would rather just use "Setll (Field1: Field2) File..." this is quicker to see than opening the exteral ds to see what fields are in there.

      dmw
      Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

      Comment


      • #4
        Re: Reading a file by %kds

        Hi Code400 Members,

        i would need the step-by-step process of the Run time error debugging in RPG/400 (From CRTRPGPGM to STRDBG and STRISDB) can anybody help me in this regard.

        Posted from Texas(sanantonio)
        Thanks and Regards,
        Pianoprasath.

        Comment


        • #5
          Re: Reading a file by %kds

          I guess you could start by reading thru this



          Welcome to code400 ....Would you please start a new thread?

          Thanks
          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


          • #6
            Re: Reading a file by %kds

            So what does the:
            D custkeyDS e ds extname(aracustd:*key)

            Really do? Just substitues the custketds with the Key fields found in the external logical file aracustd?
            So if the key fields for logical was "soldto"
            then would it be save to say:
            1) setll %kds(CustKeyDs) ARBSHIPA;
            is equal to:
            2) setll (soldto) ARBSHIPA;

            If this is true then I perfer method #2 for the simple reason is I then know what the field name is that I am using at this line. Using method #1 I would have to reference the external data structure when modifing/debugging or otherwise reviewing the program.

            I know sometimes the keys can get lengthy when multiple key fields are used. Using mtheod two if I use different data to access the fiel then in order to be consistent I would have to soldto = othersold; before I access the file.

            Using mthod #2 just change the file access line.
            chain (othersoldto) aracust;


            Just my $0.02 CDN funds worth.
            Billw
            Bill
            "A good friend will bail you out of jail,
            A true friend would be sitting beside you saying,
            'Wow, that was fun.'"

            Comment


            • #7
              Re: Reading a file by %kds

              With a single field, using the field name is prob easier. But the advantage of %kds is when the key fields change. It also forces the "search" field to be correct size, length, type.

              Comment

              Working...
              X