Insert to User Defined Table
Guys.. How can i insert my data to my user defined table (Master Document), i have write code:
Set oUserTable = oCompany.UserTables.Item("TR_MD_FAKPAJAK")
oUserTable.Code = "1"
oUserTable.Name = "TORO"
oUserTable.UserFields("U_field1").Value = "toro"
oUserTable.UserFields("U_field2").Value = "toro"
oUserTable.UserFields("U_field3").Value = "toro"
oUserTable.UserFields("U_field4").Value = "toro"
oUserTable.UserFields("U_field5").Value = "toro"
Dim retval As Long
retval = oUserTable.Add
If retval <> 0 Then
oCompany.GetLastError lErrCode, sErrMsg
MsgBox lErrCode & " " & sErrMsg
Else
MsgBox "Masuk"
End If
my question is, when i run always display error "-4002 To Generate This Document, first defined the numbering series in Administration Module",
any idea guys ??
Thx
Hi Ria,
Unfortunately you cannot insert data in to a UDO table using the DI API (by marking your table as a 'Master Document' table you have made your UDT part of a UDO). It is one of the current limitations with working with UDOs. All data must be entered through the UI (ie manually).
If you just want to store data in a UDT then it is best to create the table as 'No object'. You can then use the DI API to read and write data to your table. However, you do lose the UDO functionality (eg no automatic saving or searching etc).
Kind Regards,
Owen
Similar Messages
-
How to insert records in user defined tables through DI Server API
Hi All,
I have created a UDO using some userdefined tables .I am able to insert records in the user defined tables using DI API but problem is that now I want to insert records in those tables using DI Server API but I dont know how to do that please give me some way to do that
Thanks and Regards
UtpalThe AddObject message is :
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<SessionID>...</SessionID>
</env:Header>
<env:Body>
<dis:AddObject xmlns:dis="http://www.sap.com/SBO/DIS">
<BOM>
<BO>
<AdmInfo>
<Object>...</Object>
</AdmInfo>
</BO>
</BOM>
</dis:AddObject>
</env:Body>
</env:Envelope>
How to use it with a user defined table ? -
Update the data in user-defined table
Dear All,
Is there anyway we can insert / update the data in user-defined table in a batch instead of update it from the interface one by one? Our customer has 1,000+ data need to be imported.
They are on SAP2007A SP00 PL45, SQL 2005, CA localization. Thanks a lot.
Regards,
yukaDear Yuka,
If it is UDT, you may use any SQL query to insert, update it. It is not under SAP support anyway.
Thanks,
Gordon -
API to Maintain User Defined Tables in Oracle Apps
Hi,
Is ther any API to INSERT/UPDATE the Values into the User Defined Tables. I found one API (+AD_DD+) which is all about registring Table/Rows/Columns to it but NOT about VALUES.
Please help me out.
Thanks !Yes, check below -
Regarding the UDT(User Defined Tables) -
Using SQL query on user defined table
Hi all,
i'am currently working on a project which use user defined table and i would like to know if sap allow us to do insertion/deletion/update on those table using sql query or if we have to use the DI only?
thanks
Best regards,Hi,
Definitely you can insert in UDT. You can update but you cant change the Code field after added the rest of the field
can be updated. You cant delete in UDT but you cant delete anytime in SQL Management Studio.
THanks.
CLint -
User-Defined Table Types - Where is it in SQL Server 2008?
I am having 2 issues:
1. I don't see a folder for 'User-Defined Table Types' under programmability-->Types
2. When I execute the following code to create a Type; I get an error 'Incorrect syntax near the keyword 'AS'.'
USE Locations;
GO
/* Create a user-defined table type */
CREATE TYPE LocationTableType AS TABLE
( LocationName VARCHAR(50)
, CostRate INT );
GOHi Shayann,
The user-defined table type is a new
feature from SQL Server 2008. If you want to use it you have to upgrade your database to SQL Server 2008 or above.
In you scenario(SQL Server 2005),as a workaround, you can use the local temporary table instead.
--in SQL Server 2005
CREATE TABLE tblType(id INT,name VARCHAR(99))
GO
CREATE PROC proc1
AS
BEGIN
SELECT * FROM #temp;
END
GO
SELECT * INTO #temp FROM tblType; -- the #temp name is fixed
INSERT INTO #temp VALUES(1,'Eric');
EXEC proc1
--In SQL Server 2008 or above
CREATE TYPE LocationTableType AS TABLE
( id INT,
name VARCHAR(99) );
GO
CREATE PROC proc1 @t LocationTableType READONLY
AS
BEGIN
SELECT * FROM @t
END
GO
DECLARE @t LocationTableType;
INSERT INTO @t VALUES(1,'Eric');
EXEC proc1 @t
I still suggest you upgrade to higher SQL Server.
If you have any question, feel free to let me know.
Best regards,
Eric -
HOW TO TRANSFER USER DEFINED TABLE DATA IN NEW DATABASE
Dear all , I am trying to transfer user defined table data,in new database ,can you please tell how i can do it
Thanks for Quick responce
I have Following databases
1) Targate Database EOU TEST
2) Source database STI_BLANK
Table @MACHINE
I tried But it has some error
INSERT INTO EOU TEST.@MACHINE
SELECT STI_BLANK.@MACHINE* FROM STI_BLANK.@MACHINE
Edited by: Abhijit Bhise on Apr 1, 2010 3:27 PM
Edited by: Abhijit Bhise on Apr 1, 2010 3:28 PM -
Hi everybody who has some spare time to read my stuff
I had a problem that some of you might have had. I have a user defined table, lets call it ProductTypes. Now system by default creates two columns in this table, one is Code (primary key) and another is Name (Index). I have added third column called Department. Now, if I wanted to add the following data (see bellow) to the table I would have had a constraint violation message pointing me out that I have problems with indexing.
Code, Name, Department
1, Cream, Fragrances
2, Cream, Beauty Products
^^
I could thing of couple workarounds of this problem
1. Is to duplicate Code into Name and storing rest of the data using user columns
Code, Name, Product Name, Department
1, 1,Cream, Fragrances
2, 2, Cream, Beauty Products
This approach isnt very convenient as it requires UI development should we decide to attach this table to the Item master data form in a form of combo box.
2. Is to amend Index on the database level. Initially, the index KProductTypes_Name consisted of only one column Name, what I have done is added another column which is Code to indexing. I dont see how this can harm database consistency or damage the core system. Please correct me if I am wrong.
Another way of amending index in order to solve my problem could be choosing ignoring duplicate values option for column Name.
Please let me know what are your thoughts.
Best wishes> Why don't you try adding a trigger 'instead of
> insert' where code = max(code)1 and name=max(name)1
> and use only user columns for your data. This
> provided you know SQL basics.
in this scenario we would have to do UI SDK development for the output and going to have an extra column with meaningless data in it. -
User Defined Table locked when multi users try to save data?
Hi All,
I am having a problem with User Define Table (UDT). I am just checking if somebody having the same problem as mine (any patch level).
I've developed an add-on to save additional data to some UDTs upon saving a Production Order. I added my code in FormDataEvent (After Action = True and ActionSuccess = True).
Here are my sequences to save the data:
1. Start Transaction
2. Remove Existing Data from 3 UDTs linked to the production order number.
3. Save to table 1, using UserTable object
4. Call function A to save to table2 , using UserTable object
5. Call function B to save to table 3, using UserTable object
6. Commit Transaction.
Note: I have a try catch and rollback the transaction if any exception thrown by .NET and SAP. Below are parts of my coding to handle exception from SAP
If oUserTable.Add() <> 0 Then
oCompany.GetLastError(ErrCode, ErrMsg)
Throw New ApplicationException(ErrCode & "-" & ErrMsg)
End If
in the try catch block, i add the following code
If oCompany.InTransaction Then
oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
SBO_Application.MessageBox("[SaveRoute]:" & ex.Message)
Return False
End If
Now, the issue is in some occasions, when multi users try to save the Production Order, the data get deleted from the UDTs, but some of the data did not get saved yet it did not throw an exception. From our observation, it only happens when multi users are trying to save to the same table.
Does anybody having the same or similar issue? Really appreciate if you can share on this.
Many Thanks,
Harianto NgI Believe you should look carefully where in your code writting, you should start transaction and be sure of using end.transaction commit if the insert sends a succesfull message, and rollback it for negative message.
I used to start transacción right before .add method
Wha DBMS are u using?
Hope it helps. -
Dealing with User Defined Tables with the DI Server
I have a general question about the best way of working with the data in user defined tables using the DI Server. It appears from previous posts that it is not possible to use the standard methods such as UpdateObject. Also since update/insert and delete statements or explicitly forbidden using the ExecuteSQL method then how do we interact with the data in the tables?
Do we need to code our own data access layer for this type of access and is this a good practice?
Is this type of functionality going to be available in a future release of the DI Server?
ThanksUsing SQL for Update/Insert/Delete is not forbidden on UDTs (at least non-UDO UDTs; UDO UDTs are somehow in a gray area since they carry internal fields + e.g. inserts require further manipulation in B1 tables...)...
I.e. using ExecuteSQL to add data into UDTs is OK for DI Server...
HTH,
Frank -
how make new table as i need in sap b1 and also tell me how to insert update data in that table
thanks and regards
ParagIf you need to add table using a program, you have to use the UserTableMD object. Once table is created you can add fields using UserFieldsMD object.
Help is available with SDK help center.
Once table is created, you can add data using RecordSet objects, UserTables Objects etc.
You can also create table and fields using SBO (Tools->Customization Tools->User-Defined Tables - Setup...) and
(Tools->Customization Tools->User-Defined Fields - Management...) etc.
Anoop -
How to read and write data to a user defined table?
I have created a srf with 2 edit box and a ok buttin, I want to insert data to the user defined table i created using sql query while i press OK button..
Please provide the complete code to insert and select da from the user defined table.Hi,
You can use the code below.
Dim ret As Long
d
Private Sub Add_Table_Click()
Dim oUserTablesMD As SAPbobsCOM.UserTablesMD
Set oUserTablesMD = oCompany.GetBusinessObject(oUserTables)
' When adding user tables or fields, use a prefix
' identifying your partner name space. This will
' prevent collisions from different partner add-ons
' SAP's name space prefix is "BE_"
'Set the two mandatory fields
oUserTablesMD.TableName = "T1"
oUserTablesMD.TableDescription = "Table1"
'Add the table (which contains 2 default, mandatory fields, 'Code' and 'Name')
ret = oUserTablesMD.Add
If ret <> 0 Then
oCompany.GetLastError ret, Str
MsgBox Str
Else
MsgBox "Table: " & oUserTablesMD.TableName & " was added successfully"
End If
End Sub
Private Sub Add_UDF_Click()
Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
Set oUserFieldsMD = oCompany.GetBusinessObject(oUserFields)
oUserFieldsMD.TableName = "T1"
oUserFieldsMD.Name = "AlbUDF"
oUserFieldsMD.Description = "Albert UDF"
'Add the field to the table
lRetCode = oUserFieldsMD.Add
If lRetCode <> 0 Then
oCompany.GetLastError ret, Str
MsgBox Str
Else
MsgBox "Field: '" & oUserFieldsMD.Name & "' was added successfuly to " & oUserFieldsMD.TableName & " Table"
End If
End Sub
Private Sub Add_Data_Click()
Dim oUserTable As SAPbobsCOM.UserTable
Set oUserTable = oCompany.UserTables.Item(1)
oUserTable.GetByKey ("T1")
'Set default, mandatory fields
oUserTable.Code = "A"
oUserTable.Name = "Albert"
'Set user field
oUserTable.UserFields.Fields.Item("U_AlbUDF").Value = "1"
oUserTable.Add
If ret <> 0 Then
oCompany.GetLastError ret, Str
MsgBox Str
Else
MsgBox "Value to field: '" & oUserTable.UserFields.Fields.Item("U_AlbUDF").Name & "' was updated successfuly to " & oUserTable.TableName & " Table"
End If
End Sub
Regards,
Noor -
How to pop-up a text box for a grid item on a user defined table?
Hello,
I have a user defined table with a grid & one of the columns is for comments. What I'm trying to do is to pop up a text box when double clicking in the column field. This would be the same as the Item Details column in the Sales Order ittems grid.
Thanks,
RonPlease post your question on SDK forum. Only SDK could meet your need.
Thanks,
Gordon -
Print Layout to User Defined Table
Hello guyz..
I want a make preprinted for my user query from user defined table where the header information is from another query.
I guess, the base template User Report (system) can only show the repetitve data from one query but the header area is not,
could you help, showing the header information from another query ??
Thanks RegardsRia
The word is that you cannot use the PLD with user defined tables (i wish it was possible). So in any case to do that you have to use third party tools such as Crystal Reports and Reporting Services -
How to create a Foreign key relationship between 2 user defined tables...
Hi Folks,
I have created two user defined tables... Where in i want to create foriegn key relationship between the 2 tables.... Can anyone guide the step by step procedure to do this scenario...
Any help would be highly appreciated...
ThanksHi
1. In the 2nd table call the field of the 1st table which is a primary key.
2. Give the same field and dataelement name.
3. Select that field and then click on the foreign key field icon which is beside Search Help button.
4. Then give short text, and the 1st table name.
5. Then in the below box give the 2nd table name and 2nd table field name which you have called from 1st table.
6. Then click on copy, then u will be able to see Check table name and check table field name beside foreign key table name.
7. Then again click on copy.
Regards
Haritha.
Maybe you are looking for
-
I did some commands in CMD now firefox wont work at all!
So my problem was I couldn't ping IP addresses. So I looked up a tutorial I followed this EXACT thing and now I can't connect firefox everything says its connecting but it never loads no error message nothing. Here is exactly what I did that now gave
-
Running a VM from an exFAT drive
I use a windows 7-x64 box at work, on which i hv my linux VM running on VMware player 3. How can I use the same VM on a mac. Right now I'm running it on an NTFS external HDD which is perfect for windows. However, I need to use it on my mac (Snow Leop
-
How do you unlock your i pod touch?
my i pod died and i charged it and then when i trurned it back on there was a lock on it and i dont know the password!!!!! how do i unlock it??
-
Hi All.... Required help for one more query. I have a table with data like this: Cust_id Transaction_no 111 1 111 2 111 3 111 4 111 5 111 6 222 7 222 8 333 9 333 10 333 11 333 12 I wrote the following query : select cust_id, ntile(3) over (order by c
-
Images are not reflecting in Multi Level Menu
Hi, i am facing some problem in the Multi Level Menu. i have created a book in my portal application. For the "Main Page Book" i am setting "Multi Level Menu" For the Book with in the menu, i am setting "No Navigation"(to avoid the sub pages displayi