cancel
Showing results for 
Search instead for 
Did you mean: 

Making table fields as mandatory

Former Member
0 Kudos

Hello Everyone,

I am stuck with an issue in my application. I hope you can give me some ideas about how to proceed further!

In my webdynpro application, we have a table with 20 blanks rows added initially in the wdDoinit() method. Now, I have made all my table fields as mandatory by inserting the standard code in the "WDDOBEFOREACTION" method. My requirement is, if the user only want tot use the first 3 rows of the table and proceed, the application is expecting the user to fill all the blank rows. I want the mandatory function to work only the rows the user is using.

Is there any way that this can be acheived. please let me know if my question is not clear. I'll try to explain in more detail.

Regards,

Gopal.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The 20 rws that you are trying to populate has data in them or not.

What is "USER enters"....Can you be more clear.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

The 20 rows are present by default, but at runtime only 3 or 4 rows are meant to be filled by the endusers. So, among the 20 rows only the first few rows would have data in them.

Let me know i you need more clarification.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

Out of 20 rows, 17 rows have data in them...and other 3 rows the user has to enter data right, for which you need to vlaidate for mandatory check.

One thing, Do you know on prior you display the table, which are the rows that user needs to enter data( any indicator) is there

to distingush between the records.

Are the other 17rows/reocrds non editbale.

Former Member
0 Kudos

Hi Lekha,

No, that's not right. All the 20 rows are blank when the application is started. Now, I only want to enter data in to 3 rows as shown in the following screenshot.

http://i32.tinypic.com/fc2ovb.jpg

Thanks alot for your help.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

One thing, when the other rows are empty, why are you displaying them.

If the user enters any data in the record, Is there any button that the user clicks after entering data.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

The reason, why I am displaying the empty rows is, we dont know how many rows we will use. It will be decided only at runtime. So, we have set a maximum limit of 20 rows. Yes, once we enter the data into the table, we will click on "Post Document" button as shown in the screen shot.

http://i32.tinypic.com/fc2ovb.jpg

Regards,

Gopal.

Former Member
0 Kudos

Hi,

Due to some technical reasons, we can not access your page for the view.

As they are editable fields,

Try to have the context change log for that Node.

So that when ever the user enters any thing, As there is a change, then you can get the index of rows where the user has entered.

For these rows, you can apply mandatory checks. Are you using, your code(report error message) or using the standard ones.

For ho w many columsn editability is there.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

Could you please explain me, how to do that Context change log? I would greatly appreciate your help.

For mandatory field checks, I am using the standard ones. Please let me know if I can contact you by mail to share some screenshots?

Regards,

Gopal.

Edited by: Gopal on Sep 8, 2009 5:25 PM

Former Member
0 Kudos

Hi,

DEMO_CONTEXT_CHANGES is the standard WD component.

Can you post your code for the mandatory checks.

Are the errors thrown for all the 20rows as of now. Is that SO.

How many columns are editable.

Regards,

Lekha.

Former Member
0 Kudos

Hi Lekha,

In my table, all the 20 rows are editable. So, at runtime if we fill only 5 rows and leave all the other 15 rows blank, it is throwing mandatory fields error for all the 15rows that are left blank.

Code for the mandatory check is as follows:-


method WDDOBEFOREACTION .
DATA: l_view_controller TYPE REF TO if_wd_view_controller.
   l_view_controller = wd_this->wd_get_api( ).

  cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
  EXPORTING view_controller  = l_view_controller
            display_messages = abap_true
  ).
endmethod.

How do I use the standard WD Component DEMO_CONTEXT_CHANGES to use the context change log? Please explain me in more details. i would appreciate your help.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

First for that node yuo need to enable context change log. When ever you display the data to user that time of rendereing you enable the context change log.

For me the node is global Hence I created 3 mthods in component controller for the change logs.

ENABLE_LOG, GET_LOG and DISABLE_LOG.

Enable log -

DATA:
    context             TYPE REF TO if_wd_context,
   lo_nd_efforts       TYPE REF TO if_wd_context_node.

*   navigate from <CONTEXT> to <DAYEFFORTS> via lead selection
  lo_nd_dayefforts = wd_context->get_child_node( name = wd_this->wdctx_dayefforts ).  "Node name

    IF lo_nd_efforts  IS BOUND.
      context = lo_nd_efforts->get_context( ).
    ENDIF.
    IF context IS NOT INITIAL.
      context->enable_context_change_log( ).
    ENDIF.

DISABLE_LOG -

DATA:
    context             TYPE REF TO if_wd_context,
   lo_nd_efforts       TYPE REF TO if_wd_context_node.
*   navigate from <CONTEXT> to <DAYEFFORTS> via lead selection
  lo_nd_dayefforts = wd_context->get_child_node( name = wd_this->wdctx_dayefforts ).  "Node name

    IF lo_nd_efforts  IS BOUND.
      context = lo_nd_efforts->get_context( ).
    ENDIF.
    IF context IS NOT INITIAL.
       context->disable_context_change_log( ).
    ENDIF.

GET_LOG -

DATA:
    context             TYPE REF TO if_wd_context,
   lo_nd_efforts       TYPE REF TO if_wd_context_node.
*   navigate from <CONTEXT> to <DAYEFFORTS> via lead selection
  lo_nd_dayefforts = wd_context->get_child_node( name = wd_this->wdctx_dayefforts ).  "Node name

    IF lo_nd_efforts  IS BOUND.
      context = lo_nd_efforts->get_context( ).
    ENDIF.
    IF context IS NOT INITIAL.
       changes = context->get_context_change_log( ).  
*Declare a CHNAGES as exporting parameter in this method of type WDR_CONTEXT_CHANGE_LIST
    ENDIF.

Now, I enabled the change log method in the Inbound plug(hanlder event) by calling the ENABLE_LOG method.

Now on the Button handler, I got the log

DATA:lt_changes TYPE wdr_context_change_list, "Sorted table

*Get changes

wd_comp_controller->get_log(

IMPORTING

changes = lt_changes ). " wdr_context_change_list

Now in the node, to which the table is bound, create a attrobute of type boolean.

If there are changes in the lt_changes, then update the table for this boolean as "X" indicates that there is a change.

Then, Loop at this data table and find the record for 'X'.

Then you display your message for this record.

loop at lt_table into ls_table.

ls_table-check eq 'X'.

*Report the error message for Intiial values not entered.

endloop.

The stanndard ones for mandatory code can not be used in this case as it throws errors for all reocrds and does not consider the change log becaous you are displaying the empty records.

Regards,

Lekha.

Former Member
0 Kudos

Thanks for the code Lekha. I'll try to implement your code and will get back to you, if I have any problems. Meanwhile, could you please explain me of how to do the mandatory fields check without using the standard ones.

Thanks a lot for your help.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

If you table has 10 columns, out which how many are mandatory being set.

CALL METHOD wd_comp_controller->gref_nd_efforts->get_elements
        RECEIVING
          set  = lit_elementset.  "Check the type and declare it(if_wd_context_node)

      LOOP AT wd_comp_controller->lit_elementset INTO wd_comp_controller->gref_element.
        CALL METHOD wd_comp_controller->gref_element->get_static_attributes
          IMPORTING
            static_attributes = wd_comp_controller->lis_efforts. "You structure type

IF wd_comp_controller->lis_efforts-begda or wd_comp_controller->lis_efforts-endda.
          CALL METHOD wd_comp_controller->gref_msg_manager->report_attribute_error_message "Only for BEGDA error is showon by highlighing.
            EXPORTING
              message_text      = 'Fill in required fields'
              element           =   wd_comp_controller->gref_element
              attribute_name    = 'BEGDA'
endif.
endloop.

If you want the error to be shown to the entire record -

DATA:
    lt_attr_list    TYPE string_table,
    ls_attr_list    TYPE string.
          ls_attr_list = 'BEGDA'.
          APPEND ls_attr_list TO lt_attr_list.
          CLEAR ls_attr_list.

          ls_attr_list = 'ENDDA'.
          APPEND ls_attr_list TO lt_attr_list.
          CLEAR ls_attr_list.

****Shows errors when initial
          CALL METHOD wd_comp_controller->gref_msg_manager->report_element_error_message
            EXPORTING
              message_text = ' Fill in required field'
              element      = wd_comp_controller->gref_element
              attributes   = lt_attr_list.

To populate this table lt_attr_list yuo can use the get_attributes method of if_wd_context_node_info.

Regards,

Lekha.

Former Member
0 Kudos

Instead of appending 20 blank rows initially, why dont you create 2 buttons Append(+) and Remove(-) on table toolbar to add rows . This will allow the users to add the rows as per their needs and you can avoid lot of code related to handling so many blank rows. Radhika.

Former Member
0 Kudos

Hi Radhika,

Thanks for your reply. Initially, I have done the way you explained. But, my client wants the least number of clicks on this application. So, I am forced to do this way!!

Meanwhile, I trying to implement the above given code. But, I am bit confused with the code. Could you suggest me an alternative code for my situation? I greatly appreciate your help.

Regards,

Gopal.

Former Member
0 Kudos

Where are you getting confused......Tell me where you want to highlght erroor on specifc cell of a row or entire row needs to be highlighted.

Former Member
0 Kudos

Hi Lekha,

I inserted the code as follows:-


1. Place the following code in the WDDOINIT method of the Component Controller

* enable context change log
    data: context type ref to if_wd_context.
    context = wd_context->get_context( ).
    context->enable_context_change_log( ).

2. Create a new method 'GET_CHANGE_LOG' in the Component Controller's Methods Tab


" Create a Returning Parameter 'CHANGES'  type WDR_CONTEXT_CHANGE_LIST 
method get_change_log .
    data: context type ref to if_wd_context.
    context = wd_context->get_context( ).
    changes = context->get_context_change_log( ).
endmethod.

3. When you want to track the changes call his this method as follows,


DATA: l_ref_componentcontroller TYPE REF TO ig_componentcontroller .
    DATA: l_changes TYPE wdr_context_change_list.
          
    l_ref_componentcontroller =   wd_this->get_componentcontroller_ctr( ).
    l_changes = l_ref_componentcontroller->get_change_log( ).
 
"  l_changes will contain all the details of the changes made.

After this, you asked me to do the following, which I am not able to understand!

Now in the node, to which the table is bound, create a attrobute of type boolean.

If there are changes in the lt_changes, then update the table for this boolean as "X" indicates that there is a change.

Then, Loop at this data table and find the record for 'X'.

Then you display your message for this record.

loop at lt_table into ls_table.

ls_table-check eq 'X'.

*Report the error message for Intiial values not entered.

endloop.

Meanwhile, I am also confused about inserting the code for the mandatory check as well.

Sorry if I am causing any inconvenience. Thanks a lot for your help.

Regards,

Gopal.

Edited by: Gopal on Sep 9, 2009 11:05 AM

Former Member
0 Kudos

Hi Lekha,

I want to highlight the specific cell of the row, where the error has occured, not the entire row!

Regards,

Gopal.

Former Member
0 Kudos

Hi Lekha,

Now, I have just changed the code and I am trying to implement the code you have given me. Could you please tell me about the following parts of the code.....

1) In my scenario, my node is not global. My node is only available in the component controller. I cannot decalre all the three methods that you mentioned in the component controller. So, I created those 3 methods in my view controller. Is this fine?

2) After creating the 3 methods, how do I call the "ENABLE_LOG" method in the Inbound plug(hanlder event). I am not able to see any "Handler Event" in my Inbound plug tab.

3) Could you please suggest me of how to proceed further from here?

I would greatly appreciate your help.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

One more thing, how many columns are there that are mandatory....

the part of code....report_attrihute_error_mesage...i used to highlight specifc cell...

Write the code in button handler.

When yuo implement the context change log....

You will get the table....in button handler by calling get_log method right.

Now, in this table you will get the index of the row.

Using this index...set the attribute as X (newly created one insde the table node).....

Let me know once your done...

Regards,

Lekha.

Former Member
0 Kudos

Lekha,

When I am trying to insert the code for "Check Mandatory" that you have given:-


CALL METHOD wd_comp_controller->gref_nd_document->get_elements
    RECEIVING
      set  = lit_elementset.  "Check the type and declare it(if_wd_context_node)

    LOOP AT wd_comp_controller->lit_elementset INTO wd_comp_controller->gref_element.
      CALL METHOD wd_comp_controller->gref_element->get_static_attributes
        IMPORTING
        static_attributes = wd_comp_controller->lis_efforts. "You structure type

    IF wd_comp_controller->lis_efforts-begda or wd_comp_controller->lis_efforts-endda.
        CALL METHOD wd_comp_controller->gref_msg_manager->report_attribute_error_message "Only for BEGDA error is showon by highlighing.
            EXPORTING
              message_text      = 'Fill in required fields'
              element           =   wd_comp_controller->gref_element
              attribute_name    = 'BEGDA'.
     endif.
     endloop.

In the above code, what should be the "type" of "lit_elementset"?

Regards,

Gopal.

Former Member
0 Kudos

Hi Lekha,

Eventually, I managed to finish the "Check Mandatory" code that you have given me. Now, could you please tell me of how to implement the Context change log?

thanks for your help.

Regards,

Gopal.

Former Member
0 Kudos

Hi,

Have you created a context attribute of type boolean in the node to which table is bound.

In the button handler,

use the GET_LOG method. Refer my previous post.

created CHNAGED attribute in the node to which the table is bound.

DATA:
    lt_changes   TYPE wdr_context_change_list,
    lt_changes1     TYPE /plmu/t_frw_change_log, "Standard table
    ls_changes   TYPE wdr_context_change.                   "#EC NEEDED

*Get changes
  lt_changes = wd_comp_controller->get_log( ).
   READ TABLE lt_changes INTO ls_changes WITH KEY node_name = 'MYNODE'. "Node name
  IF sy-subrc EQ 0.
*Record changes
  IF lt_changes IS NOT INITIAL.
    lt_changes1[] = lt_changes[].
    SORT lt_changes1 BY element_index.
    DELETE ADJACENT DUPLICATES FROM lt_changes1 COMPARING element_index.
     LOOP AT lt_changes1 INTO ls_changes.
        READ TABLE wd_this->lt_dayefforts_tmp INTO ls_dayeff INDEX ls_changes-element_index.
        IF sy-subrc EQ 0.
          ls_dayeff-changed = 'X'.
          MODIFY wd_this->lt_dayefforts_tmp FROM ls_dayeff INDEX ls_changes-element_index.
        ENDIF.
        CLEAR: ls_dayeff, ls_changes.
      ENDLOOP.
  ENDIF.

Regards,

Lekha.

Former Member
0 Kudos

Lekha,

Thank you so much for your help and support. I greatly appreciate your help.

Regards,

Gopal.

Answers (0)