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 internal table in ALV output

Former Member
0 Kudos

Dear Abapers,

I am doing a report where I need to create a dynamic internal, I am not much familiar with Oops so please advice.

My Requirement is:

In my selection screen I have.. bukrs , mtart and spmon( month & year )

First I need to select and display all materials from mara for a particular material type.

LOOP AT MONTH.
    SELECT MATNR
           MTART FROM MARA
                 INTO CORRESPONDING FIELDS OF S_MARA
                 WHERE MTART IN ('FERT','HALB','ROH','HIBE').
      S_MARA-MONTH = MONTH-MONT.
      APPEND S_MARA TO I_MARA.
    ENDSELECT.
  ENDLOOP.

If the user enters 01.2010 to 05.2010 in selection-screen.

My o/p header should be:

'Material Number'   'Jan 2010'  'Feb 2010'  'Mar 2010'  'Apr 2010'  'May 2010'

and corresponding Values of each month I need to fetch from different table.

Please advice

Edited by: Karthik R on May 10, 2010 12:23 PM

Edited by: Karthik R on May 10, 2010 12:25 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Karthik,

You can refer to my article in the below link on how to create a dynamic structure and dynamic internal table.

http://www.divulgesap.com/blog.php?p=MTI4

The example contains code sample for building a dynamic internal table for display with dynamic weeks.

Hope it helps.

Regards,

Ravikiran

4 REPLIES 4

Former Member
0 Kudos

Hi Karthik,

You can refer to my article in the below link on how to create a dynamic structure and dynamic internal table.

http://www.divulgesap.com/blog.php?p=MTI4

The example contains code sample for building a dynamic internal table for display with dynamic weeks.

Hope it helps.

Regards,

Ravikiran

0 Kudos

Dear Ravikiran C ,

Thank U !!

Can U please advice how to do the same using write statement.

Former Member
0 Kudos

Hi,

For the display in ALV output format ,* creating an instance of ALV.

TRY.

CALL METHOD cl_salv_table=>factory

you will surely get the expected result in the desired format.

Thanks

Rohini.

SuhaSaha
Advisor
Advisor
0 Kudos

First of all dynamic internal table has got nothing to do with OOPs.

Yes, if you want to use the RTTS classes thats OO. But i don't understand why do you fear OO ? Trust me it doesn't bite 😄

Anyways to answer your question, to read the contents of a dynamic internal table you need to use ASSIGN COMPONENT command. Further details on SDN & SAP help.

BR,

Suhas