2016 Jun 08 7:31 AM
Hi Expert,
I have such scenario as below:
int a = 234.
int b = 567.
int c = 876.
int z.
How to add these 3 integer (a, b and c) as below:
z = 2+3+4+5+6+7+8+7+6.
Thanks.
Regards,
-Ben-
2016 Jun 08 7:52 AM
Hi Yen Shen,
Integer Type Fields does not permit subfield access.
Hence assign the Integer Type Fields to a character type fields.
Data M(3) type C.
M = a. a is your integer variable.
then you can access individual subfields like m+0(1) + m+1(1) + m+2(1).
Thanks and Regards,
Vinay Mutt
Hi Expert,
I have such scenario as below:
int a = 234.
int b = 567.
int c = 876.
int z.
How to add these 3 integer (a, b and c) as below:
z = 2+3+4+5+6+7+8+7+6.
Thanks.
Regards,
-Ben-
2016 Jun 08 7:52 AM
Hi Yen Shen,
Integer Type Fields does not permit subfield access.
Hence assign the Integer Type Fields to a character type fields.
Data M(3) type C.
M = a. a is your integer variable.
then you can access individual subfields like m+0(1) + m+1(1) + m+2(1).
Thanks and Regards,
Vinay Mutt
2016 Jun 08 8:04 AM
Hi Vinay Mutt,
Thanks for your prompt response.
Never thought and try on summation on character field.
Thanks again!
Regards,
-Ben-
2016 Jun 08 8:06 AM
Hi Yen,
You can hold your values in char variables. Then you can do the summation character by character. I wrote sample code to the below part. After plus sign, number indicates the offset and the number in the parentheses indicates the length which you want to use.
Regards.
DATA: a(3) TYPE c value '234',
b(3) TYPE c value '567',
c(3) TYPE c value '876',
z TYPE i .
z = a+0(1) + a+1(1) + a+2(1) + b+0(1) + b+1(1) + b+2(1) + c+0(1) + c+1(1) + c+2(1). //result 48
2016 Jun 08 8:13 AM
2016 Jun 08 8:12 AM
2016 Jun 08 8:14 AM
Hi Raymond,
Thanks for your suggestion. I have get the solution.
Regards,
-Ben-