‎2011 Oct 21 6:05 AM
i am using the function module /SDF/CMO_DATETIME_DIFFERENCE to calculate the days between two dates.
i m getting the output. but what i want is if it does the receives blank as one value( from the two given dates) in exporting.........then it should show blank as diff days.(importing diff days).
my code is:
I_TAB-ERDAT
I_TAB-GP_DATE
I_TAB-BC_GP.............ALL THESE HAVE BEEN DECLARED IN I_TAB. AND THWY HAVE THEIR VALUES IN DATE FORMAT IN I)TAB.
CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = I_TAB-ERDAT
TIME1 =
DATE2 = I_TAB-GP_DATE
TIME2 =
IMPORTING
DATEDIFF = I_TAB-BC_GP
TIMEDIFF =
EARLIEST =
EXCEPTIONS
INVALID_DATETIME = 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.
DO WE HAVE ANY PROVISION IN THIS FM THAT IF THERE IS BLANK SOMEWHERE IN I_TAB-GP_DATE THEN IT SHOULD SHOW
I_TAB-BC_GP AS BLANK.
HOWEVER IT IS RECEIVING VALUE IN ANOTHER EXPORTING PARAMETER THAT IS I_TAB-ERDAT.
‎2011 Oct 21 6:46 AM
Hi,
Its a difference generator FM so def .. its gonna subtract the first date from the second one ..
Try using a if condition before it to check whether your field contains initial value or not ..
If I_TAB-ERDAT is initial or I_TAB-GP_DATE is initial.
I_TAB-BC_GP = 0.
else.
call the function module.
Hope this will surely help you !!!
Regards,
Punit
‎2011 Oct 21 6:46 AM
Hi,
Its a difference generator FM so def .. its gonna subtract the first date from the second one ..
Try using a if condition before it to check whether your field contains initial value or not ..
If I_TAB-ERDAT is initial or I_TAB-GP_DATE is initial.
I_TAB-BC_GP = 0.
else.
call the function module.
Hope this will surely help you !!!
Regards,
Punit
‎2011 Oct 22 6:45 AM
dude if i declare i_tab-bc_gp = 0. then i will get i_tab-bc_gp field value as 0. man..m already getting this value.
what i want is a BLANK space whenever it finds null at any of two exporting parameters.
i_tab-bc_gp = "". is not working..showing an error. suggest something to recitify this
‎2011 Oct 24 5:51 AM
Hi,
now for any numeric field like integer, decimal the default value is always 0 whether it contains data or not.
So for display purpose you have put this value in a character field and display that field in place of the numeric one.
now for eg.
while displaying
use
write i_tab-bc_gp to <char_field>
and display that <char_field>
Hope this will resolve !!!
Regards,
Punit
‎2011 Oct 22 6:55 AM
Hi abhishek1345 ,
"Why don't you copy function module /SDF/LCMO_COMP_REPOSTOP to Z/SDF/LCMO_COMP_REPOSTOP
Change logic in " perform datetime_difference
using date1 time1 date2 time2
datediff timediff earliest. " From function module
as per your requirment .
That would be better or
Copy code from function module and change as per your requirment .
regards
Deepak.
<Removed code tags>
Edited by: Suhas Saha on Oct 24, 2011 10:36 AM