on 09-18-2012 10:24 AM
Hello gurus,
in our SRM system, we organize dinamically our custom fields layout via a simple routine in WDDOMODIFYVIEW, with the following logic:
lv_container_name_left = 'LEFT_CONTAINER'.
lv_container_name_right = 'RIGHT_CONTAINER'.
wd_this->mo_dodm_ctr_h_bd->/sapsrm/if_cll_do_mapper~init_field_extensions(
EXPORTING
iv_container_name = lv_container_name_left
iv_container_name_right = lv_container_name_right
iv_view = view ).
LOOP AT lt_header_csf INTO ls_header_csf.
* Concatenate attribute id and label
CONCATENATE ls_header_csf-field_name '_ATTR' INTO lv_attr_id.
CONCATENATE ls_header_csf-field_name '_LABEL' INTO lv_label_id.
lo_ui_element_attr ?= view->get_element( lv_attr_id ).
lo_ui_element_label ?= view->get_element( lv_label_id ).
....
lo_container ?= view->get_element( lv_container_name_cuf ).
IF lo_container IS BOUND.
lo_container->set_visible( cl_wd_uielement=>e_visible-visible ).
ENDIF.
....
CASE ls_header_csf-container_pos. "info from customer configuration table
WHEN zr7_cl_pdo=>gc_left.
lo_container ?= view->get_element( lv_container_name_left ).
WHEN zr7_cl_pdo=>gc_right.
lo_container ?= view->get_element( lv_container_name_right ).
WHEN OTHERS.
lo_container ?= view->get_element( lv_container_name_left ).
ENDCASE.
* finally, we add the couple description label - field to the container:
lo_container->add_child( the_child = lo_ui_element_label ).
lo_container->add_child( the_child = lo_ui_element_attr ).
ENDLOOP.
The above logic works fine and results are visible in the attached screenshot (custfields.png) ; as you can see, fields are organized in two distinct columns:
Now, the question: we'd like to have two custom fields aligned on the same row on the same container; specifically, we'd like to have "Min.Amount Guaranteed" and "Currency", which are the last two fields on the right container, on a single line. Photoshop helps here; we like to obtain this:
I thought this could be obtained creating a new transparent container, adding on this the two fields and then adding the transparent container to the right container. Here's a sketch of code I tried:
"create a transparent container
IF ls_header_csf-field_name = 'ZZ_MIN_GAR'. " processed before ZZ_MIN_CURRENCY in the loop
DATA: transparent_container TYPE REF TO CL_WD_TRANSPARENT_CONTAINER.
transparent_container = cl_wd_transparent_container=>new_transparent_container( ).
transparent_container->add_child( the_child = lo_ui_element_label ).
transparent_container->add_child( the_child = lo_ui_element_attr ).
ELSEIF ls_header_csf-field_name = 'ZZ_MIN_CURRENCY'. "processed after ZZ_MIN_GAR in the loop
transparent_container->add_child( the_child = lo_ui_element_label ).
transparent_container->add_child( the_child = lo_ui_element_attr ).
* add the transparent container to the right container
lo_container->add_child( the_child = transparent_container ).
...
However, I got a dump (lately, as on the single instructions it doesn't provide and sy-subrc <> 0): I'm definitely missing something, like configuration of the transparent container so that data in it should be organized with a matrix layout, and so on.
Could anyone of you gurus provide me an help or suggestion in order to achieve the desiderata?
Thanks you very much,
kind regards.
Message was edited by: Matteo Montalto
Ok, did it!
Here's how:
I created two different transparent container as sub-container of the right container, as shown below:
Then I managed via code that the first couple label-field has to be assigned to INLINE_CONTAINER_LEFT, while the second couple label-field (currency) has to be assigned to INLINE_CONTAINER_RIGHT. Here's the code:
IF ls_header_csf-field_name = 'ZZ_MIN_GAR'.
DATA: new_container TYPE REF TO cl_wd_uielement_container.
DATA: top_container TYPE REF TO cl_wd_uielement_container.
new_container ?= view->get_element( 'INLINE_CONTAINER_LEFT' ).
new_container->add_child( the_child = lo_ui_element_label ).
new_container->add_child( the_child = lo_ui_element_attr ).
top_container ?= new_container->get__parent( ).
top_container->remove_child( id = 'INLINE_CONTAINER_LEFT' ).
lo_container->add_child( the_child = new_container ).
....
IF ls_header_csf-field_name = 'ZZ_MIN_CURRENCY'.
new_container ?= view->get_element( 'INLINE_CONTAINER_RIGHT' ).
new_container->add_child( the_child = lo_ui_element_label ).
new_container->add_child( the_child = lo_ui_element_attr ).
top_container ?= new_container->get__parent( ).
top_container->remove_child( id = 'INLINE_CONTAINER_RIGHT' ).
lo_container->add_child( the_child = new_container ).
And that worked but... there's a little thing I'd like to solve.
Up to now, the resulting view is shown as below:
As you can see, the couple field-label are not aligned to the previous one (which are in TC_CTR_CAA_RIGHT); I'd like to have "Min.Amount Guaranteed" aligned w.r.t. the previous fields, and "Currency" on its right.
Tried also to work on width parameters on the Transparent Container but every change I made didn't affect the spacing in the view. Could anyone help me with that?
Thanks,
M.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.