cancel
Showing results for 
Search instead for 
Did you mean: 

Loop trough all columns in grid (Transaction VA22)

Former Member
0 Kudos

Hi,

how can i loop trough all columns in the grid in transaction va22 ???

Set GRID1 = .findbyid("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4411/subSUBSCREEN_TC:SAPMV45A:4912/tblSAPMV45ATCTRL_U_ERF_ANGEBOT")

lRow = 0

Do

   GRID1.findbyid("txtVBAP-POSNR[0," & lRow & "]").Text = Nz(rs("Position"), "")

   lRow = lRow +1

    rs.MoveNext

Loop While rs.EOF = False

What happens when i change the columns???

Thx, Mike

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

i get it 🙂

Sub Loop_trough_SAP_Grid()

   Dim GRID

   Dim i       As Integer

   Dim iPOS    As Integer

   Dim iÜPOS   As Integer

   Dim iMAT    As Integer

   Dim iMENG   As Integer

   Dim iARTBEZ As Integer

   Dim iWERK   As Integer

  

   If fnSAP_Connection = False Then

     

   Else

      With Session

         ' Grid initializeinitialisieren

         Set GRID = .findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4411/subSUBSCREEN_TC:SAPMV45A:4912/tblSAPMV45ATCTRL_U_ERF_ANGEBOT")

              

'        ****************** Methods ****************

'         Debug.Print GRID.Columns.Count

'         Debug.Print GRID.Rows.Count

'         Debug.Print GRID.Columns(14).Title

'         Debug.Print GRID.getCell(0, 14).Text

'         GRID.getCell(1, 14).Text = "77777"

'        *******************************************

              

         ' Alle Spaltenüberschriften ausgeben

         For i = 0 To GRID.Columns.Count - 1

            Select Case GRID.Columns(i).Title

               Case "Pos"

                  iPOS = i

               Case "Übergeordn. Position"

                  iÜPOS = i

               Case "Material"

                  iMAT = i

               Case "Auftragsmenge"

                  iMENG = i

               Case "Bezeichnung"

                  iARTBEZ = i

               Case "Werk"

                  iWERK = i

            End Select

         Next

        

         Debug.Print GRID.Columns(iPOS).Title

         Debug.Print GRID.Columns(iÜPOS).Title

         Debug.Print GRID.Columns(iMAT).Title

         Debug.Print GRID.Columns(iMENG).Title

         Debug.Print GRID.Columns(iARTBEZ).Title

         Debug.Print GRID.Columns(iWERK).Title

      End With

   End If

  

   Set GRID = Nothing

   Set SapGuiAuto = Nothing

   Set SAP = Nothing

   Set Connection = Nothing

   Set Session = Nothing

End Sub

Thx, Mike

Answers (0)