Quantcast
Channel: SCN: Message List - Scripting Languages
Viewing all 1708 articles
Browse latest View live

Re: Sap script vba excel compare field

$
0
0

Thank you for your idee.

I am going to look in too it next week.


Different code when recording script

$
0
0

Dear all,

 

I'm having an issue when running a script in different computers. I see the following when recording the script:

 

My SAP it records the following:

session.findById("wnd[0]/usr/txt[5]").Text = "Mytext"

 

Other computers the code appears as:

session.findById("wnd[0]/usr/txtCYCLE").Text = "Mytext"

 

Both lines are exactly the same field but in different SAP GUI in different PCs.

They are appearing different, is there any settings that can be changed so everyone can have the same setting and run the same script? or any possible way to code the same line?

 

Thanks,

Re: Different code when recording script

$
0
0

Hello.

 

Check Network Settings of SAPGUI Connection.

 

If they are set to 'High' or 'Low'. This is one Option why you can have different screenview names of fields.

 

Best regards,

 

Holger

SAP Gui Script to copy text values to clipboard needed

$
0
0

Hi All -

 

New to SAP and never created a SAP GUI script before so this may be easy for some.  I have a custom page in SAP that has 20 text fields on it.  I need to be able to grab the value in any of the 20 fields and place the values into the clipboard.  There are 20 fields but not all will have values.

 

There will always be a value in the first field:

 

session.findById("wnd[0]/usr/txtZF1").text

 

but there may or may not be a value in any of the other 19

 

session.findById("wnd[0]/usr/txtZF2").text

. . .

session.findById("wnd[0]/usr/txtZF20").text

 

The values can be up to 10 characters each and when placed into the clipboard, I need the values with a CR+LF following each so that when pasted they show up as

 

VALUE1
VALUE2
VALUE3

etc...

 

Can anyone create this script for me?

 

Thanks,

 

MDR

Re: SAP Gui Script to copy text values to clipboard needed

$
0
0

Hello Michael,

 

here an example how to copy data from SAP text fields to the clipboard via Internet Explorer inside SAP GUI Scripting:


'-Begin-----------------------------------------------------------------

 

  '-Directives----------------------------------------------------------
    Option Explicit

 

  '-Global Variables----------------------------------------------------
    Dim SapGuiAuto, application, connection, session, Text2Clip

 

  '-Sub setClipData-----------------------------------------------------
    Sub setClipData(Text2Clip)

 

      '-Variables-------------------------------------------------------
        Dim oIE

 

      Set oIE = CreateObject("InternetExplorer.Application")
      If IsObject(oIE) Then
        oIE.Navigate("about:blank")
        oIE.document.parentWindow.clipboardData.setData "text", Text2Clip
        Set oIE = Nothing
      End If

 

    End Sub

 

  '-Main----------------------------------------------------------------
    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

 

    Text2Clip = session.findById("wnd[0]/usr/txtRSYST-MANDT").text
    Text2Clip = Text2Clip & vbCrLf
    Text2Clip = Text2Clip & _

      session.findById("wnd[0]/usr/txtRSYST-BNAME").text

 

    setClipData(Text2Clip)

 

    Set session = Nothing
    Set connection = Nothing
    Set application = Nothing
    Set SapGuiAuto = Nothing

 

'-End-------------------------------------------------------------------

 

With this example you read the fields mandant and user name from the logon screen and put it to the clipboard.

 

Enjoy it.

 

Cheers

Stefan

Extracting array from SAP

$
0
0

Hello,

 

I need help in order to read data from array within SAP

 

I normally deal with tables in SAP where I have session id for each position that can easily be defined by playing with numbers in bracket .For example:

Session.findById("wnd[0]/usr/tblRSTXTCATTABLE_CONTROL/txtSELECTIONS-TDNAME[0,0]").Text

 

Now I came across what turns out to be an array. When trying to get position, only thing is I get a general shell link and nothing else, regardless to which element i interact. I get following:

session.findById("wnd[0]/usr/cntlORDER_CHECK_COND/shellcont/shell")

 

After investigating with property collector it seems this whole table seems to be an array. I can't find a way how to instruct my VBS script to read the data that is in the table. My goal is to extract all table data and copy to excel. I attach few screenshots for better understanding.

 

Any help is appreciated.

sap table array.png

array.png

Re: Extracting array from SAP

$
0
0


Hello.

 

This document from Stefan explain very good how to read a Shell table (rows ad columns).

 


http://scn.sap.com/docs/DOC-26251

 

This should give you some idea how to adopt technic of Stefan´s documentation for your requirement.

 

Br, Holger

Re: Extracting array from SAP

$
0
0

thanks Holger. Seems to be exactly what I was looking for


Re: Extracting array from SAP

$
0
0

EDIT: Problem was in "Rows". Needed to rename RowsX same for Columns, otherwise it conflicts with VBA language

 

 

Hi again,

 

I tried to adjust to VBA and run directly in excel, but I got not enough memory error. After debugging it looks like capturing all table rows is an issue. I do not know why as there are only 128 rows in my table, but I get error right after table read. And when I try to see number of rows, I get empty data, while column number is fine.

 

After I get error, script just process 3 first rows and stops, which doesn't make much sense to me. Here is sample I use. Any ideas?

 

Sub YVORD_text()

Dim SapGuiAuto

Dim Application

Dim Connection

Dim Session

Dim excelPath

Dim curRow

Dim curCol

Dim Top

Dim vanster

Dim objExcel

Dim workSheetCount

Dim currentWorkSheet

Dim usedColumnsCount

Dim usedRowsCount

Dim Cells

Dim Row

Dim Col

 

 

Dim matNo

Dim salesOrg

Dim distrCh

Dim plant

Dim itemCatGrp

Dim GRDays

Dim inputMessageText

Dim InputMessageType

Dim SaveMessageType

Dim SaveMessage

Dim Division

 

 

If Not IsObject(Application) Then

   Set SapGuiAuto = GetObject("SAPGUISERVER")

   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

On Error Resume Next

Session.findById("wnd[0]").maximize

Dim char_descr, char_value, posNo, char_descr_check, char_value_check, material_code, qty_no, qty_name, material_name, material_numb, item_cat, tabx, row_count, column_count, copy_column_count, copy_char_descr

Dim SoldPO, SoldDate, SoldType, SoldItem, SoldName, SoldMaterial, PurchPO, PurchDate, PurchType, PurchItem, PurchName, SO_item, SO_item2

'==== below write to excel ====

Dim xlApp, xlBook, xlSht

Dim filename, value1, value2, value3, value4

Dim order(0)

order(0) = Range("SOnumber")

SO_item = Range("SO_item")

'filename = "C:\Users\SERAPALISG\Desktop\Revolution\Automation scripts\Scripts\Random\text.xlsx"

 

 

Set xlApp = CreateObject("Excel.Application")

'Set xlBook = xlApp.Workbooks.Open(filename)

'Set xlSht = xlApp.ActiveSheet

 

 

xlApp.DisplayAlerts = False

Sheets("YVORDCHK").Select

Set xlSht = ActiveSheet

'write data into the spreadsheet

xlSht.Cells.Clear

'==== above write to excel ====

'==== below extract SO10 data ====

Session.sendCommand ("/nYVORDCHK_DISP")

Session.findById("wnd[0]/usr/ctxtP_VKORG").Text = "BL62"

Session.findById("wnd[0]/usr/ctxtP_VTWEG").Text = "10"

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

Session.findById("wnd[0]/usr/ctxtP_WERKS").Text = "" 'BL01, cant be empty

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

Session.findById("wnd[0]/usr/ctxtP_MSG").Text = "" 'SALES, can be empty

Session.findById("wnd[0]/usr/txtP_CHECK").Text = "" 'checkgroup

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

Session.findById("wnd[0]").sendVKey 8

posNo = 0

row_count = 1

column_count = 0

Dim field_name, status_select, field_name_check, status_numb

posNo = 0

'-Get rows and ColumnsX--------------------------------------------

Set Table = Session.findById("wnd[0]/usr/cntlORDER_CHECK_COND/shellcont/shell")

Rows = Table.RowCount() - 1

Cols = Table.ColumnCount() - 1

'-Get the technical title of all ColumnsX in the first line--

Set ColumnsX = Table.ColumnOrder()

For j = 0 To Cols

  xlSht.Cells(posNo + 1, column_count + 1) = CStr(ColumnsX(j))

  column_count = column_count + 1

Next

column_count = 0

'-Get the title of all ColumnsX in the second line-----------

For j = 0 To Cols

    Set ColumnTitle = Table.GetColumnTitles(CStr(ColumnsX(j)))

    xlSht.Cells(posNo + 2, column_count + 1) = CStr(ColumnTitle(0))

    column_count = column_count + 1

Next

column_count = 0

For i = 0 To Rows

  For j = 0 To Cols

      xlSht.Cells(posNo + 3, column_count + 1) = Table.GetCellValue(i, CStr(ColumnsX(j)))

      column_count = column_count + 1

  Next

column_count = 0

posNo = posNo + 1

'-Each 32 lines actualize the grid------------------------

If i Mod 32 = 0 Then

  table.SetCurrentCell i, CStr(ColumnsX(0))

  table.firstVisibleRow = i

End If

Next

posNo = 0

Call format_1

'===border===

'lRow = .Range("A" & .Rows.Count).End(xlUp).Row

'lCol = .Cells(1, .ColumnsX.Count).End(xlToLeft).Column

'==== border======

'==== above extract SO10 data ====

'xlBook.Save

'xlBook.Close SaveChanges = True

'xlApp.Close

'xlApp.Quit

'Set xlApp = CreateObject("Excel.Application")

'Set xlBook = xlApp.Workbooks.Open(filename)

'Set xlSht = xlApp.ActiveSheet

'==== below create item copy ====

'===below save and clean ====

Sheets("Sheet1").Select

'xlBook.Save

'xlBook.Close SaveChanges = True

'xlApp.Close

'xlApp.Quit

 

 

'always deallocate after use...

Set xlSht = Nothing

Set xlBook = Nothing

Set xlApp = Nothing

'==== above save and clean ====

End Sub

Re: Extracting array from SAP

$
0
0

May you Need to DIM all used objects like Table, ColumnsX...aso

Looping for order creation macro

$
0
0

Hello All,

 

I am working on creating macro where i need to enter material numbers, qties, date, etc., This is the script i got in recording.

 

[CODE]

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000-BUTTON").press session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,0]").text = "Material 1" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,1]").text = "Material 2" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,2]").text = "Material 3" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,3]").text = "Material 4" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-MENGE[6,0]").text = "50 " session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-MENGE[6,1]").text = "48 " session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-MENGE[6,2]").text = "4" session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-MENGE[6,3]").text = "2 "

[/CODE]

 

Could anyone help me on how to give looping to pick the details from excel and update it as line items in order.

 

Materials need to updated are dynamic.

 

[Code]

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-EMATN[4,0]").text = "Material 1"

 

etc....

[/Code]

 

thank you.

Re: Sap script vba excel compare field

$
0
0

hallo,

 

can you help me with the code because i am a noob.

Re: The control could not be found by id

$
0
0

Hi gurus,

I´m trying to upload multiple registries for a certain customizing task in SPRO (SPRO > Material Management > Purchasing > Purchase Order > Set Up Stock Transport Order > Assign Document Type, One-Step Procedure, Underdelivery Tolerance).

 

I have followed the script creation instructions given in this link:

 

http://scn.sap.com/docs/DOC-57020

 

Everything looks fine until it comes the moment when it has to upload line by line of the source Excel file.  Instead of uploading each of the lines of the Excel file, (starting from the Excel file´s second line due to the first is for column heather) it uploads values "COL1", "COL2" and "COL3" and them brings the error mentioned in this post (The Control could not be found by id").

 

I have an Excel with 5 columns:

SuppyingPlant named as "SP" column in the xls file, equals to column 1 of the xls file

ReceivingPlant named as "RP" column in the xls file, equals to column 2 of the xls file

DocType named as "DT" column in the xls file, equals to column 3 of the xls file

OneStep flag named as "OS" column in the xls file (this is a flag), equals to column 4 of the xls file

Tolerance (empty for all the registries), equals to column 5 of the xls file

and 2000 lines=registries for sap.

So the idea is the script to take care of performing this task 2000 times while I have a coffee .

 

I look forward to receiving your comments.  Many thanks to all in advance.

 

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

REM ADDED BY EXCEL *************************************

 

Dim objExcel

Dim objSheet, intRow, i

Set objExcel = GetObject(,"Excel.Application")

Set objSheet = objExcel.ActiveWorkbook.ActiveSheet

For i = 2 to objSheet.UsedRange.Rows.Count

COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1

COL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2

COL3 = Trim(CStr(objSheet.Cells(i, 3).Value)) 'Column3

COL4 = Trim(CStr(objSheet.Cells(i, 4).Value)) 'Column4

COL5 = Trim(CStr(objSheet.Cells(i, 5).Value)) 'Column5

 

REM ADDED BY EXCEL *************************************

session.findById("wnd[0]/tbar[0]/okcd").text = "/nspro"

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

session.findById("wnd[0]/tbar[1]/btn[5]").press

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").expandNode "02  1    19"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").topNode = "01  1      1"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").expandNode "03  2      3"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").topNode = "01  1      1"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").expandNode "04  3    65"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").topNode = "03  2      3"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").expandNode "05  4    24"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").selectItem "06  4    29","2"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").ensureVisibleHorizontalItem "06  4    29","2"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").topNode = "04  3    27"

session.findById("wnd[0]/usr/cntlTREE_CONTROL_CONTAINER/shellcont/shell").clickLink "06  4    29","2"

session.findById("wnd[0]/tbar[1]/btn[5]").press

session.findById("wnd[0]/usr/tblSAPL0ME6TCTRL_V_T161W/chkV_T161W-UML1S[3,0]").selected = false

session.findById("wnd[0]/usr/tblSAPL0ME6TCTRL_V_T161W/chkV_T161W-TOLKZ[4,0]").selected = false

session.findById("wnd[0]/usr/tblSAPL0ME6TCTRL_V_T161W/ctxtV_T161W-RESWK[0,0]").text = "SP"

session.findById("wnd[0]/usr/tblSAPL0ME6TCTRL_V_T161W/ctxtV_T161W-WERKS[1,0]").text = "RP"

session.findById("wnd[0]/usr/tblSAPL0ME6TCTRL_V_T161W/ctxtV_T161W-BSART[2,0]").text = "DT"

session.findById("wnd[0]/usr/tblSAPL0ME6TCTRL_V_T161W/chkV_T161W-TOLKZ[4,0]").setFocus

session.findById("wnd[0]").sendVKey 0 session.findById("wnd[0]/tbar[0]/btn[11]").press

session.findById("wnd[1]/tbar[0]/btn[0]").press

REM FINALIZATION CONTROL CHECK ************************

 

aux=col1 & " " & col2 & " " & col3  & " " & col4 & " " & col5

CreateObject("WScript.Shell").run("cmd /c @echo %date% %time% " & aux & " >> C:\Users\nbacich\Desktop\SCRIPT\Test1.txt")

next

msgbox "Process Completed"

 

REM FINALIZATION CONTROL CHECK ************************

Re: Scripting via Citrix Client ?!

$
0
0

Hi Sriram,

 

I dont need to logon to the Citrix Server -

 

I can Start the Logon via Doubleclick (like it is installed locally)

but then Citrix is starting and opening the Logon Window like it is Usually displayed -
with all Systems i can logon.

 

Its is like in http://scn.sap.com/message/14533466#14533466 this post ...

 

but it didn't give me any clues-

Re: Looping for order creation macro

$
0
0

In whatever window this is, i would automate based on the coordinate associated to data from an excel field as such:

 

'(Add an integer value based on the starting coordinate)

Dim X as Integer

Dim Y as Integer

X = 0

Y = 0


'(Define the worksheet field to key from for material entry, quantity, note, whatever...)

Worksheets("WORKSHEETNAME").Cells(X, X) = MATERIAL

Worksheets("WORKSHEETNAME").Cells(X, X) = QUANTITY


'(Begin your loop, whatever kind you want... here is a DO loop with a terminating IF/THEN statement)

Do

          If MATERIAL = "" Then

               Exit Function

          End If


     session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000-BUTTON").press      session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPL      MEGUITC_1211/ctxtMEPO1211-EMATN[4, " & X & "]").text = MATERIAL      session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPL      MEGUITC_1211/txtMEPO1211-MENGE[6, " & Y & "]").text = QUANTITY

 

     X = X + 1

     Y = Y + 1    

Loop

End Function

 

You can go further from there by adding a save function, status bar noting... whatever.


Export attachments from SAP

$
0
0

Hi Team,

 

Happy Christmas to All.

 

I want to automatically download the attachment from SAP which are uploaded through T-code FB03.

I have recorded below script for downloading the attachments but save as doalog box is not getting recorded.

 

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[0]/okcd").text = "/nfb03"

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

session.findById("wnd[0]/usr/txtRF05L-GJAHR").setFocus

session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4

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

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"

 

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").currentCellColumn = "BITM_DESCR"

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").contextMenu

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectContextMenuItem "%ATTA_EXPORT"

session.findById("wnd[1]/tbar[0]/btn[0]").press

 

 

Could somone help me to get the script for downloading attachments from SAP T-code Fb03.

 

Thanks for your support.

Re: Export attachments from SAP

$
0
0

Hi Team,

 

I forgot to attach the image

 

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[0]/okcd").text = "/nfb03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/txtRF05L-BELNR").text = "100001235"
session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").text = "3300"
session.findById("wnd[0]/usr/txtRF05L-GJAHR").text = "2015"
session.findById("wnd[0]/usr/txtRF05L-GJAHR").setFocus
session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4
session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").currentCellColumn = "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").contextMenu
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectContextMenuItem "%ATTA_EXPORT"

 

After this script line, i get the popup box which i have attached in JPG format for your reference.

 

Could any of you help me to get the complete script which will enable me to download 1 by 1 attachments on the basis of the information pulled from the excel through below script line

 

session.findById("wnd[0]/usr/txtRF05L-BELNR").text = "100001235"

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").text = "3300"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").text = "2015"

 

Thanks for your support and will be waiting for better solution on this.

Import attachments

$
0
0

Hi Team,

 

Happy Christmas to All.

 

I want to automatically import/upload attachments in SAP through T-code FB03.

I have recorded below script for uploading the attachments.

 

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

session.findById("wnd[0]/tbar[0]/okcd").text = "/nfb03"

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

session.findById("wnd[0]/usr/txtRF05L-BELNR").text = "100111498"

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").text = "3220"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").text = "2015"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").setFocus

session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4

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

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_PCATTA_CREA"

 

After this script line, i get the popup box which i have attached in JPG format for your reference.

 

Could any of you help me to get the complete script which will enable me to download 1 by 1 attachments on the basis of the information pulled from the excel through below script line

 

session.findById("wnd[0]/usr/txtRF05L-BELNR").text = "100111498"

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").text = "3220"

session.findById("wnd[0]/usr/txtRF05L-GJAHR").text = "2015"

 

Thanks for your support and will be waiting for better solution on this.

Re: Save SAP report in Excel format into specified drive

$
0
0

Hi Script Man,

 

Hope you are doing well

 

Happy Christmas and Prosperous New Year 2015 in Advance.

 

I am waiting for soultion on my below post, It would be great if you could assist me around this.

 

Export attachments from SAP

Import attachments

 

Thanks for your support as always.

Re: Save SAP report in Excel format into specified drive

$
0
0

HI script man,

 

Hope you are doing well

 

happy new year in advance

 

i tried your code to auto save the excel file but it is not working for me as im new to this. could you please help me where im wrong

 

 

Public Sub SAPExport()
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPapp = SapGuiAuto.GetScriptingEngine
Set SAPCon = SAPapp.Children(0)
Set session = SAPCon.Children(0)
Set macrobook = ActiveWorkbook
Sheets("sheet1").Select
Range("a5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nyumm_md0007"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/btn%_SP$00001_%_APP_%-VALU_PUSH").press
session.findById("wnd[1]/tbar[0]/btn[16]").press
session.findById("wnd[1]/tbar[0]/btn[24]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]").maximize

 

SAP_Workbook = "Worksheet"

EXCEL_Path = "C:\Users\Shashank.N\Desktop"
myWorkbook = "export.xlsx"


On Error Resume Next
Do
Err.Clear
Set xclapp = GetObject(, "Excel.Application")
If Err.Number = 0 Then Exit Do
'msgbox "Wait for Excel session"
wscript.sleep 2000
Loop

Do
Err.Clear
Set xclwbk = xclapp.Workbooks.Item(SAP_Workbook)
If Err.Number = 0 Then Exit Do
'msgbox "Wait for SAP workbook"
wscript.sleep 2000
Loop


On Error GoTo 0


Set xclsheet = xclwbk.Worksheets(1)

xclapp.Visible = True
xclapp.DisplayAlerts = False

xclapp.ActiveWorkbook.SaveAs EXCEL_Path & myWorkbook
xclapp.ActiveWorkbook.Close


Set xclwbk = Nothing
Set xclsheet = Nothing
'xclapp.Quit
Set xclapp = Nothing


End Sub


Viewing all 1708 articles
Browse latest View live


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