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

Field symbol assignment problem

Former Member
0 Likes
712

FIELD-SYMBOLS:<fs1> TYPE ANY,

<fs3> TYPE ANY.

fieldcat_ln-fieldname = 'SOD_ID'.

fieldcat_ln-tabname = 'IT_DASHBOARD'.

fieldcat_ln-datatype = 'CHAR'.

APPEND fieldcat_ln TO fieldcat.

  • APPEND wa_fieldcatalog TO gt_fieldcatalog_tot.

CLEAR fieldcat_ln.

fieldcat_ln-fieldname = 'BUSAREA'.

fieldcat_ln-tabname = 'IT_JRM'.

fieldcat_ln-datatype = 'CHAR'.

APPEND fieldcat_ln TO fieldcat.

  • APPEND wa_fieldcatalog TO gt_fieldcatalog_tot.

CLEAR fieldcat_ln.

LOOP AT gt_jrm.

AT NEW busarea.

CLEAR lv_field.

CONCATENATE 'BUSAREA-' gt_jrm-busarea INTO lv_field .

fieldcat_ln-fieldname = lv_field.

fieldcat_ln-tabname = 'IT_DASHBOARD'.

fieldcat_ln-datatype = 'CHAR'.

fieldcat_ln-outputlen = 5.

APPEND fieldcat_ln TO fieldcat.

  • APPEND wa_fieldcatalog TO gt_fieldcatalog_tot.

CLEAR fieldcat_ln.

ENDAT.

ENDLOOP.

ASSIGN fieldcat TO <fs3>.

ASSIGN COMPONENT 'SOD_ID' OF STRUCTURE <fs3> TO <fs1>.

<b> <fs1> = 'ZZZZZZ'.</b>

Getting the dump at the the line high-lighted above.

Pls. tell me what's the problem here.

Sreedevi

6 REPLIES 6
Read only

Former Member
0 Likes
680

Hi

The FIELDCATALOG hasn't the field SOD_ID, so the statament ASSIGN COMPONENT 'SOD_ID' OF STRUCTURE <fs3> TO <fs1> fails, and you'll have a dump when u insert a value in <fs1> because it isn't assigned yet.

You should write:

ASSIGN IT_DASHBOARD TO <FS3>.

ASSIGN COMPONENT 'SOD_ID' OF STRUCTURE <fs3> TO <fs1>.

IF SY-SUBRC = 0.

<FS1> = 'ZZZZ'.

ENDIF.

Max

Read only

0 Likes
680

the fieldcatalog is having SOD_ID as shown in the below code that I gave

fieldcat_ln-fieldname = 'SOD_ID'.

fieldcat_ln-tabname = 'IT_DASHBOARD'.

fieldcat_ln-datatype = 'CHAR'.

APPEND fieldcat_ln TO fieldcat.

CLEAR fieldcat_ln.

Read only

0 Likes
680

Hi

No! The table IT_DASHBOARD has field SOD_ID not FIELDCAT, fieldcat has only a record where the field FIELDNAME = 'SOD_ID':

or you write:

ASSIGN IT_DASHBOARD TO <FS3>.

ASSIGN COMPONENT 'SOD_ID' OF STRUCTURE <fs3> TO <fs1>.

IF SY-SUBRC = 0.

<FS1> = 'ZZZZ'.

ENDIF.

or you write:

fieldname = 'IT_DASHBOARD-SOD_ID'.

ASSIGN (FIELDNAME) TO <FS1>.

<FS1> = 'ZZZZ'.

Max

Read only

hymavathi_oruganti
Active Contributor
0 Likes
680

1) u cant assign structure

assign fieldcat to <fs3> directly like that.

u can do like below.

data:dref type ref to data.

create DATA dref type fieldcat.

assign dref->* to <fs3>.

field-symbols: <fs1> type any.

assign component 'SOD_ID' of structure <fs3> to <fs1>.

<fs1> = 'zzzz'.

Read only

0 Likes
680

actually i need to create dynamic table

so even fieldcatalog is dynamic in nature.

when I gave

<b>create DATA dref type fieldcat.</b>

it's giving error

as fieldcatalog is declared as shown below....

DATA: fieldcat TYPE slis_t_fieldcat_alv,

fieldcat_ln LIKE LINE OF fieldcat, "Field catalog

when I was coding in ABAP Objects I moved the dynamic field catalog table as shown below....

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt_fieldcatalog_tot

IMPORTING

ep_table = ref

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

ASSIGN ref->* TO <tabx>.

CREATE DATA dref LIKE LINE OF <tabx> .

ASSIGN dref->* TO <fs3> .

But If objects are not used how to create

<b>create DATA dref type fieldcat.</b>

Read only

0 Likes
680

Hi

I can't understand you want to do:

<u>create DATA dref type fieldcat.</u>

U shouldn't need it, but only:

DATA: MY_TABLE TYPE REF TO DATA,

WA TYPE REF TO DATA.

FIELD-SYMBOLS: <TAB> TYPE TABLE.

FIELD-SYMBOLS:<fs1> TYPE ANY,

<fs3> TYPE ANY.

fieldcat_ln-fieldname = 'SOD_ID'.

fieldcat_ln-datatype = 'CHAR'.

APPEND fieldcat_ln TO fieldcat.

  • APPEND wa_fieldcatalog TO gt_fieldcatalog_tot.

CLEAR fieldcat_ln.

fieldcat_ln-fieldname = 'BUSAREA'.

fieldcat_ln-datatype = 'CHAR'.

APPEND fieldcat_ln TO fieldcat.

  • APPEND wa_fieldcatalog TO gt_fieldcatalog_tot.

CLEAR fieldcat_ln.

LOOP AT gt_jrm.

AT NEW busarea.

CLEAR lv_field.

CONCATENATE 'BUSAREA-' gt_jrm-busarea INTO lv_field .

fieldcat_ln-fieldname = lv_field.

fieldcat_ln-tabname = 'IT_DASHBOARD'.

fieldcat_ln-datatype = 'CHAR'.

fieldcat_ln-outputlen = 5.

APPEND fieldcat_ln TO fieldcat.

  • APPEND wa_fieldcatalog TO gt_fieldcatalog_tot.

CLEAR fieldcat_ln.

ENDAT.

ENDLOOP.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = fieldcat

IMPORTING

ep_table = MY_TABLE

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

ASSIGN MY_TABLE->* TO <tab>.

CREATE DATA WA LIKE LINE OF <TAB> .

ASSIGN WA->* TO <fs3> .

ASSIGN COMPONENT 'SOD_ID' OF STRUCTURE <FS3> TO <FS1>.

<fs1> = 'ZZZZZZ'.

max