Data Insertion from SAP On-premise System into SAP HANA Cloud Trial

For data insertion I use HANA JDBC driver ngdbc.jar from SAP HANA Client and two R packages:

  • R package RSAP, which implements SAP RFC connectivity for R using the SAP NetWeaver RFC SDK (NW RFC SDK). This represents our connection to on-premise legacy SAP system.
  • R package RJDBC, which provides access to databases through the JDBC interface. This represents our connection to HANA Cloud database

I can’t use SAP HANA Cloud Connector because the “Service Channel” feature is not activated for trial accounts, so I use tunneling from the SAP HANA Cloud Platform SDK.

library(RSAP)
library(RJDBC)

con <- RSAPConnect(ashost=”saphostdev”, sysnr=”10″,client=”100″,  user=”***”,  passwd=”***”,  lang=”EN”, trace=”1″,  lcheck=”1″)
vbak <- RSAPReadTable(con, “VBAK”, options=list(“ERDAT >= ‘20160101’ “, ” AND AUART = ‘TA’ “),  fields=list(‘VBELN’, ‘ERDAT’,’ERNAM’, ‘VKORG’, ‘VKBUR’,  ‘VKGRP’,  ‘KUNNR’, ‘NETWR’, ‘WAERK’))
RSAPClose(con)
names(vbak)=c(“SalesDocNum”,”Created”,”CreatedBy”,”SalesOrg”,”SalesOffice”,”SalesGroup”,”SoldToParty”,”NetValue”,”DocCurrency”)

drv <- JDBC(“com.sap.db.jdbc.Driver”,”/home/tomislav/sap/ngdbc.jar”,identifier.quote=”‘”)
conn <- dbConnect(drv,”jdbc:sap://localhost:30015/?autocommit=false&currentschema=NEO_***”,”DEV_***”,”***”)

for (i in 1:nrow(vbak)) {
        insert = paste(“insert into \”VBAK\” values(“,vbak[i,”SalesDocNum”], “,'”,
                                         vbak[i,”CreatedBy”],”‘,'”,vbak[i,”SalesOrg”],”‘,'”,
                                         vbak[i,”SalesOffice”],”‘,'”,vbak[i,”SalesGroup”],”‘,” ,
                                         vbak[i,”SoldToParty”],”,'”,vbak[i,”NetValue”],”‘,'”,
                                         vbak[i,”DocCurrency”],”‘,”,to_date(‘”,
                                         vbak[i,”Created”],”‘,’YYYYMMDD’),”)”,sep=””)

dbSendUpdate(conn,insert)
  if (i%%50 == 0) { dbCommit(conn) }
}

if (i%%50 != 0) { dbCommit(conn) }

dbDisconnect(conn)

Oglasi
Ovaj unos je objavljen u Nekategorizirano. Bookmarkirajte stalnu vezu.

Komentiraj

Popunite niže tražene podatke ili kliknite na neku od ikona za prijavu:

WordPress.com Logo

Ovaj komentar pišete koristeći vaš WordPress.com račun. Odjava / Izmijeni )

Twitter picture

Ovaj komentar pišete koristeći vaš Twitter račun. Odjava / Izmijeni )

Facebook slika

Ovaj komentar pišete koristeći vaš Facebook račun. Odjava / Izmijeni )

Google+ photo

Ovaj komentar pišete koristeći vaš Google+ račun. Odjava / Izmijeni )

Spajanje na %s