Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2175

Re: error in creating dynamic alv

$
0
0

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


Viewing all articles
Browse latest Browse all 2175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>