ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

updating just 2 fields in a file

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

  • updating just 2 fields in a file

    Code:
         /free                                                     
                   chain  H1RRN   CSHCLPR;                         
                     if %found(CSHCLPR);                           
                      P_CHSEQ  = SEQX*10;                          
                      P_CHRLAB = ESTTIM;                           
                      Update CSHCLP  %Fields(P_CHSEQ: P_CHRLAB);   
                      opt = *blanks;                               
                      svseq   = SEQX* 10;                          
                      seqx    = SEQX;                              
                      SavESTTIM = ESTTIM;                          
                      update(e) DSPSFL;                            
                     endif;                                        
         /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: updating just 3 fields in a file

    I need an example right quick ...

    I need to chain a file (in /FREE) with 3 Keys...

    ie...

    Chain ( Key1 : Key2 : Key3 ) Some File;

    OR, how is the syntax??

    Help?

    Comment


    • #3
      Re: updating just 3 fields in a file

      You answered your own question

      PHP Code:
      Chain (keyfld1 keyfld2keyfld3rcdFormat;
      if %
      found(File1);
      endif; 
      Never trust a dog to watch your food.

      Comment


      • #4
        Re: updating just 3 fields in a file

        Straight from the IL REference guide

        Examples:
        D custkeyDS e ds extname(custfile:*key)
        /free
        CHAIN (keyA : keyB : key3) custrec;
        CHAIN %KDS(custkeyDS) custrec;

        Comment


        • #5
          Re: updating just 3 fields in a file

          So, this would work?

          Chain( HAItem : @Whse : HAYear ) XHST52;
          If Found( E3XHst52 );
          Update XXHST52;
          Else
          WriteXHST52;
          EndIf;

          Comment


          • #6
            Re: updating just 3 fields in a file

            No because you are either missing an X on the chain or have an extra X on the update.

            Thought you could catch me didn't you.
            Never trust a dog to watch your food.

            Comment


            • #7
              Re: updating just 3 fields in a file

              Originally posted by FaStOnE
              So, this would work?

              Chain( HAItem : @Whse : HAYear ) XHST52;
              If Found( E3XHst52 );
              Update XXHST52;
              Else
              WriteXHST52;
              EndIf;

              Not quite, you'll need "%FOUND" instead of just "FOUND". And you'll need a ";" after the Else statement.
              Jonas Temple
              Got FROG?
              Got Tadpole? No, because it's not done yet! Stay tuned....

              01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111

              Comment


              • #8
                Re: updating just 3 fields in a file

                Way to go Jonas. You have to be careful of FastOne questions.
                Never trust a dog to watch your food.

                Comment


                • #9
                  Re: updating just 3 fields in a file

                  Originally posted by Sbp0718
                  No because you are either missing an X on the chain or have an extra X on the update.

                  Thought you could catch me didn't you.
                  Which brings up a good question/poll. How many of you use record format on a chain and how many use the file name?

                  I always use the file name. Why? Because I hate having to do a DSPFD or refer to the compile listing to find out that FGREJC is the format for FILE123. I also wish they would change the UPDATE/WRITE/DELETE opcodes to basically allow a file name if there's only one record format.
                  Jonas Temple
                  Got FROG?
                  Got Tadpole? No, because it's not done yet! Stay tuned....

                  01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111

                  Comment


                  • #10
                    Re: updating just 3 fields in a file

                    @#%@#%@#%@#% you guys are quick! I see at LEAST you guys were paying attention to the details. Now, for a pop quiz...

                    What color was George Washington's White Horse??

                    Comment


                    • #11
                      Re: updating just 2 fields in a file

                      Im withya jonas I always use the file name on chains
                      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


                      • #12
                        Re: updating just 2 fields in a file

                        1. Your code is still wrong. It needs to be %Found not Found

                        2. I always use file name.

                        Comment


                        • #13
                          Re: updating just 2 fields in a file

                          I mostly use the record format. But, I also use the WDSC and the outline view. It not only list the File and record format but also the field list with key field notation.

                          Myabe JonBoy will jump in and give us HHO.
                          Never trust a dog to watch your food.

                          Comment


                          • #14
                            Re: updating just 2 fields in a file

                            Originally posted by Sbp0718
                            I mostly use the record format. But, I also use the WDSC and the outline view. It not only list the File and record format but also the field list with key field notation.

                            Myabe JonBoy will jump in and give us HHO.
                            I have REALLY tried to give WDSC a chance. After losing 45 minutes worth of work on 2 occasions I decided it wasn't worth it. I'm really anxious to try the new WDSC Lite. Hopefully it will include bug fixes as well. I do like the information it gives you while you're coding though.
                            Jonas Temple
                            Got FROG?
                            Got Tadpole? No, because it's not done yet! Stay tuned....

                            01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111

                            Comment


                            • #15
                              Re: updating just 2 fields in a file

                              jtemple,

                              I always use the file name.

                              MdnghtPgmr
                              "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

                              Comment

                              Working...
                              X