I'm creating a zk component for mount easy grid from view database. One of its powerful features is the automatic generation of filters by column. These filters appear automatically on the top column inside the auxheader tag and all are generated programmatically in java with the column info. Example of database view TIMESTAMP column (sorry not css right now):
https://prnt.sc/ZK9nMws2l68p
My problem now is that I don't know how to bind these datebox generated programmatically in java with the view for recovering the filter values.
I was searching inside the zkoss wiki and only found this:
create data binding programmatically,
where you can find how bind zk components of the zul, or how bind components generated programatically if the parent has an item render option.
But i need generate N datebox, numberbox, textbox depending on the number and type of the columns and recover the values of it.
Anyone knows how do it?
The component has a loot of code and scrap, but more or less the idea is:
https://pastebin.com/Q5VX472L
cols.setParent(gridDatatable);
// create filters inside AuxHeads
Auxhead auxhead1 = new Auxhead();
// create a line with the same number of AuxHeaders as Columns we have
for (int indexColumn = 0; indexColumn < columnsList
.size(); indexColumn++) {
if (columnsList.get(indexColumn).getVisible()) {
// i have definned the diferent Auxheader with a patron factory
Auxheader auxheader = gridDatatableFilterFactory.generateFilter(
columnsList.get(indexColumn).getTerms().getType(),
columnsList.get(indexColumn).getTerms().getKey());
auxheader.setParent(auxhead1);
}
}
// set the Auxhead line between col names and rows
auxhead1.setParent(gridDatatable);
// we add the rowrender for print the rows
gridDatatable.setRowRenderer(
new DatatableRowRender(columnsList, gridDatatableCellFactory));
search();
Thank you in advance, regards.
As the hbase Support flexible schema and my usecase needs the qualifier is dynamic value and available only on some logic (if true add column else skip) in this case we are expecting put execution should be OK even without adding any columns to it.
But we are end up of getting this error:
java.lang.IllegalArgumentException: No columns to insert
at org.apache.hadoop.hbase.client.HTable.validatePut(HTable.java:1500)
at org.apache.hadoop.hbase.client.BufferedMutatorImpl.validatePut(BufferedMutatorImpl.java:152)
at org.apache.hadoop.hbase.client.BufferedMutatorImpl.mutate(BufferedMutatorImpl.java:127)
at org.apache.hadoop.hbase.client.HTable.put(HTable.java:1028)
Put p = new Put(Bytes.toBytes("rowkey"))
if(condition1){
p.addColumn(Bytes.toBytes("cf1"),Bytes.toBytes("Q1")
}
table.put(p)
All HBase data has to be associated with a column family, even if nothing else is populated. In your case, if !condition1 then you simply shouldn't write anything:
if(condition1){
Put p = new Put(Bytes.toBytes("rowkey"))
p.addColumn(Bytes.toBytes("cf1"),Bytes.toBytes("Q1")
table.put(p)
}
I am trying to read a table from an SAP system and I am always getting this error:
Exception in thread "main" com.sap.conn.jco.JCoRuntimeException: (127)
JCO_ERROR_FIELD_NOT_FOUND: Field EMPLOYEE is not a member of INPUT
at com.sap.conn.jco.rt.AbstractMetaData.indexOf(AbstractMetaData.java:404)
at com.sap.conn.jco.rt.AbstractRecord.setValue(AbstractRecord.java:4074)
at testConf.StepServer.main(StepServer.java:50)
And here is my code :
public static void main(String[] args) {
// This will create a file called mySAPSystem.jcoDestination
System.out.println("executing");
String DESTINATION_NAME1 = "mySAPSystem";
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "xxx.xxx.x.xxx");
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "xx");
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "xxx");
connectProperties.setProperty(DestinationDataProvider.JCO_USER, "username");
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "test");
connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "en");
createDestinationDataFile(DESTINATION_NAME1, connectProperties);
// This will use that destination file to connect to SAP
try {
JCoDestination destination = JCoDestinationManager.getDestination("mySAPSystem");
System.out.println("Attributes:");
System.out.println(destination.getAttributes());
System.out.println();
destination.ping();
} catch (JCoException e) {
e.printStackTrace();
}
try{
//here starts the problem
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME1);
JCoFunction function = destination.getRepository().getFunction("RFC_READ_TABLE");
JCoParameterList listParam = function.getImportParameterList();
listParam.setValue("EMPLOYEE", "EMPLOYEE"); // I have found this in an example and I don't understand exactly what should I put there
// I was thinking maybe is the column name but I am not sure
function.execute(destination);
JCoTable table = function.getTableParameterList().getTable("ZEMPLOYEES");//name of my table from SAP
System.out.println(table);
}
catch (JCoException e)
{
System.out.println(e.toString());
return;
}
}
The error is clear when it says JCO_ERROR_FIELD_NOT_FOUND: Field EMPLOYEE is not a member of INPUT but the employee is a field in my table.
The documentation doesn't help too much, it only says:
Sets the object as the value for the named field.
Parameters:
value - the value to set for the field
name - the name of the field to set
Witch, in my opinion, I have already done.
Should I make any additional modification in sap, in order to read this new table from java? All I have done is to create a new table following this tutorial (Create a simple table in SAP).
Maybe someone with more experience can tell me how should I configure this sample code in order to work.
General use of RFC_READ_TABLE
I never used JCo, but as far as I know its interface is very similar to NCo, the .Net connector. This is basically NCo code with some guesswork added to it, but it should work.
// get the table parameter FIELDS that should be in the parameter list
// the parameter table has several fields, only the field FIELDNAME has to be set before calling the function module
JCOTable inputTableParam = function.getTableParameterList().getTable("FIELDS");
// add a row to the FIELDS table parameter
inputTableParam.appendRow();
// set values for the new row
inputTableParam.setValue("FIELDNAME", "EMPLOYEE");
// just for fun, add another field to retrieve
inputTableParam.appendRow();
inputTableParam.setValue("FIELDNAME", "SURNAME");
// now we have to set the non-table parameters
JCoParameterList inputParamList = function.getImportParameterList();
// parameter QUERY_TABLE, defines which table to query
inputParamList.setValue("QUERY_TABLE", "ZEMPLOYEES");
// parameter DELIMITER - we get a single string as the return value, the field values within that string are delimited by this character
inputParamList.setValue("DELIMITER", ";");
// execute the function
function.execute(destination);
// the parameter table DATA contains the rows
JCoTable table = function.getTableParameterList().getTable("DATA");
in the end, your variable table will hold a table object with a single field called WA. That field contains the contents of the fields you selected in input parameter table FIELDS. You can iterate over table and get the values row by row.
Queries with RFC_READ_TABLE
RFC_READ_TABLE doesn't really allow queries, it only allows you to define WHERE clauses. The TABLE parameter OPTIONS has a single field TEXT, 72 characters wide, that can only take ABAP compliant WHERE clauses.
to extend the example above, we'll add a where clause to only select entries from table ZEMPLOYEES with SURNAME = "SMITH" and FORNAME = "JOHN".
JCOTable optionsTableParam = function.getTableParameterList().getTable("OPTIONS");
// add a row to the FIELDS table parameter
optionsTableParam.appendRow();
optionsTableParam.setValue("TEXT", "SURNAME EQ 'SMITH' AND FORNAME EQ 'JOHN');
the field TEXT is only 72 characters long, so if you want to add a longer clause, you manually have to break your conditions into several rows. RFC_READ_TABLE is a bit crude and limited.
Complex joins between tables can be achieved by creating a view within the SAP system (transaction SE11) and then query that view with RFC_READ_TABLE.
If you want to call function modules from JCo, it would be very helpful if you made yourself familiar with the basic function module properties. You can look at a function module definition in transaction SE37. There you can see the IMPORT, EXPORT, CHANGING and TABLE parameters. The parameters you have to fill and the parameters that contain the results depend on the function module you call - RFC_READ_TABLE has different ones from, say, BAPI_DELIVERY_GETLIST.
Here is the documentation for JCoFunction and one of the differences between JCo and NCo, JCo has individual functions to get and set the different parameter types: https://help.hana.ondemand.com/javadoc/com/sap/conn/jco/JCoFunction.html
You are trying to call the function RFC_READ_TABLE and you try to pass a value to its parameter named "EMPLOYEE". This is NOT a parameter of RFC_READ_TABLE, hence the error.
RFC_READ_TABLE has 3 important input parameters :
QUERY_TABLE : the name of the database table you want to query
OPTIONS : the WHERE clause (you may pass an empty value)
FIELDS : the list of columns from the database table you want to query
RFC_READ_TABLE has 1 return parameter :
DATA : the contents of the table
See this example : https://vishalmasih.wordpress.com/2014/10/31/sap-jco-searching-for-a-user-in-the-usr04-table/
My program should translate the pairs of key/value of a table to a escaped JSON for shell execution. This JTable is inside a JSplitPane, but only 4 rows are displayed and when there is less than 4 a white background appears where the other 1-3 rows should be. (There are more than 4 registers)
e.g.:
With data:
Without data:
As you can see the JSON on the bottom has all the table data, but the JTable is not rendering it right. Table filling code:
DefaultTableModel dtm = ((DefaultTableModel) tblParameters.getModel());
dtm.setRowCount(0);
currentFileParameters = (ReplacerLinkedHashMap<String, String>) FileParametersDAO.getInstance().getParametersForFile(file); // get parameters from database for specific file
for (Map.Entry<String, String> entry : currentFileParameters.entrySet()) {
dtm.addRow(new Object[]{entry.getKey(), entry.getValue()}); // add row
}
dtm.addRow(new Object[]{"", ""}); // add blank row for adding more parameters
tblParameters.revalidate(); // failure trying to resolve the problem [part 1]
tblParameters.repaint(); // failure trying to resolve the problem [part 2]
LocalProperties.setLastAccessedFile(file); // saves the accessed file
loadSavedFiles(); // load all saved files to other table (that has the same problem)
Table was working before and stopped suddenly. Thank you in advance.
I am pretty basic to link from Java to Database.
I link item from Database (I use MS.Access) to Java table (JTable)
but when I delete in JTable using this code
int numRows = tblweng.getSelectedRows().length;
for(int i=0; i<numRows ; i++ )
((DefaultTableModel)tblweng.getModel()).removeRow(tblweng.getSelectedRow());
it deletes only in Table but not in Database. So how I can remove both of them at the same time I click "Remove Button".
Please guide me but don't go too deep I am just a basic here. Thank in advance.
1. click Jtable // row selected
2. get data form dep_Table like
int a = dep_Table.getSelectedRow();
String b = String.valueOf(dep_Table.getValueAt(a, 1));
3. What data you want in you get and store in String
4. Connect Database
5. use Delete Query and Delete Data From Database
6. Reload Table Again
These Few basic Step is Enough for You.. I Think..