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

Regarding Casting of objects

arpitgoyal
Product and Topic Expert
Product and Topic Expert
0 Likes
590

Currently ?= operator can only used to cast objects from one form to another. If I have value of type Boolean or String and I need to cast it to Object type what is the work around?

Do I need to create class for each type (boolean, string etc) or is there a work around to this?

Regards,

Arpit.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
562

Hi,

I think there is an easy way.

I created this code snippet. Hope this helps.

====

data : xx(20) type c,

dd type ref to data,

dd1 type ref to String.

Field-Symbols : <fs> type any.

xx = 'ABC'.

CREATE DATA dd type String.

ASSIGN dd->* to <fs>.

<fs> = xx.

dd1 ?= dd.

====

Regards,

Saurabh

3 REPLIES 3
Read only

Former Member
0 Likes
563

Hi,

I think there is an easy way.

I created this code snippet. Hope this helps.

====

data : xx(20) type c,

dd type ref to data,

dd1 type ref to String.

Field-Symbols : <fs> type any.

xx = 'ABC'.

CREATE DATA dd type String.

ASSIGN dd->* to <fs>.

<fs> = xx.

dd1 ?= dd.

====

Regards,

Saurabh

Read only

arpitgoyal
Product and Topic Expert
Product and Topic Expert
0 Likes
562

Thank you so much. It solved my problem big time.

And thanks for your time.

Regards,

Arpit.

Read only

Former Member
0 Likes
562

Hi,

Report xyz.

DATA txt(8) TYPE c VALUE '19980606'.

DATA mytype(1) VALUE 'X'.

FIELD-SYMBOLS <fs> TYPE ANY.

ASSIGN txt TO <fs>.

WRITE / <fs>.

SKIP.

ASSIGN txt TO <fs> CASTING TYPE d.

WRITE / <fs>.

ASSIGN txt TO <fs> CASTING TYPE (mytype).

WRITE / <fs>.