cancel
Showing results for 
Search instead for 
Did you mean: 

How to show error message when all inputfields are not filled

Former Member
0 Kudos

H Experts,

I have created one Webdynpro application..in that if we are not filling all  input field  it should show the error that " fill all the require fields" like ALV report..but it is giving dump..

Please share your knowledge..

find the attachment..

Thanks

Abhay Manna.

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Abhay,

You need to mark the input fields as "REQUIRED" and use the method  CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW to show errors if the required fields are not filled

Note: this method reports attribute error messages of individual input fields.

If you need to show only one message instead of individual messages , you can do it by just receiving error messages from above method and prepare an error message and use message manager method REPORT_ERROR_MESSAGE( ).

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Thank you very much for your reply

where I have to write this..in my code..actually I am beginner in Webdynpro..so if you please write me with step by step procedure..I will be grateful..

Thanks

Abhay Manna.

ramakrishnappa
Active Contributor
0 Kudos

Hi Abhay,

You can achieve your requirement as below

  • Go to view layout and find out the view element and set the property "state" to required as below

   

  • Go to the methods tab and add the below code in method WDDOBEFORE ACTION.


METHOD wddobeforeaction .
  DATA lo_api_controller TYPE REF TO if_wd_view_controller.
  DATA lo_action         TYPE REF TO if_wd_action.

  lo_api_controller = wd_this->wd_get_api( ).
  lo_action = lo_api_controller->get_current_action( ).

  IF lo_action IS BOUND.
    CASE lo_action->name.
      WHEN 'SAVE'. "Replace this with your action name
        cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
          EXPORTING
            view_controller  =     lo_api_controller
            display_messages = abap_true
        ).
    ENDCASE.
  ENDIF.
ENDMETHOD.

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Its really great.. my problem solved..Its working for me..Thanks for your help with detail information.

Now problem is if I am filling input fields with  wrong data that time again it is going for Dump.

acutally if end user putting wrong data that time also it shuld show that enter proper data..

how to do that..

Thanks

Abhay Manna.

ramakrishnappa
Active Contributor
0 Kudos

Hi Abhay,

You can perform additional validations against data consistency as below


  DATA lo_api_controller TYPE REF TO if_wd_view_controller.
  DATA lo_action         TYPE REF TO if_wd_action.
  DATA lt_messages  TYPE
cl_wd_dynamic_tool=>t_check_result_message_tab.
  DATA ls_messages  TYPE cl_wd_dynamic_tool=>t_check_result_message.

  lo_api_controller = wd_this->wd_get_api( ).
  lo_action = lo_api_controller->get_current_action( ).

  IF lo_action IS BOUND.
    CASE lo_action->name.
      WHEN 'OPEN_RM'.
        cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
          EXPORTING
            view_controller  =     lo_api_controller
            display_messages = abap_false
          IMPORTING
            messages         = lt_messages
        ).

        " all required fields are filled and hence no errors from
        " mandatory check
        IF lt_messages[] IS INITIAL.

          " read the context node of your input
            DATA lo_nd_date TYPE REF TO if_wd_context_node.

            DATA lo_el_date TYPE REF TO if_wd_context_element.
            DATA ls_date TYPE wd_this->element_date.

*           navigate from <CONTEXT> to <DATE> via lead selection
            lo_nd_date =
  wd_context->get_child_node( name = wd_this->wdctx_date ).

*           get element via lead selection
            lo_el_date = lo_nd_date->get_element( ).
*           @TODO handle not set lead selection
            IF lo_el_date IS INITIAL.
            ENDIF.

*           get all declared attributes
            lo_el_date->get_static_attributes(
              IMPORTING
                static_attributes = ls_date ).

          IF ls_date-begda < '20140101'.


            "rais error message

*             get message manager
            DATA lo_api_controller     TYPE REF TO if_wd_controller.
            DATA lo_message_manager    TYPE REF TO if_wd_message_manager.

            lo_api_controller ?= wd_this->wd_get_api( ).

            CALL METHOD lo_api_controller->get_message_manager
              RECEIVING
                message_manager = lo_message_manager
                .
           
            data lv_text TYPE string.
            lv_text = 'Start date should be after 01.01.2014'.
           
*             report message
            CALL METHOD lo_message_manager->report_attribute_error_message
              EXPORTING
                message_text              = lv_text
                element                   = lo_el_date
                attribute_name            = 'BEGDA'
                .

          ENDIF.

        ENDIF.
    ENDCASE.
  ENDIF.

Note: above code performs additional check on BEGDA

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi Abhay

If ls_node_selection-status is NOT INITIAL.

    lo_el_node_selection->get_attribute(

                 Exporting

                   name = 'division'

                  IMPORTING

                    value  = lt_division ).

If lt_division is INITIAL

message 'please provide input'

Elseif

Read itab into wa where division = lt_division.(itab- where data of division resides)

if sy-subrc = 0.

elseif

message ' please provide correct data'.

endif

thanks

Vamsi

Former Member
0 Kudos

Hi,

This code provided by you ..this also I have to write in" WDDOBEFORE ACTION "method?

becoz it is not working

Thanks

Abhay.

ramakrishnappa
Active Contributor
0 Kudos

Yes, always validation logic goes in WDDOBEFOREACTION ( ).

Former Member
0 Kudos

Hi Ramakrishnappa Gangappa,

In my Webdynpro which created based on one GUI existing report in that input screen parameter I am able to select multiple input for the input field but in webbui in Webdynpro in that I am not able to select multiple field together how to do that?..please refer the screen shot..

Thanks

Abhay Manna.

TudorRiscutia
Active Participant
0 Kudos

Hello Abhay,

     For that, you'll have to make use of the functionality of the standard WDR_SELECT_OPTIONS component. You can find plenty tutorials about this on Google.

Tudor

ramakrishnappa
Active Contributor
0 Kudos

Hi Abhay,

Hope you are using method ADD_SELECTION_FIELD( ) of IF_WD_SELECT_OPTIONS.

Make sure that the value of parameter I_NO_EXTENSION is set to ABAP_FALSE

Example:


wd_this->m_sel_options->add_selection_field(

  EXPORTING

    i_id                         = 'VBELN'

    it_result                    = LT_vbeln    " Reference to Range Table

    i_no_extension               = ABAP_FALSE    " No Multiple Selection

).

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Thanks for your reply actually I am pulling the program which is already  in the GUI, in to the  Webdynpro.In that Webdynpro screen In Input parameter screen I want to select multiple input parameter..how to do that..

bellow is my code which I written in method ONACTIONONCLICK .

Thanks

Abhay Manna.

    data : lt_params type table of rsparams,

              ls_params type rsparams.

DATA: int TYPE i,

      rspar TYPE TABLE OF rsparams,

      wa_rspar LIKE LINE OF rspar.



     clear ls_params.

       ls_params-selname = 'P_DIV'."ls_nam_val-name.

         ls_params-kind = 'P'.

          ls_params-low = gs_select-division.

         append ls_params to lt_params.



         clear ls_params.



         ls_params-selname = 'S_DATES'.

     if gs_select-POSTING_DATE  is NOT INITIAL and gs_select-POSTING_DATE1 is NOT INITIAL.

         ls_params-kind = 'S'.

          ls_params-sign = 'I'.

         ls_params-option = 'BT'.

         ls_params-low = gs_select-POSTING_DATE .

           ls_params-high = gs_select-POSTING_DATE1.

      " ls_params-high = '20140922'."wd_comp_controller->s_Edate.

         append ls_params to lt_params.

    else.

             ls_params-selname = 'S_DATES'.

         ls_params-kind = 'P'.

         ls_params-low = gs_select-POSTING_DATE .

         append ls_params to lt_params.





    endif.

     clear ls_params.

          ls_params-selname = 'P_PTYPE'.

         ls_params-kind = 'P'.

         ls_params-low = gs_select-PROCESS_TYPE .

         append ls_params to lt_params.



     clear ls_params.

          ls_params-selname = 'P_SALORG'.

          if gs_select-SALES_ORG  is NOT INITIAL  and gs_select-SALES_ORG1 is NOT INITIAL.

             ls_params-kind = 'S'.

          ls_params-sign = 'I'.

         ls_params-option = 'BT'.

         ls_params-low = gs_select-SALES_ORG .

         ls_params-high = gs_select-SALES_ORG1 .

         append ls_params to lt_params.

else.

           ls_params-kind = 'P'.

         ls_params-low = gs_select-SALES_ORG .

         append ls_params to lt_params.

    endif.

         clear ls_params.



          ls_params-selname = 'P_SOFF'.

          if gs_select-SALES_OFFICE  is NOT INITIAL and gs_select-SALES_OFFICE1 is NOT INITIAL.

             ls_params-kind = 'S'.

          ls_params-sign = 'I'.

         ls_params-option = 'BT'.

         ls_params-low = gs_select-SALES_OFFICE .

         ls_params-low = gs_select-SALES_OFFICE1 .

         append ls_params to lt_params.

  else.

               ls_params-kind = 'P'.

         ls_params-low = gs_select-SALES_OFFICE .

         append ls_params to lt_params.





  endif.

       submit zcsmr039 with selection-table lt_params

       exporting list to memory and return .

*            submit zcsmr039 VIA SELECTION-SCREEN

*             WITH SELECTION-TABLE rspar

*                      AND RETURN.



                   call function 'LIST_FROM_MEMORY'

         tables

           listobject = lobj

         exceptions

           not_found  = 4

           others     = 8.



       call function 'LIST_TO_ASCI'

         exporting

           list_index         = -1

         tables

           listasci           = olist

           listobject         = lobj

         exceptions

           empty_list         = 1

           list_index_invalid = 2

           others             = 3.

Former Member
0 Kudos

Hi,

Waiting for some positive answer. Please advice me how to do that...

Thanks

Abhay Manna

ramakrishnappa
Active Contributor
0 Kudos

Hi Abhay,

I think, I am still not getting your requirement clearly.

As per your code given, you are trying to execute the abap program with some selection parameters and get the output from memory.

Also, from your earlier screenshots, I can make out that, you are trying build the selection screen in WDA same as abap program.

i.e. Build the selection screen in Web dynpro and pass the same parameters to abap program & finally get the data from memory.

Now, are you looking for a selection screen with multiple option in WDA?

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Yes you are absolutely got my requirement....in WDA I have got the selection screen as I have given the screenshot...but in that I am not getting that arrow mark for selecting the multiple selection..i have indicated in screen shot...

Thanks

Abhay Manna.

ramakrishnappa
Active Contributor
0 Kudos

Okay,

Hope you have developed the selection screen by using methods ADD_SELECTION_FIELD.

Then, please pass the parameter i_no_extension = abap_false.

Example:

wd_this->m_sel_options->add_selection_field(

  EXPORTING

    i_id                         = 'VBELN'

    it_result                    = LT_vbeln    " Reference to Range Table

    i_no_extension               = ABAP_FALSE    " No Multiple Selection

).

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Can you please share your mail id with me? so that I can give you all the details...

Thanks

Abhay Manna.

Former Member
0 Kudos

Hi Rama,

Thank you very much,As per your guidance . my problem solved now I am able to select the multiple data.

But can i create variant in Webdynpro.as like ALV report we used to create variant. and save the input parameter. is it possible to create variant in Webdynpro. if yes please share your knowledge.

Thanks

Abhay Manna

ramakrishnappa
Active Contributor
0 Kudos

Hi Abhay,

By default, there is no standard functionality of variant in WDA selection screen / application but we can create variants by using our custom logic.

Hope following link might be helpful for you.

Variant with Web dynpro application ( Save or Read ) - Code Gallery - SCN Wiki

Regards,

Rama

Former Member
0 Kudos

hi Rama,

I am trying with your given link..

but it is showing Error "Type(ELEMENT_VARIANT) IS UNKNOWN"

DO YOU HAVE IDEA ABOUT THIS ERROR.

Thanks

Abhay Manna.


Former Member
0 Kudos

As I have already declare

data: ls_variant1 type wd_this->element_variant.

sill on this same line error is coming.. please help!

Former Member
0 Kudos

Hi Rama.

I was trying to create variant in Webdynpro. by referring your link what ever you given

But in method WDDOMODIFYVIEW  I have declare

DATA :  ls_variant_table    TYPE wd_this->element_variant_table.

but in that line it is showing an error

that is TYPE "ELEMENT_VARIANT_TABLE" is unknown.

could you please give me advice how to remove this error.

Thanks

Abhay Manna

ramakrishnappa
Active Contributor
0 Kudos

Hi Abhay,

It is refering the context node VARIANT_TABALE.

So,create a context node VARIANT_TABLE,

Former Member
0 Kudos

Hi Rama, Hope you are doing well. I have created the variant after long try. thank for your guidance. Now I have one problem with the field length,in Webdynpro last column as per my screen shot is not giving the full length even though in structure I have created the field with 30 character but its not taking more than 10 character, but  same report in GUI coming proper can you give me some advise how to resolve this?? please find the attachment Thanks Abhay

ramakrishnappa
Active Contributor
0 Kudos

Hi Abhay,

It seems that you have set the width for the column, so its not visible in the output. Try to adjust the width or don't set the width.

if you have not set the width, check by debugging whether the data of last column is filled completely.

Regards,

Rama

Former Member
0 Kudos

H

Former Member
0 Kudos

Hi, I have check in debugger,there field is completely filling, but when it is displaying it is not showing full. what would be the reason I am not getting it?? please share your knowledge.. Thanks Abhay

Former Member
0 Kudos

hi, Please tell me where I have to set the width for column..?? Thanks Abhay

ramakrishnappa
Active Contributor
0 Kudos

Hope you are displaying data in alv.

Check if the width of column is set some where in the configuration of alv. may in WDDONIT

Former Member
0 Kudos

Hi, I have checked it is not set any where... ??? This is my code.. DATA LO_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE.   LO_CMP_USAGE =  WD_THIS->WD_CPUSE_ALV_TEST( ).   IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.     LO_CMP_USAGE->CREATE_COMPONENT( ).   ENDIF.   "Create an instance of ALV Interface Controller   DATA LO_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .   LO_INTERFACECONTROLLER =  WD_THIS->WD_CPIFC_ALV_TEST( ).   "Configuration of the ALV Output   DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.   LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(  ).   DATA LR_COLUMN_SETTINGS TYPE REF TO IF_SALV_WD_COLUMN_SETTINGS.   DATA LT_COLUMNS        TYPE SALV_WD_T_COLUMN_REF.   DATA LS_COLUMNS        LIKE LINE OF LT_COLUMNS.   DATA:LS_COLUMN_HEADER    TYPE REF TO CL_SALV_WD_COLUMN_HEADER .   DATA LS_COLUMN TYPE REF TO CL_SALV_WD_COLUMN.   LR_COLUMN_SETTINGS ?= LV_VALUE.   LT_COLUMNS          = LR_COLUMN_SETTINGS->GET_COLUMNS( ).   LOOP AT LT_COLUMNS INTO LS_COLUMNS.     LS_COLUMN_HEADER = LS_COLUMNS-R_COLUMN->GET_HEADER( )  .     LS_COLUMN_HEADER->SET_DDIC_BINDING_FIELD( IF_SALV_WD_C_COLUMN_SETTINGS=>DDIC_BIND_NONE ).     CASE LS_COLUMNS-ID.       WHEN 'LEADID'.         LS_COLUMN_HEADER->SET_TEXT( 'Lead Id' ).       WHEN 'DESC'.         LS_COLUMN_HEADER->SET_TEXT( 'Description' ).       WHEN 'PRSPT_NAME'.         LS_COLUMN_HEADER->SET_TEXT( 'Prospect Name' ).       WHEN 'PRSPT_PHONE'.         LS_COLUMN_HEADER->SET_TEXT( 'Mobile Phone' ).       WHEN 'GNDR'.         LS_COLUMN_HEADER->SET_TEXT( 'Gender' ).       WHEN 'MRTLST'.         LS_COLUMN_HEADER->SET_TEXT( 'Mar. Status' ).       WHEN 'POW'.         LS_COLUMN_HEADER->SET_TEXT( 'Place Of Work' ).       WHEN 'AGEGRP'.         LS_COLUMN_HEADER->SET_TEXT( 'Age Group' ).       WHEN 'INCMGRP'.         LS_COLUMN_HEADER->SET_TEXT( 'Income Group' ).       WHEN 'EMAIL'.         LS_COLUMN_HEADER->SET_TEXT( 'Email Address' ).       WHEN 'FLTSIZCOM'.         LS_COLUMN_HEADER->SET_TEXT( 'Fleet Cmrcl' ).       WHEN 'FLTSIZPER'.         LS_COLUMN_HEADER->SET_TEXT( 'Fleet Pers' ).       WHEN 'INDUSTRY'.         LS_COLUMN_HEADER->SET_TEXT( 'Industry' ).       WHEN 'STARTDATE'.         LS_COLUMN_HEADER->SET_TEXT( 'Start Date' ).       WHEN 'ENDDATE'.         LS_COLUMN_HEADER->SET_TEXT( 'End Date' ).       WHEN 'QUAL_TXT'.         LS_COLUMN_HEADER->SET_TEXT( 'Qualification' ).       WHEN 'SALES_EMP'.         LS_COLUMN_HEADER->SET_TEXT( 'Sales Employee' ).       WHEN 'SALOF'.         LS_COLUMN_HEADER->SET_TEXT( 'Sales Office' ).       WHEN 'PROD_DESC'.         LS_COLUMN_HEADER->SET_TEXT( 'Product' ).       WHEN 'LEAD_CMNT'.         LS_COLUMN_HEADER->SET_TEXT( 'Lead Comments' ).       WHEN 'SOURCE'.                              "SOURCE Removed by Abhay         LS_COLUMN_HEADER->SET_TEXT( 'Origin' ).     ENDCASE.     endloop.

ramakrishnappa
Active Contributor
0 Kudos

Is alv table width set ?

Try to re-size the width of column in your screen and check if you can see missing data.

You can also try the below code to set the width of column and check if your data visible.

    

          WHEN 'SOURCE'.

               LS_COLUMNS-R_COLUMN->SET_WIDTH('20EX' ).

Former Member
0 Kudos

Hi, still it is not working? ??

ramakrishnappa
Active Contributor
0 Kudos

Okay, Thats weird....

Are you able to see the changes to width of column "Source" in out put?

If width changes occurred and still data is missing, then data is not completed populated into internal table.

Former Member
0 Kudos

Hi, No I cant see the changes.. ?? length is showing only 10 character..

ramakrishnappa
Active Contributor
0 Kudos

Please share the snap shot of context attribute 'SOURCE' properties from context node.

Former Member
0 Kudos

Hi, Please find the attachment! Thank You.

ramakrishnappa
Active Contributor
0 Kudos

Hello Abhay,

The type of SOURCE is CHAR10 .... please change it. So your data is truncated.

Former Member
0 Kudos

Hi, Thank you very much problem solved. Thanks Abhay

Answers (1)

Answers (1)

TudorRiscutia
Active Participant
0 Kudos

Btw, this is a really good article: