04-07-2011 5:24 AM
Hi All The ABAP Gurus,
In alv output I have to remove deimal points based on condition ie in internal table if there is a column say NAME and it had values A,B,C,D ..... so on .Now I want to remove decimal points based on the NAME from another field say AMOUNT.
I have tried this in if else loop.
IF ITAB-NAME = 'A'.
LS_FIELDCAT-DECIMALS_OUT = 0.
ELSE.
" in other fields it should display the output with decimals
ENDIF.
But it is not working.
Kindly guide me in this matter.
Thanks & Regards,
Bharti Jain
04-07-2011 11:12 AM
Thanks,
I have tried all the options but could not get success. Kindly elaorate and explain in detail.
Regards,
Bharti Jain
04-07-2011 6:51 AM
Hi
Changing the field catalog might not be the solution
You need to change the data on the internal table level , before making the feild catalog.
If you simple want to remove the decimal
Ex - 50.55 will become 5055
replace '.' in lv_c with space.
condense lv_c no-gaps.
Else if you want to truncate it
Ex - 50.55 to 50
amount = 50.55
data: var_new type p decimals 0.
move amount to var_new.
Regards
Renu
04-07-2011 7:07 AM
Hi,
I think Renu is correct in the case when there are more than 1 name and its condition since fcat can not changes for every line.
you have to manage this in your data part.
pass the amount value to char field in itab, check name and change the decimal places using offset.
split c_amount into c_int c_flt at '.'.
if name = 'A'.
c_flt = clt+0(2).
elseif name = 'B'.
c_flt = clt+0(4).
else......
endif.
concatenate c_int '.' c_flt into c_amount.
....
Thanks,
Anmol
04-07-2011 8:02 AM
Hi Bharti,
Your requirement cannot be achieved by altering the field catalog as the field type cannot be changed row wise.
To get this done,
1) you cannot get this done while having the field type of the amount field with decimals. So change it the type "CHAR" with appropriate length.
2) Now you can add the following logic.
IF ITAB-NAME = 'A'.
WRITE value to ITAB-AMOUNT DECIMALS 0.
ELSE.
WRITE value to ITAB-AMOUNT.
ENDIF.
here the variable "value" contains the amount which you want to display. Hope this will help.
04-07-2011 11:12 AM
Thanks,
I have tried all the options but could not get success. Kindly elaorate and explain in detail.
Regards,
Bharti Jain
04-07-2011 12:34 PM
Post in your code snippet ...
its not that difficult ... i guess you doing it wrong...
Regards
Renu Gusain
04-07-2011 12:36 PM
Halo Bharti,
You should declare an internal table (lt_char_itab )with type similar to yuor ITAB. Here the data type of AMOUNT field should be some character data type say CHAR10.
loop at itab into wa.
move-corresponding wa to l_wa_char.
if wa-name eq 'A'."ie no decimal display reqd
WRITE wa-amnt NO-GROUPING DECIMALS 0 TO l_wa_char-amnt.
endif.
endloop.
You should use lt_char_itab for output display
Regards
Arshad