2009 Apr 18 4:07 PM
hi guys,
i have a piece of code which says t_pa-amt= t_o-amt * -1.
and i get the amt as 500.0000-
were minus sign is after the no i want this before the no ie -500
2009 Apr 18 5:07 PM
Hi Anjum,
just do below
data : lv_neg type p decimals 2,
lv_var(20) .
lv_neg = '666.55'.
lv_neg = lv_neg * -1.
lv_var = lv_neg.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = lv_varit works
Thanks!!
hi guys,
i have a piece of code which says t_pa-amt= t_o-amt * -1.
and i get the amt as 500.0000-
were minus sign is after the no i want this before the no ie -500
2009 Apr 18 5:01 PM
define a variable with char type with same length send the value to this variable with out sign and add
sign to before the value.
2009 Apr 18 5:07 PM
Hi Anjum,
just do below
data : lv_neg type p decimals 2,
lv_var(20) .
lv_neg = '666.55'.
lv_neg = lv_neg * -1.
lv_var = lv_neg.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = lv_varit works
Thanks!!
2009 Apr 18 5:18 PM
2009 Apr 18 6:03 PM
HI,
You can try this way...
DATA L_AMT TYPE CHAR16.
WRITE ITAB-AMOUNT TO L_AMT CURRENCY <Currency>.
IF ITAB-AMOUNT < 0.
SHIFT L_AMT BY 1 PLACES RIGHT CIRCULAR.
ENDIF.
2009 Apr 20 7:36 AM
hi its working fine when i use a temp variable n when i again try to trasfer it to the field in itab to which i want - sign is getting appended at the end.... the data type of destination variable is BAPINEBTR
and i need to maintain the same datatype coz when i change the datatype in my structure i face some other problems,
so can u suggest some solution where in i need to append the sign in beginning n not change the datatype...
thanks,
2009 Apr 20 9:33 AM
Hi,
Do you want it to be stored as amount with minus and the beginning? or to be just displayed with minus ahead?
You have to disthinguish these two requirements explicitly.
As long as amount is stored in P type, the sign will be at the end (internally i.e. in your structure field). Now when you want to display it, it must be cast to C with different techniques (i.e. by means of EDIT MASK) we suggested above. This can be applied even in ALV, setting appropriate mask for a field.
But you can't simply change sign position in P type itself.
Hope this claryfies your doubt.
Regards
Marcin
2009 Apr 20 10:26 AM
k ..thx for ur response let me be a bit clear...
i actually have a structure where the amt field is of type BAPINEBTR and i get the value in my downloaded file as 50000.0000- wherein i just need to get - 50000.0000 with the - sign in the beginning
so if i change the type in the structure i get the value - 50000 with out the decimal values so let me know any method where in can put the sign in the beginning of the value ......so the file i download will get
teh value as -50000.0000 tats it....can u write a method..
2009 Apr 20 11:10 AM
You can only pass character like value to function module cloi_put_sign_in_front.
So instead you can use this method:
Declare a field in your internal table of type char23 (p_char in example below).
Populate the data in that field using the code below.
data: p_amt type BAPINEBTR value '-5000.0000',
p_char type char23,
len type i.
p_char = p_amt.
shift p_char left deleting leading space.
len = strlen( p_char ) - 1.
if p_char+len(1) eq '-'.
concatenate '-' p_char+0(len) into p_char.
endif." modify table after this transporting p_char.
Regards,
Lalit Mohan Gupta.
2009 Apr 18 8:01 PM
you can do it this way.
data: p_amt type char.
p_amt = t_pa-amt.
if t_pa-amt < 0.
len = strlen( p_amt ) - 1.
concatenate '-' p_amt+0(len) into p_amt.
endif.Regards,
Lalit Mohan Gupta.
2009 Apr 18 10:12 PM
Hi,
Use edit mask:
DATA: amount TYPE p DECIMALS 2 VALUE '-123.45'.
WRITE amount USING EDIT MASK 'V___.__'.
V indicates where the sign is to be placed.
Regards
Marcin
2009 Apr 19 12:53 AM
2009 Apr 19 10:16 AM
Hi
Find the below piece of code which may help to resolve your issue
parameters:p_wrbtr like bseg-wrbtr.
data:v_wrbtr(15) type c.
data:v_wrbtr_sign(16) type c.
v_wrbtr = p_wrbtr.
condense v_wrbtr.
concatenate '-' v_wrbtr into v_wrbtr_sign.
write:/ v_wrbtr_sign.
Regards
Sripal
2009 Apr 20 8:58 AM
hi,
Please refer to the following code.
DATA: ld_amount(100) TYPE c.
PERFORM move_minus_sign CHANGING ld_amount.
&----
*& Form move_minus_sign
&----
Move minus sign from end to begining of number value
i.e. from 100.00- to -100.00
----
<--P_AMOUNT amount
----
FORM move_minus_sign CHANGING p_amount.
check if negative amount
IF p_amount LT 0.
Hope this is helpful to u .
Warm Regards,
Srilu.
SHIFT p_amount RIGHT DELETING TRAILING '-'.
SHIFT p_amount LEFT DELETING LEADING ' '.
CONCATENATE '-' p_amount INTO p_amount.
ELSE.
SHIFT p_amount LEFT DELETING LEADING ' '.
ENDIF.
ENDFORM. " move_minus_sign
2009 Apr 20 9:24 AM
2009 Apr 20 11:01 AM
you this FM,
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = fieldname.
Regards,
Joan
2009 Apr 20 11:14 AM
yeh i used this fm this way
t_py-amt = w_ag-amt. // in this itab im getting the value as 5000.0000-
so i made a call to the fm
call funtion 'cloi_put_sign_in_front'
changing
value = t_py-amt.
it says call u fm is not correct and lands into dump...
2009 Apr 20 11:19 AM
Hi,
Field t_py-amt should be of CLIKE type.....
declaration is not matching....
at the declaration part do it this way,
data :
Begin of w_ag,
" variables you want for internal table....
amt type clike,
" variables you want for internal table....
end of w_ag.Regards,
Siddarth
2009 Apr 20 11:20 AM
You get a dump because you are passing P type, not C, which is expected here.
DATA: BEGIN OF t_py OCCURS 0,
amt_org TYPE bapinebtr, "original amount
amt_con TYPE c LENGTH 60, "converted amount
END OF t_py.
t_py-amt_con = t_py-amt_org = '5000.0000' * -1.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = t_py-amt_con.
Regards
Marcin
2009 Apr 20 11:43 AM
but by using the same teh value will be stored in the new variable i have declared ie in the variable
t_py-amt_con now i need to store the value into its orginal field only so wat should i do,
2009 Apr 20 11:21 AM
Hi,
The Function module expects input of form Character (type CLIKE).
So declare a variable of type c and size (some 20).
Assign your value to this charcter variable and send this char variable to the FM.
DAta : lv_amt type clike.
lv_amt = t_py-amt.
call funtion 'cloi_put_sign_in_front'
changing
value = lv_amt.
write: lv_amt.
Thanks & Regards,
Bhupal
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |