|
Java에서 R/3를 call할 때 JCO를 사용하는 것처럼 역시 JCO를 사용하여 R/3에서 외부 Java 기능 Call할 수 있습니다. 물론 편법도 있지만 일반적인 방법은 JCO를 이용합니다.
Java 모듈에서 R/3를 Call하는 것을 RFC Client라고 하고요. 그 역을 RFC Server라고 통칭합니다.
RFC Server 는 RFC Client보다 조금 복잡합니다. RFC Server 구성하기 위하여 해야 할 사항들을 보면 - Listener 구성 - RFC Destination구성 - RFC Function구성 - Listener에서 Java모듈과의 연결등 언뜻 떠오르는 것이 이 정도고 이를 다 설명하기는 그렇고 JCO와 BC(Business Connector) Document를 보면 잘 아실 수 있습니다. 무엇 보다도 BC를 사용하면 많을 작업을 대신해 줍니다.
오랜만이죠. 간만에 팁 하나 소개합니다.
1. JDK 설치
2. JConnect 설치
- 압축을 풀어서 c:jco-ntintel-1.1에 설치하세요.
- c:jco-ntintel-1.1librfc32.dll 을 c:winntsystem32 에 카피하세요. (win2000인 경우)
- 환경변수 *클래스패스* 설정
CLASSPATH=.;C:Jco-ntintel-1.1jCO.jar
- 재부팅
3. 테스트
- 회사코드리스트 출력 테스트
c:jco-ntintel-1.1demoTutorial1.java 의 로그인정보를 수정하십시오.
// Change the logon information to your own system/user mConnection = JCO.createClient("500", // SAP client "syhan", // userid "111111", // password "KO", // language "11.11.11.11", // host name or ip "00"); // system number
- 컴파일
도스창 혹은 명령행프롬프트를 열어서 다음과 같이 하세요.
c:jco-ntintel-1.1demo>javac tutorial1.java
- 실행
c:jco-ntintel-1.1demo>java tutorial1
4. 참고
- 이 모든 내용은 c:jco-ntintel-1.1docsintro.html 파일에 더욱 자세히 나와 있습니다.
cf. 1. 사실 귀찮아서 하지말자고 했는데, 개발담당자가 알아서 다해버렸네요. 2. C보다 코딩량이 엄청 준다고 담당자께서 얘기하시네요. 이젠 RFC를 java로
** 추가정보 (2006.08.23 등록)
샘플예제에 대한 수정
- Can someone help to configure the destination with SM59 in the R/3?
- Do any ABAP codings exist for the examples 5 & 7?
Here are the answers.
Prerequisites
- Installed SAP Java Connector (JCo). Can be downloaded here.
- Java Development Kit (JDK) installed.
- Authorisation to create a RFC destination in transaction SM59
- Authorisation to create write a ABAP Program using SE80
Used System Information
| Parameter |
Value |
| Gateway Host |
gateway |
| Gateway Service |
sapgw00 |
| Program ID |
JCOSERVER01 |
Adopt Example5
When you extract the downloaded JCo ZIP file you will find a Java source file Example5.java in the directory demo. I've copied this file and named the copy "myExample5.java". Open this file with your favourite Editor and search and replace all strings "Example5" with "myExample5". In the next step we have make some changes in the source. First we reduce the number of connections to backend servers to 1. To do this go to line 153 and change it to: JCO.Server srv[] = new JCO.Server[1];
Next we adopt the connection data. This is done in line 174: srv[0] = new Server("gateway","sapgw00","JCOSERVER01",repository);
At last we have to comment out the second connection in line 177: // srv[1] = new Server("gwhost2","gwserv00","JCOSERVER02",repository);
Now save the file, compile and run it from the command line. The output should be: Server JCOSERVER01 changed state from [ STOPPED ] to [ STARTED ]
Server JCOSERVER01 changed state from [ STARTED ] to [ STARTED LISTENING ]
Create RFC destination
- Start transaction SM59
- Click the button "Create"
- Enter the RFC destination JCO
- Choose Connection Type T
- Enter a Description JCo outbound
- Press Enter
- Go to the Technical settings tab
- Choose Activation Type Registered Server Program
- Enter Program ID JCOSERVER01
- Save the connection
- Click the button "Test connection"
The result of the Test connection should look like this: Connection test JCO
Connection type: TCP/IP connection
Logon: 702 msec
0 KB: 416 msec
10 KB: 332 msec
20 KB: 331 msec
30 KB: 366 msec
Run test program
To test the new connection and the JCo server we run this short test program: *&---------------------------------------------------------------------*
*& Report Z_JCO_TEST *
*& *
*&---------------------------------------------------------------------*
*& Test outbound JCO connection *
*& *
*&---------------------------------------------------------------------*
REPORT z_jco_test .
PARAMETERS: requtext LIKE sy-lisel.
DATA: echotext LIKE sy-lisel,
resptext LIKE sy-lisel.
CALL FUNCTION 'STFC_CONNECTION' DESTINATION 'JCO'
EXPORTING
requtext = requtext
IMPORTING
echotext = echotext
resptext = resptext.
WRITE: 'Echo Text: ', echotext.
WRITE: 'Response Text: ', resptext.
When you start the program you have to enter some text. Try "Hello World". The response should be: Test Outbound JCO connection
Echo Text:
HELLO WORLD
Response Text:
This is a response from myExample5.java
|