Skip to Content
0
Former Member
Sep 27, 2016 at 01:21 PM

Best Practice for using CAST operator

33 Views

Hello SDNers,

I looked up the SAP documentation but could not find any best practice on using the CAST operator multiple times in a procedure.

Approach#1:

INSERT LINES OF:

CAST child( parent )->table1 INTO TABLE ex_table1,

CAST child( parent )->table2 INTO TABLE ex_table2.

Approach#2:

DATA(child) = CAST child( parent ).

INSERT LINES OF:

child->table1 INTO TABLE ex_table1,

child->table2 INTO TABLE ex_table2.

In the former i am casting twice, whereas in the latter i am using a helper variable.


SAP documentation states & i quote,

The casting operator CAST is suitable for avoiding the declaration of helper variables needed only for down casts.

If i consider this statement as the thumb-rule, then approach#1 is better.

What do you think?

BR,

Suhas