Update Sales Line Qty with PO Qty

SavatageSavatage Member Posts: 7,142
edited 2007-04-04 in Navision Attain
I was thinking about this when I read another post about updating a PO Qty when you updates a sales line qty.
http://www.mibuso.com/forum/viewtopic.php?t=17518

I want to do the reverse.
We receive orders and the merch is not currently instock.
I altered the Req worksheet to pull just the OUT items and create a po for them.
Now when the PO is received I manually drill into each po line to it's corresponding Sales order and manually update the quanity. (yes one at a time)

I would like to have a Command Button On the PO header "Update Sales Lines". Each Po line does have a "Special Order Sales No" & "Special Order Sales line No" filled in.

On push of the button or function It should update the sales line with the po's "Qty received" for it's matching line. (or quanitity)

I tried some code but I seem to be off base.
IF NOT DIALOG.CONFIRM(Question,TRUE)
 THEN EXIT
 ELSE
Salesline.LOCKTABLE;
Salesline.RESET;
Salesline.SETRANGE(Salesline."Document Type",Purchline."Document Type");
Salesline.SETRANGE(Salesline."Document No.",Purchline."Special Order Sales No.");
Salesline.SETRANGE(Salesline."Line No.",Purchline."Special Order Sales Line No.");
  IF Salesline.FIND('-') THEN
    REPEAT
        IF Salesline."Special Order Purchase No." <> '' THEN
        Salesline.Quantity := Purchline.Quantity;
      Salesline.MODIFY(TRUE);
    UNTIL Salesline.NEXT = 0;

Any suggestions welcome.

Comments

  • SavatageSavatage Member Posts: 7,142
    Ok I'm trying a new idea - using a simple update report
    I'm currently testing

    Puchase Line is the dataitem..
    Salesline.GET("Document Type","Special Order Sales No.","Special Order Sales Line No.");
    Salesline.Quantity := Purchline.Quantity;
    Salesline.VALIDATE(Quantity);
    Salesline.MODIFY;
    

    It appears to be geting the correct sales line but it's not updating.
    What am I doing wrong?
  • SavatageSavatage Member Posts: 7,142
    edited 2007-04-04
    Never mind.

    I added Sales Line as a dataitem (indented) linked with code below to Purchase Line.
    Document Type=FIELD(Document Type),Special Order Purchase No.=FIELD(Document No.),Special Order Purch. Line No.=FIELD(Line No.)
    

    and added in the sales line dataitem
    OnAfterGetRecord()
    Purchline.GET("Document Type","Special Order Purchase No.","Special Order Purch. Line No.");
    Salesline.Quantity := Purchline.Quantity / Salesline."Qty. per Unit of Measure"; //We always Purch in pieces but not always sell it that way - so the division puts it all back propertly.
    Salesline.VALIDATE(Quantity);
    Salesline.MODIFY;
    

    So I can still choose the PO# using the Purchase Line table and it updates all the orders (multiple) that have sales lines linked.

    Add a command button to the purch header "Update Special Order Lines" & Happy Time! :mrgreen:
  • SavatageSavatage Member Posts: 7,142
    Just to keep adding to, apparently, my own post & replies :lol:

    By adding

    Salesheader.GET("Document Type",Salesline."Document No.");
    .
    **Do sales Header Stuff too if needed**
    .
    Salesheader.MODIFY;

    Believe it or not this whole update thing will save us tons of man hours. \:D/
Sign In or Register to comment.