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

Checking variables are fitting to data element

TimVDB92
Participant
0 Kudos
268

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
Read only

Former Member
0 Kudos
238

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
Read only

Former Member
0 Kudos
239

You can put below piece of code in your logic.

TRY.

     var1 = var2.

CATCH cx_sy_conversion_error.

     "Conversion not possible

ENDTRY.