cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP interesting patterns in standard

OttoGold
Active Contributor
0 Likes
539

Hello, ladies and gentlemen,

I am reading through some standard function modules and find things I would never write myself. So I thought I could ask you about your opinions on these patterns.

First one is:


LOOP AT LM_T030B WHERE KTOSL = I_KTOSL.
    EXIT.
  ENDLOOP.

  IF NOT SY-SUBRC IS INITIAL.

Is there any special performance reason for this? a dirty side effect? I don`t think so, but I am asking just in case I am missing. Maybe we can learn something here:))

Cheers Otto

Accepted Solutions (0)

Answers (4)

Answers (4)

Lukas_Weigelt
Active Contributor
0 Likes

The following two form routines are designed AND performed in the very same program and called directly after each others. Them lazy programmers rather thrash around everything in the ABAP memory than defining global Types. :-SSS

FORM EXPORT_FORMDEF_TO_MEMORY USING VALUE($MOLGA)
                                    VALUE($FORML)
                                    RC LIKE SY-SUBRC.
  FM-KEY-MOLGA = $MOLGA.
  FM-KEY-FORML = $FORML.
  EXPORT
    XCEDT
    I512D
    I512E
    I512F
    I512G
    I512N
    I512P
    I512Q
    I512S                                                   "VKIK080595
    I514D                                                   "VKIK061490
    SWITCH
    SWITCH_NATIO
    SWITCH_MOD
    FVAR
    FVAR_NATIO
    FVAR_MOD
*   sl_le                                                   "WXJK014138
  TO MEMORY
  ID FM-KEY.
  RC = SY-SUBRC.
ENDFORM.

FORM IMPORT_FORMDEF_FROM_MEMORY USING VALUE($MOLGA)
                                      VALUE($FORML)
                                      RC LIKE SY-SUBRC.
  FM-KEY-MOLGA = $MOLGA.
  FM-KEY-FORML = $FORML.
  IMPORT
    XCEDT
    I512D
    I512E
    I512F
    I512G
    I512N
    I512P
    I512Q
    I512S                                                   "VKIK080595
    I514D                                                   "VKIK061490
    SWITCH
    SWITCH_NATIO
    SWITCH_MOD
    FVAR
    FVAR_NATIO
    FVAR_MOD
*   sl_le                                                   "WXJK014138
  FROM MEMORY
  ID FM-KEY.
  RC = SY-SUBRC.
ENDFORM.

Fiddlesticks! D-:

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes

Hello Thomas,

Do we still have code from the 80s running the most complex ERP on this planet(pun intended) ??

Some food for thought for djh

@Otto: I think this piece of code seems to be in place before the READ command was available. Anyway i've seen many a "new age" developers using this code :-S

Cheers,

Suhas

Former Member
0 Likes

Yeah it's no excuse really to not do anything about all this.

Why not use it as an initiation rite for new internal SAP developers. Let them clean up 10.000 lines of code or something like that before they are allowed to do nice things.

I give SAP a couple of years more and if by then I don't see enough effort (or maybe they do but they're just not voicing it enough).

I might just raise an error message on OSS whenever I encounter an internal table with header line or some other obsolete stuff.

Cheers, Rob.

OttoGold
Active Contributor
0 Likes

I give SAP a couple of years more and if by then I don't see enough effort (or maybe they do but they're just not voicing it enough). I might just raise an error message on OSS whenever I encounter an internal table with header line or some other obsolete stuff.

Hi Rob, you must be kidding here...? Nobody can fix this anymore in my opinion. Fix every header line use? PFFF, that would be a nightmare:)) How often do you guys open messages when you see some weird stuff in the system? I am really interested in best practise/ your practise.

Cheers Otto

Former Member
0 Likes

Yes you are correct.

But not your nightmare.

Like I said just make it an initiation rite for new internal SAP developers who are working on the SAP products.

Or use it as a quota, or use some sort of incentive program.

Whatever just something so gradually SAP becomes nice and shiny again.

Or ask consultants over the world to come up with changes regarding the standard.

You could even use bounties, or something entirely different altogether.

It shouldn't cost SAP that much. Suppose they spend less than 3 million EUR a year on this then in 10 or 15 years time most of the old stuff could be replaced with the good stuff.

Cheers, Rob.

matt
Active Contributor
0 Likes

> @Otto: I think this piece of code seems to be in place before the READ command was available. Anyway i've seen many a "new age" developers using this code :-S

Yesterday, in something developed in 2007, I saw:

SELECT ... INTO wa WHERE ...
ENDSELECT.

IF sy-subrc ne 0.
...

And yes, you would get more than one record returned.

Edited by: Matt on Jul 15, 2011 6:31 PM

ThomasZloch
Active Contributor
0 Likes

Do you mean using a table with header line, or using LOOP / EXIT instead of READ?

Some of the ERP code is probably still from the late 1980s, I would not take this as a template on how to do things today. I am sure there are many more examples like this.

Thomas

OttoGold
Active Contributor
0 Likes

Another example I don`t get: FM J_1BSA_COMPONENT_ACTIVE

testing the same twice for two fields, ok -->> why don`t we copy the whole lot to have some MORE fun?