Date overlap - sequence split
my source will be like this
ID START DT END DT A B C D
AAAA 01/01/1968 01/01/1997 Y N N N
AAAA 01/01/1968 01/01/1999 N Y N N
AAAA 01/01/1988 01/01/1997 N N Y N
and i need break the sequence as below
ID START DT END DT A B C D
AAAA 01/01/1968 01/01/1988 Y Y N N
AAAA 01/01/1988 01/01/1997 Y Y Y N
AAAA 01/01/1997 01/01/1999 N Y N N
i am with analytical function lag but it is giving one line .
can any one help me how to code this logic
Hi,
user12997203 wrote:
... in the result set i really dont need a record if it is all N's Okay, I understand this much
and the start date of the next record if it has a gap in the dates should be same.You lost me. If we just get rid of the output rows with all 'N's, then we get these results:
expected output:
M_ID STRT_DT END_DT A B C D
BBBB 01-SEP-95 00:00:00 31-AUG-96 00:00:00 Y N N N
BBBB 01-SEP-96 00:00:00 31-DEC-99 00:00:00 Y Y N N
BBBB 01-JUN-00 00:00:00 30-SEP-00 00:00:00 N N Y N
AAAA 01-JAN-68 00:00:00 31-DEC-87 00:00:00 Y Y N N
AAAA 01-JAN-88 00:00:00 31-DEC-96 00:00:00 Y Y Y N
AAAA 01-JAN-97 00:00:00 30-SEP-00 00:00:00 N Y N N
The only complication is that we have to remove the rows with all 'N's after end_dt is computed, because end_dt depends on the dt from the row with all 'N's.
Here's one way to do that:
WITH coverage_change AS
SELECT m_id
, strt_dt AS dt
, CASE WHEN a = 'Y' THEN 1 ELSE 0 END AS a_num
, CASE WHEN b = 'Y' THEN 1 ELSE 0 END AS b_num
, CASE WHEN c = 'Y' THEN 1 ELSE 0 END AS c_num
, CASE WHEN d = 'Y' THEN 1 ELSE 0 END AS d_num
FROM test_ovlp
UNION ALL
SELECT m_id
, end_dt AS dt
, CASE WHEN a = 'Y' THEN -1 ELSE 0 END AS a_num
, CASE WHEN b = 'Y' THEN -1 ELSE 0 END AS b_num
, CASE WHEN c = 'Y' THEN -1 ELSE 0 END AS c_num
, CASE WHEN D = 'Y' THEN -1 ELSE 0 END AS D_NUM
FROM test_ovlp
, net_coverage AS
SELECT DISTINCT
m_id
, dt
, SUM (A_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS a_net
, SUM (B_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS b_net
, SUM (C_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS c_net
, SUM (D_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS d_net
, DENSE_RANK () OVER (PARTITION BY M_ID ORDER BY dt DESC) AS from_end
, MAX (dt) OVER () AS max_dt
FROM coverage_change
, got_end_dt AS
SELECT m_id
, dt AS strt_dt
, LEAD ( dt - 1
, 1
, max_dt
) OVER ( PARTITION BY m_id
ORDER BY dt
AS end_dt
, CASE WHEN a_net > 0 THEN 'Y' ELSE 'N' END AS a
, CASE WHEN b_net > 0 THEN 'Y' ELSE 'N' END AS b
, CASE WHEN c_net > 0 THEN 'Y' ELSE 'N' END AS c
, CASE WHEN d_net > 0 THEN 'Y' ELSE 'N' END AS d
FROM net_coverage
WHERE from_end > 1
SELECT m_id, strt_dt, end_dt
, a, b, c, d
FROM got_end_dt
WHERE 'Y' IN (a, b, c, d)
ORDER BY m_id DESC
, strt_dt;The first 2 sub-queries, coverage_change and net_coverage, are exactly the same as in my last message.
What used to be the main query (except for the ORDER BY clause) is now the sub-query called got_end_dt.
The new main query just excludes the all-'N' rows, and sorts.
If this is really what you need to do, then the query can probably be simplified a little. I put some tricky code into net_coverage to avoid another sub-query, but now, since we need another sub-query anyway (to remove the all-'N' rows) there might be a better way.
Similar Messages
-
Re: Date overlap - sequence split
In refrence to my earlier post Re: Date overlap - sequence split
i would like to make changes to how the end_dt is being calculated.
original code by Frank:
WITH coverage_change AS
SELECT m_id
, strt_dt AS dt
, CASE WHEN a = 'Y' THEN 1 ELSE 0 END AS a_num
, CASE WHEN b = 'Y' THEN 1 ELSE 0 END AS b_num
, CASE WHEN c = 'Y' THEN 1 ELSE 0 END AS c_num
, CASE WHEN d = 'Y' THEN 1 ELSE 0 END AS d_num
FROM test_ovlp
UNION ALL
SELECT m_id
, end_dt AS dt
, CASE WHEN a = 'Y' THEN -1 ELSE 0 END AS a_num
, CASE WHEN b = 'Y' THEN -1 ELSE 0 END AS b_num
, CASE WHEN c = 'Y' THEN -1 ELSE 0 END AS c_num
, CASE WHEN D = 'Y' THEN -1 ELSE 0 END AS D_NUM
FROM test_ovlp
, net_coverage AS
SELECT DISTINCT
m_id
, dt
, SUM (A_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS a_net
, SUM (B_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS b_net
, SUM (C_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS c_net
, SUM (D_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS d_net
, DENSE_RANK () OVER (PARTITION BY M_ID ORDER BY dt DESC) AS from_end
, MAX (dt) OVER () AS max_dt
FROM coverage_change
, got_end_dt AS
SELECT m_id
, dt AS strt_dt
, LEAD ( dt - 1
, 1
, max_dt
) OVER ( PARTITION BY m_id
ORDER BY dt
AS end_dt
, CASE WHEN a_net > 0 THEN 'Y' ELSE 'N' END AS a
, CASE WHEN b_net > 0 THEN 'Y' ELSE 'N' END AS b
, CASE WHEN c_net > 0 THEN 'Y' ELSE 'N' END AS c
, CASE WHEN d_net > 0 THEN 'Y' ELSE 'N' END AS d
FROM net_coverage
WHERE from_end > 1
SELECT m_id, strt_dt, end_dt
, a, b, c, d
FROM got_end_dt
WHERE 'Y' IN (a, b, c, d)
ORDER BY m_id DESC
, strt_dt;Instead of calculating the end dt as 1 day less than start date of next record,
I would calculate the start date of the next record as end_dt +1 some thing like this
WITH coverage_change AS
SELECT m_id
, strt_dt AS dt
, CASE WHEN a = 'Y' THEN 1 ELSE 0 END AS a_num
, CASE WHEN b = 'Y' THEN 1 ELSE 0 END AS b_num
, CASE WHEN c = 'Y' THEN 1 ELSE 0 END AS c_num
, CASE WHEN d = 'Y' THEN 1 ELSE 0 END AS d_num
FROM test_ovlp
UNION ALL
SELECT m_id
, end_dt AS dt
, CASE WHEN a = 'Y' THEN -1 ELSE 0 END AS a_num
, CASE WHEN b = 'Y' THEN -1 ELSE 0 END AS b_num
, CASE WHEN c = 'Y' THEN -1 ELSE 0 END AS c_num
, CASE WHEN D = 'Y' THEN -1 ELSE 0 END AS D_NUM
FROM test_ovlp
, net_coverage AS
SELECT DISTINCT
m_id
, dt
, SUM (A_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS a_net
, SUM (B_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS b_net
, SUM (C_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS c_net
, SUM (D_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS d_net
, DENSE_RANK () OVER (PARTITION BY M_ID ORDER BY dt DESC) AS from_end
, MAX (dt) OVER () AS max_dt
FROM coverage_change
, got_end_dt AS
SELECT m_id
,case when row_number() over (partition by m_id order by dt asc) =1 then dt else lead ( dt + 1,1,max_dt ) OVER ( PARTITION BY m_id ORDER BY dt ) end as new_start_dt --new way of calculating start_dt
, case when row_number() over (partition by m_id order by dt asc) =1 then LEAD ( dt , 1 , max_dt ) OVER ( PARTITION BY m_id order by dt ) else dt end as new_end_dt,
, CASE WHEN a_net > 0 THEN 'Y' ELSE 'N' END AS a
, CASE WHEN b_net > 0 THEN 'Y' ELSE 'N' END AS b
, CASE WHEN c_net > 0 THEN 'Y' ELSE 'N' END AS c
, CASE WHEN d_net > 0 THEN 'Y' ELSE 'N' END AS d
FROM net_coverage
WHERE from_end > 1
SELECT m_id, new_start_dt, new_end_dt
, a, b, c, d
FROM got_end_dt
WHERE 'Y' IN (a, b, c, d)
ORDER BY m_id DESC
, strt_dt;but its not giving me correct value for start_dt for last record as i am using this lead ( dt + 1,1,max_dt ) in the start_dt calculation.
is there any alternate way to do thisHi,
user12997203 wrote:
In refrence to my earlier post Re: Date overlap - sequence split
i would like to make changes to how the end_dt is being calculated.Do you want to use the same sample data as the previous thread?
... Instead of calculating the end dt as 1 day less than start date of next record,Always post the output you want from the sample data.
I would calculate the start date of the next record as end_dt +1 some thing like thisDo you want start_date derved from the next (that is, later) row, or should it be derived from the previous (that is, earlier) row, when there is one?
WITH coverage_change AS
SELECT m_id
, strt_dt AS dt
, CASE WHEN a = 'Y' THEN 1 ELSE 0 END AS a_num
, CASE WHEN b = 'Y' THEN 1 ELSE 0 END AS b_num
, CASE WHEN c = 'Y' THEN 1 ELSE 0 END AS c_num
, CASE WHEN d = 'Y' THEN 1 ELSE 0 END AS d_num
FROM test_ovlp
UNION ALL
SELECT m_id
, end_dt AS dt
, CASE WHEN a = 'Y' THEN -1 ELSE 0 END AS a_num
, CASE WHEN b = 'Y' THEN -1 ELSE 0 END AS b_num
, CASE WHEN c = 'Y' THEN -1 ELSE 0 END AS c_num
, CASE WHEN D = 'Y' THEN -1 ELSE 0 END AS D_NUM
FROM test_ovlp
, net_coverage AS
SELECT DISTINCT
m_id
, dt
, SUM (A_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS a_net
, SUM (B_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS b_net
, SUM (C_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS c_net
, SUM (D_NUM) OVER (PARTITION BY M_ID ORDER BY DT) AS d_net
, DENSE_RANK () OVER (PARTITION BY M_ID ORDER BY dt DESC) AS from_end
, MAX (dt) OVER () AS max_dt
FROM coverage_change
, got_end_dt AS
SELECT m_id
,case when row_number() over (partition by m_id order by dt asc) =1 then dt else lead ( dt + 1,1,max_dt ) OVER ( PARTITION BY m_id ORDER BY dt ) end as new_start_dt --new way of calculating start_dt
, case when row_number() over (partition by m_id order by dt asc) =1 then LEAD ( dt , 1 , max_dt ) OVER ( PARTITION BY m_id order by dt ) else dt end as new_end_dt, You don't want a comma at the end of the line above, since the line below starts with a comma.
, CASE WHEN a_net > 0 THEN 'Y' ELSE 'N' END AS a
, CASE WHEN b_net > 0 THEN 'Y' ELSE 'N' END AS b
, CASE WHEN c_net > 0 THEN 'Y' ELSE 'N' END AS c
, CASE WHEN d_net > 0 THEN 'Y' ELSE 'N' END AS d
FROM net_coverage
WHERE from_end > 1
SELECT m_id, new_start_dt, new_end_dt
, a, b, c, d
FROM got_end_dt
WHERE 'Y' IN (a, b, c, d)
ORDER BY m_id DESC
, strt_dt;There's no column called strt_dt in got_end_dt. Did you mean new_start_dt?
but its not giving me correct value for start_dt for last record as i am using this lead ( dt + 1,1,max_dt ) in the start_dt calculation.
is there any alternate way to do thisIf you fix the 2 errors mentioned above, the output (using the sample data from Feb. 21) is:
M_ID NEW_START_D NEW_END_DT A B C D
BBBB 01-Sep-1995 01-Sep-1996 Y N N N
BBBB 01-Jan-2000 01-Sep-1996 Y Y N N
BBBB 30-Sep-2000 01-Jun-2000 N N Y N
AAAA 01-Jan-1968 01-Jan-1988 Y Y N N
AAAA 02-Jan-1997 01-Jan-1988 Y Y Y N
AAAA 30-Sep-2000 01-Jan-1997 N Y N NIs that what you want? If not, post the correct results. -
Dear All,
What is Overlapping and splitting, where do i assign?Now
Splitting
An operation is split if it is carried out on several machines or by several persons at the same time (see figure).
Splitting an operation has the following effects on the operation dates:
The processing time/execution time becomes shorter.
Setup and teardown must be carried out more than once for the operation
http://help.sap.com/saphelp_47x200/HELPDATA/EN/7e/d419b7455911d189400000e8323c4f/frameset.htm
Overlapping
To reduce the lead time of a routing or production order you can overlap operations. This means that an operation starts before the previous operation has finished
You can define for each individual operation whether it should overlap with the next consecutive operation and in what way. To do this you can set the following indicators:
Required overlapping
This means the operations always overlap
Optional overlapping
This means the operations overlap if scheduling uses a reduction level that allows overlapping
Flow manufacturing
This means the system extends the lead time of all operations, that overlap using flow manufacturing, to the same length as the lead time of the longest of these operations. As with required overlapping, the operations always overlap.
For every type of overlapping you can
Define a minimum overlap time which only allows overlapping after a particular minimum limit has been reached.
Define a minimum send-ahead quantity to ensure that the operation is performed for a particular minimum quantity of the material to be produced, before the next operation starts.
http://help.sap.com/saphelp_47x200/HELPDATA/EN/8b/67221404f111d293560000e8323492/frameset.htm
pavan -
Hi Everyone,
Can you please help me solve this issue? I have dates overlapping and with gaps. I shouldn't have any overlaps, so I need to split them as below.
Here is my test data.
create table test_dates (
prov_id varchar2(20 byte),
start_date date,
end_date date,
attribute_value varchar2(10 byte)
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-01-01', date '2010-01-31', '1', 'A');
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-02-01', date '2010-02-28', '1', 'B');
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-04-01', date '2010-04-30', '1', 'C');
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-04-15', date '2010-05-31', '1', 'D');
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-07-01', date '2010-08-31', '1', 'E');
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-07-01', date '2010-07-31', '1', 'F');
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-08-15', date '2010-08-01', '1', 'G');
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-09-01', date '2010-12-31', '1', 'H');
commit;
Expected Results:
ID
START
END
1
1/1/2010
1/31/2010
1
2/1/2010
2/28/2010
1
4/1/2010
4/14/2010
1
4/15/2010
4/30/2010
1
5/1/2010
5/31/2010
1
7/1/2010
7/31/2010
1
8/1/2010
8/31/2010
1
9/1/2010
12/31/2010Hi,
Depending on your requirements:
WITH change_points AS
SELECT prov_id
, change_date
, change_type
, SUM (change_type) OVER ( PARTITION BY prov_id
ORDER BY change_date
) AS active_cnt
, LEAD (change_date) OVER ( PARTITION BY prov_id
ORDER BY change_date
) AS next_change_date
, LEAD (change_type) OVER ( PARTITION BY prov_id
ORDER BY change_date
) AS next_change_type
FROM test_dates
UNPIVOT ( change_date
FOR change_type IN ( start_date AS 1
, end_date AS -1
SELECT prov_id
, change_date + CASE
WHEN change_type = 1
THEN 0
ELSE 1
END AS start_date
, next_change_date - CASE
WHEN next_change_type = -1
THEN 0
ELSE 1
END AS end_date
FROM change_points
WHERE active_cnt > 0
AND change_date < next_change_date
ORDER BY prov_id
, start_date
Thanks for posting the sample data; that's helpful.
It also very helpful to explain how you get the results you want from the given data. For example, what role does prov_id play in this problem? (It's hard to guess when every row in the sample data has the same value for prov_id.) Also, sometimes, the start_dates or end_dates in the output are not exactly the dates in the table; sometimes they are 1 day earlier or later. How do you decide which?
In the sample data, start_date can be later than end _date, for example:
insert into test_dates(start_date, end_date, prov_id, attribute_value) values (date '2010-08-15', date '2010-08-01', '1', 'G');
Was that a mistake? -
Error "User Expiry Date Overlaps" while login into system
Dear Consultants,
A strange problem started occurring in our System.When we are trying to
login in SAP system from any user apart from SAP*, after giving user name
and password it gives error:- "user expiry date overlaps".
I want to mention here our both licenses NetWeaver_ORA & Maintenance_ORAare still valid. and we are also able to login only from SAP* login
System - SAP ECC with EHP5
O.S - Linux RHEL 5.4 X86_64
Kernel - 720
Regards
Gagan sharma
Basis ConsultantSystem Time and Server Time is Exactly same
System time 21.02.2012 19:32:01 INDIA
Server Time Tue Feb 21 19:32:29 IST 2012
I also want to mention here this problem started occurring immediately without doing any change on System or Server Side
Regards
Gagan sharma -
Hi guys, how I can see with one query if I got date overlapped? That's the scenario:
Create table tabletest ( iddd int, datefrom datetime2, dateto datetime2)
insert into tabletest values (1, '2014-01-01', '2014-02-06'),
(2, '2014-01-01', '2014-03-15'),
(1, '2014-02-05', '2014-08-01'),
(2, '2014-03-16', '2015-01-01')
For example in this case the n1 is overlapped in terms of date 2014-02-05 and 2014-02-06...SELECT *
FROM tabletest LT JOIN tabletest RT ON LT.iddd=RT.iddd AND LT.datefrom<>RT.datefrom AND LT.dateto<>RT.dateto
WHERE RT.datefrom<=LT.dateto AND RT.datefrom>=LT.datefrom
Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
The climb is all there is. -
HCM Master data upload sequence & best practices
Experts,
What would be the best method and recommended sequence to upload HCM master data into the below infotypes?
0,1,2,3 6,7,8,9 207,208,209,210 (payroll)
21,167,168,169,170,171 and 3.series (Benefits)
PA0795
PA2006
PA2012
PBO795
T529T
T530T
Please advice.
Thanks in advance.
NWHi,
The best method to mass upload is LSMW
the sequence will be
First you need to create the master data so the Action tables need to be configured first
T529T
T530T
also other related PA config need to be completed
Then when you will start uploading data the sequence will be
0, 1, 2 , 6, 7, 8, 9 , 207, 208, 209, 210, 21, 171, 167, 168 169, 170, 2006, 2012, 795
The benefits features (BAREA, BENGR, BSTAT) also need to be configured with all other benefits related config prior to uploading benefits information
Some other imp. features like LGMST, TARIF, ABKRS, SCHKZ etc.. also need to be configured prior to uploading the employee master data.
Hope this will be of help
Regards,
Guds -
Data loading sequence for 0FIGL_014
Hi experts,
Can you explain or brief the data loading sequence for 0FIGL_014?
Regards.
PrasadHi,
Following is my system configuration information
Software Component Release Level Highest support Short Description
SAP_BASIS 620 0058 SAPKB62058 SAP Basis Component
SAP_ABA 620 0058 SAPKA62058 Cross Application Component
SAP_APPL 470 0025 SAPKH47025 Logistics and Accounting
SAP_HR 470 0030 SAPKE47030 Human Resources
With the above configuration in R/3, I am not able to find the data source 0FI_GL_14.
Can you please let me know what package to install and how to install?
Regards.
Prasad -
Overlapping and splitting in routing master.
Hi...
I'm setting the PP routing master and using the capacity requirement planning.
Do you have any definition or document about the overlapping and splitting in routing master ?
In part of overlapping. There are the options
- Required overlapping, Optional overlapping, Continuous flow prod
Could you please explain how does the system calculate the lead time in production when I use the different option together with Min.overlap time or Min. send-ahead qty ?
Best Regards
JNHi,
Refer the SAP help given below it comes with an example & should clarify your query
http://help.sap.com/erp2005_ehp_04/helpdata/EN/8b/67221404f111d293560000e8323492/content.htm
Regards,
Vivek -
Need help! Can't validate date overlaps for a tabular column
Hello all,
The validation I created to validate whether new or updates rows does not overlap with any records in the table isn't working.
The columns are StartDt and EndDt
Validation Type: NOT EXISTS
Validation expresion:
select 1
from sample S
WHERE S.STARTDT BETWEEN :STARTDT AND :ENDDT
OR(S.ENDDT BETWEEN :STARTDT AND :ENDDT)
or (S.STARTDT <= :STARTDT and S.ENDDT >= :ENDDT)
or (:STARTDT <= S.STARTDT and :ENDDT >= S.ENDDT)
Error Message:
Times overlap
When Buttons pressed
-Select Button-
The validation works if a new row or updated row overlaps any existing start and end date records but it doesn't work if I update startdate and end date rows that doesn't overlap existing date times
Example:
TABLE DISPLAYS THE FOLLOWING RECORDS
NAME START DATE END DATE
TEST 1/1/2012 12/31/2012
If I update the rows to the following values, I receive an error message (although those values don't overlap any records in the table)
NAME START DATE END DATE
TEST 6/1/2012 10/30/2012
Any ideas? Do I need to change my code?
Click the link to view the answer to this question. Need help! Can't validate date overlaps for a tabular column
Message was edited by: CharlieMackLogic for date range overlap testing only requires two conditions in the WHERE clause:
ORACLE-BASE - Overlapping Date Ranges
WHERE S.STARTDT <= :ENDDT AND S.ENDDT >= :STARTDT -- TRUE for ranges that overlap
It looks a little odd, but, if you scribble out a 'logic table', it makes sense.
Condition
A.start <= B.end
A.end >= B.start
A__A B--B
true
false
A__B=A--B
true
true
A__B==B__A
true
true
B--A==B__A
true
true
B--B A__A
false
true
MK -
How to increment the date using sequence?
how to increment the date using sequence?
01-jan-10
02-jan-10
30-jan-10794244 wrote:
how to increment the date using sequence?
01-jan-10
02-jan-10
30-jan-10This doesn't look like a task where a sequence is usefull.
A sequence is a number generator that guarantees that multiple sessions will all get a different number.
Even if the sequence is fetched for differnent users (=sessions) that the same time.
This in turn means that the value returned by the sequence will depend on actions done in other sessions.
Typical task: create a new unique primary key number. The number MUST be different in all sessions.
In your case I guess that the same logic should work regardless of the session that executes it. So you need a "number generator" that works indepented from other session values. There are several ways to create such a numbered list.
The basic idea is to create a select statement that simply returns as many rows as you need. And then use ROWNUM as the number generator. Examples how to do this have already been given. LEVEL works also in hierarchical queries.
if my interpretation of your requirement is right, then all answers that really used a sequence seem to be wrong. Even if the output looks ok. At best they are just slow. To create new sequence values is a complex task and the database needs a little time for all the synchonization issues that come with it. At worst it will have gaps in the sequence because other sessions used the same value while the numbers were created.
Edited by: Sven W. on Sep 20, 2010 2:08 PM -
How to check date overlapping?
Hi,
What is the easiest/simplest way to check date overlapping?
I have date_start1, date_end1, date_start2 and date_end2, and I'd like to know if they're overlapping or not.
I searched for FM OVERLAP, but so far couldn't find one, which would help.
I've found FM TB_TIME_INTERVAL_OVERLAP, which looked promising, however I couldn't make it work, maybe I used a wrong calculation method /I tried several/.
Any idea?
Thanks in advance,
PeterHi All,
You can use the FM to validate the date overlap when from date and to date in which the date ranges have been given.
<i> CALL FUNCTION <b>'GM_VALIDATE_DATE_RANGE'</b>
EXPORTING
i_from_date = sy-datum
i_to_date = c_enddt "'99991231'
TABLES
t_daterange = p_dates
EXCEPTIONS
ranges_overlap = 1
range_has_holes = 2
continuous_but_excessive = 3
OTHERS = 4
erro_message = 99.
CASE sy-subrc.
WHEN '0'.
WHEN '1'.
MESSAGE e004(z_common) DISPLAY LIKE 'E'
WITH 'Date range should not overlap with Existing One'(003).
WHEN '2'.
MESSAGE e004(z_common) DISPLAY LIKE 'E'
WITH 'Date range should not overlap with Existing One'(003).
ENDCASE.</i>
<b>OR</b>
Only for date ranges validation no matter whatever the date ranges are given.
you can use the Z function module from the above one mentioned.
<b><i>FUNCTION zgm_validate_date_range.
""Local Interface:
*" IMPORTING
*" REFERENCE(I_FROM_DATE) TYPE DATS OPTIONAL
*" REFERENCE(I_TO_DATE) TYPE DATS OPTIONAL
*" TABLES
*" T_DATERANGE STRUCTURE GMDATERANGE
*" EXCEPTIONS
*" RANGES_OVERLAP
*" RANGE_HAS_HOLES
*" CONTINUOUS_BUT_EXCESSIVE
DATA: i TYPE i,
l_next_date LIKE sy-datum,
l_first_date LIKE sy-datum,
l_last_date LIKE sy-datum,
no_days TYPE tfmatage,
cnt_next TYPE i,
w_daterange TYPE gmdaterange.
DESCRIBE TABLE t_daterange LINES i.
IF i > 1.
SORT t_daterange BY from_date.
First determine if the slices are continuous and have
no gaps.
LOOP AT t_daterange.
cnt_next = sy-tabix + 1.
IF sy-tabix > 1. " not first record
IF t_daterange-from_date <= l_next_date.
RAISE ranges_overlap.
ENDIF.
IF t_daterange-to_date <= l_next_date.
RAISE range_has_holes.
ENDIF.
ELSE.
save first date
MOVE t_daterange-from_date TO l_first_date.
ENDIF.
update end of range
MOVE t_daterange-to_date TO : l_last_date,
l_next_date.
ENDLOOP.
ENDIF.
ENDFUNCTION.</i></b>
Thanks
Ramesh Babu N -
Data Migration: Sequence Check
i have a database (target) that i am transfering data to from another database (source)
I need to write a script to check if the sequence on the target will be ok...in a sense, I need to check the max value of the target dababase sequence and see if it is ok to add the new data.
i cant transfer data over if the sequence numbers overlap...like if i have a sequence # of 200 on the source and target...we run into problems. is this logic correct?
how do i write this sql check?
any help would be wonderful. im a novice.
thanks.It may be easier to ensure up front that the sequences won't overlap. i.e.
CREATE SEQUENCE system1_seq
START WITH 1
INCREMENT BY 2
CACHE 100
CREATE SEQUENCE system2_seq
START WITH 2
INCREMENT BY 2
CACHE 100This way, one system will generate odd numbers, the other will generate even numbers, and you won't have to worry about overlaps.
Alternately, you can add a source id to the primary key on the target system or you can renumber the rows (obviously fixing the relationships) when the data is migrated.
Justin
Justin -
Asset takeover date and asset split
Hi All,
I have an asset X with NBV of say 2000 (APC 5000 and Acc Dep 3000). This is currently available in system as one single asset.
The problem is u2013 above asset is in fact a sum of many small assets for which useful life is different and NBV is different (we are tracking it outside SAP as of now)
Say Asset 1..with APC of 300, Acc Dep as 200 and NBV of 100 u2026total useful life is 10 yrs and remaining useful life is 2 yrs
Asset 2..with APC of 400, Acc Dep as 250 and NBV of 150 u2026total useful life is 10 yrs and remaining useful life is 4 yrs
Similarly I have different assets which add up to asset X as mentioned above.
Asset take over date is 31.12.2009 (We follow Jan to Dec year). We have gone live in mid 2010.
I would like to bring those assets into Sap now. I mean make the adjustments now u2013 split the asset X to different assets. (We did not calculate dep for asset X until now from go u2013 live).
We want to the calculate dep for newly created small assets from month May, 2011.
Could someone help me with the correct process to be followed.
One option I am thing about is u2013
1) Scrap the asset X (40 posting key will be posted to u2018asset disposal accountu2019 (P&L Account))
2) Make co code status to u20182u2019 and make changes to take over date.
3) Create new assets (in AS91) for all small assets with their useful life (Say for asset 1 u2013 I will keep total useful life as 10 yrs and remaining useful life as 2 yrs
4) In takeover values in AS91 u2013 I will put APC as 300 and Acc Dep as 200 for asset 1.
5) Make an entry through OASV for total APC, Acc Dep and remaining value to u2018asset disposal accountu2019 (P&L Account u2013 which is posted in point 1)
6) Put the co code back to active status u20180u2019.
My Questions u2013
1) Can I follow above method or is there any other easy way?
2) What should be the takeover date? Is it 31.12.2010?
3) Should I change the takeover date back to 31.12.2009 after my transactions are complete or can I leave it as 31.12.2010? Its affects.
4) In OASV can I make posting to u2018asset disposal accountu2019 which is a P&L account? (System might ask for cost center which I thought I can provide it in OKB9).
5) Will the above process effect my current assets in SAP? I mean I do not want to spoil the current set up in system.
Thanks in advance for the patient reading and providing solution.
Regards,
KumarHi Kumar,
You Specify the transfer date for the asset data transfer. This date derermineds the status of posting to be used for the transfer. Posting up to this date will be included in the transfer. This specification also determines whether you want to perform the transfer during fiscal year ( with transfer of posted transcation/depreciation in the current fiscal year) or at the end of the fiscal year (with out transctions).
If the trasfer date is not the last day if the fiscal year ( according to the fiscal year variant FI), the system interprets this as transfer during the fiscal year. The system cannot transfer any historical transactions. It can only transfer cumulative values from the end of the last fiscal year, and the transctions in the current fiscal year (This is only possible for the transfer during the fiscal year).
Ex....
Transfer date - December 31, 2009
Last Closed fiscal year 2009
Specify the take over date as 31.12.2009. If the company gone live with SAP on 01.01.2010.
I hope above note will clear your doubt.
Regards,
Narendra Kumar, -
I am scanning in old slides and negatives (from the 1960s and 70s), and I want to get the resulting "events" in sequence from when the photos were taken, rather than when they were scanned. So I have been changing the dates of the photos, and previously this resulted in the associated event moving to the proper sequence. This definitely worked a month or so ago, both with prints scanned in on a flat-bed scanner, and also with slides and negatives scanned with a Veho scanner. That was faulty, however, and so it has been replaced with a Plustek 7500i scanner, using SilverFast scanning software, and importing the resulting images into iPhoto. I have recently tried to change the dates of the resulting events, and it doesn't seem to work as it used to. There has been an update to iPhoto 9.1.3 since my earlier success.
Take for example one event, CS73A. Hovering over the event in the "All events" display gives dates of 1 Apr 2011 to 2 Apr 2011; these are the dates the slides were scanned in. If I open the event and choose the Info tab, it gives the event date as 02/03/1973 (which is the approximate date that I changed it to). I had done a batch change on the event this time, so the date and time on the first slide is 2 March 1973 09:30:48. Each successive slide is 1 minute later, and the last is 2 March 1973 10:08:48 (38 slides). I asked for the dates in the files to be changed as well.
I don't know what I'm doing that's different from before. The only things I can think of are (a) something has changed in the iPhoto update, or (b) the SilverFast software stores the scanning date in some part of the EXIF that iPhoto can read but not change. I don't have tools to examine the EXIF unfortunately.
What to do?Chris, I have run into the same problem.
Try this:
Open an event with more than one photo in it.
Adjust the date of one or more photos. The event date does not update.
Delete any one photo. The event date now updates to match the above date change.
Undo the delete photo. The event date stays matching.
Change the date of any photo again. The event date updates now every time.
If you close the event and reopen it, you have to start over with the delete one photo thing.
I don't understand it but it works here.
I also have had the problem of events not sorting themselves in order of the dates when VIEW, SORT, BY DATE is selected. This seems to affect only the events were photo date changes had been made. Using the delete thing seems to keep the events in order.
Another funny thing: When I put photos into iMovie the times in iMovie show as 7 hours off the photo time.
I think Apple owes us an update to iLife!
Maybe you are looking for
-
How do I execute a vi in the background and pass it starup pramaters?
I would like to create a queue and pass it's handle to a subvi that runs in the background. I see several examples of running a vi in the background using the vi server, but I could not find any examples of running in the background and passing start
-
At the time of BOM creation We choose copy from.After that which material ,which plant needs to be copied how will we come to know about this?Do we need do to select all the items from the BOM of source material.After copying items of the source mat
-
CFGRID Binding Not Working in CF9
I'm having trouble with a CFGRID that works fine in CF8, but when trying to run it on CF9 I get no results and it's like the grid is loading forever. I did have to remove the cfajaximport I was using to get it to load at all, which is does now with t
-
Find and Replace file renaming
It would be nice to be able to find, lets say, "IMG_" in a filename and replace the text with "Smith-". If there's already an easy way to do this, please let me know.
-
Do ISE 3355 and 3315 support etherchannel configuration? And I see that they have four gigabit ethernet NICs, but two of the NICs need add-on cards? Does that mean that only two (out of the available four NICs) are ready to be used without installing