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

ASSIGN TABLE?

Former Member
0 Likes
901

I need access to an internal table from the call stack. So how do I use the ASSIGN statement to grab the contents of a table and then start looping at the table within my subroutine?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
850

Just tip, apart from above replies:

Check for SY-SUBRC value as 0, immediately after ASSIGN, other wise, it throws dump (OR) catch the system exception at root level and handle it.

Also, at the end use UNASSIGN for performence reasons.

thanq

7 REPLIES 7
Read only

franois_henrotte
Active Contributor
0 Likes
850

here is how to do it:

DATA: mem_name TYPE char60 VALUE '(REPID)TABNAME[]'.

FIELD-SYMBOLS: <table> TYPE ANY TABLE,

<struc> TYPE ANY.

ASSIGN (mem_name) TO <table>.

LOOP AT <table> ASSIGNING <struc>.

ENDLOOP.

Read only

0 Likes
850

... and for simplification please write

FIELD-SYMBOLS: 
  <table> TYPE TABLE,
  <struc> TYPE ANY.

ASSIGN ('(REPID)TABNAME[]') TO <table>.

LOOP AT <table> ASSIGNING <struc>.

ENDLOOP.

Regards,

Clemens

P.S. It was release 4.something that it was in the ABAP online help with the hint that it should not be used because it may be changed in the next release. They did not change anything since then but removed the documentation

Read only

0 Likes
850

> They did not change anything since then but removed the documentation

Are you sure? There have been a lot of changes in ABAP and I heard that (dirty ('(assign's) where on a list somewhere.

Certainly they have been security considerations...

Cheers,

Julius

Read only

Former Member
0 Likes
850

<misunderstanding_removed_by_moderator>

Edited by: Julius Bussche on Dec 23, 2009 11:33 PM

Read only

0 Likes
850

david,

no offense but please go though this to know about call stacks..

call stack

François has given a very good response to it...

@modos: please do the needful

Read only

0 Likes
850

Sorry, I misunderstood the question.

Best regards.

Read only

Former Member
0 Likes
851

Just tip, apart from above replies:

Check for SY-SUBRC value as 0, immediately after ASSIGN, other wise, it throws dump (OR) catch the system exception at root level and handle it.

Also, at the end use UNASSIGN for performence reasons.

thanq