Skip to Content
0

Script for cm25

Nov 08, 2016 at 03:00 AM

144

avatar image

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

10 |10000 characters needed characters left characters exceeded

I'm talking about capacity levelling, for example profile SAPSFCG001. That looks similar to this.


Example of a script recorded while trying to select an order from the pool, dispatch it with the button, select a dispatched order, deallocate it by pressing the button.

Only the button presses were recorded.

IfNot IsObject(application)ThenSet SapGuiAuto  = GetObject("SAPGUI")Setapplication= SapGuiAuto.GetScriptingEngine
EndIfIfNot IsObject(connection)ThenSetconnection=application.Children(0)EndIfIfNot IsObject(session)ThenSet session    =connection.Children(0)EndIfIf IsObject(WScript)Then
   WScript.ConnectObject session,"on"
   WScript.ConnectObject application,"on"EndIf
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[1]/btn[5]").press
session.findById("wnd[0]/tbar[1]/btn[6]").press
capture.jpg (150.2 kB)
0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Script Man Nov 08, 2016 at 07:17 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Pablo Duart Nov 11, 2016 at 01:10 AM
0

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

capture.jpg (150.2 kB)
Share
10 |10000 characters needed characters left characters exceeded
Calin Perpelea Nov 21, 2016 at 04:23 PM
0

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
Share
10 |10000 characters needed characters left characters exceeded