I implemented a drag and drop feature in one of my reports and it actually works fine when both grids are filled with data. When one of the grid is empty the drop feature is disabled. How can I change this?
I use the cl_gui_alv_grid class.
You may use the component cntr_ddid which represents the rest of the ALV grid control:
go_table->set_table_for_first_display(
EXPORTING
is_layout = VALUE #(
s_dragdrop = VALUE #(
cntr_ddid = l_dragdrop_handle ) )
...
Fully-working example (you may drag & drop the rows from the top table to the bottom table, initially empty -- the top table takes rows from the table SCARR that you may need to fill by calling the program SAPBC_DATA_GENERATOR --):
CLASS lcl_app DEFINITION.
PUBLIC SECTION.
METHODS main.
METHODS on_drag FOR EVENT ondrag OF cl_gui_alv_grid IMPORTING es_row_no e_dragdropobj.
METHODS on_drop FOR EVENT ondrop OF cl_gui_alv_grid.
PRIVATE SECTION.
DATA: go_split TYPE REF TO cl_gui_easy_splitter_container,
go_table1 TYPE REF TO cl_gui_alv_grid,
go_table2 TYPE REF TO cl_gui_alv_grid,
go_dragdrop1 TYPE REF TO cl_dragdrop,
go_dragdrop2 TYPE REF TO cl_dragdrop,
gt_scarr1 TYPE TABLE OF scarr,
gt_scarr2 TYPE TABLE OF scarr,
gs_scarr TYPE scarr.
ENDCLASS.
CLASS lcl_app IMPLEMENTATION.
METHOD main.
DATA: l_effect TYPE i,
l_dragdrop_handle1 TYPE i,
l_dragdrop_handle2 TYPE i.
go_split = NEW cl_gui_easy_splitter_container( parent = cl_gui_container=>screen0 ).
go_table1 = NEW cl_gui_alv_grid( i_parent = go_split->top_left_container ).
go_table2 = NEW cl_gui_alv_grid( i_parent = go_split->bottom_right_container ).
go_dragdrop1 = NEW cl_dragdrop( ).
go_dragdrop1->add(
flavor = 'DD1'
dragsrc = abap_true
droptarget = abap_false
effect = cl_dragdrop=>move ).
go_dragdrop2 = NEW cl_dragdrop( ).
go_dragdrop2->add(
flavor = 'DD1'
dragsrc = abap_false
droptarget = abap_true
effect = cl_dragdrop=>move ).
go_dragdrop1->get_handle( IMPORTING handle = l_dragdrop_handle1 ).
go_dragdrop2->get_handle( IMPORTING handle = l_dragdrop_handle2 ).
SELECT * FROM scarr INTO TABLE gt_scarr1.
go_table1->set_table_for_first_display(
EXPORTING
i_structure_name = 'SCARR'
is_layout = VALUE #(
s_dragdrop = VALUE #(
row_ddid = l_dragdrop_handle1 ) )
CHANGING
it_outtab = gt_scarr1 ).
go_table2->set_table_for_first_display(
EXPORTING
i_structure_name = 'SCARR'
is_layout = VALUE #(
s_dragdrop = VALUE #(
cntr_ddid = l_dragdrop_handle2 ) )
CHANGING
it_outtab = gt_scarr2 ).
SET HANDLER on_drag FOR go_table1.
SET HANDLER on_drop FOR go_table2.
ENDMETHOD.
METHOD on_drag.
DATA: lt_row TYPE lvc_t_roid.
FIELD-SYMBOLS:
<ls_row> TYPE lvc_s_roid.
go_table1->get_selected_rows( IMPORTING et_row_no = lt_row ).
READ TABLE gt_scarr1 INDEX lt_row[ 1 ]-row_id INTO gs_scarr.
e_dragdropobj->object = me. " dummy to trigger ON_DROP
ENDMETHOD.
METHOD on_drop.
APPEND gs_scarr TO gt_scarr2.
go_table2->refresh_table_display( is_stable = VALUE #( col = 'X' row = 'X' ) ).
ENDMETHOD.
ENDCLASS.
PARAMETERS p_dummy.
AT SELECTION-SCREEN OUTPUT.
NEW lcl_app( )->main( ).
Related
I was tinkering around with the INSERT INTO example from this post:
INSERT example:
import boto3
sql = """
INSERT INTO YOUR_TABLE_NAME_HERE
(
your_column_name_1
,your_column_name_2
,your_column_name_3)
VALUES(
:your_param_1_name
,:your_param_2_name)
,:your_param_3_name
"""
param1 = {'name':'your_param_1_name', 'value':{'longValue': 5}}
param2 = {'name':'your_param_2_name', 'value':{'longValue': 63}}
param3 = {'name':'your_param_3_name', 'value':{'stringValue': 'para bailar la bamba'}}
param_set = [param1, param2, param3]
db_clust_arn = 'your_db_cluster_arn_here'
db_secret_arn = 'your_db_secret_arn_here'
rds_data = boto3.client('rds-data')
response = rds_data.execute_statement(
resourceArn = db_clust_arn,
secretArn = db_secret_arn,
database = 'your_database_name_here',
sql = sql,
parameters = param_set)
print(str(response))
I quickly realized that I wasn't sure how to handle composite data types. For example, suppose that I have a composite data type of the form (integer, box). How do I specify its value for the parameters arg of boto3.client('rds-data').execute_statement()?
I wasn't able to find anything in these boto3 docs
Below is the result of an API call via Invoke-Restmethod
And output of $test.result.organizationContext is as follows
How can I add an line item to this "organizationContext" object with values for the different attributes like " name", "id" ?
If we assume that you already have the values you want to add defined in variables, you can create a new custom object and then effectively, yet inefficiently, add it to the array.
$newOrganizationContext = [pscustomobject]#{
classificationId = $classificationId
group = $group
id = $id
isGroupSeparator = $isGroupSeparator
name = $name
objectId = $objectId
path = $path
subClass = $subClass
synchronized = $synchronized
type = $type
}
$test.result.organizationContext += $newOrganizationContext
How do you grab an object based on its attribute (in this case, an ID that is assigned to it)? Here is an example of the code that I'm currently working on.
Ped = {} -- Ped class.
Ped.__index = Ped
gPedID = 0
gPedAdditionalID = "Shop"
function Ped.create(_type, _skin, _x, _y, _z)
local _ped = {}
setmetatable(_ped,Ped)
_ped.oType = _type
_ped.pedElement = createPed(_skin, _x, _y, _z)
_ped.ID = gPedID
gPedID = gPedID + 1
return _ped
end
function pedID(player, command)
-- code to grab the object based on the object.ID
end
I've tried to make a table that references the object, i.e:
generictable[_ped.ID] = _ped
But to no avail, I'm guessing the reason why is because it only copies the address, not the actual reference.
Help is much appreciated, thanks!
I have the following subroutine. It takes INPUT as argument 1 and sends multi-value data OUTPUT as argument 2.
SUBROUTINE MV_TO_DATASET_SELECT_SUBROUTINE(ARG_INPUT,ARG_OUTPUT)
x = ARG_INPUT
ARG_OUTPUT = "100":#VM:"101":#VM:"102":#VM:"103":#FM:"Nancy":#VM:"Andrew":#VM:"Janet":#VM:"Margaret":#FM:"01/06/1991":#VM:"06/07/1996":#VM:"11/08/1999":#VM:"12/10/2001"
RETURN
The Schema of above subroutine’s multi-value data is as below.
DataSet ds = new DataSet();
DataTable dt = new DataTable("Employee");
ds.Tables.Add(dt);
dt.Columns.Add("ID",typeof(Int32));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("HireDate", typeof(DateTime));
You can achevieve this task one of the following ways:
Use MV_To_DataTable() and DataTable_To_MV(). You can create schema of
subroutine by dragging and dropping Empty DataTable into Empty
DataSet Deginer.
By draagging and dropping Visual Studio Server Explorer’s U2
Subroutine into DataSet Designer. U2 Subrotine returns
resultset/dataset by executing API such as ST=SQLExecDirect(#HSTMT,
"SELECT F1 AS COL1,F2 AS COL2 ,F3 AS COL3 FROM #TMP SLIST 9 ORDER BY
1")
Use MV_To_DataTable() and DataTable_To_MV()
Create ASP.NET Web Application Project. Type ‘WebApplication_Subroutine’ in Project Name.
Add Reference to U2NETDK Assembly (U2.Data.Client)
Change header ‘Welcome to ASP.NET!’ to ‘Welcome to U2 Toolkit for .NET Demo on Business Logic Subroutine’s multi-value string data to .NET DataSet!’
Open ‘Default.aspx’ file and Go to Design Mode.
Do the following:
Drag and Drop Button Control. Name it ‘Load’
Drag and Drop Button Control. Name it ‘Update’
Drag and Drop GridView Control.
Right Click on Solution Explorer. Select Add ->New Item-DataSet. In the Name box, type ‘Employee.xsd’
Drag and Drop DataTable into Designer. Change the name to ‘Employee’ Table.
Create 3 new Columns (U2 subroutine Schema):
ID – DataType : INT
Name – DataType : STRING
HireDate - DataType : DATE
Open ‘Default.aspx’ file in Design Mode. Double Click ‘Load Button’. It will create Event handler Code behind.
Cut and paste the following code.
protected void Button1_Click(object sender, EventArgs e)
{
U2ConnectionStringBuilder l = new U2ConnectionStringBuilder();
l.Server = "127.0.0.1";
l.UserID = "user";
l.Password = "pass";
l.Database = "HS.SALES";
l.ServerType = "universe";
string lconnstr = l.ToString();
U2Connection c = new U2Connection();
c.ConnectionString = lconnstr;
c.Open();
U2Command command = c.CreateCommand();
command.CommandText = "CALL MV_TO_DATASET_SELECT_SUBROUTINE(?,?)";
command.CommandType = CommandType.StoredProcedure;
U2Parameter p1 = new U2Parameter();
p1.Direction = ParameterDirection.InputOutput;
p1.Value = "";
p1.ParameterName = "#arg_input";
command.Parameters.Add(p1);
U2Parameter p2 = new U2Parameter();
p2.Direction = ParameterDirection.InputOutput;
p2.Value = "";
p2.ParameterName = "#arg_output";
command.Parameters.Add(p2);
command.ExecuteNonQuery();
Employee.EmployeeDataTable dt = new Employee.EmployeeDataTable();
command.Parameters[1].MV_To_DataTable(dt);
Session["GridDataset"] = dt;
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
Run the application. Press ‘Load’ Button.
Open ‘Default.aspx’ file in Design Mode. Double click ‘Update Button’. It will create Event Handler in Code behind page.
Cut and Paste the following Code.
protected void Button2_Click(object sender, EventArgs e)
{
DataTable dt = (DataTable)Session["GridDataset"];
//To TEST, change first row
string s1 = (string)dt.Rows[0]["Name"];
dt.Rows[0]["Name"] = s1 + "NewValue";
// get the modified rows
DataTable dt_changed = dt.GetChanges();
//call DATASET_TO_MV_UPDATE_SUBROUTINE
U2ConnectionStringBuilder l = new U2ConnectionStringBuilder();
l.Server = "127.0.0.1";
l.UserID = "user";
l.Password = "pass";
l.Database = "HS.SALES";
l.ServerType = "universe";
string lconnstr = l.ToString();
U2Connection c = new U2Connection();
c.ConnectionString = lconnstr;
c.Open();
U2Command command = c.CreateCommand();
command.CommandText = "CALL DATASET_TO_MV_UPDATE_SUBROUTINE(?)";
command.CommandType = CommandType.StoredProcedure;
U2Parameter p1 = new U2Parameter();
p1.Value = "";
p1.Direction = ParameterDirection.InputOutput;
p1.ParameterName = "#arg_data";
command.Parameters.Add(p1);
command.Parameters[0].DataTable_To_MV(dt_changed);
// modified data going to subroutine
string lData = (string)command.Parameters[0].Value;
command.ExecuteNonQuery();
}
See the Modified Value in the Debugger when you click Update Button.
U2 Subrotine returns resultset/dataset
Create U2 Data Connection in Visual Studio Server Explorer. Expand Store Procedures Node.
Go to subroutine that returns resultset/dataset. Drag and Drop subroutine into DataSet Designer.
It shows INPUT argument and resultset/dataset columns.
I have a type defined in Types like this "create or replace type numbers_table is table of numbers". I have a procedure that has a parameter of this type (ids_list IN numbers_table).
On calling the procedure with Oracle Client I keep receiving the "..Wrong number or types of arguments ..." error.
I am passing this parameter like this:
OracleParameter param1 = new OracleParameter("ids_list", OracleDbType.Decimal, ParamDirection.Input);
param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
param1.ArrayBindSize = new int[collectioncount];
param1.ArrayBindStatus = new OracleParameterStatus[collectioncount];
param1.Size = collectioncount;
for(int i = 0; i < collectioncount; i++)
{
param1[i].ArrayBindSize = 8000;
param1[i].ArrayBindStatus = new OracleParameterStatus.Success;
}
param1.Value = collection;
Still no luck ... I have tried to change OracleDbType.Decimal to Double, Long, Int64 etc but nothing works for me.