Loading the temporary table

To load data into temporary table used for transaction list, you must write several procedures that work together to add the records to the temporary table. For transaction lists, the data loading process runs in the background, and can be stopped by the user, so these procedures must have special code to handle this situation.

If you don’t want the user to be able to stop the data loading process for your transaction list, you won’t need to have these procedures. Instead, you can load data into the transaction list using the same technique used for the card list.


The LoadData procedure actually loads the data into the temporary table. The name given to this procedure typically indicates which table the data is being loaded into. For example, the LoadData_ContactHistoryTrxTemp procedure is used to load data in to the temporary table for the Contact History list.

The LoadData procedure uses the OkCallBackScript callback procedure defined in the transaction list object form. This callback is used to find out whether the user has stopped the data loading process for the list. After every group of 10 records is loaded, the callback should be checked to find whether the user has clicked Stop.

If the transaction list will be displaying the Information Icon, this procedure should also set the initial value of the InfoValue field that is part of the temporary table definition. The InfoValue_SetState() function of the syListObj form in the Dynamics.dic dictionary should be used to specify the values for the InfoValue column. The icon of the highest-priorty state will be displayed for the list. The tooltip for the icon will display all of the states that have been set.

The following is the LoadData_ContactHistoryTrxTemp procedure that loads the temporary table for the Contact History list. Notice that it retrieves data from the following tables:

 

Notice that it uses the OKCallBackScript callback from the list object, and that it also keeps track of the total number of records added to the temporary table. The procedure also sets the initial value of the Information Icon that is displayed for the list.

inout ListObjState list_object;
inout long nRecCount;

local integer nStatus;
local text sCriteria;
local string sStartDateRestrict, sEndDateRestrict;
local boolean fOk;
local integer iCount;

default window to State;

range clear table RM_Customer_MSTR;

get first table RM_Customer_MSTR;
nStatus = err();

while nStatus <> EOF do
	increment nRecCount;

	clear table(list_object:'Table Reference');

	{Get data from the RM_Customer_MSTR table}
	'Customer Number' of table(list_object:'Table Reference') = 'Customer Number' of table RM_Customer_MSTR;
	'Customer Name' of table(list_object:'Table Reference') = 'Customer Name' of table RM_Customer_MSTR;
	'Active' of table(list_object:'Table Reference') = not 'Inactive' of table RM_Customer_MSTR;

	{Set the value to use for the Information Icon column}
	if Hold of table RM_Customer_MSTR = true then
		InfoValue_SetState(InfoValue of table(list_object:'Table Reference'), INFOVALUE_ONHOLD) of form syListObj;
	else
		InfoValue_ClearState(InfoValue of table(list_object: 'Table Reference'), INFOVALUE_ONHOLD) of form syListObj;
	end if;

	{Get data from the IG_Contact_History_MSTR table}
	'Customer Number' of table IG_Contact_History_MSTR =  'Customer Number' of table(list_object:'Table Reference');
	get table IG_Contact_History_MSTR by number 1;

	if err() = OKAY then
		'First Contact Date' of table(list_object:'Table Reference') =  'First Contact Date' of table IG_Contact_History_MSTR;
		'Contact Salesperson ID' of table(list_object:'Table Reference') = 'Contact Salesperson ID' of table IG_Contact_History_MSTR;

		'Last Contact Date' of table(list_object:'Table Reference') = 'Last Contact Date' of table IG_Contact_History_MSTR;
		'Contact Salesperson ID 2' of table(list_object:'Table Reference') = 'Contact Salesperson ID 2' of table IG_Contact_History_MSTR;
	end if;

	{Save the record in the temporary table}
	save table(list_object:'Table Reference');

	field(list_object:RecCountStringRef) = str(nRecCount) + CH_SPACE + '(L) TrxString';
	field(list_object:LoadingRecCountStringRef) = '(L) LoadingString' + CH_SPACE + str(nRecCount) + CH_SPACE + '(L) TrxString';

	increment iCount;
	if iCount = 10 then {Check if we should continue}
		call foreground with name list_object:OkCallBackScript in dictionary DYNAMICS, 'Window Title', fOk;
		if not fOk then
			abort script;
		end if;
		iCount = 0;
	end if;

	if nRecCount = 50 then
		call foreground with name list_object:OkCallBackScript in dictionary DYNAMICS, 'Window Title', fOk;
		if fOk then
			call foreground with name list_object:FillListCallBackScript in dictionary DYNAMICS;
		else
			abort script;
		end if;
	end if;

	get next table RM_Customer_MSTR;
	nStatus = err();
end while;

The LoadBackground procedure is called by the Refresh procedure (which will be added later) to actually fill the temporary table in the background. This procedure calls the LoadData procedure, filling the temporary table. The following is the LoadBackground procedure for the Contact History list.

inout ListObjState list_object;
inout long nRecCount;

local boolean fOk;

default window to State;

call foreground with name list_object:OkCallBackScript in dictionary DYNAMICS, 'Window Title', fOk;
if fOk then
	call LoadData_ContactHistoryTrxTemp of form ListObj_ContactHistoryTrx, list_object, nRecCount;
else
	abort script;
end if;


Documentation Feedback