Insert line with multiple values

TiwazTiwaz Member Posts: 98
Hi guys. I have made a function that will calculate two values, Quantity and Amount based on certain conditions. I call that function from my Header table.
I have this part of the function that checks if there are multiple lines on my subpage that satisfy a condition, deletes them and inserts only one with set of distinct values:

Line.RESET;
Line.SETRANGE("Travel Order No.",TravelOrderNo);
Line.SETRANGE("Travel Cost Batch",TravelSetup."Expense Type-Daily Wage");
IF Line.FINDSET THEN BEGIN
REPEAT
Line.DELETE;
UNTIL
Line.NEXT = 0;
END;
lrTravelOrderCost2.RESET;
lrTravelOrderCost2.SETRANGE("Travel Order No.",TravelOrderNo);

IF lrTravelOrderCost2.FINDLAST THEN
iLineNo := lrTravelOrderCost2."Line No." + 10
ELSE
iLineNo := 10;

lrTravelOrderCost.INIT;
lrTravelOrderCost.VALIDATE("Travel Order No.",TravelOrderNo);
lrTravelOrderCost."Line No." := iLineNo;
lrTravelOrderCost.INSERT(TRUE);

CostsType.RESET;
CostsType.SETRANGE("Cost Batch",TravelSetup."Expense Type-Daily Wage");
IF CostsType.FINDFIRST THEN BEGIN
lrTravelOrderCost.VALIDATE("Travel Cost Batch",TravelSetup."Expense Type-Daily Wage");
lrTravelOrderCost.VALIDATE("Travel Cost No.",CostsType."Travel Cost No.");
lrTravelOrderCost.VALIDATE("Qty.",Quantity);
lrTravelOrderCost.VALIDATE("Unit Amt.",Amount);
lrTravelOrderCost.MODIFY(TRUE);
END;


Now I want to know how can I insert that same line that gets inserted in first part, but when my subpage is empty, when there are no lines :(

Answers

  • KishormKishorm Member Posts: 921
    What is the problem you are having, are you getting an error or something?
Sign In or Register to comment.