Skip to Content
author's profile photo Former Member
Former Member

Transformation

Hi,

I have a requirement. basically they all missing miles. i wrote a routine its work fine but some records are not comeing right and that records are overlapping records means.

For example i have functional location lenght is 0 to 10

day Milesfr Milesto

1 1 4

2 0 5

2 2 6

3 6 7

4 8 10

so missing miles is 7 to 8, but here is the problem is i can not correctly compare miles day 1 and day 2 actuall miles are coverd 0 to 5.

all records could be the same day.

my abap is not good please help me how to change the following code.

Thanks,

**********************************

FORM MISSING_MILES tables p_copy_it_floc_temp_1
p_copy_it_floc_temp
USING P_zodrfdin_calday
P_wa_fl_mast
CHANGING P_Latest_mis_mile_Fr
P_Latest_mis_mile_To
P_Mult_count.

wa_fl_mast = P_wa_fl_mast.

zodrfdin_calday = P_zodrfdin_calday.

CLEAR: wa_floc_temp,
wa_floc_temp_1.



* Only bring the data after last successful inspection.
if zodrfdin_calday <> '10000101'.
delete copy_it_floc_temp_1 WHERE calday LE zodrfdin_calday.
else.
delete copy_it_floc_temp_1 WHERE calday < zodrfdin_calday.
endif.
If copy_it_floc_temp_1 is not initial.

sort copy_it_floc_temp_1 by zmilefr DESCENDING zmileTO DESCENDING.
*Delete data inf milesfrom are equal and milesTo less than the other
*milesTo
Delete adjacent DUPLICATES FROM copy_it_floc_temp_1 COMPARING
zmilefr.

* Only bring the data after last successful inspection.
if zodrfdin_calday <> '10000101'.
delete copy_it_floc_temp WHERE calday LE zodrfdin_calday.
else.
delete copy_it_floc_temp WHERE calday < zodrfdin_calday.
endif.

sort copy_it_floc_temp by zmilefr DESCENDING zmileTO DESCENDING.
*Delete data inf milesfrom are equal and milesTo less than the other
*milesTo
Delete adjacent DUPLICATES FROM copy_it_floc_temp COMPARING
zmilefr.

DESCRIBE TABLE copy_it_floc_temp LINES lv_count.
lv_tabix = 0.




* Append milesTo and milesFrom from master data

Read table copy_it_floc_temp_1 into wa_floc_temp_1 index 1.

If sy-subrc = 0.

Wa_floc_temp_1-zmilefr = wa_fl_mast-zmileto.
Wa_floc_temp_1-zmileto = '000'.

Append Wa_floc_temp_1 to copy_it_floc_temp_1.

sort copy_it_floc_temp_1 by calday DESCENDING zmilefr
DESCENDING.
Clear Wa_floc_temp_1.

Read table copy_it_floc_temp_1 into wa_floc_temp_1 index
1.
If sy-subrc = 0.

Wa_floc_temp_1-zmileto = wa_fl_mast-zmilefr.
Wa_floc_temp_1-zmilefr = '000'.

Append Wa_floc_temp_1 to copy_it_floc_temp_1.

Clear Wa_floc_temp_1.
*

Endif.
endif.

*Start Missing miles calculation
lv_tabix = 0.
DO lv_count TIMES.
lv_tabix = lv_tabix + 1.

*Comparing 2 records
Read table copy_it_floc_temp_1 into wa_floc_temp_1 INDEX lv_tabix.

READ TABLE copy_it_floc_temp INTO wa_floc_temp INDEX lv_tabix.

*onlu process if the functional location is active
if wa_fl_mast-/bic/zactinact <> '1'.
Else.

*if we have only 1 records
if lv_count = 1.
if wa_floc_temp-zmilefr EQ wa_fl_mast-zmilefr
and
wa_floc_temp-zmileto EQ wa_fl_mast-zmileto.

mis_mile_Fr = wa_floc_temp-zmilefr.
mis_mile_To = wa_floc_temp-zmileto.

WA_IT_MISMIL-funct_loc =
wa_floc_temp_1-funct_loc.
WA_IT_MISMIL-calday = wa_floc_temp_1-calday.
WA_IT_MISMIL-Mismilefr = mis_mile_Fr.
WA_IT_MISMIL-mismileto = mis_mile_To.
WA_IT_MISMIL-mismildif = ABS( mis_mile_To -
mis_mile_Fr )
.
APPEND WA_IT_MISMIL TO IT_MISMIL.
****************************

******************************

Elseif wa_floc_temp-zmilefr GT wa_fl_mast-zmilefr.

mis_mile_Fr = wa_fl_mast-zmilefr.
mis_mile_To = wa_floc_temp-zmilefr.

WA_IT_MISMIL-funct_loc =
wa_floc_temp_1-funct_loc.
WA_IT_MISMIL-calday = wa_floc_temp_1-calday.
WA_IT_MISMIL-Mismilefr = mis_mile_Fr.
WA_IT_MISMIL-mismileto = mis_mile_To.
WA_IT_MISMIL-mismildif = ABS( mis_mile_To -
mis_mile_Fr )
.
APPEND WA_IT_MISMIL TO IT_MISMIL.
*************************

***************************************************
Else.
if wa_floc_temp-zmileto LE
wa_fl_mast-zmileto.

mis_mile_Fr = wa_floc_temp-zmileto.
mis_mile_To = wa_fl_mast-zmileto.

WA_IT_MISMIL-funct_loc =
wa_floc_temp_1-funct_loc.
WA_IT_MISMIL-calday = wa_floc_temp_1-calday.
WA_IT_MISMIL-Mismilefr = mis_mile_Fr.
WA_IT_MISMIL-mismileto = mis_mile_To.
WA_IT_MISMIL-mismildif = ABS( mis_mile_To -
mis_mile_Fr )
.
APPEND WA_IT_MISMIL TO IT_MISMIL.
************************************

************************************
endif.

endif.
endif.

*if milefrom and mileto are same. do not process.
if wa_floc_temp_1-zmilefr EQ
wa_floc_temp-zmileto .
Else.

if wa_floc_temp_1-zmilefr GT
wa_floc_temp-zmileto .
mis_mile_Fr = wa_floc_temp-zmileto.
mis_mile_To = wa_floc_temp_1-zmilefr.

WA_IT_MISMIL-funct_loc =
wa_floc_temp_1-funct_loc.
WA_IT_MISMIL-calday = wa_floc_temp_1-calday.
WA_IT_MISMIL-Mismilefr = mis_mile_Fr.
WA_IT_MISMIL-mismileto = mis_mile_To.
WA_IT_MISMIL-mismildif = ABS( mis_mile_To -
mis_mile_Fr )
.
APPEND WA_IT_MISMIL TO IT_MISMIL.
*************************************************************

******************************************


Elseif lv_count <> 1.
Else.
if wa_floc_temp-zmilefr LE wa_fl_mast-zmilefr
and
wa_floc_temp-zmileto GE wa_fl_mast-zmileto.
mis_mile_Fr = wa_floc_temp-zmilefr.
mis_mile_To = wa_floc_temp-zmileto.

WA_IT_MISMIL-funct_loc =
wa_floc_temp_1-funct_loc.
WA_IT_MISMIL-calday = wa_floc_temp_1-calday.
WA_IT_MISMIL-Mismilefr = mis_mile_Fr.
WA_IT_MISMIL-mismileto = mis_mile_To.
WA_IT_MISMIL-mismildif = ABS( mis_mile_To -
mis_mile_Fr )
.

APPEND WA_IT_MISMIL TO IT_MISMIL.
*******************

********************

endif.
endif.

Endif.
endif.
ENDDO.

* Get Latest missing miles and multiple missing mile counter.
IF
IT_MISMIL IS NOT INITIAL.
SORT IT_MISMIL BY CALDAY DESCENDING MISMILETO DESCENDING.

Delete adjacent DUPLICATES FROM IT_MISMIL COMPARING Mismilefr.
DESCRIBE TABLE IT_MISMIL LINES MIS_COUNT.
CLEAR WA_IT_MISMIL.
Clear: P_Mult_count.

READ TABLE IT_MISMIL INTO WA_IT_MISMIL INDEX 1.
IF SY-SUBRC EQ 0.

P_Latest_mis_mile_Fr = WA_IT_MISMIL-Mismilefr.
P_Latest_mis_mile_To = WA_IT_MISMIL-mismileto.
endif.

ENDIF.
IF
MIS_COUNT > 1.
P_Mult_count = 'Y'.
ENDIF.


Endif. "copy_it_floc_temp_1 is initial.


ENDFORM. "MISSING_MILES

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 17, 2014 at 05:00 PM

    please reply me.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.