Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Include vs subroutine scenario

shivangi_pant
Participant
0 Kudos

Hello experts, i have one confusion which is very basic but i am not able to find the answer in detail.
So i worked in few reports and in some there were several includes created without perform and start of selection but in some we had to add start of selection with perform. My question is why did we do that? What exactly is the difference in both scenarios?

example-- include top, include sel, include logic, include display for declarations, selection screen, logic and display respectively.
In another report, only top and sel were made in include rest all were written in ->
Start-of-selection
perform logic.
perform display.

Thanks in advance.

1 ACCEPTED SOLUTION

matt
Active Contributor

The differences are just down to programming choice. There's no one "right" way. Includes are only ways of organising source code. They shouldn't be used for any other reason. There are no standards for how you use includes. You could have the FORM in one include and the corresponding ENDFORM in another.

Using includes to modularise programs is a very bad thing. They are not subroutines and should never be treated as such.

Includes are used in the implementation of classes and function groups. With classes you never need to handle them directly. With function groups you do, but keep the number to a minimum.

As noted above, FORMS are obsolete. Use classes and methods instead. Includes should never be used explicitly with classes.

TL:DR - don't use FORMS, don't use includes in new developments.

5 REPLIES 5

Sandra_Rossi
Active Contributor

You will learn that, while getting more and more experience. Many people understand why ABAP Objects is needed, they understand only after using a little bit, or after a lot of time, some of them will NEVER understand.

It's a matter of trends driven by the best developers. See for instance ABAP Clean Code (this won't answer your question, but you'll understand how these developers think in general).

Good luck for convincing anyone with just a little discussion...

NB: FORM/PERFORM has been obsolete for almost 15 years by the way 😉

matt
Active Contributor

The differences are just down to programming choice. There's no one "right" way. Includes are only ways of organising source code. They shouldn't be used for any other reason. There are no standards for how you use includes. You could have the FORM in one include and the corresponding ENDFORM in another.

Using includes to modularise programs is a very bad thing. They are not subroutines and should never be treated as such.

Includes are used in the implementation of classes and function groups. With classes you never need to handle them directly. With function groups you do, but keep the number to a minimum.

As noted above, FORMS are obsolete. Use classes and methods instead. Includes should never be used explicitly with classes.

TL:DR - don't use FORMS, don't use includes in new developments.

0 Kudos

Yes but why the difference as mentioned in scenarios ??? When do we have to differenciate??

Sandra_Rossi
Active Contributor
0 Kudos

shivangi_pant Again, it's a matter of individual preference. I hope you get it.

0 Kudos

sandra.rossi Yes i think i do with the explanation. Its just the situations that confused me but otherwise i have worked in both the things somewhat.