‎2009 Feb 20 1:05 PM
Hi,
I had like to move the -ve sign of the number from rear to front
Ex: if the number is 2000- i want to have this value in the output as -2000.
for that i had used the ABAP key words shift right circular
This is working fine for the numbers as well. i had made the numbers as data types Chars and performed the coding.
But if the number is in the format 0.0001-, then even after applying the shift right circular it is not working-
But the decimal part has to be maintained as these decimal values are needed in the final output
‎2009 Feb 20 1:16 PM
Hi,
try this code will definitely work.
DATA: w_pack TYPE p DECIMALS 4 VALUE '-20.0021'.
DATA: w_amount(100) TYPE c.
w_amount = w_pack.
IF w_amount < 0.
SHIFT w_amount RIGHT DELETING TRAILING '-'.
SHIFT w_amount LEFT DELETING LEADING ' '.
CONCATENATE '-' w_amount INTO w_amount.
WRITE:/ w_amount.
ELSE.
SHIFT w_amount LEFT DELETING LEADING ' '.
WRITE:/ w_amount.
ENDIF.regards
sarves
Edited by: Sarves Sombhatla on Feb 20, 2009 2:17 PM
‎2009 Feb 20 1:16 PM
Hi,
try this code will definitely work.
DATA: w_pack TYPE p DECIMALS 4 VALUE '-20.0021'.
DATA: w_amount(100) TYPE c.
w_amount = w_pack.
IF w_amount < 0.
SHIFT w_amount RIGHT DELETING TRAILING '-'.
SHIFT w_amount LEFT DELETING LEADING ' '.
CONCATENATE '-' w_amount INTO w_amount.
WRITE:/ w_amount.
ELSE.
SHIFT w_amount LEFT DELETING LEADING ' '.
WRITE:/ w_amount.
ENDIF.regards
sarves
Edited by: Sarves Sombhatla on Feb 20, 2009 2:17 PM
‎2009 Feb 20 1:35 PM
‎2009 Feb 20 1:38 PM
You could always use a regex:
DATA: g_sub1(10) TYPE c,
g_sub2(10) TYPE c,
g_result(20) TYPE c,
g_in(10) TYPE p DECIMALS 9 VALUE '000.0001-'.
g_result = g_in.
FIND all OCCURRENCEs OF REGEX '(\b\S+\b)(-?)' IN g_result SUBMATCHES g_sub1 g_sub2.
CONCATENATE g_sub2 g_sub1 INTO g_result.
WRITE:/ g_result.
‎2009 Feb 20 1:28 PM
Hello Simran,
I am trying this code & it works fine for me:
PARAMETERS: p_amt TYPE menge_d.
DATA:
l_v_amt1 TYPE char16.
WRITE p_amt TO l_v_amt1.
SHIFT l_v_amt1 BY 1 PLACES RIGHT CIRCULAR.
CONDENSE l_v_amt1.
WRITE: l_v_amt1.Hope this might be of some use to you.
BR,
Suhas