*---------------------------------------------------------------------
* 29.04.2003 |Initial Author - | This program search for a delimiter
* |Amandeep Singh | and split it into two parts.
*---------------------------------------------------------------------
*
* Split String into two parts at delimeter
* Current delimeter is '/'.
*
REPORT ZSTRING.
DATA: LENGTH TYPE I,
REMAINING_LENGTH TYPE I ,
NEXT_POINTER TYPE I ,
FIRST_HALF(20) TYPE C ,
SECOND_HALF(20) TYPE C ,
TEMP TYPE I .
PARAMETER: WORD(35) TYPE C . "INPUT WORD
START-OF-SELECTION.
LENGTH = STRLEN( WORD ). "Length of the input String
SEARCH WORD FOR '/'.
IF SY-SUBRC = 0 .
IF SY-FDPOS > 0.
MOVE WORD+0(SY-FDPOS) TO FIRST_HALF.
ENDIF.
TEMP = SY-FDPOS + 1.
IF TEMP <> LENGTH.
NEXT_POINTER = SY-FDPOS + 1.
REMAINING_LENGTH = ( LENGTH - SY-FDPOS ) - 1.
MOVE WORD+NEXT_POINTER(REMAINING_LENGTH) TO SECOND_HALF.
ENDIF.
ENDIF.
WRITE:/'Input String:', WORD
.
WRITE:/'First Half:', FIRST_HALF.
WRITE:/'Second Half:', SECOND_HALF.
*-- End of Program
Additional add-on by Mike
Or you could just do:
split p0_source at con_tm into p0_left p0_right.
And if you have multiple splits then use a 1 field table as the target.
No comments:
Post a Comment