‎2007 Jun 28 1:05 PM
HI
I have some value in my internal table like FLEX10,A10.A10FLEX,Now i need output like FLEX,A,AFLEX.
How can split numirical from char field .
please help me
To be Reward all helpfull answers
regards.
Jay
‎2007 Jun 28 1:17 PM
Hello,
Check this sample:
REPORT ZV_SDN_3 .
DATA: BEGIN OF ITAB OCCURS 0,
FIELD(10),
END OF ITAB.
DATA: INT1 TYPE I,
INT2 TYPE I VALUE 1.
ITAB-FIELD = 'FLEX10'.
APPEND ITAB.
ITAB-FIELD = 'A10'.
APPEND ITAB.
ITAB-FIELD = 'A10FLEX'.
APPEND ITAB.
LOOP AT ITAB.
CLEAR INT1.
DO.
IF NOT ITAB-FIELD+INT1(INT2) IS INITIAL.
IF ITAB-FIELD+INT1(INT2) CA '0123456789'.
CLEAR ITAB-FIELD+INT1(INT2).
ENDIF.
ADD 1 TO INT1.
* ADD 1 TO INT2.
ELSE.
CONDENSE ITAB-FIELD NO-GAPS.
MODIFY ITAB.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
LOOP AT ITAB.
WRITE: ITAB-FIELD.
ENDLOOP.
VAsanth
‎2007 Jun 28 1:09 PM
Hi
try using the STring commands and see
Take the fields separately
str1, str2
use REPLACE or OVERLAY command to replace the string '10' with spaces in each
then use CONDENSE command to remove the spaces in strings
then use them
try and see
Reward points for useful Answers
Regards
Anji
Message was edited by:
Anji Reddy Vangala
‎2007 Jun 28 1:11 PM
Hi,
Splits a character string.
Syntax
SPLIT <c> AT <del> INTO <c1>... <cn> INTO TABLE <itab>.
Searches the field <c> for the character <del> and places the partial fields before and after <del>
into the target fields <c1> <cn>, or into a new line of the internal table <itab>.
OR
you can use FM: 'STRING_SPLIT_AT_POSITION'
Ex.
PROGRAM CALL_FUNCTION.
DATA: TEXT(10) TYPE C VALUE '0123456789',
TEXT1(6) TYPE C,
TEXT2(6) TYPE C.
PARAMETERS POSITION TYPE I.
CALL FUNCTION 'STRING_SPLIT_AT_POSITION'
EXPORTING
STRING = TEXT
POS = POSITION
IMPORTING
STRING1 = TEXT1
STRING2 = TEXT2
EXCEPTIONS
STRING1_TOO_SMALL = 1
STRING2_TOO_SMALL = 2
POS_NOT_VALID = 3
OTHERS = 4.
CASE SY-SUBRC.
WHEN 0.
WRITE: / TEXT, / TEXT1, / TEXT2.
WHEN 1.
WRITE 'Target field 1 too short!'.
WHEN 2.
WRITE 'Target field 2 too short!'.
WHEN 3.
WRITE 'Invalid split position!'.
WHEN 4.
WRITE 'Other errors!'.
ENDCASE.
The function module splits an input field at a particular position into two output
fields. If the contents of POSITION are in the interval [4,6], the function module is
executed without an exception being triggered. For the intervals [1,3] and [7,9],
the system triggers the exceptions STRING2_TOO_SMALL and
STRING2_TOO_SMALL respectively. For all other values of POSITION, the
exception POS_NOT_VALID is triggered.
Regards,
Bhaskar
‎2007 Jun 28 1:13 PM
Hi,
namaste!!
DATA: BEGIN OF ITAB OCCURS 0,
FIELD(10),
END OF ITAB.
DATA: INT1 TYPE I,
INT2 TYPE I VALUE 1.
ITAB-FIELD = 'FLEX10'.
APPEND ITAB.
ITAB-FIELD = 'A10'.
APPEND ITAB.
ITAB-FIELD = 'A10FLEX'.
APPEND ITAB.
LOOP AT ITAB.
CLEAR INT1.
DO.
IF NOT ITAB-FIELD+INT1(INT2) IS INITIAL.
IF ITAB-FIELD+INT1(INT2) CA '0123456789'.
CLEAR ITAB-FIELD+INT1(INT2).
ENDIF.
ADD 1 TO INT1.
ADD 1 TO INT2.
ELSE.
CONDENSE ITAB-FIELD NO-GAPS.
MODIFY ITAB.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
LOOP AT ITAB.
WRITE: ITAB-FIELD.
ENDLOOP.
<b>Rewardpoints</b>
Regards
Message was edited by:
skk
‎2007 Jun 28 1:19 PM
HI Mr SKK.
I need out put like
from
A10 TO A
FLEX10 TO FLEX
A10FLEX TO AFLEX
Please help me
Surely i reward all helpfull answer.
‎2007 Jun 28 1:13 PM
Hi
Use this syntax
REPLACE by Pattern :
Replaces strings in fields with other strings using a pattern.
Syntax
REPLACE [ FIRST OCCURENCE OF | ALL OCCURENCES OF ] <old>
IN [ SECTION OFFSET <off> LENGTH <len> OF ] <text> WITH <new>
[IGNORING CASE|RESPECTING CASE]
[IN BYTE MODE|IN CHARACTER MODE]
[REPLACEMENT COUNT <c>]
[REPLACEMENT OFFSET <r>]
[REPLACEMENT LENGTH <l>].
In the string <text>, the search pattern <old> is replaced by the content of <new>. By default, the first occurrence of <old> is replaced. ALL OCCURENCES specifies that all occurrences be replaced. In the fields <old> and <new>, trailing spaces in C fields are ignored, but included in <text>. The SECTION OFFSET <off> LENGTH <len> OF addition tells the system to search and replace only from the <off> position in the length <len>. IGNORING CASE or RESPECTING CASE (default) specifies whether the search is to be case-sensitive. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions. The REPLACEMENT additions write the number of replacements, the offset of the last replacement, and the length of the last replaced string <new> to the fields <c>, <r>, and <l>.
REPLACE by Position:
Replaces strings in fields with other strings by position.
Syntax
REPLACE <str1> WITH <str2> INTO <c> [LENGTH <l>].
[IN BYTE MODE|IN CHARACTER MODE].
ABAP searches the field <c> for the first occurrence of the first <l> characters in the pattern <str1> and replaces them with the string <str2>. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions
‎2007 Jun 28 1:17 PM
Hello,
Check this sample:
REPORT ZV_SDN_3 .
DATA: BEGIN OF ITAB OCCURS 0,
FIELD(10),
END OF ITAB.
DATA: INT1 TYPE I,
INT2 TYPE I VALUE 1.
ITAB-FIELD = 'FLEX10'.
APPEND ITAB.
ITAB-FIELD = 'A10'.
APPEND ITAB.
ITAB-FIELD = 'A10FLEX'.
APPEND ITAB.
LOOP AT ITAB.
CLEAR INT1.
DO.
IF NOT ITAB-FIELD+INT1(INT2) IS INITIAL.
IF ITAB-FIELD+INT1(INT2) CA '0123456789'.
CLEAR ITAB-FIELD+INT1(INT2).
ENDIF.
ADD 1 TO INT1.
* ADD 1 TO INT2.
ELSE.
CONDENSE ITAB-FIELD NO-GAPS.
MODIFY ITAB.
EXIT.
ENDIF.
ENDDO.
ENDLOOP.
LOOP AT ITAB.
WRITE: ITAB-FIELD.
ENDLOOP.
VAsanth
‎2007 Jun 28 1:49 PM
HI Vasanth.
Thank you so much ,I rewarded you because you given Perfect answer.
Thanks Lot.
Regards.
Jay
‎2007 Jun 28 1:17 PM
Also check this
REPORT z_test.
data:
w_text(15) value 'FLEX10',
w_result(10).
if w_text ca '0123456789'.
if sy-fdpos NE 0.
w_result = w_text+0(sy-fdpos).
endif.
endif.
write:w_result.
‎2007 Jun 28 1:19 PM
Hi Jay,
I'd keep things simple and generic, by firstly replacing all the numeric's with spaces and then removing the spaces.
To replace all the numeric's use
TRANSLATE <itab_line> using '0 1 2 3 4 5 6 7 8 9 '.
Then remove the spaces
CONDENSE <itab_line> no-gaps.
Regards,
Darren
‎2007 Jun 28 1:20 PM
consider the code below
data:a1(10),
a2(10),
a3(10).
a1 = 'FLEX10'.
a2 = 'A10'.
a3 = 'A10FLEX'.
replace all occurrences of '10' in a1 with ''.
replace all occurrences of '10' in a2 with ''.
replace all occurrences of '10' in a3 with ''.
write:/ a1,a2,a3.
‎2007 Jun 28 1:50 PM
hi Jay
Normally to split numerals from string we use
<b>CONDENSE ITAB-FIELD NO-GAPS.</b>
The data object text must be character-type. If the data object has a fixed length, any space created by the condense operation is filled with blanks on the right. If the data object is of the type string, its length is adapted to the result of the condense operation.
so all the numerals followed by the char are removed n filed with blank spaces...
REWARD IF USEFUL