Centralize all your Instance List Activities

Visual LANSA Framework

Centralize all your Instance List Activities

Once you start to centralize all your instance lists management code into a single manager component you will find it can be used in many different ways.

For example, command handlers often need to update details in the instance list when the user updates something. For example, this command handler would need to update the instance list if the user changed the employees' name:

 

If #EMPMNGR had a shared method like this:

MthRoutine UpdateListDetails

Define_Map *Input #vf_lm002 #ListManager Pass(*By_Reference)

Define_Map *Input #EmpNo    #ForEmpNo

 

Fetch fields(*all) from_file(PSLMST) with_key(#ForEmpno)

 

Invoke #ListManager.BeginListUpdate Mode(DYNAMIC)

 

#FullName := #GiveName + " " + #SurName

 

Invoke Method(#ListManager.UpdateListEntryData) Visualid1(#Empno) Visualid2(#FullName) Akey1(#Deptment) Akey2(#Section) Akey3(#Empno) AColumn1(#Phonehme) AColumn2(#Address1) nColumn1(#PostCode)

 

Invoke #ListManager.EndListUpdate

 

EndRoutine

 

Then all any command handler would need to do to update the instance list is declare the shared #EMPMNGR like this …

DEFINE_COM CLASS(#EMPMNGR) NAME(#EmployeeManager) scope(*Application)

  

and then invoke the method to update the employees' instance list details ….

#EmployeeManager.UpdateListDetails ListManager(#avListManager) ForEmpno(#Empno)

  

The benefit here of course is that all command handlers working with employee information could reuse the UpdateListDetails method and none of them even need to understand how this is done.

Sometimes command handlers also need to delete individual entries from the instance list, so if the centralized instance list manager contained a method like this:

MthRoutine DeleteListDetails

Define_Map *Input #vf_lm002 #ListManager Pass(*By_Reference)

Define_Map *Input #EmpNo    #ForEmpNo

Define_Map *Input #Deptment #InDepartment

Define_Map *Input #Section  #InSection

 

Invoke #ListManager.BeginListUpdate Mode(DYNAMIC)

 

Invoke Method(#ListManager.RemoveFromList) Akey1(#InDeptment) Akey2(#InSection) Akey3(#ForEmpno)

 

Invoke #ListManager.EndListUpdate

 

EndRoutine

 

Then any command handler would only need to declare the shared manager:

DEFINE_COM CLASS(#EMPMNGR) NAME(#EmployeeManager) scope(*Application)

  

and invoke the method like this:

#EmployeeManager.DeleteListDetails ListManager(#avListManager) ForEmpno(#Empno) InDepartment(#Deptment) InSection(#Section)

 

to delete the details of an employee from an instance list.