cancel
Showing results for 
Search instead for 
Did you mean: 

beginner question: how to add exceptions webdynpro method

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Kiran,

Thx for the reply.

I'll check the link you gave me.

Meantime i tried the code you gave me.

After putting that in I tested the application again but got an error:

"

  • Attribut MESSAGE konnte nicht gefunden werden. (couldnt be found)

and it is of type RABAX STATE, which in ST22 gives me:

"..... The exception 'CX_WD_CONTEXT' was raised, but it was not caught anywhere along

the call hierarchy.

 

Since exceptions represent error situations and this error was not

adequately responded to, the running ABAP program

  'CL_WDR_CONTEXT_NODE_INFO======CP' has to be

terminated......."

So something is missing i think in the code you gave me.

Further help is appreciated.

Regards

Robert

former_member184578
Active Contributor
0 Kudos

Hi,

In that message is the attribute ( according to your initial post) in which you want to show 'Nothing Found' message

   lo_el_zz_carrier->Set_attribute(

     EXPORTING

       NAME = 'MESSAGE'    " replace this with your attribute name which is binded to text to show message.

       value = lv_name

       ).

I think the attribute 'message' is not in node zz_carrier, it is outside the node rite? use code wizard to set the attribute.

Regards,

Kiran

Former Member
0 Kudos

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

Answers (0)