Question Status

Suggested Answer
snoppy asked a question on 25 Aug 2014 10:54 PM

Hi expert, I want to import the open sales order number from the sales header  table to another table B (sales number only),  if  the same sales order number already exists in B, it will not be imported. If I write a report with process only, how to accomplish this? Thank you!

Reply
Suggested Answer
Mohana Yadav responded on 26 Aug 2014 12:02 AM

Did you try anything?

Please share what you have tried and what problem are you facing.

Reply
Suggested Answer
jonathan archer responded on 30 Sep 2014 12:56 PM

hi,

do the following.

the report data item:

DataType Data Source Name
DataItem Sales Header <Sales Header>
Column "Document Type" DocType
Column "No." DocNo

report properties:

ProcessingOnly = Yes

data item "Sales Header" properties:

DataItemTableView =  WHERE(Document Type=CONST(Order))
// to get only sales orders

press F9 to open the code editor

write following code:

under trigger OnPreReport()
---------------------------------
counter := 0;
skipCounter := 0;

under trigger OnPostReport()
---------------------------------
MESSAGE('done! \' + FORMAT(counter) + ' sales order nos imported.\' + FORMAT(skipCounter) + ' nos skipped.');

under trigger "Sales Header - OnAfterGetRecord()"
----------------------------------------------------------
local variables:
Name DataType Subtype
SalesOrderListLoc Record Sales Order List
// table "Sales Order List" ist the new table B 
// with only 1 field "Document No." (Code 20) 

----------------------------------------------------------
IF NOT SalesOrderListLoc.GET("Sales Header"."No.") THEN BEGIN
 SalesOrderListLoc.INIT;
 SalesOrderListLoc."Document No." := "Sales Header"."No.";
 SalesOrderListLoc.INSERT;
 counter += 1;
END ELSE
 skipCounter += 1;

used global variables:
----------------------------------------------------------
counter: Integer
skipCounter: Integer

best regards

Please verify the satisfying answer(s).

Reply
Suggested Answer
Mohana Yadav responded on 26 Aug 2014 12:02 AM

Did you try anything?

Please share what you have tried and what problem are you facing.

Reply
Suggested Answer
jonathan archer responded on 30 Sep 2014 12:56 PM

hi,

do the following.

the report data item:

DataType Data Source Name
DataItem Sales Header <Sales Header>
Column "Document Type" DocType
Column "No." DocNo

report properties:

ProcessingOnly = Yes

data item "Sales Header" properties:

DataItemTableView =  WHERE(Document Type=CONST(Order))
// to get only sales orders

press F9 to open the code editor

write following code:

under trigger OnPreReport()
---------------------------------
counter := 0;
skipCounter := 0;

under trigger OnPostReport()
---------------------------------
MESSAGE('done! \' + FORMAT(counter) + ' sales order nos imported.\' + FORMAT(skipCounter) + ' nos skipped.');

under trigger "Sales Header - OnAfterGetRecord()"
----------------------------------------------------------
local variables:
Name DataType Subtype
SalesOrderListLoc Record Sales Order List
// table "Sales Order List" ist the new table B 
// with only 1 field "Document No." (Code 20) 

----------------------------------------------------------
IF NOT SalesOrderListLoc.GET("Sales Header"."No.") THEN BEGIN
 SalesOrderListLoc.INIT;
 SalesOrderListLoc."Document No." := "Sales Header"."No.";
 SalesOrderListLoc.INSERT;
 counter += 1;
END ELSE
 skipCounter += 1;

used global variables:
----------------------------------------------------------
counter: Integer
skipCounter: Integer

best regards

Please verify the satisfying answer(s).

Reply