Well, in my continued adventure, I found a new component in web dynpro call a cell variant. The basic idea behind this is that you can change what kind of cell is within a table. For example, sometimes you may want a field editable, based on the contents, and other times it should just be a text view. Well, I had something similar in my latest web dynpro experiment. I needed to do dynamic cell variants. By this, I wanted to add the cell variant to an ALV table, so I couldn’t just manually add it to the column. Well, thanks a cool document I found, I was able to pull this off… mostly.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0e7461d-5e6c-2b10-dda9-9e99df4d136d?overridelayout=true
Now, I use the term mostly, because of course, I tried branch out on my own. It’s probably easiest to explain with a little code and my example. First, I had a column in my ALV table that either listed a single serial number, or should provide a link to another window to show all the serial numbers associated with the document. This is perfect for the cell variant. I set it up so that
Here’s where I started, and syntactically, it would fine:
data: l_cv_ser TYPE REF TO cl_salv_wd_cv_standard,
lr_link_ser TYPE REF TO cl_salv_wd_uie_link_to_action,
l_col TYPE REF TO cl_salv_wd_column.
create OBJECT lr_link_ser.
lr_link_ser->set_text_fieldname( EXPORTING value = ‘SERNR’ ).
* create cell variant
create OBJECT l_cv_ser.
l_cv_ser->set_key( VALUE = ‘MULTIPLE’ ).
* add link to action editor
l_cv_ser->set_editor( lr_link_ser ).
* Get column
l_col = lv_value->if_salv_wd_column_settings~get_column( ‘SERNR’ ).
* add cell variant to column
l_col->add_cell_variant( r_cell_variant = l_cv_ser ).
* assign attribute
l_col->set_sel_cell_variant_fieldname( ‘SERNR’ ).
Now, if you pay close attention to the bold lines, these were my problem. See, the data in the column might be MULTIPLE, or it be 1, 2, 3, 800034234, or any serial number. So in my initial testing, it was all multiple, so it worked great. suddenly I was getting a short dump when it hit a cell with a value other than MULTIPLE. It finally hit me… with a cell variant, you either need to define an editor for each value in the column? or you need to make a new column with only 1 value or blank. i ended up going down the second path.
data: l_cv_ser TYPE REF TO cl_salv_wd_cv_standard,
lr_link_ser TYPE REF TO cl_salv_wd_uie_link_to_action,
l_col TYPE REF TO cl_salv_wd_column.
create OBJECT lr_link_ser.
lr_link_ser->set_text_fieldname( EXPORTING value = ‘SERNR’ ).
* create cell variant
create OBJECT l_cv_ser.
l_cv_ser->set_key( VALUE = ‘X’ ).
* add link to action editor
l_cv_ser->set_editor( lr_link_ser ).
* Get column
l_col = lv_value->if_salv_wd_column_settings~get_column( ‘SERNR’ ).
* add cell variant to column
l_col->add_cell_variant( r_cell_variant = l_cv_ser ).
* assign attribute
l_col->set_sel_cell_variant_fieldname( ‘CV_SER’ ).
lv_value->if_salv_wd_column_settings~delete_column( id = ‘CV_SER’ ).
I hope this sheds some light on the cell variant. it really is a pretty slick tool.
Thanks for reading,
Mike
I like the helpful info you provide to your articles. I’ll
bookmark your blog and tesst again right here frequently.
I am moderately sure Iwill learn plenty of new stuff proper right here!
Best of luck for the following!