Application Development 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: 

Checking variables are fitting to data element

TimVDB92
Participant
0 Kudos

Hi,

I'm working on a migration tool where I'm reading data from a file and converting these variables in a correct format.

Is there a function module who can check a variable and an other variable from a DDIC data type and can just check if the conversion is possible?

For exemple:

Case1

-----------

Var1 = 'ABCDEFGH'

Var2 TYPE C(4)

=> This should give an error that it's not possible

Case2

-----------

Var1 = 'ABCDEFGH'

Var2 TYPE String

=> OK

Case3

-----------

Var1 = 'ABCDEFGH'

Var2 TYPE I

=> This should give an error that it's not possible

Kind regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can put below piece of code in your logic.

TRY.

     var1 = var2.

CATCH cx_sy_conversion_error.

     "Conversion not possible

ENDTRY.

1 REPLY 1

Former Member
0 Kudos

You can put below piece of code in your logic.

TRY.

     var1 = var2.

CATCH cx_sy_conversion_error.

     "Conversion not possible

ENDTRY.