ABAP Performance

pts.
Tags:
SAP ABAP
Hello, is there a difference in performance when using a CASE statement instead of a chain of IF-ELSEIF statements? Thanks for any hint. Regards, Juergen

Answer Wiki

Thanks. We'll let you know when a new response is added.

SAP state that CASE is faster than IF, though I think it is only minimal.

Having used debug quite a lot, I have noticed that all WHENs are evaluated in CASE, whereas the IF jumps to ENDIF as soon as one option has been found to be true and processed.

Hence CASE will allow multiple process depending on value and evaluation, but IF will only allow one.

Horses for Courses, as they say.

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Peahle
    You can find out yourself by turning on performance trace in ST05 that gives you a detailed result of your sql statements. Write two test programs with just this two different statements and just before execute turn on the trace, after the result is back, turn off the trace. Peter
    0 pointsBadges:
    report
  • Alcla0
    Well, according to my experience, such fine-tuning has often very few influence on the general performance of a program/system. It is probably better to study exactly how the data are accessed or stored in memory than discussing about the respective performances of an ABAP command.
    0 pointsBadges:
    report
  • Juergen
    Thank you for your hints. Best regards, Juergen
    0 pointsBadges:
    report
  • Peahle
    Hi Juergen, it is very legitim to ask such a question, because I disagree strongly with al... In my 12 years of experience in performance tuning on several SAP systems on different OS and databases more than 80 percent of bad performance resultet from poore ABAP/4 statements and expensiv sql's and only 20 percent have been solved by buffering or indexing. You have also the option of runtime analysis of your programs besides the ST05 transaction what you should use regularely when developing ABAP/4 programs. Peter
    0 pointsBadges:
    report
  • Rkohler
    I strongly agree with Peter in that the majority of ABAP performance problems result from the code itself and not so much the database or buffer. That being said though, in this specific example of IF....ENDIF or CASE....ENDCASE I don't think you'll see a significant improvement using CASE unless the IF....ENDIF logic is extensive. For me one of the big advantages of using CASE is that it makes your code much more readable and easier to follow in most situations. Rich
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following