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: 

Reg ALV

Former Member
0 Kudos

Hi Experts,

I need some help on the ALV grid display my requirement is like the following.

Comany code: Description:

plant : Plant description:

Matno Mat Description storage location M atgroup Batch

<Data Here>

That means I have to display the details of mat and all for every new Comp code and Plant I have the data n my my int tables for all these.

I don't have much idea abt ALV can some body give some detali steps so that I can do My self.

Thanks&Regards

Mahesh

5 REPLIES 5

Former Member

rajeshkumar_kaveti
Participant
0 Kudos

Hi,

You can do this using the FM REUSE_ALV_HIERSEQ_LIST_DISPLAY.

It requires two internal tables: Header & Item.

header should conatian Company code & Plant.

Item : Matno Mat Description storage location M atgroup Batch.

Explore other parameters in FM.

Regards,

Rajesh

Former Member
0 Kudos

Hi,

Go thru this links it may help you.

http://www2.warwick.ac.uk/services/finance/sap/training/reporting4.7/output

ttp://www.sapdevelopment.co.uk/reporting/alvhome.htm

Thanks

Sunil

Former Member
0 Kudos

hi

good

go through this sample ALV REPORT

REPORT ZALV_SAMPLE .

TABLES VBAK.

DATA it_vbak LIKE VBAK OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN uline.

PARAMETERS: ALV1 RADIOBUTTON GROUP ALV, "REUSE_ALV_LIST_DISPLAY

ALV2 RADIOBUTTON GROUP ALV, "REUSE_ALV_POPUP_TO_SELECT

ALV3 RADIOBUTTON GROUP ALV, "REUSE_ALV_GRID_DISPLAY

ALV4 RADIOBUTTON GROUP ALV. " NORMAL DISPLAY

SELECTION-SCREEN uline.

SELECT * FROM VBAK

INTO CORRESPONDING FIELDS OF TABLE it_vbak

UP TO 10 ROWS.

IF ALV1 = 'X'.

PERFORM ALV_FUNC1.

ELSEIF ALV2 = 'X'.

PERFORM ALV_FUNC2.

ELSEIF ALV3 = 'X'.

PERFORM ALV_FUNC3.

ELSEIF ALV4 = 'X'.

PERFORM NORM.

ENDIF.

&----


*& Form ALV_FUNC1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM ALV_FUNC1 .

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_STRUCTURE_NAME = 'VBAK'

TABLES

T_OUTTAB = it_vbak

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " ALV_FUNC1

&----


*& Form ALV_FUNC2

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM ALV_FUNC2 .

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

I_TITLE = 'SALES ORDER INFO'

I_ZEBRA = 'X'

I_TABNAME = 1

I_STRUCTURE_NAME = 'vbak'

TABLES

T_OUTTAB = it_vbak

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " ALV_FUNC2

&----


*& Form ALV_FUNC3

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM ALV_FUNC3 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_STRUCTURE_NAME = 'vbak'

I_GRID_TITLE = 'SALES ORDER INFO'

TABLES

T_OUTTAB = it_vbak

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " ALV_FUNC3

&----


*& Form NORM

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM NORM .

format intensified.

skip 1.

WRITE: /'SALES DOC.',

' Created on ',

' Time',

' Created by',

' Valid from ',

' Sold-to party'.

format intensified off.

skip 2.

LOOP AT it_vbak.

write: / it_vbak-vbeln,' ',

it_vbak-erdat,' ',

it_vbak-erzet,' ',

it_vbak-ERNAM,' ',

it_vbak-ANGDT,' ',

it_vbak-KUNNR.

endloop.

ENDFORM. " NORM

THANKS

mrutyun^

Former Member
0 Kudos

CHECK THE SAMPLE PROGRAM. BASIC PROGRAM FOR LEARNING ALV CONCEPTS.

&----


*& Report Z_REPT_ALV_EX1 *

*& *

&----


*& *

*& *

&----


report ZALV_GEN line-count 36(5)

line-size 225

no standard page heading.

************************************************************************

  • Report name: Puchase Order Report for ALV practice *

  • Program ID : Z_REPT_ALV_EX1_TG *

  • Author : ADCDEV ( T G Santosh ) *

  • Date : Sep 09, 2004 *

************************************************************************

*..Type Definitions for ALV Report

type-pools slis.

************************************************************************

  • Tables Declaration

************************************************************************

tables : lfa1,

lfb1,

lfm1.

************************************************************************

  • Data Declaration

************************************************************************

data : v_lifnr like lfa1-lifnr,

v_bukrs like lfb1-bukrs,

v_ekorg like lfm1-ekorg,

v_ktokk like lfa1-ktokk,

v_repid like sy-repid.

************************************************************************

  • Internal Tables

************************************************************************

data : begin of it_details occurs 0,

lifnr like lfa1-lifnr,

bukrs like lfb1-bukrs,

ekorg like lfm1-ekorg,

ktokk like lfa1-ktokk,

name1 like lfa1-name1,

stras like lfa1-stras,

ragio like lfa1-regio,

pfach like lfa1-pfach,

pstl2 like lfa1-pstl2,

pstlz like lfa1-pstlz,

telf1 like lfa1-telf1,

end of it_details.

data: it_fieldcatalog type slis_t_fieldcat_alv,

it_fieldcatalog1 type slis_t_fieldcat_alv,

wa_fieldcatalog type slis_fieldcat_alv,

wa_layout type slis_layout_alv,

it_events type slis_t_event,

wa_events type slis_alv_event,

it_sort type slis_t_sortinfo_alv,

wa_sort type slis_sortinfo_alv occurs 0 with header line.

************************************************************************

  • Initialization

************************************************************************

v_repid = sy-repid.

************************************************************************

  • Selecton Screen

************************************************************************

selection-screen begin of block blk1 with frame title text-001.

select-options : s_lifnr for lfa1-lifnr,

s_bukrs for lfb1-bukrs,

s_ekorg for lfm1-ekorg,

s_ktokk for lfa1-ktokk.

selection-screen end of block blk1.

selection-screen begin of block blk2 with frame title text-002.

parameter : block radiobutton group g1,

grid radiobutton group g1.

selection-screen end of block blk2.

************************************************************************

  • At Selecton Screen

************************************************************************

select single lifnr

from lfa1

into v_lifnr

where lifnr in s_lifnr.

if sy-subrc <> 0.

message i101(zsantosh) with 'v_lifnr' .

  • write : 'not a valid number', v_lifnr.

else.

select single bukrs

from lfb1

into v_bukrs

where bukrs in s_bukrs.

if sy-subrc <> 0.

message i101(zsantosh) with 'Company Code'.

else.

select single ekorg

from lfm1

into v_ekorg

where ekorg in s_ekorg.

if sy-subrc <> 0.

message i101(zsantosh) with 'Purchasing Organisation'.

else.

select single ktokk

from lfa1

into v_ktokk

where ktokk in s_ktokk.

if sy-subrc <> 0.

message i101(zsantosh) with 'Vendor Group'.

endif.

endif.

endif.

endif.

************************************************************************

  • Start of Selection

************************************************************************

start-of-selection.

select a1~lifnr

b1~bukrs

m1~ekorg

a1~ktokk

a1~name1

a1~stras

a1~regio

a1~pfach

a1~pstl2

a1~pstlz

a1~telf1

into table it_details

from lfa1 as a1

join lfb1 as b1 on a1lifnr = b1lifnr

join lfm1 as m1 on a1lifnr = m1lifnr

where a1~lifnr in s_lifnr and

b1~bukrs in s_bukrs and

m1~ekorg in s_ekorg and

a1~ktokk in s_ktokk.

clear wa_sort.

wa_sort-spos = 1.

wa_sort-fieldname = 'LIFNR'.

wa_sort-tabname = 'IT_DETAILS'.

wa_sort-up = 'X'.

append wa_sort to it_sort.

clear wa_sort.

wa_sort-spos = 2.

wa_sort-fieldname = 'BUKRS'.

wa_sort-tabname = 'IT_DETAILS'.

wa_sort-up = 'X'.

append wa_sort to it_sort.

clear wa_sort.

wa_sort-spos = 3.

wa_sort-fieldname = 'EKORG'.

wa_sort-tabname = 'IT_DETAILS'.

wa_sort-up = 'X'.

append wa_sort to it_sort.

************************************************************************

  • End of selection

************************************************************************

end-of-selection.

perform fill_fieldcat.

loop at it_fieldcatalog into wa_fieldcatalog.

if wa_fieldcatalog-fieldname = 'RAGIO'.

wa_fieldcatalog-intlen = 2.

wa_fieldcatalog-ref_fieldname = ''.

wa_fieldcatalog-ref_tabname = ''.

wa_fieldcatalog-ddic_outputlen = 2.

endif.

wa_fieldcatalog-ref_fieldname = ''.

wa_fieldcatalog-ref_tabname = ''.

modify it_fieldcatalog from wa_fieldcatalog.

endloop.

perform fill_layout.

if block = 'X'.

perform list_block_display.

elseif grid = 'X'.

perform list_grid_display.

endif.

&----


*& Form FILL_FIELDCAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fill_fieldcat .

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'IT_DETAILS'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

changing

ct_fieldcat = it_fieldcatalog

exceptions

inconsistent_interface = 1

program_error = 2

others = 3

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " FILL_FIELDCAT

&----


*& Form FILL_LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fill_layout .

wa_layout-zebra = 'X'.

wa_layout-totals_text = 'TOTAL'.

wa_layout-colwidth_optimize = 'X'.

endform. " FILL_LAYOUT

&----


*& Form list_block_display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form list_block_display .

call function 'REUSE_ALV_BLOCK_LIST_INIT'

exporting

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IT_EXCLUDING =

.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = wa_layout

it_fieldcat = it_fieldcatalog

i_tabname = 'IT_DETAILS'

it_events = it_events

it_sort = it_sort

  • I_TEXT = ' '

tables

t_outtab = it_details

exceptions

program_error = 1

maximum_of_appends_reached = 2

others = 3

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'

  • EXPORTING

  • I_INTERFACE_CHECK = ' '

  • IS_PRINT =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

exceptions

program_error = 1

others = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " list_block_display

&----


*& Form LIST_GRID_DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form list_grid_display .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

i_structure_name = 'IT_DETAILS'

  • I_BACKGROUND_ID = ' '

i_grid_title = 'DETAILS IN GRID DISPLAY'

  • I_GRID_SETTINGS =

is_layout = wa_layout

it_fieldcat = it_fieldcatalog

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = it_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_details

exceptions

program_error = 1

others = 2

.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endform. " LIST_GRID_DISPLAY

IF USEFUL PLEASE PROVIDE POINTS

REGARDS,

DEEPTHI REDDY