cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (9)

Answers (9)

former_member186445
Active Contributor

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?

kohesco
Active Contributor
0 Kudos
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

Former Member
0 Kudos

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.

kohesco
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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?

kohesco
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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[].

Former Member
0 Kudos

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

kohesco
Active Contributor
0 Kudos

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[]

kohesco
Active Contributor
0 Kudos

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[].