cancel
Showing results for 
Search instead for 
Did you mean: 

Trapping error in webdynpro when calling a function

Former Member
0 Kudos

Hi all,

I am using Adobe interactive forms and within the onsubmitevent I have webdynpro code which calls a standard function 'FMFR_CREATE_FROM_DATA' to do commitments. See code snippet below. The problem is when there is an error from the function the function simply hangs and does not come out of it.. I have tested this function as standalone via SE37 and works perfectly and also from a normal ABAP program the error can be trapped. Is it possible to trap this within webdynpro?

CALL FUNCTION 'FMFR_CREATE_FROM_DATA'

  • EXPORTING

  • I_FLG_CHECKONLY = ' '

  • I_FLG_COMMIT = 'X'

TABLES

T_POSDATA = wa_fid_tab

CHANGING

C_F_HEADDATA = wa_fih

  • EXCEPTIONS

  • DOCTYPE_NOT_ALLOWED = 1

  • ERROR_OCCURED = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

RAISE EXCEPTION TYPE ZCX_NO_CC_BUDGET.

ELSE.

" Update RFP table with consolidated amount

" per CC/PC and commitment no.

UPDATE ZAD_RFP_T

SET CURRENCY_AMOUNT = RFP_TOTAL1

AMOUNT = RFP_TOTAL1

COMMITMENT_NO = wa_fih-belnr

WHERE DOCUMENT_ID = RFP_ID

AND LINE_ID = line_one .

ENDIF.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

WebDynpro has a mesaage manager interface if_wd_message_manager. You can use one of the methods like report_t100_message instead of raising ZCX_NO_CC_BUDGET.

Former Member
0 Kudos

Thanks for th info but the problem seems to be that the process never returns from the call. We can use REPORT_T100_MESSAGE for reporting the error but I need something to check after the call to the function to see if the function was succesful or not, unfortunately the function just hangs. I've tried to debug the function to find out where it hangs (in order to give me some clues) but you have to go very deep into it. I give up after going 6 levels down.

I'm being hopeful but there must surely be a way of testing the result from a standard function call within webdynpro!!!

saravanan_narayanan
Active Contributor
0 Kudos

Try uncommenting the following lines


* EXCEPTIONS
* DOCTYPE_NOT_ALLOWED = 1
* ERROR_OCCURED = 2
* OTHERS = 3

you need to catch the exception raised by the FM and then in the " IF SY_SUBRC" block you need to convert the same to webdynpro message using MESSAGE MANAGER.

BR, Saravanan

Former Member
0 Kudos

Catch Exception in your code and then call message manager as above said

Former Member
0 Kudos

Thanks guys but i already tried this ie. uncommenting the exception but it never returns to the next line ie to theIF SY-SUBRC line in the code snippet below. The program simply hangs!!!

CALL FUNCTION 'FMFR_CREATE_FROM_DATA'

  • EXPORTING

  • I_FLG_CHECKONLY = ' '

  • I_FLG_COMMIT = 'X'

TABLES

T_POSDATA = wa_fid_tab

CHANGING

C_F_HEADDATA = wa_fih

EXCEPTIONS

DOCTYPE_NOT_ALLOWED = 1

ERROR_OCCURED = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

RAISE EXCEPTION TYPE ZCX_NO_CC_BUDGET.

ELSE.

" Update RFP table with consolidated amount

" per CC/PC and commitment no. -

UPDATE ZAD_RFP_T

SET CURRENCY_AMOUNT = RFP_TOTAL1

AMOUNT = RFP_TOTAL1

COMMITMENT_NO = wa_fih-belnr

WHERE DOCUMENT_ID = RFP_ID

AND LINE_ID = line_one .

ENDIF.

Former Member
0 Kudos

Hi,

then check the FM if it calls any dynpro screens. In that case the webdynpro session would have been terminated in between.

Former Member
0 Kudos

Please check in this function module that it is not calling any SAP standard transaction

Former Member
0 Kudos

Okay, Found the solution on another thread. Do the following:-

Just disable all exceptions in the function module in the source code and add the generic statement "error_message = 1".

Ofcourse you now need to handle messages after execution of the function module - messages will not be shown on screen anymore,

So the code should look like this:

CALL FUNCTION 'FMFR_CREATE_FROM_DATA'

EXPORTING

i_flg_checkonly = space

i_flg_commit = 'X'

TABLES

t_posdata = pr_posdata

CHANGING

c_f_headdata = pr_head_data

EXCEPTIONS

  • doctype_not_allowed = 1

  • error_occured = 2

  • OTHERS = 3.

error_message = 1.

The above did the trick for me. I could now go on to check for sy-subrc and look at the system messages.

Thanks all for your time.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

RAISE EXCEPTION TYPE ZCX_NO_CC_BUDGET.