on 05-18-2010 3:27 PM
Hi everyone.<br><br>
I've posted two questions so far about a program I've been developing for what amounts to a fair amount of time. My Ops Leader has suggested that instead of hard-coding the checkboxes for the program, I should attempt to do them dynamically. Let me give a basic program setup and then present my two current trains of thought on the subject. This will get wordy.<br><br>
The program itself is designed to be a way for an end-user to reset their password when they lock themselves out or have forgotten a password. It is to be flexible so it will display all systems the user has access to. For sake of simplicity, consider that the step of gathering users and their system accesses is done. When the page comes up, it needs to generate a series of checkboxes that the user may select one or more so the system can process all those systems in a single go when a button is clicked.<br><br>
The table used for user access (hereafter "USERSYSTEMS") has headers that are named after each system, and simply uses a boolean to signify if they are on that system or not.<br><br>
We are using RFC calls to make these resets happen, and it is setup as follows: Two description fields for each system's RFC call are used, one holding "ITCSC" which is a flag for it being used on this program, and the other is the system's name (such as CP1).<br><br>
Currently I am looking at this and seeing two ways of dynamically generating these boxes.<br><br>
<b>First method</b>: It involves using individual generation of checkboxes. I'm a bit unsure if it is possible to call USERSYSTEMS's field names to populate the text on these or not. Otherwise the RFC table would have to be used. This would likely require a loop and some hefty logic to properly generate all the text boxes.<br><br>
<b>Second method</b>: It would involve using a checkbox group (which I have no experience using yet) that requires a table to populate the checkboxes. If I wanted to go this route I would likely have to generate an internal table out of the RFC and USERSYSTEMS tables for figuring out which boxes would have to be displayed, as well as their text values and dynamically binding that internal table to the checkbox group itself.<br><br>
<b>The Question(s)</b>: If you had to perform this generation of checkboxes, would you use either method, or perhaps even another way of looking at it?<br>As an alternative question, would it be easier in your opinion to stick with my current method of static boxes? That requires adding/removing a box, a few context spots, and some text within two methods if I keep the current process.
Hi Patrick,
Try the below code to create the checkboxes dynamically.
Ensure you have created a Node in context as NODE and three attributes str1, str2, str3 type string under it & also one more node as Dynamic and an attribute ALL_REQ type wdy_boolean under it. Also create a attribute ALL_REQ type string and set the default value as All Required.
Hope this code will help you..
METHOD wddomodifyview .
DATA: lr_container TYPE REF TO cl_wd_uielement_container,
lr_checkbox TYPE REF TO cl_wd_checkbox,
lr_node TYPE REF TO if_wd_context_node.
CHECK first_time = abap_true.
lr_container ?= view->get_root_element( ).
lr_container ?= wd_this->mr_view->get_element( 'TC' ).
cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ).
DATA lo_nd_node TYPE REF TO if_wd_context_node.
DATA lo_el_node TYPE REF TO if_wd_context_element.
DATA ls_node TYPE wd_this->element_node.
DATA lv_str3 LIKE ls_node-str3.
DATA lv_str1 LIKE ls_node-str1.
DATA lv_str2 LIKE ls_node-str2.
navigate from <CONTEXT> to <NODE> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
get element via lead selection
lo_el_node = lo_nd_node->get_element( ).
get single attribute
lo_el_node->set_attribute(
EXPORTING
name = `STR3`
value = 'ON_TOGGLE' ).
lo_el_node->set_attribute(
EXPORTING
name = `STR1`
value = 'ALL_REQ' ).
lo_el_node->set_attribute(
EXPORTING
name = `STR2`
value = 'DYNAMIC.ALL_REQ' ).
navigate from <CONTEXT> to <NODE> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
get element via lead selection
lo_el_node = lo_nd_node->get_element( ).
get all declared attributes
lo_el_node->get_static_attributes(
IMPORTING
static_attributes = ls_node ).
ls_node-str1 = lv_str1.
ls_node-str2 = lv_str2.
ls_node-str3 = lv_str3.
lo_el_node->set_static_attributes(
EXPORTING
static_attributes = ls_node ).
lr_checkbox = cl_wd_checkbox=>new_checkbox( bind_checked = ls_node-str2
bind_text = ls_node-str1
on_toggle = ls_node-str3
view = wd_this->mr_view ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
lr_container->add_child( the_child = lr_checkbox ).
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm considering this question answered. The tabular display sounds like it would work rather well, so I will attempt it or the row repeater method. The main concern was in generating the table for the headers and assigning their names properly, which is solved by both using the table itself. I'm still rather new to ABAP and Dynpro, but have worked with other languages a lot in the past. I just have to remember displaying tables in SAP is a far easier thing to do than dynamically code up objects.<br><br>
Thanks everyone, and I'm always still open for more suggestions if you have any.
Edited by: Patrick Seitz on May 19, 2010 8:17 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Considering User Friendlieness\ usability and ease of writing code,I would create a tabular diplay of all the systems in which user has access to .
One column would have system name and other column would have a checkbox to select\ deselect the sytem .
So Table would be like this:
Select System (checkbox ) System Name
You can also create a button on table toolbar saying select \deselect all which would further increase usability
Generating Dynaimic Individual checkbox would be a BIG no no from my perspective as it would involve messy coding.
Regards
Manas Dua
Edited by: Manas Dua on May 19, 2010 11:58 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.