COMate - control COM objects via automation - OBSOLETE!
How i can make the follow code working with COMate?
Thanks
Code: Select all
Dim fso As Object
Dim fld As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.getfolder("d:\test\")
MsgBox fld.Size
my live space
nicolaus wrote:How i can make the follow code working with COMate?
Code: Select all
Define fso.COMateObject
Define fld.COMateObject
fso = COMate_CreateObject("Scripting.FileSystemObject")
fld = fso\getobjectproperty("getfolder('d:\test\')")
MessageRequester("", Str(fld\getintegerproperty("Size")))
fld\Release()
fso\Release()
Hygge
@glops: I don`t know, if you`ve ever solved your problem.
Try this:
Yesterday and today I had a little time to test CoMate with SAP
Here are almost all tables: http://www.lyriance-labs.com/dev/glossary-tables ...but it`s better to get the name of the name of table pressing F1, when using SAP.
lg
Marco
Tomorrow I will do some more and other stuff (I hope)! CoMate is really fantastic.
Try this:
Code: Select all
IncludePath "..\"
XIncludeFile "COMate.pbi"
Define.COMateObject Functions, LogonControl, R3Connection, func, iTABLE_NAME, eNUMBER_OF_ENTRIES, tENTRIES
LogonControl = COMate_CreateObject("SAP.LogonControl.1")
If LogonControl
Functions = COMate_CreateObject("SAP.Functions")
If Functions
R3Connection = Functions\GetObjectProperty("Connection")
If R3Connection
R3Connection\SetProperty("User = 'XXXXX'")
R3Connection\SetProperty("Client = '011'")
R3Connection\SetProperty("Password = 'XXXXX'")
R3Connection\SetProperty("System = 'LP1'")
R3Connection\SetProperty("ApplicationServer = 'SAPLP1'")
R3Connection\SetProperty("SystemNumber = '20'")
R3Connection\SetProperty("TraceLevel = '0'")
R3Connection\SetProperty("Language = 'DE'")
retcd = R3Connection\GetIntegerProperty("Logon(0, #True)")
func = Functions\GetObjectProperty("Add('RFC_GET_TABLE_ENTRIES')")
If func
eNUMBER_OF_ENTRIES = func\GetObjectProperty("Imports('NUMBER_OF_ENTRIES')")
iTABLE_NAME = func\GetObjectProperty("Exports('TABLE_NAME')")
tENTRIES = func\GetObjectProperty("Tables('ENTRIES')")
If iTABLE_NAME
iTABLE_NAME\SetProperty("Value = 'TCURR'")
func\Invoke("Call")
result=eNUMBER_OF_ENTRIES\GetIntegerProperty("Value")
For x=1 To result
Debug tENTRIES\GetStringProperty("Value("+Str(x)+",1)")
Next
iTABLE_NAME\Release()
EndIf
tENTRIES\Release()
iTABLE_NAME\Release()
eNUMBER_OF_ENTRIES\Release()
func\Release()
EndIf
R3Connection\Release()
EndIf
Functions\Release()
EndIf
LogonControl\Release()
EndIf

Here are almost all tables: http://www.lyriance-labs.com/dev/glossary-tables ...but it`s better to get the name of the name of table pressing F1, when using SAP.
lg
Marco
Tomorrow I will do some more and other stuff (I hope)! CoMate is really fantastic.
PureBasic for Windows
yes thank you, I got it too since some weeks but not time to write it
another sample :
(same header for connnection with password, etc)
but if you know how to display the data as VARIANT, I would like to know it
iTable_NAME\GetVariantProperty("DATA") ? and then ?
and if you know how to use the "Sap.TableFactory.1", we could create a kind of library for SAP to access each data

another sample :
(same header for connnection with password, etc)
Code: Select all
retcd = R3Connection\Invoke("Logon(0, #True)") ;Does this need to be retcd = R3Connection\GetIntegerProperty("Logon(0, #True)") ???
func = Functions\GetObjectProperty("Add('RFC_LOGON_INFO')")
If func
; eNUMBER_OF_ENTRIES = func\GetIntegerProperty("NUMBER_OF_ENTRIES")
; If eNUMBER_OF_ENTRIES
e1 = func\Invoke("Call")
z2.s = func\GetStringProperty("Imports\RFC_LOGIN_COMPLETE")
Debug "RFC_LOGIN_COMPLETE = " + z2.s
;Debug e1\GetStringProperty("RFC_LOGIN_COMPLETE")
;iTABLE_NAME = func\GetObjectProperty("Exports('TABLE_NAME')")
If iTABLE_NAME
; tENTRIES = func\GetObjectProperty("Tables('ENTRIES')")
; If tENTRIES
iTABLE_NAME\SetProperty("Value = 'TCURR')")
func\Invoke("Call")
;Debug "Number of entries = " + Str(eNumber_OF_ENTRIES\GetIntegerProperty("Value"))
Debug COMate_GetLastErrorDescription()
;eMAXIMAL_RESOURCES = func\GetIntegerProperty("NUMBER_OF_ENTRIES")
Debug Str(eNUMBER_OF_ENTRIES\GetIntegerProperty("NUMBER_OF_ENTRIES") )
Debug Str(eNumber_OF_ENTRIES\GetIntegerProperty("Value"))
; eNUMBER_OF_ENTRIES = func\GetObjectProperty("Imports('NUMBER_OF_ENTRIES')")
; Debug Str(eNUMBER_OF_ENTRIES\GetIntegerProperty("NUMBER_OF_ENTRIES") )
; Debug Str(eNumber_OF_ENTRIES\GetIntegerProperty("Value"))
Debug eNumber_OF_ENTRIES\GetStringProperty("Value")
Debug eNumber_OF_ENTRIES\GetStringProperty("NUMBER_OF_ENTRIES")
Debug eNUMBER_OF_ENTRIES\GetIntegerProperty("Value")
Debug COMate_GetLastErrorDescription()
Debug func\GetIntegerProperty("NUMBER_OF_ENTRIES")
;Debug PeekL(eNumber_OF_ENTRIES)
; tENTRIES\Release()
; EndIf
iTABLE_NAME\Release()
EndIf
; eNUMBER_OF_ENTRIES\Release()
; EndIf
func\Release()
EndIf
R3Connection\Release()
EndIf
Functions\Release()
EndIf
LogonCOntrol\Release()
EndIf

but if you know how to display the data as VARIANT, I would like to know it
iTable_NAME\GetVariantProperty("DATA") ? and then ?
and if you know how to use the "Sap.TableFactory.1", we could create a kind of library for SAP to access each data

OCR with MODI
a little sample : how to OCR with MODI (needs installation part of Office 2003) and it runs !!
Just create a .TIF with mspaint, or take a screen shot, save as .TIF and execute it
Have fun !
For information one of the best OCR tool I tested is ABBYY (try screenshot reader ! near 100%) but the SDK is too too expensive for me
Have fun !
Code: Select all
IncludePath "..\"
XIncludeFile "COMate.pbi"
Define.COMateObject myMODI , myLAYOUT
; Define.COMateObject e1 , e2, e3, e4, e5, e6, e99
;
; Define.l Result,*ResultR.VARIANT,*ResultG.VARIANT,*ResultB.VARIANT
;myLAYOUT = COMate_CreateObject("MODI.Layout")
;Debug COMate_GetLastErrorDescription()
myMODI = COMate_CreateObject("MODI.Document")
Debug COMate_GetLastErrorDescription()
;Debug COMate_GetLastErrorDescription()
img.s = "C:\z.tif"
;myMODI\SetProperty("FileName = '"+img.s+"'")
;Debug COMate_GetLastErrorDescription()
;z.s = myMODI\GetStringProperty("FileName")
;Debug z.s
cmd$ = "Create('" + img.s +"')"
myMODI\Invoke(cmd$)
;myMODI\Invoke("Create('c:\test.bmp')")
Define miLANG_ENGLISH$ = "9"
Debug COMate_GetLastErrorDescription()
Debug subrc
;subrc = myMODI\Invoke(z$)
;Debug COMate_GetLastErrorDescription()
Debug subrc
saveAs$ = "SaveAs('" + "C:\doc.mdi" + "', '4')"
myMODI\Invoke(saveAs$)
Debug COMate_GetLastErrorDescription()
zz = myMODI\GetIntegerProperty("Images\Count")
Debug z
Debug COMate_GetLastErrorDescription()
zOCR$ = "Ocr('"+miLANG_ENGLISH$+"', #True, #False)"
myMODI\Invoke(zOCR$)
Debug z$
Debug COMate_GetLastErrorDescription()
myLAYOUT = myMODI\GetObjectProperty("Images(0)\Layout")
Debug COMate_GetLastErrorDescription()
t$ = myLAYOUT\GetStringProperty("Text")
Debug "text = " + t$
t$ = myLAYOUT\GetStringProperty("Language")
Debug "language = " + t$
nb = myLAYOUT\GetIntegerProperty("NumWords")
Debug "nb Words = " + Str(nb)
Debug COMate_GetLastErrorDescription()
t$ = myLAYOUT\GetStringProperty("Words(0)\Text")
Debug "1st Word = " + t$
Debug COMate_GetLastErrorDescription()
Have fun !
For information one of the best OCR tool I tested is ABBYY (try screenshot reader ! near 100%) but the SDK is too too expensive for me
Have fun !
@glops: I don`t think, that this will work:
Today I just played with different tables (RFC and Bapi) - everything`s running fine til now. Next week or so I will get a corporate laptop, so I can log in from home and do some more tests.
Code: Select all
iTABLE_NAME\SetProperty("Value = 'TCURR')")
Today I just played with different tables (RFC and Bapi) - everything`s running fine til now. Next week or so I will get a corporate laptop, so I can log in from home and do some more tests.
PureBasic for Windows
comate and SAP TableFactory ....and question
An example ...how to use the TableFactory
Question for Marco2007 (or others)
Are you able to fill the OPTIONS table for RFC_READ_TABLE ? Here is one of my tries..but not success
I don't know how to fill the Value..
2 ways in VB
objOptTab.Rows.Add
objOptTab(objOptTab.RowCount, "TEXT") = "STATUS = '51'"
check : http://sapass.metro.client.jp/Sap_Activ ... ction1.htm
OR
oParam2.AppendRow
oParam2.Columns("TEXT").Value(1) ="MANDT NE '000'"
check :
No success
https://www.sdn.sap.com/irj/scn/weblogs ... /wlg/12868
Code: Select all
Define.l Result,*ResultR.VARIANT
TableFactory = COMate_CreateObject("Sap.TableFactory.1")
; Debug TableFactory
If TableFactory
myObj = TableFactory\GetObjectProperty("NewTable")
Debug COMate_GetLastErrorDescription()
Debug myObj
; TAB512 = name of STRUCTURE to read
cmd$ = "CreateFromhandle(" + Str(R3Connection) + " As COMateObject, " + Str(iTable_NAME) + ", 'TAB512', 'Data')"
myObj\Invoke(cmd$)
Debug COMate_GetLastErrorDescription()
z2.l = myObj\GetIntegerProperty("ColumnCount")
Debug z2
For i = 1 To z2
;ColumnCount
Debug myObj\GetStringProperty("ColumnName("+Str(i)+")")
Next i
;Debug iTable_NAME\wa
nbRows = iTable_NAME\GetIntegerProperty("Rows")
Debug nbRows
EndIf
Are you able to fill the OPTIONS table for RFC_READ_TABLE ? Here is one of my tries..but not success
I don't know how to fill the Value..
2 ways in VB
objOptTab.Rows.Add
objOptTab(objOptTab.RowCount, "TEXT") = "STATUS = '51'"
check : http://sapass.metro.client.jp/Sap_Activ ... ction1.htm
OR
oParam2.AppendRow
oParam2.Columns("TEXT").Value(1) ="MANDT NE '000'"
Code: Select all
Define.COMateObject etable
etable = func\GetObjectProperty("Tables('OPTIONS')") ;ok
etable\Invoke("AppendRow") ;ok
z2.l = etable\GetIntegerProperty("RowCount") ;ok
Debug z2.l ; ok
Debug COMate_GetLastErrorDescription() ;ok
Debug COMate_GetLastErrorDescription()
cmd$ = "Columns('TEXT')\Value(0) = 'WERKS' = 'F101'"
etable\SetProperty(cmd$)
Debug COMate_GetLastErrorDescription()
No success

Try :
or
Code: Select all
cmd$ = "Columns('TEXT')\Value(0) = 'WERKS = F101'"
Code: Select all
cmd$ = "Columns('TEXT')\Value(0) = 'WERKS = $0027F101$0027'"
I may look like a mule, but I'm not a complete ass.
so fast !
thanks Srod, with 1st syntax just replace 0 with 1: Return from Comate is now Okay
but later when I try to display the results I have "Bad Variant"....message
Still something wrong, but I will continue to investigate
Code: Select all
cmd$ = "Columns('TEXT')\Value(1) = 'WERKS = F101'"
but later when I try to display the results I have "Bad Variant"....message
Still something wrong, but I will continue to investigate
arf
you're too fast,, just tried it, and YES it WORKS !! Fabulous
In fact I don't need the TableFactory for what I want to do, but galaxy of interfaces for SAP from/with PB is opened ! Already have a lot of ideas !
I will buy one of your Grid one of these days for all your help !
Just optional question for you sRod, did you try the OCR code I provided (MODI) with the Office2007 version ? Are the results better ? I already find that results are very good with 2003 version ! really !
and
T H A N K S !!!
In fact I don't need the TableFactory for what I want to do, but galaxy of interfaces for SAP from/with PB is opened ! Already have a lot of ideas !
I will buy one of your Grid one of these days for all your help !
Just optional question for you sRod, did you try the OCR code I provided (MODI) with the Office2007 version ? Are the results better ? I already find that results are very good with 2003 version ! really !
and
T H A N K S !!!
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Hello it's again me
Before disturb you, KCC have read all the 23 page of this THREAD
And he don't see anything who speak to "InternetExplorer.Application"
KCC have try to translate this VB code.
But it's a disaster
Already at the third line KCC is locked, i'm sure you are not surprised :roll:
If you have again a finger, just one it's enough, to push a little bit KCC, can you use it for him ??
This is my COWPAT
Thanks and good day

Before disturb you, KCC have read all the 23 page of this THREAD

And he don't see anything who speak to "InternetExplorer.Application"
KCC have try to translate this VB code.
But it's a disaster

Already at the third line KCC is locked, i'm sure you are not surprised :roll:
If you have again a finger, just one it's enough, to push a little bit KCC, can you use it for him ??
Code: Select all
Private Sub Form_Load()
'activer la reference Microsoft HTML Objects Library
'activer la refenrce Microsoft Internet Controls
Dim i As Integer
Dim IE As InternetExplorer
Dim maPageHtml As HTMLDocument
Dim Helem As IHTMLElementCollection
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://www.google.fr/"
Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop 'attendre la fin du chargement
Set maPageHtml = IE.document
Set Helem = maPageHtml.getElementsByTagName("input")
'
'quand tu connais l'index des objets tu peux utiliser le code comme ci dessous
'pour remplir le champ
Helem.Item(1).innerText = "developpez.com"
'simule le clic sur le bouton "Recherche Google"
'Helem(2).Click
End Sub

Code: Select all
IncludePath "..\"
XIncludeFile "COMate.pbi"
FileName$ = GetTemporaryDirectory() + "test.html"
HTTPObject.COMateObject
HTTPObject = COMate_CreateObject("InternetExplorer.Application")
If HTTPObject
HTTPObject\Invoke("Visible= 1")
HTTPObject\invoke("Navigate 'http://www.google.fr/'")
; HTTPObject\Invoke("Open('GET', 'http://www.purebasic.fr/english/', #False)") ;A Boolean type is the default for a #False parameter.
; HTTPObject\Invoke("Send")
; status$ = HTTPObject\GetStringProperty("StatusText")
If status$ = "OK"
; response$ = HTTPObject\GetStringProperty("ResponseText")
; File = CreateFile(#PB_Any, FileName$)
; If File
; WriteString(File, response$)
; CloseFile(File)
; RunProgram(FileName$)
; EndIf
EndIf
HTTPObject\Release()
EndIf

Not a destination