zMTHFQR

removing dots/commas from excel sheet

Sep 15th, 2020
1,611
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DATA: v_output(30) TYPE c VALUE 'Hello, World!',
  2.       number       TYPE i,
  3.       str_len      TYPE i,
  4.       offset       TYPE i,
  5.       length       TYPE i,
  6.       replace_len  TYPE i.
  7.  
  8. PARAMETERS: p_input TYPE c LENGTH 30.
  9.  
  10. number = 2.
  11.  
  12. WHILE number > 1."Clear all thousands separators, leave only the decimal separator from input.
  13.  
  14.   REPLACE ALL OCCURRENCES OF ',' IN p_input WITH '.'.
  15.   FIND ALL OCCURRENCES OF '.' IN p_input MATCH COUNT number.
  16.   IF sy-subrc = 0 AND number > 1.
  17.     REPLACE FIRST OCCURRENCE OF '.' IN p_input WITH ''.
  18.   ENDIF.
  19.   CONDENSE p_input NO-GAPS.
  20.  
  21. ENDWHILE.
  22.  
  23. str_len = strlen( p_input ).
  24. replace_len = strlen( v_output ).
  25.  
  26. WHILE str_len > replace_len."Replace section of the string with predefined value.
  27.  
  28.   FIND FIRST OCCURRENCE OF REGEX '\d' IN p_input MATCH OFFSET offset.
  29.   IF sy-subrc = 0.
  30.     REPLACE SECTION OFFSET offset LENGTH replace_len OF:
  31.     p_input  WITH v_output.
  32.     FIND FIRST OCCURRENCE OF REGEX '\d' IN p_input MATCH OFFSET offset.
  33.     str_len = strlen( p_input ).
  34.     REPLACE SECTION OFFSET offset LENGTH str_len - replace_len OF:
  35.     p_input  WITH ''.
  36.   ENDIF.
  37.  
  38.   str_len = strlen( p_input ).
  39.  
  40. ENDWHILE.
  41.  
  42.  
  43. WRITE: / p_input.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×