Thursday, September 23, 2010

ALV pop up to select the options and show them

report zalv_sample .

tables vbak.

data it_vbak like vbak occurs 0 with header line.

selection-screen begin of block b1 with frame.
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 end of block b1.

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
*&---------------------------------------------------------------------
*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
*&---------------------------------------------------------------------
*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
*&---------------------------------------------------------------------
*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
*&---------------------------------------------------------------------
*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

No comments:

Post a Comment