sap - Ternary operator (alternatives) -
sap - Ternary operator (alternatives) -
is there ternary or conditional operator available in abap syntax? haven't found 1 assuming reply no there alternative can utilize clear mutual "dumb" if statements routinely use?
for example, consider method logs message optional message parameters. decide between using imported parameter or default have check value so:
if iv_class initial. lv_message_class = 'default'. else. lv_message_class = iv_class. endif. if iv_number initial. lv_message_number = '000'. else. lv_message_number = iv_number. endif. if iv_type initial. lv_message_type = 'e'. else. lv_message_type = iv_type. endif. a ternary operator cut down each of these five-line statements single line seen in below code block. create utilize of temporary variable unnecessary when operator used in-line.
lv_message_class = iv_class initial ? 'default' : iv_class. lv_message_number = iv_number initial ? '000' : iv_number . lv_message_type = iv_type initial ? 'e' : iv_type . is there way approximate kind of programming style in abap or stuck clutter?
release 7.40 brings whole bunch of abap improvements i'm finding heaps interesting. ternary style declaration (at to the lowest degree resembles it) 1 of them
syntax:
cond dtype|#( when log_exp1 result1 [ when log_exp2 result2 ] ... [ else resultn ] ) ... example info declaration of variable called 'bool' , conditional value assignment in 1 line. old skool abap take 10 lines.
data(bool) = cond #( when * > number abap_true else abap_false ). more info: http://scn.sap.com/community/abap/blog/2013/07/22/abap-news-for-release-740
sap abap
Comments
Post a Comment