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: 

ALV report using two internal tables.

Former Member
0 Kudos

I want to create a report having two internal tables. The first table consists of a matnr and maktx and the second table consist of matnr and all movement types that I want to display by column. Movement types varies depending on the criteria set by the user.

7 REPLIES 7

Former Member
0 Kudos

You can use function module REUSE_ALV_HIERSEQ_LIST_DISPLAY.

Check this documentation for more details -

FU REUSE_ALV_HIERSEQ_LIST_DISPLAY

____________________________________________________

Text

Hierarchical sequential list output

Functionality

This module outputs two internal tables as a formated hierarchical-sequential list.

Principle:

Pass an internal table containing the set of header information to be output.

Pass an internal table containing the set of item information to be output.

Pass a structure containing the general list layout details

Pass a field catalog in the form of an internal table. The field catalog describes the fields to be output in the list.

Notes

All interactions which are performed on the list refer directly to the internal output tables, e.g. sorting the list also sorts the passed internal output tables (passed by reference).

The expected output data quantity is an important consideration for the use of the tool or various generic functions (totals, subtotals).

The application must take account of this.

Parameters

I_INTERFACE_CHECK

I_CALLBACK_PROGRAM

I_CALLBACK_PF_STATUS_SET

I_CALLBACK_USER_COMMAND

IS_LAYOUT

IT_FIELDCAT

IT_EXCLUDING

IT_SPECIAL_GROUPS

IT_SORT

IT_FILTER

IS_SEL_HIDE

I_SCREEN_START_COLUMN

I_SCREEN_START_LINE

I_SCREEN_END_COLUMN

I_SCREEN_END_LINE

I_DEFAULT

I_SAVE

IS_VARIANT

IT_EVENTS

IT_EVENT_EXIT

I_TABNAME_HEADER

I_TABNAME_ITEM

I_STRUCTURE_NAME_HEADER

I_STRUCTURE_NAME_ITEM

IS_KEYINFO

IS_PRINT

IS_REPREP_ID

I_BYPASSING_BUFFER

I_BUFFER_ACTIVE

E_EXIT_CAUS ED_BY_CALLER

ES_EXIT_CAUS ED_BY_USER

T_OUTTAB_HEADER

T_OUTTAB_ITEM

Exceptions

PROGRAM_ERROR

Function Group

SALV

0 Kudos

Is it possible to change the format from row to column? The report displays the data in row format.

0 Kudos

I don't think we can change format from row to column. This is ALV functionality which will display details in Hierarchy format.

For eg

Material Material Description

Material Group Movement Type

MAT1 DESC1

GRP1 101

MAT2 DESC2

GRP2 102

0 Kudos

Oh, I see what you want to do. Maybe you should think of using a dynamic interal table with a dynamic ALV grid.

This way, you can build your internal table at runtime adding columns as needed. Here is a link to a weblog which describes using dynamic internal tables.

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

Regards,

Rich Heilman

0 Kudos

Thanks Rich. That was very helpful.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

There's no reason why you can't consolidate the data into one internal table and show in a standard ALV grid. Loop at the matnr/maktx internal table, then inside that loop, loop at the other internal where the matnr = the previous loop matnr, and append the data to another internal table. Then use this interal table to show in the ALV grid.

data: begin of imatnr occurs 0,
      matnr type mara-matnr,
      maktx type makt-maktx,
      end of imatnr.

data: begin of imseg occurs 0,
      matnr type mara-matnr,
      bwart type mseg-bwart,
      menge type mseg-menge,
      end of imseg.

data: begin of ialv occurs 0,
      bwart type mseg-bwart,
      matnr type mara-matnr,
      maktx type makt-maktx,
      menge type mseg-menge,
      end of ialv.

loop at imatnr.

move corresponding imatnr to ialv.
   loop at imseg where matnr = imatnr-matnr.
     ialv-bwart = imseg-bwart.
     ialv-menge = imseg-menge.
      append ialv.
   endloop.
Endloop.

Now use IALV in the ALV grid.

Welcome to SDN. Please remember to award points for all helpful answers and mark your posts as solved when solved completely. Thanks.

Regards,

Rich Heilman

0 Kudos

One more thing. The movement types will become my header, Ex.

541 542 543 544

qty amt qty amt qty amt qty amt

If matnr 2000000 has 5 movement types and 2000001 has 7 they all will be displayed except that the missing movement type for 200000 will display 0.