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

Former Member
0 Kudos

Hi all,

I have written the following ALV report, can anyone of you please help me in making this report into ALV Tree report, any help will be appreciated.

REPORT ZTEST_REPORT

.

TYPE-POOLS: slis.

Data: begin of it_mara occurs 0,

matnr like mara-matnr,

mtart like mara-matkl ,

end of it_mara.

Data: begin of it_marc occurs 0,

matnr like marc-matnr,

mmsta like marc-mmsta,

werks like marc-werks,

end of it_marc.

DATA: fieldcat TYPE slis_t_fieldcat_alv.

DATA: repid TYPE syrepid.

repid = sy-repid.

select matnr matkl into table it_mara

from mara

where matkl eq '001'.

loop at it_mara.

select werks mmsta into table it_marc

from marc

where matnr eq it_mara-matnr.

clear it_mara.

endloop.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = repid

i_internal_tabname = 'IT_MARC'

i_inclname = repid

i_bypassing_buffer = 'X'

CHANGING

ct_fieldcat = fieldcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = fieldcat

TABLES

t_outtab = it_marc.

Thanks,

Rajeeev

2 REPLIES 2

former_member156446
Active Contributor
0 Kudos

Hi Rajeev

the field catalog need to be modifed a little..

CLEAR fieldcat.

fieldcat-fieldname = 'LIFNR'.

fieldcat-tabname = 'BESTAND'.

fieldcat-ref_tabname = 'MKOL'.

fieldcat-no_out = 'X'.

APPEND fieldcat.

ENDIF.

IF g_flag_sobkz-kunnr = 'X'.

CLEAR fieldcat.

fieldcat-fieldname = 'KUNNR'.

fieldcat-tabname = 'BESTAND'.

fieldcat-ref_tabname = 'MSKU'.

fieldcat-no_out = 'X'.

APPEND fieldcat.

ENDIF.

IF g_flag_sobkz-vbeln = 'X'.

CLEAR fieldcat.

fieldcat-fieldname = 'VBELN'.

fieldcat-tabname = 'BESTAND'.

fieldcat-ref_tabname = 'MSKA'.

fieldcat-no_out = 'X'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'POSNR'.

fieldcat-tabname = 'BESTAND'.

fieldcat-ref_tabname = 'MSKA'.

fieldcat-no_out = 'X'.

APPEND fieldcat.

ENDIF.

IF g_flag_sobkz-pspnr = 'X'.

CLEAR fieldcat.

fieldcat-fieldname = 'PSPNR'.

fieldcat-tabname = 'BESTAND'.

fieldcat-ref_tabname = 'MSPR'.

fieldcat-no_out = 'X'.

APPEND fieldcat.

ENDIF.

  • here starts the second row

  • Values

IF novalues IS INITIAL.

CLEAR fieldcat.

fieldcat-fieldname = 'DUMMY'.

fieldcat-tabname = 'BESTAND'.

fieldcat-row_pos = '2'.

fieldcat-outputlen = 9.

  • calculate the length of the dummy field

IF xmchb = 'X'.

ADD 11 TO fieldcat-outputlen.

ENDIF.

IF NOT pa_sond IS INITIAL.

ADD 29 TO fieldcat-outputlen.

ENDIF.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'WLABS'.

fieldcat-tabname = 'BESTAND'.

fieldcat-ref_fieldname = 'SALK3'.

fieldcat-ref_tabname = 'MBEW'.

fieldcat-cfieldname = 'WAERS'.

fieldcat-row_pos = '2'.

fieldcat-seltext_s = text-020.

fieldcat-seltext_m = text-020.

fieldcat-seltext_m = text-020.

fieldcat-do_sum = 'X'.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'WAERS'.

fieldcat-tabname = 'BESTAND'.

fieldcat-ref_fieldname = 'WAERS'.

fieldcat-ref_tabname = 'T001'.

fieldcat-row_pos = '2'.

fieldcat-outputlen = 5.

APPEND fieldcat.

CLEAR fieldcat.

fieldcat-fieldname = 'WUMLM'.

fieldcat-tabname = 'BESTAND'.

fieldcat-ref_fieldname = 'SALK3'.

fieldcat-ref_tabname = 'MBEW'.

fieldcat-cfieldname = 'WAERS'.

fieldcat-row_pos = '2'.

fieldcat-seltext_s = text-020.

fieldcat-seltext_m = text-020.

fieldcat-seltext_m = text-020.

fieldcat-outputlen = '18'.

fieldcat-do_sum = 'X'.

APPEND fieldcat.

CLEAR fieldcat.


CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_interface_check = l_f_check
i_callback_program = repid
is_layout = layout
it_fieldcat = fieldcat[]
i_default = 'X'
i_save = 'A'
is_variant = variante
it_events = gt_events[] "n667256
i_tabname_header = 'HEADER'
i_tabname_item = 'BESTAND'
is_keyinfo = keyinfo
is_print = alv_print
it_sort = sort[]
it_excluding = excluding[]
TABLES
t_outtab_header = header
t_outtab_item = bestand
EXCEPTIONS
OTHERS = 2.

Former Member
0 Kudos

go to transaction SE80 and choose development class and enter SLIS in the name and expand programs and select program BCALV_TREE_01...refer these sample programs,this will help in modifying your program.

please reward points.

Deepti.