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

Negative Sign missing in File downloaded from ALV grid using SALV* classes

Hello Experts,

I created a very simple ALV grid having a column MSEG-MENGE (defined as type mseg-menge in itab). I created manual fieldcatalog and don't pass any other field in the fcatalog table for this field other than COLTEXT. Some menge values in itab are negative.

When used REUSE_ALV_GRID_DISPLAY :

In output ALV grid, signs and values are displayed correctly. If I download in a file using Export>Local File>Unconverted, the signs and values in the file are correct.

When used cl_salv_table=>factory (nothing done for columns explicitly):

In output ALV grid, signs and values are displayed correctly. If I download in a file using Export>Local File>Unconverted, the negative signs are NOT COMING with the values, all the values are positive. Why ??

Hope my problem is clear. I guess it is something to do with the data type of this field but how different behaviour using 2 separate functions.

Regards,

Diwakar

Edited by: Diwakar Aggarwal on Nov 1, 2011 5:58 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 02, 2011 at 05:20 AM

    Hello Diwakar,

    Are you using the SET_SIGN method as below to set your column to allow negatives within the fieldcatalog?

      TRY. 
          lo_column ?= lo_columns->get_column(
                      columnname = 'MENGE' ).
          lo_column->set_sign( abap_true ).                        
        CATCH cx_salv_not_found.
      ENDTRY.
    

    Also, when you download the file using Export >Local File >Unconverted, make sure to use the default format which is .txt

    Hope this helps.

    Cheers,

    Sougata.

    Also, another method lo_column->set_quantity_column might be required for your column to set it as qty column.

    Edited by: Sougata Chatterjee on Nov 2, 2011 6:43 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Sougata,

      Thanks for your time to discuss on this.

      You are correct that it doesn't make sense to have negative Quantities, but we are just marking them negative for identification purpose to differentiate ISSUE and RECEIPT (based on debit/credit flag). I believe SAP is also doing similar thing in MB51, MB58.

      W.r.t. your summarised analysis, I have some comments (in red) :

      1. For Currency(CURR) or Integer(INT4) Type columns (e.g. WRBTR, S_SEATSMAX)
      - calling SET_SIGN will display in the SLV grid and download to file the actual values that are in the ITAB
      - not calling SET_SIGN will display in the SLV grid and download to file the absolute values that are in the ITAB
                "not calling SET_SIGN is also resulting in ACTUAL values for me (and not the absolute values), so what is the actual importance of this field for types allowing negative values...
      
      2. For other data Types (where you are technically able to convert values as negatives in the ITAB (e.g. QUAN)
      - calling the SET_SIGN will display in the SLV grid and download to file the actual values that are in the ITAB
      - not calling SET_SIGN will display in the SLV grid with actual values in the ITAB but will download to the file with absolute values simply because the column using the associated data Type was never designed to be used for a negative number value unless specified explicitly in the application.
                "Correctly stated that data type is never designed to be used as a Negative value, but then Isn't it Strange that without calling SET_SIGN, WHY it is allowed to display the negative sign in the grid. It should be same behavior in Grid & File.
      

      As per docum of SET_SIGN method,

      Positive numbers are displayed in the output table without a sign, while negative numbers are displayed by default with the minus sign ('-').
      
      You use the SET_SIGN method to set whether the sign is displayed for negative numbers or not.
      
      Note:
      Regardless of whether you display the sign or not: For calculations, of course, the actual value is used.
      

      So, it actually is designed to work for DISPLAY ALV itself(and not the File download).

      I guess, since this data type (QUAN) is not designed for negative signs, behavior is not so convincing and moreover confusing me now because there was no such issue with REUSE*.

      Diwakar

  • author's profile photo Former Member
    Former Member
    Posted on Nov 01, 2011 at 12:19 PM

    Did you notice that MSEG has field SHKZG, the positive/negative indicator? This would indicate to me that MSEG currency values would always be shown as positive and that to get the "correct" value, I'd have to multiply the value by '-1' when the SHKZG indicator is 'H'. Check to see if that is the cause of your positive numbers only.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Davel,

      Yes, I know the field SHKZG and based on that I am changing the value of MENGE in my internal table. But, after all the values are modified with whatever logic, the values in ITAB should be correctly displayed in ALV. This is happening correctly, but why signs are missing in the download file using SALV class.

      The contents in the download file should be same as ALV, which is not the case here and is my problem.

      Regards,

      Diwakar

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2014 at 10:14 PM

    Dear Diwakar,

    After experiencing this behavior first hand, I have made a post to raise this again for discussion and review and referenced your discussion here. If you have any further insight into the matter, please feel free to check out the post and comment.

    CL_SALV_TABLE->FACTORY method, no negative symbols on ALV export.

    Kind Regards,

    James

    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.