avatar image

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).

* Please Login or Register to Comment on or Follow discussions.

106 Comments

  • Apr 23 at 05:50 PM

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

    scn.jpg (17.7 kB)
    • Apr 25 at 02:14 PM
      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

      • Apr 25 at 02:34 PM

        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. :)

        • Apr 25 at 03:49 PM

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

        • May 03 at 12:05 PM

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

    • Apr 30 at 08:13 PM

      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)
  • Apr 23 at 05:53 PM

    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)
    • Apr 24 at 10:08 AM

      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.

      • Apr 24 at 03:05 PM

        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. :)

    • 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',
        ...
  • Apr 24 at 08:16 AM

    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)
    • Apr 24 at 03:08 PM

      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. :)

      • Apr 26 at 07:01 AM

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

    • May 03 at 12:13 PM

      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...
      • May 03 at 12:17 PM

        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.
  • Apr 24 at 08:18 AM

    And one of my fav, same BTE

    if.png (10.3 kB)
  • Apr 28 at 06:49 AM

    Doubtless many have seen countless of these:

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

    or

    TRY. 
    ...
    CATCH cx_root.
    "todo
    ENDTRY.
    • Apr 30 at 02:33 PM

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

      • Apr 30 at 04:24 PM

        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.

  • Apr 28 at 06:51 AM

    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.
  • Apr 30 at 02:38 PM

    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)
    • May 03 at 12:21 PM

      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...

  • May 02 at 09:24 AM

    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)
    • May 02 at 08:36 PM

      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)
    • May 25 at 11:48 AM

      "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.

  • May 02 at 12:17 PM

    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)
    • May 02 at 01:10 PM

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

      2018-05-02.png (343.4 kB)
    • May 02 at 08:49 PM

      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-[ ]

  • May 03 at 12:31 PM

    Space catalog anyone?

    screen.png (26.6 kB)
    • May 03 at 02:32 PM

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

    • May 03 at 03:37 PM

      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.

  • May 07 at 08:07 PM

    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)
  • May 07 at 08:10 PM

    From the "mildly infuriating" department. :)

    scn.jpg (23.3 kB)
  • May 10 at 10:09 AM

    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. :(

    • May 14 at 06:33 PM

      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.

  • May 15 at 04:03 PM

    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)
    • May 16 at 08:31 AM

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

  • May 16 at 09:21 AM

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

    capture.png (28.6 kB)
    • May 16 at 12:05 PM

      Pretty Printer... such mistery tool.

      • May 16 at 12:12 PM

        And so new...

      • May 25 at 11:51 AM

        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....

  • May 18 at 08:01 AM

    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

  • 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.
  • May 25 at 11:52 AM

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

  • May 25 at 04:41 PM

    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)
    • Jun 12 at 09:38 AM

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

  • Jun 01 at 04:04 PM

    "Constants defined, boss!"

    scn.jpg (19.3 kB)
  • Jun 08 at 07:10 AM

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

  • Jun 12 at 07:02 PM

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

    scn.jpg (12.3 kB)
    • Jun 15 at 03:07 PM

      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.

  • Jun 15 at 06:32 AM

    Not Optimal

    endselect.jpg (37.6 kB)
  • Jun 16 at 04:42 AM

    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.

  • Jun 18 at 09:12 AM

    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.

  • Jun 28 at 02:24 PM

    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)
  • Jul 03 at 01:25 PM

    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)
  • Jul 03 at 01:27 PM

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

    image.png (19.2 kB)
    image.png (19.2 kB)
    • Jul 03 at 04:17 PM

      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. :)

      • Jul 04 at 06:31 AM

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

        • Jul 04 at 09:06 AM

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

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

  • Jul 10 at 02:54 PM

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

    scn.jpg (20.5 kB)
    • Aug 28 at 01:15 PM

      The irony is that the commentary is more typing than a simple if sy-subrc ... l_apc = 0.

  • Jul 11 at 06:23 PM

    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)
    • Jul 12 at 07:04 AM

      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

      • Jul 23 at 07:21 PM

        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

        .

  • Jul 30 at 01:09 PM

    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.

    • Jul 30 at 03:18 PM

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

      • Jul 30 at 03:23 PM

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

  • Aug 02 at 11:53 AM

    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.

  • Aug 08 at 10:22 AM

    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. :-)

  • Aug 15 at 03:18 AM

    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.

  • Aug 30 at 08:30 PM

    ABAP cover of Lady Gaga's Bad romance. "Rah rah ah-ah-ah!" :)

    scn.jpg (18.3 kB)
  • Sep 07 at 06:37 PM

    Going through an old program and finding this type of stuff in multiple (!) places:

    Why, oh why...

    scn.jpg (13.5 kB)
  • Oct 15 at 05:19 PM

    FM does have the exception defined with the name OTHER. FM code has just a few lines (if you don't count 2 pages of useless comments :) ) and never raises any exceptions whatsoever.

    ¯\_(ツ)_/¯

    Wondering if Extended Check did not exist in 2000 yet...

    scn.jpg (36.0 kB)
  • Oct 15 at 07:13 PM

    I love trying to change code that has been copied from a query and then changed. And don't miss my addition of the "order type"

    qery.jpg (51.3 kB)
  • Oct 16 at 08:44 AM

    If you really want to lose the will to live, have a look at standard SAP INCLUDE program RVDIREKT...

    • Oct 16 at 11:52 AM

      Jesus Christ almighty..... (ಠ_ಠ)

      It's over. You win, Paul...

      /thread

    • Oct 16 at 02:34 PM

      wow... just wow.

      This thing is all over the place.You'll see c_obj_type_salesorder LIKE swotobjid-objtype VALUE 'BUS2032', but also bus_2032(7) VALUE 'BUS2032'

    • Oct 16 at 04:32 PM

      Okay, I went to look at that include. I stopped reading on line 54.

  • Oct 16 at 02:18 PM

    Hmm, is it not no or should it be yes? And what happens if it's a maybe? Questions upon questions...

    This definition within the same program is also quite interesting.

    • Oct 16 at 04:12 PM

      My understanding is that a lot of programmers write

      IF NOT SOMETHING IS INITIAL

      rather than

      IF SOMETHING IS NOT INITIAL

      beacuse that was the way you were forced to code it before version 4.0 of SAP in 1998.

      Another possibility is that they do this because they like to sound like Yoda.

      • Oct 16 at 06:35 PM

        IF NOT SOMETHING IS INITIAL style is driving me nuts. Especially if it's

        IF NOT sy-subrc IS INITIAL.
        <do stuff>
        ELSE.
        <do other stuff>
        ENDIF.

        Well, if you use both then just start with a positive condition.

        P.S. I do not understand the way this website formats the code...

        • Oct 16 at 07:51 PM

          The only way to paste code is: first press code button then insert code in the gray line.

  • Add comment
    10|10000 characters needed characters exceeded

Skip to Content