Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Changing Fields in UFT

HI All

I created a UFT with no object Type. I want to insert muliple rows in tables with one code ,But bydefault fields (Code and Name) are act as Primary Key, so with these fields i am unable to insert data in UFT.

Is There any Idea to change the type of these Fields or any Other Solution.

Thaks In Advance

Former Member
Former Member replied

Hi

If your table is NO_OBJECT table when use this method:

- for Code column you can use function what read MAX(Code) and return the value MAX(Code + 1).

- set Name=Code.

Regards

Sierdna S.

Note: it may be "00000001", "00000002", "000000AA", "000000AB", "0000AAAZ",...

so you need some function what make convertion...

Public Function getStrNextCode(ByVal sTableName As String) As String
  Dim oRecordset As SAPbobsCOM.Recordset
  oRecordset = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
  Dim sRetValue As Long = -1
  Dim code As String
  Try
      oRecordset.DoQuery("SELECT COALESCE(MAX(code), '00000000') AS code FROM " & _
                          sTableName & " WHERE LEN(Code) = 8 ")
      If oRecordset.RecordCount > 0 Then
	  oRecordset.MoveFirst()
	  code = oRecordset.Fields.Item(0).Value
	  If code = "" Then code = "0"
	  sRetValue = code
      End If
  Catch ex As Exception
      sRetValue = -1
  Finally
      oRecordset = Nothing
  End Try
  Return (sRetValue + 1).PadLeft(8, "0")
End Function

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question