2006 Oct 30 9:04 AM
Hi abappers
I am using the FM REUSE_ALV_HIERSEQ_LIST_DISPLAY to generate a classic style ALV, i want this to be displayed in ALV grid , how can i do this without making very drastic change to the code.
secondly my requirement is to place a button in the application bar of the ALV grid, when the user clicks on button the list should be downloaded as a EXCEL sheet.I dont want to use the CREATE A LOCAL FILE OPTION. any sample code is welcome.
Regards
Naren
Hi abappers
I am using the FM REUSE_ALV_HIERSEQ_LIST_DISPLAY to generate a classic style ALV, i want this to be displayed in ALV grid , how can i do this without making very drastic change to the code.
secondly my requirement is to place a button in the application bar of the ALV grid, when the user clicks on button the list should be downloaded as a EXCEL sheet.I dont want to use the CREATE A LOCAL FILE OPTION. any sample code is welcome.
Regards
Naren
2006 Oct 30 9:07 AM
for downloading into xls file..
call fm gui_download..exporting type of file as 'XLS'.
regards,
santhosh
2006 Oct 30 9:08 AM
I am not sure but I think When u r using REUSE_ALV_HIERSEQ_LIST_DISPLAY, u cannot convert it in grid.
U can have button on application toolbar.
You just have to use the new pf status in your report program.
You should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 >Programming SubObjects> Gui Status.
Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.
Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.
Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality.
Have a look at below code for using the new status.
TYPE-POOLS: slis.
DATA: i_qmel LIKE qmel OCCURS 0.
data v_repid type repid.
SELECT * FROM qmel INTO TABLE i_qmel.
v_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
i_structure_name = 'QMEL'
TABLES
t_outtab = i_qmel
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.
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'TEST'.
endform.
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
data lv_ucomm type sy-ucomm.
lv_ucomm
= sy-ucomm.
CASE lv_ucomm.
WHEN 'BUTTON'. "Double Click line Item
**Write ur functinality here
endcase.
endform.
Also have a look at below links.
http://www.sap-basis-abap.com/abap/add-button-to-alv-toolbar-with-reuse-alv-list-display.htm
Best Regards,
Vibha
*Please mark all the helpful answers
2006 Oct 30 9:08 AM
Hi,
Better would be that you go to SE80
Enter package/development class as 'SLIS'.
You shall get lots of sample ALV codes.
I am damn sure your all issues including given will be solved.
Hope this will help you to get started
2006 Oct 30 9:13 AM
Hi,
morever,
I want to display the first item level with n number of fields and the second item with n+1 number of fields is this possible(there are only 2 items). can this be done. with the current function module i am using (REUSE_ALV_HIERSEQ_LIST_DISPLAY).or is there someother way of doing it?
i am trying to imitate the sap standard program RFDAUB00 with the above added feature.
Regards
Naren
2006 Oct 30 9:14 AM
hi,
to add a button.
<b>1.</b> first u copy the standard PF status and add ur button.
how to do this?
see this.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
----
FORM SET_PF_STATUS *
----
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZNEWSTATUS'.
"Copy of 'STANDARD' pf_status from fgroup SALV
ENDFORM.
***********copy pf status***********
1)goto se80
2)open function group SALV
3) In that STANDARD gui-status will be there.
4)right click on that and ther is option of copy
5)just copy it and save it with ur name 'status_name'.
6) now in ur program SET PF-STATUS '(status_name)'.
7)don't forget to active it again
<b>2)<i> how to down load to excel.</i></b>
REPORT ZSRIM_GUI_DOWNLOAD_TO_EXCEL.
data : itab type mara occurs 0 with header line.
select * into itab
from mara
up to 10 rows.
append itab.
endselect.
data : begin of itab1 occurs 0,
line(50) type c,
end of itab1.
itab1-line = 'field1 description'.
append itab1.
itab1-line = 'field2 desc'.
append itab1.
itab1-line = 'field3 desc'.
append itab1.
*--and so on you have to add up the records in itab1.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = 'C:\ABCD.XLS '
FILETYPE = 'DAT'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH = FILELENGTH
TABLES
DATA_TAB = ITAB
FIELDNAMES = ITAB1
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<i>here u pass the same internal table u provide in the ALV rid to the above function module</i>
rgds
anver
pls mark points if hlped
2006 Oct 30 9:18 AM
any how u can dowload to excel file na ,
if u want to put a button.
create pf status,
and call parameter in alv function module
I_CALLBACK_PF_STATUS_SET = zpf-status name..
and
I_CALLBACK_USER_COMMAND = process_user_command(perfrom name(wrie from in ur program for this))
like
FORM process_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CLEAR ist_strv1.
CASE r_ucomm.
WHEN '&IC1'.
***************
******************
ENDCASE.
ENDFORM.
Ramesh