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

function module to convert character type to required data type

Former Member
0 Likes
3,050

Hi,

Is there a function module which can convert data in character type to any other required data type?

Like i have a date 12.2.2008 and it is stored as character now i want to convert it into type d.

so that when i use

Describe field <field_name> type <type>.

statement afterwards then it gives me D not C as its data type.

The requirement does'nt stick to conversion of just one data type.I need an FM which can convert data in character type to any data type.

Hope you understood the problem.

Thanks for your time.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,738

ucan use this to convert char into any data type.

CONVERT_FROM_CHAR_SORT_RFW.

CWM/CONVERT_CHAR_TO_PACK

Reward points..

10 REPLIES 10
Read only

Former Member
0 Likes
1,738

hi,

do this way ...


data : v_date1(10) value '12.02.2008',
         v_date2(10),
         v_date3 like sy-datum.

  concatenate v_date1+ 5(4)  v_date1+ 3(2) v_date1+ 0(2) into v_date2.

  v_date3 = v_date2.

write : v_date3.

Read only

0 Likes
1,738

The data should remain as it is.Don't need to manipulate the data.

I only have to change its data type.

Read only

Former Member
0 Likes
1,738

Hi,

Use the code.

data : date like sy-datum.

call function 'CONVERT_DATE_TO_INTERNAL'
  exporting
    date_external                  =  '01.01.2008'
 IMPORTING
   DATE_INTERNAL                  = date
 EXCEPTIONS
   DATE_EXTERNAL_IS_INVALID       = 1
   OTHERS                         = 2
          .
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

Regards,

Morris Bond.

Reward Points if Helpful.

Read only

Former Member
0 Likes
1,739

ucan use this to convert char into any data type.

CONVERT_FROM_CHAR_SORT_RFW.

CWM/CONVERT_CHAR_TO_PACK

Reward points..

Read only

0 Likes
1,738

Thank you.

Read only

abapdeveloper20
Contributor
0 Likes
1,738

Hi,

check this Function module in SE37

CONVERSION_EXIT_ALPHA_OUTPUT

it will return the value in ur required format

reward if useful

Read only

Former Member
0 Likes
1,738

CONVERT_DATE_TO_INTERNAL

Read only

Former Member
0 Likes
1,738

Hi Kamini Rawat,

Have you tried FIELD-SYMBOLES for this ???

FIELD-SYMBOLS : <FS> TYPE ANY.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm

Hope it will solve your problem...

Thanks & Regards

ilesh 24x7

Edited by: ilesh 24x7 on Mar 28, 2008 10:57 AM

Read only

0 Likes
1,738

The requirement is to find whether the data is compatible with the required type or not.

When i upload data from excel file using FM alsm_excel_to_internal_table type for all the values is C.

And the column and row number of the excel file where the data format is wrong is to be captured.

We can get the correct types for these fields from dd03m.

I don't understand how field symbols can help in this?

Read only

Former Member
0 Likes
1,738

Hi,

Is there any Function module to convert character type to Raw data type or vice versa of a field.