## Adding User Defined Actions to the MultidimensionalTable Model

The MultidimensionalTable model retrieves its popup actions from the underlying EIS multidimensional model. If user-defined actions have been added to an EIS application (through model overrides) or to a subclass of EMDDB_M, then these actions will automatically be included in the MultidimensionalTable model. Likewise, actions removed from the list will not be included.

To remove actions through the EIS application builder, select the Advanced button and then select the Actions button. Use the dual listbox to remove any unwanted actions.

To add an action, some code is required. If the action to be added is specific to one EIS application, you can use the EIS application builder to override the _SET_APPLICATION_ method and add the necessary code. Select the Advanced button and then select the Methods button. Add the code in a model method. The code changes will then be picked up by the thin client.

If the actions that you want to add will be used with many applications, you should create a subclass of SASHELP.EIS.EMDDB_M that can be used with any application that requires the additional actions. The subclass should add the actions through an override of the _SET_APPLICATION_ method.

To have an EIS application use the subclass, select the Advanced button and then modify the Model entry. If you are running with the thin client and are not using an existing EIS application, you can add the MODEL attribute to your metabase registration. The MODEL attribute's value is equal to the four-level catalog entry name of the subclass that you want to use.

For more information on creating and using EMDDB_M subclasses, see the webEIS example titled Overriding a Method on the AppDev Studio Developer's Site.

If the action added is going to be used with both a thick client (SAS/EIS) and a thin client (webEIS or webAF), it is best to follow the EIS documentation for adding actions. Note: The code must be added to the model, not to the viewer. Again, the _SET_APPLICATION_ method of the model is recommended.

For applications running on the thin client, a convenience method, _addAction, has been added to the EMDDB_M model to facilitate adding actions. This method adds the information to the appropriate lists while hiding the implementation details. To avoid a program halt when the code is run in SAS/EIS, it is recommend that _HAS_METHOD_ be called on the object before calling _addAction. Note: The action will not be added when run in SAS/EIS. If you have your own subclass of EMDDB_M, you can always add a method similar to _addAction to it. In this fashion, the method will be present for both the thin client and SAS/EIS.

### _addAction(actionName, actionLabel, methodName, <pos>)

actionName defines a unique character string identifier. It is used to identify the action leaving the label translatable for internationalization. Traditionally, EIS uses CL_<actionName> to identify its actions (for example, CL_DRILL for Drilldown). To avoid potential conflicts if you use a prefix, select something other than CL_.

actionLabel defines the text displayed in the popup menu. The text is assumed to be in its internationalized form. Callers of this method should translate the text before passing it to _addAction.

methodName defines the name of the method to run when the action is selected. This method is assumed to exist on the model. If the method does not exist, the action will not be added. If this method performs an action that requires a refresh of the thin client viewer, then this method should send the NEEDSREFRESH event. Otherwise, no refresh of the thin client viewer will take place.

pos is an optional argument that indicates where to add the action in the list. By default, the action will be added as the last action in the EIS list.

The following is a sample of what the overridden _SET_APPLICATION_ method might look like:

    _self_ = _self_;
    setappl: method appl 8 optional=rc 8;
    call super(_self_, '_SET_APPLICATION_', appl, rc);
    call send(_self_, '_HAS_METHOD_', '_ADDACTION', hasMethod);

       if ( hasMethod = 1 ) then do;

    /* If the method to be driven is an instance method      */
    /* Set the instance method here before calling _addAction */

    call send(_self_, '_SET_INSTANCE_METHOD_', 'SAVEAS',
                'SASUSER.CLASSES.MYMDDB.SCL', 'saveas');

    call send(_self_, '_addAction', 'MY_SAVE_AS', 'Save', 'SAVEAS');
         end;
    endmethod;

    saveas: method optional = name $;
    appl = getnitemn(_self_, 'APPLLIST', 1, 1, 0);
    call send(_self_, '_get_application_', appl);

       if ( name = '' ) then do;
          mbrc = 0;
    	  mbmsg = '';
    	  dataattrs = makelist() ;
    	  _metabasei = getnitemn(envlist('L'), 'METABASE', 1, 1);
    	  _metabase  = getnitemc(appl, 'METABASE', 1, 1, '');
    	  _database  = getnitemc(appl, 'TABLE', 1, 1, '');

    	  call send(_metabasei,'_get_data_attr_',mbrc,mbmsg,
    	            _metabase,_database,dataattrs) ;
    	  name = getnitemc(dataattrs,'ITABLE', 1, 1, '');
    	  rc = dellist(dataattrs, 'Y');
    	  if ( name = '' ) then
    	      name = 'SASUSER.SASAPPL.BOOKMARK.EIS';
    	  end;

      rc = savelist('CATALOG', name, appl, makelist(), 'EIS Bookmark');

    endmethod;