For a complete list of all my blogs regarding content management, please see here.

When you create attachments for your business objects via cl_crm_documents=>create_with_table, you have to pass in an internal table for attachment property.
The namelist of attribute name could be got from attachment class via function module SDOK_PHIO_ATTRIBUTES_GET.

For example, attachment class CRM_P_DOC has 36 attributes.

The attributes could also be viewed in tcode DMWB

The actual attribute value could be got via function module CRM_KW_PROPERTIES_GET:


The importing parameters are guid of logical/physical object instances:

The attribute values are stored in PROPERTIES internal table.


Do you know why in the backend table, the property is stored in field PROP09?

actually it is because I hard code the content of relative url as the attachment file name.

    ls_prop-name = 'KW_RELATIVE_URL'.

    ls_prop-value = iv_file_name.

    APPEND ls_prop TO lt_prop.


The index of attribute could also be found in tcode DMWB.

For a complete list of my blogs regarding content management in CRM, please see here.

In the beginning I consider it is very easy to delete attachments via code, just like below.


I have defined one method with following two importing parameters:

iv_bor_type type string - the BOR type of your business object

iv_uuid type raw16 - the guid of your business object instance

rv_successful type abap_bool - indicates whether the deletion is successful


DATA: ls_bo          TYPE SIBFLPORB,
          lt_loios    TYPE SKWF_IOS,
          ls_loios    TYPE SKWF_IO,
          ls_error    TYPE SKWF_ERROR,
          lt_badios   TYPE SKWF_IOERRS,
          lv_del_flag TYPE ABAP_BOOL.
    ls_bo-instid = iv_uuid.
    ls_bo-typeid = iv_bor_type.
    ls_bo-catid  = 'BO'.
    rv_successful = abap_false.
    CALL METHOD cl_crm_documents=>get_info
        business_object = ls_bo
        loios           = lt_loios.
    LOOP AT lt_loios INTO ls_loios.
      CALL METHOD cl_crm_documents=>lock
          is_bo    = ls_bo
          is_loio  = ls_loios
          es_error = ls_error.
      IF ls_error IS NOT INITIAL.
    CALL METHOD cl_crm_documents=>delete
         business_object = ls_bo
         ios             = lt_loios
         bad_ios         = lt_badios
         error           = ls_error.
    IF ls_error IS INITIAL. " deletion failed
       rv_successful = abap_true.


Through testing I found it works perfectly well with most of BOR type like product, ibase, BP, and one order.

However, it does not work for my new BOR type CRMSOCPOST in CRM7.0 EHP3 - the relationship between my bo and the attachments is not really deleted until

an explicit call COMMIT WORK is written in the report. However, for any other standard CRM BOR type, the COMMIT WORK is not needed. Why?


After some debugging finally I find answer. Have you already observed the comments below? It is written quite clearly: if the business object exists in the database, the COMMIT WORK is not needed.


Back to my case, since CRMSOCPOST is a new BOR type created in CRM7.0 EHP3, the function module does not recoginize it, so the code reached line 225, and

then the bo instance is regarded as non-exist in DB. So an explicit COMMIT WORK is always necessary to make deletion work.


For a complete list of all my blogs regarding content management, please see here.
I create a utility class with method CREATE_DOC. It has following four input parameters:
iv_data type xstring - the binary data which you would like to store as attachment
iv_bor_type type string - the BOR type of your business object. You can view view business object model in tcode SWO1
iv_guid type raw16 - the guid of your business object instance
iv_file_name type string - the file name which will appear in attachment assignment block.
The source code of method below: ( in fact all attributes for an attachment could be available in the input parameters of this method. For simplicity reason I
just hard code them in the sample code )
         ls_bo              TYPE sibflporb,
         ls_prop            TYPE LINE OF sdokproptys,
         lt_prop            TYPE sdokproptys,
         lt_properties_attr TYPE crmt_attr_name_value_t,
         ls_file_info       TYPE sdokfilaci,
         lt_file_info       TYPE sdokfilacis,
         lt_file_content    TYPE sdokcntbins,
         lv_length          TYPE i,
         lv_file_xstring    TYPE xstring,
         ls_loio            TYPE skwf_io,
         ls_phio            TYPE skwf_io,
         ls_error           TYPE skwf_error.
    ls_prop-name = 'DESCRIPTION'.
    ls_prop-value = 'created by Tool'. " replace it with your own description for attachment
    APPEND ls_prop TO lt_prop.
    ls_prop-name = 'KW_RELATIVE_URL'.
    ls_prop-value = iv_file_name. " in the sample code I just reuse file name as relative url
    APPEND ls_prop TO lt_prop.
    ls_prop-name = 'LANGUAGE'.
    ls_prop-value = sy-langu.
    APPEND ls_prop TO lt_prop.
    lv_file_xstring = iv_data.
        buffer        = lv_file_xstring
        output_length = lv_length
        binary_tab    = lt_file_content.
    ls_file_info-binary_flg = 'X'.
    ls_file_info-file_name = iv_file_name.
    ls_file_info-file_size = lv_length.
    ls_file_info-mimetype = 'image/jpeg'. "use the correct mime type for your attachment
    APPEND ls_file_info TO lt_file_info.
    ls_bo-INSTID = iv_guid.
    ls_bo-typeid = iv_bor_type.
    ls_bo-catid = 'BO'.
    CALL METHOD cl_crm_documents=>create_with_table
        business_object     = ls_bo
        properties          = lt_prop
        properties_attr     = lt_properties_attr
        file_access_info    = lt_file_info
        file_content_binary = lt_file_content
        raw_mode            = 'X'
        loio                = ls_loio
        phio                = ls_phio
        error               = ls_error. " evaluate if there is anything wrong during creation
I write a piece of code to test it. After report runs I could see the generated attachment.
You can also test whether the attachment is created successfully in the backend. Test class method get_info in SE24.
Specify importing parameter BUSINESS_OBJECT:
Execute and you should get result as below: one physical object and one logical object according to how-is-attachment-physically-stored-in-database-table-in-cm-framework.
Never forget to call COMMIT WORK in your code, since the persistence of the relationship between attachment and your business object are implemented via generic object service in a update process.You could easily find this via SAT trace on your code
or switch on update debugging in your debugger settings.

If you want to know more technical detail, please find my blog list here.



Content Management(CM) was introduced in basis release 6.10 and implemented in CRM 3.0. Before CM was used, CRM applications was using the Business Document Service (BDS) or Generic Object Services (GOS) to implement Document management requirement. BDS was used in most applications like Business partners, products, product catalogues, solution database, campaigns. GOS was only used in the One Order objects like activities and opportunities. All BDS applications changed to CM in 3.0, the One Order objects only in 3.1.


A document in CM consists of several objects. The most important two are so called “logical info object” (LOIO) and a “physical info object” (PHIO). A LOIO as a logical folder or bracket which holds PHIOs together, while a PHIO represents the content of a specific version of a document. Let's use the word edit in the real world as example. If one works on a Word document and changes the document over time, each saved version would be represented by a PHIO. The LOIO would be the word document itself. This is much like if one looks at SE38 in ABAP: The program name is the LOIO and each transported version of the code is the PHIO.

Let's see an example. I have a product ZCM_DEMO with guid 0090FA0D8DC21ED395FD7C687F99BFF7, BOR type = BUS1178.

I create one attachment for it:


Go to table SKWG_BREL, input product guid 0090FA0D8DC21ED395FD7C687F99BFF7, and we see two entries belonging to this product. The first entry indicates a folder instance which is actually a logical container to hold all attachments for the given product. 



The content of column INSTID_B has naming convention as <type: F(older) or L(ogical object)><Logical object type name><guid>.

The guid in the first row can be found in table CRM_FOLDER:


The guid 0090FA0D8DC21ED395FD830F8DD9DFFF in the second row can be found in table BDSLOIO22, together with the name of attachment.



You are asking how I get to know the name of table BDSLOIO22? If one application wants to use CM to store document, it should have its dedicated class for physical object and logical object, or use the default one CRM_L_DOC. The relationship between application and its class is maintained in tcode DMWB:


in table BDSPHIO22, by specifying logical information object ID, we can get all phyiscal object lists.


once you get phyical object id 0090FA0D8DC21ED395FD830F8DD9FFFF, you can find the respective entries in table BDSCONT22.


The real content of attachment is stored in a claster way, so you cannot see its detail in SE16.


How do I know the database table name BDSCONT22?

1. Get the storage category BDS_DB22 by physical class name.


2. execute function module SCMS_SDOKSTRE_LIST to get all lists of database table. Then you can find the table name BDSCONT22 for your storage category BDS_DB22.


Hi Friends,
It is a common requirement that a certain assignment block in overview page should only be displayed under some condition, for example under control of a business switch.
Here are three ways which could control the visibility of one assignment block via code.

Approach1: dynamical view detachment

refine method DETACH_STATIC_OVW_VIEWS of the controller class of your overview page. All views put into internal table rt_viewid will be hidden by UI framework in the runtime.The code below just means you can evaludate some condition in line 3, and if the condition is met, the assignment block SearchResult will be hidden.

Approach2: dynamic UI configuration load

Create a new configuration within which only Search view is displayed. The configuration is bound to a certain UI object type.
Now we have two UI configurations. The standard configuration will display two assignment blocks by default, the configuration with UI object type = CRM_SMC will only display Search view.
  " IF search result view should be hidden
     me->set_config_keys( iv_object_type          = 'CRM_SMC'
                          iv_propagate_2_children = abap_false ).

Approach3: Control the visibility via business switch

This is a most elegant way, however it could only be used if you would like to control the visibility of your view via a business switch.
When you are assigning your assignment view to the view area of Overview page in runtime repository, a business switch can be assigned as displayed in the picture below. If the switch is turned off, the related view will be automatically hidden by UI Framework.
After you have assigned a view to the view area of oviewpage, the switch ID is displayed after view name.
You could first find the related business function for switch CRM_SOC_SFWS_SMI_2 via tcode SFW1,
then find the business function status in SFW5:
If the business function is deativated, the assignment block will also be hidden automatically.
Divya Gupta

Default text in notes

Posted by Divya Gupta Nov 21, 2013

Hi All,


This one takes us back to the basics of CRM, power of text determination procedure. We have been using notes in CRM transactions very
frequently to capture various texts entered by different Users during the process. Through this blog I am trying to showcase one of the old features
available in text determination procedures i.e. access sequence to source the content in the note type.



In my recent project, I got a requirement from customer where they wanted a default text to appear in the notes. As this note type was to be
used for printing CRM generated letter, it was acting as template for the letter and also it was supposed to be changeable by user during the process and
the changed version of the template should go for printing. As this criteria came into picture, we couldn’t just create a smartform with hardcoded text
instead found the standard way to find solution.


Access sequence in text determination procedure can be used in this case.



Following are the steps to make this work:



  1. Create the text template using SAPscript Tcode SO10



  Maintain the default text here:




2.  Create you text determination procedure and create access sequence for the text type for which the default text has to be sourced:



3. The function has to be created by technical team which has a small code for calling the SAPscript created in step 1:






CLEAR: es_reference.

  es_reference-tdobject = 'TEXT'.

  es_reference-tdid = 'ST'.

  es_reference-tdname = 'ZTEMPLATE'.

  es_reference-tdspras = 'E'.






4. Once the access sequence is created, assign this access sequence to the text type:





Leave the changes column as empty as you want it to be editable and select value “A” in transfer column for this text type.



That’s it. When this procedure is assigned to a transaction and when user creates the transaction, the default text appears in the
respective note type (text type) which can be changed by user.




A small configuration changed helped us in meeting the requirement. Thought of sharing this as a lot of us sometimes miss these
excellent features available as part of std CRM.


Hope you enjoyed revisiting the basics. sometimes it really helps.

With System Upgrade SAP delivers a whole new set of features and functionality to the end users but it takes also takes away some of the GUI transactions from the end users. In case of CRM solutions , the same functionality would be available from the WebUI but for developers it is a pain because it was possible to debug the same functionality easily and with a lesser effort. But now with the transaction not available in the backend , we have to go through the tedious process for debugging through WebUI.


I am big fan of SAP tools available in the ABAP backend as they make the task of the developer much much easier. For me it is like playing in the familiar territory and easier to ramp-up on newer areas. For some days I was struggling to understand how to debug Info-sets in Marketing area and I came across transaction CRMD_MKTSEG to perform the segmentation in ABAP backend. But the Transaction was no longer available. So I looked for another system we have and I could execute the transaction CRMD_MKTSEG. Thank god I could run it but then I wanted to run the same transaction in my system to analyze my problem. So I came across an ingenious idea. I did the following

  • I went to the trx SE93 in my another system. The trx CRMD_MKTSEG was available
  • As the transaction was available , so was the underlying program in the se93 transaction information.(  CRM_MKTTG_SEG_UI_START )
  • So I copied the program and ran it in my actual system.
  • And then I continued on doing what I love to do what I love to do-running scenarios from ABAP backend.


So if you want don't find a transaction in any system , you just have to look for another system where it runs. Also I was surprised that surprised that SAP just removed the transaction and left the underlying program. Instead it could have easily left it for the developers and put an extra authority object so that only developers could use it.

Hi friends,


I am CRM developer in SAP and our team has already integrated twitter ( also facebook ) into interaction center in CRM7.0 EHP3.


You can see an example below:


Create a tweet in twitter website:





Now I can see the tweet created just now in the web site.




And I can also see it in CRM IC agent inbox:




select the first row and I can directly reply it in CRM by clicking reply button:




just click the send button:




after click send button, I can see the reply also in twitter website:



Here below the screenshot is for Facebook:


I create a post in Facebook:



And the post could also be found in CRM system:



if you would like to integrate other social channel than twitter and facebook, you just have to implement your own client class for the new social channel, and all left tasks are centrally done by us from framework side.


you can get more detail information from consulting note 1832462 about social integration achitecture. Implementation detail for facebook client class: note 1832481. And note 1832480 for twitter.


Update on 2013-11-20 for reply to Kavindra:


We have defined a BAdI enhancement spot which you could do your specific analysis on the data extracted from web site.





We have delivered a sample implmenetation which could calculate the sentiment of the text posted in twitter & facebook like "Positive, Negative, Strong Positive, Neutral", with the help of SAP HANA Text Analysis Engine. Of course you could use your own TA engine within that BAdI enhancement implementation.



Welcome to post any questions you have here if you are interested with this topic.

New features available in EHP3 SP4

See the detail here.

Hi Friends,
in one of my post, I talked about how to open ABAP webdynpro page via pop up window to resolve a real customer issue.
Now I have another solution to navigate to ABAP webdynpro page via CRM navigation framework.
The CRM navigation framework is using a so-called navigation object which can tell framwork what the target UI view and the respective operation ( Display, Edit, Search etc ). The navigation object relies heavily on CRM ui concept like UI object type, BOR and BOL type which do not make sense for a ABAP Webdynpro page.
So the main idea of this solution is, to use a wrapper CRM ui component which encapsulate ABAP webdynpro page and make configurations to achieve the navigation from source UI component to the wrapper component. After the wrapper component is opened, it will then open ABAP webdynpro page itself.
The finaly result would look like below:
compared with the solution in my previous blog, this solution does not need any enhancement on standard UI component, instead only several customizing work
( with corresponding mapper class development )and the development of a new wrapper UI component with tiny effort. The main steps are below:
create a simple wrapper UI component. ( Please ignore view main, which is for another blog )
create an inbound plug for window MainWindow and implement as below.
  method IP_FROM_WF.
    data(lo_entity) = iv_collection->get_first( ).
    CHECK lo_entity IS NOT INITIAL.
    data(lv_guid) = lo_entity->get_property_as_string( 'DOCMNT' ).
    cl_zmeta_mainwindow_impl=>gv_url = zcl_url_utility=>get_url( CONV #( lv_guid ) ).
The idea is to get the target ABAP webdynpro page url from iv_collection which is passed by CRM navigation framwork and set it to a static attribute of window controller class. That gv_url is just used in view windowOpen.htm. So it means when this wrapper UI component view is about to be rendered, it will open the target ABAP webdynpro page via javascript
SM30, view name BSPDLCV_OBJ_TYPE create a new UI object type. please AlWAYS double check in the system whether there are already existing UI object type in the system!
Here I create a new UI object type CRM_WF. You can input any name in BOL Object name. There is no validation check, just input a meaningful name.
The Genil component specified here will be loaded automatically by framework in the runtime. In most time your ABAP webdynpro page does not have respective Genil component in CRM, you just can maintain a dummy one.
create a new entry in table CRMS_UI_OBJ_MAP. The object name comes from step2.
the mapping class must implement interface IF_CRM_UI_OBJ_MAPPER. If your scenario is just navigation from CRM ui to ABAP webdynpro,
you only need to implement GET_ENTITY_FROM_UI_OBJECT.
Here I just retrieve respective document data from database with document key passed in from framework ( iv_entty_key_value )
in SPRO-Customer Relationship Management-UI Framework-Technical Role Definition-Define Work Area Component Repository:
create a new entry for your wrapper UI component:
in inbound Plug Definition, create one entry:
in SPRO-Customer Relationship Management-UI Framework-Technical Role Definition-Define Navigation Bar Profile:
create an entry in "Define Generic Outbound Plug mapping" for your profile.
And that's all.
Hi Friends,
in my recent customer project customer complains to me that they can not navigate from the workflow search result to the target UI.
The workflow work item is a document generated via SAP document builder. They would likt to navigate to the document detail page and then decide whether to approve the document or not. With SAP standard solution so far in CRM7.0 EHP3, this is not possible since this work item does not have any BOR type but instead modelled via ABAP class /IPRO/CL_WFL_DOCUMNT. What's more, the target document page is built via ABAP webdynpro which has not respective concept like UI object type, Genil component or BOL object name.
So in order to enable customer to see the document page, I just enhance the standard table to add a new column named "Document URL". By clicking the hyperlink of that column, it will create a new popup window to display the document page.
The solution could be concluded as below steps:
enhance a new attribute DOC_URL in standard context node SEARCHRESULTNODE, implement Getter and P getter.
in getter, just get the target document page url via utility class:
  method GET_DOC_URL.
    value = zcl_document_utility=>get_display_value( iterator ).
in p getter, set the event handler for hyperlink click event:
CASE iv_property.
    WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
        rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
    WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
        rv_value = 'DISPLAY_DOC'.
define component usage GS_CMSRCH:
and in event handler for DISPLAY_DOC:
    DATA(lv_title) = cl_wd_utilities=>get_otr_text_by_alias( 'Document(to be approved) Preview' ). "#EC NOTEXT
    DATA(lr_popup) = io_wd_manager->create_popup(  iv_interface_view_name = 'GS_CMSRCH/CMDisplayContentWindow'
                                                   iv_usage_name          = 'GS_CMSRCH'
                                                   iv_title               = lv_title ).
    DATA(lr_cn)  = lr_popup->get_context_node( 'PARAMS' ).
    DATA(lr_obj) = lr_cn->collection_wrapper->get_current( ).
    READ TABLE st_url_buffer ASSIGNING FIELD-SYMBOL(<buffer>) WITH KEY uuid = iv_guid.
    CHECK sy-subrc = 0.
    DATA(ls_params) = VALUE crmt_gsurlpopup_params( url = <buffer>-url height = '1000' ).
    lr_obj->set_properties( ls_params ).
    lr_popup->set_display_mode( if_bsp_wd_popup=>C_DISPLAY_MODE_PLAIN ).
    lr_popup->set_window_width( 1000 ).
    lr_popup->set_window_height( 10000 ).
    lr_popup->open( ).
And that's all.
Interface window CMDisplayContentWindow is a new window created by SAP in EHP3 SP3. There is no magic inside it: just open the target window via javascript
you can also use the reuse component GSURLPOPUP, which can achieve the same result but with different html markup.
After I finish it, I soon realized that in this dedicated case, it is possible to "navigate" to the target ABAP webdynpro page via CRM navigation framework itself. I will explain how to do it in my next blog.
The source code of zcl_document_utility could be found from attachment.

The topic of the blog may seem queer but as I would illustrate later it is very relevant in the lives of technical consultants. I would illustrate with examples how these approaches would help you succeed or if fail then fail gracefully ( read exception and dumps ) . Lets look into each of one at a time.




  • For e.g. if you want to do something like this then this a recipe for sure shot disaster. If lv_entity is not bound then you would run into a dump/exception.You can use this in possibly many ways and you should use this as much as possible.
lv_bo ?= lv_entity.
lv_bo->set_property( iv_attr_name = ‘CITY’
iv_value = ‘Walldorf’ ).


the better way to the similar coding would be

lv_bo ?= lv_entity.
CHECK lv_bo is bound. 
lv_bo->set_property( iv_attr_name = ‘CITY’
iv_value = ‘Walldorf’ ).


lv_bo ?= lv_entity.
if lv_bo is bound.
lv_bo->set_property( iv_attr_name = ‘CITY’
iv_value = ‘Walldorf’ ).


This is a very common failure scenario and is so common that we often tend to ignore this.


  • The second variety is when you write a new method/form etc. , then check whether the importing parameters are proper. This would mean if you expect a reference variable to be passed then it should be bound or if you have a mandatory parameter passed then it should be having some value. Similarly pass export only those parameters which are requested. ( This is not a disastrous case but can save performance).For e.g. if you are sending a collection as an importing parameter to a method then you can write the following statement. This way you know that the col is bound and contains entities


          CHECK ir_col is bound and ir_col->size(  ) > 0. 





This one is my personal favorite. Often uncleared variable could cause embarrassing problems and of magnitude you cannot even imagine. For e.g. you are in a conditional statement where you fill some variables based on condition being true and condition was false and since the variable were not cleared you still get data in variables. Or for e.g. you failed to clear an entity reference variable it would cause you lots of issues. I am providing some examples


lv_bo ?= lv_person.
lv_*** = lv_bo->get_property( ‘***’ ). “Key code
if lv_person->get_parent( ) is not initial.
lv_bo ?= lv_person->get_parent( ).
lv_*** = lv_bo->get_property( ‘***’ ). “Key code


Now if the if condition is not true , then lv_*** is line no 5 should be blank but it would be filled with value fetched in line no 2. In this case it may not seem disastrous but in some cases it is extremely catastrophic.


The better way to do this would be following. As a general rule for methods which have returning or exporting parameters , clear the variables which are collecting values.

lv_bo ?= lv_person.
clear lv_***.
lv_*** = lv_bo->get_property( ‘***’ ). “Key code
if lv_person->get_parent( ) is not initial.
lv_bo ?= lv_person->get_parent( ).
clear lv_***.
lv_*** = lv_bo->get_property( ‘***’ ). “Key code


In my case , I was trying to create multiple DOCFLOW entities but I not have cleared the variable through which I was passing the data to docflow and I was passing the same docflow instance every time hence the data was getting overwritten in same entity. 




Another of my personal favorite. Exceptions are pretty common while we execute a scenario in WebUI. But they are handled in the framework and hence even though exceptions are raised , gracefully WebUI screen opens. If I call a method and it runs into an exception , then it could result in a dump or exception. Both of them are not appreciated by the users hence it makes a lot of sense to fail gracefully and provide exception handling. As a general rule if you are coding in WebUI , don't raise exceptions and don't fail to catch exceptions. Both of them are absolutely necessary.


while lr_current_entity is not initial and lr_entity is not initial .
 *  Add the entitiy
                Clear lr_entity.
CHECK lr_ent is bound.
 lr_ent ?= lr_entity.
 if lr_ent->alive( ) = abap_true.
 Clear lr_adminh , clear lv_object_type.
 lr_adminh ?= lr_ent->get_related_entity( 'BTOrderHeader' ).
 if  (Your_Condition).
  lr_current_entity ?= lr_iterator->get_next( ).
 lr_entity ?= ir_valuehelp_collection->get_next( ).
 catch cx_root.
 lr_current_entity ?= lr_iterator->get_next( ).
 lr_entity ?= ir_valuehelp_collection->get_next( ).

Now this code serves two purposes

a) It handles the exception hence there would not be any disruption in WebUI.

b) In case of exception occurs , there is a handling in that case.


Some of these guidelines may appear didactic but in reality they help in avoiding embarrassing code mishaps.

Multi-level Categorization is a kind of hierarchical categories which can be used in the business transaction for classification purposes. For example, in the service order, we can categorize the defect, reason, solutions into many hierarchical categories. One or more than one can be selected easily from the hierarchical tree in the service order header or item.


Multilevel categorization is available in varying scopes for the following applications:

  • Service orders
  • Service order templates
  • Confirmations
  • Complaints
  • In-house repair orders
  • Case management
  • Interaction record


In some cases if we need to know which level in the category is filled , then we need to calculate the node level which is filled and based on that we can determine whether the node level which we have to look for is filled or not. For e.g. in defect there are L1->L2->L3->L4->L5 , then if we need to find out if L5 is filled or not and if only level L3 is filled then the output that we would get is level 3 and we sure that L5 is not filled. In some business scenario we need to determine if a particular level is filled ( Level has to be filled mandatorily in the transaction). If the level is not filled we need to raise an error message. So the blog below would help to calcuate the level in a category. Using the APIs in the code below , you can twist and tweak as per your requirement.



data: lr_aspect   type ref to if_crm_erms_catego_aspect,
      lr_category type ref to if_crm_erms_catego_category,
      lv_ref_guid type guid_16 value '0050560600AD1ED2B8E18732B52E5D75',      lv_asp_guid type crm_erms_cat_guid,
      lv_cat_guid type crm_erms_cat_guid,
      lv_sel_level type int4,
      ls_cat      type crmt_erms_cat_ca_buf.
call method cl_crm_ml_category_util=>get_categoryfirst
    iv_ref_guid     = lv_ref_guid
    iv_ref_kind     = 'A'
*   iv_catalog_type = 'C'"ORDER_READ->ET_SUBJECT->CAT_ID'
    er_aspect       = lr_aspect
    er_category     = lr_category.
* get aspect guid
call method lr_aspect->get_asp_guid
    rv_asp_guid = lv_asp_guid.
* get category guid
call method lr_category->get_details
    ev_cat = ls_cat.
lv_cat_guid = ls_cat-cat_guid.
    iv_selected_cat_guid = lv_cat_guid    " Selected Category GUID
    iv_schema_guid       = lv_asp_guid    " Schema GUID
    ev_selected_level    = lv_sel_level    " Selected Category Level
*    ev_parent_cat_guid   =     " Parent Category GUID
*    ev_parent_cat_id     =     " Parent Category ID
*    ev_parent_level      =     " Parent Category level

The lv_sel_level would give you the level details. Based on business sceanrio , we can add validations .

in the previous blog we discussed how to maintain attachment in pop up window.
In production code it is ususally necessary to also have authorization control on attachment maintenance.
Most of the time it is done via authorization object.
In this example I just use a checkbox to control it during the whole session, in the screenshot below all buttons are disable since the "Allow Edit" checkbox is not selected.
The idea of control is, in GS_CM component controller there is a value node ATTRIBUTES which could be bound by consuming component. 
in the controller class below, Content management framework will firstly check whether the current BOR type is valid ( line 13 ~ line 18), an invalid type will lead to read only mode.
then the display mode flag will be set according to the field display of value node.
based on these findings, we can start development in our ui component.
create an event handler for checkbox status change and just use a global variable to store the flag:
create a new value node ATTRIBUTE in custom controller
redefine INIT.
here we buffer the collection wrapper reference into a global variable of component controller for later usage.
  super->if_bsp_model~init( id    = id
                            owner = owner ).
  mr_owner ?= owner.
  DATA: lv_struct_ref TYPE REF TO crmt_cm_comp_st,
        lv_value_node TYPE REF TO cl_bsp_wd_value_node,
        lv_bo_coll    TYPE REF TO if_bol_bo_col.
  CREATE DATA lv_struct_ref.
  CREATE OBJECT lv_value_node
      iv_data_ref = lv_struct_ref.
  CREATE OBJECT lv_bo_coll
  lv_bo_coll->add( lv_value_node ).
  set_collection( lv_bo_coll ).
redefine ON_NEW_FOCUS. The bufferred collection wrapper for ATTRIBUTE node is used here:
 method ON_NEW_FOCUS.
     lr_entity          TYPE REF TO cl_crm_bol_entity,
     lr_parent          TYPE REF TO cl_crm_bol_entity,
     lv_entity_name     TYPE string,
     ls_cm_attr         TYPE crmt_cm_comp_st,
     lv_product_type    TYPE comt_product_type,
     lr_bo_attr         TYPE REF TO if_bol_bo_property_access,
     ls_prtyp_cust      TYPE coms_prtyp_cust,
     lv_object_guid     TYPE ib_recno_16,
     lv_current         TYPE flag,
     ls_button          TYPE crmt_thtmlb_button.
  CHECK focus_bo IS BOUND.
  lr_entity ?= focus_bo.
  lv_entity_name = lr_entity->get_name( ).
    ls_cm_attr-display = ''.
    ls_cm_attr-display = 'X'.
  CHECK lr_bo_attr IS BOUND.
  lr_bo_attr->set_properties( ls_cm_attr ).
in WD_USAGE_INITIALIZE method of ZSMCATTR component controller, bind the context node of custom controller to GS_CM's attributes node.
CALL METHOD iv_usage->bind_context_node
          iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
          iv_name             = 'ZSMCATT/CMBO'
          iv_target_node_name = 'ATTRIBUTE'                "#EC NOTEXT
          iv_node_2_bind      = 'ATTRIBUTES'.                "#EC NOTEXT
lr_cuco_attachement ?= get_custom_controller( 'ZSMCATT/CMBO' ).
IF lr_cuco_attachement IS BOUND.
        lr_property = me>typed_context->socialpost->collection_wrapper->get_current( ).
        lr_cuco_attachement->typed_context->cmbo->on_new_focus( lr_property ).
        lr_cuco_attachement->typed_context->attribute->on_new_focus( lr_property ).
Hi friends,
you can see attachment ui everywhere in SAP CRM ui but most of them appear within assignment block.
This article just tells you how to put the attachment maintenance ui within pop up window.
The user can click hyperlink in table column "Post ID" to maintain the attachments for the selected post.
This article also shares the tip how to control the enablement of attachment maintenance dynamically.
As you see there is a checkbox "Allow Edit" in first table UI. If checked and navigate to attachment popup window, the attachment maintenance is enabled. Otherwise you will see all buttons in attachment popup window is disabled.
The invovled UI component in this solution:
1. ZSMCQR - the first UI, contains search view with only one search parameter "Post Internal ID", the checkbox to control attachment
maintenance, abd the search result view.
2. ZSMCATT - our wrapper component to load the reuse attachment component.
3. GS_CM - standard UI component provided by SAP exposing attachment operation like create, save and delete. The benefit of using it is that now
it is not necessary for application developer to care about those CRUD operations on attachment - they are all taken over by content management
4. GSURLPOPUP - standard UI component about popup window implementation
in our first host UI component, declare one component usage to GSURLPOPUP.
we would like to make field INTERNAL_ID ( label in UI: Post ID) as hyperlink and trigger a pop up window, so we need to implement a
P-Getter on it:
  CASE iv_property.
      WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
        rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
      WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
        rv_value = 'ATTACHMENT'. 
Then create a event handler for event ATTACHMENT to pop up a window. In the event handler implementation, we plan to pop up the
attachment maintenance window. Before we write code, we need to define one more component usage:
Now we are ready to implement the event handler:
          lv_post TYPE REF TO cl_crm_bol_entity,
          lv_bol_col TYPE REF TO CL_CRM_BOL_BO_COL.
    lv_post = zcl_jerry_tool=>get_selected_post_by_event( iv_col_wrapper = me->typed_context->searchresult->collection_wrapper
        iv_event = htmlb_event_ex->event_id ).
    CREATE OBJECT lv_bol_col.
    lv_bol_col->IF_BOL_BO_COL~add( lv_post ).
  lr_popup = comp_controller->window_manager->create_popup(
     iv_interface_view_name = 'ZSMCATT/MainWindow'
     iv_usage_name = 'ZSMCATT'
     iv_title = 'Social Post Attachment Maintenance' ).
  lr_popup->set_on_close_event( iv_view = me iv_event_name =
  lr_popup->open( iv_inbound_plug = 'FROM_SEARCH' iv_collection = lv_bol_col ).
all the content in pop up window is encapsulated in interface view MainWindow of ZSMCATT. Our next step will focus on its implementation.
the method get_selected_post_by_event is a handy method which just returns the selected post BOL entity via event:
    lv_index_str TYPE string,
    lv_idx       TYPE string,
    lv_index     TYPE i,
    lv_result    TYPE REF TO cl_crm_bol_entity.
    lv_index_str = iv_event.
  SHIFT lv_index_str UP TO '[' LEFT CIRCULAR.
  SHIFT lv_index_str BY 1 PLACES.
  WHILE lv_index_str(1) <> ']'.
    CONCATENATE lv_idx lv_index_str(1) INTO lv_idx.
    SHIFT lv_index_str BY 1 PLACES.
  lv_index = lv_idx.
  CHECK lv_index >= 0.
  lv_result ?= iv_col_wrapper->find( iv_index = lv_index ).
  rv_result = lv_result->get_related_entity( 'SocialPostRel' ). "#EC NOTEXT
component ZSMCATT just contains one overview page and one post header page.
The overview page has two assignment blocks: one( headerWindow ) for post header which indicates the current post being maintained, the other one( attachmentWindow ) just displays the UI of reuse component GS_CM.
see picture below:
the view contained in the attachmentWindow is not developed by us, but reuse from GS_CM.
so we define one component usage AttachmentUploadDet and include its interfacre view MainWindow into our attachmentWindow, as shown below:
Again the new pop up window shown in right part of screenshot above is also another standard UI of GS_CM, so we just define another component usage to include it into our component:
in figure5 you observed that there is a hyperlink "Properties", once clicked it will navigate to attachment property UI, which is also one standard part of GS_CM.
I call this window as "DetailWindow". So finally I have the following windows:
It means we need to define the third component usage on GS_CM to include that part into our own UI:
you may find that in three component usage, the same interface view MainWindow of GS_CM is included. So the real page that would be displayed in GS_CM.MainWindow depends on which outbound plug from our own UI component is called and which inbound plug of target UI will catch that.
So in this step we will define navigate link to specify the navigation behavior of each.
in component controller of ZSMCQR, do component context node binding for component usage ZSMCATTR:
          lv_usage  TYPE REF TO if_bsp_wd_component_usage,
          lo_entity TYPE ref to cl_crm_bol_entity.
    CHECK me->typed_context->socialpost->collection_wrapper IS NOT INITIAL.
    lv_usage = me->comp_controller->get_component_usage( iv_usage->usage_name ).
    IF lv_usage->usage_name = 'ZSMCATT'.
      CALL METHOD lv_usage->bind_context_node
           iv_controller_type  = cl_bsp_wd_controller=>co_type_component
           iv_target_node_name = 'SOCIALPOST'                   "#EC NOTEXT
           iv_node_2_bind      = 'SOCIALPOST'.                  "#EC NOTEXT
in component ZSMCATTR, create a custom controller and create a context node CMBO. Implement its on_new_focus method:
METHOD on_new_focus.
 DATA: lr_qs              TYPE REF TO cl_crm_bol_query_service,
       lr_data            TYPE REF TO data,
       ls_cmbo_prop       TYPE crmt_cmic_rfolder_attr,
       lr_entity_col      TYPE REF TO if_bol_entity_col.
  FIELD-SYMBOLS: <fs_guid> TYPE crmt_genil_object_guid.
  CHECK focus_bo IS BOUND.
      lr_qs = cl_crm_bol_query_service=>get_instance( cl_crm_cm_genil_comp=>gc_query_bo_link ).
    CATCH cx_root.                                      "#EC NO_HANDLER
  lr_data = focus_bo->get_property( 'UUID' ).
  ASSIGN lr_data->* TO <fs_guid>.
  ls_cmbo_prop-instid = <fs_guid>.
  ls_cmbo_prop-typeid = 'BUS1006'. ------------- use your own BOR type here!
  ls_cmbo_prop-catid = 'BO'.
  lr_qs->set_properties( ls_cmbo_prop ).
  lr_entity_col = lr_qs->get_query_result( ).
  me->collection_wrapper->clear_collection( ).
  me->collection_wrapper->set_collection( lr_entity_col ).
in component controller of ZSMCATTR, do the context node binding logic:
METHOD wd_usage_initialize.
DATA: lr_cn       TYPE REF TO cl_bsp_wd_context_node,
           lr_property         TYPE REF TO if_bol_bo_property_access,
           lr_cn_attr  TYPE REF TO if_bol_bo_property_access,
           lr_cuco_attachement TYPE REF TO CL_ZSMCATT_CMBO_IMPL,
           ls_cm_attr  TYPE crmt_cm_comp_st.
   IF NOT me->context IS BOUND.
     me->wd_create_context( ).
   CASE iv_usage->usage_name.
     WHEN 'AttachmentUploadDet' or 'AttachmentUpload' or 'AttachmentProperty'.
      CALL METHOD iv_usage->bind_context_node
          iv_controller_type  = cl_bsp_wd_controller=>co_type_custom
          iv_name             = 'ZSMCATT/CMBO'
          iv_target_node_name = 'CMBO'                "#EC NOTEXT
          iv_node_2_bind      = 'CMBUSOBJ'.                "#EC NOTEXT
       CALL METHOD iv_usage->bind_context_node
          iv_controller_type  = cl_bsp_wd_controller=>co_type_component
*         node at the calling component
          iv_target_node_name = 'SOCIALPOST'                       "#EC NOTEXT
*         name of the called component
          iv_name             = iv_usage->usage_name
*         node at the called component
          iv_node_2_bind      = 'PARENTNODE'.
never forget to call on_new_focus of custom controller context node manually:
lr_cuco_attachement ?= get_custom_controller( 'ZSMCATT/CMBO' ).
 IF lr_cuco_attachement IS BOUND.
        lr_property = me->typed_context->socialpost->collection_wrapper->get_current( ).
        lr_cuco_attachement->typed_context->cmbo->on_new_focus( lr_property ).
        lr_cuco_attachement->typed_context->attribute->on_new_focus( lr_property ).
implement the inbound of outbound plug of window attachmentWindow,
and DetailWindow:
for source code of these two class please refer to attached document.
that's all.
Summary: in this solution we use three component usage on GS_CM, one for attachment list page in attachment assignblock, the second for Attachment upload page and the third for attachment property page. If you would like to know how to control the enablement of attachment maintenance dynamically, please continue to read the next blog.


Filter Blog

By author:
By date:
By tag: