‎2007 Jun 21 9:27 AM
Hi everyone,
We have a scenario where we are getting an input from a file for date and number.
these formats are given in the selection screen to make it easier for the user.
for eg: date formats are given are dd/mm/yyyy so on whatever formats are available through datfm field in usr01 table.
We need to change the format of the date and the format of the number according to the user settings .fields datfm and fields dcpfm(eg. 1,23,600.00,1 23 600.00,1.23.600,00) in usr01 first and then map it to the sap fields.so we have to change this format to sap format.
can anyone please help me on this.
to change the date format as well as number format.
the number format is on more priority then date format.
any help would be appreciated.
thanks,
ahmed
‎2007 Jun 21 9:35 AM
Hi Ahmed,
well, for amounts you could use:
select single * from usr01 where bname = sy-uname.
case usr01-dcpfm.
when space.
translate input_string using '. ,.'.
when 'X'.
translate input_string using ', '.
when 'Y'.
translate input_string using ',.'.
when others.
endcase.
condense input_string no-gaps.
...and for dates:
CALL FUNCTION 'KCD_EXCEL_DATE_CONVERT'
EXPORTING
excel_date = string
date_format = 'TMJ'
IMPORTING
sap_date = date.
I hope it helps. Best regards,
Alvaro
‎2007 Jun 21 9:35 AM
Hi Ahmed,
well, for amounts you could use:
select single * from usr01 where bname = sy-uname.
case usr01-dcpfm.
when space.
translate input_string using '. ,.'.
when 'X'.
translate input_string using ', '.
when 'Y'.
translate input_string using ',.'.
when others.
endcase.
condense input_string no-gaps.
...and for dates:
CALL FUNCTION 'KCD_EXCEL_DATE_CONVERT'
EXPORTING
excel_date = string
date_format = 'TMJ'
IMPORTING
sap_date = date.
I hope it helps. Best regards,
Alvaro
‎2007 Jun 21 9:41 AM
Hi,
Here is the solution to change the formats ..
<b>for Dates:</b>
Data: date1 type sy-datum,
date2(10) type c.
date1 = sy-datum
write: date1 to date2.
write:/ date2. " This date 2 will have the user format.for the numbers also you can use the WRITE TO Option
Regards
Sudheer
‎2007 Jun 21 11:50 AM
Hi Alvaro/Sudher,
Thanks you guys for ur answers!!!
i was able to solve the problem of number format using your logics.
is there any function module to convert the number after converting it into user format.
also the date format is not getting solved as the date can be any format and the function module kcd works only when the date is in format of dd/mm/yy with any separator.
please help on the date issue and appreciate if u could tell me any fm on decimal format.
thanks again
cheers
ahmed
‎2007 Jun 21 12:04 PM
‎2007 Jun 21 12:04 PM
Hi Ahmed,
well, you should use parameter "date_format" in the function module in order to tell SAP what is the format of the date. I mean: "T" for days, "M" for months, "J" for years... so "JMT" could be useful for dates in format "YYYY/MM/DD", for example.
I hope it helps. Best regards,
Alvaro
‎2008 Mar 30 8:50 AM