Q

Displaying numeric output without changing format

I have created a Column Tree that holds numeric values, as opposed to character text. My problem is that I lose numeric formatting with commas as thousand separators, but I can see the decimal point. This is because the formatting is maintained only in output with the "write" statement, but when I pass the numeric value to the tree node, it does not hold commas for formatting.

I am using Class Interface: 'CL_ITEM_TREE_CONTROL', Structure: 'MTREEITM' and I pass my value to 'MTREEITM-TEX...

T.'

Code extract:

data: amount_value type p decimals 2.
CLEAR item.
item-node_key = 'Child1'.
item-item_name = 'Column2'.
item-class = cl_gui_column_tree=>item_class_text.
item-text = amount_value
SHIFT item-text LEFT DELETING LEADING space.
APPEND item TO item_table.

Can you please give me advice as to how I can display numeric output with all its formatting? "1,234,567.89"

Define your tree node as character data. Then populate the tree nodes from your numeric fields, using the WRITE command - thus:

WRITE amount_value TO item-text.

item-text now contains amount_value with thousand separators and decimals as defined in your defaults. You can of course use other options to the WRITE statement, like MASK, or LEFT-JUSTIFIED etc. to get the output precisely as you like.

This was last published in November 2004

Dig Deeper on SAP ABAP

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close