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

exception error handling in module pool program

Former Member
0 Likes
1,271

Hi all,

I have developed a screen in which I am calculating one of field value using two fields from same table.following is sample code.

zfi_proposal-zpro_value = zfi_proposal-zinv_rate * zfi_proposal-zno_of_shares.

here, field zinv_rate has domain type quan length 10 and decimal places = 4, and field zno_of_shares has domain type numc length 4. while zpro_value has domain type quan length 10 and decimal places = 4.

If zinv_rate > six digit value and zno_of_shares = two digit number system is giving conversion error.

can anyone provide solution to rectify this error.Thanks in advance.

Regards,

Harshada

9 REPLIES 9
Read only

Former Member
0 Likes
1,140

Change the domain of zfi_proposal-zpro_value to be a couple of digits longer.

Rob

Read only

0 Likes
1,140

Hi Rob,

I tried with increasing field (zfi_proposal-zpro_value) domain value but still it is giving exception error.how we can remove this exception error using try..catch..endtry. control statement.can you provide some sample code for this.or is there any other alternative to remove this error.

Thanks for your valuable response.

Regards,

Harshada

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,140

what is the data type of zfi_proposal-zpro_value ?

you are getting the error as this field can not hold such a big value.

Try INT4 may be this will help.

Read only

0 Likes
1,140

Hi Sandip,

zinv_rate has domain type quantity, no of characters 10 and 4 decimal places and zno_of_shares has domain type numc, no of characters 4, while zpro_value has domain type quantity, no of characters 10 and 4 decimal places.

here, zpro_value = zinv_rate * zno_of_shares.how we can remove error without changing data types defined.is there any way out to rectify this error.

Thanks for your quick response..

Regards,

Harshada

Read only

0 Likes
1,140

The ismple reason you cant avoid this error is when you do the multiplication , the result is far too big than 10 char.

Read only

0 Likes
1,140

Hi Sandip,

yes you are right.how we can rectify this error without changing field data types.is it possible to remove this error using programming.can you provide some solution.

thanks for your answers.

Regards,

Harshada

Read only

0 Likes
1,140

You can catch the exception cx_sy_arithmetic_overflow

Please refer example coding


PARAMETERS: pa_rate TYPE p DECIMALS 4,
            pa_shar TYPE n LENGTH 4,
            pa_pro  TYPE p DECIMALS 4.


AT SELECTION-SCREEN ON pa_rate.
  TRY .
      pa_pro = pa_rate * pa_shar.
    CATCH cx_sy_arithmetic_overflow.
      MESSAGE 'Sorry the rate is too high, please correct the entry' TYPE 'E'.
  ENDTRY.

AT SELECTION-SCREEN ON pa_shar.
  TRY .
      pa_pro = pa_rate * pa_shar.
    CATCH cx_sy_arithmetic_overflow.
      MESSAGE 'Sorry the no_shares is too high, please correct the entry' TYPE 'E'.
  ENDTRY.

Regards

Marcin

Read only

0 Likes
1,140

Hi all,

Thanks for your valuable answers.my problem is solved.

Warm Regards,

Harshada

Read only

Former Member
0 Likes
1,140

closed.