on 08-16-2014 12:16 AM
Hi!
I work with the PM module...
Using VBA, I want to copy a text of a Task List and put it in the excel.
But, I don't want that texts of the operations lines.
I want the complementary texts that are inside the operations...
Please look in the attached.
I can only get to grey square, using the code below. But I can't copy that text inside the grey square...
********************************************************************************************
Sub macro1()
Dim Application
If Not IsObject(Application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Application.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject Application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/tblSAPLCPDITCTRL_3400").Columns.elementAt(6).Width = 2
session.findById("wnd[0]/usr/tblSAPLCPDITCTRL_3400/chkRC270-TXTKZ[6,0]").SetFocus
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]").maximize
End Sub
********************************************************************************************
I hope I have been clear in my explanations.
Thank you in advance !!
Hello.
Do you have single operations in tasklist or multi-Operation where longtext Need to extract?
Best regards,
Holger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have multi-Operations in task list.
For example:
010 - Reapertar parafusos da bomba
(inside the grey square: Reapertar parafusos da bomba e trocá-los, se necessário. Torquear de acordo com o especificado no manual)
020 - Realizar a lubrificação dos mancais
(inside the grey square: Realizar a lubrificação dos mancais e fazer a limpeza dos mesmos, se necessário. Colocar a quantidade indicada no manual)
030 - ..................................
So I need to extract the text inside the grey square (the text in bold)...
Thanks for your attention !!
Hi Paulo.
Ok. Can you use Group and Group Counter as selection criteria?
Then I can enhance an RFC-VBA-Excel template which I used earlier on for extraction of longtext from PM Operations (IW33 order) to get longtext for tasklist Operation (IA07).
Just let me know what is your preferred selection criteria.
Best regards,
Holger
Hi Holger !
Sorry, but i didn't understand what you say about a Group and Group Counter as selection criteria?
Please, could you explain it for me?
By the way, could you show me the code that you used earlier on for extraction of longtext from PM Operations (IW33 order) to get longtext for tasklist Operation (IA07).
Thanks !!
Hello.
Group is the number of used tasklist. Group Counter is the specific code for an section (e.g. plant). So what is your critera which tasklist are in scope?
For PM Operation longtext I have used an Excel template like this (My selection criteria is Routing number and Counter => this is technically linked to PM Operation):
Where I had this VBA code included:
Hi Holger,
Analyzing your post about IW33 I had an insigth.
I think it is basic, but I really didn't know about that...
I discovered a way to become the text field in an "object".
Old editor:
Changing the editor:
Choosing the new editor:
Appearence of the new editor:
With this new appearence of the editor, I can record a script and the generated codes can get the phrases of the text field (now, they recognize the text field).
Look the code bellow:
Sub Botão1_Clique()
Dim application
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
For x = 2 To 2000
If Excel.Cells(x, 1) <> "" Then
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/niw32"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").Text = Excel.Cells(x, 1)
session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").caretPosition = 8
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpVGUE").Select
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1101/tabsTS_1100/tabpVGUE/ssubSUB_AUFTRAG:SAPLCOVG:3010/tblSAPLCOVGTCTRL_3010/btnLTICON-LTOPR[8,2]").SetFocus
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1101/tabsTS_1100/tabpVGUE/ssubSUB_AUFTRAG:SAPLCOVG:3010/tblSAPLCOVGTCTRL_3010/btnLTICON-LTOPR[8,2]").press
Excel.Cells(x, 2) = session.findById("wnd[0]/usr/sub:SAPLSTXX:1100/txtRSTXT-TXLINE[1,5]").Text
Excel.Cells(x + 1, 2) = session.findById("wnd[0]/usr/sub:SAPLSTXX:1100/txtRSTXT-TXLINE[2,5]").Text
session.findById("wnd[0]/tbar[0]/btn[12]").press
session.findById("wnd[0]/tbar[0]/btn[12]").press
session.findById("wnd[1]/usr/btnSPOP-OPTION2").press
Excel.Cells(x, 3) = "OK"
Else
x = 2001
End If
Next
MsgBox "Concluído"
End Sub
But now I have another problem.
I can get only the text inside the line indicated by the red arrow ("btnLTICON-LTOPR[8,2]")...
If I want to get the text inside each lines until find a empty line, how could I do ?
I know that I have to use variables, but i dont know how to build the code....
Could you help me please ?!
Thanks !!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.