ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Character String and Byte String Processing →  Expressions and Functions for String Processing →  String Functions →  Examples of String Functions → 

String Functions, to_mixed and from_mixed

This example demonstrates the string functions to_mixed and from_mixed.

Source Code

REPORT demo_to_from_mixed.

PARAMETERS: original TYPE c LENGTH 30 LOWER CASE
                     DEFAULT 'ABAP_DOCU_START'.
SELECTION-SCREEN SKIP.
PARAMETERS: to_sep   TYPE c LENGTH 1  LOWER CASE
                     DEFAULT '_',
            to_case  TYPE c LENGTH 1  LOWER CASE
                     DEFAULT 'a',
            to_min   TYPE i DEFAULT 1.
SELECTION-SCREEN SKIP.
PARAMETERS: frm_sep  TYPE c LENGTH 1  LOWER CASE
                     DEFAULT '.',
            frm_case TYPE c LENGTH 1  LOWER CASE
                     DEFAULT 'A',
            frm_min  TYPE i DEFAULT 5.


CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD main.
    DATA: to_mixed   TYPE string,
          from_mixed TYPE string.
    TRY.
        SKIP.
        WRITE: (12) 'original:',  original.
        to_mixed = to_mixed( val  = original
                             sep  = to_sep
                             case = to_case
                             min  = to_min ).
        SKIP.
        WRITE: /(12) 'to_mixed:', to_mixed.
        from_mixed = from_mixed( val  = to_mixed
                                 sep  = frm_sep
                                 case = frm_case
                                 min  = frm_min ).
        SKIP.
        WRITE: /(12) 'from_mixed:', from_mixed.
      CATCH cx_sy_strg_par_val.
        MESSAGE 'Invalid parameters' TYPE 'I' DISPLAY LIKE 'E'.
        RETURN.
    ENDTRY.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  demo=>main( ).

Description

The program queries the parameters for the functions to_mixed and from_mixed on the selection screen. The result of to_mixed is edited by from_mixed.