Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Friday, April 18, 2008

Split String into two parts at delimiter SAP ABAP INTERVIEW Questions

*---------------------------------------------------------------------
* 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

No comments:

Post a Comment

Content

Recent Topics