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

Using Field Symbols.

itabhishek9
Participant
0 Likes
437

Hi SDNites,

I have requirement where I have to populate different internal tables as per the values obtained. As of now I have used case statement which fills up the internal table based on case value.

Now I want that to eliminate and make the program dynamic. I am facing the problem in filling the internal table as I do not want to use case and if statements. Reason for not using case and if statement is that I have many internal table to fill and the same has to be repeated for different countries.

Can someone please suggest me the approach with examples.

Regards,

Abhi

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
410

It actually depends on what you really want to address. Is it a dynamic table or dynamic fields?

How you case statement looks like? Do you want to append something to the table? or do you want to address its fields? The information you provide is too general, based on this it is hard to to help you.

Just one hint. Addressing table with field symbols can be like


data: r_tab type ref to data.
field-symbols: <tab> type any table,
                        <wa> type any.

get reference of itab to r_tab.
assign r_tab->* to <tab>. "now <tab> "indicates" to the table itab

or by means of loops (so addressing line by line)


loop at itab assigning <wa>.
  "here <wa> "points" to line of itab
endloop.

or addressing line components


loop at itab assiginig <wa>.
assign component 'COMP_NAME' of structure <wa> to <field>.
if sy-subrc = 0.
   "here <field> "points" to component of strcture <wa>
endif.
endloop.

But as I said, your question is general hence the general answer.

Regards

Marcin

2 REPLIES 2
Read only

MarcinPciak
Active Contributor
0 Likes
411

It actually depends on what you really want to address. Is it a dynamic table or dynamic fields?

How you case statement looks like? Do you want to append something to the table? or do you want to address its fields? The information you provide is too general, based on this it is hard to to help you.

Just one hint. Addressing table with field symbols can be like


data: r_tab type ref to data.
field-symbols: <tab> type any table,
                        <wa> type any.

get reference of itab to r_tab.
assign r_tab->* to <tab>. "now <tab> "indicates" to the table itab

or by means of loops (so addressing line by line)


loop at itab assigning <wa>.
  "here <wa> "points" to line of itab
endloop.

or addressing line components


loop at itab assiginig <wa>.
assign component 'COMP_NAME' of structure <wa> to <field>.
if sy-subrc = 0.
   "here <field> "points" to component of strcture <wa>
endif.
endloop.

But as I said, your question is general hence the general answer.

Regards

Marcin

Read only

Former Member
0 Likes
410

Hi,

can u check the below example.

ata:BEGIN OF ty_updata,

bukrs TYPE bukrs, " Company code

monat TYPE monat, " Month

gjahr TYPE gjahr, " Year

END OF ty_updata.

data: tt_updata TYPE STANDARD TABLE OF ty_updata.

DATA: wa_updata TYPE ty_updata.

FIELD-SYMBOLS: <wa_updata> TYPE ty_updata.

Regards,

Raj.