How to insert sales order data to user-defined table - sapb1

How to insert Sales order data like docEntry, object type to user-defined table using data event (using C#) or any other way in SAP B1.
Thanks in Advance

check this code:
UserTable oUserTable = null;
oUserTable = conexionSAP.oCompany.UserTables.Item("TABLE_NAME");
oUserTable.Code = "2";
oUserTable.Name = "SUPER_SACO";
oUserTable.UserFields.Fields.Item("USER_FIELD1").Value = "9746";
oUserTable.UserFields.Fields.Item("USER_FIELD2").Value = "1084.00";
oUserTable.Add()
see you.

Related

QLIKVIEW 11: Formula works on Text Object but not in LOAD SCRIPT

I have the following formula in a Text Object:
=Num(Sum(Aggr(Count({<Jahr={$(vTodayYear)}, Kw={">=1<=$(vTodayKw)"}, Database.Kennzahl={'Ew'}, Database.Szenario={'Actual'}>} DISTINCT Database.MitarbeiterID), Kw) / vTodayKw) , '###.##0')
This works and it gives me the desired Value. But when I want to SET it to LOAD SCRIPT like this:
SET vMyVar = =Num(Sum(Aggr(Count({<Jahr={$(vTodayYear)}, Kw={">=1<=$(vTodayKw)"}, Database.Kennzahl={'Ew'}, Database.Szenario={'Actual'}>} DISTINCT Database.MitarbeiterID), Kw) / vTodayKw) , '###.##0');
This doesn't work and theres no ErrorMessage :(
Thanks for any help!
there is no support for Set Analysis in a LOAD statement.
You have to rewrite your statement to use it in the LOAD statement.
Something like this (depending all fields are in a table named 'Database'):
tmp_Mitarbeiter_tbl:
LOAD Count (Distinct Database.MitarbeiterID) as tmp_Mitarbeiter_count
Resident Database
Where Jahr = $(vTodayYear)
and Kw >= 1 and Kw <= $(vTodayKw)
and Database.Kennzahl = 'Ew'
and Database.Szenario = 'Actual';
LET vMyVar = Peek('tmp_Mitarbeiter_count');
DROP Table tmp_Mitarbeiter_tbl;
Best regards,
Tom

How to Update some data in a table from another table in MS Access 2007 by checking a value from the second one?

i want to update some data from a table (ehraz) in MS_Access 2007 by another table's data by checking this condition : if tableA.siba=Table2.siba then update Table1.field1 by Table2.Field2.
i use this t-sql command in sql server and works :
update ehraz set
ehraz.B_CODEMELI =bn.B_CodeMelli ,
ehraz.B_NAME =ltrim(rtrim(cast(bn.B_Name as nvarchar(20)))) ,
ehraz.B_FAMILY =ltrim(rtrim(cast (bn.B_Family as nvarchar(30)))) ,
ehraz.B_FATHER_N = ltrim(rtrim(cast(bn.B_Father_N as nvarchar(20)))),
ehraz.B_SHENAS =ltrim(rtrim(bn.B_Shenas)) ,
ehraz.B_TAVALOD = ltrim(rtrim(cast(bn.B_Tavalod as nvarchar(15)))),
ehraz.B_MOSHTARI = ltrim(rtrim(cast(bn.B_Moshtari as nvarchar(20)))) ,
ehraz.B_BARNO = ltrim(rtrim(cast(bn.B_Brno as nvarchar(10)))) ,
ehraz.CLOS = ltrim(rtrim(cast(bn.CLOS as nvarchar(5))))
from bn_data bn
where ehraz.siba = bn.Siba
how can i do this in MS-Access 2007? this query did't works in ms access.
Does this work for you?
update ehraz
inner join bn_data bn
on ehraz.siba = bn.Siba
set
ehraz.B_CODEMELI = bn.B_CodeMelli,
ehraz.B_NAME = Trim(CStr(bn.B_Name)),
ehraz.B_FAMILY = Trim(CStr(bn.B_Family)),
ehraz.B_FATHER_N = Trim(CStr(bn.B_Father_N)),
ehraz.B_SHENAS = Trim(CStr(bn.B_Shenas)),
ehraz.B_TAVALOD = Trim(CStr(bn.B_Tavalod)),
ehraz.B_MOSHTARI = Trim(CStr(bn.B_Moshtari)),
ehraz.B_BARNO = Trim(CStr(bn.B_Brno)),
ehraz.CLOS = Trim(CStr(bn.CLOS));
this query will not work in MS-Access because some of the keywords that are used in the query are not supported by MS-Access like the cast function is not supported in MS-Access. Instead Use CStr function for type conversion into text Format and CInt function to type conversion in Number format....
try replacing these keywords and let me know if this helps.

NHibernate native SQL in WHERE clause

I have a Geography column in a table in SQL Server and would like to filter rows with a specific geometry type, e.g. all records where geometry type is 'Point'
The SQL query would look like
select * from GeometryTable g where g.Geography.STGeometryType() = 'Point'
How can I create a criteria for that? The criteria is going to be used with other criterias
criteria.Add(Restrictions.Add(<Geography.STGeometryType()>, some.Value)
Thanks
Use this syntax:
var criteria = session.CreateCriteria<Geometry>();
criteria.Add
(
Expression.Sql(" {alias}.[Geography].STGeometryType() = ? "
, "Point" // a place for your parameter
, NHibernate.NHibernateUtil.String)
);
var list = criteria.List<Geometry>();

Oracle customized merge

We have two tables one is source and another one is target. The source table gets updated/refresh with external data source and we have a PL/SQL block which runs daily and updates/inserts the target table rows using Oracle's merge function.
Now we have a situation where a column (email) in the target table could get updated by some external source. Consequently, this email is being updated/overwritten by email of source table with the above mentioned PL/SQL's merge function.
Is there something in the merge function so that it only updates the rows in the target table if things other than the email have been changed. I am happy to add new column(s) into the source and target table if needed.
create or replace
PROCEDURE INSERT_UPDATE_TARGET AS
BEGIN
merge into INTEGRATION_TARGET t
using v_merge vm
on (t.person_num = vm.person_num)
when matched then update set T.YEAR_START = VM.YEAR_START,
T.SEMESTER_START = VM.SEMESTER_START,
T.SATAC_DATABASE_NAME = VM.SATAC_DATABASE_NAME,
T.STUDY_LEVEL = VM.STUDY_LEVEL,
T.REF_NUM = VM.REF_NUM,
T.SEX = VM.SEX,
T.DATE_OF_BIRTH = VM.DATE_OF_BIRTH,
T.DATE_RECEIVED = VM.DATE_RECEIVED,
T.TITLE = VM.TITLE,
T.FAMILY_NAME = VM.FAMILY_NAME,
T.GIVEN_NAME_1 = VM.GIVEN_NAME_1,
T.STREET_NAME = VM.STREET_NAME,
T.STREET_NAME_2 = VM.STREET_NAME_2,
T.STREET_NAME_3 = VM.STREET_NAME_3,
T.POSTAL_STATE = VM.POSTAL_STATE,
T.POSTAL_TOWN = VM.POSTAL_TOWN,
T.POSTAL_POSTCODE = VM.POSTAL_POSTCODE,
T.COUNTRY = VM.COUNTRY,
T.MOBILE = VM.MOBILE,
T.EMAIL = VM.EMAIL
when not matched then insert (T.YEAR_START,
T.SEMESTER_START,
T.SATAC_DATABASE_NAME,
T.STUDY_LEVEL,
T.REF_NUM,
T.PERSON_NUM,
T.SEX,
T.DATE_OF_BIRTH,
T.DATE_RECEIVED,
T.TITLE,
T.FAMILY_NAME,
T.GIVEN_NAME_1,
T.STREET_NAME,
T.STREET_NAME_2,
T.STREET_NAME_3,
T.POSTAL_STATE,
T.POSTAL_TOWN,
T.POSTAL_POSTCODE,
T.COUNTRY,
T.MOBILE,
T.EMAIL
)
values(VM.YEAR_START,
VM.SEMESTER_START,
VM.SATAC_DATABASE_NAME,
VM.STUDY_LEVEL,
VM.REF_NUM,
VM.PERSON_NUM,
VM.SEX,
VM.DATE_OF_BIRTH,
VM.DATE_RECEIVED,
VM.TITLE,
VM.FAMILY_NAME,
VM.GIVEN_NAME_1,
VM.STREET_NAME,
VM.STREET_NAME_2,
VM.STREET_NAME_3,
VM.POSTAL_STATE,
VM.POSTAL_TOWN,
VM.POSTAL_POSTCODE,
VM.COUNTRY,
VM.MOBILE,
VM.EMAIL
);
END;
Thanks
Add a where clause to your update statement

MySQL IN Operator

http://pastebin.ca/1946913
When i write "IN(1,2,4,5,6,7,8,9,10)" inside of the procedure, i get correct result but when i add the id variable in the "IN", the results are incorrect. I made a function on mysql but its still not working, what can i do?
Strings (broadly, variable values) don't interpolate in statements. vKatID IN (id) checks whether vKatID is equal to any of the values listed, which is only one: the value of id. You can create dynamic queries using PREPARE and EXECUTE to interpolate values:
set #query = CONCAT('SELECT COUNT(*) AS toplam
FROM videolar
WHERE vTarih = CURDATE() AND vKatID IN (', id, ') AND vDurum = 1;')
PREPARE bugun FROM #query;
EXECUTE bugun;
You could use FIND_IN_SET( ) rather than IN, for example:
SELECT COUNT(*) AS toplam
FROM videolar
WHERE vTarih = CURDATE()
AND FIND_IN_SET( vKatID, id ) > 0
AND vDurum = 1
Sets have limitations - they can't have more than 64 members for example.
Your id variables is a string (varchar) not an array (tuple in SQL) ie you are doing the this in (in java)
String id = "1,2,3,4,5,6,7"
you want
int[] ids = {1,2,3,4,5,6,7}
So in your code
set id = (1,2,3,4,5,6,7,8,9,10)
I cannot help you with the syntax for declaring id as I don't know. I would suggest to ensure the code is easily updated create a Table with just ids and then change your stored procedure to say
SELECT COUNT(*) AS toplam
FROM videolar
WHERE vTarih = CURDATE() AND vKatID IN (SELECT DISTINCT id FROM idtable) AND vDurum = 1;
Hope this helps.