on 03-28-2006 6:16 AM
Hi all,
I am using a flat file containing a date format DDMMYYYY when I wrongly give a date format For eg. YYYYMMDD instead of DDMMYYYY , my query is to :
-Throw a error message when it is a wrong format
Hi Paul,
You can use this FM to validate date format.
<b>DATE_CHECK_PLAUSIBILITY</b>
<b>CONVERT_DATE_TO_INTERNAL</b>
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
DATE = I_INPUT-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.
ENDIF.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = I_INPUT-DATE
IMPORTING
DATE_INTERNAL = WA_DATE
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 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.
ENDIF.
Hope this will help.
Regards,
Ferry Lianto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
If you r giving a wrong format than it wont accept that value because it will check with your flat file data.So give the write format as you have given in your flat file.
As per your question you should clarify that in which situation you want to throw a error message.Wheather you r using BDC or Something else.
Thanks
Mrutyunjaya Tripathy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi paul,
1. after uploading in internal table,
we can definitely loop and check.
2. but how will u check the format ?
3. CONVERT_DATE_TO_INTERN_FORMAT
use this FM.
3. pass DTYPE = 'DATS'. (in the parameter)
4. This FM will TAKE CARE OF
THE USERS SETTINGS
AND ACCORDINGLY CONVERT INTO PROPER FORMAT
(IE INTERNAL FORMAT OF YYYYMMDD)
<b>5 OR , u can simply use this FM (in the loop)
and detect whether the DATE is OK or not
, and appropriately give message to the user !</b>
regards,
amit m.
regards,
amit m.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think you can validate the file after you upload the file.
After uploading you can write a perform wherein you can check for the date format.If not in the reqd format move the record into an error internal table and display the app error message.
I have pasted a portion of my code:
Call the function module GUI_UPLOAD to upload the file from the presentation server.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gv_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = gt_lin
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
endform.
perform error_records_lina.
Form error_record_lina.
loop at gt_lina.
If date not in the reqd format.
append gt_error.
endloop.
endform.
Regards,
Gayathri
Message was edited by: Gayathri Hariharan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.