//怎么傳遞表資料給sap函式,然后把它通過函式寫進到sap資料庫?請高手賜教,急。
oleobject saprfc,connectionsap,funct,functions,intab
long ll_status,ll_count,ll_row
string ls_aa,ls_bb
saprfc = create oleobject
ll_status = saprfc.connecttonewobject("sap.functions")
connectionsap = saprfc.connection
connectionsap.applicationserver = "10.22.0.200"
connectionsap.system = 'ids'
connectionsap.systemnumber = '00'
connectionsap.client = '800'
connectionsap.language = 'ZH'
connectionsap.user = '用戶名'
connectionsap.password = '密碼'
if connectionsap.logon(0,true) = false then
messagebox('connet sap','connect failed')
return
else
messagebox('connect sap','connect success')
end if
//連接資料庫成功
//呼叫z_zlgq_llz
funct = create oleobject
funct = saprfc.add("z_zlgq_llz")
//怎么傳遞表資料 給sap函式然后 把它通過函式寫進到 sap資料庫?
//convert oleobject in any variable to string
//funct.exports("I_EBELN",trim(sle_1.text))
//funct.exports("xcarrname",'aa')
if funct.call = false then //Call Rfc
messagebox('failed','call failed')
destroy connectionsap
destroy saprfc
return
end if
intab = funct.tables("IT_zscarr")
ll_count = intab.rowcount()
if ll_count > 0 then
For ll_row = 1 To ll_count
ls_aa = intab.value(ll_row,'carrname')
ls_bb = intab.value(ll_row,'CURRCODE')
Messagebox(ls_aa,ls_bb)
Next
end if
connectionsap.LogOff()
destroy connectionsap
saprfc.disconnectobject()
destroy saprfc
uj5u.com熱心網友回復:
看不懂uj5u.com熱心網友回復:
這個應該是sap介面的問題,就好比pb網excel里寫資料就要用到excel的介面函式一樣。lz最好在有sap討論的論壇里問問
uj5u.com熱心網友回復:
powerbuilder呼叫bapi_po_create創建PO訂單oleobject saprfc,connection2,funct
oleobject poheader,poitems,poitemschedule,it_RETURN
oleobject ItemsRow,SchedulesRow
ANY PO_NO
long ll_status
saprfc = create oleobject
ll_status = saprfc.connecttonewobject("sap.functions") //sap.functions
/********************************************************/
//連接到SAP
/********************************************************/
connection2 = saprfc.connection
connection2.applicationserver = "10.1.4.71" //服務器IP
connection2.system = 'DEV' //系統標識
connection2.systemnumber = '00'
connection2.client = '110'
connection2.user = ''
connection2.password = ''
connection2.language = 'EN'
if connection2.logon(0,true) = false then //登錄
messagebox('連接到sap','連接失敗')
return
end if
SETPOINTER( HourGlass! )
/********************************************************/
//指定要呼叫SAP的哪個函式,并取得該函式的各物件
/********************************************************/
funct = saprfc.add("BAPI_PO_CREATE")
poheader = funct.exports.Item("PO_HEADER")
poitems = funct.tables.Item("PO_ITEMS")
poitemschedule = funct.tables.Item("PO_ITEM_SCHEDULES")
/********************************************************/
//給wa物件賦值
/********************************************************/
poheader.Value[2] = 'NB' //采購憑證型別
poheader.Value[3] = 'F' //采購憑證類別
poheader.Value[5] = '1001' //采購組織
poheader.Value[6] = 'A01' //采購組
poheader.Value[8] = '0000100024' //供應商帳戶號
/********************************************************/
//給itab物件賦值
/********************************************************/
//00010
ItemsRow = poitems.Rows.Add()
ItemsRow.Value[2] = '00010'//采購憑證的專案編號
ItemsRow.Value[5] = '000000001101010006'//物料號
ItemsRow.Value[11] = '1000'//庫存地點
ItemsRow.Value[17] ='1001'//工廠
ItemsRow.Value[21] ='5'//采購憑證中的凈價格(以憑證貨幣計)
SchedulesRow = poitemschedule.rows.add( )
SchedulesRow.Value[1] = '00010'//采購憑證的專案編號
SchedulesRow.Value[3] = '1'//日期型別 (日,周,月,間隔)
SchedulesRow.Value[4] = '20100531'//專案交貨日期
SchedulesRow.Value[6] = '100'//已計劃數量
//00020
ItemsRow = poitems.Rows.Add()
ItemsRow.Value[2] = '00020'//采購憑證的專案編號
ItemsRow.Value[5] = '000000001101010007'//物料號
ItemsRow.Value[11] = '1000'//庫存地點
ItemsRow.Value[17] ='1001'//工廠
ItemsRow.Value[21] ='6'//采購憑證中的凈價格(以憑證貨幣計)
SchedulesRow = poitemschedule.rows.add( )
SchedulesRow.Value[1] = '00020'//采購憑證的專案編號
SchedulesRow.Value[3] = '1'//日期型別 (日,周,月,間隔)
SchedulesRow.Value[4] = '20100531'//專案交貨日期
SchedulesRow.Value[6] = '99'//已計劃數量
/********************************************************/
//開始呼叫SAP的函式
/********************************************************/
BOOLEAN lb_call
lb_call = funct.call()
/********************************************************/
//取回傳wa值
/********************************************************/
PO_NO = funct.imports.ITEM('PURCHASEORDER')
/********************************************************/
//取回傳itab值
/********************************************************/
it_return = funct.tables("RETURN")
//it_RETURN = funct.tables.Item("RETURN")
string ls_aa,ls_bb
Long ll_r,i
ll_r = it_return.rowcount()
mle_1.text = ''
if ll_r > 0 then
for i = 1 to ll_r
ls_aa = it_return.value(i,'TYPE')
ls_bb = it_return.value(i,'MESSAGE')
mle_1.text += '符號:' + ls_aa +space(32) + ' 描述: ('+ ls_bb + ')~r~n'
next
end if
//MESSAGEBOX('新訂單號',STRING(PO_NO))
/********************************************************/
//釋放物件,
/********************************************************/
connection2.LogOff()
destroy connection2
saprfc.disconnectobject()
destroy saprfc
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/85268.html
標籤:數據庫相關
