1 1 1 1 1 Rating 0% (0 Votes)

Let's discus following scenarios with MM standard transactions:

  1. When you open one of the MM t-codes like ME22N, ME51N or MIGO you see that always you got on the screen one of the latest open document there. Sometimes not last but one of the lasts and you want to make it always last.

  2. You create MM documents using BAPI and you want that next time you open MM t-code which is used to display/edit this document then your document appears on the screen (of course if in the meantime user haven't created anything new)

  3. You have created your own transaction to handle standard process, like creation of purchase orders or purchase requisitions. This transaction is used only in some special occasion like only in case of account assignment category is equal to 'A'. In such case for all documents which are created by your Z-transaction you've set up in user-exit that when standard transaction is called, then you leave it to your Z-transaction. In this case often MM transactions remembers last opened document, which was created by Z-transaction and at each run it will leave to it, so you want to clear the info about last called document from standard t-code.

  4. You want to clear some default settings for the user (or set them) for standard t-code. This could be default value for some fields or toggle status of the section (for example header always expanded, items always collapsed. 

In all of this cases you'll want to look at tables:
  • ESRUO (MM: Recently Used Objects)
  • ESDUS (MM: Dynamic User Settings) 
and to function group MLSO which provides you few nice FM to handle entries in this tables: 
  • ES_READ_USER_OBJECTS
  • ES_APPEND_USER_OBJECTS
  • ES_DELETE_USER_OBJECTS
  • ES_SAVE_USER_OBJECTS
  • ES_READ_USER_SETTINGS
  • ES_APPEND_USER_SETTINGS
  • ES_SAVE_USER_SETTINGS
  • ES_DELETE_USER_SETTINGS
As you can see from the FM names all with the suffix _OBJECTS are connected to table ESRUO and the ones with suffix _SETTINGS with table ESDUS.
 

Firstly I will focus on ESROU table and OBJECTS FM as this one is easier to understand. So ESROU table contains last used MM objects used by each user. Objects are stored by it's BUS object name, so for example last used purchase orders are kept with key USERNAME BUS2012. So if you have a need then you can easily check and use last used objects for each user.

 

Let's go more in details for the OBJECTS FM. First one ES_READ_USER_OBJECTS will return you a table with a list of last used object for given user or if parameter IUNAME is not passed then for current user. Two additional parameters MAXANZ and MAXSTORE are responsible for clearing ESRUO table, if number of entries in ESRUO for given object will be GE than MAXANZ then clearing process will be run. In such case timestamp from line at MAXSTORE position will be used to delete older entries.

call function 'ES_READ_USER_OBJECTS'
  exporting
    iobject_typ       iobject_typ
*   MAXANZ            = 30
*   MAXSTORE          = 100
*   IUNAME            = IUNAME
  tables
    iesruo            iesruo
          
.

Second one ES_APPEND_USER_OBJECTS allows you to add last used objects for the user. Beside IOBJECT_TYP (BUS OBJECT ID) you have to pass IOBJECT_ID which is the document number or vendor number or any other info based on the BUS type. If you will not pass IUNAME it will save data for current user. ISAVE parameter should be changed to 'X' if you would like directly save appended object to database, if you leave it empty then you'll have to call FM ES_SAVE_USER_OBJECTS to save all the changes to DB. I_NO_REFRESH parameter is used to leave internal table of objects in Function Group MLSO without refreshing, for example you may want to use that if you want to append further objects for the same BUS type.

call function 'ES_APPEND_USER_OBJECTS'
  exporting
    iobject_typ        iobject_typ
    iobject_id         
iobject_id
*   IUNAME             = IUNAME
*   ISAVE              = ISAVE
*   I_NO_REFRESH       = I_NO_REFRESH
          .

Third one ES_DELETE_USER_OBJECTS is clearing timestamp of usage for specified object. After calling it you need to call ES_SAVE_USER_OBJECTS to save data to DB. As this FM is only clearing the timestamp then the entries will be in ESRUO table till next call of ES_READ_USER_OBJECTS.

call function 'ES_DELETE_USER_OBJECTS'
  exporting
    iobject_typ       iobject_typ
    iobject_id        
iobject_id
*   IUNAME            = IUNAME
          .

Last one from OBJECTS FM is ES_SAVE_USER_OBJECTS. You have to call it after ES_APPEND_USER_OBJECTS if it was not called with ISAVE parameter set to 'X' or after ES_DELETE_USER_OBJECTS to save changes to DB.

call function 'ES_SAVE_USER_OBJECTS'
* EXPORTING
*   I_NO_REFRESH       = I_NO_REFRESH
          .