Skip to end of metadata
Go to start of metadata

The System Landscape Directory of SAP NetWeaver (SLD) serves as a central information repository for your system landscape. A system landscape consists of a number of hardware and software components that depend on each other with regard to installation, software updates, and demands on interfaces.

● SLD stores information about all installable and installed components of a system landscape. SLD is based on the Common Information Model (CIM) standard. This standard is a general, extensible schema for describing the elements in a system landscape. SAP has enhanced the CIM standard with classes for SAP-specific content.

● SAP provides both a Web-based user interface (UI) for interactive access and client APIs for programmatic access in ABAP and Java.

● SLD provides information about installable SAP software, dependencies and recommended scenarios and regularly publishes updates on SAP Service Marketplace. You can browse this information in the software catalog views. You can also manually add information about third-party components to the SLD.

● In addition, you can use the SLD to reserve component names in the SAP NetWeaver Developer Infrastructure (NWDI). It contains the master list of all reserved names used in development, such as development component names, Java package names, and database object names.

● SAP NetWeaver Process Integration (PI) uses the SLD to store information about business systems, which are logically connected to technical systems.

  • SAP software components that are installed on technical systems are registered automatically and on a regular basis in the SLD. Thus the SLD always contains up-to-date information about the installed system landscape. You can view this information in the technical systems views, and can aggregate and group it in the landscapes views.

Common Information Model The Common Information Model (CIM) is a standard of the Distributed Management Task Force (DMTF) and is based on the object-oriented modeling approach. This standard provides an implementation-neutral schema to describe management information within a computing environment.

 The following report will help you to read all the systems and respective software components and releases installed ; in the complete landscape with the help of SLD. In addition to that it provides you the message server name for each system. The technical background of this is to create a CIM instance of an implementing class and query the information with the help of that.

  **--type creation to store final detail of software component and release installed in the landscape
types : begin of ty_software_comp,
          mandt type  mandt,
          system_name  type string,
          software_comp type  dlvunit,
          sys_release type  saprelease,
          message_server type  rfchost_ext,
          comp_type type  relc_type,
        end of ty_software_comp.

***Declaration to get SLD estination and port details from remote system
data: lt_destinations  type table of sld_s_accessdata_display,
      lt_return type  table of bapiret2.

field-symbols: <sld_details> like line of lt_destinations.

**Variables to hold port and host details
data: l_sld_host      type string,
      l_sld_port      type i.

**SLD service APi
data : l_ref_sld_service  type ref to  cl_siln_sld_services.

**SLD API declaration
data : accessor           type ref to cl_sld_accessor,
       ex                 type ref to cx_sld_api_exception,
       ex_ser             type ref to cx_siln_sld_services_exception,
       lt_ref_enumerated  type        sld_t_instref,
       system             type        string,
       host               type        rfchost_ext.

**Tables for data collection
data : lt_app_sys_swcv    type         siln_tt_appsys_swcv,
       ls_app_sys_swcv    like line of lt_app_sys_swcv,
       ls_app_sys         type         siln_ts_appsys,
       ls_soft_comp       type         siln_ts_swcv,
       l_ref_cim_instance type ref to cl_sld_cim_instance.

**Message server
data : lt_msg_server      type siln_tt_appsys_msgsrv,
       ls_msg_server      like line of lt_msg_server,
       ls_ms              type siln_ts_msgsrv,
       ls_app_sys_msg_ser type siln_ts_appsys.

**structure for component table
data : ls_software_com type ty_software_comp.

data : lt_result_soft_comp type table of ty_software_comp.

**--Input parameters
**-i_user  the user name of the system whose landscape you want to read
**-i_pass  password of the system for the given user
**-i_rfc   rfc of the system whose landcape info we need

parameters : i_user  type string obligatory,
             i_pass type string obligatory,
             i_rfc type rfcdest.

**Get port details from remote system if not passed
call function 'BAPI_SLD_DEST_LIST' destination i_rfc
    destinations = lt_destinations
    return       = lt_return.
if lt_destinations is not initial.
*TODO: verify this index 1, also handle error using lt_return!!!!!
**Index can vary but the primary flag in the table will prove the port details
  read table lt_destinations assigning <sld_details> with key primary = 'X'. "index 1.
  if sy-subrc <> 0.
**-- Crep: Y ppl didn't configure primary SLD
**--Ohh shit : No SLD configured for the system

**Type cast values
l_sld_host = <sld_details>-host.
l_sld_port = <sld_details>-port.

**Object for sld services
    create object l_ref_sld_service
        iv_alias     = 'sld/active'
        iv_namespace = 'sld/active'
        iv_user      = i_user
        iv_password  = i_pass
        iv_host      = l_sld_host
        iv_port      = l_sld_port.
  catch cx_sld_api_exception into ex.
**--TODO: Exception Handling according to your project

class cl_sld_util definition load.

* Create accessor object to SLD server:

    create object accessor
        host     = l_sld_host
        port     = l_sld_port
        user     = i_user
        password = i_pass.
  catch cx_sld_api_exception .
**--TODO: Exception Handling according to your project

* set trace level for java logging.
* 0 = none, ..., 6 = finest.
accessor->set_tracelevel( 1 ).

* Test the connection to the SLD server:
    accessor->ping( ).
  catch cx_sld_api_exception into ex.
**--TODO: Exception Handling according to your project

**Get enumerated instances for Systems connected to active SLD
lt_ref_enumerated =
  accessor->enumerate_instances( cname  = 'SAP_BCSystem' ).

**Loop on  instances
loop at lt_ref_enumerated into l_ref_cim_instance.
**Get system name from instance
  system = l_ref_cim_instance->get_property( 'SAPSystemName' ).
**Get host name from instance
  host   = l_ref_cim_instance->get_property( 'SystemHome' ).

**Prepare system details for which components needs to be searched
  ls_app_sys-sysname       = system.
  ls_app_sys-creationclass = 'SAP_InstalledSWComponentOnApplicationSystem'.
  ls_app_sys-cim_instance  = l_ref_cim_instance.
  ls_app_sys_swcv-appsys = ls_app_sys.
  append ls_app_sys_swcv to lt_app_sys_swcv.

**Get Software component and release for given system
  try .
              ct_appsys_swcv =  lt_app_sys_swcv
    catch cx_sld_api_exception into ex.    " SLD API Exceptions
**--TODO: Exception Handling according to your project
    catch cx_siln_sld_services_exception into ex_ser.    " ILN SLD Services: Exception
**--TODO: Exception Handling according to your project

**Get message server details
**Prepare system details for which message server needs to be searched
  ls_app_sys_msg_ser-sysname        = system.
  ls_app_sys_msg_ser-creationclass  = 'SAP_BCSystem'.
  ls_app_sys_msg_ser-cim_instance   = l_ref_cim_instance.
  ls_msg_server-appsys = ls_app_sys_msg_ser.
  append ls_msg_server to lt_msg_server.

**Get message server details for given application system
  try .
          ct_appsys_msgsrv = lt_msg_server
    catch cx_sld_api_exception into ex.    " SLD API Exceptions
**--TODO: Exception Handling according to your project
    catch cx_siln_sld_services_exception into ex_ser.    " ILN SLD Services: Exception
**--TODO: Exception Handling according to your project

**Read message server details
  read table lt_msg_server into ls_msg_server index 1.
  if ls_msg_server-msgsrv-hostname is not initial.
    ls_software_com-message_server = ls_msg_server-msgsrv-hostname.

**Get component types
  read table lt_app_sys_swcv into ls_app_sys_swcv index 1.
  if ls_app_sys_swcv is  initial.
**--TODO: Exception Handling according to your project

  ls_software_com-system_name   = system.

**Loop on all components and read component type property
  loop at ls_app_sys_swcv-swcv into ls_soft_comp.
**Read CIM instance
    read table ls_soft_comp-cim_instance into l_ref_cim_instance index 1.
    ls_software_com-comp_type     =  l_ref_cim_instance->get_property( 'CompType' ).
    ls_software_com-software_comp =  ls_soft_comp-componentname.
    ls_software_com-sys_release   =  ls_soft_comp-version.
    append ls_software_com to lt_result_soft_comp.

**Clear contents for next loop
  clear : lt_app_sys_swcv,
**--Now once the Magic will give you the information you needed in lt_result_soft_comp