cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Fields in UFT

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

thanks..my problem is solved

Former Member
0 Kudos

Ok, it's nice. Can I ask you how your solved the problem ?

Thanks.

Former Member
0 Kudos

Sierdna S.

ya with the help of ur code.

thanks

Answers (2)

Answers (2)

Nussi
Active Contributor
0 Kudos

Hi,

create userdefined objects - the master_data_lines or document_data_lines

will contain your line data than.

but you can't access them with DIAPI.

lg David

Former Member
0 Kudos

hi,

use document type table and insert docentry along with them

regards,

varma