cancel
Showing results for 
Search instead for 
Did you mean: 

Type mismatch oddity

Former Member
0 Kudos

Hello everyone

I am trying to write a program with VBScript for transaction ZST1. I want to combine duplicate materials and calculate total quantity of each material, and finally remove extraneous rows. My script works fine until I try to process something like 300 or more rows, and I get 'Type mismatch: CInt' error. Script first sorts the rows by material in descending order, then get fed to this loop:

index = 0
mlast = table.getCellValue(0, "MATERIAL")
total = 0

For row = 0 To table.rowCount - 1
     mnext = table.getCellValue(row, "MATERIAL")
     qnext = CInt(table.getCellValue(row, "QUANTITY"))

     If mlast = mnext Then
          total = total + qnext
     Else
          Call table.ModifyCell(index, "MATERIAL", mlast)
          Call table.ModifyCell(index, "QUANTITY", CStr(total))
          index = index + 1
          mlast = mnext
          total = qnext
     End If

     If mlast = "" Then
          table.DeleteRows(CStr(index) + "-" + CStr(table.rowCount - 1))
          Exit For
     End If
Next

There's only one instance of CInt there so it's easy to see where it fails, but I can't figure out why! Quantity column contains only numeric values, and I'm certain that the problem cannot be integer overflow. It seems that only when there's enough rows to deal with, the script just fails.

Could anyone help me to debug this thing?

Accepted Solutions (1)

Accepted Solutions (1)

holger_khn
Contributor
0 Kudos

Hello.

May you should add your code in Excel VBA.

When it got failed you can check which value cause it.

Former Member
0 Kudos

Hi

Thank you for response. I got script working by adding

table.CurrentCellRow = row

inside loop.

I think server dont send all data if there is lot of it. This forces it to do so because data needs to be shown. That is my guess only, though.

This is actually my first VBScript. Kind of fun learning it

holger_khn
Contributor
0 Kudos

Yes, if you have a list which contain a lot of rows it´s not loaded into Memory from SAP GUI. It´s the same when you want to copy a list with many rows into clipboard. You Need to scroll list until end. Then you can mark and copy as all rows got loaded into SAP GUI Memory.

Former Member
0 Kudos

So the rows are in fact cached to disk. That does make sense. But is scrolling really the only way to get all rows? It seems kind of a dirty hack to me.

Answers (0)