Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Find length of a particular field.

Former Member
0 Kudos

Hi,

I am new in ABAP. So Please guide me how to find out the length of a particular field and also give the function name with example.

Ram Shanker

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Here we use STRLEN for determinig the lenth of a field.

Even we use DESCRIBE statement.

DESCRIBE FIELD A LENGTH L.


DATA: WORD1(10) TYPE C VALUE 'STRINGA',     
    WORD2(20) TYPE C VALUE 'STRINGB',
           I1 TYPE I.

I1 = STRLEN( WORD1 ) + STRLEN( WORD2 ).

WRITE: I1.

Hope this helps.

thanx,

dhanashri

Edited by: Dhanashri Pawar on Aug 6, 2008 7:11 AM

Edited by: Dhanashri Pawar on Aug 6, 2008 7:21 AM

Edited by: Dhanashri Pawar on Aug 6, 2008 7:23 AM

10 REPLIES 10

learnsap
Active Participant
0 Kudos

Hi,

Using the DESCRIBE FIELD <f>.... we can get the field length and the attributes of the field.

FYIP...

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3145358411d1829f0000e829fbfe/content.htm

Regards,

Ramesh

Former Member
0 Kudos

to find length of string.

STRELN( str_name )

to find length of a field

SE11->Enter table Name->View lenth of correspponding Field for its length in LENGTH Couln.

rgds

rajesh

Edited by: RAJESH KUMAR on Aug 6, 2008 10:34 AM

bpawanchand
Active Contributor
0 Kudos

HI

to calculate the length of the work variables that you define in the program

DESCRIBE FIELD <f> LENGTH <l> TYPE <t> COMPONENTS <n>

OUTPUT-LENGTH <o>]DECIMALS <d>

[EDIT MASK <m> HELP-ID <h>.

to calculate the length of a string use STRLEN() function

Regards

Pavan

Former Member
0 Kudos

hi,

use DESCRIBE statement with length addtion.

syntax is

DESCRIBE FIELD <f>  LENGTH <l>.

For detail ref to,

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3145358411d1829f0000e829fbfe/content.htm

regards,

Anirban

Former Member
0 Kudos

Hi,

use the predefined function

STRLEN

Number of characters in arg; blanks at the end of data objects with a fixed length are not counted, although they are counted in type string data objects. If you use a non-Unicode double-byte code, a character that occupies 2 bytes is counted twice.

Regards,

Jagadeesh.

Former Member
0 Kudos

Hi,

Use describe field filedname w_int.

or strlen.

Former Member
0 Kudos

hi,

To get the Length of the field Use DESCRIBE statement.

DESCRIBE FIELD <Field> LENGTH <len>.

To know more use F1 help in teh ABAP Editor you will find good Example for it.

Regards

Sumit Agarwal

Former Member
0 Kudos

Hi,

Here we use STRLEN for determinig the lenth of a field.

Even we use DESCRIBE statement.

DESCRIBE FIELD A LENGTH L.


DATA: WORD1(10) TYPE C VALUE 'STRINGA',     
    WORD2(20) TYPE C VALUE 'STRINGB',
           I1 TYPE I.

I1 = STRLEN( WORD1 ) + STRLEN( WORD2 ).

WRITE: I1.

Hope this helps.

thanx,

dhanashri

Edited by: Dhanashri Pawar on Aug 6, 2008 7:11 AM

Edited by: Dhanashri Pawar on Aug 6, 2008 7:21 AM

Edited by: Dhanashri Pawar on Aug 6, 2008 7:23 AM

Former Member
0 Kudos

Use

DESCRIBE FIELD mara-matnr LENGTH l_matnr IN CHARACTER MODE..

rgds

rajesh

Former Member
0 Kudos

Hi RAM,

DESCRIBE FIELD

Syntax

DESCRIBE FIELD dobj

[TYPE typ [COMPONENTS com]]

[LENGTH ilen IN {BYTE|CHARACTER} MODE]

[DECIMALS dec]

[OUTPUT-LENGTH olen]

[HELP-ID hlp]

[EDIT MASK mask].

Effect

This statement determines several properties of the data object dobj and assigns them to the specified variables. The various additions enable you to determine the data type and the number of components for structures, the length used in the memory, the number of decimal places, the output length, the name of the data type for a reference to a data element of the ABAP Dictionary, and a possible conversion routine.

Notes

You can specify field symbols or formal parameters in procedures for dobj to determine the properties of the data object they represent at the time of the statement execution.

The statement DESCRIBE is used to determine the properties of data objects of elementary data types. When DESCRIBE is used for structures or data objects of deep data types like strings, internal tables, or reference variables, you can only determine elementary properties. Further details, for example, the static or dynamic type of a reference variable cannot be determined using DESCRIBE. For this kind of information, you can use the type classes of Run Time Type Services (RTTS). They enable you to determine all properties of data objects of all data types.