cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Fields

Former Member
0 Kudos

Hi All,

I am new to WebDynpro ABAP.

I have a requirement wherin i have to display an attachment field for uploading a document for any changes in the given field such as NACHN. The attachment field should be dynamic and is mandatory. The user can submit any format of the doc in the attachment field such as .pdf, .doc, etc.

Also i have to dynamically display 2 fields SSN,SIN for 2 different countries respectively.

And i have a requirement wherin i have to hide the display of a field for a particular country where as it should be displayed for other countries.

Any pointers or code regarding this would be helpful.

Thanks in Advance

Rama

Accepted Solutions (1)

Accepted Solutions (1)

former_member196023
Active Participant
0 Kudos

Hi Rama,

There is one UI Element called 'FileUpload", this will be useful in your case.

You need to bind XSTRING type attribute with this element. and content can be stored in databse if you wish.

Thanks,

-Haresh

Answers (4)

Answers (4)

uday_gubbala2
Active Contributor
0 Kudos

Hello Rama,

As how pointed out by the other members you need to make use a FileUpload UI element for realizing your functionality of being able to upload any kind of document.

And regarding the displaying of SSN & SIN dynamically as per the country you need not go for any kind of dynamic programming. Just design your layout with these fields on it and bind their "visibility" properties to a context attribute of type WDUI_VISIBILITY. So now depending up on the country that you have to process you would set the appropriate visibility value to the corresponding. context atribute.

Suppose you have bound attributes ATTR1 & ATTR2 to the visibility properties of SSN & SIN. By default I have given the attributes a value of 2 i.e, both the fields SSN & SIN would be visible by default. During processing if you need to show only SSN for a customer then you would change the attribute value of ATTR2 to 1 through a normal SET_ATTRIBUTE method.

Please note that you can achieve similar results through complete dynamic programming but you are best keeping things simple & doing it through this clever context mapping. Dynamic programming complicates your application and also your component would take longer to load.

Regards,

Uday

Former Member
0 Kudos

For uploading any kind of file, use File UPload UI Element.

Refer this SAP Online Help :

http://help.sap.com/saphelp_erp2005/helpdata/EN/b3/be7941601b1d09e10000000a155106/frameset.htm

Alongwith Standard Comp : WDR_TEST_EVENTS .

For Dynamic Visiblity of Fields, bind the Field' visible property to a context Attribute of type WDUI_Visibility.

For making Field based on country , set this context .

For visibility : set to 02.

For invisible : 01.

I hope it helps.

Thanks.

Former Member
0 Kudos

hello Devi ,

for dynamic fields u need to follow the foolwing steps :

1 insert a transparent container in the ROOT ELEMENT UI CONTAINER .

2 on appropriate action of creating dynamic field , proceed like this piece of code ,

for creating dynamic text edit ui element

 ..

 -> 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.


  ->  lr_container ?= wd_this->mr_view->get_element('TC_TEXTEDIT' ).

*  CHECK first_time = abap_true.

*    generating dynamic node with UNIQUE ID
 ->   DATA : lv_node type string value 'CHILD'.

  ->  CONCATENATE lv_node wd_this->count1 INTO lv_node.
   -> wd_this->count1 = wd_this->count1 + 1.

  ->  lr_node_info = wd_context->get_node_info( ).

   -> CALL METHOD lr_node_info->add_new_child_node
     -> EXPORTING
     ->   name                         = lv_node
     ->   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.



** 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_row_head_data=>new_row_head_data( element = lr_textedit ).
   ->   lr_container->add_child( lr_textedit ).

here I have created an attribute mr_view as the view reference when WDDOMODIFY is called for the first time and then use this reference in the event handler of the button to create the dropdown dynamically.

for dynamic text edit i have used the class cl_wd_text_edit ,

so u can use accordingly for ur fields .count1 is the attribute of type NUM declared in the view for unique id of

the context node.

name of the dynamic node is CHILD and attribute name is ATTR .

I hope it wud help.

regards,

amit

Former Member
0 Kudos

Check this blog on dynamic programming; [https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2888] [original link is broken]; This will help you give a basic understanding about working with dynamic programming. Regards, Radhika.