cancel
Showing results for 
Search instead for 
Did you mean: 

Sap scripting select field in table (se16 table)n

0 Kudos

Hello

This code goes to the seconde field (created on (MARA-ERSDA) in Mara , then fills out "01.01.2018".

naamloos1.jpg

session.findById("wnd[0]/usr/ctxtI2-LOW").Text = "01.01.2018"

But if this field is not present in the selection screen. Then the wrong field is entered. VField Last change (LAEDA-MARA)

naamloos2.jpg

How i can I fix this.

if the field is not present then it must be added. The field must be filled in regardless of the order of fields.

Thx

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor
0 Kudos

Hello Jeneroy,

welcome in the SAP Community.

You can loop over all elements of the screen to find the correct one via its description.

Set User = session.findById("wnd[0]/usr")
For i = 1 To User.Children.Count
  If User.Children(CInt(i)).Type = "GuiTextField" Then
    If User.Children(CInt(i)).Text = "Created On" Then
      User.Children(CInt(i + 1)).Text = "01.01.2018"
      Exit For
    End If
  End If
Next

In my case I use a selection screen which is on the UserArea. I loop over all elements and select the textfield with the name Created On and in the next element I set the date.

Let us know your results.

Cheers
Stefan

0 Kudos

Hello Stefan,

Thx for your answer, I have tested and it works 🙂

I have 2 questions:

Question 1:

How should I do it if I want to fill out the low field and the high field: example from 01.01.2018 to 31.01.2018.

Question 2:

How should I do it if I want to use multiple selection (copied from excel) :

example:

01.01.2018

03.01.2018

29.03.2018

Or how I can select the button which belongs to the field “Created on”

Thank you very much

stefan_schnell
Active Contributor

Hello Jeneroy,

to set the low and the high field you can use the following snippet. +1 fills the low and +3 the high field.

Set User = session.findById("wnd[0]/usr")
For i = 1 To User.Children.Count
  If User.Children(CInt(i)).Type = "GuiTextField" Then
    If User.Children(CInt(i)).Text = "Created On" Then
      User.Children(CInt(i + 1)).Text = "01.01.2018"
      User.Children(CInt(i + 3)).Text = "31.01.2018"
      Exit For
    End If
  End If
Next

To open the multi selection you can use the following snippet. +4 is the multi selection button.

Set User = session.findById("wnd[0]/usr")
For i = 1 To User.Children.Count
  If User.Children(CInt(i)).Type = "GuiTextField" Then
    If User.Children(CInt(i)).Text = "Created On" Then
      User.Children(CInt(i + 4)).Press
      'Your code here
      Exit For
    End If
  End If
Next

Let us know your results.

Cheers
Stefan

0 Kudos

Hello Stefan,

Yes it works

Thank you very much

stefan_schnell
Active Contributor
0 Kudos

At your service.

Answers (1)

Answers (1)

0 Kudos

Hello Stefan,

Thx for your answer, I have tested and it works 🙂