Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

 This is a small finding that I have found regarding the conversion errors like "g" to "h" or type "L" to type "I" and other errors.

When we want to move data among variables or field symbols of either similar data type to other datatypes, these conversion problems are encountered.

Using the class  cl_wdr_conversion_utils,     we can avoid these conversion errors.

This is a sample code for better understanding-

field-symbols: <fs> type data.
data lt_final type standard table of WDR_CONTEXT_CHANGE.
data ls_final type WDR_CONTEXT_CHANGE.
data ls_flights type ref to wd_this->element_flights.
data lv_var type string.
 
read table lt_final into ls_final index 1.
 
case ls_final-ATTRIBUTE_NAME.
when 'CARRID'.
        assign ls_final-new_value->* to <fs>.
          lv_var = cl_wdr_conversion_utils=>to_string( value = <fs> ).
       ls_flights-carrid = lv_var.
When...

Endcase.

 Eventhough the field symbol refers to any kind of data in the above code, still the conversion class methods are used to avoid these conversion errors.

Other example -

    DATA: l_ref_componentcontroller TYPE REF TO ig_componentcontroller .
    DATA: l_changes                 TYPE        wdr_context_change_list,
          l_subnode                 type ref to if_wd_context_node,
          l_subnodedata             type if_main=>element_details.
    field-symbols: <change> type wdr_context_change,
                   <new>    type data,
                   <old>    type data.
    l_ref_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
    l_changes = l_ref_componentcontroller->get_changes( ).
    data: l_node type ref to if_wd_context_node.
    l_node = wd_context->get_child_node( 'CHANGES' ).
    l_node->bind_table( l_changes ).
    loop at l_changes assigning <change>.
      if <change>-old_value is not initial and <change>-new_value is not initial.
        l_subnode = l_node->get_child_node( index = sy-tabix name = 'DETAILS' ).
        assign <change>-new_value->* to <new>.
        assign <change>-old_value->* to <old>.
        l_subnodedata-new_value_string = cl_wdr_conversion_utils=>to_string( value = <new> ).
        l_subnodedata-old_value_string = cl_wdr_conversion_utils=>to_string( value = <old> ).
        l_subnode->bind_structure( l_subnodedata ).
      endif.
    endloop.




 Please try to use the conversion utilities class to avoid these errors. These can be encountered when using the select-options standard ALV component or context change log class methods.

1 Comment

  1. Former Member

    Thanks for the info. It helped me to resolve my issue.