<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ABAP adding minus values in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588301#M1661365</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THANK YOU BREAKPOINT:&lt;/P&gt;&lt;P&gt;You were correct.Thanks for the help.&lt;/P&gt;&lt;P&gt;Heres my code to anyone that was having a similar problem:&lt;/P&gt;&lt;P&gt;FORM subtotal_accdue tables  tab_regup structure regup&lt;/P&gt;&lt;P&gt;                     changing&lt;/P&gt;&lt;P&gt;                        i_subtotal_accduevalue TYPE REGUP-WRBTR.&lt;/P&gt;&lt;P&gt;   IF REGUP-UMSKZ EQ SPACE.&lt;/P&gt;&lt;P&gt;   IF REGUP-SHKZG EQ 'H'.&lt;/P&gt;&lt;P&gt;   i_subtotal_accduevalue = i_subtotal_accduevalue - REGUP-WRBTR.&lt;/P&gt;&lt;P&gt;    REGUT-RBETR = i_subtotal_accduevalue.&lt;/P&gt;&lt;P&gt;    ELSEIF REGUP-SHKZG EQ 'S'.&lt;/P&gt;&lt;P&gt;   i_subtotal_accduevalue = i_subtotal_accduevalue + REGUP-WRBTR.&lt;/P&gt;&lt;P&gt;    REGUT-RBETR = i_subtotal_accduevalue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;ENDFORM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to all experts for your replies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Feb 2012 15:40:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-02-09T15:40:04Z</dc:date>
    <item>
      <title>ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588294#M1661358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts, &lt;/P&gt;&lt;P&gt;Ive put in code in an abap driver program so as to loop through a table based on certain condtions. All my loops are working bar 1. The problem is,when my code loops through the porgram its treating minus vales and adding them rather then subtracting them.&lt;/P&gt;&lt;P&gt;As a result my final outputted figure is incorrect.&lt;/P&gt;&lt;P&gt;Heres my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM subtotal_accdue tables  tab_regup structure regup&lt;/P&gt;&lt;P&gt;                     changing&lt;/P&gt;&lt;P&gt;                          i_subtotal_accduevalue TYPE REGUP-WRBTR.&lt;/P&gt;&lt;P&gt;IF REGUP-UMSKZ EQ SPACE.&lt;/P&gt;&lt;P&gt;      i_subtotal_accduevalue = REGUP-WRBTR + i_subtotal_accduevalue.&lt;/P&gt;&lt;P&gt;      REGUT-RBETR = i_subtotal_accduevalue.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 10:15:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588294#M1661358</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-09T10:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588295#M1661359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;      You could try to check if the value to be add or subtracted is a positive or negative value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM subtotal_accdue tables tab_regup structure regup&lt;/P&gt;&lt;P&gt;changing&lt;/P&gt;&lt;P&gt;i_subtotal_accduevalue TYPE REGUP-WRBTR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF REGUP-UMSKZ EQ SPACE.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if REGUP-WRBTR ge 0.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;i_subtotal_accduevalue = REGUP-WRBTR + i_subtotal_accduevalue.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else.&lt;/STRONG&gt;  ** Negative value ** &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;i_subtotal_accduevalue = i_subtotal_accduevalue - REGUP-WRBTR.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;endif.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;REGUT-RBETR = i_subtotal_accduevalue.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure which field would hold the negative value as you haven't mentioned it, but this would work assuming  &lt;STRONG&gt;REGUP-WRBTR&lt;/STRONG&gt; holding negative values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: AJ Nayak on Feb 9, 2012 11:30 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 10:24:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588295#M1661359</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-09T10:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588296#M1661360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi AJ,&lt;/P&gt;&lt;P&gt;Thanks for the reply, I really appreciate any help.&lt;/P&gt;&lt;P&gt;I put into your suggestion but unfortunately the code still outputted the same result.&lt;/P&gt;&lt;P&gt;Iu2019m trying to query field DMSHB with data element DMSHB_X8 (Amount in Local Currency with +/- Signs). When I debug and run my code I can see it adds the plus values no problem. However when it reaches a minus value it for some reason treats it as a plus and adds it despite it being a negative. Iu2019m only new to sap so apologies if Iu2019m doing something stupid. &lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 10:44:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588296#M1661360</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-09T10:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588297#M1661361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi mike &lt;/P&gt;&lt;P&gt;that may be due to the data type you are using i.e curr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;convert the values to the numeric data type and then perform the operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i hope this should help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;somesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 10:54:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588297#M1661361</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-09T10:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588298#M1661362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  Mike,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check the datatype . It as float or integer . If you want it in currency field go for pack ( p ) type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 10:54:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588298#M1661362</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-09T10:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588299#M1661363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Thanks for all the replies.&lt;/P&gt;&lt;P&gt;If im understanding your suggestions correctly: i checked the DMSHB field. It is a currency field.&lt;/P&gt;&lt;P&gt;REGUP-WRBTR is also a currency field. Therefore i would think that my code should work?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 11:07:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588299#M1661363</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-09T11:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588300#M1661364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why are you not considering the Debit/Credit Indicator for these values?  And why is everything coded backward?  You put the data into the object, not into its type....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you mean something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FORM subtotal_accdue tables tab_regup structure regup  "where are you handling the table?  there's no loop here
changing i_subtotal_accduevalue TYPE WRBTR. " I_SUBTOTAL_ACCDUEVALUE is used somewhere? 

loop at tab_regup assigning &amp;lt;lfs_reg&amp;gt;. " (of type regup).
 if &amp;lt;lfs_reg&amp;gt; is assigned.

IF &amp;lt;lfs_reg&amp;gt;-UMSKZ EQ SPACE.  "no special GL Account?

IF &amp;lt;lfs_reg&amp;gt;-SHKZG EQ 'S'."debit
i_subtotal_accduevalue = i_subtotal_accduevalue +  &amp;lt;lfs_reg&amp;gt;-WRBTR .
ELSEIF &amp;lt;lfs_reg&amp;gt;-SHKZG EQ 'H'. "credit
i_subtotal_accduevalue =  i_subtotal_accduevalue - &amp;lt;lfs_reg&amp;gt;-WRBTR .
endif.

else.????  REGUP-UMSKZ is not space?:  Is this what you mean?

i_subtotal_accduevalue = i_subtotal_accduevalue  + &amp;lt;lfs_reg&amp;gt;-rbetr. "where did REGUT come from?  

endif.  "UMSKZ populated

endif. "&amp;lt;fs&amp;gt; assigned
endloop.
ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR?  Just reading this, I'm not sure what your subroutine is supposed to do, but you're not going to accomplish what you need without correction.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 13:36:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588300#M1661364</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-09T13:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588301#M1661365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;THANK YOU BREAKPOINT:&lt;/P&gt;&lt;P&gt;You were correct.Thanks for the help.&lt;/P&gt;&lt;P&gt;Heres my code to anyone that was having a similar problem:&lt;/P&gt;&lt;P&gt;FORM subtotal_accdue tables  tab_regup structure regup&lt;/P&gt;&lt;P&gt;                     changing&lt;/P&gt;&lt;P&gt;                        i_subtotal_accduevalue TYPE REGUP-WRBTR.&lt;/P&gt;&lt;P&gt;   IF REGUP-UMSKZ EQ SPACE.&lt;/P&gt;&lt;P&gt;   IF REGUP-SHKZG EQ 'H'.&lt;/P&gt;&lt;P&gt;   i_subtotal_accduevalue = i_subtotal_accduevalue - REGUP-WRBTR.&lt;/P&gt;&lt;P&gt;    REGUT-RBETR = i_subtotal_accduevalue.&lt;/P&gt;&lt;P&gt;    ELSEIF REGUP-SHKZG EQ 'S'.&lt;/P&gt;&lt;P&gt;   i_subtotal_accduevalue = i_subtotal_accduevalue + REGUP-WRBTR.&lt;/P&gt;&lt;P&gt;    REGUT-RBETR = i_subtotal_accduevalue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;ENDFORM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to all experts for your replies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 15:40:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588301#M1661365</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-02-09T15:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP adding minus values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588302#M1661366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You Very Much Michael.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was having exactly same problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Capturing the value in the extra variable helped me solve the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again for the great help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Suchitra.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2016 06:44:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-adding-minus-values/m-p/8588302#M1661366</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-09-15T06:44:16Z</dc:date>
    </item>
  </channel>
</rss>

