How To Modify Configuration of Form View Dynamically

Here we want to modify the configuration of a form view. The idea is very simple, to convert the XML formatted configuration data to ABAP, modify and convert it back to XML

We achive this in the .hml file of our view

We start with the variables to be used

DATA: lr_view_desc     TYPE REF TO if_bsp_dlc_view_descriptor,
      lv_xml           TYPE string,
      lv_xml_inp       TYPE bsp_dlc_xml,
      ls_config        TYPE bsp_dlc_table_descr,
      lt_adv_conf      TYPE bsp_dlct_adv_conf_itm,
      lv_defidx        TYPE sy-fdpos,
      lv_clstagidx     TYPE sy-fdpos.

 

Next we read and convert the configuration data from XML to ABAP so we can modify it easily

*    get original xml
    lv_xml_inp = me->configuration_descr->get_config_data( ).

    lr_view_desc = me->configuration_descr->get_property_descriptor( ).

    cl_bsp_dlc_config_util=>adv_conf_meta_to_table( EXPORTING ir_view_descr        = lr_view_desc
                                                              iv_adv_conf_meta_xml = lv_xml_inp
                                                    IMPORTING et_adv_conf          = lt_adv_conf ).

 

Now that we have the configuration data in lt_adv_conf internal table, we can make changes. You can see the contents of the table in the debugger for easier modification

After the changes are made, we need to convert our configuration data back to XML

cl_bsp_dlc_config_util=>adv_conf_table_to_meta( EXPORTING it_adv_conf          = lt_adv_conf
                                                          ir_view_descr        = lr_view_desc
                                                IMPORTING ev_adv_conf_meta_xml = lv_xml ).

lv_defidx = -1.
    lv_clstagidx = 10000.
    IF lv_xml CS '<?xml'.
      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.

 

Lastly we pass the new configuration XML to the configuration tag for display

<chtmlb:config displayMode = "<%= controller->view_group_context->is_view_in_display_mode( controller ) %>"
               xml         = "<%= lv_xml %>"
               mode        = "RUNTIME" /> 

 

ABOUT Furkan Sönmez

www.linkedin.com/profile/view?id=122521475

RELATED POSTS

COMMENTS

comments powered by Disqus