CCLM: How to create own attribute and implement BADI to extract value
1 General Information
1.1 About this document
This document is about how to create own attributes in CCLM and implement BADI to extract data and set value for own created attribute, a step by step guide will be provided with snapshots.
The next chapter has implementation details.
1.2 Technical Prerequisite
In this version, detail authorization and technical prerequisite is not discussed. In General, authorization role SAP_CCLM_ALL (with authorization object: SM_CC_AUTH with the ID ‘SM_CC_LIB’ and activity 20 = Change library definition) has to be assigned to user who is responsible in this implementation.
SAP Note 1978139-Custom Code Library: Collection of Custom Attributes via BADI should be implemented to avoid data collection error.
2 Implementation Details
In this document we describe a scenario to create an attribute to keep old package information of custom attribute, in order that in case development class of object is changed, we have different old value and new value.
2.1 Create attribute
T-Code CCLM -> navigation bar ‘Library Definition’ -> tab ‘Attribute’, click button ‘Create’ to create new attribute.
2.2 Assign attribute to custom object
After attribute creation, you have to assign the defined attribute to custom code object in order to show it in the attribute list of object when you browse the “Objects” navigation panel.
Transaction Code ‘CCLM’ -> ‘Library Definition’ -> Tab ‘Objects and Assigned Attributes’.
2.3 Implement BAdI
Once you have defined your custom attributes and know which ones of them should be maintained automatically via a custom collector, then you have to define a customer individual RFC function module or a BADI implementation in your managed system(s) to retrieve the data for the custom attributes and pass it back to CCLM.
As a template please use the existing RFC function module /SDF/GET_CCLM_ATTR_VIA_BADI or implement directly the BAdI /SDF/CCLM_ATTR_BADI. Here we implement BAdI /SDF/CCLM_ATTR_BADI as example.
In managed system, T-code SE18.
Implement method ‘GET_ATTRIBUTES’ to extract data and set CCLM attribute.
2.3.1 Create data type
Create a data type (structure) for attribute in managed system.
T-Code SE11 -> Data Type ‘ZAGS_CC_DATA’
2.3.2 Implement data extraction coding
Sample code is attached below.
2.4 Set up the custom collector in CCLM configuration
Next step is to propagate the new customer specific function module (or specific function module which calls the BADI implementation) to the CCLM. For this please define a unique identifier in CCLM customizing table AGS_CC_CUSTOM. If you are using the BAdI implementation, please use the value CC_CONTENT = /SDF/GET_CCLM_ATTR_VIA_BADI.
T-Code SE16, table AGS_CC_CUSTOM, add one entry as below for the custom attribute.
[Comment]: For a subset of for all customer specific fields you should define this unique identifier. This unique identifier is the link between the generic data extractor job and the used function module while running the extraction. E.g. CUSTOM1 as example.
Here we directly use the name of the attribute ‘ZOLDPK’ as CC_KEY.
2.5 Define a new customer field’s extractor job
For every group of customer fields you should define your own extractor entry. This has the benefit to schedule this job independent for subsets of customer attributes. But will also give you the flexibility to schedule this job only for selected systems. Maintain the table AGS_CC_EXTACTOR with the following schema
Job name: SM_CCL: <CUSTOM1>
in this example the < CUSTOM1> must be the same as the CC_KEY in the AGS_CC_CUSTOM, in our example <CUSTOM1> is ‘ZOLDPK’. Example:
This customizing will define a new collector entry in the CCLM settings calling the CCLM standard program RAGS_CC_GET_NEW_ATTRIBUTES every week at 6 AM in the morning.
T-Code SE16, table AGS_CC_EXTRACTOR, add one entry as below.
2.6 Schedule the custom collector job
Once you have executed the step before, go to the navigation bar Settings (before SP10, in case ST-PI> SP10, go to solman_setup or directly start job in SM37) on the left and select the system where you want to schedule the job. A new entry should appear with job name:
Schedule the job to start information extraction.
[Comment]: In case upper version of ST-PI (> SP10), you might not have Settings in navigation bar, then you can either go to solman_setup -> CCLM or directly go to SM37 to create/copy a batch job for this.
2.7 Check Attribute Value in CCLM
T-Code CCLM -> navigation bar ‘Objects’ -> check attributes of the object.
[Reference]: CCLM Configuration Guide.
Extra thank you!
This is helpful.
Great blog. Thanks.
I'd like to use the FM BAdI on the local SolMan system to assign a template id to an object but the interface is different when calling a local collector and it dumps as a result. Is there another FM that is used in this case or do just need to create my own?
As I understood from the CCLM configuration guide. You have 2 ways to extract data for customer-specific attribute.
Option1, In table AGS_CC_CUSTOM, maintain CC_KEY = <Custom1>, CC_CONTENT = /SDF/GET_CCLM_ATTR_VIA_BADI, in this way, you implement BADI /SDF/CCLM_ATTR_BADI in your managed system (you can also take local solman as your managed system). And in above documentation, i use this way.
Option2, In table AGS_CC_CUSTOM, maintain CC_KEY = <Custom1>, CC_CONTENT = Z_RFC_FUBA_NAME, in this way, you create you own FM Z_RFC_FUBA_NAME in your managed system, and set the attribute there, you can refer to the definition of BADI FM /sdf/cclm/attr_badi:
- table: t_object_set which contains all custom code objects
- table: T_CCLM_attributes will be filled with the attribute calculated
And during the calling of AGS_CC_DATA in solution manager, it reads the configuration in table AGS_CC_CUSTOM for the lf_function_mod, and get attribute table in t_cclm_attributes from the FM (either BADI or your FM depending on your configuration) to feed table et_new_data, the et_new_data is going to update the attributes in CCLM.
And in CCLM, if you are using local solman as managed system, you should choose to schedule the job under system <solman> instead of managed systems, otherwise standard program will try to use RFCs for your managed systems while calling the BADI FM, it then goes to the wrong way.
Thanks for the info. I'll take a look again.
Hello Extra Li,
I am trying to implement BADI in CCM to pull the data regarding z* programs data like tcode associated with z* programs and authorizaton object associated with z*program.
Could you please help me in implementing BADI.
Hi Extra !
Where is sample code that is attached below ? And how to do that in new version SM through tcode SM_WORKCENTER ?