05-26-2006 6:42 AM
Hi all,
I'm using REUSE_ALV_GRID_DISPLAY fm to display some data. In transactions like SE16N, there is a download to excel macros (EXPORT) button present in the ALV. Is it possible to bring in the same functionality using REUSE_ALV_GRID_DISPLAY. I can only see an EXPORT to local file button when using REUSE_ALV_GRID_DISPLAY.
Regards,
Vijay
05-26-2006 6:46 AM
Vijay,
I am not sure which specific option your mentioning but the standard toolbar gives all the options that SE16n gives.
Regards,
Ravi
05-26-2006 7:08 AM
It is the export button. It is present two one button after the print button.
Regards,
Vijay
05-26-2006 7:22 AM
Hi,
Sorry Vijay,
Not able to find such a button called "Export" after print button in SE16N.
Could you mention some other txn which has the same feature.
Regards,
Anjali
Message was edited by: Anjali Devi
05-26-2006 7:27 AM
05-26-2006 7:20 AM
HI
GOOD
THIS CANT BE DONE ONLY USING RESUE ALV GRID DISPLAY,YOU HAVE TO USE OTHER FUNCTIONALITY TO ACHIEVE THIS.
GO THROUGH THIS REPORT AND DO ACCORDINGLY .
YOU CAN SEARCH IS REPORT IN BCALV_GRID*
data: ok_code like sy-ucomm,
gt_sflight type table of sflight,
gs_sflight type sflight,
g_repid like sy-repid,
g_max type i value 100,
§ 1.Define a structure of type LVC_S_LAYO.
gs_layout type lvc_s_layo,
cont_for_flights type scrfname value 'BCALVC_EXCEPTION_D100_C1',
reference to custom container: neccessary to bind ALV Control
custom_container type ref to cl_gui_custom_container,
reference to ALV Control
grid1 type ref to cl_gui_alv_grid.
§ 2.Define an output table with a field to show exceptions of type C.
Remember the name of this additional field.
In this case: 'LIGHT'
data: begin of gt_outtab occurs 0.
include structure sflight.
data: light type c.
data: end of gt_outtab.
The name of the additional field has to be acquainted to ALV
in 'gs_layout-excp_fname' which is of type lvc_cifnm.
'g_lights_name' is defined for that purpose:
*
data: g_lights_name type lvc_cifnm value 'LIGHT'.
Set initial dynpro
set screen 100.
*----
*
FORM EXIT_PROGRAM *
*----
*
form exit_program.
call method grid1->free.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in FLush'(500).
endif.
leave program.
endform.
*&----
*
*& Module PBO_100 OUTPUT
*&----
*
text
*----
*
module pbo_100 output.
set pf-status 'MAIN100'.
set titlebar 'MAIN100'.
g_repid = sy-repid.
if custom_container is initial.
§ 5.Set a value for field LIGHT for each line of your output table.
You do not necessarily need to define a field catalog if
the rest of your output table is represented by a DDIC structure.
select data from table SFLIGHT
perform build_data tables gt_outtab[].
create object custom_container
exporting
container_name = cont_for_flights
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
endif.
create an instance of alv control
create object grid1
exporting i_parent = custom_container.
*..............................................
set some layout-values (Structure LVC_S_LAYO)
*..............................................
Set a titlebar for the grid control
*
gs_layout-grid_title = 'Flights'(100).
§ 3.Set field EXCP_FNAME of the structure of type LVC_S_LAYO
with the name of your additional field.
gs_layout-excp_fname = g_lights_name.
*.............................
show table on ALV Control
*.............................
§ 6.Provide your Layout-Structure when calling
'set_table_for_first_display' (Parameter I_LAYOUT).
call method grid1->set_table_for_first_display
exporting i_structure_name = 'SFLIGHT'
is_layout = gs_layout
changing it_outtab = gt_outtab[].
endif.
call method cl_gui_control=>set_focus exporting control = grid1.
Control Framework flushes at the end of PBO automatically!
endmodule. " PBO_100 OUTPUT
*&----
*
*& Module PAI_100 INPUT
*&----
*
text
*----
*
module pai_100 input.
case ok_code.
when 'BACK'.
perform exit_program.
when 'EXIT'.
perform exit_program.
when 'SWITCH'.
perform switch_led_style.
endcase.
clear ok_code.
endmodule. " PAI_100 INPUT
*&----
*
*& Form SELECT_TABLE_SFLIGHT
*&----
*
text
*----
*
<--P_GT_SFLIGHT text
*----
*
form build_data tables p_gt_outtab structure gt_outtab.
§ 5.Set a value for field LIGHT for each line of your output table.
You do not necessarily need to define a field catalog if
the rest of your output table is represented by a DDIC structure.
*
select data from SFLIGHT and copies it into 'p_gt_outtab' which
lines contain an additional field for the lights/leds.
(see definition of 'gt_outtab' in the global deklaration section)
ALV Control only provides the possibility to SHOW lights or LEDs.
You must provide your own program logic to determine threshholds.
*
In this example
the lights/leds are set according to the number of occupied seats.
This form changes some values of SEATSOCC to get a nice mixture
of different LEDs.
data: perc_occ type f, "perc_occ % seats are occupied
decision_value type i,
decision_value2 type i,
val0k3 type f,
val0k6 type f.
select * from sflight into table gt_sflight up to g_max rows.
loop at gt_sflight into gs_sflight.
move-corresponding gs_sflight to p_gt_outtab.
to show some red lights, some values of SEATSOCC are changed:
decision_value = p_gt_outtab-seatsmax - p_gt_outtab-seatsocc.
decision_value = decision_value mod 8.
decision_value2 = sy-tabix mod 10.
if decision_value = 0 or decision_value2 = 0.
p_gt_outtab-seatsocc = p_gt_outtab-seatsmax.
endif.
set lights according to percentage of occupied seats.
val0k3 = 3 / 10.
val0k6 = 6 / 10.
perc_occ = p_gt_outtab-seatsocc / p_gt_outtab-seatsmax.
if perc_occ = 1.
p_gt_outtab-light = '1'.
elseif perc_occ >= val0k3 and perc_occ < val0k6.
p_gt_outtab-light = '2'.
elseif perc_occ >= 0 and perc_occ < val0k3.
p_gt_outtab-light = '3'.
endif.
append p_gt_outtab.
endloop.
endform. " SELECT_TABLE_SFLIGHT
*&----
*
*& Form SWITCH_LED_STYLE
*&----
*
text
*----
*
--> p1 text
<-- p2 text
*----
*
form switch_led_style.
statics style type i.
if style is initial.
§ 4.Choose an exception style by using field EXCP_LED which is
as well a component of the structure of type LVC_S_LAYO.
gs_layout-excp_led = 'X'.
style = 1.
else.
gs_layout-excp_led = ' '.
style = 0.
endif.
call method grid1->set_frontend_layout
exporting is_layout = gs_layout.
call method grid1->refresh_table_display.
waiting for flush at PBO time...
endform. " SWITCH_LED_STYLE
THANKS
MRUTYUN
05-26-2006 7:26 AM
sorry Mrutyun,
I just found out that it can be done normally also. the code is &XXL. if this is there in ur gui status you can get an export to excel macros. thanks for the patient reply although