09-27-2013 4:01 AM
Hello
Do we have any function, wherein the import params are
1) DATE_IN, (Example: MM/DD/YYYY )
2) DATE_FORMAT_IN, (Example: 2)
3) DATE_FORMAT_OUT, (Example:1 )
and the Export params are,
1) DATE_OUT (Example: DD.MM.YYYY)
2) DATE_AS_PER_INTERNAL_FORMATE (Example: YYYYMMDD)
if we don't have any straight forward single function. 2 step process also fine
I searched in SE37 by using wild cards like, *DATE*CONVERT* and *DATE*FORMAT*, but no success
Thank you
09-27-2013 4:29 AM
09-27-2013 4:38 AM
Hi MSR
You can try like this
* Using the WRITE statement
***************************
data: gd_date(10). "field to store output date
* Converts SAP date from 20020901 to 01.09.2002
write sy-datum to gd_date dd/mm/yyyy.
* Converts SAP date from 20020901 to 01.09.02
write sy-datum to gd_date dd/mm/yy.
* Using data manipulation techniques
************************************
data: gd_date(8). "field to store output date
* Converts SAP date from 20010901 to 01092001
gd_date(2) = sy-datum+6(2).
gd_date+2(2) = sy-datum+4(2).
gd_date+4(4) = sy-datum(4).
* Using Function modules
************************
data: gd_date(8). "field to store output date
* Converts date from 20010901 to 01SEP2001
gd_date = sy-datum.
CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
EXPORTING
input = gd_date
IMPORTING
OUTPUT = gd_date.
09-27-2013 4:47 AM
Dear MSR,
One small concept you need to learn. Rest of all Example you can do by yourself.
Let my LV_date is type dats(Char8). And input is coming like yyyymmdd.
Now make a lv_date_new type string which will keep modified date.
lv_year type char4.
lv_month type char2.
lv_day type char2.
lv_day = lv_date+6(2).
In the statement we are fetching data from lv_date start with 6th character and next 2 character.means we will start from M to DD. so now lv_day will carry DD. so now you can fetch month lv_date+4(2) and year lv_date+0(4) with same concept.
now concatenate your all data day month year separated by . or / or -
BR
ChanS
09-27-2013 4:57 AM
Hi MSR,
We can output the date in our own requirement .Here to go,
DATA: a(8) TYPE c, b(10) TYPE c.
a = sy-datum or p_date.-------------- or ur input parameter (p_date)
CONCATENATE a+6(2) '/' a+4(2) '/' a+0(4) INTO b. ----_DD/MM/YYYY
CONCATENATE a+6(2) '.' a+4(2) '.' a+0(4) INTO b.-------------DD.MM.YYYYY
CONCATENATE a+6(2) '-' a+4(2) '-' a+0(4) INTO b. -----------DD-MM-YYYY
write b.
Cheers
regards
Syed
09-27-2013 5:30 AM
Hi MSR,
Please find below useful code .
data : date_out type char10.
write date_in to date_out.
With Regards,
Ram.
09-27-2013 5:37 AM
Hi,
Use the FM 'HR_IN_GET_DATE_COMPONENTS' and concatenate as per the requirement, use any separator ( . - /)
CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'
EXPORTING
idate = date "use sy-datum directly here
IMPORTING
DAY = dd "day
MONTH = mm " month
YEAR = yy" year.
CONCATENATE dd mm yy into txt SEPARATED BY '-'.
Regards,
Jeffin
09-27-2013 5:46 AM
Hi,
Goto a report program press on pattern button type string like given below.
Take your desired format you need.
Regards,
Alenlee MJ
09-27-2013 6:04 AM
Hi,
Pleas try this FM. All you need to know is the diffeent formats of date. You can program it accordingly.
Links for different formats use the link provided by Maju.
PARAMETERS l_dat TYPE NLEI-IBGDT.
data l_str Type RN1DATUM-DATEX.
call function 'FORMAT_DATE_4_OUTPUT'
exporting
datin = l_dat
format = 'YYYYMMDD'
importing
datex = l_str.
WRITE l_str.
Hope this helps.
Regards.
09-27-2013 6:13 AM