modifying data and inserting to another table

asembereng
Member Posts: 220
id empid loan_amount monthly_pay total_int monthly_int int_rate balance loan Type paidoffamount
1 A001 5,000.00 500.00 1,000.00 100.00 2.00 5,000.00 0.00
2 A002 6,000.00 600.00 0.00 0.00 0.00 6,000.00 One by Six 0.00
i want to write a program that will go through a table called loan loop through the table modify the balance field and the paidoffamount field and then pick data from this table and dump it into another table called "loan history"
IF history.FIND('+') THEN BEGIN
NextLineNo := history.id + 1;
history.id := NextLineNo;
END;
history.INSERT;
IF loan.balance <> 0 THEN BEGIN
op_bal := loan.balance;
cl_bal := loan.balance - loan.monthly_pay;
paidoff := loan.loan_amount - loan.balance;
loan.balance :=cl_bal;
loan.paidoffamount := paidoff;
loan.modify;
history.empid :=loan.empid;
history.op_balance := op_bal;
history.cl_balance := cl_bal;
history.loan_id := loan.id;
message('%1',op_bal);
history.insert;
END;
I tried the code above but its not modifying the loan table nor writing to the loan history table. Can someone tell me why?
1 A001 5,000.00 500.00 1,000.00 100.00 2.00 5,000.00 0.00
2 A002 6,000.00 600.00 0.00 0.00 0.00 6,000.00 One by Six 0.00
i want to write a program that will go through a table called loan loop through the table modify the balance field and the paidoffamount field and then pick data from this table and dump it into another table called "loan history"
IF history.FIND('+') THEN BEGIN
NextLineNo := history.id + 1;
history.id := NextLineNo;
END;
history.INSERT;
IF loan.balance <> 0 THEN BEGIN
op_bal := loan.balance;
cl_bal := loan.balance - loan.monthly_pay;
paidoff := loan.loan_amount - loan.balance;
loan.balance :=cl_bal;
loan.paidoffamount := paidoff;
loan.modify;
history.empid :=loan.empid;
history.op_balance := op_bal;
history.cl_balance := cl_bal;
history.loan_id := loan.id;
message('%1',op_bal);
history.insert;
END;
I tried the code above but its not modifying the loan table nor writing to the loan history table. Can someone tell me why?
0
Comments
-
FIrst of all you have history.insert twice; the second should be a modify.
Without seeing the loan loop that's all we can see right now.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions