Home
  Add-Ons for
SAP® systems
  CT-Assist 7.1
  User comments
  R/3® Integration
  PDF / Download
  CT-Debug & Trace_Module
  R/3® Integration
  PDF / Download
  CT-Codeview & Analyzer
  CT-Test & Optimizer
  eLearning for ABAP™
  CT-Professsional_100+Help
  CT-Professsional_100
  CT-Understanding_100
  CT-Help_Workbench
  ABAP™ Programs
  Shop [SSL]
  Downloads
 


Home > ABAP™-Programs > Y9030004

ABAP™-Programs

Report Y9030004:  Simple determination of the string length ?

There are several possibilities to determine the string length within a field.

In general a function of "COMPUTE ..." group is used to calc the string length: string length = STRLEN(strings). " The STRLEN function is not necessarily one of the fastest routine ? ". One Programsr know it better: Thanks for it. By the way: Activate " Move 'hugo' ..." , What is the time difference ?

[for Download or 'cut and paste']


REPORT Y9030004.           "Release 3.1G, 4.5A
************************************************************************
* Copyright (c) 1999 by CT-Team, 33415 Verl, http://www.ct-software.com
*
*     You can use or modify this report for your own work as long
*               as you don't try to sell or republish it.
*      In no event will the author be liable for indirect, special,
*        Incidental, or consequental damages (if any) arising out of
*                       the use of this report.
*
************************************************************************
 BREAK-POINT.
*//////////////////////////////////////////////////////////////////////*
 MOVE:  ' Find out the string length in a fast way'
        TO SY-TITLE.
* STRLEN is not very quick
*//////////////////////////////////////////////////////////////////////*
************************************************************************
***************         Paramter declaration      **********************
*
 PARAMETERS: P_STRING(120) DEFAULT ' here is an abitrary string ...... '
             LOWER CASE.
************************************************************************
*
*//////////////////////////////////////////////////////////////////////*
*************               Main Section             *******************
*//////////////////////////////////////////////////////////////////////*
*
 PERFORM STRINGLAENGE.
*
*//////////////////////////////////////////////////////////////////////*
*************                Subroutines             *******************
*//////////////////////////////////////////////////////////////////////*
*
************************************************************************
*                      How long is the string ?
************************************************************************
 FORM STRINGLAENGE.
*
 BREAK-POINT 111.
  ULINE. SKIP 1.
  WRITE: /5 'Step 1: Simple determination of string length.' COLOR 5.
  ULINE. SKIP 1.
*.......................................................................
*
  IF P_STRING CP '*# '.  ENDIF.    " SY-FDPOS is set
*                 |||
*                 |||---->  ' ' = only blanks up to end of line
*                 ||----->  #   = character for blanks
*                 |------>  *   = any character
*.......................................................................
  WRITE: /1 'String:', P_STRING COLOR 4.
  WRITE: /1 'String length:', SY-FDPOS COLOR 6.
*
 ENDFORM.
************************************************************************
************************************************************************
******************* END OF PROGRAM *************************************