Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

I wonder so many requirements are based on the modification of configuration fields, its properties and positions at run time. So I thought to provide some techniques to change the configuration of fields including the properties at run time for different types of views which we commonly use in most of our components.

The standard way is to create a new configuration for each view which renders different set of fields, its properties and alignment. So at runtime depending upon the configuration key, it chooses the appropriate configuration which is the close match and renders the selected configuration view on screen. Now assume we have only limited configurations and we need to use the same configuration and render it differently based on some other conditions at run time.

                       And also as a technical consultant you might not have authorization to create a new configuration and play around with it. But fortunately we have some tricky way to get control on the configuration which is being shown on UI.

We mostly use four types of views in our components.

  1. Form View
  2. Table view
  3. Search View
  4. Overview

In all the views (except Overview) , we have a .htm page for the view which constructs the UI page layout with fields and its properties. Luckily we have a configuration tag which accepts the xml file of the configuration and uses it to render different UI components on screen.

  <%
  DATA:
  lv_xml    TYPE string.
  lv_xml = controller->configuration_descr->get_config_data( ).
%>


<chtmlb:config xml  = "<%= lv_xml %>"
               mode = "RUNTIME" />

So our technique is based on modifying the XML file according to our requirement and then passing it to the configuration tag to display the modified xml .

In this document we will concentrate on Form View.

Reading the XML file and figuring out the fields is a tedious job. As we have some utility classes which covert them to ABAP, we can start playing out with the fields and their properties.

   *********************************************************************************************************************************************************************************

<%@page language="abap" %>
<%@extension name="thtmlb" prefix="thtmlb" %>
<%@extension name="chtmlb" prefix="chtmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<%
  DATA:lv_xml    type string,
             lv_xml_inp type string,
             lv_config_type type BSP_DLC_CONFIG_TYPE,
             lv_view_desc type ref to IF_BSP_DLC_VIEW_DESCRIPTOR,
             it_adv_conf type BSP_DLCT_ADV_CONF_ITM.

* ************Read the original configuration data and property descriptors of the view as an xml file

  lv_xml_inp    = controller->CONFIGURATION_DESCR->GET_CONFIG_DATA( ).
  lv_view_desc = controller->CONFIGURATION_DESCR->GET_PROPERTY_DESCRIPTOR( ).

*********************** Use the utility class to convert xml to ABAP format
    CL_BSP_DLC_CONFIG_UTIL=>ADV_CONF_META_TO_TABLE( exporting IR_VIEW_DESCR = lv_view_desc
                                                                                                                          IV_ADV_CONF_META_XML = lv_xml_inp
                                                                                                         importing ET_ADV_CONF = it_adv_conf ).

**************************************************************
    ***  As it_adv_conf have the structure BSP_DLCT_ADV_CONF_ITM which describes each field on the UI with its properties like mandatory,display only. Also the field label name and its positions are captured . Now you can modify them according to your requirement.

    ***  Place the validation logic here ********                                          

***************************************************************
                                                 

********************* Convert the modified config ABAP table to XML


  CL_BSP_DLC_CONFIG_UTIL=>ADV_CONF_TABLE_TO_META( exporting IT_ADV_CONF = it_adv_conf
                                                                                                                         IR_VIEW_DESCR = lv_view_desc
                                                                                                          importing EV_ADV_CONF_META_XML = lv_xml ).

****  ****Here the modified XML is retrieved , but it is not ready as it has been encoded. We have to remove encoding and put it in standard format for rendering.
                                                 
  DATA: lv_defidx    TYPE sy-fdpos,
  lv_clstagidx TYPE sy-fdpos.
 
  lv_defidx = -1.
  lv_clstagidx = 10000.
  IF lv_xml CS '<?xml'.                                  "#EC NOTEXT
  lv_defidx = sy-fdpos.
  IF lv_xml CS '>'.
  lv_clstagidx = sy-fdpos + 1.
  IF lv_clstagidx > lv_defidx.
  lv_xml = lv_xml+lv_clstagidx.
  ENDIF.
  ENDIF.
  ENDIF.
  CONCATENATE '<?xml version="1.0"?>' lv_xml INTO lv_xml."#EC NOTEXT
%>

********* Finally pass the modified configuration data to the tag


<chtmlb:config xml  = "<%= lv_xml %>"
               mode = "RUNTIME" />

***************************************************************************************************************************************************************************

In the next document http://scn.sap.com/docs/DOC-29972 we will concentrate on other types of views.

26 Comments
Labels in this area