How to exclude unnecessary buttons in ALV toolbar? - toolbar

So, inside the TOOLBAR event of the CL_GUI_ALV_GRID the parameter E_OBJECT has the table MT_TOOLBAR that I can access to change all the buttons manually.
Is there a better way to include/exclude standard buttons in the toolbar than simply creating them like custom-buttons in the toolbar event?

Similar to REUSE_ALV_GRID_DISPLAY in class CL_GUI_ALV_GRID there is also a way.
Define a table of type UI_FUNCTIONS and a work area of type UI_FUNC :
data: lt_exclude type ui_functions,
ls_exclude type ui_func.
Append the attributes of the functions you want to hide to the table:
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
append ls_exclude to lt_exclude.
The attributes of the standard functions all begin with the prefix MC_FC_, in addition, there is the prefix MC_MB_ for an entire menu in the toolbar.
Pass the table using method set_table_for_first_display with parameter it_toolbar_excluding

If you use REUSE_ALV_GRID_DISPLAY in your code, this might be helpful for you:
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = 'ZPROGRAM'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_fieldcat = it_fieldcat
tables
t_outtab = gt_itab.
Your SET_PF_STATUS should be like this in order to eliminate some of the buttons you want. In this example I'm eliminating the "SORT_UP" button.
form set_pf_status using rt_extab type slis_t_extab.
data: lv_flag VALUE 'X'.
if lv_flag is not INITIAL.
append '&OUP' to rt_extab.
endif.
set pf-status 'STANDARD' excluding rt_extab.
endform. "set_pf_status
Hope it was helpful.
Talha

class lcl_event_alv definition .
public section .
methods handle_toolbar for event toolbar of cl_gui_alv_grid
importing e_object e_interactive sender.
class lcl_event_alv implementation .
method handle_toolbar.
delete e_object->mt_toolbar where function = '&LOCAL&INSERT_ROW' or function = '&LOCAL&DELETE_ROW'
or function = '&LOCAL&APPEND' or function = '&LOCAL&COPY'
or function = '&LOCAL&PASTE' or function = '&LOCAL&CUT'
or function = '&LOCAL&COPY_ROW' or function = '&LOCAL&CUT'.
endmethod.
data : go_event type ref to lcl_event_alv.
create object go_event .
set handler go_event->handle_toolbar for go_grid1.
call method go_grid1->set_table_for_first_display
exporting
is_layout = gd_layout
is_variant = value disvariant( report = sy-repid handle = 'GO_GRID1' )
i_save = 'A'
changing
it_fieldcatalog = gt_fcat1
it_outtab = gt_items1.

Related

Editable ALV with no limitation of lines

I need to create a report that displays an empty ALV with 4 columns and that is editable (the user can input on the fields of the ALV).
The ALV is going to be used as an input for the user and the data is then going to be read from the ALV.
What would be the best approach for this?
When youre setting the fieldcatalog, you need to declare "editable". For example
wa_fieldcat-fieldname = 'REMARKS'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-outputlen = 10.
wa_fieldcat-editable = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
Then you need to declare in your process after input(PAI) the check changed data of the alv.
alv->checked_changed_data

Spotfire - Is there a way to update a data function input parameters based on the slider property control values?

I have to change the axis columns for the custom plot(a plot which is added using RinR) based on the selection from the Slider property control.
I found this below code to be useful as it allows me to set the input parameter for my data function but I am not sure how to get the Slider value and to set the input as a column instead of a String as shown in this example.
from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Data.DataFunctions import *
dataManager = Document.Data
dataFunction = None
for function in dataManager.DataFunctions:
if function.Name == 'NewDF1':
dataFunction = function
for inputs in dataFunction.DataFunctionDefinition.InputParameters:
if inputs.DisplayName=="inputName":
dataFunction.Inputs.SetInput(inputs,"String(\"HelloWorld\")")

Populate a temp-table with widget-handle in progress abl

I am trying to create dynamically a group of buttons, using this code:
DEFINE VAR temp-hand AS WIDGET-HANDLE.
DEFINE INPUT PARAMETER ipc AS CHARACTER NO-UNDO.
&global-define X VALUE(v + ipc )
CREATE BUTTON temp-hand
ASSIGN
FRAME = FRAME btn-frame:HANDLE
ROW = vdeInicio
COLUMN = 10
WIDTH = 19
LABEL = ipc
SENSITIVE = TRUE
VISIBLE = TRUE
TRIGGERS:
ON CHOOSE PERSISTENT RUN btn-mess IN THIS-PROCEDURE.
END TRIGGERS.
temp-hand:LOAD-IMAGE("imagenes/Entradas").
vdeInicio = vdeInicio + 3.57.
This works when I address a single button widget, also if a write a loop and call a procedure with this code in it, it creates multiple buttons but points to one handle, some told me than creating a temp table and saving there the widget handle may work, but I donĀ“t know how to populate the table with the widget-handle, can you help me with this,
Something like this:
define temp-table tt_buttonList no-undo
field buttonId as integer
field buttonHandle as widget-handle
.
define variable i as integer no-undo.
do i = i to 5:
create tt_buttonList.
tt_buttonList.buttonId = i.
CREATE BUTTON tt_buttonList.buttonHandle
ASSIGN FRAME = FRAME btn-frame:HANDLE /* this is undefined in your example -- I have no idea where it came from */
ROW = i * 4
COLUMN = 10
WIDTH = 19
LABEL = string( i )
SENSITIVE = TRUE
VISIBLE = TRUE
.
end.
I've no idea why you would run code like this from a trigger procedure. While it might "work", mixing UI into db access code like that is really asking for serious trouble.

Enable standard toolbar for ALV grid

I created a screen for displaying ALV output but I am not able to show standard toolbar buttons (save, exit, back, etc.).
Can any one suggest how to enable them?
DATA: it_zztstudent type STANDARD TABLE OF zztstudent,
it_fcat TYPE STANDARD TABLE OF lvc_s_fcat,
i_selected_rows TYPE lvc_t_row,
w_selected_rows type lvc_s_row,
it_modified type STANDARD TABLE OF zztstudent,
lw_modified type zztstudent,
lw_zztstudent type zztstudent,
w_variant TYPE disvariant,
o_docking type REF TO cl_gui_docking_container,
o_grid type ref to cl_gui_alv_grid.
FIELD-SYMBOLS: <fs_fieldcat> type lvc_s_fcat.
tables: zztstudent.
select-OPTIONS: sst_id for zztstudent-st_id.
select * from zztstudent
into table it_zztstudent
where st_id in sst_id.
if sy-subrc NE 0.
message e001(zmsgpr).
ENDIF.
call screen 9000.
module status_9000 OUTPUT.
if o_docking is initial.
set PF-STATUS 'ZSTATUS'.
set titlebar 'ZTITLE'.
"Creating Docking Container and grid
PERFORM create_object.
"filling the fieldcatalog table
PERFORM create_fieldcat.
"Modifying the fieldcatalog table
PERFORM modify_fieldcat.
"Registering edit
PERFORM register_edit.
"displaying the output
PERFORM display_output.
ENDIF.
endmodule.
MODULE user_command_9000 INPUT.
Data: lv_ucomm TYPE sy-ucomm.
lv_ucomm = sy-ucomm.
CASE lv_ucomm.
WHEN 'CANCEL' oR 'EXIT'.
PERFORM free_objects.
leave program.
WHEN 'BACK'.
PERFORM free_objects.
SET SCREEN '0'.
leave SCREEN.
WHEN 'SAVE'.
PERFORM save_database.
CALL METHOD o_grid->refresh_table_display.
ENDCASE.
ENDMODULE.
Form create_object.
"create docking container
create object o_docking
exporting
ratio = '95'.
if sy-subrc eq 0.
"create grid
create OBJECT o_grid
exporting
i_parent = o_docking.
endif.
ENDFORM.
FORM create_fieldcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
I_STRUCTURE_NAME = 'ZZTSTUDENT'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
CT_FIELDCAT = IT_FCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
"making the column as editable
FORM modify_fieldcat.
loop at it_fcat ASSIGNING <fs_fieldcat>.
CASE <fs_fieldcat>-fieldname.
WHEN 'ST_NAME'.
<fs_fieldcat>-edit = 'X'.
WHEN 'ST_CITY'.
<fs_fieldcat>-edit = 'X'.
ENDCASE.
ENDLOOP.
ENDFORM.
FORM register_edit.
call METHOD o_grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
ENDFORM.
FORM display_output.
w_variant-report = sy-repid.
call METHOD o_grid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = 'A'
CHANGING
it_outtab = it_zztstudent
IT_FIELDCATALOG = it_fcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
if sy-subrc <> 0.
message e001(zmsgpr).
endif.
ENDFORM.
FORM free_objects.
call method o_grid->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
others = 3.
if sy-subrc <> 0.
message e001(zmsgpr).
endif.
call method o_docking->free
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
others = 3.
if sy-subrc <> 0.
message e001(zmsgpr).
endif.
ENDFORM.
First double click on set PF-STATUS 'ZSTATUS' on ZSTATUS and create object.
After that you will get here:
Click in functions Keys and add what code you want for each button.
Finally in a case statement, check if sy-ucomm has the value of the code you entered.
First you must create a method, in your class definition like this:
METHODS on_toolbar
FOR EVENT toolbar
OF cl_gui_alv_grid
IMPORTING e_object.
After that you must create an event object and there you must set the handler for the alvgrid object, like these:
IF gcl_container IS INITIAL.
CREATE OBJECT gcl_container
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT gcl_grid
EXPORTING
i_parent = gcl_container.
"erstellt einen Handler der alle ereignisse aufnimmt
"created object and set a handler of all events
CREATE OBJECT gcl_event.
SET HANDLER gcl_event->on_toolbar
FOR gcl_grid.
ENDIF.
Hope it helps you. :)

How to parameterize a link object/element in QTP?

Please give me a hint how to parameterize a link element in QTP...As we can parameterize 'WebEdit' element/object ,can we parameterize 'Link' element/object and how can we?
By parameterizing, do you mean Parameterizing the properties of the Link element to identify it using Descriptive Programming? Or is it something else?? Please elaborate!!
You can build a function like the one below for each object type that you want to use.
public Function CreateLinkDescription(LinkInnerTextValue, LinkHrefValue)
Set objLink = Description.Create()
objLink("innertext").Value = LinkInnerTextValue
objLink("href").Value = LinkHrefValue
'Add any other properties that you want to specify in the same fashion as above
Set CreateLinkDescription = objLink
End Function

Resources