Question

how to translate a VB code into VFP Visual FoxPro code objets

Asked by: dclsoft

Dear Friends

I need help to translate the VB code into VFP code

My problem is how to add value to Exports properties in the code bellow!

Rem VB code       
 Rem ***Create SAP function objetc ***
        Set oFunction = CreateObject("SAP.Functions")
        Set oFunction.Connection = g_oConnection
        
        Rem ***retreive SAP function RFC***
        Set oFunc = oFunction.Add("Z_EXEC_INTERFACES")
        
        Rem ***add parameters to export to SAP function in VB WORKS***
        oFunc.Exports("I_PROGRAMA") = 'imp_programa'  Rem ** this line in VFP does not work
        oFunc.Exports("I_ORIGEM") = 'imp_origem'
        Rem end VB code
		
		
		* code VFP does not work
        objBapiControl =CREATEOBJECT("SAP.Functions")
        objconnection=objBapiControl.connection
		
		oFunc=objBapiControl.add("Z_EXEC_INTERFACES")
        
		* util this line the program works
        
		*** add parameters to export to SAP function in VFP error***
        *** this line bellow appear error
		oFunc.Imports("I_PROGRAMA")= 'imp_programa'   && this line does not work
        oFunc.Exports("I_ORIGEM") ='imp_origem'

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-09-08 at 16:51:41ID24716665
Topics

FoxPro Database

,

VB Controls

,

VB Database Programming

Participating Experts
2
Points
500
Comments
9

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. VFP  v/s VB
    Is there anything you can do in VB which you can't do more easily and more efficiently in VFP ? Only experts in both VB & VFP please.
  2. VB grid----->VFP grid
    Is there a posibility that VB msflexgrid control or ado grid control can be used on the fox pro forms. If yes then What would the code be like? (vb code or vfp code): Please supply the links to a working example or provide some tips to how to get it to function.
  3. VFP Communication with MS SQL
    We have an application developed in VFP with VFP database at back end and VFP forms at front end. MS SQL Database is being updated by VFP indirectly through an interface routine written. WE want VFP to communicate directly with MS SQL Database by transforming the VFP Data t...
  4. FoxPro 2.5 to VFP 6.0
    I have have found myself in a situation where we have inherited a Foxpro DOS application. It is currently running version 2.5 (b) or something close to that. We want to upgrade it to a version that is supported and is more stable. Unfortunately we have limited VFP staff in ho...
  5. Cookie in VFP!
    This probably is the first question asked on Cookie in EE has search for 'cookie' yielded no results. This is the problem: We receive web based RFQ forms to submit quotation. Since this involves duplication (entering once in our back end system and another time on the RFQ f...
  6. VFP to VB
    Hi, I am a VFP programmer, programming in VFP 6.0 from last 3 years, My company is now switching to VB 6.0. For which the training is provided to everyone. We all are comfortable with VFP as a programming language, in the training session we came across some queries regarding...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ramromPosted on 2009-09-08 at 17:25:25ID: 25287348

"does not work" is pretty vague. How do you know it does not work? What is the error message?

 

by: dclsoftPosted on 2009-09-08 at 17:59:39ID: 25287489

              oFunc.Imports("I_PROGRAMA")   && no error
               oFunc.Imports("I_PROGRAMA")= 'imp_programa'   && including  = 'imp_programa' the program stops, I will see the message e post tomorrow.ok, Its lukes like the objetc does not accept the value! Or I need create a object to do this!


 

 

by: pcelbaPosted on 2009-09-08 at 22:10:03ID: 25288380

Your code in VFP seems to be rather different from VB...

VB: Set oFunction = CreateObject("SAP.Functions")
VFP: objBapiControl =CREATEOBJECT("SAP.Functions") ... OK

VB: Set oFunction.Connection = g_oConnection  ... here you are STORING existing connection
VFP: objconnection=objBapiControl.connection   ... here you are RETRIEVING connection info. WHY not storing?

VB: Set oFunc = oFunction.Add("Z_EXEC_INTERFACES")
VFP: oFunc=objBapiControl.add("Z_EXEC_INTERFACES") ... OK

VB: oFunc.Exports("I_PROGRAMA") = 'imp_programa'
VFP: oFunc.Imports("I_PROGRAMA")= 'imp_programa' ... Do you see the difference?

Neither  oFunc.Imports("I_PROGRAMA")= 'imp_programa'  nor  oFunc.Exports("I_PROGRAMA")= 'imp_programa'  can work in VFP because you cannot assign values to OLE properties this way in VFP.

 

by: pcelbaPosted on 2009-09-09 at 03:05:30ID: 25289620

I have to correct myself, the oFunc.Exports("I_PROGRAMA")= 'imp_programa' is allowed. Sorry.

The program which could work in VFP follows.

*-- objconnection must contain valid connection object already (it maight be created following way)
oSAPLogon = CREATEOBJECT('SAP.LogonControl.1')
oSAPLogon.ApplicationServer = "YourSAPserver"
objconnection = oSAPLogon.NewConnection()
*-- And here you have to complete all necessary connection properties and call 
*-- objconnection.Logon(0,.T.)
 
 
*-- Here follows your corrected code
objBapiControl = CREATEOBJECT("SAP.Functions")
objBapiControl.connection = objconnection
oFunc=objBapiControl.add("Z_EXEC_INTERFACES")
oFunc.Exports("I_PROGRAMA") = 'imp_programa'
oFunc.Exports("I_ORIGEM") = 'imp_origem'
 
*-- And now you can call RFC
llSuccess = oFunc.Call()
 
*-- And process oFunc.Imports (which is problematic for many RFCs sometimes)
*-- Of course, you have to test return values for success and check error states.
*-- The best way you can start is VFP Command window
 
*-- And please remember, SAP consultancy is a little bit expensive :-(
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:

Select allOpen in new window

 

by: dclsoftPosted on 2009-09-09 at 04:41:05ID: 25290087

Pcelba,

Thank You in advanced!

I will try your program, but my problem is not about connection is in pass values into porperties Exports!

How do I assign values to OLE properties  VFP for this example?

The programa below works fine!

* DEFINIE VALOR PARA AS PROPRIEDADES DE LOGON NO SAP
xsystem='00'         &&System ID 
xuser='kffk227'     &&SAP User name 
xclient='303'         &&SAP Client
xpassword='eccastra1' &&Password 
 
**All the ablove values may be left blank
 
* DEFINE E CHAMA O OBJETO DA CLASSE SAP FUNCTIONS
objBapiControl =CREATEOBJECT("SAP.Functions")
objconnection=objBapiControl.connection
 
objconnection.ApplicationServer = '156.70.93.131'  &&SAP System IP address
objconnection.System=xsystem
objconnection.Client=xclient
objconnection.User=xuser
objconnection.Password=xpassword
objconnection.Language='PT'
objconnection.tracelevel=6
 
retcd=objconnection.Logon(0,.T.)  && .F. COM LOGON ABRINDO NA TELA
 
IF retcd = .f.
   return
ENDIF
 
* ATIVA O METODO QUE TRÁS A TABELA DO SAP DA RFC Z_RFC_LIC_PRODUTO"
objcompanycodes=objBapiControl.add("Z_RFC_LIC_PRODUTO")
objcompanycodes.call
 
objtable=objcompanycodes.tables("T_PRODUTO")  && T_CONVERSAO  && T_HIERARQUIA  && BU/BF
 
 
* CRIA-SE UMA CURSOR\TABELA TEMPORÁRIA PARA RECEBER OS DADOS DA TABLE DO SAP (BLOCO FOR - NEXT)
create table ('c:\temp\solution\T_PRODUTO') ;   &&Change as required
     (ID_PRODUTO C(18), ID_BU C(2), ID_BF C(2), ID_AREA C(2), ID_FAMILIA C(3), TDESCRICAO C(40))
     
* LE-SE TODAS AS LINHAS DA TABLE INSERINDO OS REGISTROS NO CURSOR\TABELA TEMPORARIA 
FOR i = 1 TO objtable.rowcount
   APPEND BLANK
   replace ID_PRODUTO WITH objtable.cell(i,1)
   replace  ID_BU  WITH objtable.cell(i,2)
   replace ID_BF WITH objtable.cell(i,3)
   replace ID_AREA WITH objtable.cell(i,4)
   replace ID_FAMILIA  WITH objtable.cell(i,5)
   replace TDESCRICAO WITH objtable.cell(i,6)
endfor
 
objconnection.logoff
 
BROWSE

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:

Select allOpen in new window

 

by: pcelbaPosted on 2009-09-09 at 04:54:58ID: 25290183

First of all tell us what error message is generated by the following part of code attached to my answer:

oFunc=objBapiControl.add("Z_EXEC_INTERFACES")
oFunc.Exports("I_PROGRAMA") = 'imp_programa'
oFunc.Exports("I_ORIGEM") = 'imp_origem'

*-- And now you can call RFC
llSuccess = oFunc.Call()

 

by: dclsoftPosted on 2009-09-10 at 12:27:42ID: 25303400

This code below works since the RFC to be a atbel if the RFC is a structure the message error appear.

oFunc=objBapiControl.add("Z_EXEC_INTERFACES")
oFunc.Exports("I_PROGRAMA") = 'imp_programa'
oFunc.Exports("I_ORIGEM") = 'imp_origem'

The problem is hw do I call a RFC pass parameters to BAPI in structure?

Z_EXEC_INTERFACES like  a table works, but if is a structure does not work, How do I call a RFC pass parameters?

 

by: pcelbaPosted on 2009-09-10 at 13:50:03ID: 25304163

I would say the above code works if there are just single parameters in oFunc.Exports. Tables work also but you need to fill oFunc.Tables. We have been testing structures but they are implemented just for Imports but not for Exports. If I remember well, structures used as input parameters did not work correctly for us so all RFC inputs were changed to single parameters or to tables.

I have no access to SAP function which requires input structure so I cannot test it now.

BTW, you have been asking "how to translate a VB code into VFP Visual FoxPro code objets". Where are above mentioned structures in your VB code?

I would suggest to close this question because it was answered already and ask the new question where you should attach your VB code containing input structures. It could help with conversion to VFP.

You should also ask similar question in SAP zone: http://www.experts-exchange.com/Software/Business_Management/Software/SAP/#browseZones

 

by: dclsoftPosted on 2009-09-10 at 18:33:33ID: 31626375

Thanks!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...