Skip to Content
0

Automate Downloading PDF file from SAP using VBA and save directly to desktop

Oct 17, 2017 at 09:38 AM

52

avatar image
Former Member

Hi Guys may i request for your kind assistance. I need your help about my script. It simply downloading the Pdf file from GSAP and a Pop up of "save as" would appeared. I want to automate the save as and send the file directly to my desktop.


* I want also to loop, if i have 3 numbers like invoice number or delivery number, what i need is in one click all these three Invoice numbers will automatically download the file and save to my desktop.

Tcode: VF01

Function ProcessRow(iRow)
Dim W_orderNum, W_CFreasons, W_DeliveryNote

objSheet.Cells(iRow, 2) = 1

If objSheet.Cells(iRow, 1) <> "" Then

W_DeliveryNote = objSheet.Cells(iRow, 1)

Else W_DeliveryNote = ""

End If

On Error GoTo myerr


objSess.findById("wnd[0]").ResizeWorkingPane 146, 26, False objSess.findById("wnd[0]/usr/cmbRV60A-FKART").Key = "ZF8" objSess.findById("wnd[0]/usr/tblSAPMV60ATCTRL_ERF_FAKT/ctxtKOMFK-VBELN[0,0]").Text = W_DeliveryNote objSess.findById("wnd[0]/usr/tblSAPMV60ATCTRL_ERF_FAKT/ctxtKOMFK-VBELN[0,0]").caretPosition = 9 objSess.findById("wnd[0]").sendVKey 0

objSess.findById("wnd[0]/mbar/menu[2]/menu[0]/menu[3]").Select objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3").GetAbsoluteRow(0).Selected = True objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/lblDV70A-STATUSICON[0,0]").SetFocus objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/lblDV70A-STATUSICON[0,0]").caretPosition = 0 objSess.findById("wnd[0]/tbar[1]/btn[18]").Press objSess.findById("wnd[1]/tbar[0]/btn[0]").Press objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/ctxtDNAST-KSCHL[1,0]").Text = "zprm" objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/ctxtDNAST-KSCHL[1,0]").caretPosition = 4 objSess.findById("wnd[0]").sendVKey 0

objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3").GetAbsoluteRow(0).Selected = True objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/lblDV70A-STATUSICON[0,0]").SetFocus objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/lblDV70A-STATUSICON[0,0]").caretPosition = 0 objSess.findById("wnd[0]/tbar[1]/btn[2]").Press objSess.findById("wnd[0]/usr/chkNAST-DELET").Selected = True objSess.findById("wnd[0]/usr/chkNAST-DIMME").Selected = True objSess.findById("wnd[0]/usr/ctxtNAST-LDEST").Text = "locl" objSess.findById("wnd[0]/usr/cmbNAST-TDARMOD").Key = "3" objSess.findById("wnd[0]/usr/cmbNAST-TDARMOD").SetFocus

objSess.findById("wnd[0]/tbar[0]/btn[3]").Press objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3").GetAbsoluteRow(0).Selected = True objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/lblDV70A-STATUSICON[0,0]").SetFocus objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/lblDV70A-STATUSICON[0,0]").caretPosition = 0 objSess.findById("wnd[0]/tbar[1]/btn[5]").Press objSess.findById("wnd[0]/usr/cmbNAST-VSZTP").Key = "4" objSess.findById("wnd[0]/tbar[0]/btn[3]").Press objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3").GetAbsoluteRow(0).Selected = True objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/lblDV70A-STATUSICON[0,0]").SetFocus objSess.findById("wnd[0]/usr/tblSAPDV70ATC_NAST3/lblDV70A-STATUSICON[0,0]").caretPosition = 0 objSess.findById("wnd[0]/tbar[0]/btn[11]").Press objSess.findById("wnd[0]/tbar[0]/okcd").Text = "/nvf01" objSess.findById("wnd[0]").sendVKey 0


Appreciate your help guys.


Thank you

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers