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
0
Comments
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.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
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.
Use only the INIT..INSERT block. Your don't have to repeat purchase lines.
Dynamics NAV Developer since 2005
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
The issue is resolved.