Update field for all lines in form

podollypodolly Member Posts: 84
Dear all,

I am making a customization on form 99000818 (Prod. Order Compoenet). Added 2 fields, LocCode and BinCode, and user can specify a location and bin. When he pushes a "Update" button. All component lines for that production order will be udpated with same location code and bin code, so that warehouse is always putting the picked items to 1 bin.

I have worked a bit on the programming, but can't work it out. I need to move cursor the every line to make it works. Here comes my code.

OnPush() of the UPDATE button
"Location Code" := LocCode;
"Bin Code" := 'B1';
COMMIT;
CurrForm.UPDATE;

How can I modify this to have all lines update at once?

Comments

  • vijay_gvijay_g Member Posts: 884
    edited 2009-10-05
    [
  • vijay_gvijay_g Member Posts: 884
    vijay_g wrote:
    OnPush() of the UPDATE button
    "Location Code" := LocCode;
    "Bin Code" := 'B1';
    COMMIT;
    CurrForm.UPDATE;

    How can I modify this to have all lines update at once?

    hi..
    can u tell me on what base you have been changing the value of loccode and B1 for each record.
    rest of the all i think you should have to use a function with rec parameter on that same form
    and call it from update button push..

    Vijay Gupta
  • podollypodolly Member Posts: 84
    Hi, thanks for reply first.

    We activated the receipt and pick for the raw material location. To have a full picture on how many items are in-stock and how many items are picked (treat as WIP, but may not consume in real time), we changed the location code and bin code in component lines, so that every time the warehouse pick is from stock to B1. Then items in B1 are the "WIP" and we can have very accurate inventory.

    I have also tried rec."Location Code", but it does the same. Originally I wanted to get that set of records and then modify, but it fails to recognize "Prod. Order Component" table, and so I tried this.

    Do you have any further idea how to make it? [-o<
  • matttraxmatttrax Member Posts: 2,309
    I say this with all respect. Based on your code, if you are using a COMMIT, and don't know how the MODIFY or MODIFYALL commands work on records, you should not be changing this code. If you're an end user, talk to your partner. If you're a programmer at a partner, talk to a more senior member of your team. COMMITs can be dangerous; you want to do this mod correctly.
  • kinekine Member Posts: 12,562
    matttrax wrote:
    I say this with all respect. Based on your code, if you are using a COMMIT, and don't know how the MODIFY or MODIFYALL commands work on records, you should not be changing this code. If you're an end user, talk to your partner. If you're a programmer at a partner, talk to a more senior member of your team. COMMITs can be dangerous; you want to do this mod correctly.

    I second this... please, ERP is not a toy... [-o<
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • SavatageSavatage Member Posts: 7,142
    podolly wrote:
    How can I modify this to have all lines update at once?

    I do something similar with my Payment journal using a REPEAT & UNTIL. I like to have the Description Line Say (Check Payment "& the date here")
    so instead of typing it in everytime I made an Button that runs thru the lines updating the description of each entry.
    It looks like this.
    OnPush()
    IF CONFIRM("Mass Change All Descriptions?",FALSE) THEN BEGIN //<<Double checking you really want to do this
      GenJnlLine.RESET;
      GenJnlLine.COPY(Rec);
      GenJnlLine.SETRANGE("Bank Payment Type","Bank Payment Type"::"Computer Check");
       IF GenJnlLine.FIND('-') THEN  //<<Find all the lines that FIT my Setrange
        REPEAT //<<Start making some changes
          GenJnlLine.Description := 'Check Payment '+FORMAT(WORKDATE,0,'<Month,2>/<Day,2>/<year4>'); //<<Create New Description
          GenJnlLine.MODIFY;  //<<update the line
        UNTIL GenJnlLine.NEXT = 0; //<<All done
    END;
    

    Perhaps you're looking for somthing similar with just changing the location. Just like I used the GenJnlLine - you'll be using Prodction order line (or whatever it's called - we don't use that) Don't forget to validate! This description does not need validation but a location code is different.
    VALIDATE("Location Code",LocCode);

    I'm assuming these new fields are located on a header where the change is made once and you want all the lines to be updated on a push of a button.

    Another example using a sales header & updating lines
    1)I Always like a double checking question.
    2)Set the range of the date you're looking for.
    3)Find & Repeat until done.
    OnPush()
    IF NOT DIALOG.CONFIRM("Your Double Check Question",TRUE) 
     THEN EXIT
     ELSE
      SalesLine.RESET;
      SalesLine.SETRANGE("Document Type","Document Type");
      SalesLine.SETRANGE("Document No.","No.");
      IF SalesLine.FIND('-') THEN
        REPEAT
    >>>>Your Code between HERE
       Validate("Location Code", "FROM HEADER".Loccode);
       Etc. Etc.
        UNTIL SalesLine.NEXT = 0;
    
Sign In or Register to comment.