Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

exceptions

Former Member
0 Likes
668

hi,

i run FM 'CONVERT_DATE_TO_EXTERNAL' to test the exceptions but no matter what i pass in, even an invalid date i still not able to go in exceptions.

i actually would like to see what is these 1 and 2. thx

1) what is 1 and 2? are they sy-subrc? what if sy-subrc is 4?

2) what is this 'OTHERS' under the exceptions in the call function below?

3) why i simply enter an invalid date like '10022031' in yyyymmdd format, sy-subrc still 0?

in abap :

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

date_internal = p_date

IMPORTING

date_external = p_outdate

EXCEPTIONS

date_internal_is_invalid = 1

OTHERS = 2.

in FM :

CASE SY-SUBRC.

WHEN 0.

DATE_EXTERNAL = H_DATE_EXTERNAL.

WHEN OTHERS.

MESSAGE E650 RAISING DATE_INTERNAL_IS_INVALID.

  • Bitte gültiges internes Datum angeben (JJJJMMTT)

ENDCASE.

4 REPLIES 4
Read only

amit_khare
Active Contributor
0 Likes
566

whenever you use the FM, the exception numbers are actuallty the sy-subrc value.

You require to check the sy-subrc and display message accordingly.

Others is the default exception attach with all FM.

Since there are some uncounted errors may occur like OS failure to name.

Soeverytime u use a FM handle these sy-subrc or exceptions accordingly.

If sy-subrc is 0 means success.

Regards,

Amit

Read only

Former Member
0 Likes
566

After calling the FM , tr this..

IF SY-SUBRC <> 0.

  CALL FUNCTION 'TB_MESSAGE_BUILD_TEXT'
       EXPORTING
            LANGU = SY-LANGU
            MSGID = SY_MSGID
            MSGNO = SY_MSGNO
            MSGV1 = SY_MSGV1
            MSGV2 = SY_MSGV2
            MSGV3 = SY_MSGV3
            MSGV4 = SY_MSGV4
       IMPORTING
            TEXT  = P_L_ERR_MSG.   "  declare this variable of length 100

  write : P_L_ERR_MSG..
ENDIF.

Read only

Former Member
Read only

Former Member
0 Likes
566

hi,

1) in the FM, only 1 and 2, what if it returns other than 1 and 2? why OTHERS is 2? which means only can cater for 1 and 2 sy-subrc? what if other number then how to take care? or by this way, can restrict system to return only 1 and 2? i know when alright will return 0.

2) why need to call 'tb_message_build_text'?

3) i just do not understand why 'CONVERT_DATE_TO_EXTERNAL' also can return 0 for sy-subrc even i input letter.

please advise again.

thanks