05-22-2009 11:56 AM
Hi experts,
I would like to implement a ABAP routine BW. This routine will check the format of the date, if they are not "YYYYMMDD", the routine will set empty for this zone. As I am not good at ABAP, is there any informatioin about this ABAP code?
Thanks very much in advance.
05-22-2009 12:45 PM
Hi david,
This is a typical code to fullfil your requirement;
data input_date type d. " This you should be passing to the routine
data temp_date type d.
input_date = '20090522'. " 22 may 2009
temp_date = input_date - 1.
temp_Date = temp_date + 1.
IF temp_date NE input_date.
"Wrong Format set date to empty
clear input_Date.
ENDIF.
Here i have given 20090522 which is in YYYYMMDD, if i give in wrong format the above code will empty the input date. If you have any queries revert back.
Regards
Karthik D
05-22-2009 12:16 PM
Hi experts,
I would like to implement a ABAP routine BW. This routine will check the format of the date, if they are not "YYYYMMDD", the routine will set empty for this zone. As I am not good at ABAP, is there any informatioin about this ABAP code?
Thanks very much in advance.
Hi,
The SAP default date format is YYYYMMDD. I hope your date format which you are going to pass like DDMMYYYY. For that, the DDMMYYYY date format you can use the concatenate statement to make it as SAP date format like YYYYMMDD. Find the below example.
DATA : V_DATE LIKE SY-DATUM.
DATA : V_SAP_DATE LIKE SY-DATUM.
DATA : LV_DATE(2) TYPE N,
LV_MONTH(2) TYPE N,
LV_YEAR(4) TYPE N.
V_DATE = SY-DATUM.
LV_DATE = V_DATE+6(2).
LV_MONTH = V_DATE+4(2).
LV_YEAR = V_DATE+0(4).
CONCATENATE LV_YEAR LV_MONTH LV_DATE INTO V_SAP_DATE.
Regards
Thiru
05-22-2009 12:45 PM
Hi david,
This is a typical code to fullfil your requirement;
data input_date type d. " This you should be passing to the routine
data temp_date type d.
input_date = '20090522'. " 22 may 2009
temp_date = input_date - 1.
temp_Date = temp_date + 1.
IF temp_date NE input_date.
"Wrong Format set date to empty
clear input_Date.
ENDIF.
Here i have given 20090522 which is in YYYYMMDD, if i give in wrong format the above code will empty the input date. If you have any queries revert back.
Regards
Karthik D