cancel
Showing results for 
Search instead for 
Did you mean: 

Find context and add abap code in Function module using SAP GUI Scripting

former_member544737
Discoverer
0 Kudos

Hi All,

i am trying to do Find and add code logic inside function module. i am not able to raise context menu function find and feed context into find popup.

context menu is not working on below object

session.findById("wnd[0]/usr/tabsFUNC_TAB_STRIP/tabpSOURCE/ssubSCREEN_HEADER:SAPLEDITOR_START:8430/cntlEDITOR/shellcont/shell")

Can any one suggest how can we do this ?

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_schnell
Active Contributor
0 Kudos

Hello Praveen,
you can try this to find and add a code inside SE80 with SAP GUI Scripting.

strSearch = "Your code is searched for"
strAdd    = "Your code to add"

Set ABAPEditor = session.findById("wnd[0]/usr/tabsFUNC_TAB_STRIP/tabpSOURCE/ssubSCREEN_HEADER:SAPLEDITOR_START:8430/cntlEDITOR/shellcont/shell")

For i = 1 To ABAPEditor.GetLineCount
  If InStr(ABAPEditor.GetLineText(i), strSearch) Then
    ABAPEditor.ScrollToLine i
    ABAPEditor.insertText "" & vbCrLf & "", i, Len(ABAPEditor.GetLineText(i)) + 1
    ABAPEditor.insertText strAdd, i + 1, 1
  End If
Next

In a loop I search for the code and if it was found I scroll to the line, insert a line break and add the new code in the next line.

Best regards
Stefan