Sir if I take string st1 = ' wel come' . Then how can we remove that space? In other programing language there is way to remove space within same string
You need to do type casting. Take another variable of character type, pass your variable value to that character variable and apply condense on to that new variable.
Hello sir, i am giving DATA(lv_input) = 'Welcome to home'. DATA lv_length(5) TYPE n. lv_length = strlen( lv_input ). WRITE:/ lv_length. in this i am getting output is: 00015 i want to remove leading zeroes is this possible? and DATA(lv_input) = 'Welcome to home'. DATA(lv_length) = strlen( lv_input ). WRITE:/ lv_length. i wrote like this i am getting output like : 15 why?
First is Explicit declaration , you declared the variable( LV_LENGTH) explicitly. If you want to remove the leading zero's. You can use SHIFT string operation or use the function module : CONVERSION_EXIT_ALPHA_OUTPUT. In the same playlist, you will be able to learn - SHIFT string operation. Now in the second case, you are going for inline data declaration, so system is taking the length of the variable based upon the value Welcome to home, so it has leading space and then 15.
Hi Sir, Ekansh this side, i have doubt regarding strlen. for example : strlen( 'ABAP' ) returns length 4, strlen( ' ABAP' ) with 2 leading spaces returns length 6, but strlen( 'ABAP ' ) with 2 trailing spaces returns only length 4 . Does this mean strlen ignores trailing spaces in the string ? Could you please check this and let me know.
Hello Siddhant, As per my knowledge, STRLEN inbuilt function is used to calculate the String length in SAP. At the same time, we can achieve everything through Writing our own code also, Using Do loop and taking the characters one by one , we can calculate the length , but that will be more complex way to do this.
Good session ❤
Thank you Rahul sir 🎉
Sir if I take string st1 = ' wel come' .
Then how can we remove that space? In other programing language there is way to remove space within same string
Yes, you can use CONDENSE NO-GAPS.
Sir why we are specifying (2) in the bracket of length?
This is the length of the variable LV_LENGTH.
How to use condense for df16_dec data type?
You need to do type casting. Take another variable of character type, pass your variable value to that character variable and apply condense on to that new variable.
Hello sir,
i am giving
DATA(lv_input) = 'Welcome to home'.
DATA lv_length(5) TYPE n.
lv_length = strlen( lv_input ).
WRITE:/ lv_length.
in this i am getting output is: 00015
i want to remove leading zeroes is this possible?
and DATA(lv_input) = 'Welcome to home'.
DATA(lv_length) = strlen( lv_input ).
WRITE:/ lv_length.
i wrote like this i am getting output like : 15
why?
First is Explicit declaration , you declared the variable( LV_LENGTH) explicitly. If you want to remove the leading zero's. You can use SHIFT string operation or use the function module : CONVERSION_EXIT_ALPHA_OUTPUT. In the same playlist, you will be able to learn - SHIFT string operation. Now in the second case, you are going for inline data declaration, so system is taking the length of the variable based upon the value Welcome to home, so it has leading space and then 15.
@@sapabapbyrahulmehta okay sir thank you so much
Hi Sir, Ekansh this side, i have doubt regarding strlen. for example : strlen( 'ABAP' ) returns length 4, strlen( ' ABAP' ) with 2 leading spaces returns length 6, but strlen( 'ABAP ' ) with 2 trailing spaces returns only length 4 . Does this mean strlen ignores trailing spaces in the string ? Could you please check this and let me know.
Yes, right observation.
Without using STRLEN how to find the length of the string sir..??
Hello Siddhant, As per my knowledge, STRLEN inbuilt function is used to calculate the String length in SAP. At the same time, we can achieve everything through Writing our own code also, Using Do loop and taking the characters one by one , we can calculate the length , but that will be more complex way to do this.