ashishjain
2nd August 2011, 16:33
Hi All,

I am using AFS to add Freight Item line to Sales order line session. The problem is that i want to add Freight Item line at 901 position but its getting the line position automatically but not 901 & inserting the Freight Item.

mark_h
2nd August 2011, 17:19
I can't answer why this happens. The one question I have is how hard would it be to insert the line manually and then update it through AFS? Kind of hard for me to make suggestions since we don't use the sales order sessions.

ashishjain
4th August 2011, 12:20
User dont need to insert the line manually. The requirement is...

1. We have created a new table tdslsxxx which contains Warehouse (Index), Freight Item (Cost Type) and Freight Percentage.

2. User will create a sales order with say n lines.

3. Whenever user will save & exit sales order line session, afs will get the total net amount of all sales order line with same warehouse. If warehouse entry is present in table tdslsxxx then AFS will add Freight Item to sales order line with amount = (Net Amount from sales order line for warehouse * Freight Percentage)/100

Example:Line 1 Item1 $200 WH1
Line 2 Item1 $300 WH2
Line 3 Item1 $200 WH1

Total For Warehouse WH1 = $400
Total For Warehouse WH2 = $300
Table tdslsxxx is having a record for Warehouse=WH1, Freight Item= FItem, and Freight Percentage = 15%

Freight Item Amount = $400 x 15%
= $60


So the Sales order line session will looks like...
Line 1 Item1 $200 WH1
Line 2 Item1 $300 WH2
Line 3 Item1 $200 WH1
Line 4 FItem $60

The problem is, instead of Line4, session should take Line901(Defined at script level).

I think i have figured out the problem but not tried yet.
I am assigning Sales order line position while calling the AFS. When AFS invokes sales order line session, SO Line position number is getting re-assigned by standard process (Or you can say logic written in sales order line script). I assume that if we can write below code in sales order line script just after standard process assign the position number then we don't face any problem....

If api.mode then
tdsls041.pono = User Defined Position Number
Endif

mark_h
4th August 2011, 15:19
Bad choice of words on my part - what I was suggesting was to just use baan sql to insert the line, then AFS code to update the line to what it needs. Just a quick db.insert on the table with the line. But if you have the source code, then you suggestion is better.