※ 동영상을 감상 하실떄 720P(HD)로 변경해서 감상하시길 바랍니다.

    쫌 끊김이 보이네요;;;;, 소리 없습니다;;;



아래 인터페이스 개발방법은 PI 내부에 있는 Local Disk에서 파일을 가져와서 Interface Table로 Insert하는 내용이다

아래과 같은 인터페이스다.


Source정보인 파일에 관련된 내용은 다음과 같다.

  파일경로 : D:\TEST\10042

  백업경로 : D:\TEST\10042\backup

  파일내용 : 아래 예제와 같으며 HEAD, DETAIL 구조로 되어 있으며 첫째칸에 TYPE필드가 H이면 HEAD고, D면 DETAIL이다.
                 파일은 FixedLength구조이며 HEAD는 각 필드의 크기가 1, 10, 10, 10, 10이며, DETAIL은 1, 10, 10, 4, 5, 5 이다.

H10042     0000000001     data1      sub1

H10042     0000000002     data2      sub2

D10042     0000000001key1data1 sub1

D10042     0000000001key2data2 sub2

D10042     0000000001key3data3 sub3

D10042     0000000002key1data1 sub1

D10042     0000000002key2data2 sub2

D10042     0000000002key3data3 sub3

※ 파일 채널 셋팅에 대한 참고 URL 클릭


Target 정보는 Table은 다음 그림과 같으며 스키마 구조도 아래 내용을 참고 하기 바란다.

Table : HEAD_TABLE


Table : DETAIL_TABLE



 HEAD_TABLE

  DETAIL_TABLE

 CREATE

   TABLE HEAD_TABLE  (

       ID VARCHAR2(10) NOT NULL, 

       H_INDEX VARCHAR2(10) NOT NULL, 

       DATA1 VARCHAR2(10), 

       DATA2 VARCHAR2(10), 

       PRIMARY KEY (ID, H_INDEX) 

   )

 CREATE 

    TABLE DETAIL_TABLE (

        ID VARCHAR2(10) NOT NULL, 

        D_INDEX VARCHAR2(10) NOT NULL, 

        KEY VARCHAR2(4) NOT NULL, 

        DATA1 VARCHAR2(5), 

        DATA2 VARCHAR2(5), 

        PRIMARY KEY (ID, D_INDEX, KEY) 

)


  • Enterprise Services Builder

Namespace

http://www.inspien.co.kr/DB2FILE

DataType

INSPIEN_FILE2DB_OUT_DT

INSPIEN_FILE2DB_IN_DT

MessageType

INSPIEN_FILE2DB_OUT_MT

INSPIEN_FILE2DB_IN_MT

ServiceInterface

INSPIEN_FILE2DB_Out

INSPIEN_FILE2DB_In

MessageMapping

INSPIEN_FILE2DB_MM

Opteration Mapping

INSPIEN_FILE2DB_OM


  • Integration Builder


시나리오 : INSPIEN_FILE2DB

파일채널 : INSPIEN_FILE2DB_FILESender

     D:\TEST\10042

     D:\TEST\10042\backup

  


    HEAD.fieldFixedLengths 1,10,10,10,10

    HEAD.endSeparator           'nl'

    HEAD.fieldNames TYPE,ID,H_INDEX,DATA1,DATA2

    HEAD.keyFieldValue H


    DETAIL.fieldFixedLengths         1,10,10,4,5,5

    DETAIL.endSeparator 'nl'

    DETAIL.fieldNames         TYPE,ID,D_INDEX,KEY,DATA1,DATA2

    DETAIL.keyFieldValue D

     

JDBC채널 : INSPIEN_FILE2DB_JDBCReceiver

    oracle.jdbc.driver.OracleDriver

    jdbc:oracle:thin:@192.168.0.15:1521:XE   



샘플파일

10042.txt


Posted by INSPIEN
,

 

 

 

 

 

 

 

 

 

 

 

 

* Reference

 Note 831162 - FAQ: XI 3.0 / PI 7.0 / PI 7.1 / PI 7.3 JDBC Adapter : Question No. 31
     https://websmp230.sap-ag.de/sap(bD1rbyZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=831162

 Note 1404778 - Prepared Statement usage in JDBC Receiver Adapter
     https://websmp230.sap-ag.de/sap(bD1rbyZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1404778

 PreparedStatement with JDBC Receiver Adapter
     http://scn.sap.com/people/francesco.bersani/blog/2009/11/27/preparedstatement-with-jdbc-receiver-adapter

 JDBC Receiver Prepared Statement (sqlBindMode): how to convert date ?
     http://scn.sap.com/message/14169013

 Improving JDBC Receiver Channel Performance by using Precompiled Prepared Statement
     http://sapnwnewbie.blogspot.com/2012/02/improving-jdbc-receiver-channel.html#ixzz2bM44F3Cu

Posted by INSPIEN
,
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import org.omg.CORBA.portable.InputStream;
public class httpURLCon {
 public static void main(String[] args) throws UnsupportedEncodingException{
  
   String data = "DATADATA?SVCID=SKKU160R&KEY=4s";
   
  String strURL = "http://XXX.XXX.XXX.XXX:51000/sap/xi/adapter_plain?";
  strURL = strURL + URLEncoder.encode("namespace", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("http://test.com/pilot/01/scenario1", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("interface", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("Act_Out", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("service", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("ZPILOT_Legacy_BS", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("receiverService", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("ZPILOT_Legacy_BS", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("QOS", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("BE", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("sap-user", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("계정", "UTF-8") + "&";
  
  strURL = strURL + URLEncoder.encode("sap-password", "UTF-8") + "=";
  strURL = strURL + URLEncoder.encode("비번", "UTF-8") + "&";
      
  System.out.println(strURL); 
  
  try{
   HttpURLConnection httpURLCon = null;
   OutputStream outs = null;
   
   URL url = new URL(strURL);
   
   httpURLCon = (HttpURLConnection) url.openConnection();
   httpURLCon.setRequestMethod("POST");
   httpURLCon.setDoInput(true);
   httpURLCon.setDoOutput(true);
   httpURLCon.setUseCaches(false);
   httpURLCon.setDefaultUseCaches(false);
   httpURLCon.setRequestProperty("CONTENT-TYPE", "Application/x-www-form-urlencoded");
   httpURLCon.connect();
   
   outs = httpURLCon.getOutputStream();
   byte[] sendByte = new String(data).getBytes("KSC5601");
   
   outs.write(sendByte);
   outs.close();
   //httpURLCon.connect();
   
   String line;
   BufferedReader reader = new BufferedReader(new InputStreamReader(httpURLCon.getInputStream()));
   
   while((line = reader.readLine()) != null) {
    System.out.println(line); 
   }
/*         
   if (httpURLCon.getResponseCode() == HttpURLConnection.HTTP_OK) {
    System.out.println("1ResponseCode : " + httpURLCon.getResponseCode()); 
   }else {
    System.out.println("2ResponseCode : " + httpURLCon.getResponseCode()); 
   }
*/   
  }catch(Exception e) {
   System.out.println(e.toString()); 
  }
 }
}
Posted by INSPIEN
,