Round Decimal value based on last digit
Hi Experts,
I'm trying to round the decimal value based on its last digit. If the last digit is >5 then add +1 to the digit before that and remove the last digit else just remove.
ie.
-59664.15000000005 should become -59664.15
-21308625.00000002 should become -21308625
-85234500.00000006 should become -85234500.0000001
18288102.85714287 should become 18288102.8571429I tried with Round Function but it did not help,
Pls assist.
Thanks!
Got it done just took the length and did the change.. sorry for this lame question.. should have tried before posting the question. Tx for your time...
Similar Messages
-
I have a report that takes 2 date parameters ("Start Date" and "End Date"). Get fields back based on that criteria....I want to create a formula field that shows me the "Amount" field data that is equal to the "End Date".
How can I do that?
Thanks in Advance!!Hi shaun,
You can take a running total of the date as
Running total name : datecount
Summary Field to Summarize as : yourdatefield
Type of summary : Nth largest
N is : 1
Evaluate
For Each Record
Reset
Never
Now Create a Formula for ur fileld as
if {Command.Yourdate} = {#datecount} then {Command.fieldname}
I hope this solves your problem
Regards,
Pradeep -
Rounding off to a variable value to 4 decimal values in sap script ouput
Hi All,
I have a value getting displayed in sap script output as 235.6789 i want to Round off this variable value to 4 decimal values!
What is the formatting option need to be used & how!
Thanks in advance.
Thanks,
Deep.Hi,
1.In layout just call that variable, where you need like:
&variable(.4)&.
Just see these:
&symbol(Z)& Omit Leading Zeros
&symbol(S)& Omit Leading Sign
&symbol(<)& Display Leading Sign to the Left
&symbol(>)& Display Leading Sign to the Right
&symbol(C)& Compress Spaces
&symbol(.N)& Display upto N decimal places
&symbol(T)& Omit thousands separator
&symbol(R)& Right justified
&symbol(I)& Suppress output of the initial value
Regards,
If helpful reward with points(Don't forget). -
Excel import rounding up decimal values
In my excel file I have a column that contains dollars and cents (e.g. 49.95). When I run the import the values in this column are rounded up to the next integer (e.g. 49.95 is rounded up to 50). Is this a bug or am I doing something wrong?
Thanks,
PeterHi All,
I have already migrated lakhs of records and I am facing the same problem for decimal value migration. Shall I know whether anyone has fixed this problem? Is there any other free tool for SQL Server to ORACLE migration? Please do guide me as soon as possible.
Thanks,
Srinivasan.T -
ALV: issue in truncating decimal values (rounding up)
Hi,
I have been receiving a problem truncating decimal values in alv environment using this abap code.
WRITE gwa_komv-kwert TO gv_out_tax CURRENCY rte0143sf-currency
DECIMALS l_decimals LEFT-JUSTIFIED.
where l_decimals = 0.
More exactly the value is rounded up but this is not my expectation.
Any idea?
Thanks.
GiovanniStandard behaviour with DECIMALS 0: rounding up or own.
And when you use the addition DECIMALS, then the CURRENCY addition is ignored as well. -
Rounding a decimal value to 3 digits
I have opened a UDF and copied the value of Total (LC) column in that field. I want to round off the copied value to 2 digits.
Below is the query written to copy the value.
SELECT ($[$38.21.NUMBER] * $[$38.U_GST.1.11]) / 100
Below is the query written to ROUND the value.
SELECT ROUND(($[$38.21.NUMBER] * $[$38.U_GST.1.11]) / 100, 2)
Thanks & Regards,Try: SELECT ROUND(($[$38.21.NUMBER\] * $[$38.U_GST.NUMBER\]) / 100, 3)
However, I think it is probably not working because B1 has internal checking to make sure the decimal value follow your setting. If you setup your currency by 2 decimals, you may never get any additional decimal place.
Thanks,
Gordon -
Excise Amount with three Digit decimal value
Dear All,
I enabled three digit decimal values for sales.
When I am raising a Excise Invoice through J1I3, two digit only appearing?
For Ex: Excise amount in sale order is 6897.525 where as in J1I3 transaction, it's showing as 68975.25.
How to correct this issue?
Rgds,
Senni.BDear GSL,
For Import purchase purpose, client is asking for three digit decimal values. But when we go for excise related transactions, it's taking only two digits of the actual value.
Is there any settings in CIN to activate three digit decimal?
Rgds,
Senni.B -
BPEL round function with precision for a decimal value?
Dear All,
I need to do a rounding of a higher value to 3 precisioned one.
As per the round function available in Jdeveloper, I can only round a decimal to its respective integer value.
But my requirement is to retain the decimal value, but with a limited precision value...
How can I accomplish this.. Is there any extension of round function in BPEL to do this...?
Please update..
Many thanks...Use the function format-number(variable,precision_num)+.
Thanks,
Sen -
How to make the Decimal values into Round off value
Hi Experts,
I have an internal table with 3 columns, the 3rd column having decimal values, Now i want to convert the values in to whole number, Ex: 15.67 will be 15.7
Anyone plz help this.
Mohanahii
use following code
DATA:
wa_val type p decimals 2,
L_ANDEC like T006-ANDEC value 1,
wa_val2 type p decimals 1.
wa_val = '15.67' .
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = L_ANDEC
input = wa_val
SIGN = '+'
IMPORTING
OUTPUT = wa_val2
EXCEPTIONS
INPUT_INVALID = 1
OVERFLOW = 2
TYPE_INVALID = 3
OTHERS = 4
WRITE:/ wa_val2.
regards
twinkal -
Issue in Decimal value round off
Hi All, I am facing an issue wherein Decimal value of 0.01 is getting converted to 0.00. Let me brief you about Source-target Types - Source - Flat FileTarget - DB2Powercenter Version - 9.6.1 HF2 Issue - Field in Source File is defined as Number(5,2).Corrosponding field from Db2 Target Table is defined as Decimal(5,2). Mapping is simple straight forward mapping with 1:1 loading from Source to target. Now, my Source File contain data as below - 0.010.020.0312.01 When I execute mapping, DB2 target Table gets loaded with all records.Value from corrosponding DB2 Target Table is - 0.000.020.0312.01 As you can see value of 0.01 is getting converted to 0.00 whereas all other values are working fine as expected. As a quick fix, I have applied to_decimal(source_field,2) before loading it to target. Could anyone please explain if this is an issue with Powercenter or there's some other issue. If I think it's a rounding issue then how come value of 0.02 is working fine? Please advise.
Hi All, I have one scenario to read the source file . The file delimiter is '|' . The no of pipeline for each line is 17. So if a line containing more than 17 , send an error email. For this first i am printing tota pipeline in ecah line to afile called pipelinecount.txt . Then i will read this file and send each value to while loop /for loop , where it will get > 17 , it will exit the process and send an email. But here in script i am getting error at while line. Could anyone help. #! /bin/kshset -x SOURCE_DIR=/vp01/SrcFilessed 's/[^|]//g' /vp01/SrcFiles/Test.txt | awk '{ print length }'> /vp01/SrcFiles/pipelinecount.txtcd $SOURCE_DIRwhile line in `cat pipelinecount.txt`; do if [ $line -eq 17 ];thenecho "No issue in pipeline"exit 0;fiif [ $line -gt 17 ];thenecho "No of pipelines exceeded the expected. Please verify the source file." | mailx -s "WKFS Load: Failed" [email protected]
-
Re: Issue in Decimal value round off in DB2
Hi All, It is happening only only when the decimal separator of source is ',' and behaving normally when decimal separator is '.'. Some how ..we casted the incoming field to TO_DECIMAL(IN_FIELD,2) ..in that case it is working fine. Regards,Srinivas
Hi All, I am facing an issue wherein Decimal value of 0.01 is getting converted to 0.00. Let me brief you about Source-target Types - Source - Flat FileTarget - DB2Powercenter Version - 9.6.1 HF2 Issue - Field in Source File is defined as Number(5,2).Corrosponding field from Db2 Target Table is defined as Decimal(5,2). Mapping is simple straight forward mapping with 1:1 loading from Source to target. Now, my Source File contain data as below - 0.010.020.0312.01 When I execute mapping, DB2 target Table gets loaded with all records.Value from corrosponding DB2 Target Table is - 0.000.020.0312.01 As you can see value of 0.01 is getting converted to 0.00 whereas all other values are working fine as expected. As a quick fix, I have applied to_decimal(source_field,2) before loading it to target. Could anyone please explain if this is an issue with Powercenter or there's some other issue. If I think it's a rounding issue then how come value of 0.02 is working fine? Please advise.
-
Pr00 decimal values needs instead off rounding the value
In export sales Pr00 condition value is rounding off i need to be in decimal values
i have checked in Condition type V/06 rounding fields it is not effecting and also OB90 and OY04
example rounding off 26 USD, but at actual it should 25.58 exchange rate is 43 and qty is 100
can any body suggests where the setting ar requiredHi,
Please check the Rounding rule property of the condition type 'PR00'. It must have been set to Round up rather than Commercial.
Change the Rounding rule property to Commercial. I guess this will solve your purpose. -
Hi Guru,
Good day.
I have 5 output as bellow:
.15 2.2 1 .4 14.8 .43
I need to show them like bellow:
1 3 2 15 1
how can i get the desired output.
please help me.
With thanks
Moshiur
Moderator Message: Very basic question. Could be answered with a simple search and/or a few lines of code.
Edited by: kishan P on Sep 18, 2010 4:05 PMHi moshiur sohel,
Use FM 'ROUND' to round any value. Your scenario is of Positive rounding, for that give SIGN parameter as '+'.The following is the example code.
PARAMETER P_VAL TYPE P DECIMALS 2.
CALL FUNCTION 'ROUND'
EXPORTING
* DECIMALS = 0
INPUT = P_VAL
SIGN = '+'
IMPORTING
OUTPUT = P_VAL
EXCEPTIONS
INPUT_INVALID = 1
OVERFLOW = 2
TYPE_INVALID = 3
OTHERS = 4
Close the thread if you have solved your query.
Thanks & Regards,
Rock. -
How to get the leading zeros for decimal values?
Hi,
How i wil get the leading zeros for decimal values.For CONVERSION_EXIT_ALPHA_INPUT it is not working.Now iam using overlay condition for getting leading zeros.But iam getting the value like 00013.500.But as per my requirement i want to display this value 0000013.5.
my code is
overlay w_MetLife_detail-rdempsalary with '000000000'
data :rdempsalary type char9
Please help me on this.
Regards,
SujanHi
For more info,
The function of the statement UNPACK is based on the fact, that the BCD display of a decimal place corresponds to the second half-byte of code of a digit in the most character representations. This conversion is commonly called "unpacking".
The statement PACK to pack is obsolete and can be replaced by MOVE.
If destination is specified as untyped field symbol or as untyped formal parameter and is not flat and not character-type during execution of the statement, then an untreatable exception occurs in Unicode programs. In non-Unicode programs, an exception occurs only with deep types, whereas flat types are treated as character-type types.
Example
After the assignments,char1 and char2 contain the values "123.456" and "0000123456".
DATA: pack TYPE p LENGTH 8 DECIMALS 3 VALUE '123.456',
char1 TYPE c LENGTH 10,
char2 TYPE c LENGTH 10.
MOVE pack TO char1.
UNPACK pack TO char2.
Regards -
Last digit truncates while downloading to Excel from ALV Grid
Hi All,
I have been using REUSE_ALV_LIST_DISPLAY and REUSE_ALV_GRID_DISPLAY in my report program.
While i use REUSE_ALV_GRID_DISPLAY and downloading the data to a local file(Excel) the last digit of the Vendor code is truncated. But in REUSE_ALV_LIST_DISPLAY the datas are downloaded correctly as displayed in the ALV.
I have copied the code for the reference.
REPORT zfirp001 .
TYPE-POOLS: slis.
TABLES: bsak.
SELECT-OPTIONS: s_bukrs FOR bsak-bukrs,
s_lifnr FOR bsak-lifnr,
s_blart FOR bsak-blart,
s_augdt FOR bsak-augdt,
s_zterm FOR bsak-zterm.
PARAMETERS: s_list AS CHECKBOX,
s_vari LIKE disvariant-variant.
DATA: g_ext_num(24) TYPE c.
DATA: BEGIN OF gt_bsak OCCURS 0,
bukrs LIKE bsak-bukrs,
lifnr LIKE bsak-lifnr,
augdt LIKE bsak-augdt,
gjahr LIKE bsak-gjahr,
belnr LIKE bsak-belnr,
blart LIKE bsak-blart,
zterm LIKE bsak-zterm,
END OF gt_bsak.
DATA: BEGIN OF gt_bseg OCCURS 0,
bukrs LIKE bseg-bukrs,
belnr LIKE bseg-belnr,
gjahr LIKE bseg-gjahr,
wrbtr LIKE bseg-wrbtr,
projk LIKE bseg-projk,
shkzg LIKE bseg-shkzg,
hkont LIKE bseg-hkont,
END OF gt_bseg.
ALV
DATA: gt_fieldtab TYPE slis_t_fieldcat_alv,
g_save(1) TYPE c,
g_variant LIKE disvariant.
DATA: BEGIN OF gt_result OCCURS 0,
bukrs LIKE bsak-bukrs,
lifnr LIKE bsak-lifnr,
name1 LIKE lfa1-name1,
augdt LIKE bsak-augdt,
gjahr LIKE bsak-gjahr,
belnr LIKE bsak-belnr,
blart LIKE bsak-blart,
zterm LIKE bsak-zterm,
wrbtr LIKE bseg-wrbtr,
waers LIKE bkpf-waers,
ext_num(24) TYPE c,
txt20 LIKE skat-txt20,
usr00 LIKE prps-usr00,
usr01 LIKE prps-usr01,
usr02 LIKE prps-usr02,
usr03 LIKE prps-usr03,
END OF gt_result.
CONSTANTS: c_credit(1) TYPE c VALUE 'H',
c_x(1) TYPE c VALUE 'X',
c_en(2) TYPE c VALUE 'EN',
c_mrc(4) TYPE c VALUE 'CA01'.
*====================================================
INITIALIZATION.
PERFORM initialize_variant.
AT SELECTION-SCREEN.
PERFORM pai_of_selection_screen.
*====================================================
START-OF-SELECTION.
REFRESH gt_result.
find clearing documents
SELECT bukrs
lifnr
augdt
gjahr
belnr
blart
zterm
INTO TABLE gt_bsak
FROM bsak
WHERE bukrs IN s_bukrs
AND lifnr IN s_lifnr
AND augdt IN s_augdt
AND blart IN s_blart
AND zterm IN s_zterm.
CHECK NOT gt_bsak[] IS INITIAL.
LOOP AT gt_bsak.
read WBS items
SELECT bukrs
belnr
gjahr
dmbtr
projk
shkzg
hkont
INTO TABLE gt_bseg
FROM bseg
WHERE bukrs = gt_bsak-bukrs
AND belnr = gt_bsak-belnr
AND gjahr = gt_bsak-gjahr
AND projk > space.
gt_result-bukrs = gt_bsak-bukrs.
gt_result-lifnr = gt_bsak-lifnr.
gt_result-augdt = gt_bsak-augdt.
gt_result-belnr = gt_bsak-belnr.
gt_result-gjahr = gt_bsak-gjahr.
gt_result-blart = gt_bsak-blart.
gt_result-zterm = gt_bsak-zterm.
document currency
SELECT SINGLE waers
INTO gt_result-waers
FROM bkpf
WHERE bukrs = gt_bsak-bukrs
AND belnr = gt_bsak-belnr
AND gjahr = gt_bsak-gjahr.
vendor name
SELECT SINGLE name1
INTO gt_result-name1
FROM lfa1
WHERE lifnr = gt_result-lifnr.
for each accounting document
LOOP AT gt_bseg.
convert to external WBS
CALL FUNCTION 'PSPNUM_INTERN_TO_EXTERN_CONV'
EXPORTING
edit_imp = c_x
int_num = gt_bseg-projk
IMPORTING
ext_num = gt_result-ext_num
EXCEPTIONS
not_found = 1
OTHERS = 2.
debit or credit
IF gt_bseg-shkzg = c_credit.
gt_result-wrbtr = gt_bseg-wrbtr.
ELSE.
gt_result-wrbtr = gt_bseg-wrbtr * -1.
ENDIF.
GL short Text
SELECT SINGLE txt20
INTO gt_result-txt20
FROM skat
WHERE spras = c_en
AND ktopl = 'CA01'
AND saknr = gt_bseg-hkont.
user fields
SELECT SINGLE usr00
usr01
usr02
usr03
INTO (gt_result-usr00,
gt_result-usr01,
gt_result-usr02,
gt_result-usr03)
FROM prps
WHERE pspnr = gt_bseg-projk.
append to result table
APPEND gt_result.
ENDLOOP.
ENDLOOP.
*====================================================
END-OF-SELECTION.
PERFORM initialize_fieldcat USING gt_fieldtab[].
g_variant-report = sy-repid.
g_save = 'A'.
IF s_list = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = gt_fieldtab
i_default = 'A'
i_save = g_save
is_variant = g_variant
TABLES
t_outtab = gt_result.
ELSE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = gt_fieldtab
i_default = 'A'
i_save = g_save
is_variant = g_variant
TABLES
t_outtab = gt_result.
ENDIF.
*& Form initialize_variant
FORM initialize_variant.
g_save = 'A'.
CLEAR g_variant.
g_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
s_vari = g_variant-variant.
ENDIF.
ENDFORM. " INITIALIZE_VARIANT
*& Form pai_of_selection_screen
FORM pai_of_selection_screen.
IF NOT s_vari IS INITIAL.
MOVE s_vari TO g_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant.
ELSE.
PERFORM initialize_variant.
ENDIF.
ENDFORM. " PAI_OF_SELECTION_SCREEN
*& Form initialize_fieldcat
FORM initialize_fieldcat USING p_fieldtab TYPE slis_t_fieldcat_alv.
DATA: l_fieldcat TYPE slis_fieldcat_alv.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BUKRS'.
l_fieldcat-seltext_L = 'Company'.
l_fieldcat-outputlen = '8'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'LIFNR'.
l_fieldcat-seltext_L = 'Vendor'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'NAME1'.
l_fieldcat-seltext_L = 'Name'.
l_fieldcat-outputlen = '35'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'AUGDT'.
l_fieldcat-seltext_L = 'Cleared'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'GJAHR'.
l_fieldcat-seltext_L = 'Year'.
l_fieldcat-outputlen = '5'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BELNR'.
l_fieldcat-seltext_L = 'Document'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BLART'.
l_fieldcat-seltext_L = 'Type'.
l_fieldcat-outputlen = '4'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'ZTERM'.
l_fieldcat-seltext_L = 'Pay Terms'.
l_fieldcat-outputlen = '4'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'WRBTR'.
l_fieldcat-seltext_L = 'Amount'.
l_fieldcat-outputlen = '13'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'WAERS'.
l_fieldcat-seltext_L = 'CURR'.
l_fieldcat-outputlen = '5'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'EXT_NUM'.
l_fieldcat-seltext_L = 'WBS'.
l_fieldcat-outputlen = '24'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'TXT20'.
l_fieldcat-seltext_L = 'Short Text'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR00'.
l_fieldcat-seltext_L = 'H/O File Ref'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR01'.
l_fieldcat-seltext_L = 'Local File Ref'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR02'.
l_fieldcat-seltext_L = 'INFORM Agree ID'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR03'.
l_fieldcat-seltext_L = 'INFM Prim Ag ID'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
ENDFORM. " INITIALIZE_FIELDCAT
Could the experts do help to overcome the probs.
Thanks in Advance.
Regards,
Anbalagan.VHi Anbalagan,
i've tested your program - but it works fine (Rel. 4.6C,SAPKB46C30)
download is ok and direct transfer (excel inplace) is ok.
but i've a question to the selection of waers in your program -
why do you select waers from bkpf and not from bsak ?
i think sel. of bkpf is'nt necessary !
regards Andreas
Maybe you are looking for
-
How do I prevent the playhead from returning to it's original position after pausing or stopping with the spacebar or k button? With either the skimmer on or off, whenever I pause or stop the **** playhead will always return to the position it
-
Receiver Type Function Module in SWE2 use of export parameter.
i am trying to understand the underlying concept in following things:(neednot to say i have searched alot and read sap documentation already). In event type linkage table say i have an entry for BOR -> AFVC_PM. As per sap Documentation says all these
-
Variable values not passing with Web Application Designer
We are on SP 11 I have defined variables in the planning modeler (no personalization) that should be used when executing a copy function. The idea is to have ready input capability. For example, the variable VERSION is defined - when the planning f
-
SQL Developer Screens Don't Match Tutorial Screens
Hi, I am new to SQL Developer and am starting to go through the tutorial that is at this URL http://st-curriculum.oracle.com/tutorial/SQLDeveloper/index.htm. The version of SQLDeveloper that I just downloaded and am running is version 1.1.0.23. My pr
-
My company suggest to use our official mail server open in Mozilla browser.I have open my mails and downloading the files but I can not send My mails and not upload the attachments in this mail kindly suggest in this regard My official Mail server Na