Create sales Header and lines from sample header and lines

Hi am new to AX,

I have created custom tables like SampleHeader and SampleLine, also created some fields as same as in sales table.

In sampleListpage form i have placed button to create sales order. i need all the sample header and line information to be inserted to create sales order.

i tried using below code. but for multiple sampleline records how to use while loop to check next record in sample line and create that record in sales line. pls give me some suggestion

// Create the Sales Order

SalesTable salesTable;

NumberSeq NumberSeq;

SalesId sid;

SalesLine sl;

SalesFormLetter fl;

EDILine _EDiLine;

;

NumberSeq =NumberSeq::newGetNum(SalesParameters::numRefSalesId() , true);

sid=NumberSeq.num();

salesTable.SalesId = sid;

salesTable.initValue();

salesTable.CustAccount = EDIHeader.CustAccount;

salesTable.CustomerRef = EDIHeader.EDINumber;

salesTable.initFromCustTable();

salesTable.insert();

Create the Sales Line with the created Sales Order

sl.SalesId=sid;

sl.ItemId=EDILine.ItemId;

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

info(“Sales Order Created with Line”);

If you don’t know how to create a loop, then your thread has a completely misleading name. It’s not about sales orders; you would have the same problem with any other table.

You should first study basics in X++, otherwise you’ll constantly running into many more problems.

Anyway, you can achieve that with while select statement, for example.

I agree martin, pls tell me how to run the loop until the next record is empty. like we do in navision REPEAT… UNTIL NEXT = 0;

I already told you to use while select statement and gave you a link to a more detailed explanation, including examples? What more do you ask for?

How it’s done in Navision is irrelevant. Please self-study at least basic X++ keywords, if nothing else.