Show TOC

Binding ABAP Strings to Dynpro FieldsLocate this document in the navigation structure

Use

ABAP fields declared with the data types STRING or XSTRING (character strings or byte strings with dynamic lengths) can be bound to identically named dynpro fields, just like fields with fixed lengths. However, it must be noted that there are no dynpro fields with variable lengths. The length of a dynpro field is always defined in Screen Painter by the element attribute defLg. This means that dynpro fields are the same as character fields with type C in ABAP, whose length is always defined.

For this reason, data transports between ABAP programs and dynpros in ABAP fields with type STRING or XSTRING are performed in the same way as the internal ABAP assignments (MOVE) between character/byte strings and character fields:

  • If, during the transport of a character string or byte string to a dynpro field, the string contains more characters than the length of the dynpro field, any surplus characters or bytes are cut off. Since a dynpro field may not exceed 132 characters of length, only up to 132 characters or bytes of a character string or byte string may be transported to the dynpro.

  • In transports from a dynpro field to a character string, any trailing blanks are cut off.

These restrictions apply to the transport to and from normal input/output fields as well as to fields in table controls without an assigned internal table and to the use of dropdown boxes.

REPORT demo_dynpro_strings.
DATA: string1 TYPE string,
      string2 TYPE string,
      char1(10) TYPE c,
      char2(100) TYPE c.
DATA  len TYPE i.
string1 = '123       X'.
string1 = string1(10).
char1   = string1.
string2 = '12345678901234567890'.
char2   = string2.
len = strlen( string1 ).
WRITE:  'PBO:',
       / 'Length of STRING1:', len.
len = strlen( char1 ).
WRITE: / 'Length of CHAR1:  ', len.
len = strlen( string2 ).
WRITE: / 'Length of STRING2:', len.
len = strlen( char2 ).
WRITE: / 'Length of CHAR2:  ', len.
ULINE.
CALL SCREEN 100.
len = strlen( string1 ).
WRITE:  'PAI:',
       / 'Length of STRING1:', len.
len = strlen( char1 ).
WRITE: / 'Length of CHAR1:  ', len.
len = strlen( string2 ).
WRITE: / 'Length of STRING2:', len.
len = strlen( char2 ).
WRITE: / 'Length of CHAR2:  ', len.
ULINE.


         

The static next dynpro number of dynpro 100 is 0 and four input strings, STRING1, STRING2, CHAR1, and CHAR2 are created in its layout:

The dynpro fields all have a length of 10. No modules are called in the dynpro flow logic.

When the program is executed, the screen is displayed with the values '123 ' and '1234567890' in the fields STRING1/CHAR1 and STRING2/CHAR2. Choosing ENTER displays the following list:

PBO:                             
Length of STRING1:         10    
Length of CHAR1:            3    
Length of STRING2:         20    
Length of CHAR2:           20    
PAI:                             
Length of STRING1:          3    
Length of CHAR1:            3    
Length of STRING2:         10    
Length of CHAR2:           10    
         

At PBO, STRING1 contains ten characters, seven of which are trailing blanks. These are lost during the assignment to CHAR1 and the character length of CHAR1 is only three.

At PAI, STRING1 contains only three characters, because the blanks are suppressed during the transport to and from the dynpro.

In both STRING2 and CHAR2, all characters that do not fit into the corresponding dynpro fields are cut off.