Skip to Content
author's profile photo Former Member
Former Member

Concatenating '$' to an amount field in ALV Grid

Hi SAP Gurus.....

I am trying to Concatenating '$' to an amount field in ALV Grid....I am assigning '$' as first char of amount field taken as char.....

But some time allignment of digits & '$' is not proper as

'$' need to present only at first pos irrespective of length of amount field....

Pl suggest some way out.....

Thanks in advance

Regards,

Gaurav

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2005 at 01:12 PM

    Hello Gaurav,

    You have said that <i>sometimes</i> there is a problem with the alignment. That is somewhat vague to understand completely. Could you provide the specific example where it is not appearing correctly? Also paste the code here, so that we can analyze it better.

    Regards,

    Anand Mandalika.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello Gaurav,

      Why do you need to use the FM CONVERSION_ALPHA...?

      Consider the following code snippet :

      tables vbak.
      
      data netwr type vbak-netwr.
      
      data amount_char(19).
      
      move '20006768' to netwr.
      move netwr to amount_char.
      write amount_char.
      
      move '546' to netwr.
      move netwr to amount_char.
      write / amount_char.
      
      move '889' to netwr.
      move netwr to amount_char.
      write / amount_char.
      

      the list output, as you can see is properly aligned as per your requirement.

      Now if you want a '$' sign, make the character field which contains the amount 2 characters greater than the actual currency field's length. Now set the first character to a '$' explicitly.

      Hope this is clear. Else, post your code here.

      Regards,

      Anand Mandalika.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2005 at 02:37 PM

    Hi,

    Try this you will get the answer with required spaces.

    TABLES: vbak.

    DATA: temp1 LIKE vbak-netwr,

    temp2(15) type c,

    temp3(17) type c.

    temp1 = 245666.

    write:/ temp1.

    temp2 = temp1.

    concatenate '$' ' ' temp2 into temp3.

    write:/ temp3.

    temp1 = 666.

    write:/ temp1.

    temp2 = temp1.

    concatenate '$' ' ' temp2 into temp3.

    write:/ temp3.

    just concatenate the value as shown above.

    Regards,

    Kathirvel.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2005 at 02:39 PM

    Hi,

    Make sure that you pass the concated value to the ALV grid and also the field should be like the final concatenatedd values type.

    Regards,

    Kathirvel.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 05, 2005 at 02:55 PM

    Hello Gaurav,

    I think, it can be solved with only 1 line source code.

    WRITE: amount TO wchar USING EDIT MASK 'RR$ _________________'.

    grx Andreas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2005 at 03:45 PM

    The problem is with the ALV Grid display.

    The solutions presented here will correctly format the data with a dollar sign, and if you are doing a traditional list display, then you are good to go. But if you display the data in an ALV Grid, the data is displayed with a proportional font. A space takes up less room than a digit so 2 character fields with a different number of spaces, will display with different total lengths.

    I am playing around with the idea of using a non-display character instead of a space. I would need a non-display character that takes up the same amount of room as a digit. No luck so far, any ideas?

    I looked around for an ALV option to change the font but no luck.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 05, 2005 at 05:04 PM

    No luck on the unprintable character.

    You can default to left justified and get the $'s to line up but the digits will not line up.

    You can set the JUST parameter in the field catalog to the value 'R' and get the field right justified and then the digits will line up but the $'s will not line up.

    You can use the underscore character instead of spaces between the digits and the $. It appears to use the same amount of room as the digits. Be careful of any commas because then the proportional problem appears again.

    You can put a $ in a 1 character field in front of the number, then present the number right justified without a $.

    Any better solutions out there?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.