Enable standard toolbar for ALV grid - toolbar

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. :)

Related

Does a OUTER-JOIN always divide the query in two parts, leaving the part on the right empty if not complete in Progress?

I'm trying to do an OUTER-JOIN in progress using this page as inspiration. My code is as follows
OPEN QUERY qMovto
FOR EACH movto-estoq
WHERE movto-estoq.lote BEGINS pc-lote
AND movto-estoq.it-codigo BEGINS pc-it-codigo
AND movto-estoq.dt-trans >= pd-data1
AND movto-estoq.dt-trans <= pd-data2
AND movto-estoq.cod-emitente = pi-cod-emitente,
EACH item OUTER-JOIN
WHERE movto-estoq.it-codigo = item.it-codigo,
EACH item-cli OUTER-JOIN
WHERE item-cli.item-do-cli BEGINS pc-item-cli
AND movto-estoq.cod-emitente = item-cli.cod-emitente
AND movto-estoq.it-codigo = item-cli.it-codigo
AND movto-estoq.un = item-cli.unid-med-cli,
EACH nota-fiscal OUTER-JOIN
WHERE movto-estoq.nro-docto = nota-fiscal.nr-nota-fis
BY movto-estoq.dt-trans DESCENDING BY movto-estoq.hr-trans DESCENDING.
The problem that is happening is when 1 element in null, all the other elements that are in the OUTER-JOIN are appearing as null as well, even though they are not null. Is there a better way to write this code? Should I put 'LEFT' before the OUTER-JOIN? Thanks for your time.
To make your example easier, consider making it work from ABL dojo. The following code:
define temp-table ttone
field ii as int
.
define temp-table tttwo
field ii as int
field cc as char
.
create ttone. ttone.ii = 1.
create ttone. ttone.ii = 2.
create tttwo. tttwo.ii = 2. tttwo.cc = "inner".
create tttwo. tttwo.ii = 3. tttwo.cc = "orphan".
define query q for ttone, tttwo.
open query q
for each ttone,
each tttwo outer-join where tttwo.ii = ttone.ii.
get first q.
do while available ttone:
message ttone.ii tttwo.cc.
get next q.
end.
Can be run from https://abldojo.services.progress.com/?shareId=600f40919585066c219797ed
As you can see, this results in :
1 ?
2 inner
The join which is not available is shown as unknown. The value of the outer part of the join is shown.
Since you do not show how you are getting an unknown value for everything, maybe you are concatenating the unknown values?

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.

Losing some z3c relation data on restart

I have the following code which is meant to programmatically assign relation values to a custom content type.
publications = # some data
catalog = getToolByName(context, 'portal_catalog')
for pub in publications:
if pub['custom_id']:
results = catalog(custom_id=pub['custom_id'])
if len(results) == 1:
obj = results[0].getObject()
measures = []
for m in pub['measure']:
if m in context.objectIds():
m_id = intids.getId(context[m])
relation = RelationValue(m_id)
measures.append(relation)
obj.measures = measures
obj.reindexObject()
notify(ObjectModifiedEvent(obj))
Snippet of schema for custom content type
measures = RelationList(
title=_(u'Measure(s)'),
required=False,
value_type=RelationChoice(title=_(u'Measure'),
source=ObjPathSourceBinder(object_provides='foo.bar.interfaces.measure.IMeasure')),
)
When I run my script everything looks good. The problem is when my template for the custom content tries to call "pub/from_object/absolute_url" the value is blank - only after a restart. Interestingly, I can get other attributes of pub/from_object after a restart, just not it's URL.
from_object retrieves the referencing object from the relation catalog, but doesn't put the object back in its proper Acquisition chain. See http://docs.plone.org/external/plone.app.dexterity/docs/advanced/references.html#back-references for a way to do it that should work.

QTP Script to Get Field Values from QC

I want to get the count of status(Pass/Fail) of all testcases present in QC by checking the execution grid.
What is the method to retrieve the status and execution date of a test case ?
Currently I am only able to get the test case name.
Code:
Set treeMgr = gTDConn.TestSetTreeManager
Set tstTree = treeMgr.NodeByPath(TestSetPath)
Set tstFactory = tstTree.testSetFactory
Set tsetList = tstFactory.NewList("")
For Each tset In tsetList
msgbox tset.Name
next

How to exclude unnecessary buttons in ALV 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.

Resources