cancel
Showing results for 
Search instead for 
Did you mean: 

an odd problem when error handling

Former Member
0 Kudos

hi experts

I encountered a very odd problem when trying to show up an error message... and hope someone can help me out.

I defined a standard action in the view, and wrote some lines of code to check the input data in the predefined methodWDDOBEFOREACTIONwhich will call a method from component controller, and that method will call message_mananger->report_t100_message to show up an E type message if any error happened. But the problem is the program does not stop there but go into the action handler(ONACTIONACT_XXX).

I think it should actually stop and show up the message rather than get into the action handler because of the action is standar...

can anyone help?

many tkx

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

also have you checked in the debugging that its not going there.

i guess if action is from the same view it should go there.

thanks

sarbjeet

Former Member
0 Kudos

hi sarbjeet

the following is wddobeforeaction


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

  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 'ACT_EXC'.

        lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).

        lo_componentcontroller->execute_ikuseiplan_chk_mtd(
        ).

    ENDCASE.
  ENDIF.


ENDMETHOD.

and the following is a fraction of lo_componentcontroller->execute_ikuseiplan_chk_mtd


* the invocation - errors are always fatal !!!
  zpha_cl_ikuseiplan=>ikuseiplan_chk_mtd(
    CHANGING
       im_pginfo =                       wd_this->im_pginfo
    EXCEPTIONS
      basdate_error =                     1
      orgeh_error =                       2
      plans_error =                       3 ).
* error handling
  CASE sy-subrc.
    WHEN  1.
* report message
      CALL METHOD wd_this->message_mananger->report_t100_message
        EXPORTING
          msgid = 'ZPH0'
          msgno = '067'
          msgty = 'S'.

      EXIT.
    WHEN  2.
      
* report message
      CALL METHOD wd_this->message_mananger->report_t100_message
        EXPORTING
          msgid = 'ZPH0'
          msgno = '054'
          msgty = 'E'.


      EXIT.

gill367
Active Contributor
0 Kudos

thanks for pasting the code.

check the action name again.

also

put a breakpoint in the METHOD wddobeforeaction and debug to check whether the control is going there.

thanks

sarbjeet

Former Member
0 Kudos

hi sarbjeet

tkx for ur help

I checked the action name, its correct, and I set a break point in the wdbeforeaction, the control did stop there and called method message_mananger->report_t100_message, but then ended up with going into onaction_xxx......

gill367
Active Contributor
0 Kudos

use

Raise_T100_error

instead of

report_t100_message

it will cancel the navigation

thanks

sarbjeet

sahai
Contributor
0 Kudos

hi,

i went through your code.....the code is fine but as you told that it goes to the exception handler after coming to the message part ...this is because you are using

CALL METHOD LO_MESSAGE_MANAGER->REPORT_T100_MESSAGE

EXPORTING

MSGID =

MSGNO =

MSGTY =

  • P1 =

  • P2 =

  • P3 =

  • P4 =

  • MSG_USER_DATA =

  • IS_PERMANENT = ABAP_FALSE

  • SCOPE_PERMANENT_MSG = CO_MSG_SCOPE_CONTROLLER

  • VIEW =

  • SHOW_AS_POPUP =

  • CONTROLLER_PERMANENT_MSG =

  • MSG_INDEX =

  • CANCEL_NAVIGATION =

  • ENABLE_MESSAGE_NAVIGATION =

RECEIVING

MESSAGE_ID =

this function will simply report that message but will not hold the control to the same screen..

so use

CALL METHOD LO_MESSAGE_MANAGER->REPORT_FATAL_ERROR_MESSAGE......

and tell me whether it solved the problem or not....

@ sarbjeet i think that Raise_T100_error is an obselete function...rite?

thanks and regards,

sahai.s

.

gill367
Active Contributor
0 Kudos

Oh yeah sahai .thanks . i just checked its obselete..

but the problem here is he is reading the messages form message class

is it possible with the method that you are speciflying.

thanks

sarb

sahai
Contributor
0 Kudos

hi,

actualy there is no problem in the code the thing is that he is using simple message generator method which will be generated and any further action will be continued ....to stop this he must use fatal error exception which after being raised wont allow any further action to take place .....hence his problem will be solved... m waiting for him to say the same..hopefully it will work

thanks and regards,

sahai.s

gill367
Active Contributor
0 Kudos

Yeah that i understood sahai..

i am saying how we can read the message from the message class using this method.

is there any parameter for the same.

thanks

sarbjeet

Former Member
0 Kudos

hi sahai.s

tkx for ur help. and my apology goes for my legging reply.

I tried ur way, unfortunely it dumpped....lol...it looks very weird....

I have some questions , hope u can help out.

1. I initialized the message manager in the wddoinit( ) of component controller, is that fine?

2. when I tried to test the application, it will also go to the wddobeforeaction() before the page showed up, is it correct?

3. I went through NET310, it says that If the action type is standard) the following message types will cancel the navigation and prevent the processing of the action handler method and the hook method wddomofifyview( 😞

Fatal error messages.

Error messages related to context attributes.

it seems nothing to do with the method of report_T100_MESSAGE, so if I set the message type as 'E', the systme should cancel the navigation, but things is not acting this way now....

do hope u can help

thanks and regards

Former Member
0 Kudos

btw, the scenario of my case is that the user will input some query criteria, and download a file to local as soon as he click the excute button, and the page will get refreshed rather than navigated to another page.

thanks and regards

gill367
Active Contributor
0 Kudos

HI

try REPORT_ELEMENT_T100_MESSAGE method it will cancel the navigation.

use the following code.

pass any element to parameter lo_el_context.

data msge type symsg.
   msge-MSGID                     = 'zsarb'.
    msge-MSGNO                     = '000'.
    msge-MSGTY                     = 'E'.
* report message
CALL METHOD lo_message_manager->REPORT_ELEMENT_T100_MESSAGE
  EXPORTING
    MSG = msge
ELEMENT = lo_el_context.

hope it will solve your problem

thanks

sarbjeet

Former Member
0 Kudos

>

> btw, the scenario of my case is that the user will input some query criteria, and download a file to local as soon as he click the excute button, and the page will get refreshed rather than navigated to another page.

>

> thanks and regards

Hi,

please study the phase model [http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d2/8acd409cc4dd50e10000000a1550b0/frameset.htm|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d2/8acd409cc4dd50e10000000a1550b0/frameset.htm]

event handlers are not called only if it is pertaining to the user input. In your case you are reporting error which is probably not an user input validation error.

I guess, Sarbeet singh suggestion might work as you are reporting that the node element is error.

Former Member
0 Kudos

hi sahai.s

thx for ur help and also thx everyone.

just like what u said the fatal error exception can stop any further action and stop the navigation. it solves my problem.

but I went through the manual book which tells some other methods, for example REPORT_ATTRIBUTE_ERROR_MESSAGE ,REPORT_ATTRIBUTE_EXCEPTION,REPORT_ELEMENT_ERROR_MESSAGE, can also stop the further action ( usually the event handler) , but I tried them and they did not act like the manual book says....

could u please kindly explain?

thx and regards

sun

sahai
Contributor
0 Kudos

hi sun wanlei ,

REPORT_ATTRIBUTE_ERROR.........this error message is used when you have to validate that whether particular value has been supplied value or not...for example suppose if you have an input field and user leaves it blank...this will have a error message.....and wont allow any futher action till user fills it....

REPORT_ATTRIBUTE_EXCEPTION....is used to check whether user entered a valid value or not.....

regards,

sahai.s

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

can you paste the code you have written in the onbeforeaction method.

thanks

sarbjeet