Application Development 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: 

Dynamic ALV Internal table Problem

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

raja_narayanan2
Active Participant
0 Kudos

*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 OMENG FROM VBBE INTO CORRESPONDING FIELDS OF TABLE <IT_DYN> WHERE MBDAT IN S_MBDAT.

BREAK-POINT.

YOU WILL GET VALUES IN INTERNAL TABLE.

TO SOLVE YOUR ISSUE YOU SHOULD USE NUM INSTEAD OF DATS.

3 REPLIES 3

raja_narayanan2
Active Participant
0 Kudos

*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 OMENG FROM VBBE INTO CORRESPONDING FIELDS OF TABLE <IT_DYN> WHERE MBDAT IN S_MBDAT.

BREAK-POINT.

YOU WILL GET VALUES IN INTERNAL TABLE.

TO SOLVE YOUR ISSUE YOU SHOULD USE NUM INSTEAD OF DATS.

0 Kudos

Thanks for u r reply,I will try and let u know that worked or not.

As Iam new to this Dynamic ALV what should I do now to complete the code?

I never used field symbols b4 and searched SDN but I got all examples with field symbols.Can anyone PLZ complete the code or give me a CLEAR example to complete it.

Thanks.

uwe_schieferstein
Active Contributor
0 Kudos

Hello

Class cl_alv_table_create is out-dated and you should use the RTTI instead (if already available on your system).

For a sample report have a look at [Creating Flat and Complex Internal Tables Dynamically using RTTI|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI]

Final remark: if you are using dynamic itabs for selection you should use a dynamic WHERE clause as well.

Regards

Uwe