‎2007 Feb 17 11:27 AM
Hi Experts,
I need control break statement apart from AT NEW F and ON CHANGE OF.
Please look below scenario.
I am working on Class Methods. In methods I am using control break statement as
at new f1. But for some cases at new f is not applicable and also on change of is not supported. Please look in the following scenario.
let's say f1 f2 f3 f4 are 4 fields with some values as below.
say structure s1
f1 f2 f3 f4
100 200 300 400
100 200 300 400
100 200 300 500
100 200 300 500
So the logic required is if f4 value for several records is same then then we have to group those records as one order. So in above case there will be two orders.
for f4 400 value rest f1 f2 f3 values are also same for two records so at new f4 is applicable.
But what if the condition is as below
f1 f2 f3 f4
r1 100 200 300 400
r2 100 200 400 400
r3 100 200 500 500
r4 100 200 600 500
though f3 is differrent as 300 and 400 for two records I have to group this as same record for one order as f4 is same 400 for r1 and r2. What can I do to group above records for two orders as earlier condition.
One solution I tried to adjust structures for these two differrent conditions as interchanging f3 and f4 into differrent strucure as s2 . and then moving-corresponding from s1 to s2 by applying loop.
say structure s2.
f1 f2 f4 f3
r1 100 200 400 300
r2 100 200 400 400
r3 100 200 500 500
r4 100 200 500 600
loop at s1.
move-corresponding s1 to s2.
endloop.
and then applying logic
AT NEW F4.
it's working but I doubt it may be performance issue.
Please let me know if thee is another alternative control break statements apart from AT NEW F4 and ON CHANGE OF to manage this situation.
Thanks,
Yogesh.
‎2007 Feb 18 1:27 PM
Hi Yogesh,
To my knowledge, in case of classes and methods, OOPs ABAP, only AT NEW control break statement works. Pls note that ON CHANGE OF is not applicable in case of classes/methods.
Jaydeep
‎2007 Feb 18 1:27 PM
Hi Yogesh,
To my knowledge, in case of classes and methods, OOPs ABAP, only AT NEW control break statement works. Pls note that ON CHANGE OF is not applicable in case of classes/methods.
Jaydeep
‎2007 Feb 18 4:29 PM
Hello Yogesh
In this scenario I usually use the following control break logic:
DATA:
ls_s2 TYPE <structure s2>,
ls_s2_x TYPE <structure s2>,
ls_s2_old TYPE <structure s2>,
lt_itab_x TYPE STANDARD TABLE of <structure s2>.
SORT lt_itab BY f4.
CLEAR ls_s2_old.
LOOP AT lt_itab INTO ls_s2.
IF ( ls_s2-f4 ne ls_s2_old-f4 ).
* ... do processing
* If you need to collect all records with the same value for field f4 proceed as following:
REFRESH: lt_itab_x.
LOOP AT lt_itab INTO ls_s2_x
WHERE ( f4 = ls_s2-f4 ).
APPEND ls_s2_x TO lt_itab_x.
ENDLOOP.
* ... do processing
ENDIF.
ls_s2_old = ls_s2.
ENDLOOP.Regards
Uwe