Home > database >  Pb9 connected by RFC SAP instance and the required documents (dynamic library)
Pb9 connected by RFC SAP instance and the required documents (dynamic library)

Time:09-21

Recently, as the topic, to do a project to pb system connection with SAP, which masters know excuse me, please grant instruction,,,,

CodePudding user response:

Pb connection with SAP

OleObject i_ole_Conn i_ole_FxnCtrl//objects are defined with the OLE



Long ll_status//build success or failure of SAP function by OLE (0 - success or failure)
Boolean lb_logon judging//login SAP success or failure (true - success, or false on failure)



I_ole_FxnCtrl=create oleobject
Ll_status=i_ole_FxnCtrl. ConnectToNewObject (" SAP functions provides ")//set up the SAP connection object
IF ll_status & lt;> 0 THEN
Gf_errmsg (' create SAP connection error OLE! The error code: "+ string (ll_status))
Destroy i_ole_FxnCtrl//release resources
The return - 1
End the if



//set the connection parameters

I_ole_Conn=i_ole_FxnCtrl. Connection ()
I_ole_Conn. SAP application server=is_ipaddress//server IP address
I_ole_Conn. SYSTEMNUMBER=is_systemnumber//system number
I_ole_Conn. Codepage=is_codepage//code
I_ole_Conn. Client=is_client//group
I_ole_Conn. User=is_userid//login account
I_ole_Conn. Password=is_password/login/password
I_ole_Conn. Language=is_language//
I_ole_Conn. Autologon=true



Lb_logon=i_ole_Conn. Logon (0, true)//automatic connection
If not lb_logon then
Messagebox (' login failure ', 'login server failed, please check the input program is correct, or contact the administrator! ', stopsign!)
Destroy i_ole_FxnCtrl

The else

Messagebox (', 'the connection is successful! ')
End the if

CodePudding user response:

learning how to learn!!!!!!

CodePudding user response:

Need to call the machine install SAP GUI client to
Are you input parameters or to get the data

CodePudding user response:

//the following is a PB and SAP communications from SAP download data
Oleobject saprfc connection2, funct table_d, functions provides, funct2, intab, categ, oline
Long ll_status, result
A long Row, I


Saprfc=create oleobject
Ll_status=saprfc. Connecttonewobject (" SAP functions provides ")
Connection2=saprfc. Connection
//server IP
Connection2. Application server="192.168.99.57"//"192.168.100.10
"//system number
Connection2. Systemnumber='15'//'00'
//port
Connection2. Client='210'//'800'
//user
Connection2. User='zhongy'//'orderin'
//password
` connection2. Password='123456'//'WLSL'
//login language
Connection2. Language='en'

If connection2. Logon (0, true)=false then
Connet messagebox (' SAP ', 'the connect failed')
End the if


//call z_mto_info
Funct=create oleobject

//the RFC function name
Funct=saprfc. Add (" Z_MTO_INFO ")
//the RFC input parameter
BSTNK funct. Exports (" "). The value=https://bbs.csdn.net/topics/trim (sle_2. Text)////incoming parameters "MF07BH06016RY # 1"


If funct. Call ()=false then//call the Rfc
Messagebox (', 'Read bom call failed)
The else

//receive the RFC returns the
Table_d=funct. Tables. The item (" MTO ");//the output parameters
The Row=Table_d. Rows. Count

St_6. Text=""
For I=1 to Row
St_6. Text=st_6. Text + string (Table_d. Value (I, 1)) + '-' + string (Table_d. Value (I, 2)) + '-' + string (Table_d. Value (I, 3)) + '-' + string (Table_d. Value (I, 4)) + '-' + string (Table_d. Value (I, 5)) + '-' + string (Table_d. Value (I, 6)) + '-' + string (Table_d. Value (I, 7)) + '-' + string (Table_d. Value (I, 8)) + '-' + string (Table_d. Value (I, 9)) + '~ r ~ t'
Next
Messagebox (', 'Read bom call is successful, this article to get the data of total number' + string (Row))
End the if
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */




//the following is a PB and SAP communications to SAP upload data

Oleobject saprfc connection2, funct table_d, functions provides, funct2, intab, categ, oline, addrow
Long ll_status, result
A Long Row, I
String o_matnr
Boolean Sign

Saprfc=Create oleobject
Ll_status=saprfc. ConnectToNewObject (" SAP functions provides ")
Connection2=saprfc. Connection
//server IP
Connection2. Application server="192.168.99.56"//"192.168.100.10
"//system number
Connection2. Systemnumber='30'//'00'
//port
Connection2. Client='500'//'800'
//user
Connection2. User='neusoft'//'orderin'
//password
Connection2. Password='12345678'//'WLSL'
//login language
Connection2. Language='en'

IF connection2. Logon (0, True)=False THEN
Connet MessageBox (' SAP ', 'the connect failed')
END the IF


//call z_mto_info
Funct=Create oleobject

//the RFC function name
Funct=saprfc. Add (" Z_FI_RFC_IFI003_001 ")
//to transmit the SAP form
Intab=funct. Tables. The Item (" T_YFINVOICE ")
//new line
Addrow=intab. Rows. The add
//to the each field assignment
Addrow. Value [1]="0000001612"
Addrow. Value [2]="11111111"
Addrow. Value [3]="22222222"
Addrow. Value [4]="33333333"
Addrow. Value [5]="20061107"
Addrow. Value [6]="20061107"
Addrow. Value [7]="20061107"
Addrow. Value [8]="77777777"
Addrow. Value [9]="20070507"

//Call the error information returned Rfc: funct. Exception
IF funct. Call ()=False THEN
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related