‎2010 Aug 27 3:53 PM
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
‎2010 Aug 27 4:05 PM
Change the domain of zfi_proposal-zpro_value to be a couple of digits longer.
Rob
‎2010 Aug 30 7:43 AM
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
‎2010 Aug 30 7:46 AM
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.
‎2010 Aug 30 8:54 AM
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
‎2010 Aug 30 9:12 AM
The ismple reason you cant avoid this error is when you do the multiplication , the result is far too big than 10 char.
‎2010 Aug 30 10:11 AM
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
‎2010 Aug 31 12:55 PM
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
‎2010 Sep 01 3:28 PM
Hi all,
Thanks for your valuable answers.my problem is solved.
Warm Regards,
Harshada
‎2010 Sep 18 2:54 PM