[Java] SAP RFC 조회
- 📕 Programing/Java
- 2021. 8. 31. 18:14
참고 URL
http://www.henrikfrank.dk/abaptips/javaforsap/javabasics/sapjava_simple_rfc.htm
SAP Java Connector - Excample 1: CompanyCode_GetList
SAP Java Connector - Excample 1: Simple RFC call Scenario We will call the RFC function module ZNAS_HIE1_GET_MEMBER_FARM.that returns members that have owned a farm. Input to the function is a farm number, and output is a table of members that have owned t
www.henrikfrank.dk
public static Boolean isSapRecall(String changeNumber) {
/*
* true --> 가능
* false --> 안됨 ( In process )
*/
LOGGER.debug("//////////////// isSapRecall start /////////////// "+serverType+"///");
boolean returnValue = true;
SapConnectionManager sapConnectionManager = new SapConnectionManager();
IRepository repository = null;
JCO.Client client = null;
String SID = "ABAP_AS";
String sFuncName = "ZPLM_PDMLINK_ECO_STATUS_INFO";
String tableName = "ET_ECO_LIST";
try {
if (serverType == 0) {
//운영
client = JCO.createClient(
"100",
"RFCCAD",
"hyosung00",
"EN",
"nherpdb.hyosung.com",
"40"
//"NEP",
//"nherp"
);
} else if(serverType == 1){
//개발
client = JCO.createClient(
"100",
"RFCCAD",
"hyosung00",
"EN",
"tnsdeccsvr01.hyosung.com",
"40"
);
} else if(serverType == 2) {
return true;
}
client.connect();
repository = new JCO.Repository("ABAP_AS", client);
IFunctionTemplate ftemplate = repository.getFunctionTemplate(sFuncName);
JCO.Function function = ftemplate.getFunction();
ParameterList pList = function.getImportParameterList();
//JCO.Structure input = pList.getStructure(tableName);
pList.getField("I_AENNR").setValue(changeNumber);
client.execute(function);
JCO.ParameterList table2 = function.getTableParameterList();
JCO.Table iTable2 = table2.getTable(tableName);
for (int i = 0; i < iTable2.getNumRows(); i++) {
String AENNR = (String) iTable2.getValue("AENNR");
String AENST = (String) iTable2.getValue("AENST");
String ZAENST = (String) iTable2.getValue("ZAENST");
String ZWERKS = (String) iTable2.getValue("ZWERKS");
String ANNAM = (String) iTable2.getValue("ANNAM");
Date ANDAT = (Date) iTable2.getValue("ANDAT");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String S_ANDAT = df.format(ANDAT);
LOGGER.info("ZPLM_PDMLINK_ECO_STATUS_INFO :: AENNR={}, AENST={}, ZAENST={}, ZWERKS={}, ANNAM={}, S_ANDAT={}"
, AENNR, AENST, ZAENST, ZWERKS, ANNAM, S_ANDAT);
if( "In Process".equals(ZAENST)) {
returnValue = false;
}else if("Released".equals(ZAENST)) {
returnValue = false;
}else if("Rejected".equals(ZAENST)) {
returnValue = true;
}
iTable2.nextRow();
}
String type = function.getExportParameterList().getString("E_TYPE");
String message = function.getExportParameterList().getString("E_MESSAGE");
LOGGER.info("EPM APPROVAL SEND RESULT :: ETYPE={}, E_MESSAGE={}" + type, message);
if ("S".equals(type)) {
} else {
returnValue = false;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
client.disconnect();
}
return returnValue;
}
커넥션 정보
package e3ps.common.util;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
public class SapConnectionManager {
static final String SID = "ABAP_AS";
public IRepository getPoolConnection() throws Exception {
return getConnection(SID);
}
public IRepository getConnection(String sid) throws Exception {
return getConnection100(sid);
}
public IRepository getConnection100(String sid) throws Exception {
IRepository repository = null;
try {
JCO.addClientPool(sid, // Alias for this pool
3, // Max. number of connections
"100", // SAP client
"RFCCAD", // userid
"hyosung00", // password
"EN", // language
"150.15.214.5", // host name
"40");
repository = JCO.createRepository("MYRepository", sid);
} catch (Exception ex) {
ex.printStackTrace();
throw ex;
}
return repository;
}
public void cleanUp() {
JCO.removeClientPool(SID);
}
public void cleanUp(String sid) {
JCO.removeClientPool(sid);
}
}
'📕 Programing > Java' 카테고리의 다른 글
[Java] 메서드 실행 시간 구하기(초) (0) | 2021.10.13 |
---|---|
SAP RFC 연결 오류 (0) | 2021.09.02 |
[Java] Arryas 기본 사용법 (0) | 2021.06.07 |
[Java] Map 관련 Iterate(반복문) 방법 (0) | 2021.03.22 |
[Java] 람다식(Lambda Expression) (0) | 2020.12.01 |