cancel
Showing results for 
Search instead for 
Did you mean: 

MIR4 TABLE EXTRACTION TO EXCEL

Former Member
0 Kudos

Hi All Experts,

Need your valuable input in scripting:

I Want to download the from T.code MIR4 PO Ref Table to Excel. ( Amount, PUrchase Order & Order)

Below Problems:

a) How would the Script read the number of Rows in Table.

b) How would values would be stored & saved in Excel.

I am presently counting the number of rows and doing it manually in SAP GUI. ( The GUI has to count the number of rows in table and copy the details to excel)

Sample:

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]/usr/txtRBKP-BELNR").text = strInvRef

session.findById("wnd[0]").sendVKey 0

Cell1 = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-WRBTR[1,0]").Text

Cell2 = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-WRBTR[1,1]").Text

Cell3 = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-WRBTR[1,2]").Text

Cell4 = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-WRBTR[1,3]").Text

Cell5 = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-WRBTR[1,4]").Text

Cell6 = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-WRBTR[1,5]").Text

'Cell7 = session.findById("wnd[0]/usr/subHEADER_AND_ITEMS:SAPLMR1M:6005/subITEMS:SAPLMR1M:6010/tabsITEMTAB/tabpITEMS_PO/ssubTABS:SAPLMR1M:6020/subITEM:SAPLMR1M:6310/tblSAPLMR1MTC_MR1M/txtDRSEG-WRBTR[1,6]").Text

session.findById("wnd[0]").sendVKey 12

set ns1=createobject("WScript.shell")

ns1.AppActivate "Microsoft Excel"

objSheet.Cells(2, 2) = Cell1

objSheet.Cells(3, 2) = Cell2

objSheet.Cells(4, 2) = Cell3

objSheet.Cells(5, 2) = Cell4

objSheet.Cells(6, 2) = Cell5

objSheet.Cells(7, 2) = Cell6

'objSheet.Cells(8, 2) = Cell7

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Since nobody has given this question a try after this long I will give it a shot: I am not familiar with that transaction (don't even have access to it) but I think that if you are going to end up with your data in Excel anyway then why don't you just download all the data and do the calculations with Excel (the calculations are Excel's strength) with a Pivot Table or something like it.