2016 Feb 24 1:14 PM
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
2016 Feb 24 1:44 PM
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.
2016 Mar 02 1:32 AM
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
*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
2016 Feb 24 2:16 PM
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.
2016 Mar 02 1:31 AM
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
*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
2016 Feb 24 2:18 PM
2016 Mar 02 1:28 AM
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
*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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |