Updated value of line is not getting inserted in the table

Markandey_PandeyMarkandey_Pandey Member Posts: 178
Hi all,

I have created a table which will store purchase header and line data when order is received, so i have written the following code for that:

RecPurchaseLine->Record->Purchase Line
RecRcDetail->Record->Challan (Table i have created)

RecPurchaseLine.RESET;
RecPurchaseLine.SETRANGE("Document No.","No.");
IF RecPurchaseLine.FINDSET THEN

REPEAT
RecRcDetail.INIT;
RecRcDetail."Rc. No.":="Vendor Invoice No.";
RecRcDetail."Customer No.":="Pay-to Vendor No.";
RecRcDetail."Customer Name":="Pay-to Name";
RecRcDetail."Item No.":=RecPurchaseLine."No.";
RecRcDetail."Item Description":=RecPurchaseLine.Description;
RecRcDetail."Received Qty":=RecPurchaseLine."Qty. to Receive";
RecRcDetail.INSERT;
UNTIL (RecPurchaseLine.NEXT=0);


here even if i am changing the received qty on line but it is not affected and the old value from the line table is saved in the challan table.

can anybody suggest me what i should do so that when the qty is changed on the line on purchase order it should insert the changed value to challan table.
Markandey Pandey

Comments

  • DaveTDaveT Member Posts: 1,039
    Hi Markandey,

    Two issues that I can see

    1. Where are you calling the code from - has the Purchase Line been updated yet

    2. What is the Key on RecRcDetail? - you may have a problem on if the same item is used more that once on the document.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    DaveT wrote:
    Hi Markandey,

    Two issues that I can see

    1. Where are you calling the code from - has the Purchase Line been updated yet

    2. What is the Key on RecRcDetail? - you may have a problem on if the same item is used more that once on the document.


    Hi,

    1.
    I am aware of the issue 1. but not aware where i should call this code so that it will get the updated line.

    2. I have used Challan No and Item No as a composite key so its not a problem if same item is used more than once.

    need ur help on case 1.
    Markandey Pandey
  • Cem_KaraerCem_Karaer Member Posts: 281
    In the 90 codeunit
      TempVATAmountLineRemainder.DELETEALL;
      PurchLine.CalcVATAmountLines(1,PurchHeader,PurchLine,TempVATAmountLine);
    
      IF PurchLine.FIND('-') THEN
        REPEAT
          ItemJnlRollRndg := FALSE;
          LineCount := LineCount + 1;
    .......ENTER YOUR CODE HERE........
          IF GUIALLOWED THEN
    

    Use only the INIT..INSERT block. Your don't have to repeat purchase lines.
    Cem Karaer @ Pargesoft
    Dynamics NAV Developer since 2005
  • matttraxmatttrax Member Posts: 2,309
    Set a break point and step through the debugger. Quickest and easiest way to see when a value is changing. Often it will be changed, but then changed back later on in code, or not saved to the database. Could be anything. When modifying posting routines the code needs to be evaluated as a whole, and only you can do that. Debugger is the way to go. If you can't determine the problem from there let us know.
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    Hi thanx for your support,
    i have one more problem, actually when i am invoicing i want to update the "Qty to Ship" from Sales line to the Challan table that i have created, so i have written the following code
    in CodeUnit 80 (Sales-Post) after the following lines:-
    ////NAV CODE
    IF ABS(SalesLine."Quantity Invoiced" + SalesLine."Qty. to Invoice") >
    ABS(SalesLine."Return Qty. Received")
    THEN BEGIN
    SalesLine.VALIDATE("Qty. to Invoice",
    SalesLine."Return Qty. Received" - SalesLine."Quantity Invoiced");
    SalesLine."Qty. to Invoice (Base)" :=
    SalesLine."Return Qty. Received (Base)" - SalesLine."Qty. Invoiced (Base)";
    END;
    ////NAV CODE

    /////MY CODE
    RecRcDetail->Record->Challan
    IF(RecRcDetail.FINDSET )THEN
    BEGIN
    RecRcDetail."Supplied Qty":=ABS(RecRcDetail."Supplied Qty"+SalesLine."Qty. to Ship");
    RecRcDetail."Balance Qty":=ABS(RecRcDetail."Balance Qty"-SalesLine."Qty. to Ship");
    RecRcDetail.MODIFY;
    END
    ELSE
    ERROR('Record Does not Exist');
    //////MY CODE

    Suppose if there are two lines then the "Qty To Ship" from Sales Line is getting added and is upadated in the first line of Challan Table and second line remain blank.
    I want to upadte the "QTY to SHIP" from sales line to Challan's "Supplied Qty"

    I had tried to use
    IF(RecRcDetail.GET("Rc. No","No.") ) instead of IF(RecRcDetail.FINDSET)) but the code is going in ELSE block in this case.

    Can u plz guide me
    Markandey Pandey
  • Markandey_PandeyMarkandey_Pandey Member Posts: 178
    Hi all
    The issue is resolved.
    Markandey Pandey
Sign In or Register to comment.