Application Development and Automation 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: 
Read only

Abap objects standards

0 Likes
4,058

Hi Folks,

I'm in need of help. I have just come into a shop that has no SAP OO standards. There are many kingdoms that are not even using SE24 to build classes. Is there a SAP document or guide I can use to set standards. I am really fighting with  producing good code over what is in place.

Thanks

Bruce

1 ACCEPTED SOLUTION
Read only

0 Likes
3,975

Hi Folks,

Thanks for the hints. Since SAP OO is different from other conceptual OO I wanted to stick directly with the language I'm working with ABAP. I have gone through the Thomas Jung videos at least 6 times. I have also read the "ABAP Objects: ABAP Programming in SAP Netweaver by Horst Keller cover to cover. I have been programming the last 2 years WDA using only SAP wizards and WDA tools. I was hoping there was a SAP official document that outlined good programming practices as the folks here are "hiding" behind OO article that have nothing to do with ABAP.

Thanks

Bruce

23 REPLIES 23
Read only

arthur_alvesteixeira
Active Participant
0 Likes
3,975

This message was moderated.

Read only

0 Likes
3,975

Hi Arthur,

Some folks are football fans I am a Thomas Jung fan. Yes I have embrased his style and belive that is the way to program abap objects. I need to be able to get something from SAP that says follow Thomas's videos.

Bruce

Read only

0 Likes
3,975

This message was moderated.

Read only

0 Likes
3,975

thanks I have those in my favorites

What I was hoping for is some reference to some SAP document

Thanks

Bruce

Read only

0 Likes
3,975

This message was moderated.

Read only

tom_demuyt
Explorer
0 Likes
3,975

I am reviewing my coding standards, I don't have much on this either.

* Global classes should be named ZCL_XX_YYY with ZZ the module and YY a descriptive name

* Parameter names start with P_YYY  ( P_IN_YYY and P_OUT_YYY are too verbose )

* Class instances start with CL_XX

* Banned statements

   * No nested method calls ( A cool feature which often leads to terrible code )

* Avoid

   * arrow anti pattern, maximum tolerance is 5 levels

   * copy pasting, consider 3 strikes and you refactor. For over 15 lines if code, you must always re-factor.

   * avoid over lengthy code blocks, maximum tolerance for a code block is 60 lines with the exception being BAPI wrappers

* Do

  * use result = class->method( parameter ) over class->method( exporting p_parameter = parameter importing p_result = result ).

  * use the preferred parameter feature

  * use inheritance, but cap at 3 levels ( base class, subclass, subsubclass, stop here )

  * consider interfaces

  * use a custom error class based of CX_STATIC_CHECK

It would be great if others could add to this.

Read only

0 Likes
3,975

Hi Tom,

I have a fool who thinks you should not use SE24 and I'm struggling with that aspect so I was hoping SAP has a big stick I could hit him with. Really that's where I'm at.

Bruce

Read only

0 Likes
3,975

This message was moderated.

Read only

0 Likes
3,975

Ah, I agree with that, this is part of my coding standard as well

  1. Banned statements
    • All code that creates inline classes, use SE80 to create classes

The problem with local/inline classes is that they are no re-usable unless you start putting them in includes which is not OO at all.. The other problem is that SAP themselves use local classes.. I dont think you will find anything that bans them. I hope that the *ool is not the development manager

Read only

0 Likes
3,975

Just a few thoughts...

Tom Demuyt wrote:


* Parameter names start with P_YYY  ( P_IN_YYY and P_OUT_YYY are too verbose )

We use two letters at max: (I|E|C|R)(V|S|T|R)_YYY. The first letter is importing/exporting/changing/returning, the second one is atomic value (often omitted, so just I_FOO), structure, table, reference. Doesn't waste too much space and convey almost everything you need to know


* Banned statements

CHECK, EXIT, RETURN. Don't use it - I'd rather see the arrow pattern than some hidden method abortion that's hard to spot when trying to figure out what to adapt.


* For over 15 lines if code, you must always re-factor.

   * avoid over lengthy code blocks, maximum tolerance for a code block is 60 lines with the exception being BAPI wrappers

I'm not a friend of hard-and-fast rules like that. ABAP is a verbose language, and with real-life business logic, you will often end up with methods that span 100+ lines - nothing too fancy, just a chain of function/method calls with lots of parameters


  * use result = class->method( parameter ) over class->method( exporting p_parameter = parameter importing p_result = result ).

Agreed, but be aware of the potential performance implications.


  * use a custom error class based of CX_STATIC_CHECK

Even more importantly, learn what each of the three exception subhierarchies is good for and use each one where appropriate 🙂

Cheers

  Volker

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
3,975

Hello Volker,

I have learned a thing or two from ABAP Pitfall blog series. I really like them


Even more importantly, learn what each of the three exception subhierarchies is good for and use each one where appropriate.

Although i know the difference in behavior for these 3 different types of exception classes, but i still can't appreciate the usage of the dynamic- & no-check exception types. While it makes sense in case of ABAP keywords to have the exceptions as dynamic type, but why would you use them in custom code?

Can you give a business case where you had used an exception class other than the static type?

BR,

Suhas

Read only

0 Likes
3,975

Suhas,

thank you - I've still got a few subjects queued up, and I've just added the exception stuff to the list. Unfortunately, there's a rather large project blocking everything else right now.

Cheers

  Volker

Read only

Former Member
0 Likes
3,975

Hi Bruce,

I think our colleagues already have given you a start point to what you asked, beyond that i believe you must go deep in conceptual studies.

You can find several books, internet articles and etc about OO. The internet is flooded with info about it, and it is up to you to choose what suits, and i think that Thomas Jung's articles are a very good lead on this.

If you are acquainted with that, great! if you aren't much, i recommend you to give a shot to understand a bit more deeper.

Here are some hints on basic content that helped me:

Why we need OO? *Check out the part that says about design rotting symptoms

http://www.google.com.br/url?url=http://www.objectmentor.com/resources/articles/Principles_and_Patte...

How we do it in ABAP? * I have been reading a blog that Naimesh Patel has made, he is a scn contributor, and his content on OO is excelent for practice and understanding of several OO resources/strategies

http://zevolving.com

I also recommend you to get some extra content on software design to get new leads. For instance, i am reading the book "The Pragmatic Programmer", this book is simply mind blowing and applies to any development technology, and applies even for professional and personal self improvement matters.

Best Regards,

Renan

Read only

former_member730258
Participant
0 Likes
3,975

it's gonna be difficult to introduce one when all is in place already. but you can start by creating one requirement in OOP and then give them the idea that that one is preferably based on sap best practice and moving forward you can possibly move other objects to adapt that technique.

Read only

0 Likes
3,976

Hi Folks,

Thanks for the hints. Since SAP OO is different from other conceptual OO I wanted to stick directly with the language I'm working with ABAP. I have gone through the Thomas Jung videos at least 6 times. I have also read the "ABAP Objects: ABAP Programming in SAP Netweaver by Horst Keller cover to cover. I have been programming the last 2 years WDA using only SAP wizards and WDA tools. I was hoping there was a SAP official document that outlined good programming practices as the folks here are "hiding" behind OO article that have nothing to do with ABAP.

Thanks

Bruce

Read only

0 Likes
3,975

Hi Bruce,

I am sorry for saying things that have nothing to do with ABAP , i really thought that what i said about zevolving.com had something to do with ABAP OO, regarding design patterns and OO concepts applied to it.

See below my reason to think it: (there's much more, i really appreciate this blog and several times i merged these approaches to mine )

and etc,

I like to learn concepts, because these are made of ideas. Ideas aren't bonded to physical limitations. Your physical resources may evolve and become obsolete over time, an idea can evolve but it can't die, although it can be changed with a tremendous flexibility, it will never be obsolete over a reasonable amount of time.

I am a bit sad because you said i am hiding behind the first link i sent . Robert Martin (CEO of Object Mentor) has so much to say about this matter, and his text about Symptoms of Rotting Design says about an absurd quantity of problems i have seen and interacted with in my ABAP experience. The other book i mentioned has so much good concepts and ideas that in here ... i can't put in words.

I am really sorry for being a nuisance. Lesson learned, i won't talk about matters that are so far from the topic ever again.

Obs.: About official SAP documentation, in the SAP Official Course TAW12 (since 2007 *when i saw this subject in it), SAP released in part 1, around 300 pages of content about ABAP Objects. And there are others you can check in SAP PRESS

Regards,

Renan

Read only

0 Likes
3,975

Hi Renan,

My message was completely misunderstood. A lot of the design concepts are based on Java. Such as the Gang of 4 chain of responsibility. Java has a very hard time dealing with events. This is a real game changer with SAP ABAP. Using SE24 to drag and drop methods into programs, test individual methods and link objects using events and event handlers are extremely powerful. These are used time and time again in WDA. SAP objects flexibility for use in SAP is far superior than what I have seen outside SAP. This because I am an ABAPer. It is my frustration when having to defend using se24 to people who I am working with who quote non SAP sources why they should not take advantage of powerful tools at hand. So it is my English that I apologize for. My goal in asking for assistance, is that I am looking for a SAP shield that I can hit over the head of my folks at work to say "see this is STANDARD SAP approved guidelines for class development using the recommended SE24 transaction. I have no access to your source  TAW12 (since 2007 *when i saw this subject in it), SAP released in part 1, around 300 pages of content about ABAP Objects. I can only hope SAP has released something that I can use. Again It is my mistake in the way I wrote my last response.

Bruce

Read only

0 Likes
3,975

This message was moderated.

Read only

0 Likes
3,975

Hi Bruce

Can you clarify something for me? What are they using instead of SE24? Is it that they are still writing procedural programs?

If so, you might point out then that in the release notes of 7.02 PERFORM is an obsolete statement. Therefore they might as well gear themselves up to either only using Function Modules for modularisation, or go the whole way and begin doing proper OO coding - since fairly soon (or already), what they're doing will be "obsolete".

Further, it they don't learn OO, then they will have grave difficulties continuing to work with ABAP (web dynpro etc., CL_SALV_TABLE). So their choice is, effectively, career limiting.

If they're writing just local classes - well, that's just weird. I mean, SE24 is to objects, what function modules is to reports. Do they not use SE37 either?

Read only

0 Likes
3,975

They are typing in local classes. I'm so not good with that. I have quite a political battle ahead. I now have great tools thanks to the many comments like yours and the others. Also Renan has been a big help. Thanks folks.

Bruce

Read only

0 Likes
3,975

Hi Matthew,

How will SAP handle all the SAP code that use PERFORM?

Thanks

Bruce

Read only

0 Likes
3,975

As ever, "obsolete" in SAP terms, means "don't develop new code using".

Read only

0 Likes
3,975

Hi Matthew,

Many many thanks for the info. It will be put to great use.

Bruce