Refersh Button/ ALV
Hi,
I want to add custom buttons for 'Refresh' in the existing row of the ALV grid
Any sample code on this please ?
Thanks,
Kumar
Hi,
data : lr_btnui_e_add TYPE REF TO cl_salv_wd_fe_button, " Ref to the button
lr_function_e_add TYPE REF TO cl_salv_wd_function. " Ref to the standard button
CREATE OBJECT lr_btnui_e_add.
lr_btnui_e_add->set_text( 'REFRESH' ).
DATA lo_value TYPE REF TO cl_salv_wd_config_table.
lo_value = lo_interfacecontroller->get_model(
lr_function_e_add =
LO_VALUE->if_salv_wd_function_settings~create_function( id = 'REFRESH' ).
where lo_value is the model of alv.......
This wil create a button on toolbar of alv...
Thanks,
Shailaja Ainala.
Similar Messages
-
Custom button ALV to download data to excel and word.
Hai Experts,
I have a requirement in which i need to add a button on the alv tool bar
which has the functionality of downloading the data in the alv to
word/excel/notepad..
i got the prcedure to download the data but my problemis how to capture the data in the alv into an internal table.
if i can capture the column headings and the data into an internal table, my problrm of downloading the data solves.
so please help how to capture the data along with the headings displayed in the
ALV into an internal table.
its urgent,,,,
Madhucheck this link for a guide how to add and remove buttons from the ALV in web dynpro:
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40794172-b95a-2910-fb98-b86d8a0918b4">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40794172-b95a-2910-fb98-b86d8a0918b4</a>
part of this document:
Get reference to ALV component and configuration model
To obtain a reference to the ALV component and its configuration model you can use the following code.
The configuration model can be used to set all sorts of properties of the ALV
DATA: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table,
r_table TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
* get reference to ALV component interface lr_salv_wd_table = wd_this->wd_cpifc_alvmain( ).
* get ConfigurationModel from ALV Component
wd_this->r_table = lr_salv_wd_table->get_model( ).
Hide / add function buttons in your ALV
You can hide all function buttons of the ALV with one of these methods.
* Set toolbar visibility to false. data: lr_function_settings type ref to if_salv_wd_function_settings. lr_function_settings ?= wd_this->r_table. lr_function_settings->set_visible( CL_WD_UIELEMENT=>E_VISIBLE-NONE ). * set default ALV Functions off data: lr_standard_functions type ref to if_salv_wd_std_functions. lr_standard_functions ?= wd_this->r_table. lr_standard_functions->set_sort_headerclick_allowed( ABAP_false ). lr_standard_functions->set_filter_filterline_allowed( ABAP_false ). lr_standard_functions->set_filter_complex_allowed( ABAP_false ). lr_standard_functions->set_sort_complex_allowed( ABAP_false ).
You can set individual functions with these methods:
CALL METHOD cl_salv_wd_config_table=>if_salv_wd_standard_functions~set_<x>_allowed
EXPORTING
Value = ABAP_true.
Where <x> is to be replaced with the property of your choice. -
Hi,
We just upgraded to SAP 6.0 and we are having an issue with some of our zreports using ALV.
When using the excel button on the grid, it starts excel but only the first few lines
the report are now being transferred to excel. Example: If I have five line in my alv report only three will appear in Excel. When you switch back to the SAP viewer
the lines are displayed in the ALV grid.
What I am missing? Any suggestions would greatly be appreciated.
ChrisPlease implement OSS Note: 947167. Point 5 in the note is the problem you are facing. I had exactly the same problem and after logging the issue to SAP, they replied me asking me to implement this Note and now it works fine- all data on ALV grid are getting transferred to Excel inplace.
-
How active the standard sum button in the alv oo?
try this code:
*& Report ZTEST_DEMO_ALV
report ztest_demo_alv.
class cl_event_reciever definition deferred.
data:
wa_vbak type vbak.
data:
i_vbak type standard table of vbak,
i_vbap type standard table of vbap.
data:
v_container1 type scrfname value 'CONT1',
v_grid1 type ref to cl_gui_alv_grid,
v_custom_container1 type ref to cl_gui_custom_container,
v_container2 type scrfname value 'CONT2',
v_grid2 type ref to cl_gui_alv_grid,
v_custom_container2 type ref to cl_gui_custom_container,
ok_code type syucomm,
v_event_reciever type ref to cl_event_reciever.
* CLASS cl_event_reciever DEFINITION
class cl_event_reciever definition.
public section.
methods:
handle_double_click for event double_click of cl_gui_alv_grid
importing e_row e_column.
endclass. "cl_event_reciever DEFINITION
* CLASS cl_event_reciever IMPLEMENTATION
class cl_event_reciever implementation.
method handle_double_click.
read table i_vbak
into wa_vbak
index e_row.
if sy-subrc = 0.
select * from vbap
into table i_vbap
where vbeln = wa_vbak-vbeln.
if sy-subrc = 0.
set screen 00.
leave to screen 100.
endif.
endif.
endmethod. "handle_double_click
endclass. "cl_event_reciever IMPLEMENTATION
select-options:
s_vbeln for wa_vbak-vbeln.
start-of-selection.
select * from vbak
into table i_vbak
up to 50 rows
where vbeln in s_vbeln.
if sy-subrc <> 0.
message i000(z_zzz_ca_messages) with 'No data found!'.
leave list-processing.
endif.
end-of-selection.
call screen 100.
*& Module STATUS_0100 OUTPUT
* text
module status_0100 output.
set pf-status '100'.
* SET TITLEBAR 'xxx'.
if v_custom_container1 is not bound.
create object v_custom_container1
exporting container_name = v_container1.
create object v_grid1
exporting i_parent = v_custom_container1.
call method v_grid1->set_table_for_first_display
exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
i_structure_name = 'VBAK'
* is_variant =
* i_save =
* i_default = 'X'
* is_layout =
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = i_vbak
* it_fieldcatalog =
* it_sort =
* it_filter =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
create object v_event_reciever.
set handler v_event_reciever->handle_double_click for v_grid1.
endif.
if v_custom_container2 is not bound
and i_vbap is not initial.
create object v_custom_container2
exporting container_name = v_container2.
create object v_grid2
exporting i_parent = v_custom_container2.
call method v_grid2->set_table_for_first_display
exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
i_structure_name = 'VBAP'
* is_variant =
* i_save =
* i_default = 'X'
* is_layout =
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = i_vbap
* it_fieldcatalog =
* it_sort =
* it_filter =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
endif.
if v_custom_container2 is bound.
call method v_grid2->refresh_table_display.
endif.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
module user_command_0100 input.
case ok_code.
when 'BACK'.
if v_grid1 is bound.
call method v_grid1->free.
endif.
if v_grid2 is bound.
call method v_grid2->free.
endif.
set screen 00.
leave screen.
endcase.
endmodule. " USER_COMMAND_0100 INPUT -
The first two lines of my toolbar have gone. I'm left with most visited but the lines above, containing the refresh button, bookmarks and search bar and above that containing the links to files etc have gone, how do I get em back?
== I was fiddling with the different bars and must have clicked sth I shouldn't have.Alt V
T
M
Be sure to do this in a new blank tab. -
Back button issue in ALV Grid(Factory method)
Hi All,
I have displayed a report using factory method(CL_SALV_TABLE).In that i have added buttons in application bar too.So when clicking on refresh button ALV should display again with latest number of records,that is working fine but when clicking on back button it should go to selection screen instead of that it is going a step back and displaying previous list of grid and then back and then selection screen.
Can any one help me how to directly go to input selection screen instead of going step back...
Regards,
RamHI,
Use this syntax (CALL SELECTION-SCREEN 1000)...Try this one
regards,
balaji -
Hi all,
I have a subscreen with ALV grid in module pool program.
The main screen has two subscreens (one is header and other is items/reports)
from the main screen, the ALV Grid subscreen can be called in two ways.
1. from application tool bar (show report button) - ALV grid will be displayed in Items/Reports subscreen.
2. In Items/Reports subscreen, while displaying items there is a requirement to display same ALV grid subscreen report on hotspot of particular item.
ALV Grid in subscreen displaying only first come first serve for subscreen, if the subscreen called from application toolbar button then the ALV grid from items hotspot call not displaying and vice versa.
Not sure where i am doing wrong, but if i free the container, alv and re-generate all the objects its working fine but user doesn't like the flickering display of conatiner when it re-generating.
Any suggestions would help.
Regards
SyedHi Aruna Kumara,
Thanks for the reply.
I have only one ALV grid instance.
Process Flow from Application toolbar
Main Screen: 100
PBO:
CALL SUBSCREEN C_REPORT INCLUDING SY_REPID '0300'.
SUBSCREEN: 300
PBO:
IF CONTAINER IS NOT BOUND.
CREATE Container. with container name
CREATE ALV_Grid. passing container created
BUILD FIELDCAT.
CREATE EVENTS.
CALL METHOD SET_DISPLAY_TABLE_FIRST.
ELSE.
REFRESH_TABLE_DISPLAY.
FLUSH. "tried with without flush too.
ENDIF.
Process Flow from Items:
Items table is a subscreen 200 in main screen.
When the desired item click thru hotspot, a Modal dialog screen 250 open with subscreen element.
In event hotspot_click.
CALL SCREEN 250 STARTING AT ...ENDING AT.
PBO of 250:
CALL SUBSCREEN C_REPORT INCLUDING SY-REPID '0300'.
SubScreen 0300:
PBO as describe above, as the container already bound next time it refreshes the table display. But i see a blank screen in Popup.
Hope this helps.
Regards
Syed -
Dynpro-PAI doesn't recognize actual selections in ALV-Control
Hi Control-Framework-Experts,
I have a Dynpro with an ALV-Grid-Control (cl_salv_table).
You can mark rows.
There is User-ALV-Button (cl_salv_functions_list) and
a event-handler (EVENT added_function OF cl_salv_events),
which find out, what rows are selected and gives a corresponding Info-message.
Example:
The rows 1 and 2 are selected.
User presses the ALV-Button
ALV-Event-Handler Method is proceeded and the following message is shown
"Selected Rows: 1 2".
Everything works fine.
Now the Problem. I want to put this function to a "normal" Dynpro-Standard-Toolbar-Event.
The PAI-Module does the same coding as the ALV-Event-Handler-Method.
But -> The Result is outdated.
Example:
The rows 1 and 2 are selected.
User presses the ALV-Button
ALV-Event-Handler Method is proceeded and the following message is shown
"Selected Rows: 1 2".
Now - Only Row 1 is selected.
+The Dynpro-Standard-Toolbar-Button is pressed. +
The PAI-Module (user_command_0100) tries to find out the selected rows -> Result:
"Selected Rows: 1 2". (wrong)
The PAI-Module only shows the result of the last Event-Handler-Call.
What is the trick to synchronize Control and Dynpro?
Regards
Juergen
Here ist the coding (sorry for some german inline-comments)
program zschoe01.
data: ok_code like sy-ucomm.
* Dynpro-CustomControl
data: gr_cont01 type ref to cl_gui_custom_container,
gr_alv01 type ref to cl_salv_table.
types: begin of ts_fauf,
aufnr type aufnr,
text type maktx,
end of ts_fauf.
data: gt_fauf type table of ts_fauf,
gs_fauf type ts_fauf.
* CLASS lcl_event_handler DEFINITION
class lcl_event_handler definition.
public section.
* Klassenmethoden
* Trick, weil man sich so das Erzeugen eines gesonderten Objekts
* sparen kann
class-methods:
* FCODE-Behandlung innerhalb des ALV01
handle_alv01_user_command
for event added_function of cl_salv_events
importing e_salv_function.
endclass. "lcl_event_handler DEFINITION
* CLASS lcl_event_handler IMPLEMENTATION
class lcl_event_handler implementation.
* FCODE-Behandlung innerhalb des ALV01
method handle_alv01_user_command .
data: lr_selections type ref to cl_salv_selections,
lt_rows type salv_t_row,
ls_row like line of lt_rows.
data: lv_string type string,
lv_char(6) type c.
* Markierte Zeilen aus ALV-Anzeige ermitteln.
lr_selections = gr_alv01->get_selections( ).
lt_rows = lr_selections->get_selected_rows( ).
if sy-subrc <> 0 or lt_rows[] is initial.
message i001(00) with 'Nothing selected'.
else.
case e_salv_function.
when 'SAVE'.
clear lv_string.
loop at lt_rows into ls_row.
* Aufzählung aller markierten Zeilen in einen langen String
write ls_row to lv_char.
concatenate lv_string lv_char into lv_string separated by space.
endloop.
message i001(00) with 'Selected Rows:' lv_string.
endcase.
endif.
endmethod. "handle_alv01_user_command
endclass. "lcl_event_handler IMPLEMENTATION
start-of-selection.
gs_fauf-aufnr = '4711'.
gs_fauf-text = 'Text1'.
append gs_fauf to gt_fauf.
gs_fauf-aufnr = '5616'.
gs_fauf-text = 'Another Text'.
append gs_fauf to gt_fauf.
call screen 100.
* MODULE status_0100 OUTPUT
module status_0100 output.
set pf-status '0100'.
set titlebar '0100'.
endmodule. " STATUS_0100 OUTPUT
* MODULE init_controls OUTPUT
module init_controls output.
perform init_controls.
endmodule. "init_controls OUTPUT
*& Module exit_commands_0100 INPUT
* text
module exit_commands_0100 input.
* -> Transaktion verlassen
leave to screen 0.
endmodule. " exit_commands_0100 INPUT
*& Module USER_COMMAND_0100 INPUT
* text
module user_command_0100 input.
case ok_code.
when 'SAVE'.
* (Ctrl-S) gedrückt -> Same Coding as in lcl_event_handler
data: lr_selections type ref to cl_salv_selections,
lt_rows type salv_t_row,
ls_row like line of lt_rows.
data: lv_string type string,
lv_char(6) type c.
* Markierte Zeilen aus ALV-Anzeige ermitteln.
lr_selections = gr_alv01->get_selections( ).
lt_rows = lr_selections->get_selected_rows( ).
if sy-subrc <> 0 or lt_rows[] is initial.
message i001(00) with 'Nothing selected'.
else.
clear lv_string.
loop at lt_rows into ls_row.
* Aufzählung aller markierten Zeilen in einen langen String
write ls_row to lv_char.
concatenate lv_string lv_char into lv_string separated by space.
endloop.
message i001(00) with 'Selected Rows:' lv_string.
endif.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*& Form init_controls
* text
form init_controls .
data: lr_selections type ref to cl_salv_selections.
data: lr_functions type ref to cl_salv_functions_list.
data: lr_events type ref to cl_salv_events_table.
data: lv_text type string,
lv_icon type string.
if gr_cont01 is initial.
create object gr_cont01
exporting
* parent =
container_name = 'CUSTCTRL01'.
*... §2 create an ALV table
try.
cl_salv_table=>factory(
exporting
r_container = gr_cont01
container_name = 'CUSTCTRL01'
importing
r_salv_table = gr_alv01
changing
t_table = gt_fauf ).
catch cx_salv_msg. "#EC NO_HANDLER
endtry.
*... §3 Functions
*... §3.1 activate ALV generic Functions
lr_functions = gr_alv01->get_functions( ).
* lr_functions->set_default( abap_true ).
lr_functions->set_all( abap_true ).
try.
lv_text = '__Who_is_selected?___'.
lr_functions->add_function(
name = 'SAVE'
text = lv_text
tooltip = lv_text
position = if_salv_c_function_position=>left_of_salv_functions ).
catch cx_salv_wrong_call cx_salv_existing.
endtry.
*... §4.3 set the selection mode: multiple or single row selection
lr_selections = gr_alv01->get_selections( ).
lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
*... §5 register to the events of cl_salv_table
lr_events = gr_alv01->get_event( ).
*... §5.1 register to the event USER_COMMAND
** Eventhandlermethode auch wirklich zuordnen.
** Achtung: Syntax! Weil Klassenmethode, Aufruf mit =>
** (vgl. Objekte ->)
set handler:
lcl_event_handler=>handle_alv01_user_command for lr_events.
gr_alv01->display( ).
endif.
endform. " init_controlsWell I figured out why it wasn't performing like I expected. My logic was wrong. Seems reasonable.
Was I right about this part though?
My guess is the restore
doesn't show up because the window isn't really maximized, because I
made it smaller to maintain proportions.
My updated VI is attached
Message Edited by elset191 on 09-23-2009 02:50 PM
Tim Elsey
LabVIEW 2010, 2012
Certified LabVIEW Architect
Attachments:
Untitled 1.vi 25 KB -
How to use this USER_COMMAND and ALV grid
hi all,
I have requirement.
there are 2 radiobutton in selection screen.
when rad1 is clicked,
some plain report display with button 'SUM" at the application toolbar.
when i click this SUM button , ALV grid report opens
when rad2 is clicked,
ALV grid report opens directly without plain report.
my code:
start-of-selection
if rad1 = 'X"
write """"
at user-command.
case sy-ucomm.
..perform ALV_report.
endcase.
elseif rad2 = 'X"
perform ALV_report.
endif.
I am getting an error " Incorrect nesting: Before the statement "AT, the structure introduced by IF must be concluded by ENDIF"..
kindly help.
points will be rewarded
thanks in advanceHi Jayasree,
As AT User-Command is an event which cannot be used under some condition. Check this sample code.
START-OF-SELECTION.
Perform select_data.
AT USER-COMMAND.
IF l_rad1 EQ 'X'.
CASE sy-ucomm.
WHEN 'ENTR'. "Use your Fcode.
PERFORM alv_report.
ENDCASE.
ELSEIF l_rad2 EQ 'X'.
PERFORM ALV_report.
ENDIF.
Reqard if useful.
Regards,
Ramkumar.K -
Approver regrouping in Shopping cart after approval and refresh button is clicked
Dear Experts
I created a shopping cart (Say 5 levels of approval) it reaches the approver . The approver approves the shopping cart and the cart is in completion step. When after approval in 3 rd step. If i click on refersh button at the top, the list of approvers who approved the cart are getting grouped in to a folder like structure. How it can be avioded i.e we need the approvers to be shown in sequence even after n approvals and clicking on the refresh button.
Thanks & Regards
Arun.K.PHi Laurent,
Please check the screenshots. -
hello all expert,
i have requirement display alv report in screen painter. select options and report display on same screen.
iam taking custom control for display alv report .but when i click on button alv not displayed in custom control.
plz help me anyone /
there is no hurry.
Thanks in advance,
sandeep.
Edited by: Thomas Zloch on Jan 22, 2011 1:00 PM - urgency reducedThanks for reply ,
now i write my code in pbo and pbi event but report not displayed yet.
now this is the code.
*& Report ZTEST_SCREEN1 *
REPORT ZTEST_SCREEN1 .
DATA :
gr_EBELN TYPE RANGE OF EKKO-EBELN,
grs_EBELN LIKE LINE OF gr_EBELN.
DATA:
gs_fieldcatalog TYPE lvc_s_fcat OCCURS 0,
gv_fcat LIKE LINE OF gs_fieldcatalog,
gs_layout TYPE lvc_s_layo.
TYPES :
BEGIN OF gty_item,
mandt LIKE EKKO-mandt,
EBELN LIKE EKKO-EBELN,
lifnr LIKE EKKO-lifnr,
matnr LIKE EKPO-matnr,
desc_text LIKE zEKPO-desc_text,
END OF gty_item,
BEGIN OF gty_EKKO,
mandt LIKE EKKO-mandt,
EBELN LIKE EKKO-EBELN,
lifnr LIKE EKKO-lifnr,
END OF gty_EKKO,
BEGIN OF gty_EKPO,
EBELN LIKE EKPO-EBELN,
matnr LIKE EKPO-matnr,
END OF gty_EKPO.
DATA :
gs_item TYPE gty_item,
gt_item TYPE TABLE OF gty_item.
DATA :
gs_EKKO TYPE gty_EKKO,
gt_EKKO TYPE TABLE OF gty_EKKO,
gs_EKPO TYPE gty_EKPO,
gt_EKPO TYPE TABLE OF gty_EKPO.
DATA :
g_Container TYPE scrfname VALUE 'CC_CONTAINER_GRID',
g_Custom_Container TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
g_Grid TYPE REF TO CL_GUI_ALV_GRID.
DATA :
OK_CODE LIKE sy-ucomm,
SAVE_OK LIKE sy-ucomm.
START-OF-SELECTION.
call screen 100.
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
SET TITLEBAR 'TITLE'.
IF g_Custom_Container IS INITIAL.
"Create CONTAINER object with reference to container name in the screen
CREATE OBJECT g_Custom_Container EXPORTING CONTAINER_NAME =
g_Container.
" Create GRID object with reference to parent name
CREATE OBJECT g_Grid EXPORTING I_PARENT = g_Custom_Container.
PERFORM u_prepare_fieldcatalog.
gs_layout-ZEBRA = 'X'.
"gs_layout-edit = 'X'. " Makes all Grid editable
" SET_TABLE_FOR_FIRST_DISPLAY
CALL METHOD g_Grid->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gs_fieldcatalog
IT_OUTTAB = gt_item. " Data
ELSE.
CALL METHOD g_Grid->REFRESH_TABLE_DISPLAY.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'EXIT' OR 'BACK' OR 'CNCL'.
LEAVE PROGRAM.
WHEN 'LIST'.
PERFORM u_filter_EKKO.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form u_filter_EKKO
text
--> p1 text
<-- p2 text
FORM u_filter_EKKO .
REFRESH gt_EKKO.
Define Range Criteria
grs_EBELN-SIGN = 'I'.
grs_EBELN-OPTION = 'EQ'.
grs_EBELN-low = '6000000004'.
grs_EBELN-high = ekko-ebeln.
APPEND grs_EBELN to gr_EBELN.
CHECK gr_EBELN[] IS NOT INITIAL.
SELECT mandt EBELN kunnr
FROM EKKO INTO TABLE gt_EKKO
WHERE EBELN IN gr_EBELN.
CHECK gt_EKKO[] IS NOT INITIAL.
SELECT EBELN matnr
FROM EKPO INTO TABLE gt_EKPO
FOR ALL ENTRIES IN gt_EKKO
WHERE EBELN EQ gt_EKKO-EBELN.
IF gt_EKKO[] IS NOT INITIAL.
LOOP AT gt_EKPO INTO gs_EKPO.
READ TABLE gt_EKKO INTO gs_EKKO WITH KEY EBELN = gs_EKPO-EBELN.
gs_item-mandt = gs_EKKO-mandt.
gs_item-EBELN = gs_EKKO-EBELN.
APPEND gs_item TO gt_item.
CLEAR gs_item.
CLEAR gs_EKKO.
CLEAR gs_EKPO.
ENDLOOP.
ENDIF.
ENDFORM. " u_filter_EKKO
FORM U_PREPARE_FIELDCATALOG .
CLEAR gv_fcat.
gv_fcat-fieldname = 'MANDT'.
gv_fcat-tabname = 'EKPO'.
gv_fcat-col_pos = 0.
gv_fcat-coltext = 'MANDT'.
gv_fcat-no_out = 'X'. " Do not Display Column
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
CLEAR gv_fcat.
gv_fcat-fieldname = 'EBELN'.
gv_fcat-tabname = 'EKPO'.
gv_fcat-col_pos = 1.
gv_fcat-coltext = 'EBELN'.
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
CLEAR gv_fcat.
gv_fcat-fieldname = 'ERDAT'.
gv_fcat-tabname = 'EKPO'.
gv_fcat-col_pos = 2.
gv_fcat-coltext = 'ERDAT'.
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
CLEAR gv_fcat.
gv_fcat-fieldname = 'KUNNR'.
gv_fcat-tabname = 'EKPO'.
gv_fcat-col_pos = 3.
gv_fcat-coltext = 'KUNNR'.
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
CLEAR gv_fcat.
gv_fcat-fieldname = 'MATNR'.
gv_fcat-tabname = 'EKPO'.
gv_fcat-col_pos = 5.
gv_fcat-coltext = 'MATNR'.
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
ENDFORM. " U_PREPARE_FIELDCATALOG -
HI
I WANT TO REFREAH ALV AFTER I PRES ON BUTTON.
WHEN I USE REUSE_ALV_GRID_DISPLAY
IN USER-COMMAND I USE
FORM USER_COMMAND USING P_UCOMM TYPE SYUCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
P_SELFIELD-REFRESH = 'X'
how can i refresh when i use class
CL_SALV_TABLE?
thanks
have nice dayhi yossi,
check these links..
Refresh in ALV.
Alv Grid and Refresh Button
ALV grid Refresh.
http://www.sap-img.com/abap/how-to-refresh-alv-list-grid-once-it-is-displayed.htm
http://sap.ittoolbox.com/groups/career/SAP-CAREER/refresh-alv-report-421919
Re: Refresh ALV with a new value
Re: Update/refresh ALV grid -
Hi all,
I have created an ALV Grid display using container.
My question is : How to edit an AlV.
Initially some of column are in Display Mode, That i had set as non editable.
But i want that when i create new/insert new record using the Insert button of alv , the only new column should apper as editable (all columns) as it is new record. So i can insert it into batabase.
Any one an help me with this .
Thanks
AmarHi Amar,
I have added one Sample program pls check it and Let me know
INCLUDE .
TABLES: lfa1, lfb1, ekko, ekpo.
TYPE-POOLS: slis.
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'CONTAINER',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: repname LIKE sy-repid.
DATA: t_disvariant TYPE TABLE OF disvariant WITH HEADER LINE.
DATA: t_fieldtab TYPE lvc_t_fcat.
DATA: t_layout TYPE lvc_s_layo.
DATA: gs_toolbar TYPE stb_button.
DATA: t_rows TYPE lvc_t_row WITH HEADER LINE.
TABLA DE DATOS
DATA: BEGIN OF ti_acred OCCURS 0,
bukrs LIKE lfb1-bukrs,
lifnr LIKE lfa1-lifnr,
land1 LIKE lfa1-land1,
name1 LIKE lfa1-name1,
ort01 LIKE lfa1-ort01,
pstlz LIKE lfa1-pstlz,
regio LIKE lfa1-regio,
sortl LIKE lfa1-sortl,
stras LIKE lfa1-stras,
adrnr LIKE lfa1-adrnr,
END OF ti_acred.
DATA i_salida LIKE ti_acred OCCURS 0.
DATA: d_bukrs LIKE t001-bukrs.
DATA container.
DATA save VALUE 'X'.
Pantalla de Selección -
SELECTION-SCREEN BEGIN OF BLOCK bloq1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : lifnr FOR lfa1-lifnr,
bukrs FOR lfb1-bukrs.
SELECTION-SCREEN END OF BLOCK bloq1.
SELECTION-SCREEN BEGIN OF BLOCK bloq3 WITH FRAME TITLE text-003.
PARAMETERS: p_alvasg TYPE slis_vari. " Disposición ALV
SELECTION-SCREEN END OF BLOCK bloq3.
LOCAL CLASSES: Definition
*===============================================================
class lcl_event_receiver: local class to
define and handle own functions.
Definition:
~~~~~~~~~~~
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_menu_button
FOR EVENT menu_button OF cl_gui_alv_grid
IMPORTING e_object e_ucomm,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS.
lcl_event_receiver (Definition)
*===============================================================
LOCAL CLASSES: Implementation
*===============================================================
class lcl_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
§ 2.At event TOOLBAR define a toolbar element of type 1 by using
event paramenter E_OBJECT. Remember its function code.
Part I: Define a menu button including a function code that
is evaluated in 'handle_MENU_BUTTON
append a menu with default button (Type 1)
The function code of the default button is the same as
the one for the menu.
If the user klicks on the default button ALV raises
directly event BEFORE_USER_COMMAND
(then USER_COMMAND, AFTER_USER_COMMAND).
If the user klicks on the menu button ALV raises event MENU_BUTTON.
CLEAR gs_toolbar.
MOVE 'MODIFY' TO gs_toolbar-function.
--> This function code is evaluated in 'handle_menu_button'
MOVE icon_change TO gs_toolbar-icon.
MOVE 'Modificar' TO gs_toolbar-quickinfo.
MOVE 0 TO gs_toolbar-butn_type.
MOVE space TO gs_toolbar-disabled.
APPEND gs_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD handle_menu_button.
§ 3.At event MENU_BUTTON query your function code and define a
menu in the same way as a context menu.
Part II: Evaluate 'e_ucomm' to see which menu button of the toolbar
has been clicked on.
Define then the corresponding menu.
The menu contains function codes that are evaluated
in 'handle_user_command'.
query e_ucomm to find out which menu button has been clicked on
IF e_ucomm = 'MODIFY'.
CALL METHOD e_object->add_function
EXPORTING fcode = 'MODIFY'
text = 'Modificar'. "modificar
§ 3a.) choose a default function and define the same function code
as used for the menu.
CALL METHOD e_object->add_function
EXPORTING fcode = 'DECISION'
text = 'Decisión de empleo'. "Decisión
"de empleo
ENDIF.
ENDMETHOD.
METHOD handle_user_command.
§ 4.At event USER_COMMAND query the function code of each function
defined in step 3.
Part III : Evaluate user command to invoke the corresponding
function.
DATA: lt_rows TYPE lvc_t_row.
get selected row
CALL METHOD grid1->get_selected_rows
IMPORTING et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = repname
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
go to other table
CASE e_ucomm.
WHEN 'DECISION'.
REFRESH T_ROWS.
PERFORM SELECCION_LINEAS_DECISION TABLES lt_rows.
WHEN 'MODIFY'.
REFRESH t_rows.
PERFORM SELECCION_LINEAS_modify TABLES lt_rows.
CALL SCREEN 200.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS.
lcl_event_receiver (Implementation)
*===================================================================
INITIALIZATION -
INITIALIZATION.
repname = sy-repid.
PERFORM initialize_fieldcat.
PERFORM initializa_layout.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alv -
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alvasg.
PERFORM alvl_value_request USING p_alvasg ' '.
START-OF-SELECTION -
START-OF-SELECTION.
PERFORM obtener_datos.
END-OF-SELECTION -
END-OF-SELECTION.
CALL SCREEN 9010.
Subrutinas -
Form obtener_datos
FORM obtener_datos.
REFRESH ti_acred.
CLEAR ti_acred.
SELECT * INTO CORRESPONDING FIELDS OF TABLE ti_acred
FROM lfa1
WHERE lifnr IN lifnr.
LOOP AT ti_acred.
SELECT SINGLE bukrs INTO ti_acred-bukrs FROM lfb1
WHERE lifnr = ti_acred-lifnr.
MODIFY ti_acred.
ENDLOOP.
i_salida[] = ti_acred[].
ENDFORM.
MODULE PBO OUTPUT *
MODULE status_9010 OUTPUT.
DATA it_toolbar_excluding TYPE ui_func.
SET PF-STATUS 'EMPRESA'.
CLEAR g_custom_container.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
CALL METHOD grid1->set_table_for_first_display
EXPORTING i_structure_name = 'I_SALIDA'
is_variant = t_disvariant
i_save = save
I_DEFAULT = ' '
is_layout = t_layout
CHANGING it_outtab = i_salida
it_fieldcatalog = t_fieldtab.
SET HANDLER lcl_event_receiver=>handle_user_command
lcl_event_receiver=>handle_menu_button
lcl_event_receiver=>handle_toolbar FOR ALL INSTANCES.
CALL METHOD grid1->set_toolbar_interactive.
ELSE.
CALL METHOD grid1->refresh_table_display.
ENDIF.
ENDMODULE.
Module EXIT INPUT
MODULE exit INPUT.
REFRESH i_salida.
CLEAR i_salida.
SET SCREEN 0.
LEAVE SCREEN.
ENDMODULE. " EXIT INPUT
Form initialize_fieldcat
FORM initialize_fieldcat.
DATA: l_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
REFRESH t_fieldtab.
Catálogo de Campos
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-key = 'X'.
l_fieldcat-ref_field = 'BUKRS'.
l_fieldcat-ref_table = 'LFB1'.
l_fieldcat-fieldname = 'BUKRS'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-key = 'X'.
l_fieldcat-ref_field = 'LIFNR'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'LIFNR'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-edit = 'X'.
l_fieldcat-ref_field = 'NAME1'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'NAME1'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-edit = 'X'.
l_fieldcat-ref_field = 'LAND1'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'LAND1'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-edit = 'X'.
l_fieldcat-ref_field = 'ORT01'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'ORT01'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-edit = 'X'.
l_fieldcat-ref_field = 'PSTLZ'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'PSTLZ'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-edit = 'X'.
l_fieldcat-ref_field = 'REGIO'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'REGIO'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-edit = 'X'.
l_fieldcat-ref_field = 'SORTL'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'SORTL'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-edit = 'X'.
l_fieldcat-ref_field = 'STRAS'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'STRAS'.
APPEND l_fieldcat TO t_fieldtab.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'I_SALIDA'.
l_fieldcat-fix_column = 'X'.
l_fieldcat-no_out = 'O'.
l_fieldcat-key = 'X'.
l_fieldcat-ref_field = 'ADRNR'.
l_fieldcat-ref_table = 'LFA1'.
l_fieldcat-fieldname = 'ADRNR'.
APPEND l_fieldcat TO t_fieldtab.
ENDFORM. " initialize_fieldcat
Form initializa_layout
FORM initializa_layout.
t_layout-zebra = 'X'.
t_layout-cwidth_opt = 'X'.
t_layout-no_toolbar = 'X'.
T_LAYOUT-EDIT = 'X'.
T_LAYOUT-DETAILINIT = 'X'.
T_LAYOUT-CWIDTH_OPT = 'X'.
T_LAYOUT-TOTALS_BEF = 'X'.
T_LAYOUT-NUMC_TOTAL = 'X'.
ENDFORM. " initializa_layout
Module USER_COMMAND_9010 INPUT
MODULE user_command_9010 INPUT.
CASE sy-ucomm.
WHEN 'SAVE'.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = ' '
DIAGNOSE_OBJECT = ' '
text_question = 'Pulsaste SAVE'
TEXT_BUTTON_1 = 'Ja'(001)
ICON_BUTTON_1 = ' '
TEXT_BUTTON_2 = 'Nein'(002)
ICON_BUTTON_2 = ' '
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = 'X'
USERDEFINED_F1_HELP = ' '
START_COLUMN = 25
START_ROW = 6
POPUP_TYPE =
IMPORTING
ANSWER =
TABLES
PARAMETER =
EXCEPTIONS
TEXT_NOT_FOUND = 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.
ENDCASE.
ENDMODULE. " USER_COMMAND_9010 INPUT
Form alvl_value_request
FORM alvl_value_request USING pi_alv
value(p_0158).
DATA: l_disvariant TYPE disvariant.
Wertehilfe
l_disvariant-report = sy-cprog.
l_disvariant-report(1) = 'A'.
l_disvariant-variant = pi_alv.
l_disvariant-log_group = p_0158.
CALL FUNCTION 'LVC_VARIANT_SAVE_LOAD'
EXPORTING
i_save_load = 'F'
i_tabname = '1'
CHANGING
cs_variant = l_disvariant
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0.
pi_alv = l_disvariant-variant.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " ALVL_VALUE_REQUEST
Kanagaraja L -
To update an alv grid..
Hello everyone,
I have a requirement.
update button in selection-screen.
I have an alv grid display and I have to maintain last 2 fields in editable mode in the output and the user will enter the values after executing the report in the output screen and will save it.
and when he will select display radiobutton in the selection-screen ,,
the entries which he entered above has to display ,,( all the entries should display in the output ).
is it possible ? if yes, then let me know the procedure.
will be rewarded..Hi,
yes it is possible
all u need to do is call a new alv with same funtion modules and pass the updated internal table to these function modules
i have the same req for 'SAVE' button in menu , u just change it by your radio button in the sample code below
type-pools : slis.
types : begin of t_mat,
matnr type matnr,
werks type werks_d,
lgort type lgort_d,
labst type labst,
meins type meins,
maktx type maktx,
name1 type name1,
lgobe type lgobe,
msehl type msehl,
v_lights type c,
v_row type c length 4, "FOR ROW COLOR
v_col type slis_t_specialcol_alv,
end of t_mat,
begin of t_makt,
matnr type matnr,
maktx type maktx,
end of t_makt,
begin of t_marc,
matnr type matnr,
werks type werks_d,
end of t_marc,
begin of t_mard,
matnr type matnr,
werks type werks_d,
lgort type lgort_d,
labst type labst,
end of t_mard,
begin of t_t001l,
werks type werks_d,
lgort type lgort_d,
lgobe type lgobe,
end of t_t001l,
begin of t_t001w,
werks type werks_d,
name1 type name1,
end of t_t001w.
types : begin of wa_mat,
werks type werks,
end of wa_mat.
data : flag type i value 0.
******VARIABLE DECLARATION********
data:v_prog_name type sy-repid, "VARIABLE FOR PROG NAME
v_grid_title type lvc_title. "VARIABLE FOR GRID TITLE
*****INTERNAL TABLE DECLARATION***
data: it_mat type standard table of t_mat,
it_marc type standard table of t_marc,
it_mard type standard table of t_mard,
it_t001l type standard table of t_t001l,
it_t001w type standard table of t_t001w,
it_makt type standard table of t_makt,
it_fieldcat type slis_t_fieldcat_alv,
it_sortinfo type slis_t_sortinfo_alv,
it_eventcat type slis_t_event,
it_listheader type slis_t_listheader,
t_color type slis_specialcol_alv.
data : it_werks type standard table of wa_mat.
*****WORK AREA DECLARATION*********
data: wa_mat type t_mat,
wa_mard type t_mard,
wa_t001l type t_t001l,
wa_t001w type t_t001w,
wa_makt type t_makt,
wa_layout type slis_layout_alv.
data : wa_werks type wa_mat.
data : wa_variant1 like disvariant,
wa_variant2 like disvariant.
Selection-Screen *
selection-screen begin of block plant with frame title text-001.
select-options: s_plant for wa_mat-werks,
s_stor for wa_mat-lgort.
parameters : p_var like disvariant-variant.
selection-screen end of block plant.
selection-screen begin of block output with frame title text-002.
parameter: p_rb_01 radiobutton group rd1 default 'X', " list
p_rb_02 radiobutton group rd1. " grid
selection-screen end of block output.
Initialization *
perform zf_initialization.
At Selection Screen *
at selection-screen on value-request for p_var.
wa_variant1-report = sy-repid.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = wa_variant1
I_TABNAME_HEADER =
I_TABNAME_ITEM =
IT_DEFAULT_FIELDCAT =
i_save = 'A'
i_display_via_grid = 'X'
importing
e_exit = v_exit
es_variant = wa_variant2
exceptions
not_found = 1
program_error = 2
others = 3
if sy-subrc = 0.
p_var = wa_variant2-variant.
else.
clear wa_variant2.
endif.
at selection-screen.
perform zf_validate_sel_screen.
Start of Selection *
start-of-selection.
perform zf_get_data.
End of Selection *
end-of-selection.
perform zf_display_data.
*& Form zf_initialization
This will intialize all the variables, work area & subroutines
--> p1 text
<-- p2 text
form zf_initialization .
clear : wa_mat,
wa_mard,
wa_t001l,
wa_t001w,
wa_makt,
wa_layout.
refresh : it_mat,
it_marc,
it_mard,
it_t001l,
it_t001w,
it_makt,
it_fieldcat,
it_sortinfo,
it_eventcat,
it_listheader.
v_prog_name = sy-repid.
wa_variant2-report = sy-repid.
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
exporting
i_save = 'A'
changing
cs_variant = wa_variant2
exceptions
wrong_input = 1
not_found = 2
program_error = 3
others = 4.
if sy-subrc = 0.
p_var = wa_variant2-variant.
else.
p_var = '/DEFAULT'.
endif.
endform. " zf_initialization
*& Form zf_validate_sel_screen
This is to validate the inputs on the selction screen
--> p1 text
<-- p2 text
form zf_validate_sel_screen .
if not p_var is initial.
wa_variant1-report = sy-repid.
wa_variant1-variant = p_var.
call function 'REUSE_ALV_VARIANT_EXISTENCE'
exporting
i_save = 'A'
changing
cs_variant = wa_variant1
exceptions
wrong_input = 1
not_found = 2
program_error = 3
others = 4.
if sy-subrc = 0.
clear wa_variant2.
move p_var to wa_variant2-variant.
move sy-repid to wa_variant2-report.
else.
message e006. "No such variant exists
endif.
else.
clear wa_variant1.
endif.
select werks from marc into wa_mat-werks where werks in s_plant.
exit.
endselect.
if sy-subrc <> 0.
message e002.
clear wa_mat.
endif.
select lgort from mard into wa_mat-lgort where lgort in s_stor.
exit.
endselect.
if sy-subrc <> 0.
message e003.
clear wa_mat.
endif.
endform. " zf_validate_sel_screen
*& Form zf_get_data
This will fetch data from the database tables & finally merge them
into a single internal table, to pass it to alv
--> p1 text
<-- p2 text
form zf_get_data .
select matnr werks into table it_marc from marc where werks in s_plant
if sy-subrc = 0.
sort it_marc by matnr werks.
endif.
if it_marc[] is not initial.
select matnr maktx into table it_makt from makt
for all entries in it_marc
where matnr = it_marc-matnr
and spras = sy-langu.
if sy-subrc = 0.
sort it_makt by matnr.
endif.
select matnr werks lgort labst into table it_mard from mard
for all entries in it_marc
where matnr = it_marc-matnr
and werks = it_marc-werks
and lgort in s_stor.
if sy-subrc = 0.
sort it_mard by matnr werks lgort.
endif.
select werks name1 into table it_t001w from t001w
for all entries in it_marc
where werks = it_marc-werks.
if sy-subrc = 0.
sort it_t001w by werks.
endif.
endif.
if it_mard[] is not initial.
select werks lgort lgobe into table it_t001l from t001l
for all entries in it_mard
where werks = it_mard-werks
and lgort = it_mard-lgort.
if sy-subrc = 0.
sort it_t001l by werks lgort.
endif.
endif.
clear : wa_mat,
wa_mard,
wa_t001l,
wa_t001w,
wa_makt.
loop at it_mard into wa_mard.
wa_mat-matnr = wa_mard-matnr.
wa_mat-werks = wa_mard-werks.
wa_mat-lgort = wa_mard-lgort.
wa_mat-labst = wa_mard-labst.
read table it_makt into wa_makt with key matnr = wa_mard-matnr
binary search.
if sy-subrc = 0.
wa_mat-maktx = wa_makt-maktx.
endif.
read table it_t001l into wa_t001l with key werks = wa_mard-werks
lgort = wa_mard-lgort binary search.
if sy-subrc = 0.
wa_mat-lgobe = wa_t001l-lgobe.
endif.
read table it_t001w into wa_t001w with key werks = wa_mard-werks
binary search.
if sy-subrc = 0.
wa_mat-name1 = wa_t001w-name1.
endif.
append wa_mat to it_mat.
endloop.
sort it_mat by matnr werks lgort.
loop at it_mat into wa_mat.
clear t_color.
if wa_mat-labst < 100.
wa_mat-v_lights = '1'.
t_color-fieldname = 'LABST'.
t_color-color-col = 6.
append t_color to wa_mat-v_col.
wa_mat-v_row = 'C610'.
modify it_mat from wa_mat.
elseif wa_mat-labst < 1000.
wa_mat-v_lights = '2'.
t_color-fieldname = 'LABST'.
t_color-color-col = 3.
append t_color to wa_mat-v_col.
wa_mat-v_row = 'C510'.
modify it_mat from wa_mat.
else.
wa_mat-v_lights = '3'.
t_color-fieldname = 'LABST'.
t_color-color-col = 5.
append t_color to wa_mat-v_col.
wa_mat-v_row = 'C210'.
modify it_mat from wa_mat.
endif.
clear wa_mat.
endloop.
endform. " zf_get_data
*& Form zf_display_data
--> p1 text
<-- p2 text
form zf_display_data .
*If Internal Table Is Populated Then Only Display Alv Report.
if not it_mat[] is initial.
&---Prepare fieldcatalog .
perform zf_build_fieldcat using it_fieldcat.
&---Build event catalog.
perform zf_eventcat using it_eventcat.
&---Build Listheader for TOP OF PAGE EVENT.
perform zf_build_listheader using it_listheader.
&---Build layout.
perform zf_layout.
&---Build sorting.
perform zf_sorting using it_sortinfo.
&---Initializating Grid Title
perform zf_build_grid_title.
IF GRID RADIO button (ALV GRID) IS selected .
if p_rb_02 is not initial.
DISPLAY ALV GRID.
perform zf_display_alv_grid.
else.
DISPLAY ALV LIST.
perform zf_display_alv_list.
endif.
else.
*&---If Table is not Populated ie Records Does not exist
message s001.
endif.
endform. " zf_display_data
*& Form ZF_BUILD_FIELDCAT
text
-->P_IT_FIELDCAT text
form zf_build_fieldcat using p_it_fieldcat type slis_t_fieldcat_alv.
*Declaring Local Variable
data: l_fieldcat type slis_fieldcat_alv.
clear l_fieldcat.
for First field
l_fieldcat-col_pos = '1'. "POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'WERKS'. "FIELD FOR WHICH CATALOG
l_fieldcat-tabname = 'IT_MAT'. "NAME OF INTERNAL TABLE
l_fieldcat-ref_tabname = 'MARC'. "FOR F1 & F4 HELP AS REFERNCED
l_fieldcat-key = 'X'. "MAKING FIELD AS KEY FIELD
l_fieldcat-outputlen = 4. "SET THE OUTPUT LENGTH.
l_fieldcat-seltext_l = text-003. "Long text for header.
l_fieldcat-seltext_m = text-003. "Medium text for header.
l_fieldcat-seltext_s = text-003. "Short text for header.
append l_fieldcat to p_it_fieldcat.
clear l_fieldcat.
for Second field
l_fieldcat-col_pos = '2'. "POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'LGORT'. "FIELD FOR WHICH CATALOG
l_fieldcat-tabname = 'IT_MAT'. "NAME OF INTERNAL TABLE
l_fieldcat-ref_tabname = 'MARD'. "FOR F1 & F4 HELP AS REFERNCED
l_fieldcat-key = 'X'. "MAKING FIELD AS KEY FIELD
l_fieldcat-outputlen = 4. "SET THE OUTPUT LENGTH.
l_fieldcat-seltext_l = text-004. "Long text for header.
l_fieldcat-seltext_m = text-005. "Medium text for header.
l_fieldcat-seltext_s = text-006. "Short text for header.
append l_fieldcat to p_it_fieldcat.
clear l_fieldcat.
for third field
l_fieldcat-col_pos = '3'. "POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MATNR'. "FIELD FOR WHICH CATALOG
l_fieldcat-tabname = 'IT_MAT'. "NAME OF INTERNAL TABLE
l_fieldcat-ref_tabname = 'MARA'. "FOR F1 & F4 HELP AS REFERNCED
l_fieldcat-key = 'X'. "MAKING FIELD AS KEY FIELD
l_fieldcat-outputlen = 18. "SET THE OUTPUT LENGTH.
l_fieldcat-seltext_l = text-007. "Long text for header.
l_fieldcat-seltext_m = text-008. "Medium text for header.
l_fieldcat-seltext_s = text-009. "Short text for header.
append l_fieldcat to p_it_fieldcat.
clear l_fieldcat.
for fourth field
l_fieldcat-col_pos = '4'. "POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'LABST'. "FIELD FOR WHICH CATALOG
l_fieldcat-tabname = 'IT_MAT'. "NAME OF INTERNAL TABLE
l_fieldcat-ref_tabname = 'MARD'. "FOR F1 & F4 HELP AS REFERNCED
l_fieldcat-outputlen = 16. "SET THE OUTPUT LENGTH.
l_fieldcat-seltext_l = text-010. "Long text for header.
l_fieldcat-seltext_m = text-011. "Medium text for header.
l_fieldcat-seltext_s = text-012. "Short text for header.
l_fieldcat-do_sum = 'X'.
l_fieldcat-input = 'X'. "Making the field editable
l_fieldcat-edit = 'X'.
append l_fieldcat to p_it_fieldcat.
clear l_fieldcat.
endform. " ZF_BUILD_FIELDCAT
*& Form zf_eventcat
text
-->P_IT_EVENTCAT text
form zf_eventcat using p_it_eventcat type slis_t_event.
data l_eventcat type slis_alv_event.
clear l_eventcat.
*Get all the events.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_it_eventcat
exceptions
list_type_wrong = 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.
TOP-OF-PAGE FORM
clear l_eventcat.
read table p_it_eventcat into l_eventcat with key
name = slis_ev_top_of_page.
if sy-subrc = 0.
move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
modify p_it_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
PF_STATUS_SET FORM
clear l_eventcat.
read table p_it_eventcat into l_eventcat with key
name = slis_ev_pf_status_set.
if sy-subrc = 0.
move 'ZF_PF_STATUS_SET' to l_eventcat-form.
modify p_it_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
USER_COMMAND FORM
clear l_eventcat.
read table p_it_eventcat into l_eventcat with key
name = slis_ev_user_command.
if sy-subrc = 0.
move 'ZF_USER_COMMAND' to l_eventcat-form.
modify p_it_eventcat from l_eventcat index sy-tabix
transporting form.
endif.
endform. " zf_eventcat
*& Form ZF_BUILD_LISTHEADER
text
-->P_IT_LISTHEADER text
form zf_build_listheader using p_it_listheader type slis_t_listheader.
data: l_listheader type slis_listheader.
refresh p_it_listheader.
clear l_listheader.
l_listheader-typ = 'H'. "Header
l_listheader-key = 'FCIL,INDIA'. "Ignored for "Header" Type
l_listheader-info = text-013.
append l_listheader to p_it_listheader.
clear l_listheader.
data : lv_date(10) type c .
write sy-datum to lv_date .
l_listheader-typ = 'S'.
l_listheader-key = 'DATE'.
l_listheader-info = lv_date.
append l_listheader to p_it_listheader.
clear l_listheader.
l_listheader-typ = 'A'.
l_listheader-key = 'COMMENT'. " key is ignored
l_listheader-info = text-014.
append l_listheader to p_it_listheader.
clear l_listheader.
l_listheader-typ = 'S'.
l_listheader-key = text-016.
l_listheader-info = 'Input Plant'.
append l_listheader to p_it_listheader.
clear l_listheader.
l_listheader-typ = 'S'.
l_listheader-key = text-017.
l_listheader-info = 'Plant'.
append l_listheader to p_it_listheader.
select werks from marc into table it_werks where werks in s_plant.
sort it_werks by werks.
delete adjacent duplicates from it_werks comparing werks.
loop at it_werks into wa_werks.
clear l_listheader.
l_listheader-typ = 'S'.
l_listheader-key = 'X'.
l_listheader-info = wa_werks-werks.
append l_listheader to p_it_listheader.
endloop.
endform. " ZF_BUILD_LISTHEADER
*& Form ZF_LAYOUT
text
--> p1 text
<-- p2 text
form zf_layout .
clear wa_layout.
wa_layout-zebra = 'X'.
wa_layout-lights_fieldname = 'V_LIGHTS'.
wa_layout-lights_tabname = 'IT_MAT'.
wa_layout-info_fieldname = 'V_ROW'. " infofield for listoutput
wa_layout-coltab_fieldname = 'V_COL'. " colors
endform. " ZF_LAYOUT
*& Form ZF_SORTING
text
-->P_IT_SORTINFO text
form zf_sorting using p_it_sortinfo type slis_t_sortinfo_alv.
data l_sortinfo type slis_sortinfo_alv.
clear l_sortinfo.
l_sortinfo-spos = '1'.
l_sortinfo-fieldname = 'WERKS'.
l_sortinfo-tabname = 'IT_MAT'.
l_sortinfo-up = 'X'.
l_sortinfo-group = 'UL'. "UNDERLINE AFTER EVERY GROUP
l_sortinfo-subtot = 'X'.
append l_sortinfo to p_it_sortinfo.
endform. " ZF_SORTING
*& Form ZF_BUILD_GRID_TITLE
text
--> p1 text
<-- p2 text
form zf_build_grid_title .
v_grid_title = text-015.
endform. " ZF_BUILD_GRID_TITLE
*& Form ZF_DISPLAY_ALV_GRID
text
--> p1 text
<-- p2 text
form zf_display_alv_grid .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_prog_name
i_callback_pf_status_set = 'ZF_PF_STATUS_SET'
i_callback_user_command = 'ZF_USER_COMMAND'
i_callback_top_of_page = 'ZF_TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = v_grid_title
I_GRID_SETTINGS =
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = it_sortinfo
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = 'A'
is_variant = wa_variant2
it_events = it_eventcat
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_mat
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. " ZF_DISPLAY_ALV_GRID
*& Form zf_display_alv_list
text
--> p1 text
<-- p2 text
form zf_display_alv_list .
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = v_prog_name
i_callback_pf_status_set = 'ZF_PF_STATUS_SET'
i_callback_user_command = 'ZF_USER_COMMAND'
I_STRUCTURE_NAME =
is_layout = wa_layout
it_fieldcat = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = it_sortinfo
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = WA_VARIANT2
it_events = it_eventcat
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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it_mat
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. " zf_display_alv_list
*& Form zf_top_of_page
text
--> p1 text
<-- p2 text
form zf_top_of_page .
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_listheader
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
endform. " zf_top_of_page
*& Form zf_pf_status_set
text
--> p1 text
<-- p2 text
form zf_pf_status_set using rt_extab type slis_t_extab.
set pf-status 'ALV_MENU_MAT' excluding 'BACK'.
case sy-ucomm.
when 'SAVE'.
IF flag <> 0.
set pf-status 'ALV_MENU_MAT' .
ENDIF.
endcase.
endform. " zf_pf_status_set
*& Form zf_user_command
text
--> p1 text
<-- p2 text
form zf_user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
sy-ucomm = r_ucomm.
case r_ucomm.
when 'SAVE'.
flag = flag + 1.
read table it_mat index rs_selfield-tabindex into wa_mat.
wa_mat-labst = rs_selfield-value.
if rs_selfield-value < 100.
wa_mat-v_lights = '1'.
t_color-fieldname = 'LABST'.
t_color-color-col = 6.
wa_mat-v_row = 'C610'.
clear wa_mat-v_col.
append t_color to wa_mat-v_col.
elseif rs_selfield-value < 1000.
wa_mat-v_lights = '2'.
t_color-fieldname = 'LABST'.
t_color-color-col = 3.
wa_mat-v_row = 'C510'.
clear wa_mat-v_col.
append t_color to wa_mat-v_col.
else.
wa_mat-v_lights = '3'.
t_color-fieldname = 'LABST'.
t_color-color-col = 5.
wa_mat-v_row = 'C210'.
clear wa_mat-v_col.
append t_color to wa_mat-v_col.
endif.
modify it_mat from wa_mat index rs_selfield-tabindex.
IF GRID RADIO button (ALV GRID) IS selected .
if p_rb_02 is not initial.
SET PF-STATUS 'ALV_MENU_MAT'.
DISPLAY ALV GRID.
perform zf_display_alv_grid.
else.
SET PF-STATUS 'ALV_MENU_MAT'.
DISPLAY ALV LIST.
perform zf_display_alv_list.
endif.
set screen 0.
when 'BACK'.
leave screen.
when others.
message i004.
endcase.
WHEN 'BACK'.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE SCREEN.
ENDCASE.
endform. " zf_user_command
reward points if helpful -
Would you please summarize what the difference between tc and alv?
hi, experts,
would you please summarize what the difference between table control and alv base on the function and usage practice.
for example, as i know:
1.edit
tc: can edit in the same screen and save.
alv: pop up a sub screen to let user edit, so this is unconvenient.
2.functional button
alv: can have many functional button as default ,eg. sort, summary and so on
tc: developers must implements by himself.
3.color
alv: can have and change color
tc: cann't changed color
some client may required the data displayed in alv and edit in tc ,such as example BCALV_EDIT_02.
above are my idea, experts, would you give me some comments on my opinion and summarize what the difference between those two components? i should make it clear in order to consult the UI with my client.hunger for your advice, thanks!
Message was edited by:
liu shaochangALV Grid is basically used for display puropse. It is more user friendly. There are arious features ( such as coloring, sorting, saving to a local file, sedning by mail etc. ) These featurs make ALV Grid a very good option to display the data .
However , the table control is not only used to display data take from the database table, but also you can do operation such as deletion of data from database table, insertion of data into the database table and updation also. Yeah it has not got the various features whihc ALV has.
So table control and ALV Grid , if you are just using for display purpose, then ALV Grid is a better option due to its layout and attractive features. But if you want to do the database operations other than display, table control can be used.
As far as execution is concerned, I think ALV Grid is faster.
ALV grid control is faster when compared to Table control. But the comaprision is Negligible .
One of the major differences comes in taking of line items - ALV has an advantage over Table Control when it comes to update database from it.Table control only allows maximum of 999 records at a time where as this limitation is not there in ALV.
Also,a main feature of ALV Grid is that it contains a standard set of functions. These functions extend beyond the functions of a table control.
These two UI elements require different keyboard navigation, with ALV Grid being more user-friendly.
An application can display table data in ALV Grid or in a table control. In some applications you can choose between displaying and editing data in either ALV Grid or a table control. If a configurable button () appears in the right upper corner of the table, it is a table control.
Basically ALV is a way to display the output and Table Control is designed in screen painter through which you can get entries in Table Control, can delete some records etc for further processing and its not use only for Display.
ALV is Application List viewer:-
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
TABLE CONTROL:-
ABAP offers two mechanisms for displaying and using table data in a screen. These mechanisms are table controls and step loops. Table controls and step loops are types of screen tables you can add to a screen in the Screen Painter.
Maybe you are looking for
-
I have acrobat on old pc and want to move it to new pc?
Seems like I need to deactivate on old pc and reactivate on new pc, but it has been so long since I bought a new computer for home I can't remember. Any help?
-
Hi Friends, I have an issue with loading. 1. From source 2lis_13_VDITM, data loads to 2 targets. ZIC_SEG, 0SD_C03.and from 0sd_C03 it again loads to ZSD_C03W and ZSD_C03M through DTP. I have done a repair full load on 08.08.2011 to PSA and loaded thi
-
GPS settings on Nokia e90. Just checking!
I have recently bought an E90 communicator and had a couple of questions about my GPS setup/ costs etc. I have read as many forums etc as I can but nothing quite answers my queries. I have successfully managed to lock onto satellites. I have initiate
-
Simulating SOAP Header in Testsuite
Hi all, I'm using an BPEL Process with a custom soap header. Can anybody tell me how I can create a testcase, that fills in the custom soap header with testdata? Thanks in advance. Regards Markus
-
Date format while calling RFC??
Hi all, Do we need to format date in WDJ while calling a RFC function module?? I am trying to populate with the code. import java.sql.Date; Date payDate; payDate = wdContext.currentContextElement().getSelectedPayDate(); incInput1.setPay_Date(payDate)