COND ABAP. Condition in ABAP code SAP

COND ABAP in SAP – new ABAP syntax construction. COND very useful for using in ABAP program for getting value with conditions. In old syntax you can use CASE or IF and ELSE, for example, but it will be with addition variable and ABAP code will be longer.

COND in ABAP examples SAP

I create a lot of examples using COND and I will show you step by step from the easiest to the most difficult with new ABAP syntax in SAP program.

COND ABAP SAP

Simple example COND in SAP

For example, we want to check price, and if price not correct to change to 0. It old ABAP it will be:

Not so long, but it the easiest example. In new syntax ABAP:

We not only check conditions for price, but also convert type to NETWR. You also can convert types in ABAP with construction CONV ABAP.

Example COND SAP with 2 conditions

We can also use COND ABAP with more difficult conditions. For example, I need to choose order number with some conditions.

Also not so big. But for example if you want to send this variable to method it will be easier with new syntax:

Because in this case you can use all construction COND #( … ) in parameter for methods. You also can use COND # without type if program can understand type.

Example COND with WHEN and ELSE.

COND SAP in this case in old syntax will be IF, ELSEIF and ELSE. But in new ABAP:

In this example I also to add using new ABAP construction Concatenate ABAP for adding lidding zeros with other ways.

Example COND with dates

One more example using this construction with date

I will add more examples in future. Because with COND we also can use LET for creating new local variable for using inside.

Subscribe to YouTube and I will tell you!

Leave a Reply