Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

fetch data from VB6 to SAP

Former Member
0 Likes
2,095

Hi!

We have got an application software in VB6.

Our version of SAP R/3 is ECC5.

now I have to put the values of application software into SAP customised table.

suppose text1 and text2 are there in the software VB6 and

the values that users put in it should reflect into a customised table in SAP say ZTAB

with fields ztext1 and ztext2.

i.e, text1 of VB6 software equals ztext1 of SAP table ZTAB and so on...

A relevant BAPI is to be created to do so but how to fetch

the data from VB6 to SAP and how do i connect VB6 and SAP.

thanking you

Amit

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,701

Hi..

First u have to create BAPI using SE37 ( Function Module ) with remote enabled functionality.

which have import / export parameters through which u can send data from VB6 to SAP.

then open vb6.

then write following sample code :



        Dim Functions As Object

        Set Functions = CreateObject("SAP.Functions")
 
        Functions.Connection.User = suser
        Functions.Connection.Password = sPassword
        Functions.Connection.Client = sClient
        Functions.Connection.ApplicationServer = sdestination
        Functions.Connection.Language = sLanguage
       
        Functions.Connection.SystemNumber = sYstemnumber       
If Functions.Connection.Logon(0, True) = True Then
        
        
        While Not rsSql.EOF
        
            Set RfcCallTransaction = Functions.Add(<BAPI_NAME>)
            RfcCallTransaction.Tables(<TABLE NAME IN WHICH U WANT TO PASS DATA>).appendrow
            
            RfcCallTransaction.Tables(<TABLE NAME IN WHICH U WANT TO PASS DATA>).MCount, <Field_Name>= rsSql.Fields(<Field_Name>)
            RfcCallTransaction.Tables(<TABLE NAME IN WHICH U WANT TO PASS DATA>).MCount, <Field_Name_2>= rsSql.Fields(<Field_Name_2>)

            MCount = MCount + 1
            rsSql.MoveNext
        
        Wend

	If RfcCallTransaction.Call = True Then
                   
                                    
	endif.

endif.

here rsSql is recordset which contains data which u want to send in sap.

Here statement "If RfcCallTransaction.Call = True Then" call bapi and data will be sent to SAP.

From above u can easily setup connection with SAP. no basis guy required.

This may surly help u.

Regards,

Chintan.

Edited by: Chintan_SAP on May 8, 2009 9:09 AM

Edited by: Chintan_SAP on May 8, 2009 9:53 AM

Edited by: Chintan_SAP on May 8, 2009 9:54 AM

Hi!

We have got an application software in VB6.

Our version of SAP R/3 is ECC5.

now I have to put the values of application software into SAP customised table.

suppose text1 and text2 are there in the software VB6 and

the values that users put in it should reflect into a customised table in SAP say ZTAB

with fields ztext1 and ztext2.

i.e, text1 of VB6 software equals ztext1 of SAP table ZTAB and so on...

A relevant BAPI is to be created to do so but how to fetch

the data from VB6 to SAP and how do i connect VB6 and SAP.

thanking you

Amit

10 REPLIES 10
Read only

Former Member
0 Likes
1,701

Is there any way you can download it to excel.

If yes then you can use BDC or LSMW to upload from there.

Regards,

Lalit Mohan Gupta.

Read only

Former Member
0 Likes
1,701

If the VB program is to call the BAPI, then write the bapi with your 2 text fields as input parameters and then when you call the bapi from your VB program just send the 2 text fields. The bapi doesn't look back into its calling program. Am I missing something here?

Read only

Former Member
0 Likes
1,701

Hi Amit,

We did a Weigh Bridge in the same way long ago fo rone of our client.

We written the program using a BAPI. & The interface part is from VB. it was done by VB Programmers..!

So check if you got some VB programmers, as there are some simple interfaces...

You can search in the net for "VB to SAP interface" or BAPI for "VB Application" Might be help you for reference, as I got one from internet and it was having comple screens for interfacing.

Thanks & regards,

Dileep .C

Read only

Former Member
0 Likes
1,702

Hi..

First u have to create BAPI using SE37 ( Function Module ) with remote enabled functionality.

which have import / export parameters through which u can send data from VB6 to SAP.

then open vb6.

then write following sample code :



        Dim Functions As Object

        Set Functions = CreateObject("SAP.Functions")
 
        Functions.Connection.User = suser
        Functions.Connection.Password = sPassword
        Functions.Connection.Client = sClient
        Functions.Connection.ApplicationServer = sdestination
        Functions.Connection.Language = sLanguage
       
        Functions.Connection.SystemNumber = sYstemnumber       
If Functions.Connection.Logon(0, True) = True Then
        
        
        While Not rsSql.EOF
        
            Set RfcCallTransaction = Functions.Add(<BAPI_NAME>)
            RfcCallTransaction.Tables(<TABLE NAME IN WHICH U WANT TO PASS DATA>).appendrow
            
            RfcCallTransaction.Tables(<TABLE NAME IN WHICH U WANT TO PASS DATA>).MCount, <Field_Name>= rsSql.Fields(<Field_Name>)
            RfcCallTransaction.Tables(<TABLE NAME IN WHICH U WANT TO PASS DATA>).MCount, <Field_Name_2>= rsSql.Fields(<Field_Name_2>)

            MCount = MCount + 1
            rsSql.MoveNext
        
        Wend

	If RfcCallTransaction.Call = True Then
                   
                                    
	endif.

endif.

here rsSql is recordset which contains data which u want to send in sap.

Here statement "If RfcCallTransaction.Call = True Then" call bapi and data will be sent to SAP.

From above u can easily setup connection with SAP. no basis guy required.

This may surly help u.

Regards,

Chintan.

Edited by: Chintan_SAP on May 8, 2009 9:09 AM

Edited by: Chintan_SAP on May 8, 2009 9:53 AM

Edited by: Chintan_SAP on May 8, 2009 9:54 AM

Read only

former_member188827
Active Contributor
0 Likes
1,701

first create a bapi using tcode "SWO1".. in da function module of bapi use import parameters to read data from VB6 and den use da data to update ur z table.

da call of bapi in VB6 has to be coded by VB programmer.u also need basis person to estblish interface b/w SAP and VB..

Read only

ashish_shah5
Participant
0 Likes
1,701

Important Tcode:

BAPI - Buisness Object Browser

SWO1 - Buisness Object Builder

SE11 - Data Dictionary

Se37 - Function Builder

Steps:

1. SE11-You have to create Structure.

2. SE37- Create Function Group

3. SE37- Create Function Module with Remote Enable Mode

- In Import Parameter Click on pass value

4. SE37- After writting code use Release option.

5. SWO1- Create New BAPI Object

- Application: '*'

- Select Method & Click on Add Method

- Implement

- Release

- Generate

This are the steps which you have to take care.

Regards.

Read only

Former Member
0 Likes
1,701

Hi..

I want to retrieve Changing parameter from a Remote Enabled function module in VB from SAP.

Can anyone provide me the method name to extract the Changing parameter.

My Function Module : RPY_FUNCTIONMODULE_READ_NEW

Parameter to Extract from VB in SAP : NEW_SOURCE

Iam connecting to SAP from my VB application.

Please do the needful.

Read only

Former Member
0 Likes
1,701

Hi,

I am trying to use the same code but not able to connect to SAP through VB6.

Can you please tell me know the actual procedure for connecting to the system and any pre-requisite for the connection

Any help would be appreciated.

Thanks & regards,

Akshay Ruia.

Read only

0 Likes
1,701

First, you need to create the function module, enabled for remote calling, prefereably in a distinct function group, as security is handled at the function group level.

Next, you need a user and password in SAP

Next, you need to add security to the profile of user, for S_RFC, using acvt 16, the function group name, and RFC_TYPE FUGR

You should consider connecting to SAP via a login group, if you have multiple application servers, but here is code from my SAP connection obect that connects direct to a server. CP is a connection profile. fill in these fields with the appropriate informatin for your system.

    SAP as Object   

Private Sub ConnectToServer()

        SAP = CreateObject("SAP.Functions")

        SAP.Connection.System = CP.System

        SAP.Connection.client = CP.Client

        SAP.Connection.ApplicationServer = CP.ApplicationServer

        SAP.Connection.user = CP.UserID

        SAP.Connection.Password = CP.Password

        SAP.Connection.language = CP.Language

    If SAP.Connection.logon(0, True) <> True Then

            Me.Connected = False

        Else

            Me.Connected = True

       End If

End Sub

This will just Connect you to SAP. You then need to call the function module:

     Controller as Object

            Controller = SAP.add("Y_LABOR_SESSION_CONTROLLER")

            Export = Controller.exports("RESPONSE")

            Import = Controller.imports("REQUEST")

            KVTable = Controller.tables("KEYVAL")

            TXTable = Controller.tables("TEXT")

Here, we create a new object, called controller, and objects fro Export, import, etc. In this example, request, response, etc are all parameters of the function module, either imported, exported or tables.

Note, I named them this way, becuase i only have one export, and one import. If you have mlutiple exports, like test1 and text2, then each would be set up like

Text1 = Controller.exports("TEXT1")

Text2 = Controller.exports("TEXT2")

or something like that

The export object is a structure, you can access like this

           Export("SESSIONID") = Resp.SessionID

           Export("RESPONSEDATA") = Resp.ResponseData

           Export("MSGRESP") = Resp.MsgResp

Then, finally, you call the function module

          callok = Controller.call()

     If callok = False Then

               pvtSAPError = Controller.exception()

     End If

This code was taken from one of my working applications, so obviously, you need to tweak it. It was orginally created in VB6, and then adjusted into VS in various releases. it should show you, though, how to handle connecting, setting up the function module definition in VB, calling the FM, and checking for errors. I did not try and rewrite it to your specific scenario, though.

I hope it helps.

Read only

0 Likes
1,701

Hi David,

Thanks For the Reply. It worked Great.

Regards,

Akshay Ruia