Skip to Content
1
Feb 24, 2020 at 06:54 AM

Upload attachment in SAP transaction code FB03 through store business document

448 Views

Hi Script Gurus,

I am currently trying to automate using VBA for attaching multiple type of files to FB03 through "ARL_LINK". I am having problem with my script. I have seen previous questions but I don't really understood those..

So I hope you'll help me with this.

in 4th column there is link of those files.

Main Code

session.findById("wnd[0]/usr/txtRF05L-BELNR").Text = ActiveSheet.Range("B" & i).Value 'docnumber
session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = ActiveSheet.Range("C" & i).Value 'companycode
session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = ActiveSheet.Range("A" & i).Value 'year
ActiveSheet.Range("D" & i).Value = "X:\Automation\MB\Files\" & ActiveSheet.Range("C" & i).Value & " " & ActiveSheet.Range("B" & i).Value & " " & ActiveSheet.Range("A" & i).Value & ActiveSheet.Range("E" & i).Value
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/titl/shellcont/shell").pressButton "%GOS_TOOLBOX"
session.findById("wnd[0]/shellcont/shell").pressContextButton "CREATE_ATTA"
Set WShell = CreateObject("WScript.Shell")
WShell.Run "X:\Automation\MB\Files\Script1.vbs" & " " & CStr(i), 1, False
session.findById("wnd[0]/shellcont/shell").SelectContextMenuItem "ARL_LINK"
session.findById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").hierarchyHeaderWidth = 269
session.findById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").selectItem "0000000737", "HITLIST"
session.findById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").ensureVisibleHorizontalItem "0000000737", "HITLIST"
session.findById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").topNode = "0000000722"
session.findById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").doubleClickItem "0000000737", "HITLIST"
session.findById("wnd[2]").sendVKey 0
session.findById("wnd[2]/usr/sub:SAPLSPO4:0300/txtSVALD-VALUE[1,21]").Text = "Buchbeleg"
session.findById("wnd[2]/usr/sub:SAPLSPO4:0300/txtSVALD-VALUE[1,21]").caretPosition = 9
session.findById("wnd[2]").sendVKey 0

Script1.vbs

Set Wshell = CreateObject("WScript.Shell")

Do

bWindowFound = Wshell.AppActivate("Import file")

WScript.Sleep 1000

Loop Until bWindowFound

bWindowFound = Wshell.AppActivate("Import file")

if (bWindowFound) Then

Wshell.appActivate "Import file"

WScript.Sleep 100

Wshell.sendkeys "{ENTER}"

WScript.Sleep 100

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

Wshell.sendkeys xclapp.cells(wscript.arguments(0),4).value


WScript.Sleep 100

Wshell.sendkeys "{ENTER}"

WScript.Sleep 100

end If

I tried this but it is not helping me..