I am using RFC function to receive data from sap abap side that sending from java. There is no error from java side . Problem is I cannot capture data from sap side. I need to save those data in a sap ztable.
This is my java code.
public class CreateAttendence extends TimerTask {
RFCHandler handler;
DBPool_SF pooler;
DataSource dataSource;
DataSource dataSource1;
int rcount = 0;
private Object[][] itemData;
public CreateAttendence() {
handler = new RFCHandler();
}
@Override
public void run() {
try {
getItem();
sendValuesToSap();
} catch (Exception e) {
e.printStackTrace();
}
}
private void getItem() {
// TODO Auto-generated method stub
Connection con3 = null;
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
System.out.println(dateFormat.format(date));
String sbQuery3 = "SELECT * FROM attendance_log ";
try {
pooler = DBPool_SF.getInstance();
dataSource1 = pooler.getDataSource();
} catch (Exception e1) {
e1.printStackTrace();
}
try {
con3 = dataSource1.getConnection();
con3.setAutoCommit(false);
Statement st = con3.createStatement();
ResultSet rs = st.executeQuery(sbQuery3);
int lineitem = 0;
try {
rs.last();
rcount = rs.getRow();
rs.beforeFirst();
} catch (Exception ex) {
ex.printStackTrace();
}
itemData = new Object[6][rcount];
while (rs.next()) {
itemData[0][lineitem] = rs.getString("device_id");
itemData[1][lineitem] = rs.getString("user_id");
itemData[2][lineitem] = rs.getDate("check_in"); // in date
itemData[3][lineitem] = rs.getDate("check_out"); // out date
itemData[4][lineitem] = rs.getTime("check_in"); // in time
itemData[5][lineitem] = rs.getTime("check_out"); // out time
lineitem = lineitem + 1;
}
} catch (SQLException e) {
e.printStackTrace();
}
try {
con3.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void sendValuesToSap() {
JCO.Table IT_LIST = null;
try {
if (rcount > 0) {
handler.createRFCFunction("ZZSL_ATEND_CRT_LOG_TBL");
IT_LIST = handler.getTablePara("IT_LIST");
for (int x = 0; x < rcount; x++) {
IT_LIST.appendRow();
System.out.print(itemData[1][x] + " ");
System.out.print(itemData[2][x] + " ");
System.out.print(itemData[3][x] + " ");
System.out.print(itemData[4][x] + " ");
System.out.print(itemData[5][x] + " ");
System.out.println();
IT_LIST.setValue("110", "MANDT");
IT_LIST.setValue(itemData[1][x], "PERNR");
IT_LIST.setValue(itemData[2][x], "DATE1");
IT_LIST.setValue(itemData[3][x], "DATE2");
IT_LIST.setValue(itemData[4][x], "TIN1");
IT_LIST.setValue(itemData[5][x], "TOUT1");
}
System.out.println(IT_LIST);
handler.excFunction();
handler.releaseClient();
}
} catch (Exception e) {
// TODO: handle exception
handler.releaseClient();
e.printStackTrace();
}
finally {
rcount = 0;
}
}
}
This is my ABAP code.
FUNCTION ZZSL_ATEND_CRT_LOG_TBL.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" IT_LIST STRUCTURE ZSLATENLOG
*" IT_LIST_T STRUCTURE ZSLATENLOG
*"----------------------------------------------------------------------
DATA : wa_list LIKE LINE OF IT_LIST,
wa_list_t LIKE LINE OF IT_LIST.
INSERT ZSLATENLOG FROM IT_LIST.
ENDFUNCTION.
ZSLATENLOG is my z table.