Application Development 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: 

ASSIGN

kiran_k8
Active Contributor
0 Kudos

Hi,

Can anyone please let me know what does the following statement mean


FIELD-SYMBOLS : <table> TYPE table.
DATA : v_ref TYPE REF TO data.

ASSIGN v_ref->* TO <table>.

What is this v_ref->*


FIELD-SYMBOLS : <table> TYPE table.
FIELD-SYMBOLS : <uline> TYPE ANY.
.....

ASSIGN LOCAL COPY OF INITIAL LINE OF <table> TO <line>.

What does this LOCAL COPY OF INITIAL LINE mean?

Thanks,

K.Kiran.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

... dref->*

Effect

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.

In contrast to all the other operand positions where the specification of dref->* is only possible as of Release 6.10 and the data reference dref must be fully typed, the specification of dref->* was already possible with Release 4.6 in the statement ASSIGN.

In the statement ASSIGN, dref can be typed generically using TYPE REF TO data. Furthermore, the data referencing of a data reference that does not point to any data object does not cause an exception that cannot be handled, but only in the statement ASSIGN.

Since Release 6.10, dref->* can also be specified in the dynamic variants mentioned as a field content, and after dref->* it is possible to enter offset or length specifications - if dref is completely typed.

Example

Creating a local copy of a global data object g_dat in a procedure with the help of a data reference dref and access through a local field symbol <l_dat> after data referencing

DATA g_dat TYPE string.

...

FORM subroutine.

DATA dref TYPE REF TO data.

FIELD-SYMBOLS <l_dat> TYPE ANY.

CREATE DATA dref LIKE g_dat.

ASSIGN dref->* TO <l_dat>.

WRITE <l_dat> ...

ENDFORM.

ASSIGN LOCAL COPY

the statement ASSIGN LOCAL COPY assigns a memory area mem_area to the field symbol <fs>.

Hope it will helps

8 REPLIES 8

Former Member
0 Kudos

Hi,

... dref->*

Effect

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.

In contrast to all the other operand positions where the specification of dref->* is only possible as of Release 6.10 and the data reference dref must be fully typed, the specification of dref->* was already possible with Release 4.6 in the statement ASSIGN.

In the statement ASSIGN, dref can be typed generically using TYPE REF TO data. Furthermore, the data referencing of a data reference that does not point to any data object does not cause an exception that cannot be handled, but only in the statement ASSIGN.

Since Release 6.10, dref->* can also be specified in the dynamic variants mentioned as a field content, and after dref->* it is possible to enter offset or length specifications - if dref is completely typed.

Example

Creating a local copy of a global data object g_dat in a procedure with the help of a data reference dref and access through a local field symbol <l_dat> after data referencing

DATA g_dat TYPE string.

...

FORM subroutine.

DATA dref TYPE REF TO data.

FIELD-SYMBOLS <l_dat> TYPE ANY.

CREATE DATA dref LIKE g_dat.

ASSIGN dref->* TO <l_dat>.

WRITE <l_dat> ...

ENDFORM.

ASSIGN LOCAL COPY

the statement ASSIGN LOCAL COPY assigns a memory area mem_area to the field symbol <fs>.

Hope it will helps

0 Kudos

This is nothing but F1 help.

@Kiran I would suggest you to take SAP help As much as possible sometime we misconcept but they never

Cheers

Former Member
0 Kudos

>

>


> FIELD-SYMBOLS : <table> TYPE table.
> FIELD-SYMBOLS : <uline> TYPE ANY.
> .....
> 
> ASSIGN LOCAL COPY OF INITIAL LINE OF <table> TO <line>.
> 

>

>

> What does this LOCAL COPY OF INITIAL LINE mean?

From F1 help.

Obsolete creation of a local data object. This variant of the ASSIGN statement can only be used in subroutines and function modules. The field symbol <fs> must be declared locally in the procedure.

As of release 4.6, the creation of a local data object with the statement ASSIGN LOCAL COPY is replaced with the statement CREATE DATA with subsequent deferencing in the normal ASSIGN statement.

Regards

Karthik D

naveen_inuganti2
Active Contributor
0 Kudos

HI,

->* is dereferencing operator.

Please check the documentation for Read position.(follow this navigation in help)

ABAP theme -> ABAP syntax -> ABAP statements -> Operands -> 
Data Objects in Op' positions -> Read position.

'Thanks,

'Naveen.I

0 Kudos

Hi Everybody,

Thanks for the reply.

Does that mean if sy-subrc = 4 for the statement ASSIGN v_ref->* TO <table> then does that result in an error "attempt to access an unassigned field symbol".

If it is so can we make this particular statemet fail in debugging? ie

I want to make this particular statement ASSIGN v_ref->* TO <table>

fail in debugginig by changing the values.

Kindly let me know.

Thanks,

K.Kiran.

0 Kudos

> Hi Everybody,

>

> Thanks for the reply.

> Does that mean if sy-subrc = 4 for the statement ASSIGN v_ref->* TO <table> then does that result in an error "attempt to access an unassigned field symbol".

>

> If it is so can we make this particular statemet fail in debugging? ie

>

> I want to make this particular statement ASSIGN v_ref->* TO <table>

> fail in debugginig by changing the values.

>

> Kindly let me know.

>

> Thanks,

> K.Kiran.

Answer is yes we can forcefully fail this statement in Debug.(By changing the Sy-subrc values)

ASSIGN LOCAL COPY OF INITIAL LINE OF <table> TO <line>.

But this is Obslete since 4.6

Cheers

Edited by: Ámit Güjärgoüd on Sep 26, 2008 7:22 AM

0 Kudos

Amit,

What value needs to be changed so that I can make these two statements fail in debugging.I tried with sy-subrc but in vain.

At the same time kindly let me know instead of this "Assign local copy of" what can be used.I am in 4.7c.

All in all I need to get an error "Trying to access an unassigned field symbol"

Thanks,

K.Kiran.

0 Kudos

Thanks everyody for the info.

K.Kiran.