Skip to Content
avatar image
Former Member

beginner question: how to add exceptions webdynpro method

Hi,

I've followed some tutorials and now created a webdynpro application that gets the carriername form the carrier-id.

It works good.

Now i want to add a message when no carriername is found. I've added a field on my view to receive the message and i've added the lines to the assist method, but i'm struggling to get it from there to the field.

  • My view is called MAIN.

In the layout it has an inputfield for carrier ID, a button to search, an outputfield for the carrier name, and an output for the message.

  • The context is a node zz_carrier (carrid, carrname, and url) and an attribute: message

  • The button Search triggers the method:

method ONACTIONSEARCH_AIRL_NAME .

   DATA lo_nd_zz_carrier TYPE REF TO if_wd_context_node.

   DATA lo_el_zz_carrier TYPE REF TO if_wd_context_element.

   DATA ls_zz_carrier    TYPE wd_this->element_zz_carrier.

   DATA lv_id            LIKE ls_zz_carrier-carrid.

   DATA lv_name          LIKE ls_zz_carrier-carrname.

* navigate from <CONTEXT> to <ZZ_CARRIER> via lead selection

   lo_nd_zz_carrier = wd_context->get_child_node( name = wd_this->wdctx_zz_carrier ).

   lo_el_zz_carrier = lo_nd_zz_carrier->get_element( ).

* get single attribute

* first determine the carrier id from the value we fill on screen.

   lo_el_zz_carrier->get_attribute(

     EXPORTING

       name = 'CARRID'

     IMPORTING

       value = lv_id  ).

* then use the assistance class method to get the carrier name

   wd_assist->GET_CARRIERNAME(

     EXPORTING

       CARR_ID = lv_id

     IMPORTING

       CARR_NAME = lv_name ).

* now export the carrier name to the view and will be shown in the output field

   lo_el_zz_carrier->Set_attribute(

     EXPORTING

       NAME = 'CARRNAME'

       value = lv_name

       ).

 

endmethod.

  • The assist class has the method GET_CARRIERNAME:

method GET_CARRIERNAME.

   SELECT SINGLE CARRNAME FROM SCARR

     INTO CARR_NAME

    WHERE CARRID = CARR_ID.

   IF CARR_NAME IS INITIAL.

     MESSAGE = 'NOTHING FOUND'.

   ENDIF.

  endmethod.

My question is what must i add to the method ONACTIONSEARCH_AIRL_NAME to pass my 'NOTHING FOUND' message from the assist class to the view?

I must declare it obviously but not sure how to declare an attribute from the context.

I must do a SET_ATTRIBUTE i think at the end but how to do that.

Thx for the input.

Regards

Robert

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Oct 28, 2013 at 03:14 PM

    Hi,

    In your ONACTIONSEARCH_AIRL_NAME method after the method call wd_assist->GET_CARRIERNAME ( )

    you can simply write

    if lv_name is initial.

       lo_el_zz_carrier->Set_attribute(

         EXPORTING

           NAME = 'MESSAGE'

           value = lv_name

           ).

    endif.


    I suggest you, instead of creating message field to display message, create a message area UI and use if_wd_message_manager to display WDA messages.

    Check this: message Handling in WDA

    Hope this helps u.,

    Regards,

    Kiran

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Kiran Kumar Valluru

      Hi Kiran,

      I now used the link you gave and put the messagearea in the view, and generated the code for the exception if nothing was found.

      That works nice enough and to me is good point to remember.

      Thx

      Robert