Extract Letter Char of Input Field

Code di bawa ini bisa digunakan untuk menghilankgan karakter huruf dan hanya mengambil karakter numeric dalam suatu field.

Example:
Input: Floor 31; Output: 31
Input: Length 29,8 cm; Output: 29,8

PARAMETERS: p_text(10).

DATA: d_text(10),
      d_len TYPE i,
      d_count TYPE i,
      d_texto(10).

d_text = p_text.
d_len = STRLEN( d_text ).

IF d_len > 0.
  DO d_len TIMES.
    IF d_text+d_count(1) CA '0123456789,'.
      CONCATENATE d_texto d_text+d_count(1) INTO d_texto.
      CONDENSE d_texto.
    ENDIF.
    ADD 1 TO d_count.
  ENDDO.
ENDIF.

WRITE d_text.

Happy trying šŸ™‚

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s