2010 Aug 10 4:42 AM
Hi ,
I need a basic programming help. I am not able to get a proper solution for this.
I have a requirement to split the records on the basis of date.
Input:
From date TO DATE ID Amount
01/01/2009 03/01/2010 1 200
01/01/2010 12/31/2010 2 200
10/01/2010 12/31/2011 3 300
Output Exoected:
From date TO DATE ID Amount
01/01/2009 12/31/2009 1 200
01/01/2010 03/01/2010 1 200
01/01/2010 03/01/2010 2 200
03/02/2010 09/30/2010 2 200
10/01/2010 12/31/2010 2 200
10/01/2010 12/31/2010 3 300
01/01/2011 12/31/2011 3 300
I need to split my input records in such a way that i split the overlapping records. Can any one suggest me a logic to get
Edited by: Muhammed Ansari Abubekkar on Aug 10, 2010 9:12 AM
Hi ,
I need a basic programming help. I am not able to get a proper solution for this.
I have a requirement to split the records on the basis of date.
Input:
From date TO DATE ID Amount
01/01/2009 03/01/2010 1 200
01/01/2010 12/31/2010 2 200
10/01/2010 12/31/2011 3 300
Output Exoected:
From date TO DATE ID Amount
01/01/2009 12/31/2009 1 200
01/01/2010 03/01/2010 1 200
01/01/2010 03/01/2010 2 200
03/02/2010 09/30/2010 2 200
10/01/2010 12/31/2010 2 200
10/01/2010 12/31/2010 3 300
01/01/2011 12/31/2011 3 300
I need to split my input records in such a way that i split the overlapping records. Can any one suggest me a logic to get
Edited by: Muhammed Ansari Abubekkar on Aug 10, 2010 9:12 AM
2010 Aug 10 7:51 AM
Hi,
Check the below code.
TYPES : BEGIN OF y_struc,
date_fr TYPE datum,
date_to TYPE datum,
id TYPE i,
amnt TYPE i,
END OF y_struc.
DATA : it_tab TYPE STANDARD TABLE OF y_struc
, it_final TYPE STANDARD TABLE OF y_struc
, it_tab1 TYPE STANDARD TABLE OF y_struc
.
DATA : wa_tab TYPE y_struc
, w_tabix LIKE sy-tabix
, e_tab TYPE y_struc
.
FIELD-SYMBOLS : <fs_tab> TYPE y_struc.
*01/01/2009 03/01/2010 1 200
*01/01/2010 12/31/2010 2 200
*10/01/2010 12/31/2011 3 300
wa_tab-date_fr = '20090101'.
wa_tab-date_to = '20100301'.
wa_tab-id = 1.
wa_tab-amnt = 200.
APPEND wa_tab TO it_tab.
wa_tab-date_fr = '20100101'.
wa_tab-date_to = '20101231'.
wa_tab-id = 2.
wa_tab-amnt = 200.
APPEND wa_tab TO it_tab.
wa_tab-date_fr = '20101001'.
wa_tab-date_to = '20111231'.
wa_tab-id = 3.
wa_tab-amnt = 300.
APPEND wa_tab TO it_tab.
SORT it_tab BY date_fr ASCENDING.
MOVE it_tab[] TO it_tab1[].remaining code will be continues in the next post
Edited by: Senthil Kumar on Aug 10, 2010 12:31 PM
2010 Aug 10 8:11 AM
Continues......
LOOP AT it_tab ASSIGNING <fs_tab>.
w_tabix = sy-tabix.
LOOP AT it_tab1 INTO wa_tab.
IF sy-tabix EQ w_tabix.
CONTINUE.
ELSEIF sy-tabix GT w_tabix.
IF wa_tab-date_fr GT <fs_tab>-date_fr
AND wa_tab-date_fr LT <fs_tab>-date_to.
MOVE <fs_tab> TO e_tab.
e_tab-date_to = wa_tab-date_fr - 1.
APPEND e_tab TO it_final.
MOVE <fs_tab> TO e_tab.
e_tab-date_fr = wa_tab-date_fr.
APPEND e_tab TO it_final.
ENDIF.
ELSE.
IF <fs_tab>-date_fr GT wa_tab-date_fr
AND <fs_tab>-date_fr LT wa_tab-date_to.
MOVE <fs_tab> TO e_tab.
e_tab-date_to = wa_tab-date_to.
APPEND e_tab TO it_final.
MOVE <fs_tab> TO e_tab.
e_tab-date_fr = wa_tab-date_to + 1.
APPEND e_tab TO it_final.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.I tried posting the whole code in a single post but displaying in improper manner. I hope this post will help you
Hi, Is it solved your issue?
Edited by: Senthil Kumar on Aug 11, 2010 3:55 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |