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

pls explain me

Former Member
0 Likes
842

data: lr_wa TYPE REF TO data.

FIELD-SYMBOLS: <s_chas> TYPE ANY,

<ref> TYPE ANY.

  • create structure for the selection criteria

create data lr_wa like line of eto_chas.

assign lr_wa->* to <s_chas>.

in above code i want to know what is happening.

lr_wa type ref to data (what is data here)

i mean is it class,iam unable to understand.

again lr_wa->* to <s_chas>,

what is * ????

data: lr_wa TYPE REF TO data.

FIELD-SYMBOLS: <s_chas> TYPE ANY,

<ref> TYPE ANY.

  • create structure for the selection criteria

create data lr_wa like line of eto_chas.

assign lr_wa->* to <s_chas>.

in above code i want to know what is happening.

lr_wa type ref to data (what is data here)

i mean is it class,iam unable to understand.

again lr_wa->* to <s_chas>,

what is * ????

6 REPLIES 6
Read only

Former Member
0 Likes
815

Hi,

Here the data could be some Data object like field or structure or table

lr_wa->* to <s_chas>,

this is use dfor Broading casting .

raam

Read only

Former Member
0 Likes
815

HI!,

using your code as the example,

if you dont know the data type of lr_wa beforehand (here it is of type eto_chas ) , you can define a field symbol of any type and later assign it. The system will automatically type cast <s_chas> to the data type of lr_wa.

pros- very usefull when you are using a field symbol for muliple purposes like string manipulations.

cons- if it is used in some funciton modules it may sometimes throw error.

Read only

0 Likes
815

its good ..please explain me in detail with ex.

Read only

0 Likes
815

DATA: gr_table TYPE REF TO data.

FIELD-SYMBOLS: <itab> TYPE ANY TABLE.

PARAMETERS: p_tab TYPE tablename DEFAULT 'SFLIGHT'.

START-OF-SELECTION.

CREATE DATA gr_table TYPE TABLE OF (p_tab).

ASSIGN gr_table->* TO <itab>.

SELECT * FROM (p_tab) INTO TABLE <itab>.

Edited by: Micky Oestreich on Apr 25, 2008 7:49 AM

Read only

0 Likes
815

could u tell me tht casting ?in your own words

with uses? and types?

Read only

0 Likes
815

1. With create data you are create a data object like you would when declaring it statically with:

data: itab type standard table of sflight.

2. Next with assign gr_table you are derefencing, which I can't explain any better than this from F1 help on assign:

If you specify a data reference dref for a mem_area that was dereferenced using the dereferencing operator ->*, the storage area of the data object is assigned to the field symbol. The data object concerned is the one to which dref points. If the reference variable dref does not reference any data object, the assignment is not carried out and sy-subrc is set to 4.

So, the storage area of the data object is assigned to the field symbol, which means that the field symbols now will take on the 'type' of gr_table, so now the field-symbol actually is an internal table with structure sflight