Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10449

Re: Gathering MHTML reports

$
0
0

Hello Holgar!

 

Thank you very much for your reply.

 

My purpose was to be able to gather all the ALV-grid info into one excel file.

(For many diff. order numbers, all gathered into one file)

 

When I tried the above script, the furthest it took me was to display mode...

 

Is there any way I am able to transfer this into excel file (and save)?

Capture.PNG

Thank you once again!

 

BR, Cathy

 

 

* What I have so far *

 

Sub GetPlanCostData()
'---------------------------------
  '---------------------------------
' Parameters


'---------------------------------
   '-------- SAP LOGIN --------------
   '---------------------------------


    'If Right(CLPdirName, 1) <> "\" Then CLPdirName = CLPdirName & "\"

    On Error Resume Next

    If SAPApp Is Nothing Then
        Set SapGuiApp = GetObject("SAPGUI")
        Set SAPApp = SapGuiApp.GetScriptingEngine
       ' If SAPApp Is Nothing Then GoTo Exit_AllReport
    End If
    If Connection Is Nothing Then
        Set Connection = SAPApp.Children(0)
    End If
    If Session Is Nothing Then
        Set Session = Connection.Children(0)
    End If

Set GRID = Session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell")
GRID.setCurrentCell -1, ""
Row = GRID.currentCellRow
CELL = GRID.getcellvalue(Row, "COLUMN_NAME")

 

' Get data for paging-down

RowCount = GRID.RowCount

VisibleRows = GRID.VisibleRowCount

VisiblePages = (RowCount / VisibleRows) - 1

 

' Get current column selected by user

SelectedColumn = GRID.CurrentCellColumn

GRID.selectColumn SelectedColumn

GRID.FirstVisibleRow = GRID.RowCount - 1

 

'Page to bottom of ALV

For Pages = 1 To VisiblePages

    GRID.FirstVisibleRow = (Pages * VisibleRows)

Next

 

' Select all text

GRID.contextMenu

GRID.SelectContextMenuItemByPosition "0"

 

' Return to first row

GRID.FirstVisibleRow = 0

GRID.ClearSelection

GRID.currentCellRow = 0

GRID.CurrentCellColumn = SelectedColumn

 

 

'MsgBox "Number of records: " & Grid.RowCount, vbInformation, "Count of Records"

 

' Cancel popup message (Not all data has been copied into the clipboard)

On Error Resume Next

    Session.FindById("wnd[1]/tbar[0]/btn[0]").press

On Error GoTo 0

    If Err = 0 Then flgSapIsOpen = True
    Err.Clear
   
    On Error GoTo 0

    If flgSapIsOpen = False Then
        Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
        Set Connection = SapGuiApp.OpenConnection(CLPsapName, True, False)
      '  If Connection Is Nothing Then GoTo Exit_AllReport
   '?     Set session = Connection.Children(0)

        If Not IsObject(Connection) Then
            Set Connection = SAPApp.Children(0)
        End If
        If Not IsObject(Session) Then
            Set Session = Connection.Children(0)
        End If

    End If

'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

'Start Processing in SAP
i = 2

SO = Cells(i, 1)


    Session.FindById("wnd[0]").maximize
    Session.FindById("wnd[0]/tbar[0]/okcd").Text = "/niw33"
    Session.FindById("wnd[0]").sendVKey 0
    Session.FindById("wnd[0]/usr/ctxtCAUFVD-AUFNR").Text = SO
    Session.FindById("wnd[0]/tbar[1]/btn[8]").press
    Session.FindById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/tabsTS_1100/tabpKOAU/ssubSUB_AUFTRAG:SAPLICO1:1100/btnPUSH1").press
    ThisWorkbook.Sheets(2).Activate
    Set Table_Message = Session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell")
    Set Cols = Table_Message.ColumnOrder()
    ROW_COUNT = Table_Message.RowCount() - 1
    COL_COUNT = Table_Message.ColumnCount() - 1
   
    For i = 0 To ROW_COUNT
        For j = 0 To COL_COUNT
            DoEvents
            If i = 0 Then ThisWorkbook.Sheets(2).Cells(i + 1, j + 1).Value = Table_Message.GetDisplayedColumnTitle(CStr(Cols(j)))
            ThisWorkbook.Sheets(2).Cells(i + 2, j + 1).Value = Table_Message.getcellvalue(i, CStr(Cols(j)))
        Next
    Next
   
Columns.AutoFit


SAP_Workbook = "Worksheet in Basis (1)"
EXCEL_Path = "C:\SAP\"
myWorkbook = "Report.xlsx"

End Sub


Viewing all articles
Browse latest Browse all 10449

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>