on 11-08-2016 3:00 AM - last edited on 02-03-2024 5:42 PM by postmig_api_4
Good morning,
Thanks to the resources in this community I've been able to write several vba scripts to automatize some tasks within SAP.
Now I'm trying to write a Script for CM25, but this one seems much more tricky...
My idea was to extract the production and planned orders from SAP, come up with the best sequence within my excel macro and then dispatch the orders with the sequence I came up with using cm25.
In the previous scripts I wrote, I used the record script function in SAP to identify the different elements, and then personalized that code for my purposes.
With CM25 though, when I select a production order from the pool or from the ones dispatched, no line of code is written. So it fails even when you try to execute the .vbs file just after recording it.
So my question is: Does anyone know the command or the method in VBA to select an order in CM25?
Thank you very much for your help,
Pablo
Hi Experts,
I know it is not very close to the topic but I really like to help me because I am trying to find out about this problem for a week.
My macro it is blocking at opening "FBL3N" transaction I really have no ideea why. The error is "method 'find by id' or object 'isapsessiontarget' failed"
Any advice is appreciate!
Sub SAP_export()
Dim SAPguiAPP As SAPFEWSELib.GuiApplication
Dim oConnection As SAPFEWSELib.GuiConnection
Dim SAPSesi As SAPFEWSELib.GuiSession
If SAPguiAPP Is Nothing Then
Set SAPguiAPP = CreateObject("Sapgui.ScriptingCtrl.1")
If SAPguiAPP Is Nothing Then
Exit Sub
End If
End If
If oConnection Is Nothing Then
Set oConnection = SAPguiAPP.OpenConnection("102 P62 [EMEA Prod]", True) 'P62 (1) 351
If oConnection Is Nothing Then
Exit Sub
End If
End If
If SAPSesi Is Nothing Then
Set SAPSesi = oConnection.Children(0)
If SAPSesi Is Nothing Then
End If
End If
With SAPSesi
.FindById("wnd[0]/usr/txtRSYST-MANDT").Text = Worksheets("Sheet1").Cells(1, 1).Value
.FindById("wnd[0]/usr/txtRSYST-BNAME").Text = Worksheets("Sheet1").Cells(1, 2).Value
.FindById("wnd[0]/usr/pwdRSYST-BCODE").Text = Worksheets("Sheet1").Cells(1, 3).Value
.FindById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
.FindById("wnd[0]").sendVKey (0)
.FindById("wnd[1]/tbar[0]/okcd").Text = "fbl3n"
.FindById("wnd[1]").sendVKey 0
End With
Stop
Set SAPSesi = Nothing
Set oConnection = Nothing
Set SAPguiAPP = Nothing
End Sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your answer Mr. ScriptMan,
Unfortunately, I didn't explain myself properly in my original post.
I'm talking about capacity leveling (for example profile SAPSFCG001), that looks similar to this:
This is a very short script that I recorded as an example. While recording I selected a production order from the pool and pressed the dispatch button, and then selected a production order from the dispatched ones, and pressed the Deallocate button.
As you can see on the code below, only the click of the buttons were recorded. So I'm trying to find a way to select these production orders as the first step to building some tools.
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]/tbar[1]/btn[5]").press
session.findById("wnd[0]/tbar[1]/btn[6]").press
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pablo,
I do not work with the TA CM25. When I call this I can still record some commands:
session.findById("wnd[0]/tbar[0]/okcd").text = "/ncm25"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").text = "SAPSFCG021"
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/ctxtAFKAUFNR-LOW").text = "D00000012007"
session.findById("wnd[0]/usr/ctxtPLAPLNUM-LOW").setFocus
session.findById("wnd[0]/usr/ctxtPLAPLNUM-LOW").caretPosition = 0
session.findById("wnd[0]/tbar[1]/btn[8]").press
Maybe it will help you.
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.