on 03-04-2009 1:39 AM
Hi,
I am trying to add a dynamic amount of groups into a group that I have on the view.
The problem is that I get a dump (The ASSERT condition was violated.).
I do it on the WDDOMODIFYVIEW method.
my code is:
data:
lr_group TYPE REF TO cl_wd_group,
lr_new_group TYPE REF TO cl_wd_group.
lr_group ?= view->get_element( 'GROUP_ITEMS' ).
LOOP AT lt_items ASSIGNING <item>.
ADD 1 TO lv_col.
CONCATENATE 'GROUP_' lv_col '_' lv_row INTO lv_str.
lr_new_group = cl_wd_group=>new_group( id = lv_str
design = '02'
).
lr_matrix_head = cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_new_group ).
lr_new_group->set_layout_data( lr_matrix_head ).
lr_group->add_child( lr_new_group ).
....
endloop.
All the examples I saw are with text view/ input field.
Has anyone tried this before?
Thanks,
Itay
Hi Itay,
Try use the below code in your WDDOMODIFYVIEW. It would:
1) Create a main group with id MAIN_GROUP & a caption for it.
2) Dynamically create 4 other Groups (with id's Group1..Group4) & captions for each and them to the main group.
Hope this helps resolve your problem.
Regards,
Uday
method WDDOMODIFYVIEW .
data: lr_container type ref to cl_wd_uielement_container,
lr_group type ref to cl_wd_group,
lr_new_group type ref to cl_wd_group,
lr_caption type ref to cl_wd_caption,
lv_string type string.
check first_time = abap_true.
lr_container ?= view->get_root_element( ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
" Create a Group (with id MAIN_GROUP) & set its layout properties
lr_group = cl_wd_group=>new_group( id = 'MAIN_GROUP' ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_group ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_group ).
" Create a caption to use for the Group created
lr_caption = cl_wd_caption=>new_caption( text = 'Caption For Group1' ).
lr_group->set_header( lr_caption ).
" Create 3 Groups & add them to the main Group -> MAIN_GROUP
do 4 times.
" Now we create Group's dynamically. For this we compute their id's to be of the format GROUP1..GROUP4
lv_string = sy-index.
concatenate 'GROUP'
lv_string into lv_string.
condense lv_string no-gaps.
lr_new_group = cl_wd_group=>new_group( id = lv_string ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_new_group ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_new_group ).
" Now we create Caption's dynamically. For this we compute their text's to be of the format
" "Caption for Group1"..."Caption for Group4"
concatenate 'Caption for'
lv_string into lv_string separated by space.
lr_caption = cl_wd_caption=>new_caption( text = lv_string ).
lr_new_group->set_header( lr_caption ).
lr_group->add_child( the_child = lr_new_group ).
enddo.
" Add the main Group (MAIN_GROUP) with all its embedded Groups to the Container
lr_container->add_child( the_child = lr_group ).
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Itay,
As an additional example you can go through this other code snippet which does the following tasks:
1) Create a context node (by name CHILD) dynamically
2) Create 4 attributes (ATTR1..ATTR4) for the created node dynamically
3) Create a Group dynamically
4) Create 4 TextView's dynamically & embed them within the Group
Regards,
Uday
METHOD wddomodifyview.
DATA: lr_container TYPE REF TO cl_wd_uielement_container,
lr_group TYPE REF TO cl_wd_group,
lr_caption_group TYPE REF TO cl_wd_caption,
lr_textedit TYPE REF TO cl_wd_text_edit,
lr_node_info TYPE REF TO if_wd_context_node_info,
lr_node TYPE REF TO if_wd_context_node,
lr_element TYPE REF TO if_wd_context_element,
lr_attribute_info TYPE wdr_context_attribute_info,
content TYPE string,
attribute_name TYPE string,
lv_textview_id TYPE string.
CHECK first_time = abap_true.
lr_node_info = wd_context->get_node_info( ).
CALL METHOD lr_node_info->add_new_child_node
EXPORTING
name = 'CHILD'
is_mandatory = abap_false
is_multiple = abap_true
is_multiple_selection = abap_true
is_singleton = abap_false
is_initialize_lead_selection = abap_true
is_static = abap_false
RECEIVING
child_node_info = lr_node_info.
lr_container ?= view->get_root_element( ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
lr_group = cl_wd_group=>new_group( id = 'GROUP' ).
lr_group->set_width( value = '50%' ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_group ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_group ).
lr_caption_group = cl_wd_caption=>new_caption( text = 'Group Header' ).
lr_group->set_header( the_header = lr_caption_group ).
DO 4 TIMES.
MOVE sy-index TO attribute_name.
" Preparing the data to be displayed in the textEdit i.e, data for context attribute
CONCATENATE 'This'
'is the'
'data for textEdit number: '
attribute_name INTO content SEPARATED BY cl_abap_char_utilities=>newline.
CONCATENATE 'ATTR'
attribute_name INTO attribute_name.
" Condense the ID to ensure that the format is consistent with SAP standard
CONDENSE attribute_name NO-GAPS.
" Prepare properties of attribute & add to context node CHILD
lr_attribute_info-name = attribute_name.
lr_attribute_info-type_name = 'STRING'.
lr_attribute_info-value_help_mode = '0'.
lr_node_info->add_attribute( EXPORTING attribute_info = lr_attribute_info ).
lr_node = wd_context->get_child_node( name = 'CHILD' ).
lr_element = lr_node->create_element( ).
lr_element->set_attribute( name = attribute_name
value = content ).
lr_node->bind_element( new_item = lr_element
set_initial_elements = abap_false ).
" Compute the attribute path dynamically i.e, like CHILD.ATTR1
CONCATENATE 'CHILD.'
attribute_name INTO attribute_name.
CONDENSE attribute_name NO-GAPS.
lr_textedit = cl_wd_text_edit=>new_text_edit( cols = 10
rows = 5
width = '90%'
bind_value = attribute_name ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_textedit ).
lr_group->add_child( the_child = lr_textedit ).
ENDDO.
lr_container->add_child( the_child = lr_group ).
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Avni,
Please go thru the links below for dynamic programming for creation of group.
[Dynamic prog. Part 1|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2888] [original link is broken] [original link is broken] [original link is broken];
[Dynamic Prog. Part 2|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2915] [original link is broken] [original link is broken] [original link is broken];
[dynamic prog part 3|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2953] [original link is broken] [original link is broken] [original link is broken];
Regard
Manoj Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
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.