Adding current_timestamp
Hi,
I am currently trying to add a timestamp+(variable) to my mssql database via a JSP. I can add the simple time stamp by doing the following:
PreparedStatement ps = connection.prepareStatement("INSERT INTO table1 VALUES (?,?,?, CURRENT_TIMESTAMP+5)");
...which adds 5 days to the current date. However if i wanted to replace '5' with a variable how do i go about doing this. i have tried for example:
String extraDays = 5; (just for example)
PreparedStatement ps = connection.prepareStatement("INSERT INTO table1 VALUES (?,?,?, CURRENT_TIMESTAMP+extraDays)");
also tried by replacing with:
CURRENT_TIMESTAMP+"extraDays"
CURRENT_TIMESTAMP+'extraDays'
but none of them seem to work.
Any help would be gladly appreciated.
Message was edited by:
haggard17
PreparedStatement ps = connection.prepareStatement("INSERT INTO table1 VALUES (?,?,?, CURRENT_TIMESTAMP+"+extraDays+")");
Similar Messages
-
Adding Current_Timestamp to HANA table
Hi,
We have tables that are replicated from SAP using SLT.
We are trying to add a column to that table, so we can capture insert/update datetime every time a record is inserted or updated in the table.
We have two options currently:
1. We can add the physically add the column to the table and use the transformation from SLT server to update/insert the date with current_timestamp.
2. Adding trigger to the tables - We were told by SAP that this was not a good practice for replicated tables.
Instead of configuring in SLT server, we are trying to see if we can do this using virtual column like "Alter Table xxx Generate Always As
current_timestamp).
Apparently we cannot use Current_Timestamp in Generated As columns.
My question is does anyone know any work around where we can assign current_timestamp to virtual columns?
Or is there any way I can accomplish this other than using virtual columns?
I cannot use default in a column as it needs to update for both insert and update.
Thank you for your help.
HyunGuys,
what is the use case here?
Why is it even relevant to know the server time when a record had been inserted by SLT?
Be very clear about that this is not an application level timestamp.
It doesn't tell you when the record was changed in the application nor when it was valid for the application.
So, what is behind the mysterious scenario to have a column that is automagically filled with the DB server timestamp of when a record is gets inserted/updated in a table?
- Lars -
Query to get the last added record in a table for a particular id
T
Hi,
I have 2 tables A, B
Table A has id,name
Table B had parentid(foreignkey referring to ID in above table), record_type,created_timestamp
I want to get the last added record_type from Table B for all the ids present in Table A.Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. I know this is
a skeleton, but could you at least try to do good programming? Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. And sample data also helps.
I have 2 tables: Alphas, Betas
CREATE TABLE Alphas
(alpha_id CHAR(10) NOT NULL PRIMARY KEY,
alpha_name VARCHAR(25) NOT NULL);
Why was that DDL so hard you could not write it? But your narrative about the second table does not tell us if it has a key. I will guess that it is also alpha_id, but thanks to your rudeness, that is all we can do.
CREATE TABLE Beta
(alpha_id CHAR(10) NOT NULL PRIMARY KEY
REFERENCES Alphas (alpha_id),
record_type CHAR(2) NOT NULL,
creation_timestamp DATETIME2(0) DEFAULT CURRENT_TIMESTAMP
NOT NULL,
>> I want to get the last added record_type from Table Beta for all the ids present in Table A.<<
Think about this. Since Beta.alpha_id is a FOREIGN KEY to Alphas, all of its rows will have a match to Alpha. The SQL engine does this for you!
SELECT *
FROM (SELECT alpha_id, record_type, creation_date,
MAX(creation_date) OVER () AS creation_date_max
FROM Betas)
WHERE creation_date = creation_date_max;
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Inconsistent results with localtimestamp and current_timestamp
Running XE on Windows XP with the system timezone to GMT rebooted, restarted XE)
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
I'm getting incorrect and inconsistent results with current_timestamp and localtimestamp:
With SQL, localtimestamp computes the wrong offset (appears to use 1987-2006 DST rules):
select
dbtimezone
, sessiontimezone
, current_timestamp
, current_timestamp + numtodsinterval(18,'day') as current_timestamp18
, localtimestamp
from dual;
+00:00
US/Eastern
17-MAR-10 10.27.17.376000000 AM US/EASTERN
04-APR-10 10.27.17.376000000 AM US/EASTERN
17-MAR-10 09.27.17.376000000 AM
however, in PL/SQL, both current_timestamp and localtimestamp return the wrong hour value, and adding 18 to current_timestamp shows it is using 1987-2006 DST rules (1st sunday of april)/ note that this happens in straight PL/SQL and in embedded SQL (same results selecting from tables other than DUAL):
begin
for r1 in (
select
dbtimezone
, sessiontimezone
, current_timestamp
, current_timestamp + numtodsinterval(18,'day') as current_timestamp18
, localtimestamp
from dual
loop
dbms_output.put_line('SQL dbtimezone = ' || r1.dbtimezone);
dbms_output.put_line('SQL sessiontimezone = ' || r1.sessiontimezone);
dbms_output.put_line('SQL current_timestamp = ' || r1.current_timestamp);
dbms_output.put_line('SQL current_timestamp +18 = ' || r1.current_timestamp18);
dbms_output.put_line('SQL localtimestamp = ' || r1.localtimestamp);
end loop;
dbms_output.put_line('dbtimezone = ' || dbtimezone);
dbms_output.put_line('sessiontimezone = ' || sessiontimezone);
dbms_output.put_line('systimestamp = ' || systimestamp);
dbms_output.put_line('current_timestamp = ' || current_timestamp);
dbms_output.put_line('current_timestamp +18 = ' || (current_timestamp + numtodsinterval(18,'day')));
dbms_output.put_line('localtimestamp = ' || localtimestamp);
end;
SQL dbtimezone = +00:00
SQL sessiontimezone = US/Eastern
SQL current_timestamp = 17-MAR-10 09.29.32.784000 AM US/EASTERN
SQL current_timestamp +18 = 04-APR-10 10.29.32.784000000 AM US/EASTERN
SQL localtimestamp = 17-MAR-10 09.29.32.784000 AM
dbtimezone = +00:00
sessiontimezone = US/Eastern
systimestamp = 17-MAR-10 02.29.32.784000000 PM +00:00
current_timestamp = 17-MAR-10 09.29.32.784000000 AM US/EASTERN
current_timestamp +18 = 04-APR-10 10.29.32.784000000 AM US/EASTERN
localtimestamp = 17-MAR-10 09.29.32.784000000 AM
dbtimezone = +00:00
sessiontimezone = US/Eastern
systimestamp = 17-MAR-10 02.16.21.366000000 PM +00:00
current_timestamp = 17-MAR-10 09.16.21.366000000 AM US/EASTERN
current_timestamp +18 = 04-APR-10 10.16.21.366000000 AM US/EASTERN
localtimestamp = 17-MAR-10 09.16.21.366000000 AM
is this a known bug?
is there a patch or a work-around for XE?
are other datasbase versions affected?Can't patch XE, unfortunately it comes with pre-2007 DST rules.
There is a metalink note describing how to fix the DST changes, and while it's not really a "supported" method, neither is XE- if you can get updated timezone files from a later patch set for the same release, 10gR2, on the right operating system, shutdown/startup the database the updated DST rules will be in place. The timezone files are in $ORACLE_HOME/oracore/zoneinfo.
Another unfortunately, any values already stored in the database using timestamp with local timezone datatypes for the affected period of the DST changes won't be correct, i.e. there is no 2010-03-14 02:01 (?) but with older timezone rules in place that would be a valid timestamp. The data has to be saved before updating the timezone file, and re-translated to timestamp w/local tz datatypes after the update.
IMHO storing literal timezone info isn't an ideal practice, let the client settings do the time interpretation, time is always changing. Its the interpretation of the time that gets changed. From time to time. :( -
Hi
Is it possible to get alert when user adds document? I was been told that it is possible by query.
Pls guide me on this
Regards
Shashihi guys You Con Try this method for instant alert
Alert For Document Add (Eg : SO)
Create two user fields in to the table ORDR (SO)
Eg:Hour and Minutes
Add this Transaction Notification in You are data base
---Transaction Notification For alert
IF (@object_type=N'17') AND (@transaction_type = N'A' or @transaction_type = N'U')
Begin
update ORDR set
U_Hour=(select case when ((select convert(int ,substring(convert(varchar,CURRENT_TIMESTAMP),16,2)))='59'
and (select convert(int ,substring(convert(varchar,CURRENT_TIMESTAMP),13,2)))='12')
then
(select convert(int ,01))
else
(case when
((select convert(int ,substring(convert(varchar,CURRENT_TIMESTAMP),16,2)))='59'
and (select convert(int ,substring(convert(varchar,CURRENT_TIMESTAMP),13,2)))<>'12')
then
(select convert(int ,substring(convert(varchar,CURRENT_TIMESTAMP),13,2))+1)
else
(select convert(int ,substring(convert(varchar,CURRENT_TIMESTAMP),13,2)))
end)
End
U_Minutes=(select case when (select convert(int ,substring(convert(varchar,CURRENT_TIMESTAMP),16,2)))='59'
then
(select convert(int ,00))
else
(select convert(int ,substring(convert(varchar,CURRENT_TIMESTAMP),16,2))+1)
end)
where DocEntry=@list_of_cols_val_tab_del
End
---End Transaction Notification Alert
Note: Add or update event current Hour and minutes is going to update in the document
Set this Query To Query Manager
SELECT T0.[DocNum], T0.[CardCode], T0.[CardName],T0.[NumAtCard], T0.[DocDate],
T0.[DocStatus],T0.U_Hour [Hour],T0.U_Minutes [Minutes] FROM ORDR T0 INNER JOIN RDR1 T1 ON
T0.DocEntry = T1.DocEntry WHERE DATEDIFF(DD,T0.CREATEDATE,GETDATE())=0
and convert(int,T0.U_Hour)=(select substring(convert(varchar,CURRENT_TIMESTAMP),13,2))
and convert(int,T0.U_Minutes)=(select convert(int,substring(convert(varchar,CURRENT_TIMESTAMP),16,2)))
Alert Manager
Set alert for Every 1 Minutes
Result
alert will come document added after One Minutes -
Error while adding A/P Credit Memo!
Error while adding A/P Credit Memo..........
'G/L Accounts' (OACT) (ODBC-2028) Message - 131-183
Please advice me .....
Thanks...Hi
Check this thread this may help you.
[Re: AP Invoice - No Matching Account Error]
Regards
Balaji -
Added new field to cube but data not passed from DSO
Hope someone can help.
(BI 7.0) We added new fields into a cube. The fields already existed in the DSO. When we ran the process chain in development for the first time after making this change, we notice that the 'historical' data for these fields is populated in the cube. When we do this in our quality system only new data passed to the cube is updated. In development in the sub-chain DTP request we see all previous requests listed under selections. In quality it is only the latest request. The only difference is that the DeltaInit flag in the DTP request in development is ticked (extraction mode) - but not in quality. Does anyone know whyb this is?hi peter,
Adding fields to cube doesn't affect delta status...The delta DTP should be able to handle delta requests automatically.
I guess in you quality system, the cube already got all requests updated from ODS before you importing the change request. And in develop system none of the requests in ODS were updated before the change.
Regards,
Frank -
HI, i recently just switched to verizon and so far i have loved it. But now im running into an issue and itseems almost impossible to get ahold of anyone via phone for support so im going to try this way.
I am mid way through my month and i have ran out of data. I want to add more to my account so my phone will have internet again. How do i do this? I have added more data packages but that hasnt solved the issue, i still have no internet. I use my phone for work alot and need to have internet the remainder of the month. Can someone please tell me how to go about getting internet on my phone until my plan renews in two weeks.
THank you for any help!huss9,
I am happy to hear that you are loving the service. Welcome to the Verizon Wireless family. But let's get to work on the issue at hand today. With the iPhone can you please go into Settings, General, Scroll to the bottom and tap on Reset, then do reset network settings. This will not delete any of your personal information. All of your pictures, contacts, apps, and music will still be on the phone. Then re-try the network out. Please keep us posted.
KevinR_VZW
Please follow us on Twitter @VZWSupport -
I added my first folder of MP3s and it created a playlist, but didn't show up in the library. When adding a second folder, it didn't show up anywhere. I can do a search for them in the search window, and it finds/plays them, but I want to be able to browse them in my library. These are not MP3s downloaded from iTunes, but are personal files located on my hard drive. Can anyone help?
I have a Dell that's running Windows XP. I have found that itunes is very temperamental. this works most of the time... except on my son's computer that's running Windows Vista.
Go to your library in iTunes. Then go up to file and try one of the options (import, add folder to library, or add file to library).
Adding a folder is the least work. You can add all the files from a folder with one click... if it works. Remember that itunes is temperamental.
If that doesn't work, try adding a file. The problem with that is that you have to go through the whole process for each and every file (song, movie, etc).
Sometimes the only thing that works is to import.
I haven't gotten iTunes to work on my son's computer (Windows Vista).
I can't get support from apple in any way at all! They are good about creating electronics that appeal to us But they are lousy at support. If anyone figures out how to access support (where you can actually contact Apple) please let me know ([email protected]). I've been trying for 6 months. -
Adding New Data To Same Page - HELP
I am trying to put together a invoice on the fly, the products are added to the invoice by selecting the disired product from a drop down menu and hitting the add button. You SHOULD then be able to select more products from the same drop down menu and htting add again will include it in the invoice.... simple?? Well the problem i have is that when i hit the add button to add another item it just replaces the one i have already added.... this is very annoying... i cannot think of a way to take the product data through the form submission ready for adding too.
Any Ideas this is really bugging me, and the more time i spend on it, the worse its getting. Code Below
<%@ page buffer="32kb" %>
<%@ page import="java.sql.*, javax.servlet.ServletException, java.io.IOException, com.stock_control.*" %>
<%!
String convertResultsToSelect ( ResultSet rs, String selectName, String idCol, String descCol ) throws SQLException
StringBuffer sb = new StringBuffer ( "<select name=" + selectName +">" );
if (rs != null) {
while (rs.next()) {
sb.append ( "<option value=" );
sb.append ( rs.getString(idCol) );
sb.append ( ">" );
sb.append ( rs.getString(descCol) );
sb.append ( "</option>" );
sb.append ( "</select>" );
return sb.toString ();
%>
<html>
<head>
<title>Members Area - Stock Check</title>
</head>
<body bgcolor="#CCCCCC" topmargin="0">
<%@ include file="topConn.jsp" %>
<%
String msg = "";
String name = "";
String address1 = "";
String address2 = "";
String town ="";
String postcode = "";
String country = "";
String phone = "";
String mail = "";
String comments = "";
float total = 0;
int nextFree = 0;
String prodResults;
int numberOfItems = 0;
String shop = (String)session.getValue("SHOP");
String selectProd = "SELECT ProductID, ProductName FROM product WHERE ShopID=";
rs1 = stmt.executeQuery(selectProd+shop);
prodResults = convertResultsToSelect( rs1, "product","ProductID","ProductName");
rs = stmt.executeQuery("SELECT COUNT(*) AS stockLevel FROM product WHERE ShopID ="+shop);
while(rs.next())
numberOfItems = rs.getInt("stockLevel");
Product[] products = new Product[numberOfItems];
if (request.getParameter("add")!=null)
// get values from all text boxes....
name = request.getParameter("name");
address1 = request.getParameter("address1");
address2 = request.getParameter("address2");
town = request.getParameter("town");
postcode = request.getParameter("postcode");
country = request.getParameter("country");
phone = request.getParameter("phone");
mail = request.getParameter("mail");
comments = request.getParameter("comments");
// add data from dropdown
String newProduct = request.getParameter("product");
//connect to database and put product data into array + increment
int thenewid = 0;
String theName = "";
float thePrice = 0;
String nono = "0";
String getProd = "SELECT * FROM product WHERE ProductID=";
rs = stmt.executeQuery(getProd+newProduct);
if(rs.next())
thenewid = Integer.parseInt(newProduct);
theName = rs.getString("ProductName");
thePrice = rs.getFloat("SalePrice");
Product addProduct = new Product(thenewid, theName, thePrice, nono);
products[nextFree] = addProduct; //PROBLEM
nextFree++;
// reload page with new data in form
//for loop arround array
%>
<form method="GET">
<div align=center>
<p>
<%=prodResults%>
<input type="submit" value="Add" name="add"></p>
<TABLE width=100% height="1">
<TBODY>
<tr>
<td width="4%" height="19"> </td>
<td width="96%" height="19">
</td>
</tr>
<tr>
<td width="4%" height="198"> </td>
<td width="96%" height="198">
<div align="center"></div>
<table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber5">
<tr>
<td width="4%"> </td>
<td width="15%"><font face="Verdana" size="2">Customer Name</font></td>
<td width="30%"><input type="text" name="name" size="30" value="<%=name%>"></td>
<td width="19%"><font face="Verdana" size="2">Customer Phone #</font></td>
<td width="26%"><input name="phone" type="text" size="30" value="<%=phone%>"></td>
<td width="6%"> </td>
</tr>
<tr>
<td> </td>
<td><font face="Verdana" size="2">Address Line 1</font></td>
<td><input type="text" name="address1" size="40" value="<%=address1%>"></td>
<td><font face="Verdana" size="2">Customer E-mail</font></td>
<td><input name="mail" type="text" size="30" value="<%=mail%>"></td>
<td> </td>
</tr>
<tr>
<td height="32"> </td>
<td><font face="Verdana" size="2">Address Line 2</font></td>
<td> </td>
<td><font face="Verdana" size="2">Comments</font></td>
<td width="26%" rowspan="5"><p>
<textarea name="comments" cols="29" rows="5"><%=comments%></textarea>
</p>
<p> </p></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><font size="2" face="Verdana">Town/City</font></td>
<td><input name="town" type="text" size="40" value="<%=town%>">
<input name="address2" type="text" size="40" value="<%=address2%>"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><font size="2" face="Verdana">Post Code</font></td>
<td><input type="text" name="postcode" size="10" value="<%=postcode%>"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><font size="2" face="Verdana">Country</font></td>
<td><input type="text" name="country" size="40" value="<%=country%>"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="24"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="23"> </td>
<td><strong><font size="2" face="Verdana">Product Code</font></strong></td>
<td><strong><font size="2" face="Verdana">Name</font></strong></td>
<td><strong><font size="2" face="Verdana">Price</font></strong></td>
<td> </td>
<td> </td>
</tr>
<%
if (request.getParameter("add")!=null)
for(int i=0; i<nextFree; i++)
Product temp = products;
int prodID = temp.getid();
String prodName = temp.getname();
float prodPrice = temp.getprice();
total = total + prodPrice;
// work out total on the fly
%>
<tr>
<td height="23"> </td>
<td> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=prodID%> </font></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=prodName%></font></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">£<%=prodPrice%></font></td>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
<td> </td>
</tr>
<%
%>
<tr>
<td width="4%" height="23"> </td>
<td width="15%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
<td width="30%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
<td width="19%"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Total:</font></strong></td>
<td width="26%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><%=total%></font></td>
<td width="6%"> </td>
</tr>
</table>
<p align="center">
<input type="submit" value="Continue" name="continue">
</form>
</p>
</td> </tr> </TBODY></table>
<%@ include file="bottomConn.jsp" %>
</body>
</html>anyone?
-
I am adding more memory, should I replace the top two slots with the 4g memory modules, then place 2g memory modules on bottom slots. Does it even matter?
I am adding more memory, should I replace the top two slots with the 4g memory modules, then place 2g memory modules on bottom slots. Does it even matter?
-
Get All Values From NewForm.aspx using Event Receiver Item Adding
HI All,
I have conditions to check before the insertion of "Calendar Event".For this I am using Item Adding Event Receiver ,When Click on Save button I need to get all the values of Items filled in NewForm.aspx and check
the condition,If condition satisfies make them insert else show alert info as"Not Valid",Below is code and error message
public override void ItemAdding(SPItemEventProperties properties)
base.ItemAdding(properties);
string StartTime = properties.AfterProperties["Start Time"].ToString();
string EndTime = properties.AfterProperties["End Time"].ToString();
Error
Object reference not set to an instance of an object.
Use the New "Keyword to create an object instance
Can any one help me how can I do it.
Thanks,
Quality Communication Provides
Quality Work.
http://siddiq-sharepoint2010.blogspot.in/
Siddiqali Mohammad .Hi,
Have you tried with the code snippet as mentioned below
string EndDate = Convert.ToString(properties.AfterProperties["EndDate"]);
string StartDate = Convert.ToString(properties.AfterProperties["EventDate"]);
If my post is helpful - please click on the green arrow to mark it as answer -
Hi Guys,
I am using the full width video widget on a site. The widget was working perfectly however I have just added additional content to the site and re-uploaded and now the video is not working! Please help I have tried everything and am freaking out as this web-site has been payed for by my client.
AlexMany thanks.
With those symptoms, I'd try the following document:
Apple software on Windows: May see performance issues and blank iTunes Store
(If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.) -
Not Able to Generate Out of the Report by adding the new 2 fields
Hi,
I'm Very new to ABAP. I have created one report. after 2 new fields added they are EKNAM and EKGRP.
The Thing is the remaining fields are displaying in the output. The Newly added fields are not displaying the out. I was able to add this 2 fields in the head of the report. But issue is not able to get the data on these 2 fields.
Please see the below program and any one please help me out to display the data in this report for the fields eknam and ekgrp.
TABLES: eban,
lfa1,
ekko,
t024,
v_username.
DATA: BEGIN OF i_req_items OCCURS 10,
ernam LIKE eban-ernam, "Created by
lifnr LIKE eban-lifnr, "Desired vendor
ebeln LIKE eban-ebeln, "PO Number
ebelp LIKE eban-ebelp, "PO Item
eknam LIKE t024-eknam, "Pur.Grp Name
ekgrp LIKE t024-ekgrp, "Pur.Grp Number
flief LIKE eban-flief, "Fixed vendor
name1 LIKE lfa1-name1, "Vendor name
badat LIKE eban-badat, "Creation date
erdat LIKE eban-erdat, "Change date
banfn LIKE eban-banfn, "Requisition no.
bnfpo LIKE eban-bnfpo, "Req. item no.
bsart LIKE eban-bsart, "Document type
knttp LIKE eban-knttp, "Acct.assgmt category
txz01 LIKE eban-txz01, "PO item description
menge LIKE eban-menge, "Quantity
preis LIKE eban-preis, "Price
peinh LIKE eban-peinh, "Price unit
value(14) TYPE p DECIMALS 2, "Item Value
END OF i_req_items.
DATA: BEGIN OF i_reqs OCCURS 10,
ernam LIKE eban-ernam, "Created by
persn LIKE usr21-persnumber, "Person number
uname LIKE adrp-name_text, "User name
lifnr LIKE eban-lifnr, "Vendor
name1 LIKE lfa1-name1, "Vendor name
badat LIKE eban-badat, "Creation date
banfn LIKE eban-banfn, "Requisition no.
bnfpo LIKE eban-bnfpo, "Req. item no.
bsart LIKE eban-bsart, "Document type
knttp LIKE eban-knttp, "Acct.assgmt category
txz01 LIKE eban-txz01, "PO item description
eknam like t024-eknam, "Purchase Grp Name
ekgrp like t024-ekgrp, "Purchase Grp Number
value(14) TYPE p DECIMALS 2, "Item Value
END OF i_reqs.
DATA: BEGIN OF i_req_keys OCCURS 0,
ernam LIKE eban-ernam, "Created by
lifnr LIKE eban-lifnr, "Desired vendor
erdat LIKE eban-erdat, "Create or Change date
banfn LIKE eban-banfn, "Requisition no.
bnfpo LIKE eban-bnfpo, "Req. item no.
eknam like t024-eknam, "Purchase Grp Name
ekgrp like t024-ekgrp, "Purchase Grp number
END OF i_req_keys.
DATA: BEGIN OF i_req_keeper OCCURS 0,
ernam LIKE eban-ernam, "Created by
lifnr LIKE eban-lifnr, "Desired vendor
banfn LIKE eban-banfn, "Requisition no
END OF i_req_keeper.
DATA: wa_reqitems LIKE i_req_items.
DATA: BEGIN OF i_export OCCURS 10,
record(150) TYPE c,
END OF i_export.
CONSTANTS
CONSTANTS:
c_doccat LIKE eban-bstyp VALUE 'B',
c_creind LIKE eban-estkz VALUE 'R',
c_delflag LIKE eban-loekz VALUE 'L',
c_write(5) TYPE c VALUE 'WRITE',
c_slash(1) TYPE c VALUE '/',
*start ESPZC U8DK900439
c_delimiter TYPE x VALUE '09',
c_delimiter TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
*end ESPZC U8DK900439
c_sc(1) TYPE c VALUE ';',
c_x(1) TYPE c VALUE 'X',
c_usd(1) TYPE c VALUE '2',
c_export LIKE authb-filename VALUE '/BAY2/UBEM_SPLIT_REQS'.
WORKING VARIABLES
DATA: w_report_id LIKE syst-repid,
w_sttime LIKE syst-uzeit,
w_rpt_pagno LIKE syst-pagno,
w_rc LIKE sy-subrc,
w_datelow LIKE eban-badat,
w_datehigh LIKE eban-badat,
w_export LIKE c_export,
w_records TYPE i,
w_message(50) TYPE c.
TYPES number TYPE i.
SELECTION SCREEN / PARAMETERS
SELECTION-SCREEN BEGIN OF BLOCK org WITH FRAME TITLE text-001.
PARAMETERS: p_purorg LIKE eban-ekorg OBLIGATORY DEFAULT 'US02'.
SELECT-OPTIONS: s_doctyp FOR eban-bsart,
s_date FOR eban-badat.
PARAMETERS: p_timper(2) TYPE n.
SELECTION-SCREEN: COMMENT 37(37) text-002.
SELECTION-SCREEN END OF BLOCK org.
SELECTION-SCREEN BEGIN OF BLOCK outp WITH FRAME TITLE text-003.
PARAMETERS: p_onlin RADIOBUTTON GROUP outp DEFAULT 'X',
p_servr RADIOBUTTON GROUP outp.
SELECTION-SCREEN END OF BLOCK outp.
AT SELECTION SCREEN
AT SELECTION-SCREEN.
IF p_servr = c_x.
CLEAR w_rc.
PERFORM authority_check_dataset USING w_export
CHANGING w_rc.
IF w_rc <> 0.
MESSAGE e532 WITH text-006 w_export.
ENDIF.
CLEAR w_rc.
PERFORM verify_unix_path_and_file CHANGING w_rc.
IF w_rc <> 0.
MESSAGE e531 WITH w_message.
ENDIF.
ENDIF.
INITIALIZATION EVENT
INITIALIZATION.
PERFORM get_filename.
MOVE syst-uzeit TO w_sttime.
MOVE syst-repid TO w_report_id.
CLEAR: w_rpt_pagno.
START-OF-SELECTION.
PERFORM get_data.
IF p_onlin = c_x.
IF w_records GT 0.
PERFORM print_report_header.
PERFORM write_report.
ELSE.
MESSAGE i531 WITH text-007.
ENDIF.
ELSEIF p_servr = c_x.
PERFORM write_export.
ENDIF.
END-OF-SELECTION.
---- F O R M R O U T I N E S -
*& FORM get_filename
FORM get_filename.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = c_export
IMPORTING
file_name = w_export
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " get_filename
FORM authority_check_dataset
FORM authority_check_dataset USING p_filename
CHANGING p_rc.
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING
activity = c_write
filename = p_filename
EXCEPTIONS
no_authority = 1
activity_unknown = 2
OTHERS = 3.
p_rc = sy-subrc.
ENDFORM. "authority_check_dataset
FORM verify_unix_path_and_file
FORM verify_unix_path_and_file CHANGING p_rc.
*start ESPZC U8DK900439
OPEN DATASET w_export FOR OUTPUT IN TEXT MODE
MESSAGE w_message.
OPEN DATASET w_export FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
MESSAGE w_message.
*end ESPZC U8DK900439
p_rc = sy-subrc.
ENDFORM. "verify_unix_path_and_file
FORM get_data
FORM get_data.
CLEAR w_datelow.
CLEAR w_datehigh.
w_datelow = s_date-low - p_timper.
w_datehigh = s_date-high + p_timper.
w_datehigh = s_date-high.
SELECT ernam lifnr ebeln ebelp flief badat erdat banfn bnfpo bsart
knttp menge preis peinh txz01
FROM eban
INTO CORRESPONDING FIELDS OF TABLE i_req_items
WHERE bstyp = c_doccat
AND estkz = c_creind
AND knttp <> space
AND bsart IN s_doctyp
AND loekz <> c_delflag
AND ekorg EQ p_purorg
AND ( ( badat BETWEEN w_datelow and w_datehigh ) OR
( erdat BETWEEN w_datelow AND w_datehigh ) ).
AND erdat BETWEEN w_datelow AND w_datehigh.
IF sy-subrc = 0.
LOOP AT i_req_items.
IF i_req_items-lifnr IS INITIAL.
IF NOT i_req_items-flief IS INITIAL.
MOVE i_req_items-flief TO i_req_items-lifnr.
MODIFY i_req_items.
ENDIF.
IF NOT i_req_items-ebeln IS INITIAL.
SELECT lifnr FROM ekko
INTO i_req_items-lifnr
WHERE ebeln = i_req_items-ebeln.
ENDSELECT.
MODIFY i_req_items.
ENDIF.
ENDIF.
IF i_req_items-erdat GT i_req_items-badat.
MOVE i_req_items-erdat TO i_req_items-badat.
MODIFY i_req_items.
ENDIF.
ENDLOOP.
PERFORM weed_out_unique_records.
PERFORM apply_time_period.
SORT i_req_items BY ernam lifnr banfn bnfpo.
LOOP AT i_req_items.
i_req_items-value = ( i_req_items-menge *
( i_req_items-preis / i_req_items-peinh ) ).
MODIFY i_req_items.
ENDLOOP.
Getting vendor name from table LFA1 -
CLEAR i_req_items.
LOOP AT i_req_items.
SELECT SINGLE name1 FROM lfa1
INTO i_req_items-name1
WHERE lifnr = i_req_items-lifnr.
MODIFY i_req_items.
ENDLOOP.
LOOP AT i_req_items.
MOVE-CORRESPONDING i_req_items TO i_reqs.
Getting user name from view v_username -
SELECT SINGLE name_text
FROM v_username INTO i_reqs-uname
WHERE bname = i_reqs-ernam.
APPEND i_reqs.
ENDLOOP.
ENDIF.
DESCRIBE TABLE i_reqs LINES w_records.
ENDFORM. "Get_data
FORM print_report_header
FORM print_report_header.
ADD 1 TO w_rpt_pagno.
CALL FUNCTION '/BAY2/UBEXBH_BAYER_HEADR_FUN'
EXPORTING
f_jobname = text-020
f_business_group = text-021
f_report_title = text-022
f_repid = w_report_id
f_sysid = syst-sysid
f_linsz = syst-linsz
f_pagno = w_rpt_pagno
f_mandt = syst-mandt
f_datum = syst-datum
f_uzeit = w_sttime.
FORMAT COLOR COL_HEADING.
WRITE: /1 text-010, "Created by CWID & user name
29 text-011, "Vendor #
38 text-012, "Vendor Name
69 text-013, "Req Number
79 text-014, "/Item
87 text-015, "Created On
98 text-017, "A (AcctAssgmtCat)
100(14) text-019 RIGHT-JUSTIFIED, "Item Value
116(30) text-018, "Item Description
148 text-030, "Pur.Grp Name
170 text-031. "Pur.Grp Number
FORMAT COLOR OFF.
ULINE.
ENDFORM. "print_report_header
*& Form WRITE_REPORT
FORM write_report.
LOOP AT i_reqs.
WRITE: /1 i_reqs-ernam,
9(18) i_reqs-uname,
29 i_reqs-lifnr,
38(30) i_reqs-name1,
69 i_reqs-banfn,
79 c_slash,
80 i_reqs-bnfpo,
87 i_reqs-badat,
98 i_reqs-knttp,
100(14) i_reqs-value CURRENCY c_usd,
116(30) i_reqs-txz01,
145 i_reqs-eknam,
160 i_reqs-ekgrp.
ENDLOOP.
ENDFORM. "write_report
*& Form WRITE_EXPORT
FORM write_export.
DATA: l_value(14) TYPE c,
l_bsart(100) TYPE c,
l_uname(7) TYPE c,
l_records(5) TYPE c,
l_header(150) TYPE c,
l_params(150) TYPE c,
i_char TYPE i.
LOOP AT i_reqs.
CLEAR l_value.
CLEAR l_uname.
l_value = i_reqs-value.
l_uname = sy-uname.
CONCATENATE: i_reqs-uname
i_reqs-ernam
i_reqs-lifnr
i_reqs-name1
i_reqs-banfn
i_reqs-bnfpo
i_reqs-badat
i_reqs-knttp
l_value
i_reqs-txz01 INTO i_export
SEPARATED BY c_delimiter.
APPEND i_export.
ENDLOOP.
CONCATENATE: text-008 "Created By Name
text-009 "CWID
text-011 "Vendor No
text-012 "Vendor Name
text-013 "Req Number
text-023 "Item
text-015 "Created On
text-017 "A
text-019 "Item Value
text-018 "Item Description
text-030 "Purchase Grp name
text-031 "Purchase Grp number
INTO l_header SEPARATED BY c_delimiter.
INSERT l_header INTO i_export INDEX 1.
IF sy-batch IS INITIAL.
MOVE sy-uname TO l_uname.
ELSE.
MOVE text-024 TO l_uname.
ENDIF.
PERFORM collect_bsart CHANGING l_bsart
i_char.
l_records = w_records.
CONCATENATE: sy-sysid
p_purorg
l_bsart(i_char)
s_date-low
s_date-high
p_timper
l_uname
sy-datum
l_records INTO l_params
SEPARATED BY c_delimiter.
INSERT l_params INTO i_export INDEX 1.
LOOP AT i_export.
CONDENSE i_export NO-GAPS.
TRANSFER i_export TO w_export.
ENDLOOP.
CLOSE DATASET w_export.
MESSAGE s533 WITH text-028 w_export text-029.
ENDFORM. "write_export
*& FORM collect_bsart
FORM collect_bsart CHANGING p_bsart
p_char.
CLEAR p_bsart.
LOOP AT s_doctyp.
IF sy-tabix = 1.
p_bsart = s_doctyp-low.
ELSE.
CONCATENATE: p_bsart c_sc s_doctyp-low INTO p_bsart.
ENDIF.
ENDLOOP.
CONDENSE p_bsart NO-GAPS.
p_char = strlen( p_bsart ).
ENDFORM. "collect_bsart
*& Form WEED_OUT_UNIQUE_RECORDS
FORM weed_out_unique_records.
DATA: i_l_req_items LIKE i_req_items OCCURS 0 WITH HEADER LINE.
DATA: i_l_req_final_items LIKE i_req_items OCCURS 0 WITH HEADER LINE.
DATA: l_count TYPE i,
l_sy_tabix LIKE sy-tabix,
l_banfn LIKE eban-banfn.
REFRESH i_l_req_items.
REFRESH i_l_req_final_items.
CLEAR l_banfn.
i_l_req_items[] = i_req_items[].
i_l_req_final_items[] = i_req_items[].
SORT i_req_items BY ernam lifnr.
SORT i_l_req_items BY ernam lifnr.
SORT i_l_req_final_items BY ernam lifnr.
LOOP AT i_l_req_items.
l_banfn = i_l_req_items-banfn.
CLEAR l_count.
LOOP AT i_req_items
WHERE ernam = i_l_req_items-ernam
AND lifnr = i_l_req_items-lifnr.
IF i_req_items-banfn <> l_banfn.
ADD +1 TO l_count.
ENDIF.
ENDLOOP.
IF NOT ( l_count > 0 ).
LOOP AT i_l_req_final_items
WHERE ernam = i_l_req_items-ernam
AND lifnr = i_l_req_items-lifnr.
DELETE i_l_req_final_items.
ENDLOOP.
ENDIF.
ENDLOOP.
REFRESH i_req_items.
i_req_items[] = i_l_req_final_items[].
ENDFORM. " WEED_OUT_UNIQUE_RECORDS
*& Form APPLY_TIME_PERIOD
FORM apply_time_period.
DATA: l_i_req_keys LIKE i_req_keys.
DATA: l_days_diff TYPE p,
l_no_of_key_recs TYPE i,
l_next_item LIKE sy-tabix,
l_finished_with_keys TYPE c VALUE 'N',
l_add_line TYPE c VALUE 'N',
l_count TYPE i,
l_req_ernam LIKE eban-ernam,
l_req_lifnr LIKE lfa1-lifnr,
l_req_banfn LIKE eban-banfn,
l_save_tabix like sy-tabix.
REFRESH: i_req_keys, i_req_keeper.
LOOP AT i_req_items.
MOVE-CORRESPONDING i_req_items TO
i_req_keys.
IF i_req_items-erdat IS INITIAL.
i_req_keys-erdat = i_req_items-badat.
ENDIF.
APPEND i_req_keys.
ENDLOOP.
SORT i_req_keys BY ernam lifnr erdat.
CLEAR l_no_of_key_recs.
DESCRIBE TABLE i_req_keys LINES l_no_of_key_recs.
LOOP AT i_req_keys.
IF l_add_line = 'Y'.
MOVE-CORRESPONDING i_req_keys
TO i_req_keeper.
APPEND i_req_keeper.
l_add_line = 'N'.
ENDIF.
IF l_finished_with_keys = 'Y'.
EXIT.
ENDIF.
CLEAR l_next_item.
l_save_tabix = sy-tabix.
COMPUTE l_next_item = sy-tabix + 1.
IF l_next_item = l_no_of_key_recs.
l_finished_with_keys = 'Y'.
ENDIF.
clear: l_i_req_keys.
READ TABLE i_req_keys INDEX l_next_item
INTO l_i_req_keys.
sy-tabix = l_save_tabix.
CLEAR l_days_diff.
l_days_diff = l_i_req_keys-erdat -
i_req_keys-erdat.
IF l_i_req_keys-ernam =
i_req_keys-ernam AND
l_i_req_keys-lifnr =
i_req_keys-lifnr AND
l_i_req_keys-banfn <>
i_req_keys-banfn AND
l_days_diff <= p_timper.
MOVE-CORRESPONDING i_req_keys
TO i_req_keeper.
APPEND i_req_keeper.
l_add_line = 'Y'.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM i_req_keeper
COMPARING ALL FIELDS.
SORT i_req_keeper BY ernam lifnr banfn.
LOOP AT i_req_items.
CLEAR l_count.
CLEAR: l_req_ernam,
l_req_lifnr,
l_req_banfn.
l_req_ernam = i_req_items-ernam.
l_req_lifnr = i_req_items-lifnr.
l_req_banfn = i_req_items-banfn.
LOOP AT i_req_keeper
WHERE ernam = i_req_items-ernam
AND lifnr = i_req_items-lifnr
AND banfn = i_req_items-banfn.
ADD +1 TO l_count.
ENDLOOP.
IF NOT ( l_count > 0 ).
LOOP AT i_req_items
WHERE ernam = l_req_ernam
AND lifnr = l_req_lifnr
AND banfn = l_req_banfn.
DELETE i_req_items.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM. " APPLY_TIME_PERIODRajesh,
Put a breakpoint and try to debug the report step by step.
You will findout the reason very easily.
Whenever you have a select and are trying to append into an internal table, keep checking your internal table if it is been populated with the correct records.
This way, you will findout the cause and can correct is accordingly.
Thanks,
Suresh Ganti -
So.....deeply....disappointed by Lion...
It honestly gets in the way of getting things done.
When was the last time you had an upgrade, in any program or OS that caused an immediate productivity drop?
Mail windows, when adding a new address, pop under to become the lowest window in the stack...before you are done composing...
no extra clicks..just adding ONE character to the actual address bar does it.
Trying to add files to an online content management system is hard...it's hard because when you attempt to add the file, it disappears from
the list, so a search must be conducted...oh not a search of your hard drive...no...it has to include ALL FILES and that takes a while, showing
files totally unrelated to what you need or in whatever that view is, showing everything from movies to documents, to a whole range of other stuff
that is irrelevant to what is being sought.
I can get used to the disappearing icon tool bar...but the message threading in Mail is so strangely bad it's hard to describe. So you send out an email,
and it had 5 points...but that was 3 emails before...A reply comes in addressing those 5 points but saying something like ..."I disagree with point number 4"
Unless you have total recall the thread shows you only incoming mail and the LAST most recent folded up message you sent. You are forced to go digging
into sent mail to see what that point you made 8 days eariler actually was...
I am pleased that I don't have to have Launchpad (honestly the silliest 'feature' I've ever seen on a computer) in the dock and see no point in the juvenile Mission Control (the naming scheme is odd and reminiscent of Junior Spaceman...how ironic that we end America's manned launch capability at the same time as Launch Pad and Mission Control, both throwbacks to the 60's are added to an OS). In any case both are virtually useless tools. One, replacing the mildly useful Spaces and the other just genuinely useless.
I'm going to give Apple until the second bug fix...but I can tell right now that Snow Leopard was a far more robust OS. The thousands of posts about this may rise to the level of AntennaGate...I hope so...It seems the only way to get Steve (for whom I have now honestly lost respect for the FIRST TIME) to address the issues is to embarrass the company publicly. Lion is a broken system, poorly conceived...and proof that the Apple methodology of no widespread user testing can and does fail. This needs to get fixed. Soon.It seems to have something to do with profile manager.
I get stack traces in the "system messages" logs for the "Server" application, grrrr.
I'll get that info and attempt to submit a but report tonight.
Maybe you are looking for
-
Using JHS 10.1.2 on Jdeveloper 10.1.3
Hi, We have been using JHS 10.1.2 on Jdeveloper 10.1.2. Now we are upgrading from Jdeveloper 10.1.2 to 10.1.3. So when we tried to migrate the existing modules in Jdeveloper 10.1.3 by including all the JHS 10.1.2 libraries, all the modules which just
-
X-Fi: ICQ-Start changes LineIn to
Hi! First of all sorry for my english, hope you understand me! 2 Questions: I just bought the X-Fi ExtremeMusic and I'm amazed about the difference to my old Li've 5.! But now I have a problem with the Line-In/Mic. Every time I start ICQ, it will cha
-
Regarding uploading .wri files in sap system
Hi Experts, I want to know which all file types can be uploaded in sap system. Can we upload .wri file in sap system ? Waiting for quick replies. Thanks in advance, Akash
-
Hello Arch community, i´m back to Arch. After using it for nearly 3 years, i´ve used Kubuntu nearly a half year, because thats the "standard" Linux Distri used at my chair in university. I´m very happy, that i can use ARCH again. So long so good. Let
-
Hello. I am trying to create an Invoice template. Here in Prince Edward Island, Canada the Taxes are Laid out as follows: Amount of Sale $100.00 GST (6%) $6.00 Sub-Total $106.00 PST (10%) $10.60 Total Payable $116.60 Does anyone know how to set this