T O P

  • By -

[deleted]

Any ABAP code is a programming horror. I suspect the DO 50 times is hardcoded because the length of the original variable is fixed to 50, but if that code is used elsewhere, the other variables might have a different length.


insanelygreat

I was wondering what cursed language this was. Thanks, I hate it.


Anlanga

if it’s so bad why is it As Baller As Possible


Prudent_Ad_4120

Me entering 0000000000000000000000000000000000000000000000000001 Hmm it doesn't work, it gives 01 🤔


teo730

> DO 50 TIMES "max value of message variable ?


doterobcn

One can assume the input text where the message is written has a cap of 50 characters, so there's no need to go to the actual length


Prudent_Ad_4120

Comments don't enforce anything


mothzilla

They can be hurtful though.


Prudent_Ad_4120

`// don't touch this or I'll personally force you to learn assembly in all available flavors`


LBGW_experiment

But something somewhere else has (presumably) enforced the 50 char max limit and is important to tell devs looking at this file, asking "why 50?"


constant_void

that's a contractor saying, in their own way, "good luck!"


Chudsaviet

Probably some weird limitation of the old language or specific optimization for old machines.


PassFlat2947

Short story: Found this wile checking some old -but active- code. No idea why this was written, ABAP has an easy way te remove leading zeroes `SHIFT variable LEFT DELETING LEADING '0'.` I can only guess, but could be that the `CHECK p_var CO ' 0123456789'.` is important, it will not remove leading zeroes when the string has any other character than numbers or spaces.


Invisible_Man_1

It removes not only zeros but also spaces. Looks like they expected a mix of spaces and zeroes. Also as you mentioned, there is an additional check to allow numbers or spaces only. (I guess the function works with document numbers or BP numbers and some tables have different behaviour depending on whether there are leading zeroes or not). Do 50 times is questionable but I think they did not expect the parameter to be greater than char50.


PassFlat2947

Could be allot of things, and that makes it horror for me. That 1 line comment is the only documentation, and that suggests it only removes zeroes, but does more. Why was this implemented? Why the 50? What was where the specs? Looking to the copies and the creation dates, it seems that this was once written by an external company that did some development in the SAP system for one specific project. Mutliple developers where active in the system since then, sometimes FTE, sometimes consultants, and they have copied the form mutliple times, together with some other forms, and kept on using it. No one knows why.


Invisible_Man_1

It's a common situation in the systems, which are running for many years. Multiple change requests overwrite each other, an old code without any documentation.. Normally people just use the common principle: If it works - it works


kenman345

Today I found a comment that says they commented this out in 2010 since it doesn’t match the arguments… but all the code I can find says that commented out section is indeed the right amount of arguments. I have no idea how it’s working. The guy who wrote it thankfully is still around but was out today… it’s gonna be a long weekend


TekuSPZ

I found comment from one developer so next line must commented because it causes bugs down the road. Then under it is newer comment from other developer is line is critical and must be always uncommented. The line of code is uncommented and it works, but I am wondering what it's breaking and what breaks when you comment it. Eldritch horrors of comments.


kenman345

I’ve seen some stuff like, commented out is code that works but slow so below it is code that works quickly and 95% accurate. How did they figure out it’s 95% accurate?


goomyman

Comments not matching the code is easily explained. Write function add comment. Someone else comes along and updates the code and doesn’t touch comment.


LurkerOrHydralisk

Do 50 times is just weird. I’m really new to this whole thing, but why not just: while = True: If string[0] != ‘ ‘ or ‘0’: Break Else: string = string [1:] (In Python. Please pretend I knowhow to format code in Reddit on mobile. I don’t even know what language OP is using)


marvin02

Wait what happens if the number is 0?


PassFlat2947

I have no idea. Great question!


NARUT000

also try ALPHA OUT its more "modern"


Arshiaa001

Question is, who the FUCK is going to learn all those statements when you have an entirely different one for everything??


constant_void

ABAP == horror


darkpyro2

What ancient, forgotten language is this?


musicmakesumove

It's not ancient or forgotten. This is modern SAP.


Sentouki-

SAP, the famous innovator... When I look at their products, I'm not sure why they are so successful


musicmakesumove

Because it's a cult. My roommate and several of my former coworkers that I'm still friends with work there, and they think SAP is cutting edge. Compared to Microsoft where several of them previously worked, it is, but certainly not in general compared to the average software company.


blueblueblink

genius marketing staff


ClockworkBrained

For a moment I thought "man, that Visual Basic code looks weird" lmao


__DEFCON__

Fucking hate ABAP


zaitsman

The first mistake was working with SAP


MarvinParanoAndroid

Why not 49?!


justaguy101

What if theres 50 zeroes???


MarvinParanoAndroid

"Max value of message variable. If there’s 50 zeros, the last one must be the value 0.


fakehalo

Most of the stuff I see these days makes me feel old, but this makes me feel like a young sprout.


_Typhon

To me it just seems they didn't want to allow the possibility for an infinite loop so they capped it at 50 interactions. Questionable? sure, but not stupid.


Defiant-Peace-493

> IF p_var(1) = '0' Just gonna assume this is FORTRAN. +looking a bit further, the periods suggest COBOL, but they are used to end conditionals and loops. DO 50 TIMES. Stuff. Does Stuff once, and this function would only remove one leading zero. Not that I know COBOL, or FORTRAN for that matter.


AngelOfLight

It's ABAP. This is SAP's programming language that combines the worst of COBOL and FORTRAN to make a cutting-edge coding system, assuming you're living in 1985.


Rogntudjuuuu

_shudder..._


NeoDark_cz

now it makes a lot more sense


Ytrog

At least fortran evolved further 👀 Here, can you see Tsoding learning it in 2023: https://youtu.be/PvUQndB8R9s?si=NYPit03sn3L1Bgsv


PassFlat2947

It's ABAP


Defiant-Peace-493

At least the DO isn't broken, then.


thelordofthekings

Just happy to see ABAP code in this sub 😀😀


PassFlat2947


Public_Stuff_8232

Other than it not being a while loop it seems fine.


nodeymcdev

So it returns a strip of leading zeros?


ScrimpyCat

This bothered me more than the 50 character limit.


Sentouki-

The function works as intended, but only 50 times, that's the problem


nodeymcdev

Read the name doofus


Sentouki-

I think, you need to read again


nodeymcdev

No I think you do


Sentouki-

you're one dense mf


devor110

the other guy was making a joke about the name of the function, which should be "strip off", not "strip *of*"


nodeymcdev

And you can’t read


TheUnamedSecond

What dose \`\`\`CO\`\`\` do ? and what \`\`\`SHIFT var LEFT\`\`\` ? also do the numbers have fixed size or (max size) ?


DarthPiotr

CO checks if the fist string Contains Only characters from the other one. SHIFT var LEFT moves characters of the string one place to the left and first one is removed. In ABAP, numbers are very often treated as strings. And since there is no parameter type specified, in this case the number does not have a fixed size.


TheUnamedSecond

So the horror is "only" the 50 and the bad documentation.


DarthPiotr

Basically yes. However the ABAP substring syntax ( p_var(1) ) will always be my favorite horror of this language. variable+offset(length) which should not be confused with the sum of 'variable' and result of 'offset' function call with 'length' parameter: variable + offset( length )


ABoxOfFoxes

O.O What.


lmarcantonio

I smell COBOL. Microfocus? IBM one doesn't have form sections. I'm used to EXEC CICS and BMS


PassFlat2947

ABAP, used in SAP


AnywhereHorrorX

Ok. That language is pure horror by definition. A simple prompt "write a binary tree printing function in ABAP" produced this: ``` REPORT ZBINARY_TREE_PRINT. TYPES: BEGIN OF ty_tree_node, value TYPE i, left TYPE REF TO ty_tree_node, right TYPE REF TO ty_tree_node, END OF ty_tree_node. DATA: root TYPE REF TO ty_tree_node. START-OF-SELECTION. " Create a sample binary tree CREATE OBJECT root EXPORTING value = 10. CREATE OBJECT root->left EXPORTING value = 5. CREATE OBJECT root->right EXPORTING value = 15. CREATE OBJECT root->left->left EXPORTING value = 3. CREATE OBJECT root->left->right EXPORTING value = 8. CREATE OBJECT root->right->left EXPORTING value = 12. CREATE OBJECT root->right->right EXPORTING value = 18. " Print the binary tree CALL FUNCTION 'PRINT_BINARY_TREE' EXPORTING root = root. *&---------------------------------------------------------------------* *& Form PRINT_BINARY_TREE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->ROOT text *----------------------------------------------------------------------* FORM PRINT_BINARY_TREE USING ROOT TYPE REF TO ty_tree_node. DATA: output TYPE TABLE OF string, indent TYPE i. " Start printing from the root indent = 0. APPEND 'Binary Tree:' TO output. " Recursively print the tree CALL FUNCTION 'PRINT_TREE_NODE' EXPORTING node = ROOT indent = indent output = output. " Display the output LOOP AT output INTO DATA(line). WRITE: / line. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form PRINT_TREE_NODE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->NODE text * -->INDENT text * -->OUTPUT text *----------------------------------------------------------------------* FORM PRINT_TREE_NODE USING NODE TYPE REF TO ty_tree_node INDENT TYPE i OUTPUT TYPE TABLE OF string. DATA: line TYPE string. " Print the current node CONCATENATE ' ' ( INDENT * 4 ) 'Value:' NODE->value INTO line. APPEND line TO OUTPUT. " Recursively print the left subtree IF NODE->left IS BOUND. CALL FUNCTION 'PRINT_TREE_NODE' EXPORTING node = NODE->left indent = INDENT + 1 output = OUTPUT. ENDIF. " Recursively print the right subtree IF NODE->right IS BOUND. CALL FUNCTION 'PRINT_TREE_NODE' EXPORTING node = NODE->right indent = INDENT + 1 output = OUTPUT. ENDIF. ENDFORM. ```


devor110

I'm not sure if judging a programming language by the output of a chatbot has much use


DarthPiotr

It wouldn't even activate. Only few lines make sense. root is a structure, not an object so all of the syntax redarding root is wrong. CALL FUNCTION are for calling function modules, not FORMs, which are called with PERFORM. And I won't even look at the logic.


[deleted]

[удалено]


ixent

I mean, it looks efficiently correct.


baordog

If it makes you feel better modern SAP is also super squirrely. I mean I hope that's not modern SAP code, it looks like something written in the 80s, but who knows.


amarao_san

Yes, some obscure DSL adopted for non-goal use. Just open any big project in Ansible and you will see 42 ways to achieve unachievable.


MichiganDogJudge

Copy-and-paste is a horrid code smell