Understanding SLD API for mass creation of business systems / other SLD objectsPosted: November 6, 2014 | Author: singhvikas | Filed under: Uncategorized |Leave a comment
From my blog on SCN:
I had to recently work with SLD API to mass create business systems. There were over thousands of business systems to be created and we needed a solution to automate the process as going to SLD for each business system creation will be very time consuming process as the tasks require business system creation, linking with other business systems etc.
Overview of the steps involved.
1. Navigate to SLD and look at the Development area . Click on CIM Classes ( bottom right in the below image ).
- Find the CIM class you’re interested in – in our case we’re interested in “Business System”.
- Click on the Class Diagram. This is important as this will understand objects that need to be created. This is important to understand as when we create a business system, system creates various objects – the class diagram helps to understand the relationships. Some objects are directly linked and others have an indirect relationship.
- Again in SLD Development area, click on CIM Classes and chose the class name as “Business System”.
Chose a business system to display. All associations need to be created for successful creation of business system.
- Look at examples in package SLD_API. You can do a good test by copying program SLDAPI_READ_EXAMPLE to do a read test and SLDAPI_WRITE_EXAMPLE for writing to SLD.
With information from these three sources, we’re good to start ABAP development.
Steps to get a handle of a SLD object
- SLD operations require the “handle” of the object to be retrieved before it can be used for operations. It involves the following steps
- Create a filter using class CL_SLD_FILTER.
- Add pattern to the filtter for property “Name” and the value. It will be the object value . Look in SLD CIM Instance to get the string to be created. As an example, technical system name is <TS_NAME>.Systemhome.<Hostname>
- Get the list of instances by supplying cname as the name for the object and filter object created.
- Loop at instances and get the ‘CreationClassName’ . If the value matches the classname we’re looking for, store the object.
- Call get_objectname to get the system handle.
E.g sample code for creating technical system
concatenate p_tec_sys_name ‘.SystemHome.’ p_hostname into lv_tech_sys_full_name.
create object lo_filter. lo_filter->add_pattern( pname = ‘Name’ value = lv_tech_sys_full_name ).
lt_instances = o_accessor->enumerate_instances( cname = gc_sap_appl_sys filter = lo_filter ). “’SAP_ApplicationSystem
loop at lt_instances into lo_instance. lv_classname = lo_instance->get_property( pname = ‘CreationClassName’ ). i_sld = lo_instance->get_properties( ).
if lv_classname = gc_sap_standal_sys . “’SAP_StandaloneJavaSystem’ c_tec_sys = lo_instance. c_tec_sys_handle = lo_instance->get_objectname( ). exit. endif.
Process of creating SLD objects:
- Create an object of type CL_SLD_CIM_INSTANCE passing the classname from SLD CIMInstance and accessor ( an object of type reference to class CL_SLD_ACCESSOR ).
- Set property ‘CreationClassName’ as the name of the class from SLD CIMInstance.
- Set property name
d) Set any other attribute ( like caption , description etc )
- Finally write to SLD by using CREATE_INSTANCE method of accessor ( reference to class CL_SLD_ACCESSOR )
create object lo_bus_sys “type CL_SLD_CIM_INSTANCE exporting classname = gc_sap_bus_sys “’SAP_BusinessSystem’ accessor = o_accessor. “type CL_SLD_ACCESSOR
lo_bus_sys->set_property( pname = ‘CreationClassName’ value = gc_sap_bus_sys ). “SAP_BusinessSystem
lo_bus_sys->set_property( pname = ‘Name’ value = p_bus_system ).
…….Set other attributes…..c_handle = o_accessor->create_instance( iref = lo_bus_sys ). “c_hanlde is a string
Steps we took to create business systems:
- Get handle of PI Integration Server Business system
- Get handle for the group of business systems we’ll be creating
- Get handle of technical system
- Create business system
- Create business system GUID
- Attach GUID to the business system
- Create entry for SAP_BusinessSystemViewedStandaloneJavaSystem ( using BS and TS handle – it links the BS and TS )
- Create entry for SAP_BusinessSystemExchangeServer ( using BS and IS ( Integration Server ) handle – it assigns the IS for the BS )
- Create entry for SAP_LogicalALESystem
- Create entry for SAP_ALESystemViewedBusinessSystem
- Add the business system to collection using the group handle from b)
- Create relationship with other business systems ( dev -> pre-prod, prod etc).