Share your "ABAP gore"

There is a sub on Reddit called Techsupport gore where people share pictures and stories of some horrific things they see done with technology.

I've been looking at some old programs lately and see lots of stuff that would qualify as "ABAP gore". :) So I thought it might be therapeutic and educational to post some examples on SCN (examples to follow in the comments).

11
Show 91
* Please Login or Register to Comment on or Follow discussions.
avatar image
Apr 23 at 05:49 PM edited Apr 23 at 05:54 PM
1.7k

"Oh well, I hope these comments compensate for my non-descriptive variable names":

scn.jpg (17.7 kB)
3 Share
Looks like you kind of gave up at "Printer speed" and especially "Speed type".

And I just love how - out of nowhere - there is "v_brand". Did someone else add that one? :D

0 Share

LOL. I thought so too but it seems to be from the same version. It looks as if the person doing this was either under influence or had some health problem and were sort of going in and out of conscious state. They misspelled "processor" in the 2nd line, then copy-pasted "printer speed" then suddenly woke up: "huh? what just happened? where am I? v_b... BRAND! BRAND!".

Also "speed type" reminded me of Spaceballs: "ludicrous speed". Good times. :)

1 Share

I didn't even catch the double "Printer speed" comment! Now we will never know, what "v_prsb" is used for. ;(

1 Share

Yeah, that's why not to trust comments :-)

0 Share

The Zodiac killer strikes again!

I'm wondering if they meant "monitor" instead of "screen" but then forgot the word. Or, considering this is written around 2000, maybe they thought end of days is coming or something.

scn.jpg (20.0 kB)
3 Share

Monitor, screen... tomayto tomahto... :D

1 Share

For the bonus points: these are not actually used anywhere in the program but even before they were commented out they were used exactly one time.

scn2.jpg (18.5 kB)
5 Share

Actually, I can relate to this: rules say "never use a literal, always use a constant instead".

For long years, in nearly every report, I (and I think others as well) define

gc_x type c value 'X'.

...until at some point, I realizes I could now just use abap_true instead.

1 Share

That rule makes sense only if the constant is named properly. E.g. just the other day I had to look up VBFA with J (=delivery) document type. So I created c_delivery constant. Even though I used it once, this made the code more clear, I believe.

Also I take your gc_x and raise you gc_space. Apparently no one have heard about the space variable either. :)

0 Share
Jelena Perfiljeva
May 01 at 10:17 AM

This is a classic, I've seen it so often in previous engagements. It was often the result of blind adherence to programming standards, where either or both of these conditions existed:

- the programming standards weren't good enough to explain when and when not to use which rules

- the adherence was applied with a complete lack of common sense

What was worse was that in some cases the constants like this had been edited, so you ended up with something like this (see arrow)!

constants:
  c_10(2) value '10',
  c_20(2) value '25',      <---- !
  c_30(2) value '30',
  ...
9 Share

Why use the correct company code in FBL3N BTE? Just read the first thing you find (and i do not want to speak about how it has been written)

no-bukrs.png (16.5 kB)
2 Share

Haha, who cares about the company code!

I also love SELECT from language specific table but without specifying a language. Sure, it works fine when you have just one language in the system but then the big bosses decide to open an outfit in Mexico and suddenly a customer in Ohio gets an invoice with Spanish descriptions. :)

0 Share

Oh, sadly i already fixed those, but i found in the same BTE those kind of checks.

0 Share

I have seen variants like this. Why read random first, when you can read random last :D ;-(

SELECT * FROM knb1 into wa_knb1 WHERE kunnr = i_kunnr.
ENDSELECT.
IF sy-subrc = 0.
  "do something with wa_knb1...
2 Share

Well, when i was young, blonde, rebel and handsome, i found a code like this from the collegue who should to unveil me the mysteries of ABAP

SELECT * FROM <table> WHERE <condition>.
CHECK sy-subrc = 0.
<do stuff>
ENDSELECT.
3 Share

You can never be to sure about the subrc :)

1 Share

And one of my fav, same BTE

if.png (10.3 kB)
3 Share

Wow, this just takes the cake!

0 Share

Doubtless many have seen countless of these:

IF sy-subrc <> 0. 
  "todo
ENDif.

or

TRY. 
...
CATCH cx_root.
"todo
ENDTRY.
4 Share

Not even "todo", just "Implement suitable error handling..." or whatever text comes when you use the Pattern button.

1 Share

Dunno, to me an old todo is worse. A "todo" comment means someone has engaged brain and decided this is a valid gap. Many a bug has been traced to one of these.

1 Share

One of my all-time favourites:

METHOD return_sy_datum.
  data: lv_date type sy-datum. 
  lv_date = sy-datum. 
  rv_date = lv_date. 
ENDMETHOD.
12 Share

You know you shouldn't be writing stuff like that, right? ;-)

0 Share

I did have that nagging suspicion there must be a simpler way... :-)

1 Share

This is the best i have ever seen;-)

2 Share

Oh gosh...

0 Share

ABAP equivalent of "Honey, the cat threw up again! I'll just put a paper towel here. Gotta run, bye-e!" :)

scn.jpg (24.3 kB)
5 Share

Oh no, the "we don't have Materials in this format" is a clear hint of a nice practice of COPY-AND-PASTE a code from another customer's system and then... forget!

Like a test on a company code not even in the system...

1 Share

A "simple" method named "START_OF_SELECTION" with just 366 rows of code and thise structure.
The method is defined in a Global Class, used in just one report, report which is used to create the selection screen and pass to this class the select options.
Someone needs to learn how to use OOP and to structure code....

Oh, wait!
It's the same person, our consultants' technical reference, saying that "Code's quality is matter of opinion, there is no strict rule" when i started to reject their code (Sadly i'm finding these monsters here and there)

why-me.png (10.7 kB)
1 Share

They must have gone to the same ABAP school as our former consultants. :( Some kind of a nested IF addiction is sweeping the nation. I don't have the screenshots anymore but used to see up to 10 nested IFs in some places. How would you even read your own code? That's what I don't understand...

Gotta love massive CLEAR list too. This is just a tip of the iceberg, there are 8 of those "prodsets", takes full screen on my laptop:

scn.jpg (21.2 kB)
1 Share

"It's the same person, our consultants' technical reference, saying that "Code's quality is matter of opinion, there is no strict rule" when i started to reject their code (Sadly i'm finding these monsters here and there)"

Of course it's a matter of opinion. And I'm of the opinion that if you don't fix it, that the carpark is awfully dark. It would be awful if an accident were to happen.

2 Share

I'll make you an offer you can't refuse? :D

1 Share

We are at the 14th! level of nested structure in a more than 1000 lines long SD user-exit. This coding passage repeated around 5 times. By the way, not a single line of comment.

And they asked to fix the problem quickly... :D

exit.jpg (109.4 kB)
5 Share

Beaten!
We share the pain!
(perfect meme follows)

2018-05-02.png (343.4 kB)
12 Share

But... it's beautiful! *_*

2 Share

I say, your meme-skills intrigue me! Verily.

0 Share

Thanks Facebook groups about developers :P

0 Share

Could be one of those cases when a functional spec is translated into code quite literally. Once we had a consultant write a user exit and the spec had several steps like "check this condition... if so, do X". All those steps were performed with the entries in an internal table (the spec did not go into the implementation details). But instead of using a LOOP, the consultant literally put a bunch of READ... IF... there.

P.S. Wait, are they actually updating document flow (VBFA) in that user exit? 8-[ ]

1 Share

Space catalog anyone?

screen.png (26.6 kB)
5 Share

Reminds me of colleagues that use "space" instead of "tab" in Word to structure texts. *shudders*

3 Share

Yep, again same ABAP school as our former consultants. I suspect there is a copy of an ALV report that just gets passed from one consultant to another since 2000 and they all feel this is bees knees.

2 Share

Declare a dozen of useless variables but then write into an sy-... one? Well, it's there, so might as well use it, why not:

scn.jpg (16.0 kB)
0 Share

From the "mildly infuriating" department. :)

scn.jpg (23.3 kB)
4 Share

Not sure whether it qualifies as 'ABAP gore' but here it goes.

A functional consultant asked me to check a custom-made report as it didn't work as supposed: a dozen radion buttons on the selection screen didn't give the expected result.

Turned out not one single radio button was processed in the report!!!

In the end i had to rewrite the report. :(

2 Share

Classic! Haha! :) Have to admit I've been guilty of writing all the code for the buttons but then forgetting to actually call it. :) This was caught in QA though, fortunately.

0 Share

Wondering if this was written on a dare to use every possible way of variable declaration (pre-7.4) in one structure. Readability be damned.

scn.jpg (14.5 kB)
0 Share

but it does give a summary of the field declaration... so at least the name of the internal table is well chosen :)

1 Share

I don't even want to talk of the code itself.

capture.png (28.6 kB)
1 Share

Pretty Printer... such mistery tool.

2 Share

And so new...

1 Share

I instructed a developer who changed a small part of something I'd written that since I'd made the program nicely formatted, it was matter of courtesy that he should do the same.

The car park is awfully dark....

2 Share

Me: Dear consultant-that-i-pay-too-much, i cannot see the required OSS Note installed on our system.

C-T-I-P-T-M : Oh the note has just manual operations, so i applied them without installing the note: should i install the note and mark as done?

Me: have you any other idea than that to keep track of which note is installed in our system otherwise?

C-T-I-P-T-M : i installed the note

4 Share

Can you help me? I don't understand why i'm getting a dump.

  IF e_cabecera-persl IS NOT INITIAL.

    t_detalle-persl = e_cabecera-persl.

    MODIFY t_detalle TRANSPORTING persl

     WHERE persl IS INITIAL

        OR persl IS NOT INITIAL.

  ENDIF.
5 Share
Jesus Javier Contreras Colmenares
May 24 at 05:09 PM

Wow, this just wins the Internet! :)

0 Share

This discussion is not good for my blood pressure...

5 Share

Warning: this one may be dangerous for people with heart conditions. :)

Let me set the stage for you here. I'm looking at a 20k line program. The author defined variable L_RC (type I) in a routine (a SY-SUBRCesque flag). They are then calling multiple other subroutines with USING l_rc and are actually changing l_rc (same name everywhere too) in those subroutines.

This is the second hour of me going down the rabbit hole and I haven't hit the bottom yet. It is already 4 or 5 subroutines down and keeps going. If I don't make it out alive - it was nice knowing y'all!

scn.jpg (41.3 kB)
3 Share

Well those 'class', 'method' and 'exception' thingies are way too modern anyway :-P

2 Share

"Constants defined, boss!"

scn.jpg (19.3 kB)
4 Share

Arrghh ... This is the first thing i see here in the morning! Pure evil this! :D

0 Share

"No idea what I'm doing here but one of these should do the trick, I guess."

scn.jpg (12.3 kB)
3 Share

To be sure to be sure!.

And just in case it doesn't work I'll add a comment so people know what I want, what I really really want.

1 Share

Not Optimal

endselect.jpg (37.6 kB)
5 Share

Matthew Billingham DO NOT READ THIS!

(yes, i'm evil)

3 Share

So, what's in form SUBRC_CHECK?

0 Share
Matthew Billingham
Jun 18 at 06:05 AM

EXIT from the ENDSELECT presumably. A nice manually entered comment telling us what the FORM routine is supposed to do.

subrc-check.jpg (15.1 kB)
1 Share

And you cannot go wrong naming the internal tables ITAB1, ITAB2 and ITAB3 as is the case in this program.

1 Share

I'm just sad the form name isn't F_SUBRC_CHECK.

0 Share

Nice modularization tho. :)

0 Share

You know how you shouldn't use INCLUDEs for modularisation. And you shouldn't use Macros?

Just found an include that's included in multiple methods in multiple classes, which contains 3 complex macros. And in most of the methods where the include is included don't even use the macros.

1 Share

Fine example of comments telling lies. Message 366 does start with the word "warning" I will grant you that. I also like the variable that has SH for ship-to and AG for customer in it. A fine mix of English and German abbreivations.

2 Share

At first, every line is narrated in the comments:

But then out of the blue stuff like this starts and there is not a single comment, no documentation and no explanation of what's the significance of those values:

Face palm.

scn.jpg (34.9 kB)
scn1.jpg (35.5 kB)
0 Share

Please, focus on WA_SSOZ: is it just me seeing a little problem with a possible endless loop?

Performances are another issue but, well, in this case it's the last of the problem

And i wonder if RANGE_DATA will work this way.... something i doubt.

1.png (28.9 kB)
2.png (19.5 kB)
1 Share

Suddenly, this makes me feel a bit better about our system. :) Yikes!

0 Share

Not happy about the previous post,in 8 lines find the 2 monster errors

image.png (19.2 kB)
image.png (19.2 kB)
1 Share

That just doesn't make any sense... "Oh, I didn't find the company address, so lemme just grab a random one" ?

Someone had too much wine with lunch, I think. :)

0 Share

And notice that P_BUKRS is a select option so, even if i find a company address, it's one over N!

1 Share

Well, at least it is a valid address for someone ;-)

That point must have been for sure in the specifications....

1 Share

"Since I assigned 0 above..... Do not check Return". Ugh.

scn.jpg (20.5 kB)
0 Share

Forget about the fact that we are still using SAPScript in 2018 but there are 3 pages of this stuff for what looks like half of the alphabet:

scn.jpg (44.8 kB)
0 Share

Just a note: SAP doesn't provide smartforms for everything.

Last example i worked on is the cheques' print and, in my 731, i have only sapscript

0 Share

Yes, you're right. SAP loves to yell at us to use new tech but then they just don't offer it. :) FI module is notoriously underserved by Smart Forms or PDFs. Finding SAPScripts in SD is quite surprising though

.

0 Share

Let's talk about BAPIs... and WM?

1 Share

OK, this isn't exactly 'ABAP gore' but it's too danged good not to share.

I'm system debugging this morning, and oh dear lord, YAWN, but then I see this:

Blessings upon the person who wrote it. REALLY MEAN IT.

8 Share

So what was your next step? (Just in case you are still able to tell us...:))

1 Share

I was so excited about the comment, I forgot to keep stepping and the debugger timed out. Read into that what you will :-)

1 Share

I saw a short dump (TIME_OUT) in production and found this wonderful code.

There are forty one such blocks looping over GT_TABLE2 looking for one record. GT_TABLE and GT_TABLE2 both have 50,000 records. Both are STANDARD tables. Why in the world is it timing out?

I also think it is best practice to use names like GT_TABLE for your internal tables, just to make it obvious what sort of data the table contains. The upper/lower case formatting is pretty good as well.

3 Share

I'm sharing this piece of code (found in LVEDBF4R due to a recent dump it caused with an incoming IDOC) not because it's typical "ABAP gore" but out of frustration regarding the back-and-forth I'm currently having via an OSS-message to possibly get it fixed by SAP (they want to close my message because the issue is no longer reproducible as we already corrected the IDOC causing it):

*- proof the length of the order number -------------------------------*
   condense e1edk02-belnr.
   if e1edk02-belnr+10(1) ne space.
    xvbak-vbeln = '0000000000'.
   else.
 
 *- Auftragsnummer -----------------------------------------------------*
 *- order number -------------------------------------------------------*
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
         EXPORTING
              INPUT   =  E1EDK02-BELNR
         IMPORTING
              OUTPUT  =  XVBAK-VBELN
         EXCEPTIONS
              OTHERS  = 1.
   endif.
  ENDIF.<br>

Unless I'm missing something - always a possibility - this should be quite easy to fix, shouldn't it, to actually work in more cases than the current rather limited one?

The problematic content of field E1EDK02-BELNR was something like this "08.08.2018 some more text" when the conversion exit dumped.

Update: shortly after posting this here, my OSS-message was forwarded to the development team. :-)

1 Share
Update: shortly after posting this here, my OSS-message was forwarded to the development team. :-)

They are watching! :)

1 Share

Bärbel Winkler, you invoked them!

(why no gif allowed?! :( )

1 Share

I like comments ...

Found in SAP standard code, explaining how they work out what tz database values match a given Netweaver (SU01 style) timezone, prior to transfer to success factors.

Unfortunately the code underneath, while very clean and not deserving of being mentioned here, doesn't cope well with Australian time zones. Then again, sometimes neither do I.

5 Share
10 |10000 characters needed characters left characters exceeded
Skip to Content