Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

shift command

Former Member
0 Likes
1,612

data: ALPHA1(14) TYPE C value '10000.00' .

alpha1 has the value '10000.00'.

I want to remove the decimal part using the shift command and the string should be '10000 '.

How we can use the shift command to change the string as '10000'.

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
934

Abhishek,

Declare a integer variable and move the value of the decimal variable to that. you problem will get solved.. you need not to use shift statement.

<b>Reward for helpful answers</b>

Satish

Message was edited by:

Satish Panakala

6 REPLIES 6
Read only

Former Member
0 Likes
935

Abhishek,

Declare a integer variable and move the value of the decimal variable to that. you problem will get solved.. you need not to use shift statement.

<b>Reward for helpful answers</b>

Satish

Message was edited by:

Satish Panakala

Read only

0 Likes
934

Hi Satish.

Only when the currency is without any decimal places like JPY I need to declare a integer variable and move the value of the decimal variable to that.

Is there any way to find out that whether the currency is having decmal places or not.

If the currency does not decimal placves like JPY or LIRA, then we will declare a integer variable and move the value of the decimal variable to that else we don't do any change.

How we can implement the code to check whether the currency is having decimal places or not. Pls suggest. Thanks

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
934

If you really want to use the SHIFT statement, this will probably work.

data: ALPHA1(14) TYPE C value '10000.00' 

shift alpha right by 3 places.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
934

Hi abhishek,

try this

REPORT YCHATEST2.

DATA: ALPHA1(14) TYPE C VALUE '10000.00' .

SEARCH ALPHA1 FOR '...'.

IF SY-SUBRC EQ 0.
  CLEAR ALPHA1+SY-FDPOS(3).
ENDIF.

WRITE : ALPHA1.

Read only

JozsefSzikszai
Active Contributor
0 Likes
934

hi Abhishek,

is it necessary to use the SHIFT command?

You can easily do with SPLIT:

SPLIT alpha1 INTO ... AT '.'.

then you have 10000 and 00

ec

Read only

Former Member
0 Likes
934

Hi

Possible Shift functions :

  • shifting strings by a given number of places

DATA: t1(10) TYPE c VALUE 'abcdefghij',

string1 LIKE t1.

string1 = t1.

WRITE string1.

SHIFT string1.

WRITE / string1.

string1 = t1.

SHIFT string1 BY 3 PLACES LEFT.

WRITE / string1.

string1 = t1.

SHIFT string1 BY 3 PLACES RIGHT.

WRITE / string1.

string1 = t1.

SHIFT string1 BY 3 PLACES CIRCULAR.

WRITE / string1.

SKIP.

ULINE.

  • shifting up to a given string

DATA: t2(10) TYPE c VALUE 'abcdefghij',

string2 LIKE t2,

str2(2) TYPE c VALUE 'ef'.

string2 = t2.

WRITE string2.

SHIFT string2 UP TO str2.

WRITE / string2.

string2 = t2.

SHIFT string2 UP TO str2 LEFT.

WRITE / string2.

string2 = t2.

SHIFT string2 UP TO str2 RIGHT.

WRITE / string2.

string2 = t2.

SHIFT string2 UP TO str2 CIRCULAR.

WRITE / string2.

SKIP.

ULINE.

  • shifting a string depending on the first or last sign

DATA: t3(14) TYPE c VALUE ' abcdefghij',

string3 LIKE t3,

str3(6) TYPE c VALUE 'ghijkl'.

string3 = t3.

WRITE string3.

SHIFT string3 LEFT DELETING LEADING space.

WRITE / string3.

string3 = t3.

SHIFT string3 RIGHT DELETING TRAILING str3.

WRITE / string3.

Thanks,

Praveen