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: 

How to do a SUM of number stored in SSTRING type field

avinashd_m
Participant
0 Kudos

Hi All,

Note : We are working in 1809 system with SAP BASIS release of 753 0007.

We have a requirement of finding out the totals for the numbers stored in the table field of type SSTRING.

i have come to know that, in casting expression for source type SSTRING, no other target types is supported, for the same the casting matrix can be seen below:

So now, since aggregate function SUM cannot work with string type, and also casting is not supported in the system, is there any way where we can achieve summation of number value stored in SSTRING type in select query?, something like below:

*****

Select SUM( CAST( sstring_value as number_type ) )

from DB_Table

*****

Thanks in Advance,

Avinash

1 REPLY 1

Yasin
Active Participant
0 Kudos

Hi Avinash

am not sure about casting but you can try to convert all of your sstrings values into numbers then apply your summation or whatever, you can simply archive that by assigning the strings values to variable type p or i.

DATA v_num_value type P.
v_num_value = v_sstring_value .

The system will automatically convert types for you.

Please reward the answer if was helpful to you.

Thanks