Helios Auto ApS, Tølløsevej 47, DK-2700 Brønshøj - +45 4457 0088 - hotline@heliosauto.dk
There are two ways of reading data from and writing data to a sales order. It is important to differentiate between programs run directly from the sales order window and programs run from for example a button on the Helios Desktop.
Importing data to the currently open sales order
The following is an example of how to import data using a program that is called directly from the sales order window. The data does not show how the data to be imported is read (eg. from an .xml or .txt file etc.) but only how it is imported to the sales order.
Creating a new salesorder
The following is an example of how to create a new salesorder using a program that is not called from the sales order window. The program imports customer data to the sales order head and two order lines, one of which contains data from the stock register.
New(CustomerTable, Create(REG_CUSTOMER));
New(SalesOrderHTable,Create(REG_SALESORDERHEAD));
New(SalesOrderLTable,Create(REG_SALESORDERLINE));
New(OrderHandler,Create(REG_SALESORDERHEAD,REG_SALESORDERLINE,TRUE));
CustomerNo := StrToCode('12345678');
Dept := NUL_CODE;
ItemNo := StrToCode('SERVICE-FEE');
FromDate := StrToDate('010111');
ToDate := StrToDate('311211');
IF CustomerTable.FindSingleEqRec(KEY_PRIM,CustomerNo) THEN
{ Customer found - Initialize new order }
OrderHandler.Init;
{ Fill order header }
WITH SalesOrderHTable DO BEGIN
InitRec(TRUE);
LoadSalesOrderCustomer(SalesOrderHTable,CustomerNo);
SetAsDate(1160,GetDate);
SetAsStr(2010,'Autotaks abonnement');
SetCurOrderRec;
END{endwith - salesorderhtable};
{ Add two lines }
WITH SalesOrderLTable DO BEGIN
{ Add a text line }
InitRec(TRUE);
SetAsStr(1100,'This invoice covers '+DateToStr(FromDate)+' - '+DateToStr(ToDate));
SetAsInt(1180,0);
SetCurOrderRec(1);
OrderHandler.RecalcLineOnOrder(1,FALSE);
{ Add a stock item }
InitRec(TRUE);
LoadSalesOrderLineFromStock(SalesOrderLTable,ItemNo,CustomerNo,Dept);
SetAsInt(1180,1);
SetCurOrderRec(2);
OrderHandler.RecalcLineOnOrder(2,FALSE);
END{endwith - salesorderltable};
OrderHandler.Recalc;
OrderHandler.Save(OrderNo,FALSE);
END{endif - customer found and order created };