Fill selection criteria in an SAP report automatically

ohcan8

New Member
Joined
Jul 20, 2007
Messages
11
Hi guys,

I am trying to get a code for downloading SAP reports automatically but I do not know how to fill the selection criteria once the macro "jumps" into SAP, see the code below:

Sub Macro1()

Dim ONE As DataObject

Range("A1").Select
ActiveCell.Formula = ("EU249001") 'This would be a WBSE, but it is just an example

ONE = ActiveCell

AppActivate ("SAP Easy Access")

Application.Wait ((Now + TimeValue("0:00:0" & 1)))

SendKeys "/nZK32{enter}", True 'The T-Code in which I would like to select the WBSE


'The only thing I need to know how to select the field in SAP,
'and also, how to copy and paste into each field
'I am also aware about "timing" problems between Excel and SAP, I will sort that out

End Sub


Help please!!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
ohcan8,

I have used the following API calls:
Private Declare Function SetCursorPos Lib "user32" _
(ByVal X As Long, ByVal Y As Long) As Long

Private Declare Sub mouse_event Lib "user32" _
(ByVal dwFlags As Long, ByVal dx As Long, _
ByVal dy As Long, ByVal cButtons As Long, _
ByVal dwExtraInfo As Long)

Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)

Along with two constants:
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4

You will have to plot the X Y coordinates of the fields in SAP.

And then you could, simulate the mouse down and up, and have the data entered in the correct field:

Code:
            ' "Order Number:" Column "B"
            ' txtOrderNumberText
            ' Windows 2000  X = 206, Y = 646
            ' Windows XP    X = 184, 658
            ' ServiceCenter Release: 5.0.2.1.0002   X = 645, 504
            X = 645
            Y = 504
            Call SetCursorPos(X, Y)
            mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
            mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
            SendKeys "{end}", True
            SendKeys txtOrderNumberText, True

Hope this helps you in the rigth direction.

Have a great day,
Stan
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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