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

Date validations

Former Member
0 Likes
811

Hi,

I want to validate the date in the flat file on the presentation server. I am using the FM CHECK_DATE_PLAUSIBILITY. It is checking correctly. And i want to catch the exception in a local varible. How it will be. Can anybody provide me the coding.

Thanks.....

6 REPLIES 6
Read only

Former Member
0 Likes
729

hi,

for catching exceptions Check this one

call function 'ITS_DOWNLOAD'

EXPORTING

bin_filesize = bin_filesize

filename = tempfile

filetype = typ

mode = mode

wk1_t_format = wk1_t_format

wk1_n_format = wk1_n_format

IMPORTING

filelength = filelength

TABLES

data_tab = data_tab

EXCEPTIONS

file_write_error = 1

gui_refuse_filetransfer = 2

others = 3.

if sy-subrc = 1.

raise file_write_error.

elseif sy-subrc = 2.

raise unknown_error.

elseif sy-subrc = 3.

raise unknown_error.

endif.

exit.

endif.

hope this helps.

PLZ reward if helpful.

Read only

Former Member
0 Likes
729

hi Anil,

After calling FM pass the value to a local variable

PARAMETER P_DATE TYPE SYDATUM.
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = P_DATE
EXCEPTIONS
PLAUSIBILITY_CHECK_FAILED = 1
OTHERS = 2.

[code]v_subrc = sy-subrc.

if v_subrc = '1'.

write : 'PLAUSIBILITY_CHECK_FAILED'.
elseif  v_subrc = '2'.
write : 'OTHERS'.

endif

Read only

Former Member
0 Likes
729

Hi

U can write the message in a string:

DATA: _DATE LIKE SY-DATUM,
      _MESSAGE(100) TYPE C.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
     EXPORTING
          DATE                      = _DATE
     EXCEPTIONS
          PLAUSIBILITY_CHECK_FAILED = 1
          OTHERS                    = 2.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 INTO _MESSAGE.
ENDIF.

Max

Read only

Former Member
0 Likes
729

Hi Anil ,

All you need to do is assign the value of sy-subrc to your local varaible soon after the function is called i.e.next statement after function call must be some thing like this

V_TEMP = SY-SUBRC.

Regards

Arun

Read only

Former Member
0 Likes
729

hi anil,

data: l_subrc type c,

date type sy-datum.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

date = DATE

EXCEPTIONS

PLAUSIBILITY_CHECK_FAILED = 1

OTHERS = 2.

l_subrc = sy-subrc.

if l_subrc = '1'.

write : 'PLAUSIBILITY_CHECK_FAILED'.

elseif l_subrc = '2'.

write : 'OTHERS'.

elseif l_subrc = '0'.

write \ correct date.

endif

Read only

Former Member
0 Likes
729
REPORT ychatest LINE-COUNT 50.

DATA : v_date LIKE sy-datum,
       text TYPE string.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
  EXPORTING
    date                      = v_date
  EXCEPTIONS
    plausibility_check_failed = 1
    OTHERS                    = 2.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  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  = text.        "  Text will contain the error message

ENDIF.

Try to reward points and close the threads if the answers are helpful

Message was edited by:

Chandrasekhar Jagarlamudi