Skip to Content
0

How to eliminates records that net to zero in internal table ( start/End routine)

Feb 24, 2017 at 02:33 PM

240

avatar image

Hello experts ,

I trying to use a start routine to eliminates all records ( sharing the same field) and the summation (net value of summation) nets to zero in vain. The records in black. For instance, 762, 75 and -762,75 both share the same 0CLR_DOC_N0 and their sum is zero, I would like to eliminate both records before I load the data into the target.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

9 Answers

Mario Tibollo Mar 07, 2017 at 09:15 AM
2

if you're deleting these records, you'll be missing data, no?

anyway the data in the report will be correct as for a given key combination it will aggregate the info and show 0 as value.

So the actual question is: what is the specific reason to delete these lines in the cube?

Share
10 |10000 characters needed characters left characters exceeded
Koen Hesters Feb 28, 2017 at 10:06 AM
0

Hi,

you can use a startroutine to do so.. something like

loop at source_package assigning <sp>.

if prev = <sp>-docnr/key

sum = sum + <sp>-amount

else

if sum <> 0

move <sp> to wa_temp

append wa_Temp to it_temp

prev=<sp>-docnr / key

endloop.

refresh source_package

source_package[] = it_temp[].

Share
10 |10000 characters needed characters left characters exceeded
John Betterman Mar 01, 2017 at 02:43 AM
0

Hi Koen,

Thanks for your feedback. This is not working for me. What is the initial value of prev and sum? The problem is that some of the records that were supposed to offset others are actually moved in by the following lines code:

move <sp> to wa_temp

append wa_Temp to it_temp

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi,

second try

it_temp[] = sourcepackage[]

sort source_package by key

delete adjacent duplicates from source_pacakge comparing key

Loop at source_package assigning <sp>

clear sum

loop at it_temp assigning <temp> where key=<sp>-key

sum = sum + <temp>-amount

endloop.

if sum = 0

delete it_temp where key= <sp>-key

endif

endloop

refresh source_package

source_package[] = it_temp[]

0
John Betterman Mar 01, 2017 at 02:32 PM
0

Hi Koen,

Your logic is sound in this algorithm, but for some reason, the sum conditions never get met. I even tried to define a integer variable which did not work. I tested, if the sum <> delete, it deletes everything . I don't understand why the condition is not met ....below is my code :

Note : I have tried in both in start routine and in endroutine, the results are the same.

LOOP AT itab_temp2 ASSIGNING <fs_clr_doc2> .

CLEAR itab_sum .

LOOP AT itab_temp3 ASSIGNING <fs_clr_doc3> WHERE CLR_DOC_NO =
<fs_clr_doc2>-CLR_DOC_NO .
balance = <fs_clr_doc3>-DEB_CRE_LC .
itab_sum = itab_sum + balance .

IF itab_sum EQ 0 .

DELETE itab_temp3 WHERE CLR_DOC_NO = <fs_clr_doc2>-CLR_DOC_NO .


ENDIF.
ENDLOOP.

ENDLOOP.
refresh RESULT_PACKAGE .

RESULT_PACKAGE[] = itab_temp3[].

Share
10 |10000 characters needed characters left characters exceeded
Koen Hesters Mar 02, 2017 at 01:32 PM
0

Hi,

the if statement to delete should be outside the second loop. the second loop creates the sum.

additionnaly you can try deleting via index (you can save the indexes n1 and n2 while looping (second one))

DELETE <itab> [FROM <n1>] [TO <n 2>]

Grtz

Koen

Share
10 |10000 characters needed characters left characters exceeded
John Betterman Mar 06, 2017 at 02:53 AM
0

Hy Koen,

Thanks so much for trying to help. The more I look at this issue, the more I realize that the issue is not even the while look /if or any other code which is not working. Not say that you are not right with everything you just advised me. The point is , from DSO to Cube, this numbers should offset each other without using any code.

I was analyzing the source of the data, and I realized that the addictive mode of the infocube (which is the target containing the data you see there on the screenshot) worked for some data records, and did not work for others ( the ones I'm trying to get rid of using abap code).

So the real and right question is: why would the addictive mode of infoCube work for some data records and not for others? what is the exception to the rule?

Context: Data from sap delivered extractor is staged into a write optimization DSO. This DSO has many fields including the keys you see in the figure. In the cube, I dropped most of the keys (including document dates...posting dates..) and kept just the ones you see ( gl, allocation_number and clearing document Number). The results are that from the DSO, the addictive mode worked for some records ( the ones with debit/credit amount is 00,00 but I did not work for the ones with numbers in the debit/credit key figure.

Any reasons why?

Share
10 |10000 characters needed characters left characters exceeded
Koen Hesters Mar 06, 2017 at 10:01 AM
0

Hi,

Check your KF in transformation (rules -> Detail -> Aggregation -> ADD) if they are in ADD mode and not in overwrite mode, if this is okay, you can check the change log of your DSO, those contain all the records that are involved. Try to follow the flow, from RSA3 over DSO to Cube. Maybe a reinit will be usefull, to check everything cleanly.

Grtz

Koen

Share
10 |10000 characters needed characters left characters exceeded
John Betterman Mar 07, 2017 at 05:15 PM
0

Thanks everyone for trying to help.

Hoen, the aggregation is set to summation in the cube, which is the only one available. I'm still investigating the data to figure out why the addictive mode works for some data and does not work for other records. In the meantime , I have just added another level (cube) as a work around and used sort/delete adjacent duplicates.

Share
10 |10000 characters needed characters left characters exceeded
Koen Hesters Mar 08, 2017 at 08:09 AM
0
John,

off course is it set as summation to the cube, I'm talking about the transfo towards your DSO('s), that should be add as well, otherwise he will overwrite!

Grtz

Koen

Share
10 |10000 characters needed characters left characters exceeded