Sql to get average timestamp between 2 timestamps
I know similar question has been asked many times in several forums. Most of them dealt with fetching interval or difference between timestamps in numbers (hours, mins,...) or using PL/SQL or custom functions.
Without using PL or custom functions, but just a sql what's the most efficient way of calculating timestamp that's half way between 2 timestamps?
alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS';
select
to_date('2013-12-05 04:30:20','YYYY-MM-DD HH24:MI:SS') start_date,
to_date('2013-12-06 15:00:30','YYYY-MM-DD HH24:MI:SS') end_date,
'' avg_date
from dual;
Thanks,
-srinivas y.
Hi,
Here's one way to get the mid-point between 2 DATEs:
WITH input_data AS
SELECT TO_DATE ('2013-12-05 04:30:20', 'YYYY-MM-DD HH24:MI:SS') AS start_date
, TO_DATE ('2013-12-06 15:00:30', 'YYYY-MM-DD HH24:MI:SS') AS end_date
FROM dual
SELECT start_date, end_date
, start_date + ( (end_date - start_date)
/ 2
) AS mid_point
FROM input_data
If start_date and end_date are already in a table, then use that table instead of a sub-query like input_data above.
Message was edited by: Frank Kulash
Actually, this works equally well if start_date and end_date are TIMESTAMPs.
(TIMESTAMP is a separtate datatype from DATE. You asked about TIMESTAMPs, but the example you gave used DATEs. If you really want TIMESTAMPs, you can use TO_TIMESTAMP instead of TO_DATE.)
Similar Messages
-
Query for getting records max reported timestamp and 2nd max report
query for getting records in between
max reported timestamp and 2nd max reported timestamp
HERE IS ALL RESULT SET
TIME DOMAIN
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:08:05 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:08:05 TOMCAT
PD_REPORTED_TIMESTAM PD_USER
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:08:05 TOMCAT
30:jun:2006:20:08:05 TOMCAT
PD_REPORTED_TIMESTAM PD_USER
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:25 TOMCAT
QUERY RESULT TO COME
TIME DOMAIN
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
Message was edited by:
user517983Hi,
can we write query like this.
1 select pd_user,PD_REPORTED_TIMESTAMP
2 from sp_process_detail_current spdc
3 where host_id='DSCP02469'and pd_user='TOMCAT'
4 and exists(
5 select PD_REPORTED_TIMESTAMP from sp_process_detail_current
6* having max(PD_REPORTED_TIMESTAMP)-spdc.PD_REPORTED_TIMESTAMP=0)
SQL> /
PD_USER PD_REPORTED_TIMESTAM
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45 -
Select where timestamp between date1 and date 2
try a lot of variations but still dont work
this was my last shot, then i come here ask for help
the field DATAHORAS is timestamp
data1 and dat2 will come from a form
To_Date(S.DATAHORAS, 'dd/mm/yyyy hh24:mi:ss')
Between Cast(To_Date(:data1) As TimeStamp) And Cast(To_Date(:data2) As TimeStamp)
thanks in advancedNo. You don't need to. But....
Edit: I was originally using a stupid example using DUAL which was completely misleading - sorry.
Originally I used the example below to show that you don't have to do an explicit conversion.
Things will still work comparing timestamps and dates.
SQL> select systimestamp, sysdate, sysdate+1
2 from dual
3 where systimestamp between sysdate and sysdate + 1;
SYSTIMESTAMP SYSDATE SYSDATE+1
09-FEB-10 13.58.35.712017 +00:00 09-FEB-2010 13:58:35 10-FEB-2010 13:58:35But then I added an explain plan to show that implicit conversions were going on:
1 explain plan for
2 select systimestamp, sysdate, sysdate+1
3 from dual
4* where systimestamp between sysdate and sysdate + 1
SQL> /
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 4192335797
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 1 (0)| 00:00:01 |
|* 1 | FILTER | | | | |
| 2 | INDEX FULL SCAN| SYS_IOT_TOP_57625 | 1 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter(SYS_EXTRACT_UTC(SYSTIMESTAMP(6))<=SYS_EXTRACT_UTC(SYSDATE@
!+1) AND SYS_EXTRACT_UTC(SYSTIMESTAMP(6))>=SYS_EXTRACT_UTC(SYSDATE@!))
15 rows selected.
SQL>However, this example is misleading because it's not the same implicit conversion you get with a proper table with a timestamp column:
SQL> create table t1
2 (col1 timestamp);
Table created.
SQL> ed
Wrote file afiedt.buf
1 explain plan
2 for
3 select *
4 from t1
5 where col1 between to_date('08-JAN-2010','DD-MON-YYYY')
6* and to_date('09-JAN-2010','DD-MON-YYYY')
SQL> /
Explained.
SQL>
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3617692013
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 13 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T1 | 1 | 13 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter("COL1">=TIMESTAMP' 2010-01-08 00:00:00' AND
"COL1"<=TIMESTAMP' 2010-01-09 00:00:00')
Note
- dynamic sampling used for this statement
18 rows selected.
SQL>Which is really what you want.
It has an implicit conversion on the date parameters and no implicit conversion on the column which would prevent index usage if there were an index.
Interestingly if you explicitly convert the dates to a timestamp, then you can get an extra filter predicate comparing the two parameters:
SQL> explain plan
2 for
3 select *
4 from t1
5 where col1 between cast(to_date('08-JAN-2010','DD-MON-YYYY') as timestamp)
6 and cast(to_date('09-JAN-2010','DD-MON-YYYY') as timestamp);
Explained.
SQL>
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3332582666
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 13 | 2 (0)| 00:00:01 |
|* 1 | FILTER | | | | | |
|* 2 | TABLE ACCESS FULL| T1 | 1 | 13 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter(CAST(TO_DATE(' 2010-01-08 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') AS timestamp)<=CAST(TO_DATE(' 2010-01-09 00:00:00',
'syyyy-mm-dd hh24:mi:ss') AS timestamp))
2 - filter("COL1">=CAST(TO_DATE(' 2010-01-08 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') AS timestamp) AND "COL1"<=CAST(TO_DATE(' 2010-01-09
00:00:00', 'syyyy-mm-dd hh24:mi:ss') AS timestamp))
Note
PLAN_TABLE_OUTPUT
- dynamic sampling used for this statement
23 rows selected.oracle version 11.1.0.6
Sorry about the mistakes in previous version of this reply.
Edited by: DomBrooks on Feb 9, 2010 2:25 PM -
How to get a current date timestamp ?
Hi,
I need to get the current date timestamp in a format DDMMYY HH:MM:SS.mmmm and store it in an Oracle column which is declared as of type DATE.
Also i need to store this timestamp in a string format.
Please give your inputs in this regard, which is appreciated.
RegardsDates dont' have formats. String represenations of dates do.
If you have a DB column that is of char or varchar type but represents a date/time, you should change your data model so that the column type is date or time or timestamp. If you can't do that, and need to put a date into a particular format, use java.text.SimpleDateFormat.
To get the current date and time, look at System.currentTimeMillis, java.util.Date, java.sql.Date, java.sql.Timestamp.
To put one of these into a database, use PreparedStatement. For example, a timestamp would be something like this: PreparedStatement ps = con.prepareStatement("insert into some_table (some_timestamp) values(?)");
Timestamp ts = new TimeStamp(...);
ps.setTimestamp(1, ts);
ps.excuteUpdate(); -
Get millisecond values from timestamp column in v$logmnr_contents
Hello
How do we get millisecond values from timestamp column in v$logmnr_contents.
I tried with following query.
select scn,To_Char(timestamp,'DD-MON-YYYY HH24:MI:SS:FF') from v$logmnr_contents WHERE OPERATION NOT IN('START') and username ='SCOTT' and sql_redo is not null and (seg_owner is null or seg_owner not in('SYS'));
it says ORA-01821: date format not recognized. I want to find the relation of scn with timestamp. In forums i found, scn is derived from timestamp value. I dont know its correct or not.
if i query with out FF in time format i get like
scn timestamp
808743 27-NOV-2007 00:12:53
808743 27-NOV-2007 00:12:53
808743 27-NOV-2007 00:12:53
808744 27-NOV-2007 00:12:53
808744 27-NOV-2007 00:12:53
808744 27-NOV-2007 00:12:53
if scn is derived from timestamp with milliseconds, each scn should be different right?More help pleaseMay be there's an easy way solving your problem, I did it like that:
CREATE TABLE quota_test (test VARCHAR2(50))
INSERT INTO quota_test
VALUES ('update "SCOTT"."NEWTAB1" set a="34" and b="45"')
SELECT test normal, REPLACE(SUBSTR(test,INSTR(test,'"',1),INSTR(test,'.',1)+2),'"','') changed
FROM quota_test
Result is :
NORMAL
update "SCOTT"."NEWTAB1" set a="34" and b="45"
CHANGED
SCOTT.NEWTAB1
If you didn't understand, I can explain what I wrote -
How to use between timestamp in where clause
Hi All,
i have a colum column2 of data type timestamp.now i wants to fatch record having between two date of column2.how to use between operator in where condition having column as timespamp'Hi,
You can use a timestamp literal, or use a function that return a timestamp datatype, here is an example:
(TIMESTAMP 'YYYY-MM-DD HH24:MI:SS.FF')
select * from yourtable where column2 between TIMESTAMP '1997-01-31 09:26:50.12' and systimestampHave a look to the documentation, for example http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch4datetime.htm -
How to get command history with timestamp ?
how to get command history with timestamp ?
If you are using bash:
HISTTIMEFORMAT If this variable is set and not null, its value is used as a format string for strftime(3) to print the time stamp associated with each history entry displayed by the history builtin. If this variable is set, time stamps are written to the history file so they may be preserved across shell sessions.
[SunOS 5.10/bash] [email protected]:/etc/ftpd
# HISTTIMEFORMAT="%h/%m - %H:%M:%S ";export HISTTIMEFORMAT;history
1 Aug/08 - 19:07:52 chmod a+rwx /root
2 Aug/08 - 19:07:52 ll /
3 Aug/08 - 19:07:52 tail -f /root/mylog.log
4 Aug/08 - 19:07:52 vi /usr/dt/bin/Xsession
5 Aug/08 - 19:07:52 cat /root/mylog.log
6 Aug/08 - 19:07:52 ls /export/home/p661210/.dt
7 Aug/08 - 19:07:52 ls -la /export/home/p661210/.dt
8 Aug/08 - 19:07:52 cat /export/home/p661210/.dt/errorlog
9 Aug/08 - 19:07:52 vi /usr/dt/config/C/sys.dtwmrc
10 Aug/08 - 19:07:52 ls
11 Aug/08 - 19:07:52 cat Xresources.jds
12 Aug/08 - 19:07:52 vi /usr/dt
[SunOS 5.10/bash] [email protected]:/etc/ftpd
[SunOS 5.8/bash] root@wgls03:/root
# HISTTIMEFORMAT="%h/%m - %H:%M:%S ";export HISTTIMEFORMAT;history
1 Jul/07 - 09:02:21 vi /etc/vfstab
2 Jul/07 - 09:02:21 mount /store
3 Jul/07 - 09:02:21 cd /store/bnz
4 Jul/07 - 09:02:21 ls
5 Jul/07 - 09:02:21 ./BNZ_installBaseSoftware
6 Jul/07 - 09:02:21 find /usr -name gunzipCheers,
Andreas -
Java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv
Hi all,
I am writing a servlet that connects to Oracle 8.0.6 through jdbc for jdk1.2 on NT 4.0
English version and it works fine.
But when the servlet is deployed to a solaris with Oracle 8.0.5 (not a typo, the oracle on
NT is 8.0.6 and oracle on solaris is 8.0.5) and jdbc for jdk1.2 (of course, for Solaris),
the servlet failed with the Exception:
java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv
(I am using JRun 3.0 as the application and web server for both NT and Solaris)
(The database in both the NT and solaris platform are using UTF8 charset)
My servlet looks like this: (dbConn is a Connection object proved to be connected to Oracle
in previous segment of the same method):
String strSQL = "SELECT * FROM test";
try { Statement stmt = dbConn.createStatement();
ResultSet rs = stmt.execute(strSQL);
while (rs.next()) {
out.println("id = " + rs.getInt("id"));
System.out.println("id written");
out.println("name = " + rs.getString("name")); // <-- this is the line the
exception is thrown
System.out.println("name written");
} catch (java.sql.SQLException e) {
System.out.println("SQL Exception");
System.out.println(e);
The definition of the "test" table is:
create table test(
id number(10,0),
name varchar2(30));
There are about 10 rows exists in the table "test", in which all rows contains ONLY chinese
characters in the "name" field.
And when I view the System log, the string "id written" is shown EXACTLY ONCE and then there
is:
SQL Exception
java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv
That means the resultset is fetch back from the database correctly. The problem arise only
during the getString("name") method.
Again, this problem only happens when the servlet is run on the solaris platform.
At first I would expect there are some strange code shown on the web page rather than having
an exception. I know that I should use getBytes to convert between different encodings, but
that's another story.
One more piece of information: When all the rows contains ascii characters in their "name"
field, the servlet works perfectly even in solaris.
If anyone knows why and how to tackle the problem please let me know. You can feel free to
send email to me at [email protected]
Many thanks,
Ben
nullHi all,
For the problem I previously posted, I found that Oracle had had such bug filed before in Oracle 7.3.2 (something like that) and is classified to be NOT A BUG.
A further research leads me to the document of Oracle that the error message:
"java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv"
is a JDBC driver error message of error number ORA-17037.
I'm still wondering why this behaviour will happen only in Solaris platform. The servlet on an NT machine I am using (which has an Oracle 8.0.6 and jdbc for jdk 1.2 running) is working just fine. I also suspect that this may be some sort of mistakes from jdbc driver.
Nevertheless, I have found a way to work around the problem that I cannot get non-English string from Oracle in Solaris and I would like to share it with you all here.
Before I go on, I found that there are many people out there on the web that encounter the same problem. (Some of which said s/he has been working on this problem for a month). As a result, if you find this way of working around the problem does help you, please tell those who have the same problem but don't know how to tackle. Thanks very much.
Here's the way I work it out. It's kinda simple, but it does work:
Instead of using:
String abc = rs.getString("SomeColumnContainsNonEnglishCharacters");
I used this:
String abc = new String(rs.getBytes("SomeColumnContainsNonEnglishCharacters"));
This will give you a string WITH YOUR DEFAULT CHARSET (or ENCODING) from your system.
If you want to convert the string read to some other encoding type, say Big5, you can do it like this:
String abc = new String(rs.getBytes("SomeColumneContainsNonEnglishCharacters"), "BIG5");
Again, it's simple, but it works.
Finally, if anyone knows why the fail to convert problem happens, please kindly let me know by leaving a word in [email protected]
Again, thanks to those of you who had tried to help me out.
Creambun
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by creambun creambun ([email protected]):
Hi all,
I am writing a servlet that connects to Oracle 8.0.6 through jdbc for jdk1.2 on NT 4.0
English version and it works fine.
But when the servlet is deployed to a solaris with Oracle 8.0.5 (not a typo, the oracle on
NT is 8.0.6 and oracle on solaris is 8.0.5) and jdbc for jdk1.2 (of course, for Solaris),
the servlet failed with the Exception:
java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv
(I am using JRun 3.0 as the application and web server for both NT and Solaris)
(The database in both the NT and solaris platform are using UTF8 charset)
My servlet looks like this: (dbConn is a Connection object proved to be connected to Oracle
in previous segment of the same method):
String strSQL = "SELECT * FROM test";
try { Statement stmt = dbConn.createStatement();
ResultSet rs = stmt.execute(strSQL);
while (rs.next()) {
out.println("id = " + rs.getInt("id"));
System.out.println("id written");
out.println("name = " + rs.getString("name")); // <-- this is the line the
exception is thrown
System.out.println("name written");
} catch (java.sql.SQLException e) {
System.out.println("SQL Exception");
System.out.println(e);
The definition of the "test" table is:
create table test(
id number(10,0),
name varchar2(30));
There are about 10 rows exists in the table "test", in which all rows contains ONLY chinese
characters in the "name" field.
And when I view the System log, the string "id written" is shown EXACTLY ONCE and then there
is:
SQL Exception
java.sql.SQLException: Fail to convert between UTF8 and UCS2: failUTF8Conv
That means the resultset is fetch back from the database correctly. The problem arise only
during the getString("name") method.
Again, this problem only happens when the servlet is run on the solaris platform.
At first I would expect there are some strange code shown on the web page rather than having
an exception. I know that I should use getBytes to convert between different encodings, but
that's another story.
One more piece of information: When all the rows contains ascii characters in their "name"
field, the servlet works perfectly even in solaris.
If anyone knows why and how to tackle the problem please let me know. You can feel free to
send email to me at [email protected]
Many thanks,
Ben<HR></BLOCKQUOTE>
null -
Inconsistent datatypes: expected TIMESTAMP got TIMESTAMP
Yes, that's the error message when I do:
select from_tz(systimestamp,'US/Pacific') from dual;
I get a rather funny error message:
ORA-00932: inconsistent datatypes: expected TIMESTAMP got TIMESTAMP
What gives?Check this
hr@XE> create table sun_tz_test(col1 TIMESTAMP, col2 TIMESTAMP WITH TIME ZONE);
Table created.
1* insert into sun_tz_test values(TIMESTAMP '2006-12-13 18:30:39', current_timestamp)
hr@XE> /
1 row created.
hr@XE> select * from sun_tz_test;
COL1 COL2
13-DEC-06 06.30.39.000000 PM 13-DEC-06
06.16.32.081000 PM -05:00 -
SQL Exception: Fail to convert between UTF8 and UCS2: failUTF8Conv
Hi,
I am trying to use the DBMS_OBFUSCATION_TOOLKIT to encrypt/decrypt some strings through JDBC, but I am getting the following exception:
SQL Exception: Fail to convert between UTF8 and UCS2: failUTF8Conv
The input and output parameters for the encryption/decryption functions are VarChar2.
Our database is using UTF8.
I will be glad if someone can help me on this.
Thanks,
CenkSusi,
This is just a wild guess, but your java client is on a different computer to your Oracle 9.2 server, and the locale (or encodings) on the two computers is different. Am I correct? If so, then I guess you need to change the locales (or encodings) so that they match.
Have you tried printing out the "System" properties for the two JVMs (Oracle's and your client's)? Something simple like this:
System.getProperties().list()Good Luck,
Avi. -
How to get percentage difference between two matrices?
Good day everyone, I just want to ask how to get the percentage difference between two binary matrices. This is for comparing two images converted to matrices in LabView. Thank you.
Solved!
Go to Solution.pinkman wrote:
Good day everyone, I just want to ask how to get the percentage difference between two binary matrices. This is for comparing two images converted to matrices in LabView. Thank you.
You probably converted it to a 2D array (A matrix in LabVIEW has a special meaning).
"Binary" is not very well defined (unless you are looking for the number of bits that are different). What is the datatype? Was it a color image or a greyscale image? Are both arrays the same size?
How do you define "percentage difference"? Which one of the two is the 100% reference?
Do you want a new 2D array where each element is the difference of the second array compared to the first (or vice versa), expressed in percentages?
Do you want to know what percentage of array elements are different between the two arrays?
Do you want to know the average difference between all array elements?
All possible interpretations can be easily solved with very little code, but you need to explain in more detail what you actually want?
Here is a simple solution for case #2, for example (assuming the array have the same size, and we only want a rought estimate, rounded down to the nearest integer percent):
LabVIEW Champion . Do more with less code and in less time .
Attachments:
PCT-Difference.png 16 KB -
Using Measurement Studio (Vis. Basic), I'm trying to calculate as a numerical value the total or average power between two stated frequencies of the AutoPowerSpectrum. The PowerFrequencyEstimate Method gets me part of the way there. Using appropriate values of the input variables SearchFreq and Span, I divided the range between my two frequencies into 12 segments and let PowerFrequencyEstimate find the frequency and its power at the highest point in each segment. Then I added the 12 resulting powers. Since these are power values at several peaks, not average power over a given frequency range, it's not exactl
y what I want. Do any other approaches occurr to anyone?
Thanks.Most people here won't do your homework for you. If you make an attempt yourself and get stuck then post your code (wrapped in code tags for easy reading), include any errors you get and what line they occur on and most of all ask a specific question. Don't just say "It doesn't work".
However, your assignment mentions that you are not allowed to use inbuilt C/C++ functions. This is a Java forum. Although the languages are similar and some here have C experience, try posting in a C forum. -
Generating SQL in a PL/SQL progam ( getting the values of a value)
Hi,
We're using Oracle 11.1.
I want to generate sql to do the following
something like
fld_pos(i) = 'MPI';Where fld_pos is part of a varray.
The basic procedire is below.
PROCEDURE get_oldest_mpi (
pin_fld0 VARCHAR2
, pin_fld1 VARCHAR2
, pin_fld2 VARCHAR2
, pin_fld3 VARCHAR2
, pin_fld4 VARCHAR2
, pin_fld5 VARCHAR2
, pin_fld6 VARCHAR2
, pin_fld7 VARCHAR2
, pin_fld8 VARCHAR2
, pin_fld9 VARCHAR2
, pin_fld10 VARCHAR2
, pin_fld11 VARCHAR2
, pin_fld12 VARCHAR2
, pin_fld13 VARCHAR2
IS
TYPE fld IS VARRAY(14) OF VARCHAR2(50);
fld_pos fld;
v_sql_stmt VARCHAR2(1000);
mpi_pos number;
BEGIN
--load the pin_fld vars into an array so they can be processed in a loop
FOR i IN 1..fld_pos.COUNT
LOOP
fld_pos(i) := 'pin_fld'||i;
END LOOP;
--see if the variable pin_fld'x' = the word 'MPI'
FOR i IN 1..fld_pos.COUNT
LOOP
IF fld_pos(i) = 'MPI' then -- I know this statement is wrong. This is where I need help.
mpi_pos :=i;
END IF;
END LOOP;
.I know that 'fld_pos(i)' equals 'pin_fld||i .
So how do I get to the value in the value for this? How can generate the SQL to get the expression I need?
Thanks,Hi,
It's still an awkward procedure, but
CREATE OR REPLACE PROCEDURE get_oldest_mpi (
pin_fld0 VARCHAR2,
pin_fld1 VARCHAR2,
pin_fld2 VARCHAR2,
pin_fld3 VARCHAR2,
pin_fld4 VARCHAR2,
pin_fld5 VARCHAR2,
pin_fld6 VARCHAR2,
pin_fld7 VARCHAR2,
pin_fld8 VARCHAR2,
pin_fld9 VARCHAR2,
pin_fld10 VARCHAR2,
pin_fld11 VARCHAR2,
pin_fld12 VARCHAR2,
pin_fld13 VARCHAR2
) IS
TYPE fld IS VARRAY (14) OF VARCHAR2 (50);
fld_pos fld
:= fld (pin_fld0,
pin_fld1,
pin_fld2,
pin_fld3,
pin_fld4,
pin_fld5,
pin_fld6,
pin_fld7,
pin_fld8,
pin_fld9,
pin_fld10,
pin_fld11,
pin_fld12,
pin_fld13
v_sql_stmt VARCHAR2 (1000);
mpi_pos NUMBER;
BEGIN
--see if the variable pin_fld'x' = the word 'MPI'
FOR i IN 1 .. fld_pos.COUNT LOOP
IF fld_pos (i) = 'MPI' THEN
mpi_pos := i;
END IF;
END LOOP;
END;
/Regards
Peter -
Prep 2007 Upgrade - SQL to Get Clients Started
<u><b>Prep for SAP 2007 - Some SQL to Get the Clients Started</b></u>
(NOTE: Marilyn Pratt suggested I post this here since it is so general. If there is a better place, please let me know and I can move/post it there).
I have just started working with a customer doing international business; pre-payments and block payments are 90% of their business. They have not reconciled items for almost three years in SAP B1. In my discussions with them about SAP 2007, they wanted to be a bit more proactive in dealing with reconciliations before SAP 2007 arrived. In order to get them moving quickly, I wrote the following versions of SQL which identifies business partners with a zero account balance and open documents/journal entries (what easier way is there to start?). If you find yourself in a similar situation, you might want to utilize this SQL to gently guide your customers into looking at unreconciled/unmatched situations. The SQL is simple, but direct. It might be written a lot better, but the whole purpose was to get the customer to START doing something. Two side benefits; one, the results of the SQL provide 100% success in what they are doing and they gain some confidence in a new process, and two, the customer can run this on a daily basis to keep things clean. Once they are done with this easy-to-do phase, I will put something together that might help with those items needing more research.
Might have made a mistake while re-typing the SQL for this post, so check them out and leave a note if I typed something wrong, OK? Its not much, but hope these help those who might be in a similar situation!
(note the two dashed items are just info only and not do not need to be put in the actual SQL you write).
<u><b>--SQL to Identify Business Partners with Zero Balance and Open Documents</b></u>
SELECT
--T10 = Business Partner Master Data Information
T10.CardCode AS BP Code,
T10.Cardname AS BP Name,
T10.Balance AS BP Account Balance,
--T20 = Invoice Header Information
Sum(T20.DocTotal) AS Total Open Invoices,
Sum(T20.PaidToDate) AS Total Paid To Date,
--T30 = Credit Memo Header Information
Sum(T30.DocTotal) AS Total Cred Memo Info
FROM OCRD T10 INNER JOIN OINV T20
ON T10.CardCode = T20.Card Code
AND T20.DocStatus = 'O'
--NOTE: use OINV for customer BPs, substitute ORPC for OINV to get a report on BPs that are vendors
LEFT OUTER JOIN ORIN T30
ON T10.CardCode = T30.CardCode
AND T30.DocStatus = 'O'
WHERE T10.Balance = 0
GROUP BY T10.CardCode, T10.CardName, T10.Balance
ORDER BY T10.CardCode, T10.CardName
--END OF SQL to Identify Business Partners with Zero Balance and Open Documents
Another version that could help.
<u><b>--SQL to Identify Business Partners with Zero Balance and Unmatched Journal Entries</b></u>
--T10 = Journal Entry Header Information
T10.TransID,
--T20 = Journal Entry Detail Information
T20.IntrnMatch AS Intern Match ID,
T20.ShortName AS JE BP Code,
Sum(T20.Debit) AS JE Debit Total,
Sum(T20.Credit) AS JE Credit Total,
--T30 = Business Partner Master Data Information
T30.CardCode AS BP Num,
T30.Balance AS BP Account Balance
FROM OJDT T10 INNER JOIN JDT1 T20
ON T10.TransID = T20.TransID
LEFT OUTER JOIN OCRD T30
ON T20.ShortName = T30.CardCode
AND T30.Balance = 0
WHERE T20.IntrnMatch =
--NOTE: that is a single quote mark, space, and another single quote mark for IntrnMatch
GROUP BY T20.ShortName, T20.IntrnMatch, T30.CardCode, T30.Balance
ORDER BY T20.ShortName
--END OF SQL to Identify Business Partners with Zero Balance and Unmatched JEs.Hi,
What is the native vlan you are using ? If it is vlan number 2, then there is known bug CSCui73764
Symptom:
Flex mode APs 1130 & 1240 series, will not pass traffic, e.g. DHCP, ARP. on some wlans.
Conditions:
1) Flex connect local switching
2) AP 1240 or 1130
3) any version before 7.4.121.7
4) native vlan x, non working vlan y.
5) user unable to get ip address.
Workaround:
change the native vlan to an unexpectedly high number, so no wlan will ever get mapped to a bridge group number that high.
Further Problem Description:
telnet to the flex ap. here is an example. vlan 3 is the native vlan on the flex ap, it is correctly mapped to bridge group 1. now the wlan which will not work is the one, which is mapped to vlan2. see carefully below, the vlan 2 is mapped to bridge group 3. this is the instance where we hit the bug. so it can be any wlan-vlan-native vlan combination.
HTH
Rasika
**** Pls rate all useful responses **** -
How to get the link between mara, ausp, cawn and cawnt tables
hello ABAPERS
i have got a requiremet in that i have to get the relation .
how to get the link between mara, ausp, cawn and cawnt tables and also type how can we get link between char value and char description in cawn and cawnt tables through ausp and mara tables.
I would be very thankful for ur help in advance.
Thanks & Regards.
soniHi,
Sample report using the linkage between tables;
report batch_char no standard page heading
line-size 132
line-count 58(1)
message-id mm.
Report by Batch Characteristic *
Description : Report by Batch Characteristic *
Declaration for Tables
tables: mara, " Material Master
mard, " Storage Location Data for Material
t001w, " Plants/Branches
t001l, " Storage Locations
cabn, " Characteristics
inob. " Link between Internal Number and Object
Declaration for Constants
constants : c_klart like ausp-klart value '023', " Class Type
c_obtab like inob-obtab value 'MCH1', " Database Table
c_flag type c value 'X', " Flag
c_c23 type i value '23', " Ratio
Constants for Ratio Categories
c_13 type p decimals 2 value '13.00', " For Ratio 13
c_1499 type p decimals 2 value '14.99', " For Ratio 14.99
c_15 type p decimals 2 value '15.00', " For Ratio 15
c_1699 type p decimals 2 value '16.99', " For Ratio 16.99
c_17 type p decimals 2 value '17.00', " For Ratio 17
c_1899 type p decimals 2 value '18.99', " For Ratio 18.99
c_19 type p decimals 2 value '19.00', " For Ratio 19
c_2099 type p decimals 2 value '20.99', " For Ratio 20.99
c_21 type p decimals 2 value '21.00', " For Ratio 21
c_2299 type p decimals 2 value '22.99', " For Ratio 22.99
c_23 type p decimals 2 value '23.00', " For Ratio 23
c_g23(4) type c value '>=23', " For Ratio >=23
c_ratio(5) value 'RATIO', " For Ratio
Constants for Storing Selected item field information
c_cursor1(15) value 'I_OUTPUT1-MEINS', " For Selected Base
" Unit of Measure
c_cursor2(15) value 'I_OUTPUT1-MATNR', " For Selected Base
" Material Number
c_cursor3(15) value 'I_OUTPUT1-MAKTX', " For Selected Base
" Material Des.
c_cursor4(15) value 'I_OUTPUT1-CLABS', "For Selected Base
" Stock Value
c_cursor5(15) value 'I_OUTPUT1-ATFLV', " For Selected Base
" Char.Value (Ratio)
c_cursor6(5) value 'C_G23'.
Declaration for Global Variables
data : g_exit type c, " Flag
g_clabs1(16) type c, " Quantity
g_clabs(18) type c, " Quantity
g_cursor(15) type c, " Cursor field name
g_matnr type mara-matnr, " Material Number
g_werks type mchb-werks, " Plant
g_atinn(30) type c. " Character.
Declaration for Internal tables
Internal table to hold Batch Stock data
data : begin of i_mchb occurs 0,
matnr like mchb-matnr, " Material Number
werks like mchb-werks, " Plant
lgort like mchb-lgort, " Storage Location
charg like mchb-charg, " Batch Number
clabs like mchb-clabs, " Stock Value
meins like mara-meins, " Unit of measure
atflo like ausp-atflv, " Char.Value (Ratio)
atflv like ausp-atflv, " Char.Value (Ratio)
end of i_mchb.
Internal table to hold Secondary List data
data : begin of i_mchb1 occurs 0,
werks like mchb-werks, " Plant
matnr like mchb-matnr, " Material Number
lgort like mchb-lgort, " Storage Location
charg like mchb-charg, " Batch Number
atinn like ausp-atinn, " Char.Value
clabs like mchb-clabs, " Stock Value
atflo like ausp-atflv, " Char.Value (Ratio)
atflv like ausp-atflv, " Char.Value (Ratio)
end of i_mchb1.
Internal table to get the Plant Name
data : begin of i_plant occurs 0,
werks like t001w-werks, " Plant
name1 like t001w-name1, " Name
end of i_plant.
Internal table to get the Material Description
data : begin of i_makt occurs 0,
matnr like makt-matnr, " Material
maktx like makt-maktx, " Description
end of i_makt.
Internal table to hold AUSP data
data : begin of i_ausp occurs 0,
objek like ausp-objek, " Object No
atinn like cabn-atinn, " Characteric value
atflv like ausp-atflv, " Characteristic Value
end of i_ausp.
Internal table to hold output data
data : begin of i_output occurs 0,
atinn like cabn-atinn, " Characteric value
werks like mchb-werks, " Plant
matnr like mchb-matnr, " Material Number
atnam like cabn-atnam, " Characteristic
atflv like ausp-atflv, " Char.Value (Ratio)
name1 like t001w-name1, " Plant Description
maktx like makt-maktx, " Material Description
clabs like mchb-clabs, " Stock Value
meins like mara-meins, " Base Unit of Measure
end of i_output.
Internal table to hold final Output data
data : begin of i_output1 occurs 0,
atinn like cabn-atinn, " Characteric value
werks like mchb-werks, " Plant
matnr like mchb-matnr, " Material Number
atnam like cabn-atnam, " Characteristic
atflv(32) type c, " Char.Value (Ratio)
name1 like t001w-name1, " Plant Description
maktx like makt-maktx, " Material Description
clabs like mchb-clabs, " Stock Value
meins like mara-meins, " Base Unit of Measure
end of i_output1.
Selection screen
selection-screen begin of block b1 with frame title text-001.
select-options: s_werks for t001w-werks obligatory, " Plant
s_lgort for t001l-lgort, " Stor.Location
s_matnr for mara-matnr obligatory, " Material No
s_atinn for cabn-atinn. " Character.
selection-screen end of block b1.
At selection screen
at selection-screen.
Validation of Selection Screen Fields
perform validate_screen.
Start of selection
start-of-selection.
Get the Material and Batch Stock data from MARA and MCHB Tables
perform get_mat_stock_data.
Get the Material Group Text and Plant Name from T023T and T001W Tables
perform get_plant_grp_data.
Append the data into final Output Internal Table after getting the
Characteristic Values data from INOB and AUSP Tables
perform append_final_data.
Processing if the Characteristics contain 'RATIO'
perform collect_ratio.
End-of-Page
end-of-page.
write /1(125) sy-uline.
End of selection
end-of-selection.
if g_exit <> c_flag.
Display the Report Output data
perform display_report.
endif.
Top-of-Page
top-of-page.
Write the Report and Column Headings
perform get_headings.
at line-selection
at line-selection.
if sy-lsind = 1.
perform display_batch.
endif.
Top of page during line-selection
top-of-page during line-selection.
perform heading_seclist.
Form validate_screen
Validation of Selection Screen fields
form validate_screen.
Validation of Plant
clear t001w.
if not s_werks[] is initial.
select werks
into t001w-werks
from t001w
up to 1 rows
where werks in s_werks.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Plant'(002).
endif.
endif.
Validation of Material Number
clear mara.
if not s_matnr[] is initial.
select matnr
into mara-matnr
from mara
up to 1 rows
where matnr in s_matnr.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Material'(003).
endif.
endif.
Validation of Storage Location
clear t001l.
if not s_lgort[] is initial.
select lgort
into t001l-lgort
from t001l
up to 1 rows
where lgort in s_lgort.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Storage Location'(004).
endif.
endif.
Validation of Characteristic Value
clear cabn.
if not s_atinn[] is initial.
select atinn
into cabn-atinn
from cabn
up to 1 rows
where atinn in s_atinn.
endselect.
if sy-subrc <> 0.
message e899 with 'Enter Valid Characteristic Value'(005).
endif.
endif.
Validation of Plant, Material and Storage Location
clear mard.
select matnr werks lgort
into (mard-matnr, mard-werks, mard-lgort)
from mard
up to 1 rows
where matnr in s_matnr and
werks in s_werks and
lgort in s_lgort.
endselect.
if sy-subrc <> 0.
message e899 with 'No Data found for the Selection Criteria'(006).
endif.
endform. "validate_screen
*& Form get_headings
Write the Report and Column Headings
form get_headings.
data: l_repid type sy-repid.
l_repid = sy-repid.
call function 'Y_STANDARD_HEADING'
exporting
repid = l_repid
heading1 = sy-title.
write:/1(125) sy-uline.
format color col_heading on.
write : /1 sy-vline, 2(18) 'Material Number'(008) centered,
20 sy-vline, 21(40) 'Material Description'(011) centered,
61 sy-vline, 62(22) 'Ratio'(009) centered,
84 sy-vline, 85(18) 'Quantity'(010) centered,
103 sy-vline, 104(20) 'Base Unit of Measure'(015) centered,
125 sy-vline.
write:/1(125) sy-uline.
format color off.
endform. "get_headings
*& Form get_mat_stock_data
Get the Material and Batch Stock data from MARA and MCHB Tables
form get_mat_stock_data.
clear: i_mchb,i_output, i_output1.
refresh: i_mchb,i_output, i_output1.
select a~matnr " Material Number
b~werks " Plant
b~lgort " Storage Location
b~charg " Batch Number
b~clabs " Stock Value
a~meins " Base Unit of Measure
into table i_mchb
from mara as a inner join mchb as b
on amatnr eq bmatnr
where b~matnr in s_matnr and
b~werks in s_werks and
b~lgort in s_lgort.
if sy-subrc <> 0.
g_exit = c_flag.
message s899 with 'No Data found for the Selection Criteria'(006).
stop.
endif.
sort i_mchb by matnr werks lgort charg.
endform. " get_mat_stock_data
*& Form get_plant_grp_data
Get the Material Group Text and Plant Name from T023T and T001W
form get_plant_grp_data.
if not i_mchb[] is initial.
Get the Plant Description from t001w Table
clear i_plant.
refresh i_plant.
select werks " Plant
name1 " Name
into table i_plant
from t001w
for all entries in i_mchb
where werks = i_mchb-werks.
Get the Material Description from MAKT Table
clear i_makt.
refresh i_makt.
select matnr " Material number
maktx " Material Description
into table i_makt
from makt
for all entries in i_mchb
where matnr = i_mchb-matnr and
spras = sy-langu.
sort i_plant by werks.
delete adjacent duplicates from i_plant comparing werks.
sort i_makt by matnr.
delete adjacent duplicates from i_makt comparing matnr.
endif.
endform. "form get_plant_grp_data.
*& Form append_final_data
Append the data into final Internal Table
form append_final_data.
data : l_matbatch(28),
l_tabix like sy-tabix.
if not i_mchb[] is initial.
loop at i_mchb.
l_tabix = sy-tabix.
clear l_matbatch.
concatenate i_mchb-matnr i_mchb-charg into l_matbatch.
move-corresponding i_mchb to i_output.
Get the Plant Description from i_plant Table
read table i_plant with key werks = i_mchb-werks binary search.
if sy-subrc = 0.
i_output-name1 = i_plant-name1.
endif.
Get the Material Description from i_makt Table
read table i_makt with key matnr = i_mchb-matnr binary search.
if sy-subrc = 0.
i_output-maktx = i_makt-maktx.
endif.
Get the Characteristic Values data from INOB and AUSP Tables
clear inob.
select single cuobj from inob
into inob-cuobj
where klart = c_klart and
obtab = c_obtab and
objek = l_matbatch.
if sy-subrc = 0.
select objek
atinn
atflv
from ausp
into table i_ausp
where objek = inob-cuobj and
atinn in s_atinn and
klart = c_klart.
sort i_ausp by objek atinn.
loop at i_ausp.
clear cabn.
select single atinn atnam from cabn
into (cabn-atinn,cabn-atnam)
where atinn = i_ausp-atinn.
if sy-subrc = 0.
If the ratio value is between 13-14.99, display 13
if cabn-atnam cs c_ratio.
if i_ausp-atflv between c_13 and c_1499.
i_mchb-atflo = i_ausp-atflv.
i_mchb-atflv = c_13.
If the ratio value is between 15-16.99, display 15
elseif i_ausp-atflv between c_15 and c_1699.
i_mchb-atflo = i_ausp-atflv.
i_mchb-atflv = c_15.
If the ratio value is between 17-18.99, display 17
elseif i_ausp-atflv between c_17 and c_1899.
i_mchb-atflo = i_ausp-atflv.
i_mchb-atflv = c_17.
If the ratio value is between 19-20.99, display 19
elseif i_ausp-atflv between c_19 and c_2099.
i_mchb-atflo = i_ausp-atflv.
i_mchb-atflv = c_19.
If the ratio value is between 21-22.99, display 21
elseif i_ausp-atflv between c_21 and c_2299.
i_mchb-atflo = i_ausp-atflv.
i_mchb-atflv = c_21.
If the ratio value is greater than or equal to 23, display 23
elseif i_ausp-atflv >= c_23.
i_mchb-atflo = i_ausp-atflv.
i_mchb-atflv = c_23.
endif. " Condition for RATIO values
else. " If characteristic does contain RATIO
i_mchb-atflv = i_ausp-atflv.
endif.
i_output-atinn = cabn-atinn.
i_output-atnam = cabn-atnam.
i_output-atflv = i_ausp-atflv.
i_mchb1-matnr = i_mchb-matnr.
i_mchb1-werks = i_mchb-werks.
i_mchb1-lgort = i_mchb-lgort.
i_mchb1-charg = i_mchb-charg.
i_mchb1-clabs = i_mchb-clabs.
i_mchb1-atinn = i_ausp-atinn.
i_mchb1-atflo = i_mchb-atflv.
i_mchb1-atflv = i_ausp-atflv.
append : i_output, i_mchb1.
clear i_mchb1.
modify i_mchb index l_tabix transporting atflo atflv .
endif.
endloop.
endif.
endloop.
endif.
Checking whether the table is filled or not
if not i_output[] is initial.
sort i_output by atinn werks matnr atflv.
else.
g_exit = c_flag.
message s899 with 'No Data found for the Selection Criteria'(006).
endif.
Delete the records where RATIO is less than 13.
delete i_output where atnam cs c_ratio and atflv lt c_13.
endform. "append_final_data
*& Form display_report
Display the Report Output data
form display_report.
data: l_tabix like sy-tabix.
loop at i_output1.
l_tabix = sy-tabix.
At new Characteristic
at new atinn.
read table i_output1 index l_tabix.
format color 1 intensified on.
write: /1 sy-vline, 2(20) 'Characteristic Name:'(007),
23(40) i_output1-atnam,
125 sy-vline.
format color off.
format color 4 intensified on.
write: /1 sy-vline, 2(20) 'Plant Name :'(022),
23(4) i_output1-werks, 29(30) i_output1-name1,
125 sy-vline.
format color off.
write /1(125) sy-uline.
endat.
clear: g_clabs, g_clabs1.
format color col_normal.
write :/1 sy-vline, 2(18) i_output1-matnr,
20 sy-vline, 21(40) i_output1-maktx,
61 sy-vline.
if i_output1-atflv = c_c23.
write: 62(22) c_g23 centered.
else.
shift i_output1-atflv left deleting leading space.
write: 62(22) i_output1-atflv centered.
endif.
write: 84 sy-vline,
103 sy-vline,
110(5) i_output1-meins.
If the quantity value is negative
if i_output1-clabs ge 0.
write: 85(18) i_output1-clabs unit i_mchb-meins,
125 sy-vline.
else.
i_output1-clabs = - i_output1-clabs.
write i_output1-clabs unit i_mchb-meins to g_clabs1.
condense g_clabs1.
concatenate '(' g_clabs1 ')' into g_clabs separated by space.
write: 85(18) g_clabs right-justified,
125 sy-vline.
endif.
format color off.
hide : i_output1.
new-line.
At end of material
at end of matnr.
sum.
move : i_output1-matnr to g_matnr.
format color 3 intensified on.
write /1(125) sy-uline.
write :/1 sy-vline, 2(25) 'Total for Material :'(012),
28(18) g_matnr.
if i_output1-clabs ge 0.
write: 85(18) i_output1-clabs unit i_mchb-meins,
125 sy-vline.
else.
i_output1-clabs = - i_output1-clabs.
write i_output1-clabs unit i_mchb-meins to g_clabs1.
condense g_clabs1.
concatenate '(' g_clabs1 ')' into g_clabs separated by space.
write: 85(18) g_clabs right-justified,
125 sy-vline.
endif.
write: 125 sy-vline.
format color off.
write /1(125) sy-uline.
endat.
At end of plant
at end of werks.
sum.
move : i_output1-werks to g_werks.
format color 3 intensified off.
write :/1 sy-vline, 2(25) 'Total for Plant :'(013),
28(4) g_werks.
if i_output1-clabs ge 0.
write: 85(18) i_output1-clabs unit i_mchb-meins,
125 sy-vline.
else.
i_output1-clabs = - i_output1-clabs.
write i_output1-clabs unit i_mchb-meins to g_clabs1.
condense g_clabs1.
concatenate '(' g_clabs1 ')' into g_clabs separated by space.
write: 85(18) g_clabs right-justified,
125 sy-vline.
endif.
format color off.
write /1(125) sy-uline.
endat.
At end of characteristic
at end of atinn.
read table i_output1 index l_tabix.
sum.
format color 3 intensified on.
write :/1 sy-vline, 2(25) 'Total for Characteristic:'(014),
28(25) i_output1-atnam.
if i_output1-clabs ge 0.
write: 85(18) i_output1-clabs unit i_mchb-meins,
125 sy-vline.
else.
i_output1-clabs = - i_output1-clabs.
write i_output1-clabs unit i_mchb-meins to g_clabs1.
condense g_clabs1.
concatenate '(' g_clabs1 ')' into g_clabs separated by space.
write: 85(18) g_clabs right-justified,
125 sy-vline.
endif.
format color off.
write /1(125) sy-uline.
endat.
endloop.
endform. " display_report
*& Form DISPLAY_BATCH
Display the batch details for the seclected material *
form display_batch.
Get the batch details for the selected material
get cursor field g_cursor.
if g_cursor = c_cursor1 or
g_cursor = c_cursor2 or
g_cursor = c_cursor3 or
g_cursor = c_cursor4 or
g_cursor = c_cursor5 or
g_cursor = c_cursor6.
format color 3.
write: /1 sy-vline,
2(17) 'Material Number :'(020),
20(17) i_output1-matnr,
94 sy-vline.
format color off.
write /1(94) sy-uline.
loop at i_mchb1 where matnr = i_output1-matnr and
atinn = i_output1-atinn and
atflo = i_output1-atflv.
format color col_normal.
shift i_mchb1-charg left deleting leading '0'.
write :/1 sy-vline, 2(16) i_mchb1-lgort centered,
18 sy-vline, 19(17) i_mchb1-charg centered,
36 sy-vline.
if i_output1-atnam cs c_ratio.
write: 37(29) i_mchb1-atflv
exponent 0 decimals 2 centered.
else.
write : 37(29) i_mchb1-atflv
exponent 0 decimals 0 centered.
endif.
write : 66 sy-vline, 67(27) i_mchb1-clabs unit i_mchb-meins,
94 sy-vline.
format color off.
endloop.
write /1(94) sy-uline.
else.
message s899 with 'Invalid cursor position'(016).
exit.
endif.
endform. " DISPLAY_BATCH
*& Form HEADING_SECLIST
Write the Column Headings for Interactive Report
form heading_seclist.
write /1(94) sy-uline.
format color col_heading on.
write :/1 sy-vline, 2(16) 'Storage Location'(021),
18 sy-vline, 19(17) 'Batch Number'(017) centered,
36 sy-vline, 37(29) 'Characteristic Value'(018) centered,
66 sy-vline, 67(27) 'Quantity'(019) centered,
94 sy-vline.
write /1(94) sy-uline.
format color off.
endform. " HEADING_SECLIST
*& Form COLLECT_RATIO
Display the Characteristic ratio data
form collect_ratio.
loop at i_output.
clear g_atinn.
i_output1-atinn = i_output-atinn.
i_output1-atnam = i_output-atnam .
i_output1-werks = i_output-werks.
i_output1-name1 = i_output-name1.
i_output1-matnr = i_output-matnr.
i_output1-maktx = i_output-maktx.
i_output1-clabs = i_output-clabs.
i_output1-meins = i_output-meins.
call function 'CONVERSION_EXIT_ATINN_OUTPUT'
exporting
input = i_output-atinn
importing
output = g_atinn.
if g_atinn cs c_ratio.
If the ratio value is between 13-14.99, display 13
if i_output-atflv between c_13 and c_1499.
i_output1-atflv = c_13.
If the ratio value is between 15-16.99, display 15
elseif i_output-atflv between c_15 and c_1699.
i_output1-atflv = c_15.
If the ratio value is between 17-18.99, display 17
elseif i_output-atflv between c_17 and c_1899.
i_output1-atflv = c_17.
If the ratio value is between 19-20.99, display 19
elseif i_output-atflv between c_19 and c_2099.
i_output1-atflv = c_19.
If the ratio value is between 21-22.99, display 21
elseif i_output-atflv between c_21 and c_2299.
i_output1-atflv = c_21.
If the ratio value is greater than or equal to 23, display 23
elseif i_output-atflv >= c_23.
i_output1-atflv = c_23.
endif.
write i_output1-atflv to i_output1-atflv .
else.
write i_output-atflv to i_output1-atflv exponent 0 decimals 0.
endif.
collect i_output1.
clear i_output1.
endloop.
sort i_output1 by atinn werks matnr atflv.
endform. " COLLECT_RATIO
Reward if useful..
Regards,
Anji
Maybe you are looking for
-
Text message to update LG Ally
I received a text message to get an app from the market to enable the OS update - when I try to install this app I get an error saying that no android phones are associated with my account - I have tried to find where to associate my phone with my go
-
How do I move my iTunes library from my old computer to my new computer?
I currently have a Gateway 500S PC running Windows XP. I also have a 120GB portable WD Passport USB Drive. My iTunes library is on this computer. I have just purchased a Dell XPS 410 PC running Microsoft Windows XP Media Center Edition 2005. My quest
-
EJB 3.0 Constraints Problem
Hi everybody ! Hope someone can help me !! Im really go crazy with this stuff :s... Im Using jdeveloper .... I have 2 Entity Bean called Jiverating and Jiveuser, I creadte them using "Create Entity Bean from Table".... also a Session Bean called Foru
-
Ethernet Cord not being detected by 2008 Macbook Pro
My macbook pro that I purchased late 2008 is no longer seeing that it is connected to an ethernet cord. Other computers can connect to this cord though and work fine. Is this a problem I would have to bring my computer into a Mac store for?
-
Path of the Find-Change Queries/Grep folder in ID CC 2014
Hi, Is this var correct to localize the path of the Find-Change Queries/Grep folder in ID CC 2014? var query_folder = app.scriptPreferences.scriptsFolder.parent.parent + "/Find-Change Queries/Grep/"; Thanks in advance!