‎2007 Oct 17 10:27 AM
Hi,
I am doing function module. In that i created import export and exceptions,and written the code in the source code. See the function module code below.
DATA : l_date TYPE sy-datum VALUE '18000101'.
IF date1+4(2) > '12'.
RAISE ex_month.
ELSEIF date1+6(2) > '31'.
RAISE ex_day.
ENDIF.
IF date2+4(2) > '12'.
RAISE ex_month.
ELSEIF date2+6(2) > '31'.
RAISE ex_day.
ENDIF.
no_days = abs( date1 - date2 ).and called the function in the editor. see the code below.
data : no_days type i.
parameters: date1 type dats,
date2 type dats.
call function 'Z50803_SD_FUNC_DAYSBTTWODATES1'
exporting
date1 = date1
date2 = date2
importing
no_days = no_days
exceptions
dat = 1
mon = 2
day = 3
others = 4.
if sy-subrc <> 0.
case sy-subrc.
when 1.
write:/ 'please enter valid date'.
when 2.
write:/ 'Please enter valid month'.
when 3.
write:/ ' Please enter valid day'.
endcase.
else.
write:/ 'NO OF DAYS:', no_days.
endif.
.
My question is exceptions is not trigger in the output and in the selection screen the date farmat is (yyyy.mm.dd). If i enter the date any format i want to display the output.
plese help me ASAP.
Regards
Srinu
‎2007 Oct 17 10:30 AM
‎2007 Oct 17 10:32 AM
Hi,
The date data type should alwyz be fixed.
Else use FM 'CONVERT_DATE_TO_INTERNAL' or 'CONVERT_DATE_TO_EXTERNAL' for changing the format.
Best regards,
Prashant
‎2007 Oct 17 10:33 AM
DATA: var_dt(10) TYPE c.
CALL FUNCTION 'RP_FORMATING_DATE'
EXPORTING
date_i = var_dt
birth_date = 'X'
IMPORTING
date_o = gv_convtddate.
EXCEPTIONS
DATE_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.
CONCATENATE gv_convtddate6(2) gv_convtddate4(2) gv_convtddate+0(4)
INTO date1 SEPARATED BY '.'
Message was edited by:
sagar kekare
‎2007 Oct 17 10:39 AM
hi,
you will have to convert the input which you give to yyyymmdd format,
hence you can use FM 'CONVERT_DATE_TO_INTERNAL'
regards,
ritika malhotra
‎2007 Oct 18 6:45 AM
hi,
for the date to be changed to the system format you can use the function module :
CONVERT_DATE_TO_INTERNAL.
this will help you.
regards,
sohi
‎2007 Oct 18 7:04 AM
hi ,
use the FM CONVERT_DATE_FORMAT to display the date in the ddmmyyyy format.
regards,
sandhya.