I’ve been working recenlty on a business requirement that involved creation of a mix of some predefined columns and a number of period columns determined by selection criteria – so they could easily be modified (From/To).

And it would seem you have a number of options to create a SALV_WD_TABLE structure for a dynamic table, yet every had some drawbacks.

You could either use a DDIC structure reference for the static fields described here: https://scn.sap.com/thread/3245460

This is done by passing the structure name:

wd_context->get_node_info( )->add_new_child_node(
name  = ‘NODE_NAME’

static_element_type = ‘DDIC_NAME’

…)

The pros of this is you get all the DDIC bonuses in your column/cells like F4 help, edit masks and such. The drawback is that if you later loop over the node to dynamically add more columns, they don’t seem to be linked to values in the SALV data model, so the cells are always empty.

A workaround for that problem would be to rather pass an RTTI structure description of the dynamic table (already with the extra columns for periods), but then you loose a lot of the DDIC information like edit mask, because the attribute structure is a bit short.

lr_nd_info         = wd_context->get_node_info( )->add_new_child_node(

name                   = ‘DATA’

static_element_rtti    = lr_structdescr               “RTTI structure

…)

I did search a lot, but couldn’t find a good solution, so eventually I tried the hard way by checking the code and different parameters, and what I ended up is using the attributes parameter like so:

ls_attrib-name = ‘WBS_ELEMENT’.

ls_attrib-value_help_available = abap_true.

CONCATENATE if_wd_value_help_handler=>co_prefix_searchhelp ‘:’ ‘PRP’ INTO ls_attrib-value_help_id.

ls_attrib-value_help_mode = if_wd_value_help_handler=>co_prefix_searchhelp.

ls_attrib-value_help_type = if_wd_value_help_handler=>co_vh_type_backend.

ls_attrib-rtti ?= cl_abap_datadescr=>describe_by_name( p_name = ‘PS_POSID’ ).

INSERT ls_attrib INTO TABLE lt_attribs.

lr_nd_info         = wd_context->get_node_info( )->add_new_child_node(
name                   = ‘DATA’  
static_element_rtti    = lr_structdescr               “RTTI structure   attributes = lt_attribs ).

Only this way I managed to get those static columns with a sensible amount of DDIC support (value help, edit mask, column headers) and dynamic columns to properly work with the data model.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply