cancel
Showing results for 
Search instead for 
Did you mean: 

Column name of a Table

Former Member
0 Kudos

Hello,

i am a biginner.

i use a Windows Visual Basic script.

the script calls a SAP Table

I have to read the Content of some cells.

But sometimes a User have an other Layout of the table and the Column is not listetd.

How can i check the Column name is available

how can i check the column Names of the Table.

session.findbyid("Wnd[0]......").columns(3).title

don't work.

Laufzeitfehler 438

Antworten gerne auch in deutsch.

Accepted Solutions (0)

Answers (1)

Answers (1)

script_man
Active Contributor
0 Kudos

Hi Emil,

If you present us a little of your code, then we could help you under certain circumstances.

Regards,

ScriptMan

Former Member
0 Kudos

OK, thank you for your interest

here the structur of the code

1. standard Logon procedure

2. Call the transaction

3. Call the table with session.findById("wnd[0]/tbar[1]/btn[8]").press

If session.ActiveWindow.Name <> "wnd[0]" Then

       GoTo errorhandler

End If

Set table = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell")

Now, i have to check the column names of the table.

How can i get these?

i found an indirect way to check with

If table.GetColumnPosition("ANUM") < 0 Then

GoTo errorhandler

end if

but it would be better to have an output of the column names.

Regards,

Emil

script_man
Active Contributor
0 Kudos

Hi Emil,

You could try the following.

for example:

i_max = Table.columncount

for i = 0 to i_max - 1
title = Table.columnorder(i)
msgbox title

next

resulting from above:

If table.columnorder(i) <> "ANUM" Then

  GoTo errorhandler

end if

Regards,

ScriptMan

Former Member
0 Kudos

Wonderful,

columncount() and coumnorder() are the commands where i am loocking for.

This was very helpful.

Thank you very much!!!

Regards,

Emil

former_member213011
Participant
0 Kudos

Dear Emil,

The id doesn't seem to be like a GuiTableControl, but GuiGridView.

If you want to get the Title of the grid as displayed in SAPgui, you can try the following in VBA:

        Dim colmax As Long

        Dim i As Long

       

        colmax = table.ColumnCount - 1

        For i = 0 To colmax

            MsgBox table.GetDisplayedColumnTitle(table.ColumnOrder(i))

        Next i

Thanks,

Sayuti

Former Member
0 Kudos

Dear Sayuti,

your code works fine too.

Now, i have also the displayd Title.

Thank you very much!!!

Regards,

Emil