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
Similar Messages
-
SQL Query for user defined form
Hi experts,
I want query to update some fields in my user defined form using stored procedure on clicking of ADD button.
Explanation:
I have User Defined form call "DC request" with Object 'DCLM'..On click of Add button, it is saving my record info into the form. But in one field if value in not entered then it is saving as 'Null'.
Addon is already made, can not change in coding.
I want to update this field with '0' value through query in stored procedure on click of Add Button. Can anyone help me out to achieve this.
ThanksHi Team Bone.
Please try below Transaction Notification which will Restrict User to ADD if Field_Name is NULL and then User Need to Enter ZERO i.e. 0 for Adding.
IF @OBJECT_TYPE = 'DCLM' AND (@TRANSACTION_TYPE = 'A' or @TRANSACTION_TYPE = 'U')
BEGIN
If Exists (Select T0.DocEntry from [Table_Name] T0 Where ( T0.Field_Name is null OR T0.Field_Name = ' ' ) AND T0.DocEntry = @lisT_of_cols_val_Tab_del )
begin
SET @error = -100000
SET @error_message = 'Filed_Name is NULL then So, Please enter ZERO Value i.e. 0 in Filed_Name'
End
End
Please change Table_Name and Field_Name with with UDO field.
Hope this help
Regards::::
Atul Chakraborty -
Problem in retriving data in query of user defined table(Document)
hi,
am retriving data from two tables(RDR1,@DOCUMNET) by making joins
when i am giving conditions in where clause of @DOCUMENT am got the below error
BUT without any conditons in where clause all data is retriving from tables
"This entry already exists in the following tables 'Service Contracts' (OCTR) (ODBC -2035) [Message 131-183]"
example:
" select * FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry LEFT JOIN [dbo].[@DOCUMENT] T2 ON T1.DocEntry=T2.U_DocEntry AND
T1.LineNum=T2.U_LineNum
WHERE T0.[DocNum]=[%0]
AND T1.[Dscription]='[%1]'"Hello rajesh
As I see it, your problem may have something to do with the search variables the [%x] , sometimes you need to put quotes around '[%0]' if the field is alphanumeric or character based.
Please try this :
SELECT * FROM ORDR T0
INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
LEFT JOIN [dbo].[@DOCUMENT] T2 ON
T1.DocEntry=T2.U_DocEntry AND T1.LineNum=T2.U_LineNum
WHERE T0.DocNum='[%0]' AND T1.Dscription=' [%1]'
Best Regards
Amin -
UDT and UDF - User-defined Tables and Fields
Dear All,
I am writing a Query to permit the Cashier to check her Cash entries and balances on a Daily basis.
Basically, it's a General Ledger, but I want the Query - Selection Criteria window to display only a few GL codes namely GL codes 1240601, 1240602, 1240603 etc.
I don't know if I am doing it right. This is what I did (SAP B1 8.8):
UDT
I created a UDT called TEST2 using:
Tools -> Customization Tools -> User-defined Tables - Setup
UDF
Then I created a field in the UDT called GlCod using User-Defined Fields - Management
Title : GlCod
Description : GL Code
Type : Alphanumeric 30
Field Data
In the Field Data window, I ticked the Set Valid Values for Fields checkbox and filled in the blanks as follows:
# Value Description
1 1240601 Cash in Hand (Rs)
2 1240602 Cash in Hand (USD Notes)
3 1240603 Cash in Hand (Euro Notes)
etc...
Query
Then I wrote my Query (see below).
When I run it, I get the Selection Criteria screen as I wanted:
Query - Selection Criteria
GL Code ............... (arrow here)
Posting Date ...............
[OK] [Cancel]
When I click on the GL Code arrow, I get a window with the exact choices I need. It looks like this:
1240601 - Cash in Hand (Rs)
1240602 - Cash in Hand (USD Notes)
1240603 - Cash in Hand (Euro Notes)
Executing the Query
The Query seems to run normally, but nothing is generated on the screen, and there's no Error Message.
What can be wrong about this query?
I suspect that the GL codes in JDT1 and TEST2 are not of the same data type, so that INNER JOIN returns nothing.
Thanks,
Leon Lai
Here's my SQL
declare @TEST2 TABLE
(GlCod varchar(30))
declare @GlCod nvarchar (30)
set @GlCod =/*SELECT T0.U_GlCod from [dbo].[@TEST2] T0 where T0.U_GlCod=*/ '[%0]'
declare @refdt datetime
set @ref=/*SELECT T1.RefDate from [dbo].[JDT1] T1 where T1.RefDate=*/ '[%1]'
select
t1.Account as 'GL Code',
t1.RefDate as 'Posting Date',
t0.U_GlCod as 'Restricted GL Codes'
from JDT1 T1
INNER JOIN @TEST2 T0 ON T0.[U_GlCod] = T1.[Account]
WHERE
t1.RefDate <= @refdt
and
t0.U_GLCod = @GlCodTry this:
declare @GlCod nvarchar (30)
set @GlCod =/*SELECT T0.U_GlCod from [dbo].[@TEST2] T0 where T0.U_GlCod=*/ '[%0]'
declare @refdt datetime
set @refdt=/*SELECT T1.RefDate from [dbo].[JDT1] T1 where T1.RefDate=*/ '[%1]'
select
t1.Account as 'GL Code',
t1.RefDate as 'Posting Date'
from JDT1 T1
WHERE
t1.RefDate <= @refdt
and
T1.[Account] = @GlCod
(There is no need to declare the memoria table @test2 if you already created one table with this name.
And there is no need to a join.)
Edited by: István Korös on Aug 15, 2011 1:27 PM -
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 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 ? -
What the best way to create User defined table with ADDON purpose
Hi folks, how are you ?
I´m beginner in development to business one, and I m studying to develop ISV addons.
But, during my exercises and analisys, I learned that have two ways to create tables and fields in business one. One way is throght by wizard in business one using Tools Menu > Configuration Tools > User Defined Tables >
Obs: I ´m using Business One Patch Level 9.
Other way, is create the tables and fields using DI API
But, my question is. When I develop one addon, or one UDO form that uses one set of user defined tables or used defined fields that where created by the first way (by wizard in B1), how I deploy this in other business one installation ? The package process will ensure the creation of this tables in another enviroment or I must implement the creation of user defined tables using DI API so that this code is called during the installation?
If in cases of addon develop I must use DI API to create user defined tables, How can I use my classes with this responsibility in package process ?
Thanks my friends.Hi Renan,
You just need to put your logic in to the startup of your application, after you've established your connection to the UI API and DI API. All this will be triggered in the constructor of your main class.
namespace MyNamespace
public class MyAddon
bool runAddon = true;
bool initialised = false;
const string ADDON_NAME = "My Addon";
public static void Main()
MyAddon addOn = new MyAddon();
if(runAddon)
System.Windows.Forms.Application.Run();
else
Application.Exit();
public MyAddon()
// Connect to SBO session for UI
if(!SetApplication()) runAddon = false;
private bool SetApplication()
// Code goes in here to establish UI API and DI API connections
// See SDK samples for examples
// You should also define and filter the UI API events your addon will trap at this stage and create any menus
// Call your routine to check if the required UDFs/UDTs exist on this company
initialised = CheckInitialisation();
if (!initialised)
// AddOn not yet intialised on this company so prompt the user to run the intialisation process
int iResponse = app.MessageBox("The " + ADDON_NAME + " addon will now create all required fields and tables."
+ System.Environment.NewLine + System.Environment.NewLine
+ "WARNING: It is strongly recommended that all other users are logged out of this company "
+ "before running this process. Are you sure you wish to continue?", 2, "Yes", "No", "");
if (iResponse == 1) initialised = InitialiseAddOn(); // Call your routine to create the objects
return true;
Kind Regards,
Owen -
CANT execute query with parameter on user defined tables using query genera
Dear All,
I have problem when executing query with parameter on user defined tables using query generator.
It seems SBO cannot accept parameter to query user defined tables.
I've tried these:
SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = [%0] --- this FAIL
I try to pass the value directly without using parameter and It works
SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = 2 --- this SUCCESS
This one works
SELECT * FROM RDOC T0 WHERE T0.width =[%0] --- this SUCCESS
and this one works too
SELECT * FROM RDOC T0 WHERE T0.width = 595 --- this SUCCESS
Is there anyone can help me ....???
Thanks,
AlfaI generated this code using query wizard ....
SELECT T0.[U_Status] AS 'Document Status' FROM [dbo].[@ST_PR_H] T0 WHERE T0.[U_Status] = (N'2' )
and replaced the (N'2' ) with [%0]
SELECT T0.[U_Status] AS 'Document Status' FROM [dbo].[@ST_PR_H] T0 WHERE T0.[U_Status] = [%0]
and It worked ......
Thanks 4 all ..... -
Query SQL with variables Parameters and user defined tables
Hi everyone
I got a problem about Query SQL
[dbo].[@CSOURCE] is a user defined table
select * from [dbo].[@CSOURCE]
you can get the result in following
code name
T01 newspaper
T02 TV
T03 radio
T04 friends
when I execute the following SQL Statements ,I get an error
SELECT T0.CardCode , 0.CardName ,T1.Name ,T2.SONumber
FROM OCRD T0 LEFT JOIN [dbo].[@CSOURCE] T1 ON T0.U_CSOURCE = T1.Code
LEFT JOIN (SELECT T0.CardCode ,COUNT(T0.DocNum)SONumber
FROM ODLN T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
WHERE T1.GroupCode =111
AND (T0.DocDate >=[%0] or [%0]='')
AND (T0.DocDate <=[%1] or [%1]='')
GROUP BY T0.CardCode) T2 ON T0.CardCode=T2.CardCode
WHERE T0.GroupCode =111
and T0.CardType ='C
Is there anyone can correct it for me
thank you very much
Edited by: Li Mishan on Jul 17, 2008 9:36 AM
Edited by: Li Mishan on Jul 17, 2008 9:40 AMI am sorry .It is just a mistake of my typewriting.
The following is the whole SQL
dbo.@CSOURCE is a user table.It's content is
code name
T01 newspaper
T02 TV
T03 radio
T04 friends
declare @m int
declare @FromDate DateTime
declare @ToDate DateTime
set @m=(SELECT count(*) FROM ORDR T0 WHERE T0.DocDate >=[%0] and T0.DocDate <=[%1])
set @FromDate=[%0]
set @ToDate=[%1]
/*****************If I do not connect user tavble dbo.@CSOURCE ,I will succed *****************************************************/
SELECT T0.CardCode ,T0.CardName ,T2.SONumber,T1.Name
FROM OCRD T0 LEFT JOIN [dbo].[@CSOURCE] T1 ON T0.U_CSOURCE = T1.Code
LEFT JOIN (
SELECT T0.CardCode ,COUNT(T0.DocNum)SONumber FROM ODLN T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode
WHERE T1.GroupCode =111
AND (T0.DocDate >=@FromDate or @FromDate='')
AND (T0.DocDate <=@ToDate or @ToDate ='')
GROUP BY T0.CardCode
) T2 ON T0.CardCode=T2.CardCode
WHERE T0.GroupCode =111
and T0.CardType ='C'
when I excute the SQL, It return a error , whith says the column name '%0' is invalid.
If I delete "set @m=(SELECT count(*) FROM ORDR T0 WHERE T0.DocDate >=[%0] and T0.DocDate <=[%1])"
and rewrite "set @FromDate='2008.05.01' set @ToDate='2008.07.01' "
It Shows the following results
CardCode CardName SONumber name
1 000070 Deng. Jiahua 1 newspaper
2 000293 LU .Weijuan 1 radio
3 000313 Xie .Jifang 3 TV
Edited by: Li Mishan on Jul 18, 2008 4:42 AM
Edited by: Li Mishan on Jul 18, 2008 4:43 AM
Edited by: Li Mishan on Jul 18, 2008 5:43 AM -
Use SP Transaction Notification for trigger on user defined table
Hi i need some help. I have a user defined table in sap (@LAU_ACCT) .
I need way to catch the event on the table (update , delete , add).
I heard about SP Transaction Notification , but how use it with udt ?
Thanks!Hi Pavel,
it is only possible if the UDT is registered as part of an object ( UDO ) - further info http://scn.sap.com/thread/3277846 . So for pure UDT actions you have to find another way ( SQL trigger, UI API, periodic query ).
regards,
Maik -
How to Use Sequence Object Inside User-defined Function In SQL Server
I'm trying to call sequence object inside SQL Server user-defined function. I used
Next Value for dbo.mySequence to call the next value for my sequence created. But I'm getting an error like below.
"NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, or derived tables."
Is there any standard way to call sequence inside a function?
I would really appreciate your response.
Thanks!The NEXT
VALUE FOR function cannot be used for User Defined function. It's one of the limitation.
https://msdn.microsoft.com/en-us/library/ff878370.aspx
What are you trying to do? Can you give us an example and required output?
--Prashanth -
How to migrate sql server 2000 user defined function returns table
Hi,
How do I capture the SQL Server 200 user defined function that returns table? Is this supported in the current version of Oracle Migration Workbench? I am using the latest version - Release 9.2.0.1.0 with SQL SERVER 2000 plug-in.
I was able to capture the SQL Server 2000 user defined function that returns string and smalldatetime but not the functions return table during the migrate data source stage.
Thanks in Advance,
SusanSusan,
This is not currently supported. The next release of the Oracle Migration Workbench (due very soon), will do a better job of catching this mad reporting an error. We are looking into a suitable mapping and have created bug # 2355073 - TABLE DEFINITIONS NOT ACCEPTED FOR TABLE FUNCTIONS to track this issue.
Once possible solution we are looking into is using the object type to emulate. Here is an example from the bug:
Original table
SQL> create table tabela (a number, b number, c number, d number);
SQL> insert some values...
SQL> select * from tabela;
A B C D
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
SQL Server 2000 code
CREATE FUNCTION FUNCRETORNATABELA()
RETURNS TABLE
AS
RETURN SELECT A,B,C,D FROM TABELA
SELECT A,B,C,D
FROM FUNCRETORNATABELA()
ORDER BY A
Oracle code (workaround)
SQL> create or replace type MyObjType as object (
2 a number, b number, c number, d number);
3 /
Type created.
SQL> create or replace type MyTabType as table of MyObjType;
2 /
Type created.
SQL> create or replace function teste return Mytabtype pipelined as
2 aa MyObjType := MyObjType(null, null, null, null);
3 cursor c1 is select a,b,c,d from tabela;
4 begin
5 open c1;
6 loop
7 fetch c1 into aa.a, aa.b, aa.c, aa.d;
8 exit when c1%NOTFOUND;
9 pipe row (aa);
10 end loop;
11 close c1;
12 return;
13 end;
14 /
Function created.
SQL> select * from table(teste);
A B C D
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
SQL> select a, c from table(teste) order by c desc;
A C
4 4
3 3
2 2
1 1
Donal -
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 Execute User Defined Table in SQL?
Hi Experts
I have User Defined Table @SIN_MPLN in SAP B1 , i stored value in that User Defined Table and if i execute that Table Through Query Generator it shows me value. it works fine.
But when i go to SQL Server 2008 R2 and trying to execute this as..
select * from @SIN_MPLN
then it gives me Error --> Must declare the table variable "@SIN_MPLN"
so please give me the answer
ThanksHello Navanath,
Nagarajan's answer is correct.
select * from [@SIN_MPLN] wil also work. the prefix "dbo" is not mandatory.
Best Regards Teun -
Unable to run user defined table in Query Generator...
hi experts,
iam unable to run the user defined table in query generator..this is the query iam using...
Select T0.U_Date from dbo.@ENQHEAD T0 where T0.U_EnqNo='[%0]'
When i run this query it popups a window & asking EnqNo,when i select any enquiry no it's saying an error like----- Incorrect syntax near '@ENQHEAD'. iam unable to solve the above problem can anybody suggest me sme ideas....
thanking you,
shangai.Hi Shangai,
I've just tried to reproduce the issue and found the following query worked correctly for me:
SELECT T0.[Name] FROM [dbo].[@D01] T0 WHERE T0.[U_SO] = '[%0]''
The only difference I can see is the square brackets [] in my query?
Regards,
Niall
Maybe you are looking for
-
Error rollback segment while exporting a table
I am getting error while exporting a table, can someone advise me how i can handle this issue. EXP-00056: ORACLE error 1555 encountered ORA-01555: snapshot too old: rollback segment number with name "" too small ORA-22924: snapshot too old Thanks
-
Hi Everyone, I want to create a site definition that use my own master page in the homepage (VS2012 + SP2010). When the site definition is created, there are already codes in the default.aspx page that simply display a string in the body. And the pag
-
I'm new to JasperReport. I can't compile this kind of report
Hi, all I'm trying to create a report using Jasper Report. I already add the needed files into net bean classpath. And the compile task is successful. However when I run it, i meet the following message. And my app stucks there. net.sf.jasperreports.
-
Very new to MDX, and stuck trying to understand how to achieve the following; would appreciate some hints in the right direction please. Using two dimensions - Project and Department, I am trying to retrieve a count of Projects opened by each Departm
-
I need help for a mac book with no delete key
i watched some tutorials and some of the stages required the use of a deleted key (to undo a shape creation in pages, deleting a column in pages) and i was wondering how to do these tasks without a delete key.