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: 

how to build a internal table of field symbols.

Former Member
0 Kudos

Hi,

I want to build a internal table, which consists of several field symbols. Each field symbol points to an entry of other internal tables. All of these tables have different structure definition. How can I implement it. If it is possible, it can save a lot of table query time.

I will be very appreciate for your help.

Best Regards, Jun

5 REPLIES 5

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Jun,

You need to create an internal table of data references. Now each row of the internal table can contain a data reference which can point to the internal table of your choice.

DATA: it_dref TYPE STANDARD TABLE OF REF TO DATA.

In order to access the individual tables, you just need to dereference the data reference to a field-symbol.

FIELD-SYMBOLS: <wa_dref> TYPE REF TO DATA,
<itab> TYPE STANDARD TABLE.

LOOP AT it_dref ASSIGNING <wa_dref>.
  ASSIGN <wa_dref>->* TO <itab>. 
ENDLOOP.

Hope i'm clear.

BR,

Suhas

Former Member
0 Kudos

Hi suhas,

Thanks for your reply. Could you explain more detailly how can I fill the table of data references.

eg. I have two internal tables:

it_first TYPE itabA

it_second TYPE itabB

And I will loop at each table and apped all rows of them to the it_dref.

Which kind of data should I declare and use.

Thank you very much!

Regards, Jun

Former Member
0 Kudos

I have tried with this.....

DATA: ls_first LIKE LINE OF gt_first,

wa_dref TYPE REF TO data.

LOOP AT gt_first REFERENCE INTO wa_dref.

APPEND wa_dref TO gt_dref.

ENDLOOP.

LOOP AT gt_second REFERENCE INTO wa_dref.

APPEND wa_dref TO gt_dref.

ENDLOOP.

it seems all of the entries from the both tables appear in table gt_dref. Another problem encountered is how to identify the ddic type of fied symbol while iterating

gt_dref.

Edited by: Jun Long on Oct 20, 2011 5:34 PM

sreenivas_pachva
Participant
0 Kudos

hello jun

i hope the following example give the some idea to build internal table fileds with differen field symbol data types.

FIELD-SYMBOLS:<f1> type any,<f2> TYPE ANY.

data:BEGIN OF itab,

t1 type i value 10,

t2(30) type c value 'john',

t3 type p DECIMALS 3 value '4.7658',

END OF itab.

ASSIGN itab to <f1>.

DO 3 TIMES.

ASSIGN COMPONENT sy-index OF STRUCTURE <f1> TO <f2>.

WRITE <f2>.

ENDDO.

'''''''''''''''''''''''''''''''''''''''''''''''''''''*************************************************

types:begin of it_line,

i1 type i,

t1 type string,

p1 type p DECIMALS 3,

end of it_line.

data:itab1 type table of it_line.

FIELD-SYMBOLS:<f1>.

ASSIGN itab1 to <f1>.

and also u can refer the following links

1-> http://help.sap.com/saphelp_wp/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm

2--> http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3923358411d1829f0000e829fbfe/content.htm

Thanks&Regards

sreenivas p

0 Kudos

Hello sreenivas p

Thanks.But I think the example shows only how to assign the component of a structure to field symbol, not for internal table.

Regards,

jun