5 1 1 1 1 1 Rating 100% (1 Vote)
As we got a short description of ESDUS and ESRUO and connected FMs in previous parts, then now it's time for examples. Let's start with scenarios which I described in first part
 
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.
 
To be sure you get last document you have to select data from ESRUO table directly, sort it by timestamp and get last object. Then update setting of default document for transaction, in my example for ME52N/53N/54N.

datafs_esruo type esruo.
dataft_esruo type standard table of esruo.
dataf_active type esdus-active.
dataft_esduscom type standard table of esduscom.  

select into corresponding fields of table ft_esruo
  
from esruo
  
where uname eq sy-uname
  and   object_typ eq 'BUS2105'.
  
  
sort ft_esruo by timestamp descending.
  read table ft_esruo index into fs_esruo.
  concatenate fs_esruo-object_id 'A' into f_active.

call function 'ES_READ_USER_SETTINGS'
  exporting
    iaction       'MEPO'
*   IUNAME        = IUNAME
*   IDB           = IDB
*   ILIKE         = ILIKE
  tables
    iesdus        ft_esduscom
   
.

call function 'ES_DELETE_USER_SETTINGS'
 exporting
  iaction        'MEPO'
  ielement       'Application         Req_Process'
*  iactive        =
*  IUNAME          = IUNAME
*  isave           = 'X'
* TABLES
*   IESDUS          = IESDUS
 exceptions
   not_found       1
   others          2
          .
if sy-subrc eq 0.

endif.

call function 'ES_APPEND_USER_SETTINGS'
exporting
  iaction        'MEPO'
  ielement       'Application         Req_Process'
  iactive        f_active
*   IUNAME         = IUNAME
  isave          'X'
* TABLES
*   IESDUS         = IESDUS
  .

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).
 
Example of setting document that will be open by default in ME52N/53N/54N

call function 'ES_READ_USER_SETTINGS'
exporting
  iaction       'MEPO'
*   IUNAME        = IUNAME
*   IDB           = IDB
*   ILIKE         = ILIKE
tables
  iesdus        gt_esduscom
  
.

call function 'ES_DELETE_USER_SETTINGS'
 exporting
  iaction        'MEPO'
  ielement       'Application         Req_Process'
*  iactive        =
*  IUNAME          = IUNAME
*  isave           = 'X'
* TABLES
*   IESDUS          = IESDUS
 exceptions
   not_found       1
   others          2
          .
if sy-subrc eq 0.

endif.

call function 'ES_APPEND_USER_SETTINGS'
exporting
  iaction        'MEPO'
  ielement       'Application         Req_Process'
  iactive        '0019324803V' "Requisition number + mode (V - change, A - display)
*   IUNAME         = IUNAME
  isave          'X'
* TABLES
*   IESDUS         = IESDUS
  .

 
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.

 

Before going to your Z-Transaction call FM ES_DELETE_USER_SETTINGS, in most cases internal table of FG are filled already so you don't need to call ES_READ_USER_SETTINGS before. Like here for Purchase order number

call function 'ES_DELETE_USER_SETTINGS'
 exporting
  iaction        'MEPO'
  ielement       'Application         Po_Process'
*  iactive        =
*  IUNAME          = IUNAME
  isave           'X'
* TABLES
*   IESDUS          = IESDUS
 exceptions
   not_found       1
   others          2
          .
if sy-subrc eq 0.

endif.

 
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.
 
 
This is an example of setting header data of Purchase order expanded or collapsed in ME21N/22N/23N.

call function 'ES_READ_USER_SETTINGS'
exporting
  iaction       'PurchaseOrder'
*   IUNAME        = IUNAME
*   IDB           = IDB
*   ILIKE         = ILIKE
tables
  iesdus        gt_esduscom
  
.

call function 'ES_DELETE_USER_SETTINGS'
 exporting
  iaction        'PurchaseOrder'
  ielement       'DYN_4000-BUTTON TOGGLE_STATE'
*  iactive        =
*  IUNAME          = IUNAME
*  isave           = 'X'
* TABLES
*   IESDUS          = IESDUS
 exceptions
   not_found       1
   others          2
          .
if sy-subrc eq 0.

endif.

call function 'ES_APPEND_USER_SETTINGS'
exporting
  iaction        'PurchaseOrder'
  ielement       'DYN_4000-BUTTON TOGGLE_STATE'
  iactive        '2' "1 = collapsed, 2 = expanded
*   IUNAME         = IUNAME
  isave          'X'
* TABLES
*   IESDUS         = IESDUS
  .

 
Other settings found in ESDUS:
 
ActionElementActiveDescription
MEPOApplication         Po_Process4500000001AXME22N/ME23N: Default document to open and it's display mode
MEPOApplication         Req_Process0019324803VME52N/ME53N/ME54N: Defualt document to open and it's display mode
MEPOSAPLMEGUI/0000      Tree-On ME22N/ME23N: Document overview X = display , empty = hidden
MEPOSAPLMEGUI/0000      Tree-Width374ME22N/ME23N: Document overview width
MEPOTree-Control        Tree-On ME22N/ME23N: Document overview X = display , empty = hidden
MEPOTree-Control        Tree-Width374ME22N/ME23N: Document overview width
MIGO_DEFAULTSA01R01BWART101MIGO: default movement type for A01 (Goods Receipt) R01 (Purchase Order), by analogy to other actions and reference document types
MIGO_DEFAULTSA01R01SOBKZ MIGO: default special stock indication for A01 (Goods Receipt) R01 (Purchase Order), by analogy to other actions and reference document types
MIGO_DETAILACTIVE_TABOK_GOITEM_MATERIALMIGO: Default active tab for details
MIGO_DETAIL_TOGGLERVISIBILITYXMIGO: Colapse or expand Details section
MIGO_FIRSTLINEA01R01MIGO: Default Referenced Document type for Action A01 (by analogy also for other actions)
MIGO_FIRSTLINEACTIONA04MIGO: Default Action for transaction
MIGO_HEADERACTIVE_TABOK_GOHEAD_GENERALMIGO: Default active tab for header
MIGO_HEADER_TOGGLERVISIBILITYXMIGO: Colapse or expand Header section
MIGO_TREEDISPLAYXMIGO: Display Overview (X = display, empty  = hidden)
MIGO_TREEWIDTH160MIGO: Overview tree width
MIROITEM_LIST_VERSION7_6310MIRO: Invoice Items Layout
MIROREFERENZBELEGTYP1MIRO: Default Reference Document Category
MIROTREEV_DISPLAY MIRO: Display / Hide PO worklist
MIROTREE_DISPLAYXMIRO: Display / Hide PO structure
MIROVORGANG1MIRO: Transaction type
PurchaseOrderDYN_4000-BUTTON     TOGGLE_STATE1ME21N/22N/23N: Header section collapsed (1), expanded (2)
PurchaseOrderDYN_4001-BUTTON     TOGGLE_STATE2ME21N/22N/23N: Items section collapsed (1), expanded (2)
PurchaseOrderDYN_4002-BUTTON     TOGGLE_STATE2ME21N/22N/23N: Item details section collapsed (1), expanded (2)
PurchaseOrderHEADER-TABSTRIP     SUBVIEW_INDEX1ME21N/22N/23N: Default tab to be opened on Header section
PurchaseOrderPOHeaderProposer    BSARTNBME21N/22N/23N: Default document type
PurchaseOrderPOHeaderProposer    BUKRS ME21N/22N/23N: Default Company Code
PurchaseOrderPOHeaderProposer    EKGRP ME21N/22N/23N: Default purchase group
PurchaseOrderPOHeaderProposer    EKORG ME21N/22N/23N: Default purchase organization
PurchaseOrderPOItemProposer      AFNAM ME21N/22N/23N: Default Requsitioner
PurchaseOrderPOItemProposer      BEDNR ME21N/22N/23N: Default Tracking Nr
PurchaseOrderPOItemProposer      EEIND ME21N/22N/23N: Default delivery Date
PurchaseOrderPOItemProposer      ELPEI ME21N/22N/23N: Default delivery Date category
PurchaseOrderPOItemProposer      KNTTP ME21N/22N/23N: Default Account Assignment Category
PurchaseOrderPOItemProposer      LGORT ME21N/22N/23N: Default Storage location
PurchaseOrderPOItemProposer      WERKS ME21N/22N/23N: Default Plant
PurchaseOrderShopping-Basket #1  DROP-ONXME21N/22N/23N: Shopping basket on-off
PurchaseOrderitem_view           SUBVIEW_INDEX18ME21N/22N/23N: Default Item Details tab
PurchaseRequisitionDYN_4003-BUTTON     TOGGLE_STATE2ME51N/52N/53N/54N: Header section collapsed (1), expanded (2)
PurchaseRequisitionDYN_4004-BUTTON     TOGGLE_STATE2ME51N/52N/53N/54N: Items section collapsed (1), expanded (2)
PurchaseRequisitionDYN_4005-BUTTON     TOGGLE_STATE2ME51N/52N/53N/54N: Item details section collapsed (1), expanded (2)
PurchaseRequisitionREQ-HEADER-TAB      SUBVIEW_INDEX2ME51N/52N/53N/54N: Default tab to be opened on Header section
PurchaseRequisitionReqProposer         AFNAM ME51N/52N/53N/54N: Default Requsitioner
PurchaseRequisitionReqProposer         BEDNR ME51N/52N/53N/54N: Default Tracking Nr
PurchaseRequisitionReqProposer         EEIND ME51N/52N/53N/54N: Default delivery Date
PurchaseRequisitionReqProposer         ELPEI ME51N/52N/53N/54N: Default delivery Date category
PurchaseRequisitionReqProposer         KNTTP ME51N/52N/53N/54N: Default Account Assignment Category
PurchaseRequisitionShopping-Basket #2  DROP-ONXME51N/52N/53N/54N: Shopping basket on-off
PurchaseRequisitionreq_item_view       SUBVIEW_INDEX11ME51N/52N/53N/54N: Default Item Details tab
RM06BA00USERVARIANTSAP&STANDARDME5A: User variant
RM06BZ00USERVARIANTTESTME56/57: User variant
RM07DOCSPA_AISTRARCHIVEMB51: Default Archive Information Structure
 
 
Hope it will clear a bit how to use ESDUS and ESRUO tables!