‎2008 Mar 24 3:37 AM
Hello All,
Can anybody tell the difference between STRLEN and NUMOFCHAR.
Which is better to use and why to use the better one.
Can anybody explain me in detail. I will reward you with points.
Thanks,
Karan
‎2008 Mar 24 3:49 AM
Hi,
check this link
http://help.sap.com/saphelp_nw70/helpdata/EN/79/c55479b3dc11d5993800508b6b8b11/frameset.htm
Regards
‎2008 Mar 24 3:54 AM
Hi,
Function STRLEN works only with character type field and returns the length in characters.
Function NUMOFCHAR returns the number of characters in a string or a character-type field.
This function behaves like STRLEN in single byte code page.
Regards
Sandipan
‎2008 Mar 24 3:55 AM
Hi,
Check these links....
http://help.sap.com/saphelp_nw04/helpdata/en/79/c55479b3dc11d5993800508b6b8b11/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb33d9358411d1829f0000e829fbfe/content.htm
Reward points if useful.
Regards
AK
‎2008 Mar 24 3:56 AM
hi,
STRLEN:
Returns the length of a character-type field in characters. With c-fields, as opposed to fields with type STRING, only the actual length used is relevant because blanks at the end are not counted.
NUMOFCHAR.
Returns the number of characters of a character-type field. In Unicode systems and non-Unicode systems with single-byte codepages, this function behaves like STRLEN. In non-Unicode systems with double-byte codepages, characters that take up more than one byte are counted with length 1, while STRLEN returns length 2.
just refer ABAPDOCU for more information.
reward if useful,
regards,
bharathi.
‎2008 Mar 24 4:00 AM
Hi,
NUMOFCHAR : It gives the total length of the variable irrespect of
the number of chars in the cvariable.
Ex : v_num(30). means "30" is thge result.
STRLEN : It gives the nuber of chars present in that variable.
Ex: v_num(30) TYPE c value 'abcdef'.
result is '6'
‎2008 Mar 24 4:11 AM
Hello MuraliKrishna,
Thanks for the reply. Can you tell me which is better to use.
Thanks,
Karan
‎2008 Mar 24 4:17 AM
Hi,
it depends.
Some times in program you need to find the length of the variable,based on that you have to caluculate some thing, that time you have to use STRLEN().Here if you use NUMOFCHAR() your result will be wrong.
So use based on requirement use above functions.
‎2008 Mar 24 4:27 AM
Hi Murali,
In a scenario if we want to find the length by using STRLEN each character takes 2 bytes. But for NUMOFCHAR it takes only 1 byte.
Can you tell me an example for STRLEN which takes 1 character as 2 bytes.
thanks,
Karan