Skip to end of metadata
Go to start of metadata

Author: Marc Bernard, SAP Techology RIG
Submitted: 2010-07-26

Description:
This snippet gives three examples on how to use the API for reading BW master data and attributes.

Related Links:
SAP NetWeaver Developer's Guide for BIM Scenarios:
https://www.sdn.sap.com/irj/sdn/devguide2004s
> IT-Scenario-Driven Enhancements to Applications
> Enterprise Data Warehousing

Data Definitions
  DATA:
    l_chavl        TYPE rsd_chavl,
    i_co_area      TYPE /bi0/oico_area,
    i_costcenter   TYPE /bi0/oicostcenter,
    e_obj_curr     TYPE /bi0/oiobj_curr,
    es_wbs_elemt   TYPE /bi0/mwbs_elemt,
    et_country     TYPE TABLE OF /bi0/mcountry.
EXAMPLE 1: Read one attribute
* Look-up object currency attribute value on cost center 
  CONCATENATE i_co_area i_costcenter INTO l_chavl.
  
  CALL FUNCTION 'RSAU_READ_MASTER_DATA'
    EXPORTING
      i_iobjnm                = '0COSTCENTER'
      i_chavl                 = l_chavl
      i_attrnm                = '0OBJ_CURR'
    IMPORTING
      e_attrval               = e_obj_curr
    EXCEPTIONS
      read_error              = 1
      no_such_attribute       = 2
      wrong_import_parameters = 3
      chavl_not_found         = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
EXAMPLE 2: Read all attributes
* Lookup various attributes on wbs element
  l_chavl = i_wbs_elemt.

  CALL FUNCTION 'RSAU_READ_MASTER_DATA'
    EXPORTING
      i_iobjnm                = '0WBS_ELEMT'
      i_chavl                 = l_chavl
    IMPORTING
      e_structure             = es_wbs_elemt
    EXCEPTIONS
      read_error              = 1
      no_such_attribute       = 2
      wrong_import_parameters = 3
      chavl_not_found         = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
EXAMPLE 3: Read all characteristic values
* Look-up all countries
  CALL FUNCTION 'RSAU_READ_MASTER_DATA'
    EXPORTING
      i_iobjnm                = '0COUNTRY'
      i_flg_whole_table       = 'X'
    IMPORTING
      e_table                 = et_country
    EXCEPTIONS
      read_error              = 1
      no_such_attribute       = 2
      wrong_import_parameters = 3
      chavl_not_found         = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.

2 Comments

  1. This page content help me. Thank you.

  2. Has this FM RSAU_READ_MASTER_DATA been updated with a Class?  I looked at cl_rsdmd_lookup_master_data, but it has too many steps.  

    CREATE_KEYS_TABLE, PREFETCH, FETCH etc...   Thanks for any input.