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: 

Assigning fields(data) to field symbos of table

Former Member
0 Kudos

Hi All,

Though there is lot of material available on the concept of field symbols I could not apply the logic of it to my problem. Hence posting this query.

I am creating dynamic internal table and want to populate that internal table with other itab.

i have created Field symbols now how to populate the part of the other itab to field symbols which

points to other itab.

My code is like

data : p_intab LIKE dfies-tabname .

data : begin of wbs occurs 0,

wbs type c,

objnr type proj-objnr,

end of wbs.

FIELD-SYMBOLS :

<fs_tab> LIKE LINE OF tab_info,

        • Output Structure****

<it_disptab> TYPE table .

p_intab = fieldcatalog.

ASSIGN p_intab TO <fs_tab>-tabname .

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = <fs_tab>-tabname

CHANGING

ct_fieldcat = it_grid_fcat.

*Creating internal table

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_grid_fcat

IMPORTING

ep_table = dref.

ASSIGN dref->* TO <it_disptab>.

PERFORM populate_grid_data .

CALL METHOD grid->set_table_for_first_display

EXPORTING

is_layout = struct_grid_lset

CHANGING

it_outtab = <it_disptab>

it_fieldcatalog = it_grid_fcat

. " Period

form populate_grid_data.

*i want to populate the fields of dynamic internal table <it_disptab>

with wbs

endform.

*once i display it to user he will edit the values that i want to save it back to transperant table from fields symbols <it_disptab>.

Best Regards

Sandeep

6 REPLIES 6

Former Member
0 Kudos

Hi Sandeep,

It would be a pleasure replying to the post if you were to give the actual code you are using ( in full ). For instance, what is <b>tab_info</b> in this code?

The ABAP compiler fails to understand that !! And So do I. As it is Field-symbols make the programming generic enough and we cannot have generic problem descriptions as well.:-)

Regards,

Anand Mandalika.

Former Member
0 Kudos

Hi Sandeep,

within your form routine you can do the following:

form populate_grid_data.

*i want to populate the fields of dynamic internal table <it_disptab>

with wbs

1. create work area for your table

data: l_lineref type ref to data.

field-symbols: <l_line> type any.

create data l_lineref like line of <it_disptab>.

assign l_lineref->* to <l_line>.

  • case you have identical named fields

move corresponding wbs to <l_line>.

append <l_line> to <it_disptab>.

  • case the fieldnames are different

field-symbols: <fs_target1>,

<fs_target2>.

assign component 'Fieldname' of structure <l_line>

to <fs_target1>.

<fs_target1> = wbs-wbs.

assign component 'Fieldname' of structure <l_line>

to <fs_target2>.

<fs_target2> = wbs-objnr.

append <l_line> to <it_disptab>.

endform.

Hope it helps.

regards

Siggi

0 Kudos

Hi All,

Sorry I cant give full code as it is too big. By the way tab_info refers to structure dfies.

Siggi

when i add following code to my code it gives error as

<l_line-> is not a structure or internal table with header line.

*******

DATA: l_lineref TYPE REF TO data.

FIELD-SYMBOLS: <l_line> TYPE ANY.

CREATE DATA l_lineref LIKE LINE OF <it_disptab>.

ASSIGN l_lineref->* TO <l_line>.

LOOP AT i_wbs_element.

MOVE-CORRESPONDING i_wbs_element TO <l_line>.

APPEND <l_line> TO <it_disptab>.

********

Best Regards

Sandeep

0 Kudos

Hi Sandeep,

in that case, I think there is something wrong with your <it_disptab>, because l_line should be a line of <it_disptab>. But what about the other option, having some more field symbols for the target fields? Did you try that too?

regards

Siggi

0 Kudos

Hi Sandeep,

I would like to refer yo to this post, where I hope you will find the answer.

Regards,

Anand Mandalika.

0 Kudos

thanks all for response

Message was edited by: SANDEEP MUJUMDAR