ABAP drag and drop object on ALV GRID - drag-and-drop

I discover the Drag AND Drop object on my alv grid, but when I search documentation it's hard to understand the process flow ,
I have a lot of questions :
I want to block the possibility to drag and drog on some columns.
And I want that the sign that not allowed appear.
I want that when I select more than one line, On the drop place display the focus on more than one cell.
This is my code :
In My Class : In the Definition
on_drag FOR EVENT ondrag OF cl_gui_alv_grid
IMPORTING e_column e_row es_row_no e_dragdropobj,
on_drop FOR EVENT ondrop OF cl_gui_alv_grid
IMPORTING e_column e_row es_row_no e_dragdropobj,
In the Implementation:
METHOD on_drag.
DATA: lr_objct TYPE REF TO lcl_dragdropobj.
CREATE OBJECT lr_objct.
gr_alvpl->get_selected_cells( IMPORTING et_cell = lr_objct->lt_cells ).
e_dragdropobj->object = lr_objct.
ENDMETHOD. "on_drag
METHOD on_drop.
DATA: lv_lines TYPE i,
lv_tolin TYPE i,
lv_icone TYPE icon,
ls_cells TYPE lvc_s_cell,
ls_colmn TYPE lvc_s_col,
ls_trows TYPE lvc_s_row,
ls_tbalv TYPE zscad_planification,
lv_value TYPE string,
lr_objct TYPE REF TO lcl_dragdropobj.
FIELD-SYMBOLS: <struc> TYPE zscad_planification,
<value> TYPE ANY.
PERFORM verif_before_dad.
lr_objct ?= e_dragdropobj->object.
DESCRIBE TABLE lr_objct->lt_cells LINES lv_lines.
lv_tolin = e_row + lv_lines.
*
* DATA: lt_field TYPE TABLE OF sval,
* ls_field TYPE sval.
*
* ls_field-fieldname = 'comment'.
* ls_field-fieldtext = 'Vous pouvez saisir un message'.
* APPEND ls_field TO lt_field.
* CALL FUNCTION 'POPUP_GET_VALUES'
* EXPORTING
** NO_VALUE_CHECK = ' '
* popup_title = 'Confirmation'
** START_COLUMN = '5'
** START_ROW = '5'
** IMPORTING
** RETURNCODE =
* tables
* fields = lt_field
** EXCEPTIONS
** ERROR_IN_FIELDS = 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.
LOOP AT lr_objct->lt_cells INTO ls_cells.
CLEAR: ls_colmn, ls_trows.
ls_colmn = ls_cells-col_id.
ls_trows = ls_cells-row_id.
READ TABLE gt_tbalv ASSIGNING <struc> INDEX ls_trows-index.
IF sy-subrc EQ 0.
CONCATENATE '<struc>-' ls_colmn-fieldname INTO lv_value.
ASSIGN (lv_value) TO <value>.
lv_icone = <value>.
CLEAR: <value>.
ENDIF.
ENDLOOP.
* Fill the new Day
LOOP AT lr_objct->lt_cells INTO ls_cells.
CLEAR: ls_colmn, ls_trows.
ls_colmn = e_column.
* ls_colmn = ls_cells-col_id.
ls_trows = ls_cells-row_id.
READ TABLE gt_tbalv ASSIGNING <struc> INDEX ls_trows-index.
IF sy-subrc EQ 0.
CONCATENATE '<struc>-' ls_colmn-fieldname INTO lv_value.
ASSIGN (lv_value) TO <value>.
<value> = lv_icone.
ENDIF.
ENDLOOP.
gr_alvpl->refresh_table_display( ).
ENDMETHOD. "on_drop
METHOD on_date_selected.
gv_datax = date_begin.
PERFORM destroy_all_object.
* PERFORM refresh_alv.
ENDMETHOD.
And when I build my ALV, I launch this routine :
FORM alv_dragdrop.
DATA: lv_effct TYPE i,
lv_hndla TYPE i,
ls_dragd TYPE lvc_s_dd01.
* Define a behaviour for drag and drop on ALV objects and get its handle.
* Define a drag & Drop behaviour for the whole grid
CREATE OBJECT gr_dragd.
lv_effct = cl_dragdrop=>move + cl_dragdrop=>copy.
CALL METHOD gr_dragd->add
EXPORTING
flavor = 'Line'
dragsrc = 'X'
droptarget = 'X'
effect = lv_effct.
CALL METHOD gr_dragd->get_handle
IMPORTING
handle = lv_hndla.
* Provide handle to alv control using the layout-structure
ls_dragd-row_ddid = lv_hndla.
gs_layou-s_dragdrop = ls_dragd.
ENDFORM. " ALV_DRAGDROP
Thanks. Regards,

I think that it s not possible

Related

Can someone help me with the update function in Matlab to move values to MySQL?

I'm dealing with a problem with the update function in Matlab.
conn=database('MySQL','user','password');)
selectquery_select = 'SELECT * FROM inputs WHERE i_read = 0';
data_select = select(conn,selectquery_select);
for j=1:size(data_select)
id_data = data_select(j,1);
id_data = string(id_data.(1));
time_data = data_select(j,4);
time_data = string(time_data.(1));
time_dataform = datetime(time_data,'InputFormat','yyyy-MM-dd HH:mm:ss');
y0=data_select(j,2);
y0 = str2num(string(y0.(1)));
r0=data_select(j,3);
r0 = str2num(string(r0.(1)));
if id_data == "115"
run("C:\Users\...\uu.m")
update(conn,'inputs','i_read',1,'WHERE (ID_code = "115") AND WHERE (i_Time = time_data)');
end
end
Basically, I'm taking some value from the database when i_read is equal to 0 (i_read is a boolean variable in the database that should give 1 if the value is already processed and 0 if not). After a value is read, we want to change the i_read in the database from 0 to 1. We decide to use the update function, but this gave us the following error:
Error using database.odbc.connection/update
Too many input arguments.
Error in Patient_Identification (line 57)
update(conn,'inputs','i_read',1,'WHERE (ID_code = "112") AND WHERE (i_Time = ', time_data,')');
Someone is able to help us with this problem? Thank you.

Weird error while using constant properties in class

I am trying to save functions as variables inside a class so I can reach them in an ordered manner. However, whenever I try to pull any constant from the following class, I get the following error.
%FORMULAS Summary of this class goes here
% Detailed explanation goes here
properties (Constant)
%F.heatCapacityOfLiquid
t = #(z) z *2
end
properties (Constant)
enthalpyChange = #(constants, temperatureIn, temperatureOut)integral(#(temperature)(#(constants, temperature)...
constants(1)...
+ temperature * constants(2)...
+ temperature.^2 * constants(3)...
+ temperature.^3 * constants(4)), 0,10);
heatCapacityOfLiquid = #(constants, temperature) constants(1)...
+ temperature * constants(2)...
+ temperature.^2 * constants(3)...
+ temperature.^3 * constants(4);
end
end
ERROR
>> F.t
Invalid default value for property 'enthalpyChange' in class 'F':
Error: Invalid use of operator.

Libre Office custom Dialog Table

I am creating a custom Dialog where the user is supposed to select one of multiple possible entries. I use a List Box to list the possible entries to be selected from.
There are multiple variables for each row, therefore I would like to use a table to properly align the entries. Is there a possibility to do so?
What i have:
abcdefg hijkl mnopq
abcd efghijk lmno
What i want:
abcdefg hijkl mnopq
abcd efghilkl mno
Use a fixed-width font for the list box, and pad the strings with spaces.
Sub PaddedListboxItems
oListBox.addItems(Array(
PaddedItem(Array("abcdefg", "hijkl", "mnopq")),
PaddedItem(Array("abcd", "efghijk", "lmno"))), 0)
End Sub
Function PaddedItem(item_strings As Array)
PaddedItem = PadString(item_strings(0), 10) & _
PadString(item_strings(1), 11) & item_strings(2)
End Function
Function PadString(strSource As String, lPadLen As Long)
PadString = strSource & " "
If Len(strSource) < lPadLen Then
PadString = strSource & Space(lPadLen - Len(strSource))
End If
End Function
More ways to pad strings in Basic are at http://www.tek-tips.com/viewthread.cfm?qid=522164, although not all of them work in LibreOffice Basic.
Yes, it is possible.
Create a new dialog and at the bottom, add a label.
Create a new module and add following code:
Option Explicit
Option Base 0
Dim oDialog1 As Object, oDataModel As Object, oListener As Object
Sub OpenDialog()
Dim oGrid As Object, oGridModel As Object, oColumnModel As Object, oCol As Object
Dim oLabel1 As Object, rect(3) As Integer
DialogLibraries.LoadLibrary("Standard")
oDialog1 = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
oGridModel = oDialog1.getModel().createInstance("com.sun.star.awt.grid.UnoControlGridModel")
oLabel1 = oDialog1.getModel().getByName("Label1")
rect(0) = oLabel1.getPropertyValue("PositionX")
rect(1) = 10
rect(2) = oLabel1.getPropertyValue("Width")
rect(3) = oLabel1.getPropertyValue("PositionY") - 2*rect(1)
With oGridModel
.PositionX = rect(0)
.PositionY = rect(1)
.Width = rect(2)
.Height = rect(3)
End With
oColumnModel = oGridModel.ColumnModel
oCol = oColumnModel.createColumn()
oCol.Title = "Column 1"
oColumnModel.addColumn(oCol)
oCol = oColumnModel.createColumn()
oCol.Title = "Column 2"
oColumnModel.addColumn(oCol)
oCol = oColumnModel.createColumn()
oCol.Title = "Column 3"
oColumnModel.addColumn(oCol)
oDialog1.getModel().insertByName("grid", oGridModel)
oGrid = oDialog1.getControl("grid")
oListener = (CreateUnoListener("grid_", "com.sun.star.awt.grid.XGridSelectionListener"))
oGrid.addSelectionListener(oListener)
oDataModel = oGridModel.GridDataModel
oDataModel.addRow("a", Array("abcdefg", "hijkl", "mnopq"))
oDataModel.addRow("b", Array("abcd", "efghijk", "lmno"))
oDialog1.execute()
oDialog1.dispose()
End Sub
To get the values of the selected row, add a listener for the grid_selectionChanged event:
Sub grid_selectionChanged(ev)
Dim oRows() As Object, oLabel1 As Object, sCells(2) As String
oRows = ev.Source.getSelectedRows()
oLabel1 = oDialog1.getModel().getByName("Label1")
sCells(0) = oDataModel.getRowData(oRows(0))(0)
sCells(1) = oDataModel.getRowData(oRows(0))(1)
sCells(2) = oDataModel.getRowData(oRows(0))(2)
oLabel1.setPropertyValue("Label", "Selected values: " + sCells(0) + "," + sCells(1) + "," + sCells(2))
End Sub
If you did all correctly, by running OpenDialog you should get your grid:

How do you order annotations by offset in brat?

When using the rapid annotator tool brat, it appears that the created annotations file will present the annotation in the order that the annotations were performed by the user. If you start at the beginning of a document and go the end performing annotation, then the annotations will naturally be in the correct offset order. However, if you need to go earlier in the document and add another annotation, the offset order of the annotations in the output .ann file will be out of order.
How then can you rearrange the .ann file such that the annotations are in offset order when you are done? Is there some option within brat that allows you to do this or is it something that one has to write their own script to perform?
Hearing nothing, I did write a python script to accomplish what I had set out to do. First, I reorder all annotations by begin index. Secondly, I resequence the label numbers so that they are once again in ascending order.
import optparse, sys
splitchar1 = '\t'
splitchar2 = ' '
# for brat, overlapped is not permitted (or at least a warning is generated)
# we could use this simplification in sorting by simply sorting on begin. it is
# probably a good idea anyway.
class AnnotationRecord:
label = 'T0'
type = ''
begin = -1
end = -1
text = ''
def __repr__(self):
return self.label + splitchar1
+ self.type + splitchar2
+ str(self.begin) + splitchar2
+ str(self.end) + splitchar1 + self.text
def create_record(parts):
record = AnnotationRecord()
record.label = parts[0]
middle_parts = parts[1].split(splitchar2)
record.type = middle_parts[0]
record.begin = middle_parts[1]
record.end = middle_parts[2]
record.text = parts[2]
return record
def main(filename, out_filename):
fo = open(filename, 'r')
lines = fo.readlines()
fo.close()
annotation_records = []
for line in lines:
parts = line.split(splitchar1)
annotation_records.append(create_record(parts))
# sort based upon begin
sorted_records = sorted(annotation_records, key=lambda a: int(a.begin))
# now relabel based upon the sorted order
label_value = 1
for sorted_record in sorted_records:
sorted_record.label = 'T' + str(label_value)
label_value += 1
# now write the resulting file to disk
fo = open(out_filename, 'w')
for sorted_record in sorted_records:
fo.write(sorted_record.__repr__())
fo.close()
#format of .ann file is T# Type Start End Text
#args are input file, output file
if __name__ == '__main__':
parser = optparse.OptionParser(formatter=optparse.TitledHelpFormatter(),
usage=globals()['__doc__'],
version='$Id$')
parser.add_option ('-v', '--verbose', action='store_true',
default=False, help='verbose output')
(options, args) = parser.parse_args()
if len(args) < 2:
parser.error ('missing argument')
main(args[0], args[1])
sys.exit(0)

Value changing event in browser?

define variable hOrderQuery as handle no-undo.
define variable browseOrder-hdl as handle no-undo.
define variable browse-hdl as handle no-undo.
define variable CNumber as integer no-undo.
CREATE QUERY hQuery.
hQuery:SET-BUFFERS(BUFFER Customer:HANDLE).
hQuery:QUERY-PREPARE("FOR EACH Customer").
hQuery:QUERY-OPEN().
CREATE BROWSE browse-hdl
ASSIGN
TITLE = "Customer Browser"
FRAME = FRAME MyFrame:HANDLE
QUERY = hQuery
X = 2
Y = 2
WIDTH = 74
DOWN = 10
VISIBLE = YES
SENSITIVE = TRUE
READ-ONLY = yes.
browse-hdl:ADD-COLUMNS-FROM(BUFFER Customer:HANDLE,"SalesRep,email,fax,comments,address,City,State,PostalCode").
on value-changed of browse-hdl
do:
FIND CURRENT Customer.
cNumber = Customer.CustNum.
CREATE QUERY hOrderQuery.
hOrderQuery:SET-BUFFERS(BUFFER Order:HANDLE).
hOrderQuery:QUERY-PREPARE("FOR EACH Order where Order.CustNum = " + string(cNumber)) no- error.
hOrderQuery:QUERY-OPEN().
CREATE BROWSE browseOrder-hdl
ASSIGN
TITLE = "Order Browser"
FRAME = FRAME MyFrame:HANDLE
QUERY = hOrderQuery
X = 2
Y = 240
WIDTH = 74
DOWN = 10
VISIBLE = YES
SENSITIVE = TRUE
READ-ONLY = yes.
browseOrder-hdl:ADD-COLUMNS-FROM(BUFFER Order:HANDLE,"warehousenum,CustNum").
end.
on value-changed of browseOrder-hdl
do:
message "hai" view-as alert-box.
end.
this is my issue.I have 3 browsers.Now i created only two. When I click on first customer browser's one row it should select the current customer and should show his order in the second browser-order browser.
When I click on order browser value it should show the corresponding orderline table values in the 3rd orderline browser(which i didnt create now).
So when I tried to take the browseOrder-hdl to create second value-changed event, it is showing it is already deleted.
How to overcome this issue??Please reply.
DEFINE FRAME MyFrame
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1
SIZE 80 BY 16.
define variable hOrderQuery as handle no-undo.
define variable browseOrder-hdl as handle no-undo.
define variable browse-hdl as handle no-undo.
define variable CNumber as integer no-undo.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
CREATE QUERY hQuery.
hQuery:SET-BUFFERS(BUFFER Customer:HANDLE).
hQuery:QUERY-PREPARE("FOR EACH Customer").
hQuery:QUERY-OPEN().
CREATE BROWSE browse-hdl
ASSIGN
TITLE = "Customer Browser"
FRAME = FRAME MyFrame:HANDLE
QUERY = hQuery
X = 2
Y = 2
WIDTH = 74
DOWN = 10
VISIBLE = TRUE
SENSITIVE = TRUE
READ-ONLY = TRUE
TRIGGERS:
ON VALUE-CHANGED DO:
RUN ShowOrderBrowser.
END.
END.
browse-hdl:ADD-COLUMNS-FROM(BUFFER Customer:HANDLE,"SalesRep,email,fax,comments,address,City,State,PostalCode").
WAIT-FOR CLOSE OF THIS-PROCEDURE.
/* ********************** Internal Procedures *********************** */
PROCEDURE ShowOrderBrowser:
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
FIND CURRENT Customer.
cNumber = Customer.CustNum.
CREATE QUERY hOrderQuery.
hOrderQuery:SET-BUFFERS(BUFFER Order:HANDLE).
hOrderQuery:QUERY-PREPARE("FOR EACH Order WHERE Order.CustNum = " + STRING(cNumber)).
hOrderQuery:QUERY-OPEN().
CREATE BROWSE browseOrder-hdl
ASSIGN
TITLE = "Order Browser"
FRAME = FRAME MyFrame:HANDLE
QUERY = hOrderQuery
X = 2
Y = 240
WIDTH = 74
DOWN = 10
VISIBLE = TRUE
SENSITIVE = TRUE
READ-ONLY = TRUE
TRIGGERS:
ON VALUE-CHANGED DO:
MESSAGE "hai"
VIEW-AS ALERT-BOX.
END.
END.
browseOrder-hdl:ADD-COLUMNS-FROM(BUFFER Order:HANDLE,"warehousenum,CustNum").
WAIT-FOR VALUE-CHANGED OF browseOrder-hdl.
END PROCEDURE.