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

string value

Former Member
0 Likes
822

Dear gurus,

Can i move the value from string type variable to type p variable with decimal.

scenario is i want move the value is ( -102334) from string type to the variable type p decimal 2.

Regards

R.Rajendran

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
798

Hi,

Yes you can.

data: str type string value '-1245',
      p1 type p decimals 2.


p1 = str.

write:/ 'String = ', str,
      / 'Packed = ', p1.

Output:

String = -1245

Packed = 1,245.00-

Regards,

Subramanian

6 REPLIES 6
Read only

Former Member
0 Likes
798

yes, you should be able to move.

Read only

Former Member
0 Likes
799

Hi,

Yes you can.

data: str type string value '-1245',
      p1 type p decimals 2.


p1 = str.

write:/ 'String = ', str,
      / 'Packed = ', p1.

Output:

String = -1245

Packed = 1,245.00-

Regards,

Subramanian

Read only

0 Likes
798

if the computation done it is not working

data: str type string ,

strr type p decimals 2.

strr = 1234.

strr = strr * ( -1 ).

str = strr.

write:/ 'String = ', str,

/ 'Packed = ', strr.

Regards

Read only

0 Likes
798

Hi,


data: str type string ,
strr type p decimals 2.

strr = 1234.

str = strr.
strr = strr * ( -1 ).
write:/ 'String = ', str,
/ 'Packed = ', strr.

You cannot compute on string. first convert to packed decimal and then do the computation.

Regards,

Subramanian

Edited by: Subramanian PL on Jul 10, 2008 9:50 AM

Read only

Former Member
0 Likes
798

Hello Rajendra,

Yes you can move a value from String to a packed field with decimals 2.

Here is the code :

data: w_string type string value '-102334',

w_pack type p decimals 2.

w_pack = w_string.

After this assignment statement the value in w_pack = 102334.00-

I hope this answers your question.

Thanks,

Sushil Joshi

Read only

Former Member
0 Likes
798

You can do this, but the assignment should be done within try..endtry block to capture error.

data: val_str type string.

data: val_p type p decimals 2.

val_str = `-102334`.

try.

val_p = val_str.

catch cx_root.

  • For error handling

endtry.

Write: val_p.

Regards,

Joy.