how to insert multiple values from temporary table to my main table

Hai To all ,

i have one temporary table in that i create field in header ( cust account , invoice account , purch id, sales name,sales id ) and in lines ( item number , qty , unit price , proj id ) from here i want to insert values to my main table (sales order) …

here i create class and write coding for insert values from temporary table to my main table ( sales order)…

now i want to insert multiple values from temporary table to my main table ( sales order) … what can i do for that ???

while select HeaderTable

{

NumberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().numberSequence);

sid=NumberSeq.num();

salesTable.SalesId = sid;

salesTable.initValue();

salesTable.CustAccount = HeaderTable.CustAccount;

salesTable.InvoiceAccount = HeaderTable.InvoiceAccount;

salesTable.CurrencyCode = ‘USD’;

salesTable.initFromCustTable();

salesTable.insert();

salesTable.clear();

while select LineTable

{

sl.SalesId=sid;

sl.ItemId = LineTable.ItemId;

sl.CreateLine(NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes,NoYes::Yes);

info(“Sales Order Created with Line”);

fl=SalesFormLetter::construct(DocumentStatus::Invoice);

fl.update(SalesTable::find(sid));

info(“Sales Order Posted”);

hai every one for creating temporary table and insert values to main table ( sales order)

here i use codes in class are given here

public class TmpSalesOrder

{

SalesTable salesTable;

SalesLine salesLine;

HeaderTable headerTable;

LineTable lineTable;

NumberSeq NumberSeq;

SalesId sid;

SalesLine sl;

SalesFormLetter fl;

TmpSalesOrder tmpSalesOrder;

int counter;

}


Public void create(SalesTable _salesTable)

{

;

ttsbegin;

while select forupdate headerTable where HeaderTable.CustAccount == _salesTable.CustAccount

{

HeaderTable.Creation=“yes”;

HeaderTable.ErrorStatus=StatusOfErrors::No;

HeaderTable.ErrorMessage= “Sucess”;

HeaderTable.update();

}

ttscommit;

}


public void errorDetails(SalesTable _salesTable)

{

;

ttsbegin;

while select forupdate headerTable where HeaderTable.CustAccount == _salesTable.CustAccount

{

headerTable.ErrorStatus=StatusOfErrors::Yes;

headerTable.Creation = “No”;

headerTable.ErrorMessage = " values are not inserted ";

headerTable.update();

}

ttscommit;

}


public void insertGateLines()

{

;

ttsbegin;

while select HeaderTable

{

NumberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().numberSequence);

sid=NumberSeq.num();

salesTable.SalesId = sid;

salesTable.initValue();

salesTable.CustAccount = HeaderTable.CustAccount;

salesTable.InvoiceAccount = HeaderTable.InvoiceAccount;

salesTable.CurrencyCode = ‘USD’;

salesTable.initFromCustTable();

salesTable.insert();

salesTable.clear();

while select lineTable where lineTable.SalesId == headerTable.PurchId

{

if(InventTable::find( lineTable.ItemId ))

{

//sl.clear();

sl.SalesId=sid;

sl.ItemId = LineTable.ItemId;

sl.createLine(true, true, true, true, true, true);

tmpSalesOrder = new TmpSalesOrder();

tmpSalesOrder.create(SalesTable);

}

else

{

tmpSalesOrder = new TmpSalesOrder();

tmpSalesOrder.errorDetails(salesTable);

}

}

}

Info(“Sucess”);

ttscommit;

}


public static TmpSalesOrder construct()

{

return new TmpSalesOrder();

}


static void main(Args args)

{

TmpSalesOrder TmpSalesOrder;

;

TmpSalesOrder = new TmpSalesOrder();

TmpSalesOrder.insertGateLines();

}


i create a temporary table for insert values and create a button for pass values from tmp table to main table ( sales order)
with the following code using in class … i use this fields for insert values in my tmp table and the help of copylines button i pass the values to main table ( sales order) …