1 1 1 1 1 Rating 0% (0 Votes)
Welcome back :-) 
Some time ago I presented how I get data from classifications to reference data variable ( or table). If you feel comfortable with my method then we can go further. I had a task to update some characteristic values from ALV grid, this would be not a problem at all if the characteristics would be defined from the begriming, but they weren't. In that case I couldn't just add needed fields to fieldcatalog and call FM to update characteristics when save button was pressed. I realized I need dynamic structure for ALV which will call standard screen for characteristic update. If this could be done then I could omit carrying about type of characteristics (date, number, char ) and if it is single o multiple type. So I started to dig in SAP, debug standard functions and I was finally able to prepare all needed functions.
So firstly what was needed (additionally to previously presented methods):
In this and following parts of this tutorial you'll see all mentioned methods and example of their usage. You can also find the code in attached NUGG file for easier import to your system.
Ok so let's start with simple method to convert values from standard type to characteristic value. This method is needed because if you look into characteristic values table you'll see it's stored in floating point type.

I_ATNAM     Type API_VALUE-ATNAM ->  Characteristic Name
I_VALUE_NEW Type ANY             ->  Characteristic Value


R_VALUE_FLOAT Type -> Internal floating point from


  method convert_char_value.
    datam_value_new type atwtb.

    write i_value_new to m_value_new.

    call function 'CHAR_VALUE_CHANGE2'
*       atinn                  = ft_values-atinn
        atnam                  i_atnam
*       atwrt                  = r_value_float
        atflv                  r_value_float
        characteristic_unknown 1
        conversion_error       2
        value_set_error        3
        others                 4.
    if sy-subrc eq 0.

  endmethod.                    "convert_char_value

Ok, so we have one simple method ready, in next part one old trick will be needed.