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: 

Dirty assign not working

Former Member
0 Kudos
717

Hi ,

I am new on using field symbols,

so i need some help.

i gor the below error for this code.

LOOP at <dyn_table_o> INTO <dyn_wa_r>.

assign component 'ALT_KUNNR' of structure <dyn_wa_r> to <fs>.

if sy-subrc = 0 and <fs> is not initial.

APPEND <dyn_wa_r> to <dyn_table_r>.

endif.

ENDLOOP.

error:

You attempted to access an unassigned field symbol

(data segment 32771).

This error may occur if

- You address a typed field symbol before it has been set with

ASSIGN

- You address a field symbol that pointed to the line of an

internal table that was deleted

- You address a field symbol that was previously reset using

UNASSIGN or that pointed to a local field that no

longer exists

- You address a global function interface, although the

respective function module is not active - that is, is

not in the list of active calls. The list of active calls

can be taken from this short dump.

what should i do?

Regards,

Harshit Rungta

Edited by: Julius Bussche on Jul 7, 2009 9:02 AM

Please use meaningfull subject titles.

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
175

Does <dyn_wa_r> have a component called ALT_KUNNR at runtime?

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
175

You might want to try using ASSIGNING instead of INTO.

loop at <dyn_table_o> ASSIGNING <dyn_wa_r>.

Regards,

Rich Heilman

Former Member
0 Kudos
175

Thanks Rich,

But i am again getting error at the line

APPEND <dyn_wa_r> to <dyn_table_r>.

I also tried with

ASSIGN <dyn_wa_r> to <dyn_table_r>.

but still getting the error.

Thanks,

Harshit Rungta

0 Kudos
175

Have you assigned <dyn_table_r> yet? You would need to do this before trying to append to it. How are you creating this dynamic internal table. Post the relevant code, please.

Regards,

Rich Heilman

Former Member
0 Kudos
175

FIELD-SYMBOLS :<dyn_table_r> TYPE STANDARD TABLE,

<dyn_wa_r> TYPE ANY.

ASSIGN <dyn_table_o> to <dyn_wa_r> .

ASSIGN <dyn_wa_r> to <dyn_table_r>.

*

field-symbols: <fs> type any.

LOOP at <dyn_table_o> ASSIGNING <dyn_wa_r>.

assign component 'ALT_KUNNR' of structure <dyn_wa_r> to <fs>.

if sy-subrc = 0 and <fs> is not initial.

APPEND <dyn_wa_r> to <dyn_table_r>.

endif.

ENDLOOP.

Hi Rich,

above is the code.

Its working now,

but the statement ASSIGN <dyn_table_o> to <dyn_wa_r> is transferring all the entries of the dyn table to the wa,

wheras i just want the structure of the same.

what should i do?

Regards,

Harshit Rungta

0 Kudos
175

Yes, you appear to be a bit confused about what you are trying to do. <dyn_table_r> must be created dynamically at runtime and assign thereafter. Something like....

FIELD-SYMBOLS :<dyn_table_r> TYPE STANDARD TABLE,
<dyn_wa_r> TYPE ANY.


data: o_ref type data.

* assume that <dyn_table_o> has already been created, and assigned.
create data o_ref like <dyn_table_o>.
assign o_ref->* to <dyn_table_r>.


field-symbols: <fs> type any.
LOOP at <dyn_table_o> ASSIGNING <dyn_wa_r>.
assign component 'ALT_KUNNR' of structure <dyn_wa_r> to <fs>.
if sy-subrc = 0 and <fs> is not initial.
APPEND <dyn_wa_r> to <dyn_table_r>.
endif.
ENDLOOP.

As you can see above, you must create the dynamic internal table <dyn_table_r>. You can base this from the <dyn_tab_o> if it already exists at runtime. I'm assuming that it does.

Regards,

Rich Heilman

Former Member
0 Kudos
175

Thanks a lot Rich,

But for the statement

data : o_ref type data.

I am getting the error

"DATA" is a generic type. A type reference is possible only for field

symbols and formal parameters . . . . . . . . . .

Regards,

Harshit Rungta

0 Kudos
175

oops, sorry. that should be TYPE REF TO DATA

data: oref type ref to data.

Regards,

Rich Heilman