Skip to Content
0
Former Member
Jun 06, 2008 at 11:33 AM

Dynamic ALV Internal table Problem

16 Views

Hi all,I have successfully built an IT using method 'create_dynamic_table'.But my problems are :

1)When Iam trying to select the data with multiple tables then it is short dumping.

2)I tried to oselect the data using one table,after selecting the data if I use FM REUSE_ALV_Grid_Display then it is showing short dump with error 'type conflict when calling FM'.

I never used field symbols before.PLZ complete my program or give me suffecient feedback.Here is my program :

DATA : g_tdref TYPE REF TO data,
       g_wdref TYPE REF TO data.

DATA : dats LIKE vbbe-mbdat,
       t_fieldcat TYPE lvc_t_fcat,
       wa_fieldcat TYPE lvc_s_fcat.

FIELD-SYMBOLS : <it_dyn> TYPE STANDARD TABLE,
                <wa_dyn>,
                <dyn_field>.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mbdat FOR dats.
SELECTION-SCREEN END OF BLOCK blk1.

wa_fieldcat-tabname = 'MSKA'.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.

APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.

wa_fieldcat-tabname = 'MSKA'.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-seltext = 'Material Number'.
wa_fieldcat-intlen = '18'.

APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.

wa_fieldcat-tabname = 'MAKT'.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.

APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.

wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = 'MBDAT'.
wa_fieldcat-datatype = 'CHAR'.
wa_fieldcat-intlen = '10'.

APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.

wa_fieldcat-tabname = 'VBBE'.
wa_fieldcat-fieldname = 'OMENG'.
wa_fieldcat-datatype = 'QUAN'.
wa_fieldcat-intlen = '10'.

APPEND wa_fieldcat TO t_fieldcat.
CLEAR : wa_fieldcat.


DATA : d TYPE i,
       v(02) TYPE n VALUE '0',
       day(8) TYPE c.

d = s_mbdat-high - s_mbdat-low + 1.

DO d TIMES.

  v = v + 1.

  CONCATENATE 'Day' v INTO day.

  wa_fieldcat-tabname = 'VBBE'.
  wa_fieldcat-fieldname = day.
  wa_fieldcat-datatype = 'DATS'.
  wa_fieldcat-seltext = day.
  wa_fieldcat-intlen = '8'.

  APPEND wa_fieldcat TO t_fieldcat.
  CLEAR : wa_fieldcat.

ENDDO.
*-----Building Dynamic internal table.

CALL METHOD cl_alv_table_create=>create_dynamic_table
  EXPORTING
    it_fieldcatalog = t_fieldcat
  IMPORTING
    ep_table        = g_tdref.

ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.

SELECT m~werks m~matnr v~omeng v~mbdat INTO CORRESPONDING FIELDS
OF TABLE <it_dyn> FROM mska AS m INNER JOIN vbbe AS v
ON m~posnr = v~posnr WHERE v~mbdat IN s_mbdat.