Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FieldCatalog Problem?

abdul_hakim
Active Contributor
0 Likes
1,893

Hi Friends,

I want to remove decimal places for particular currency say 'KRW'.So while building fieldcatalog i have checked if currency = 'KRW' then decimals_out = 0.

It is working fine if execute for KRW alone.If i combine KRW and GBP the decimal is not coming for both currencies.

How can i show decimals for currencies other than KRW and without decimal for KRW.

Thanks,

Abdul

11 REPLIES 11
Read only

Former Member
0 Likes
1,347

Hi Abdul,

That is not possible, But why can't you populate the data population level itself and try (decimals other than KRW , for KRW no decimals).

vijay

Read only

0 Likes
1,347

Hi Vijay.

Already there is one standard transaction MB52 which is doing this purpose successfully through fieldcatalog.The problem is that they have used macros and other stuffs to achieve this,very difficult to understand what they have done.Is there any function module availble for removing decimals...

Regards,

Abdul

Read only

0 Likes
1,347

try to check it as suggested by deepak.

vijay

Read only

0 Likes
1,347

It is not working.

Abdul

Read only

0 Likes
1,347

i know that , but you should convert the the currency if it is KRW and remove decimals, but if it is other than KRW you don't do any thing...

regards

vijay

Read only

0 Likes
1,347

Is there any other way to remove it!!

Abdul

Read only

Former Member
0 Likes
1,347

Hi,

In field catalog you need to pass one filed for which you are editing.

And for currencies we must always refer curr field.

*******

fieldcat-cfieldname = 'WAERS'.

fieldcat-datatype = 'CURR'.

*********************

See for Korean currency and Japanese currency there will be no decimals.

So while building the field catalog for amount field refer the CURR like what i mentioned above.

It will take care.

In the decleration also you have to refer Db Table-field not Type CHAR.

*************************

Thanks.

If this helps u reward with points and close the thread.

Message was edited by: Deepak333 k

Message was edited by: Deepak333 k

Read only

0 Likes
1,347

... just a small addition. What we do, is first build the field catalog (semi-automatic).

Then 'enhance it' modifying some texts and so on. In this step, we assign the currency fields

field-symbols:

<alv_fieldcat> type slis_fieldcat_alv.

loop at pt_alv_fieldcat assigning <alv_fieldcat>.

if <alv_fieldcat>-fieldname(5) = 'KBETR'.

  • Company code currency

<alv_fieldcat>-cfieldname = 'BWAER'.

elseif <alv_fieldcat>-fieldname(5) = 'KWERT'.

  • Document Currency

<alv_fieldcat>-cfieldname = 'WAERK'.

endif.

endloop.

The interesting thing is: If you have any ALV sums on currency columns, the sums are split by currency.

I thing the same logic applies to units, only the reference field is called qfieldname (not cfieldname).

You should have the currency itself in the same table, otherwise you have to specify the reference table as ctabname in the field catalog.

Good luck,

C.

Read only

Former Member
0 Likes
1,347

Hi abdul,

1. There are two things.

a) in the internal table there must a field for currency which must be properly containing values

eg. INR, USD etc.

(u might be already having it )

a) we need to modify the field-catalogue

(after it is built)

2. suppose your fieldcatalogue variable name is ALVFC.

3. Declare this first.

DATA : alvwa TYPE slis_fieldcat_alv.

4. Then just after the field catalogue has been built.

write this code :

LOOP AT alvfc INTO alvwa.

alvwa-cfieldname = 'WAERS'.

alvwa-tabname = 'ITAB'.

MODIFY alvfc FROM alvwa.

ENDLOOP.

5. Modify the code a little to

specify the ACTUAL NAMES.

for

ITAB = name of your internal table

WAERS = name of the field which has curreny

6. I tried the code, it works fantastic.

7. The system will take the decision

to show decimals or not for that currency

based upon configuration.

8. U can use currency COP

for no decimals.

(even if your actual currency is different,

just populate COP for such currency.

u may use extra field in ur internal table

for such manipulation puropse

only for handling decimals.

actual currency field can be different

But accordingly speecify in the field catalogue)

I hope u understood the funda.

regards,

amit m.

Message was edited by: Amit Mittal

Read only

Former Member
0 Likes
1,347

Hi again,

1. I tried another INTERESTING & SIMPLE thing.

2. In your internal table,

how is the field for currency defined ?

3. define it like this.

waers LIKE TCURC-WAERS,

4. NO NEED TO DO ANYTHING.

IT WORKS FANTASTIC.

5. DEFINE IT EXACTLY LIKE THIS.

DO NOT EVEN CHANGE THE FIELD NAME.

regards,

amit m.

Read only

Former Member
0 Likes
1,347

Hi again,

1. try this simple program (just copy paste)

2. especially note currency field declaration

f1 LIKE P0008-BET01,

(it should be LIKE some real TABLE-FIELDNAME

which has currency value)

3.

REPORT abc.

TYPE-POOLS : slis.

*----


DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : BEGIN OF itab OCCURS 0,

f1 LIKE P0008-BET01,

waers LIKE tcurc-waers,

END OF itab.

*----


START-OF-SELECTION.

itab-f1 = '4.15'.

itab-waers = 'KRW'.

APPEND itab.

itab-f1 = '4.68'.

itab-waers = 'GBP'.

APPEND itab.

*----


CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = alvfc

TABLES

t_outtab = itab

EXCEPTIONS

OTHERS = 2.

regards,

amit m.