Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > SAP Forum > SAP ABAP HR Forum


String Handling in ABAP - Removing Unwanted Char


Reply
Views: 1618  
Thread Tools Rate Thread
  #1  
Old 05-21-2009, 09:14 AM
bholus7
Guest
 
Posts: n/a
Default String Handling in ABAP - Removing Unwanted Char

String Handling in ABAP - Removing Unwanted Char


I am importing data from a file and the string data has HTML tags in the description example Line Clearance, how I can programmatically strip the tags away and just leave the text?

The code for this String Handling Line Clearance .

REPORT zstring.
DATA : ipstr TYPE string.
DATA : opstr TYPE string.
DATA : len TYPE i VALUE 0.
DATA : ch TYPE char1.
DATA : num TYPE i VALUE 0. "No of Characters to be taken
DATA : pos TYPE char3. "Position of Char in the Input String
*Input string
ipstr = ' Line Clearance '.
*Removing only ""
REPLACE ALL OCCURRENCES OF '' IN ipstr WITH ' '.
*Removing only "<"
REPLACE ALL OCCURRENCES OF '<' IN ipstr WITH ' '.
CONDENSE ipstr.
*Length of Input String
len = STRLEN( ipstr ).
DO len TIMES.
*Char by Char
ch = ipstr+pos(1).
pos = pos + 1.
*Scan each char in input String for ">"
FIND '>' IN ch IGNORING CASE.
IF sy-subrc = 0.
num = len - pos.
*Output String
opstr = ipstr+pos(num).
ENDIF.
ENDDO.
WRITE :/ opstr.

Reply With Quote
Reply

New topics in SAP ABAP HR Forum





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)