Skip to Content

SAP APO VBA - Select-Copy-Paste planning book from SDP94 into Excel

In order to reduce some manual task I perform almost on a daily basis I am trying to build a code that would:

<code>-Select a code from a list in excel
-Open the SDP94 transaction in SAP ECC
-Load the code in a particular book
-Select all the data from the report loaded & Copy
-Paste it in an Excel.

The problem I have so far is in APO. I am able to load the report but the steps of select & copy are not reflected/ dont show anything in the sap script recorder. I am not considering the option of downloading the report since several codes need to be checked and this will have an impact on the total time the macro takes to process.

Last tines of the code (loading)

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/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").expandNode "F00008"			
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00002"			
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").topNode = "Favo"			
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00002"			
session.findById("wnd[0]/shellcont[0]/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").hierarchyHeaderWidth = 392			
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").expandNode "         45"			
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").selectItem "        172","Column1"			
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").ensureVisibleHorizontalItem "        172","Column1"			
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = "         45"			
session.findById("wnd[0]/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").doubleClickItem "        172","Column1"			
session.findById("wnd[0]/shellcont[0]/shell/shellcont[0]/shell/shellcont[0]/shell").pressButton "/SAPAPO/MCPSH_SELECTION_SCREEN"			
session.findById("wnd[1]/usr/cmbGS_GROUP-OBJ").key = "INTERN_MATLO"			
session.findById("wnd[1]/usr/subSEL_SUB_02:/SAPAPO/SAPLMCPSH_SH:0202/cmbGS_SEL-02-OBJ").setFocus			
session.findById("wnd[1]/usr/subSEL_SUB_02:/SAPAPO/SAPLMCPSH_SH:0202/cmbGS_SEL-02-OBJ").key = "9AMATNR"			
session.findById("wnd[1]/usr/subSEL_SUB_02:/SAPAPO/SAPLMCPSH_SH:0202/txtGS_SEL-02-VAL").text = "914771"			
session.findById("wnd[1]/usr/subSEL_SUB_02:/SAPAPO/SAPLMCPSH_SH:0202/txtGS_SEL-02-VAL").setFocus			
session.findById("wnd[1]/usr/subSEL_SUB_02:/SAPAPO/SAPLMCPSH_SH:0202/txtGS_SEL-02-VAL").caretPosition = 6			
session.findById("wnd[1]").sendVKey 0			
session.findById("wnd[1]/tbar[0]/btn[8]").press			
session.findById("wnd[0]/shellcont[0]/shell/shellcont[0]/shell/shellcont[0]/shell").pressButton "/SAPAPO/MCPSH_MARK_ALL"			
session.findById("wnd[0]/usr/subSUB_MAIN:/SAPAPO/SAPLMSDP_SDP:0027/cntlSDP_TLB_CUSTOM_CONTROL/shellcont/shell").pressButton "MSDP_REFRESH"	




<br>

Is there any way to do this in a quick way? Select the report from SAP APO, copy it to the clipboard and then move to Excel and paste?

I am been exploring option with Menucontext but I dont have much clarity on how to make the code work.

Greats, A.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

0 Answers