‎2012 Dec 31 9:27 AM
| INDEX | XBLNR |
|---|---|
| 1 | 00034567 |
| 2 | 00034567 |
‎2012 Dec 31 9:35 AM
Hello Shimano,
Is XBLNR the left-most column of your internal table? If no, then the behavior of AT NEW & AT END are as expected.
From SAP documentation on control break statements:
The control breaks take place when the content of the component compi or another component to the left of compi changes.
BR,
Suhas
‎2012 Dec 31 9:35 AM
Hello Shimano,
Is XBLNR the left-most column of your internal table? If no, then the behavior of AT NEW & AT END are as expected.
From SAP documentation on control break statements:
The control breaks take place when the content of the component compi or another component to the left of compi changes.
BR,
Suhas
‎2012 Dec 31 10:47 AM
Hi,
I was wondering what is the logic behind:
"The control breaks take place when the content of the component compi or another component to the left of compi changes."
Regards.
‎2012 Dec 31 11:15 AM
It means you need to define the fields in the internal table in the order that the field values changes from left to till the field that you specify in AT NEW or AT END OF. The remaining fields are irrelevant for your purposes and will have values **** as its contents inside these loops.
If you are interested in only one field changes you have to declare that field as the first field in the internal table mentioning that other fields are irrelevant for looking for changes in their contents.
This is only in case of one field value change. But ABAP also allows you the flexibility of observing multiple field changes based on your requirement. In this case you have to declare the fields from left to right indicating that when the first field value changes you are not interested in the remaining field contents. When the first field value remains same then only you are interested in a change in the second field value and so on till the field you specified at AT NEW or AT END OF.
Hope its clear.
‎2013 Jan 02 2:57 PM
Hi,
Thanks for you explanation.
So if we want to generate different report based on differet sorting for each report we need to define different structure ?
If I am right it seem a little bit restricting syntax and not very productive....
Regards.
‎2013 Jan 02 4:22 PM
Yes in this kind of situation you have to go for it in that way only. But this kind of situation rarely occurs as normally you will always have key fields in the beginning of the structure and will look for a change in that.
‎2013 Jan 02 4:39 PM
Hi,
Rarely occurs ? I wander.
Take for example classic case:
Customer,Product,Date,Value,Quantity.
It is very common requirement to summarize the same data in different sorting and different control field.
With ALV you can define sorting and control field dynamically. I believe that this flexibility should be also
available in ABAP .
I can think on different technics to overcome this limitation but this will create unnecessary complexity in the code.
Regards.
‎2013 Jan 03 5:47 AM
In such cases, you already know what a programmer does, write your own code handling multiple field changes
‎2012 Dec 31 9:42 AM
Hi Shimano,
If you use AT NEW & AT END statement then XBLNR should be first field in your internal table itab..in the same sorting order
Most prob this will solve ur issue
Thanks
Ben
‎2012 Dec 31 9:46 AM
Hi Shimano,
Your program is not at all working strangely. Suhas is right.
Please first understand how AT NEW and AT END OF works in the below link.
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/content.htm
then you can solve your problem yourself...
thanks.
‎2012 Dec 31 10:16 AM
.Hi Shimano,
At new , at first will check the field value from the leftmost column.
In this scenario at new xblnr and at end xblnr will be triggered twice because the value of index is changing.
If either of index or xblnr will change the statements will be triggered.
Put your Xblnr field as first column of the internal table.
Regards,
Swarna
‎2013 Jan 02 10:18 AM
If you're not interested in using "SUM" as a control break result, i don't see why you would want to use AT NEW / END in the first place.
You might want to try ON CHANGE OF field_name instead, since it is invoked on (and only on) changes of field_name . If you need to do some postprocessing at the end of a group of data, you could use a save_workarea for the previous entry.
Regards
Jörg
‎2013 Jan 02 10:30 AM
Hi Jorg,
Please press F1 on ON CHANGE OF statement and see. Please don't suggest obsolete statements.
thanks.
‎2013 Jan 02 10:31 AM
Hello Jörg,
Afaik ON CHANGE OF is an obsolete syntax
BR,
Suhas
‎2013 Jan 03 3:44 AM
| INDEX | BLART | XBLNR |
|---|---|---|
| 1 | SA | 00034567 |
| 2 | 00034567 |
| INDEX | BLART | XBLNR |
|---|---|---|
| 1 | SA | 00034567 |
| 2 | SA | 00034567 |
To anyone out there who are puzzled with the similar case study, the missing BLART at the 2nd index in QAS was causing the problem.
‎2013 Jan 03 7:35 PM