Skip to Content
avatar image
Former Member

SAP Gui scripting for attaching file from FB03 t-code for a SAP document

Hi All,

Greetings for the day!

I have been trying to write a code where a file(irrespective of type(excel,pdf,email..,) should be attached for a SAP document from FB03 screen.

The path of the file is from my desktop and the name will be the document number as mentioned in the below code:

Sub attachmentfb03()

Dim application

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 = "1400493353" session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = "4060" session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = "" session.findById("wnd[0]/usr/txtRF05L-GJAHR").SetFocus session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 0 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" session.findById("wnd[1]/usr/ctxt[0]").Text = Sheets("Worksheet").Range("C:\desktop\supportings").Value session.findById("wnd[1]/usr/ctxt[1]").Text = Sheets("Worksheet").Range("1400493353").Value

End Sub

Please assist me in this as this helps me a lot in saving supporting documents for audit purpose.

Thanking you in advance!

Chandra Shekar. Y

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers