String Operation – Shift


SHIFTing- is likely to repositioning the string.

In ABAP – Left shift, Right Shift and circular left and circular right shift.


Step1. Code

” SHIFTING “
DATA :    str1 TYPE string VALUE ‘SAP ABAP PROGRAM’,
str2 TYPE string VALUE ‘SAP ABAP PROGRAM’,
str3 TYPE string VALUE ‘SAP ABAP PROGRAM’,
str4 TYPE string VALUE ‘SAP ABAP PROGRAM’,
str5 TYPE string VALUE ‘SAP ABAP PROGRAM’.

” Left Shift
WRITE :‘Before Left Shift:’str1.
SHIFT str1 LEFT BY PLACES.
WRITE :‘After Left Shift:’str1.
ULINE.

” Right Shift
WRITE :‘Before Right Shift:’str2.
SHIFT str2 RIGHT BY PLACES.
WRITE :‘After right Shift:’str2.
ULINE.

” SHIFT upto a substring
WRITE :‘Before Shift upto a substring’,str3 .
SHIFT str3 UP TO  ‘ABAP’.
WRITE :‘After shift upto a substrung’,str3 .
ULINE.

” Circular Shift- Left
” by default it is left circular shift
WRITE :‘Before left circular Shift:’str4.
“SHIFT str4 CIRCULAR BY 3 PLACES.
SHIFT str4 LEFT CIRCULAR BY PLACES.
WRITE :‘After left  circular Shift:’str4.
ULINE.

” Circular Shift-Right
WRITE :‘Before right circular Shift:’str5.
SHIFT str5 RIGHT CIRCULAR BY PLACES.
WRITE :‘After right circular Shift:’str5.
ULINE.



Step2. Here is the output!


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s