cancel
Showing results for 
Search instead for 
Did you mean: 

DI + UDO

Former Member
0 Kudos

I created two table for Purchase Requisition @OPRE and @PRE1, and I register them to an object.

Can I use DI to insert / delete / update these table? Just like doing it in system table?

Ken

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ken,

If you have register your UDO, it's not necessary to code Insert/Delete/update for it.

If you add in your form the button OK/Add (ID 1), SAP insert/update/delete automatically the data, you are no nothing to do with DI.

Regards

Michael

Former Member
0 Kudos

but I need to a batch job to load data from text file to create PR, which has 2 UDO tables... so it can use DI only.... is it possible?

Ken

Former Member
0 Kudos

What you need to do is this:

If using UI API:

Add a button to your form (not id 1 or 2)...

Or if you are using any other application...

From this button (or application) call a routine that reads your text file into a DataSet or RecordSet, then you have to go through this data making inserts for each line... something like this



Dim strQuery as String = ""
Dim intLastEntry as Integer = 0
Dim intLastLine as Integer = 0
Dim rs as RecordSet as SapBobsCOM.RecordSet

rs = CompanyObject.GetBusinessObject(SapBobsCOM.oRecordSet)

strQuery = "SELECT MAX(DocEntry) as Last FROM [@OPRE]"
rs.DoQuery(strQuery)

If rs.RecordCount > 0 Then
	intLastEntry = CInt(rs.Fields.Item("Last").Value) + 1
Else
	intLastEntry = 1
End If

For i as integer = 0 to DataSet.Table("@OPRE").Rows.Count - 1

	strQuery = " INSERT INTO @OPRE (DocEntry, Columns) " + _
	                " VALUES (" + intLastEntry.ToString() + ", " + _
                        DataSet.Table("@OPRE").Rows(i).Colums + ")"
	'//This next line Make the insert in the master table.
	rs.DoQuery(strQuery)
	intLastEntry += 1

	For j as integer = 0 to DataSet.Table("@PRE1").Rows.Count - 1
		intLastLine = j + 1
		strQuery = " INSERT INTO @OPRE (DocEntry, LineNum, Columns) "
		                 " VALUES (" + intLastEntry.ToString() + ", " + _  
                                 intLastLine.ToString() +  ", " + _ 
                                 DataSet.Table("@PRE1").Rows(j).Colums + ")"
		'//This next line Make the insert in the detail table.
		rs.DoQuery(strQuery)
	Next j

Next i

Hope it helps

GAB

Answers (0)