Skip to Content
0
Former Member
Oct 28, 2013 at 02:50 PM

beginner question: how to add exceptions webdynpro method

25 Views

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