pexels-photo-1314525.jpeg

Counting chars or entries in new ABAP syntax

May you wanted to count the length of a simple string or the total rows of an internal table. With the new ABAP syntax, it is possible to get these counts and lengths within the same line.

Counting characters in a string

IF strlen( lv_counting_string ) GT 10.
  " Do something cool here
ENDIF.

With this method you can easily check the length of the string at the same line as your condition and therefore you save some lines of code.

Counting rows in an internal table

When you want to count the lines of an internal table, you can select the other command lines.

IF lines( lt_some_entries ) GT 5.
  " Do something cool here
ENDIF.

This will count the lines of the first level of your internal table. So, if you have a deep structure with multiple entries again, they won’t get counted.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ad blocker detected

We have detected that you are using extensions to block ads. Please support us by disabling your ad blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO