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

Conversion external data type to internal data type

Former Member
0 Likes
5,123

Hi freinds,

Problem:

I would like to convert the fields in my ITABs with conversion routines such as '==CUNIT', '==ISOLA', '==MATN1' etc from the user external format to SAP internal format.

I have the feelings that my code is too complicated, so I would like to simplify it. My intension is this:

Aim:

ITAB (in ext. format) -->FM or Bapi (converts all neccessary fields with conversion routines) --> ITAB (intern. format)

Does some know a FM or how I can achieve this aim as simple as possible?

Blacky.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,702

Hi,

First you need to list out the list of fields and their conversion exist, if exist. Assume that your internal table has three field as below for example..

field1 -> no conversion exist

field2 -> has ALPHA conversion

field3 -> has MATN1 conversion

Then write a separate subroutine for each converion exit. I am taking ALPHA as one example.

form z_conversion_exit_cunit changing p_input.

clearL: p_input.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = p_input

IMPORTING

OUTPUT = p_input

.

endform.

Similarly write for other conversion exits also.

Then loop at the table and call each conversion exits.

loop at itab.

call ALPHA converion routine for itab-field2.

call MATN1 converion routine for itab-field3.

modify itab. "Modify itab

endloop.

After the loop your internal table will have internal format data.

Regards,

Yellappa.

5 REPLIES 5
Read only

Former Member
0 Likes
2,702

Hi,

Are you trying to upload some thing from external flat file in your program.

If yes,then the internal table in which you are trying to upload the data just put the fields of those internal table as standard sap tables field for e.g.

data:begin of itab occurs 0,

matnr type mara-matnr,

...... ..

end of itab.

I hope you got my point.

then use any of the Fm available for upload and pass the internal table to those Fm.

I hope this will help you.

Read only

Former Member
0 Likes
2,702

Hi,

First read the records from your flat file.Convert them to the proper format by CONVERSION ROUTINES then pass them to FM /BAPI.After that if you further require them convert them to internal format.

Read only

Former Member
0 Likes
2,703

Hi,

First you need to list out the list of fields and their conversion exist, if exist. Assume that your internal table has three field as below for example..

field1 -> no conversion exist

field2 -> has ALPHA conversion

field3 -> has MATN1 conversion

Then write a separate subroutine for each converion exit. I am taking ALPHA as one example.

form z_conversion_exit_cunit changing p_input.

clearL: p_input.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = p_input

IMPORTING

OUTPUT = p_input

.

endform.

Similarly write for other conversion exits also.

Then loop at the table and call each conversion exits.

loop at itab.

call ALPHA converion routine for itab-field2.

call MATN1 converion routine for itab-field3.

modify itab. "Modify itab

endloop.

After the loop your internal table will have internal format data.

Regards,

Yellappa.

Read only

0 Likes
2,702

Hi Yellapa,

Thanks for this tip. However this is exactly what I did. I am just thinking there could be a simpler way to do this.

However I will give some points for tghe tip.

My logic was:

- Upload text data into ext_ITAB

- Describe ext_ITAB into desc_ITAB

- loop desc_ITAB

- case routine

- When conversion routine (e.g. '==CUNIT') found

- then loop ext_ITAB

- use FM CONVERSION_EXIT_CUNIT_INPUT

- Modify ITAB

Blacky,

Read only

0 Likes
2,702

Hi Blacky,

Just wondering, whether did you find any simple way without having to use the loop statement while doing the conversion routine in internal table?

Appreciate if you could share your trick.

Thank you.