Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Number Conversion:Urgent

Former Member
0 Likes
948

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
894

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

6 REPLIES 6
Read only

Former Member
0 Likes
895

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

Read only

Former Member
0 Likes
894

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

Read only

0 Likes
894

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

Read only

0 Likes
894

Hi Parvez,

Try the FM 'CONVERT_DATE_TO_EXTERNAL'.

Regards,

Amit

Read only

0 Likes
894

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

Read only

Former Member
0 Likes
894

solved