Application Development and Automation 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: 
Read only

alv report

Former Member
0 Likes
2,091

am writting report that will list customer master data. i am using function REUSE_ALV_GRID_DISPLAY but then it allows only one internal table to be passed as interface parameter. i have created one internal table type for details in table kna1 but i also want to pick customer master sales data in table knvv. how do it or is there any beter way to write an alv grid report than what i have done.

below is an extract of my source code

TABLES: KNA1, knvv.

  • Data to be displayed

DATA: GT_kna1 TYPE TABLE OF kna1.

SELECT-OPTIONS: KUNNR FOR KNA1-KUNNR.

----


  • Selection

SELECT * FROM kna1 INTO TABLE GT_kna1

WHERE KUNNR IN KUNNR..

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_STRUCTURE_NAME = 'kNA1'

TABLES

T_OUTTAB = GT_KNA1.

am writting report that will list customer master data. i am using function REUSE_ALV_GRID_DISPLAY but then it allows only one internal table to be passed as interface parameter. i have created one internal table type for details in table kna1 but i also want to pick customer master sales data in table knvv. how do it or is there any beter way to write an alv grid report than what i have done.

below is an extract of my source code

TABLES: KNA1, knvv.

  • Data to be displayed

DATA: GT_kna1 TYPE TABLE OF kna1.

SELECT-OPTIONS: KUNNR FOR KNA1-KUNNR.

----


  • Selection

SELECT * FROM kna1 INTO TABLE GT_kna1

WHERE KUNNR IN KUNNR..

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_STRUCTURE_NAME = 'kNA1'

TABLES

T_OUTTAB = GT_KNA1.

2 REPLIES 2
Read only

Former Member
0 Likes
1,990

Hello,

If u want to display all the records of KNA1 & KNVV then use the ALV Heirarcy display:

<b>Use the demo report BALVHD01 ewith FM REUSE_ALV_HIERSEQ_LIST_DISPLAY</b>

If u want to REUSE_ALV_GRID_DISPLAY then take the data from KNA1 and KNVV and move to the final table and call the FM REUSE_ALV_GRID_DISPLAY

If useful reward.

Vasanth

Read only

Former Member
0 Likes
1,990

Hi,

I have done a similar program which picks data from 2 tables MARA and MARD

check this.

type-pools:slis.

DATA:BEGIN OF ITAB1 OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

END OF ITAB1.

DATA:BEGIN OF ITAB2 OCCURS 0,

MATNR LIKE MARA-MATNR,

WERKS LIKE MARD-WERKS,

END OF ITAB2.

TYPES:BEGIN OF TY_IT_FINAL,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

WERKS LIKE MARD-WERKS,

END OF TY_IT_FINAL.

DATA:IT_FINAL TYPE TABLE OF TY_IT_FINAL WITH HEADER LINE.

data:x_fcat type SLIS_FIELDCAT_ALV,

t_fcat type SLIS_T_FIELDCAT_ALV.

define build_fieldcat.

clear x_fcat.

x_fcat-fieldname = &1.

x_fcat-seltext_l = &2.

x_fcat-col_pos = &3.

x_fcat-outputlen = &4.

append x_fcat to t_fcat.

end-of-definition.

START-OF-SELECTION.

SELECT MATNR MTART FROM MARA

INTO TABLE ITAB1.

SELECT MATNR WERKS FROM MARD

INTO TABLE ITAB2

FOR ALL ENTRIES IN ITAB1

WHERE MATNR = ITAB1-MATNR.

LOOP AT ITAB1.

IT_FINAL-MATNR = ITAB1-MATNR.

IT_FINAL-MTART = ITAB1-MTART.

READ TABLE ITAB2 WITH KEY MATNR = ITAB1-MATNR.

IT_FINAL-WERKS = ITAB2-WERKS.

APPEND IT_FINAL.

ENDLOOP.

build_fieldcat:

'MATNR' 'Material No.' '1' '20',

'MTART' 'Material type' '2' '20',

'WERKS' 'Plant' '3' '10'.

<b>CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IT_FIELDCAT = t_fcat

TABLES

T_OUTTAB = it_final.</b>

Hope this helps.

Regards,