Skip to Content

Search for values from excel in SAP table

Currently I'm creating a sap script that will automatically comment in SAP when values is found.

Basically, I have an excel file which contains list of items.

In column AK (Assignment), column V (Document Number) and column AM (Quantity), these are the columns that I need to search for in SAP Table.

Here is the excel:

SAP table:

So I want to search the table based on the column AK, V, and AM then it will double click the line item and edit the text.

As this is my first time to deal with SAP scripting I'm not sure on how to proceed.

This is my code so far:
'***********Initiate Tcode to access*****************
session.FindById("wnd[0]").Maximize
session.FindById("wnd[0]/tbar[0]/okcd").Text = "fbl3n"
session.FindById("wnd[0]").SendVKey 0

'***********End Initiate Tcode to access*****************

'*******Choose Layout***************
session.FindById("wnd[0]/usr/ctxtPA_VARI").Text = RangeLayout.Value
session.FindById("wnd[0]/usr/ctxtPA_VARI").CaretPosition = 11
'*******End Choose Layout************

'*****GL Account*******************
RngGL.Copy

session.FindById("wnd[0]/usr/btn%_SD_SAKNR_%_APP_%-VALU_PUSH").Press
session.FindById("wnd[1]/tbar[0]/btn[24]").Press
session.FindById("wnd[0]/usr/btn%_SD_SAKNR_%_APP_%-VALU_PUSH").Press
session.FindById("wnd[1]/tbar[0]/btn[8]").Press

Application.CutCopyMode = False

session.FindById("wnd[0]/usr/ctxtSD_BUKRS-LOW").Text = RangeCompanyCode.Value
session.FindById("wnd[0]/tbar[1]/btn[8]").Press

'**********End GL Account************

'table name RFPOSXEXT
'FI Doc Column 22
'assignment Column 37
'Quantity Column 39

excel.jpg (199.3 kB)
sap-table.jpg (272.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Hello Repsev,

    welcome in the SAP Community.

    In my opinion is this a very complex problem, considering your first contact with SAP GUI Scripting.

    My suggestion: You should read the whole table in an array - you can find an example here, but instead as CSV file store the content in an array. So you can locate the line by comparing the cells. Then you have the number of the line and you can trigger the event you need.

    Best regards
    Stefan

  • Get RSS Feed

0 Answers