SAP Automation with Excel VBA

NinoD

New Member
Joined
Oct 7, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am working on my SAP automation process. I have written most of it but I am struggling with writing code for copying dates from two different rows to Posting date : "from" and "to".

LastRow = sht.Range("D2").CurrentRegion.Rows.Count
sht.Range("D2").Copy

Session.FindById("wnd[0]").ResizeWorkingPane 68, 23, False
Session.FindById("wnd[0]/usr/btn%_SO_BUDAT_%_APP_%-VALU_PUSH").Press
Session.FindById("wnd[1]/tbar[0]/btn[24]").Press
Session.FindById("wnd[1]/tbar[0]/btn[8]").Press
Session.FindById("wnd[0]/usr/ctxtSO_BUDAT-HIGH").SetFocus
Session.FindById("wnd[0]/usr/ctxtSO_BUDAT-HIGH").CaretPosition

I used this code to copy date to "From" but unfortunately I am not able to do the same for "to".

I would appreciate if anybody knows any solution for this :)

Best Regards,
Nino
 

Attachments

  • Capture11.PNG
    Capture11.PNG
    4.5 KB · Views: 28

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi.

Not a great solution but does your version of SAP have the "record" function? That way just record yourself typing in a "To" date in the relevant box. Open the script in Notepad and all the code will appear that you recorded?

I do all of my SAP coding in the same way as I've found our company's SAP version has a lot of company specific transactions built which means the coding is rarely translatable across transactions.

VBA Code:
session.findById("wnd[0]/usr/ctxtSO_LDAT-LOW").Text = "Sheet5.Range("H1")"
session.findById("wnd[0]/tbar[1]/btn[8]").press

I just checked a macro I have and this is entering a "to" date. Not sure if that helps :-/
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,085
Members
452,378
Latest member
Hoodzy01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top