Skip to Content

Question on ALV IDA

Jul 24, 2017 at 05:49 PM


avatar image
Former Member

While formulating a condition for ALV IDA, I see the below example.

* Add the required condition

data(lo_condition) = lo_alv_cond_fac->between( name = 'POSNR' low = '000010' high = '000030')->AND( lo_alv_cond_fac->equals( name = 'VBELN' value = '0000000010' ) ).

I need some help in understanding the usage of "->AND".

why does this usage not return any syntax error?

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

1 Answer

Fabian Lupa Jul 24, 2017 at 07:02 PM

Not sure which class "lo_alv_cond_fac" is but this factory seems to make use of the builder pattern (more so than of the factory pattern) which means that each instance method returns a reference to the instance itself (as a returning parameter) to allow method chaining.

Though I have to admit your example condition factory builder thingy seems to also allow for nesting to define the interpretation order / priority which makes it a bit more difficult to read.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Method chaining is one thing but how does SAP allow the use of the keyword ->AND or ->OR to join conditions.

capture.jpg (40.4 kB)

Well a quick look at the signatures reveals that CONDITION_FACTORY( ) returns a reference to IF_SALV_IDA_CONDITION_FACTORY, which includes the EQUALS, NOT_EQUALS, ... methods. Each of them returns a reference to IF_SALV_IDA_CONDITION, which, again looking at the signatures, has the condition concatenation methods OR and AND which take another condition (-> IF_SALV_IDA_CONDITION) as the argument and also return the condition again.

So basically the factory returns conditions and each condition can be connected to another one using the methods OR / AND.

These interfaces do have long text documentation you might want to look into for more details.