cancel
Showing results for 
Search instead for 
Did you mean: 

Internal table to field symbols

Former Member
0 Kudos
180

Hi All,

I know there is lot of discusstion available on the net / sdn for this but still I am not getting correct answer for this.

I have following piece of code. ( Field-symbol <data> which is a workarea of <it_disptab> ) now I want to transfer

the data of i_wbs of selectively fields to <data>, how do i do that? In the following code, system stores garbage value

if the datatype of field of <data> is curr. The structure of <data> and i_wbs is not same.

Data : begin of i_wbs occurs 0,

Pspnr like prps-pspnr,

Posid like prps-posid,

Wtges like coep-wtges,

End of i_wbs.

LOOP AT i_wbs.

MOVE i_wbs TO <data>.

APPEND <data> TO <it_disptab>.

ENDLOOP.

Best Regards

Sandeep

Accepted Solutions (0)

Answers (2)

Answers (2)

jayanthi_jayaraman
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Anand,

I am adding few more points .

data : begin of I_wbs occurs 0,

pspnr like prps-pspnr,

wtges like bpge-wtges,

end of i_wbs.

Field-symbols : <it_disptab> TYPE table ,

<data> TYPE ANY,

perform buildcatalog.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = fieldcatalog

IMPORTING

ep_table = dref.

ASSIGN dref->* TO <it_disptab>.

CREATE DATA is_file LIKE LINE OF <it_disptab>.

ASSIGN is_file->* TO <data>.

PERFORM populate_grid_data .

form buildcatalog.

fieldcatalog2-fieldname = 'POSID'.

fieldcatalog2-coltext = 'WBS'.

fieldcatalog2-outputlen = 24.

fieldcatalog2-col_pos = 0.

fieldcatalog2-key = 'X'.

fieldcatalog2-emphasize = 'X'.

fieldcatalog2-edit = space.

APPEND fieldcatalog2 TO fieldcatalog.

CLEAR fieldcatalog2.

colpos = colpos + 1.

fieldcatalog2-fieldname = 'PSPNR'.

fieldcatalog2-coltext = 'WBS Element'.

fieldcatalog2-outputlen = 8.

fieldcatalog2-no_out = 'X'.

fieldcatalog2-col_pos = colpos.

fieldcatalog2-key = 'X'.

fieldcatalog2-emphasize = 'X'.

fieldcatalog2-edit = space.

APPEND fieldcatalog2 TO fieldcatalog.

CLEAR fieldcatalog2.

colpos = colpos + 1.

colpos = colpos + 1.

fieldcatalog2-fieldname = 'WTGES'.

fieldcatalog2-coltext = 'Total Budget'.

fieldcatalog2-col_pos = colpos.

fieldcatalog2-outputlen = 15.

fieldcatalog2-just = 'R'.

  • fieldcatalog2-datatype = 'CURR'.

APPEND fieldcatalog2 TO fieldcatalog.

CLEAR fieldcatalog2.

LOOP AT proj_dur2.

CONCATENATE proj_dur2-year proj_dur2-period INTO fieldcatalog2-txt_field.

fieldcatalog2-fieldname = proj_dur2-month.

fieldcatalog2-coltext = proj_dur2-month.

fieldcatalog2-col_pos = colpos.

fieldcatalog2-outputlen = 15.

fieldcatalog2-decimals = 2.

fieldcatalog2-just = 'R'.

fieldcatalog2-no_zero = 'X'.

fieldcatalog2-edit = 'X'.

APPEND fieldcatalog2 TO fieldcatalog.

CLEAR fieldcatalog2.

colpos = colpos + 1.

ENDLOOP.

endform.

form populate_grid_data.

LOOP AT i_wbs.

MOVE i_wbs TO <data>.

APPEND <data> TO <it_disptab>.

ENDLOOP.

ENDFORM. " populate_grid_data

Message was edited by: SANDEEP MUJUMDAR

Former Member
0 Kudos

Oh my God! Sandeep, if this is exactly the code that you're using, then <b><data></b> is not even declared as a field-symbol. You have used the DATA statement to declare it !!

Former Member
0 Kudos

Hi,

Instead of

data : <it_disptab> TYPE table ,

<data> TYPE ANY,

It should be

<b>FIELD-SYMBOLS: <it_disptab> TYPE table ,

<data> TYPE ANY.</b>

Thansk & Regards,

Judith.

Former Member
0 Kudos

Hi Judith

It was typo mistake from my side , i have corrected it.

BR

Sandeep

Former Member
0 Kudos

Hi,

Can try this code

loop at i_wbs.

move i_wbs-f1 to <data>-f1.

move i_wbs-f2 to <data>-f2.

move i_wbs-f3 to <data>-f3.

append <data> to <it_disptab>.

endloop.

OR

Try this sample and get some idea

DATA: BEGIN OF line,

col1(1) TYPE c,

col2(1) TYPE c VALUE 'X',

END OF line.

<b>FIELD-SYMBOLS <fs> LIKE line.

ASSIGN line TO <fs>.</b>

MOVE <fs>-col2 TO <fs>-col1.

WRITE: <fs>-col1, <fs>-col2.

Can be done with in a loop too.

Also Check this link

http://help.sap.com/saphelp_46c/helpdata/en/fc/eb38c8358411d1829f0000e829fbfe/frameset.htm

Thanks & Regards,

Judith.

Former Member
0 Kudos

For the first code I already tried doing that but it says <data> is a structure without header line.

Former Member
0 Kudos

Could u plz paste ur code.

Including data definition for <data>.

Thanks & Regards,

Judith.

Former Member
0 Kudos

Hi Sandeep,

Please be as accurate in your posts as possible. Are you getting an error which says that a <i>structure does not have a header line</i> ?

Are you certain that the field symbol <data> is actually referring to a structure ? Well, it seems like it is not the case. Provide the declaration for the field-symbol <data> and also the ASSIGN statement for it.

Regards,

Anand Mandalika.