Application Development 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: 

How to move sign to the left on a Currency Field in ALV and have the field keep its format

Former Member
0 Kudos

I have field in a table with the domain of VTCUR9, the user wants this field displayed in an ALV report with the sign on the left.  They also want to be able to subtotal from ALV Grid Display which means the field has to keep its definition and not be character.

I found out to use the Function Module "CLOI_PUT_SIGN_IN_FRONT" to get my sign on the left, but your table field has to be character.  The result is not pretty as you loose your commas and the alignment right, plus you can't subtotal on the field since it is now character.

Is there a way to switch the sign and still get the field to keep it's definition, which in this case is currency?

4 REPLIES 4

Former Member
0 Kudos

You can assign an edit mask in the field catalog.

Rob

0 Kudos

The display length of the field is 23 characters so I would have to tell it the edit mask looks like:

'RRV___,___,___,___,___.__'

And if I do this will 100,000.51- display as -100,000.51 and not -  ,     ,     ,    ,100,000.51

0 Kudos

Well, give it a try.

Rob

former_member585060
Active Contributor
0 Kudos

Hi,

     Try with the same function module and use WRITE statements instead of MOVE or = while moving the changed value. Also declare the Output field a character and while building fieldcatalog pass the REF_FIELD and REF_TABLE pointing to a currency field.

Ex:-

Output field is DMBTR

In declaration declare as

dmbtr TYPE c LENGTH 16.

In fieldcatalog

Below are LVC field catalog structure

lw_fieldcat-col_pos        = v_colpos.

lw_fieldcat-fieldname      = 'DMBTR'.

lw_fieldcat-tabname       = 'I_OUTPUT'.

lw_fieldcat-do_sum        = p_do_sum.

lw_fieldcat-ref_field        = 'DMBTR'.       " SLIS it is REF_FIELDNAME

lw_fieldcat-ref_table       = 'BSAD'.         " SLIS it is REF_TABNAME

lw_fieldcat-selddictxt     = p_selddictxt.

lw_fieldcat-scrtext_l      = p_scrtext_l.

lw_fieldcat-no_out         = p_no_out.

Providing the ref_field and ref_table the column will have the BSAD_DMBTR field attributes, so it can be used for subtotals as well.

DATA : v_dmbtr TYPE C LENGTH 16.

Logic while filling the i_output table for that field

IF wa_bsad_tmp-dmbtr >= 0.

       WRITE : wa_bsad_tmp-dmbtr TO wa_output-dmbtr

                                     RIGHT-JUSTIFIED.

     ELSE.

       WRITE : wa_bsad_tmp-dmbtr TO v_dmbtr.

       CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'

         CHANGING

           value = v_dmbtr.

       WRITE : v_dmbtr TO wa_output-dmbtr  RIGHT-JUSTIFIED.

       CLEAR : v_dmbtr.

     ENDIF.

The WRITE statement above will preserve the comma separators.

Have a try with above method.

Thanks & Regards

Bala Krishna