Displaying negative nos.

Hi,
I am working on an ALV program which should show the no. of days as negative...if the due date is past the current date.
For instance if the due date is 07/26/2005, it should show 1-.
I have declared the data as:
no_of_days_1 type I.
no_of_days_1_d(10) type C.
In my code:
disc_d_date: gets calculated at run time.
no_of_days_1 = sy-datum - disc_d_date.
if no_of_days_1 < 0 .
concatenate
no_of_days_1_d '-' into
no_of_days_1_d.
condense no_of_days_1_d NO-GAPS.
shift no_of_days_1_d RIGHT
DELETING TRAILING space.
else.
no_of_days_1_d = no_of_days_1.
endif.
The problem it appears, no_of_days_1_d being declared as I(integer), cannot store negative nos. A possible solution would be to create a data element with the sign checkbox ticked.
Would appreciate if anybody has a better solution.
Rajib

Yes, integers can have a negative value.
Check out the sample program,  pay attention to the IMARA-TESTF field.  This is all you need to do to show negative in your ALV grid.
report zrich_0004
       no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: sort     type slis_t_sortinfo_alv.
data: begin of imara occurs 0,
      matnr type mara-matnr,
      matkl type mara-matkl,
      labor type mara-labor,
      brgew type mara-brgew,
      maktx type makt-maktx,
<b>      testf type i,</b>
      end of imara.
* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.
start-of-selection.
  perform get_data.
  perform write_report.
*  Get_Data
form get_data.
  select  mara~matnr mara~matkl mara~labor mara~brgew makt~maktx
            into corresponding fields of table imara
              from mara
               inner join makt
                 on mara~matnr = makt~matnr
                    where mara~matnr in s_matnr
                      and makt~spras = sy-langu.
<b>  loop at imara.
    imara-testf = sy-tabix * -1.
    modify imara.
  endloop.</b>
endform.
*  WRITE_REPORT
form write_report.
  perform build_field_catalog.
* CALL ABAP LIST VIEWER (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            it_sort     = sort
            it_fieldcat = fieldcat
       tables
            t_outtab    = imara.
endform.
* BUILD_FIELD_CATALOG
form build_field_catalog.
  data: fc_tmp type slis_t_fieldcat_alv with header line.
  clear: fieldcat. refresh: fieldcat.
  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material Number'.
  fc_tmp-fieldname  = 'MATNR'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '18'.
  fc_tmp-col_pos    = 2.
  append fc_tmp to fieldcat.
  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material Description'.
  fc_tmp-fieldname  = 'MAKTX'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '40'.
  fc_tmp-col_pos    = 5.
  append fc_tmp to fieldcat.
<b>  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Test Field'.
  fc_tmp-fieldname  = 'TESTF'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '12'.
  fc_tmp-do_sum     = 'X'.
  fc_tmp-col_pos    = 4.
  append fc_tmp to fieldcat.</b>
endform.
Regards,
Rich Heilman

Similar Messages

  • How to display negative values in a screen field of a screen

    Hi All,
    Please let me know how to display negative values in a screen field of a screen.
    thanks

    Hi Kishore,
    You can do this method. In the screen , create a text field of CHAR instead fo creating an INT4 field.
    I have created a field of CHAR of name say TEXT.
    In the main program,
    declare a variable of the same name ie. TEXT.
    data: TEXT(5) TYPE C.
    In PBO, just assign the negative values.
    It will work.Since there is automatic conversion between character and integer data types, it will work for positive values as well.
    Regards,
    Sylendra.

  • Displaying negative numbers in brackets in Excel output

    Hello all.
    I have an RTF template...I tired displaying negative numbers in brackets like : (123.80) in Excel output
    But, this is working in PDF and not in Excel.
    Please let me know the way to dsiplay the numbers in brackets.

    varma wrote:
    Negative numbers in bracket
    add a conditional statement like below.
    <?if: NUMBER_TO_CHECK < 0?> <?concat('(',NUMBER_TO_CHECK,')')?><?end if?>
    <?if: NUMBER_TO_CHECK > 0?> <?NUMBER_TO_CHECK?><?end if?>
    are you using the same template for PDF and EXCEL ?
    if so, it has to be handled little differently.
    Place this line in the beginning of the rtf
    <?param@begin:_xf;''?>
    add this condition on number column for Excel output
    <?if:$_xf='excel' and NUMBER_TO_CHECK < 0?> <?concat('(',NUMBER_TO_CHECK,')')?><?end if?>
    Try the above one it should work.
    Have a Nice dayThis didnt work.
    Say that I have element named 'market'
    I placed this condiion <?param@begin:_xf;''?> at the beginningof RTF
    Replaced the number field with this condition: <?if:$_xf='excel' and market< 0?> <?concat('(',market,')')?><?end if?>
    This is giving me a blank output in place of the number.
    >

  • Wi-Fi Connection Time Displays Negative Numbers

    Using an AEBS with the latest firmware 7.6.2 and OS X 10.7.2.  The Wi-Fi connection time appears to randomly start displaying negative numbers. It then counts down (up?) to zero and then displays positive numbers. Anyone else seen this?
    Regards.

    I have the same problem (Macbook 2008, 10.6.8 airport extreme 7.6). Has there been a fix? How do I report this bug, which seems to be affecting older machines as well? It's somewhat amusing, but is starting to become annoying.
    Melinda

  • WebLogic 9.2MP2.Messages Pending topic count JMS display negative value

    on admin console. Services -> Messaging -> JMS Modules in JMS System Modules -> JMS queue name -> Monitoring role tab .
    I use WebLogic 9.2MP2 version . I found that JMS destination summaize page, Messages Pending topic count display negative value.
    What is mean negative value ? or that bug of WebLogic9.2 MP2.
    Thank you.
    BR,

    A negative value indicates a bug -- quite likely in internal statistics gathering code itself. I don't know if the problem has been addressed in later MPs or later versions.
    Tom

  • Display Negative numbers

    Hi,
    I am using JDeveloper 11.1.1.5
    One of an ADF page is expected to display negative number and also follow the number format pattern as shown below. I am not able to display negative numbers. Can anyone help here please?
    Below is my code snippet.
    VO.xml ::
         <ViewAttribute
         Name="TotalDue"
         IsUpdateable="false"
         IsPersistent="false"
         PrecisionRule="true"
         Precision="15"
         Scale="2"
         Type="java.math.BigDecimal"
         ColumnType="NUMBER"
         AliasName="NET_DUE_INVESTOR"
         Expression="NET_DUE_INVESTOR"
         SQLType="NUMERIC">
         <DesignTime>
         <Attr Name="_DisplaySize" Value="22"/>
         </DesignTime>
         <Properties>
         <SchemaBasedProperties>
              <LABEL
              ResId="NET_DUE_TOFROM_INVESTOR"/>
              <FMT_FORMATTER
              ResId="com.ahmsi.isams.liquidation.model.vo.Liquidation332FormView.TotalDue_FMT_FORMATTER"/>
              <FMT_FORMAT
              ResId="com.ahmsi.isams.liquidation.model.vo.Liquidation332FormView.TotalDue_FMT_FORMAT"/>
         </SchemaBasedProperties>
         </Properties>
         </ViewAttribute>
    ModelBundleProperties ::
         TotalDue_FMT_FORMATTER=oracle.jbo.format.DefaultNumberFormatter
         TotalDue_FMT_FORMAT=\#,\#\#\#,\#\#\#,\#\#\#,\#\#0.00;(\#,\#\#\#,\#\#\#,\#\#\#,\#\#0.00)
    myjsfpage.jsf ::
         <af:outputText value="#{bindings.TotalDue.inputValue}"
              id="ot5141" inlineStyle="font-weight:bold;">
         <af:convertNumber groupingUsed="false"
                   pattern="#{bindings.TotalDue.format}"/>
         </af:outputText>

    Got it correct now. I changed the pattern as below. Also added a nowrap=true on the output text
    ModelBundleProperties ::
    TotalDue_FMT_FORMATTER=oracle.jbo.format.DefaultNumberFormatter
    TotalDue_FMT_FORMAT=\#,\#\#\#,\#\#\#,\#\#\#,\#\#0.00;-\#,\#\#\#,\#\#\#,\#\#\#,\#\#0.00
    Thank you all for your directions.
    Thanks,
    Prashant

  • How to display NEGATIVE sign on the left side of a number in SMARTFORMS

    Hi,
         In smartforms I'm trying to print some negative values, but the negative sign is displayed on the right hand side of the number.
    How can I display the '-' sign on the left hand side of a number. I tried the logic &value(<), it works well in sap scripts. Why is it not working in smartforms ?
    Eg :   I'm getting  the output  as  126.75 -
             I want :  - 126.75

    see this wiki which gives details for restrictions of formatting options (I guess you didn't declare the variable correctly, i.e. with the right data element): http://wiki.sdn.sap.com/wiki/display/ABAP/SAPscript#SAPscript-WhatarethevarioustextformattingoptionsinSAPscript%3F

  • Displaying negative numbers under certain conditions

    I have a Crystal Report which I am developing and need to display positive numbers as negative, but only under certain conditions.  I did not see anything on this type of questions so I decided to join and post it up myself.  This is a transfer report so if the location number entered in the parameter list is the SHIPPING location, I need to display retail, cost, and totals as negative.  Here is the formula which I came up with for ext cost, but it is returning all zeros.  I cannot seperate the to and from locations in the parameters because this report needs to display both in and out of that location.
    if totext({?loc}) = totext({Command.SHIP_FROM}) then ({Command.EXT_COST}*-1)
    Any suggestions?  Appreciate the help!

    Hi Jon,
    If it returns zeroes, then it means that this part of the code fails:
    totext({?loc}) = totext({Command.SHIP_FROM})
    Do you have records where the value entered in the 'loc' prompt matches with records in the SHIP_FROM column on the report?
    See if this helps:
    if totext({?loc},0,"") = totext({Command.SHIP_FROM},0,"") then ({Command.EXT_COST}*-1)
    -Abhilash

  • Screen displaying negative image

    My 3 year old was hitting buttons on my laptop, I walked over to remove him and my screen is a complete negative image of what is being displayed. I am sure it was just a combination of buttons hit but I have no idea how to revert it. Anyone??? Anyone???? Tried looking under system preferences but nothing... have no idea how to fix.

    I did a little searching. for anyone else who encounters the problem hit Control, Option, Command, then 8. it will switch it back to normal.

  • Results don't display negative numbers

    I have an application that accepts a 24 bit number and does some simple mathematical operations (see attached).  If number 3(a probe) receives a number lower than the constant that is being subtracted from it, which should result in a negative number, number 6(probe) displays a much larger, positive integer.
    I'm sure that I must be missing something simple somewhere.
    I thank you for your help in advance.
    Ron Deavers, CLD
    Attachments:
    NumberError.bmp ‏114 KB

    Thank you very much. I didn't realize the difference between unsigned integer and integer.
    Ron Deavers, CLD

  • Dvt:gauge StatusMeter displaying negative value strangely

    Hi,
    I'm creating a number of dvt:gauge components to display some retrieved numeric values. My aesthetic preference is to use the STATUSMETER gauge type. The values to be displayed vary greatly in scale and may be positive or negative. As a result I'm letting Oracle determine the best Min and Max values for the gauge(s).
    The problem is that when a negative value is displayed, the status bar is still shown starting from left to right. This looks quite odd to our users as we would expect the bar to start at 0 (zero) and move from right to left. Currently it looks as if the value starts at an arbitrary negative value and is moving towards zero...?!
    I've tried configuring the Min and Max values myself with no joy. Are there some additional attributes that I'm missing that enable the Status Meter to be shown in a more sensible way? Thanks.
    FYI. I'm using JDeveloper Studio Edition Version 11.1.2.1.0.

    Hi,
    Any help on this would be really appreciated.
    Thanks.

  • Screen displaying "Negative of usual colors"

    kids were playing on iMac and now the screen displays a negative of usual color palette? Any ideas what is causing this?

    factor14,
    Welcome to Apple Discussions.
    System Preferences...>Universal Access>Seeing>Display (Reset Black on White/Use grayscale/Enhance contrast as necessary)
    ;~)

  • Need pattern to display negative value in red

    I am having one xdp form which contains multiples objects having some textfields mapped with some xsd.
    requirement is if values is negative need to display it in red color as  "-$18,970.50"
    currently it is getting displayed as   "$-18,970.50"
    I have used pattern num{$z,zzz,zz9.99}
    Is any ready made format available for this?

    Your requirement ("-$18,970.50") is not so common and may have to do major changes to meet this....I will start using a textField rather than a NumberField and Format using scripting not using out of box functionality. Changing text color to red is easy and can be easily done using scripting again.
    I am sure you can try your self if you have some idea about JS or FC scripting....I can help you if you post additional requirements.....like...
    1. Is the value prefilled / keyed in / calculated from other fields or combination of one or more?
    2. Max and Min value allowed/ expected.
    3. Any involvement of user actions there on?

  • Why does B1 display negative balance amounts for the REVENUE GL accts

    I am not an accountant.
    When displaying the balances for REVENUE GL accts, the numbers are negative.
    I know it is correct to do so since the P&L report displays them as positive.
    Is this an accounting convention?
    Mike

    Hi Mike,
    The revenue accounts should have a credit value if everything is alright with the business and the account setup.
    In Administration -> Systam Initialisation -> Company Details: Tab 'Basic Initialisation' you will find the check box 'Display Credit Balance with Negative Sign'.
    By default this is checked when creating a new company in most localisations.
    As it says this means that when the balance of an account shows a credit value it will be displayed as a negative. Business One makes no difference if the accounts are Balance Sheet or Profit and Loss account.
    I hope this answers the question.
    Jesper

  • Datediff formula not displaying negative times

    I have a DATEDIFF formula between two times that is not displaying a negative time when for example:
    DateDiff ("n",next({caseintraop.orsetup_start_datetime}), {caseintraop.pat_or_out_datetime},
    so if the time it pulls is 930am-1000am, it gives us 30 not -30 min.
    When the field is formated to show negatives it does the oppostie and shows the postive times as negatives and vice versa.
    Is there a way to format the formula to show the correct resulted time diffence?

    You wrote
    DateDiff ("n",next({caseintraop.orsetup_start_datetime}), {caseintraop.pat_or_out_datetime},
    so if the time it pulls is 930am-1000am, it gives us 30 not -30 min.
    This will never be negative because start time 9:30 am is before end time 10:00 am
    DateDiff does not subtract end time from start time, if you want it to be negative just reverse the order.
    Ian

Maybe you are looking for

  • Bridge is not to be found and cannot be loaded on my iMac

    I have an Imac and loaded the new software from Apple, mountain Lion 10.8. After Iloaded Photoshop CS6  from the Cloud but cameraRAW did not work good. That is the begin and the end. Now Bridge is gone missing. I reloaded Photoshop several times and

  • SAP Report RSNASTED

    Hi all, I copied SAP standard report RSNASTED. Then I assigned the copy as IDOC processing program to an output type. Once I'm creating that output message I got an 'A' error because the internal table for the IDOC data (type EDIDD) is empty. After t

  • PRINT TWO FORMS

    HI EXPERTS,                  I HAVE TWO LINE ITEMS IN MY ITAB AND I NEED TO PRINT EACH LINE ITEM IN DIFFERNT PAGE . I AM NOT USING ANY MAIN WINDOW IN MY SMARTFORMSS? SO HOW TO DO THIS? RAGRDS, MANI

  • Is there an easier way to adjust volumes of tracks?

    Easier than making control points with the automator? What I would like to do, if possible, is to adjust the volume with the slider as it plays. I can already do this while I am just listening to it, but I can not find a way to have it record or save

  • Defining planning time fence and creation indicator with out oppr settings

    Hi, we dont use mrp groups and accordingly i did not set oppr settings. i observed that planning time fence and the creation indicator (omdz & oppr) are defined thru mrp goups. please advise how to define those w/o oppr settings? is there any seperat