05-13-2011 9:30 AM
Hi,
My table data is as below.
Kunnr BDAT EDAT D1 D2 D3 D4 D5
1111 2001 2002 1 2 1 2 1
1111 2003 2008 1 0 4 1 2
1111 2008 2011 1 1 1 1 1
2222 2003 2008 1 2 2 2
2222 2008 2011 1 2 1 1
Here for kunnr between begin and end date we have to caluclate the dependencies. (I.e if there is any value in D1or D2 or D3orD4 it shoulbe counted as 1. of it is zero or blank then it should not be coutned).
for Ex: for 1111 between 2001 & 2002 tot dependencies are 5.
for 1111 between 2003 & 2008 tot dependencies are 4.
in this scenario what will be the best way of writing the code. Do we need to check each and every field when counting the Sum value or and simple way to improve the performance.
Regards,
Vishnu
Edited by: Vishnuvadhan K on May 13, 2011 10:30 AM
Moderator Message: This is not a forum, where you can get your work done by others.
Edited by: kishan P on May 13, 2011 3:52 PM
05-13-2011 10:08 AM
using the get curser and parllel curser u can help it out in this case syst variable in sy-tabx
when u use the above stmts u can do in whaich debuging can be done but see that a set of stmt should be used ids that
refeseh
loop and
append should be kept must so that ur record will be displayed in the given table
05-13-2011 10:27 AM
Hi,
I am not sure if i really understand what your saying.
Can you please give the skeliton of the code.
Regards,
Vishnu
05-13-2011 10:34 AM
Hello,
First Sort your Internal Table.Then Use the Control Statements like AT END OF ,AT FIRST etc in a Loop on the Internal table.
Do your Calculation part in these Control Statemests between blocks for Example
AT END OF (Field1)
DO SUM and Store it in another Variable in the Ineternal table
ENDAT.
Write your Internal table contents .
If i wrongly Understood ,Please let me know.
05-13-2011 10:51 AM
Hi Vishnu,
Here, you will have to check for the range of your begin date & end date. If it comes in the said range, then you simply have to add the values of your D1, D2,... DX values which you can store in some variables by setting out a flag as one counter for each.
If your case is satisfied for any of the date range, then just check for the flag values which are satisfied & add them or display the sum of the number of counters.
@Ambujavalli, At End Of won't work here because the date ranges given by Vishnu will differ.
Those statements are useful in a case when suppose for the same field value, you need to calculate a particular sum.
Here, that is not the case. Hence, AT First & At End Of won't work.
Thanks,
Gayathri.
Edited by: gnikesh88 on May 13, 2011 11:52 AM
05-13-2011 10:55 AM
hi,
I can't add the values of D1, D2..Dx. This fields may cantain either 1 or 2 or any value. But if it is greate than one, then cound should be one. otherwise do not count it.
Regards,
Vishnu
05-13-2011 10:57 AM
Just keep counters for them and add up the number of those counters for which your condition is satisfied.
Please check out my modified comments for the same.
Thanks,
Gayathri.