‎2005 Nov 22 12:55 PM
Hi Guys,
I have to find out format of a date field which is stored in a field symobl.
assume <f1> = 11/11/2005.
I need to whether it is in MM/dd/yyyy or dd/mm/yy...like that.
After i need to convert this to a YYYYMMDD format...
Do i have any functionModules or logic exist for this.
Earliest response is appreciated.
Thanks in advance.
Raja.
Message was edited by: raja gurrala
‎2005 Nov 22 1:00 PM
Raja,
For your Q 2 (convert this to a YYYYMMDD format..), use the function module <b>'CONVERSION_EXIT_IDATE_INPUT'</b>.
Make sure u give the input date is in the format <b>ddmmyyyy</b> or <b>dd.mm.yyyy</b>
Thanks
Kam
‎2005 Nov 22 1:00 PM
Raja,
For your Q 2 (convert this to a YYYYMMDD format..), use the function module <b>'CONVERSION_EXIT_IDATE_INPUT'</b>.
Make sure u give the input date is in the format <b>ddmmyyyy</b> or <b>dd.mm.yyyy</b>
Thanks
Kam
‎2005 Nov 22 1:02 PM
if the intention is to converti the external date format to internal format simply use the following FM
DATE_CONV_EXT_TO_INT
Regards
Raja
‎2005 Nov 22 1:04 PM
Hi Raja,
Can you please tell me Which Version of SAP you are Using, because Some FM's are Available in Some Versions of SAP Only.
Please get back to me Immediately, So that I will surely get you the Idea of it.
Thanks,
Satya Krishna .M
‎2005 Nov 22 1:13 PM
‎2005 Nov 22 1:05 PM
Hi
I don't know if there is a fm, but you can split the date and analyze the single values:
SPLIT <f1> AT '/' INTO DAY MONTH YEAR.
CONCATENATE YEAR MONTH DAY INTO DATE.
I think it won't be easy to know if the date format is MM/DD/YYYY or DD/MM/YYYY, you can be sure only if you can know how the date is stored in field symbol.
The format of the date usually depends on user attributes, if it's your case, check the table USR01, field DCPFM.
Max
Message was edited by: max bianchi
‎2005 Nov 22 1:08 PM
raja,
would this works for..
if my datefield format is ..
11/11/2005 or 11-11-2005...etc..
to give in export structure u mentioned..
‎2005 Nov 22 1:10 PM
‎2005 Nov 22 1:17 PM
Hi Raja,
There is one FM to Convert the Date to the Internal Format. Whatever the Date Format, You can Pass that Date to this FM through FS, It Automatically Converts to the Internal Format of the System. Please use this FM.
<b>
CONVERT_DATE_TO_INTERN_FORMAT
</b>
Please Pass the Parameters of the DATA Format and the DTYPE as DATS.
Thanks,
Satya Krishna.M
‎2005 Nov 22 1:19 PM
Hi Raja,
Please let you know more FM's, let me do R & D on this.
Please be Patient, Will let you know the Answer for this.;
Thanks,
Satya Krishna.M
‎2005 Nov 22 1:13 PM
Max ..easily i can split...and work out for my logic..
But
the problem in dif countries people use dif formats..
example dd/mm/yyyy or mm/dd/yyyy..or some other..
So if i split that how would i come to know that ..which is earlier two digits are day or months...
i hope u understand my problem..
‎2005 Nov 22 1:18 PM
i am not sure whether function i mentioned in available in 4.6C
you can also use
CONVERT_DATE_INPUT
CONVERT_DATE_TO_INTERNAL
but these will allow you to pass only user specific date format as input
Regards
Raja
‎2005 Nov 22 1:19 PM
I know it, dO you try to see the date format stored in USR01?
Max
‎2005 Nov 22 1:19 PM
Raja,
Even if u split the date, u will have problem in recognization.
If suppose the Date is '11/12/2005' or '12/11/2005' or '09/12/2005'(for eq), then u would not be in a position to find the correct Day and Month!!!!!
Thanks
Kam
‎2005 Nov 22 1:24 PM
Hi Raja
In the table T005X (field DATFM) you can find out the date format for country;
In the table USR01 (field DATFM) you can find out the date format for user.
Max
‎2005 Nov 22 1:24 PM
Raja,
here is another FM, Which you can get the Format of the Date.
<b>SLS_MISC_GET_USER_DATE_FORMAT</b>
Thanks,
Satya Krishna Madasu
‎2005 Nov 22 1:39 PM
Hi satya,Draja,Max,kam...
Thank u very much for instant replies.
i am a junior level programmer.
I copied the <FS> to a l-dtmp char(10) field.
CALL FUNCTION 'DATE_CONV_EXT_TO_INT'
EXPORTING
I_DATE_EXT = l_dtmp
IMPORTING
E_DATE_INT = l_date.
I used this FM ..and i got the field into l_date also as 11/11/2005...
If i assign this to
standard date field...
it copied as ...20051111.( this is what i required)..
Is this solution ok?
works for all instances..
like..if the format is 11-11-2005..??
As i am a beginner ..i need clarification to include this solution to mine..
Message was edited by: raja gurrala
‎2005 Nov 22 1:45 PM
Hi Raja,
By using the function module 'SLS_MISC_GET_USER_DATE_FORMAT', you can get the format of the date in your system. Based on this you split that into year,month and date. Later you can write into whatever format you want.
Regards,
Rajavardhana Reddy
‎2005 Nov 22 1:47 PM
Guys ,
Needed clarification for my previous posting!!!..
<b>Experts..plz do make comments ..on my proposed solution and clarify my misgivings..</b>
‎2005 Nov 22 2:21 PM
Hey Raja,
I have Cross Checked with the Date Format you have like 11-11-2005, you cannot give this type of format to the FM, Whether you should give without any wild characters into it.
you can give like 11112005 and its converts into the Standard Internal Format,
Please tell me raja, Whether the FM's Which is given by me, is useful to you for this Case.
Thanks,
Satya Krishna.M
‎2005 Nov 23 6:15 AM
Hi all,
IF i <b>use date_con_ext_to_int FM</b> it is working fine as per my requirement..
But when supposed to save the PO (As i am using this in an userexit for ME21).
at last step of saving ..it is givng error like
Use data format of the user.
can any body look into this problem.
Message was edited by: raja gurrala
‎2005 Nov 23 6:41 AM
it looks like you need to pass the date in the user specific format.
first use date_con_ext_to_int to convert the date to internal format (YYYYMMDD) then use the following piece of code to conver that date to user specific format.
select single datfm into usr01-datfm from usr01 where
bname eq sy-uname .
if sy-subrc eq 0 .
move: usr01-datfm to wf_datfm .
endif .
if wf_datfm eq '1' .
concatenate loc_date+6(2)
loc_date+4(2)
loc_date+0(4)
into wf_date separated by '.' .
condense wf_date .
elseif wf_datfm eq '2' .
concatenate loc_date+4(2)
loc_date+6(2)
loc_date+0(4)
into wf_date separated by '/' .
condense wf_date .
elseif wf_datfm eq '3' .
concatenate loc_date+4(2)
loc_date+6(2)
loc_date+0(4)
into wf_date separated by '-' .
condense wf_date .
elseif wf_datfm eq '4' .
concatenate loc_date+0(4)
loc_date+4(2)
loc_date+6(2)
into wf_date separated by '.' .
condense wf_date .
elseif wf_datfm eq '5' .
concatenate loc_date+0(4)
loc_date+4(2)
loc_date+6(2)
into wf_date separated by '/' .
condense wf_date .
elseif wf_datfm eq '6' .
concatenate loc_date+0(4)
loc_date+4(2)
loc_date+6(2)
into wf_date separated by '-' .
condense wf_date .
endif .Regards
Raja
‎2005 Nov 23 6:51 AM
Raja,
Thanks i will try n get back.
IF i use the split logic like...
l_date0(4) = l_dtmp6(4)..
etc..
at last i am making l_date ( which i am passing )yyyymmdd ..only...
then it is not giving any error..
IF i use the FM module then only ..it is giving problem.
remaining 2 FMs also working but...every one is giving error at the time of saving only..
‎2005 Nov 23 1:13 PM
ok got your point. you say system accepts YYYYMMDD. then as suggested use the FM which i have given (DATE_CONV_EXT_TO_INT) and make sure that the variable for parameter E_DATE_INT is of type D.
if you use variable of type D the return will be in system format which is YYYYMMDD
Regards
Raja
‎2005 Nov 23 1:29 PM
Hi Raja,
If you are working with BDC then there will be one problem. The date format for BDC process sets according to the login user format.
Then the BDC should take the date format according to the login user format.
Inorder to get that there is no need of using FM or any.
It quite simple to give two statments as follows:
Eg:
data: v_date like sy-datum value '20050912',
v_date1(8) type c.
write v_date to v_date1.
write v_date1.
Here Write statement sets the date according to the user format
Again i request your rewards for the useful answers.
Thanks,
Gopi
‎2005 Nov 23 2:00 PM
Hi Raja,
... and with FM DATE_CHECK_PLAUSIBILITY you can check
whether a certain format you have is a valid date or not interpretable yet.
regards
Andreas