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

error in creating dynamic alv

former_member574106
Participant
0 Likes
1,085

Hi friends,

I am creating a dynamic alv for the first time. It is getting activated , but on executing  a dump is coming. I checked a similar dump in the blogs, but on making changes in the code, the solution is not coming. What is the error? Please check the attachment.

Regards,

Saurav Lahiry

Hi friends,

I am creating a dynamic alv for the first time. It is getting activated , but on executing  a dump is coming. I checked a similar dump in the blogs, but on making changes in the code, the solution is not coming. What is the error? Please check the attachment.

Regards,

Saurav Lahiry

6 REPLIES 6
Read only

Former Member
0 Likes
1,054

Hello,

You did not show the usefull part of the dump But I guess you have a issue with the field symbols

<gfs_dyn_table> (or one of the others). First thing: you should check the return code after you assign a field-symbols (so to avoid the dump).

Then you could send the part of the dump that gives which line is dumping...

Then you should use RTTS classes in order to create your dynamic table instead of that ugly create_dynamic_table method, but that's another story (with plenty of example over the web)

Cheers,

Manu.

Read only

0 Likes
1,054

Hi Manu,

Thanks a lot for the tips. But it is still not clear to me how to correct the error . Please check the below code.

The dump is happening here.

<fs1> = wa_table-amt.

The complete code is given for ur reference.

*&---------------------------------------------------------------------*

*& Report  ZDYNAMIC

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT ZDYNAMIC.

DATA : lw_fcat TYPE lvc_s_fcat,

       lt_fcat TYPE lvc_t_fcat,

       gt_dyn_table TYPE REF TO data,

       gw_line TYPE REF TO data,

       gw_line1 TYPE REF TO data.

*       gt_dyn_table TYPE REF TO data.

DATA : fname TYPE string,

gv_pos TYPE i.

TYPES : BEGIN OF ty_table,

        vend(6) TYPE c,

        amt TYPE i,

        month(6) TYPE c,

        END OF ty_table.

DATA : i_table TYPE STANDARD TABLE OF ty_table WITH HEADER LINE,

       wa_table TYPE ty_table.

FIELD-SYMBOLS : <fs1>,

                <gfs_line>,

                <gfs_line1>,

                <gfs_dyn_table> TYPE STANDARD TABLE.

wa_table-vend = 'V100'.

wa_table-amt  = '100.00'.

wa_table-month = 'JAN'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

wa_table-vend = 'V100'.

wa_table-amt  = '200.00'.

wa_table-month = 'FEB'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

*Creating fieldcatalog

gv_pos = gv_pos + 1.

lw_fcat-fieldname = 'VEND'.

lw_fcat-outputlen = 5.

lw_fcat-tabname   = 'IT_DEMO'.

lw_fcat-coltext   = 'VENDOR'.

lw_fcat-col_pos   = gv_pos.

lw_fcat-key       = 'X'.

lw_fcat-key_sel   = 'X'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

*Loop through the internal table for creating a distinct month in the

*internal table

LOOP AT i_table INTO wa_table.

gv_pos = gv_pos + 1.

CONCATENATE wa_table-month '13' INTO fname.

READ TABLE lt_fcat INTO lw_fcat WITH KEY fieldname = wa_table-month.

IF sy-subrc NE 0.

lw_fcat-fieldname = wa_table-month.

lw_fcat-tabname   = 'I_TABLE'.

lw_fcat-coltext   = fname.

lw_fcat-outputlen   = 10.

lw_fcat-col_pos    = gv_pos.

APPEND lw_fcat TO lt_fcat.

*Create a dynamic internal table with this structure

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

*    I_STYLE_TABLE             =

IT_FIELDCATALOG           = lt_fcat

*    I_LENGTH_IN_BYTE          =

IMPORTING

EP_TABLE                  = gt_dyn_table

*    E_STYLE_FNAME             =

* EXCEPTIONS

*    GENERATE_SUBPOOL_DIR_FULL = 1

*    others                    = 2

        .

IF SY-SUBRC <> 0.

* Implement suitable error handling here

  1. ENDIF.

*Assign the new table to field symbol

ASSIGN gt_dyn_table->* TO <gfs_dyn_table>.

*Create dynamic work area

CREATE DATA gw_line LIKE LINE OF <gfs_dyn_table>.

CREATE DATA gw_line1 LIKE LINE OF <gfs_dyn_table>.

ASSIGN gw_line->* TO <gfs_line>.

ASSIGN gw_line1->* TO <gfs_line1>.

* Populate the dynamic table

LOOP AT i_table INTO wa_table.

ASSIGN COMPONENT lw_fcat-fieldname OF STRUCTURE <gfs_line> TO <fs1>.

<fs1> = wa_table-amt.

UNASSIGN <fs1>.

ENDLOOP.

ENDIF.

CLEAR : wa_table.

ENDLOOP.

APPEND <gfs_line> TO <gfs_dyn_table>.

CLEAR : <gfs_line>.

CLEAR : wa_table.

Regards,

Saurav Lahiry

Read only

Patrick_vN
Active Contributor
0 Likes
1,054

Your report tries to access an unassigned field symbol. From the dump i cannot say at which point the error occurs.

I suggest you debug and keep an eye on sy-subrc at the ASSIGN commands.. if all are assigned correctly chances are the report tries to access a field symbol that where someone forgot to assign.

Read only

0 Likes
1,054

Hi Patrick,

Thanks a lot for the tips. But it is still not clear to me how to correct the error . Please check the below code.

The dump is happening here.

<fs1> = wa_table-amt.

The complete code is given for ur reference.

*&---------------------------------------------------------------------*

*& Report  ZDYNAMIC

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT ZDYNAMIC.

DATA : lw_fcat TYPE lvc_s_fcat,

       lt_fcat TYPE lvc_t_fcat,

       gt_dyn_table TYPE REF TO data,

       gw_line TYPE REF TO data,

       gw_line1 TYPE REF TO data.

*       gt_dyn_table TYPE REF TO data.

DATA : fname TYPE string,

gv_pos TYPE i.

TYPES : BEGIN OF ty_table,

        vend(6) TYPE c,

        amt TYPE i,

        month(6) TYPE c,

        END OF ty_table.

DATA : i_table TYPE STANDARD TABLE OF ty_table WITH HEADER LINE,

       wa_table TYPE ty_table.

FIELD-SYMBOLS : <fs1>,

                <gfs_line>,

                <gfs_line1>,

                <gfs_dyn_table> TYPE STANDARD TABLE.

wa_table-vend = 'V100'.

wa_table-amt  = '100.00'.

wa_table-month = 'JAN'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

wa_table-vend = 'V100'.

wa_table-amt  = '200.00'.

wa_table-month = 'FEB'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

*Creating fieldcatalog

gv_pos = gv_pos + 1.

lw_fcat-fieldname = 'VEND'.

lw_fcat-outputlen = 5.

lw_fcat-tabname   = 'IT_DEMO'.

lw_fcat-coltext   = 'VENDOR'.

lw_fcat-col_pos   = gv_pos.

lw_fcat-key       = 'X'.

lw_fcat-key_sel   = 'X'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

*Loop through the internal table for creating a distinct month in the

*internal table

LOOP AT i_table INTO wa_table.

gv_pos = gv_pos + 1.

CONCATENATE wa_table-month '13' INTO fname.

READ TABLE lt_fcat INTO lw_fcat WITH KEY fieldname = wa_table-month.

IF sy-subrc NE 0.

lw_fcat-fieldname = wa_table-month.

lw_fcat-tabname   = 'I_TABLE'.

lw_fcat-coltext   = fname.

lw_fcat-outputlen   = 10.

lw_fcat-col_pos    = gv_pos.

APPEND lw_fcat TO lt_fcat.

*Create a dynamic internal table with this structure

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

*    I_STYLE_TABLE             =

IT_FIELDCATALOG           = lt_fcat

*    I_LENGTH_IN_BYTE          =

IMPORTING

EP_TABLE                  = gt_dyn_table

*    E_STYLE_FNAME             =

* EXCEPTIONS

*    GENERATE_SUBPOOL_DIR_FULL = 1

*    others                    = 2

        .

IF SY-SUBRC <> 0.

* Implement suitable error handling here

  1. ENDIF.

*Assign the new table to field symbol

ASSIGN gt_dyn_table->* TO <gfs_dyn_table>.

*Create dynamic work area

CREATE DATA gw_line LIKE LINE OF <gfs_dyn_table>.

CREATE DATA gw_line1 LIKE LINE OF <gfs_dyn_table>.

ASSIGN gw_line->* TO <gfs_line>.

ASSIGN gw_line1->* TO <gfs_line1>.

* Populate the dynamic table

LOOP AT i_table INTO wa_table.

ASSIGN COMPONENT lw_fcat-fieldname OF STRUCTURE <gfs_line> TO <fs1>.

<fs1> = wa_table-amt.

UNASSIGN <fs1>.

ENDLOOP.

ENDIF.

CLEAR : wa_table.

ENDLOOP.

APPEND <gfs_line> TO <gfs_dyn_table>.

CLEAR : <gfs_line>.

CLEAR : wa_table.

Regards,

Saurav Lahiry

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,054

lw_fcat-fieldname is initial, so I doubt of success of


ASSIGN COMPONENT lw_fcat-fieldname OF STRUCTURE <gfs_line> TO <fs1>.

Read again your code and move one ENDLOOP at a better (and correct) line of source


Hint: Try to create the dynamic table only once.


Regards,

Raymond

Read only

0 Likes
1,054

Hi Raymond,

Thanks a lot for the tips. But it is still not clear to me how to correct the error . Please check the below code.

The dump is happening here.

<fs1> = wa_table-amt.

The complete code is given for ur reference.

*&---------------------------------------------------------------------*

*& Report  ZDYNAMIC

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT ZDYNAMIC.

DATA : lw_fcat TYPE lvc_s_fcat,

       lt_fcat TYPE lvc_t_fcat,

       gt_dyn_table TYPE REF TO data,

       gw_line TYPE REF TO data,

       gw_line1 TYPE REF TO data.

*       gt_dyn_table TYPE REF TO data.

DATA : fname TYPE string,

gv_pos TYPE i.

TYPES : BEGIN OF ty_table,

        vend(6) TYPE c,

        amt TYPE i,

        month(6) TYPE c,

        END OF ty_table.

DATA : i_table TYPE STANDARD TABLE OF ty_table WITH HEADER LINE,

       wa_table TYPE ty_table.

FIELD-SYMBOLS : <fs1>,

                <gfs_line>,

                <gfs_line1>,

                <gfs_dyn_table> TYPE STANDARD TABLE.

wa_table-vend = 'V100'.

wa_table-amt  = '100.00'.

wa_table-month = 'JAN'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

wa_table-vend = 'V100'.

wa_table-amt  = '200.00'.

wa_table-month = 'FEB'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

*Creating fieldcatalog

gv_pos = gv_pos + 1.

lw_fcat-fieldname = 'VEND'.

lw_fcat-outputlen = 5.

lw_fcat-tabname   = 'IT_DEMO'.

lw_fcat-coltext   = 'VENDOR'.

lw_fcat-col_pos   = gv_pos.

lw_fcat-key       = 'X'.

lw_fcat-key_sel   = 'X'.

APPEND wa_table TO i_table.

CLEAR  wa_table.

*Loop through the internal table for creating a distinct month in the

*internal table

LOOP AT i_table INTO wa_table.

gv_pos = gv_pos + 1.

CONCATENATE wa_table-month '13' INTO fname.

READ TABLE lt_fcat INTO lw_fcat WITH KEY fieldname = wa_table-month.

IF sy-subrc NE 0.

lw_fcat-fieldname = wa_table-month.

lw_fcat-tabname   = 'I_TABLE'.

lw_fcat-coltext   = fname.

lw_fcat-outputlen   = 10.

lw_fcat-col_pos    = gv_pos.

APPEND lw_fcat TO lt_fcat.

*Create a dynamic internal table with this structure

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

*    I_STYLE_TABLE             =

IT_FIELDCATALOG           = lt_fcat

*    I_LENGTH_IN_BYTE          =

IMPORTING

EP_TABLE                  = gt_dyn_table

*    E_STYLE_FNAME             =

* EXCEPTIONS

*    GENERATE_SUBPOOL_DIR_FULL = 1

*    others                    = 2

        .

IF SY-SUBRC <> 0.

* Implement suitable error handling here

  1. ENDIF.

*Assign the new table to field symbol

ASSIGN gt_dyn_table->* TO <gfs_dyn_table>.

*Create dynamic work area

CREATE DATA gw_line LIKE LINE OF <gfs_dyn_table>.

CREATE DATA gw_line1 LIKE LINE OF <gfs_dyn_table>.

ASSIGN gw_line->* TO <gfs_line>.

ASSIGN gw_line1->* TO <gfs_line1>.

* Populate the dynamic table

LOOP AT i_table INTO wa_table.

ASSIGN COMPONENT lw_fcat-fieldname OF STRUCTURE <gfs_line> TO <fs1>.

<fs1> = wa_table-amt.

UNASSIGN <fs1>.

ENDLOOP.

ENDIF.

CLEAR : wa_table.

ENDLOOP.

APPEND <gfs_line> TO <gfs_dyn_table>.

CLEAR : <gfs_line>.

CLEAR : wa_table.

Regards,

Saurav Lahiry