<?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: variable length in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707661#M1106034</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE level="1"&gt;&lt;/BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi&lt;/P&gt;&lt;P&gt;&amp;gt; I have a Quantity field with 3 decimals. Now in the o/p I have to shoe that in special way..i.e. &lt;/P&gt;&lt;P&gt;&amp;gt; 4.000 = 4&lt;/P&gt;&lt;P&gt;&amp;gt; 4.120 = 4.12&lt;/P&gt;&lt;P&gt;&amp;gt; 4.100 = 4.1&lt;/P&gt;&lt;P&gt;&amp;gt; So how to do that? Is there any FM 4 dat?&lt;/P&gt;&lt;P&gt;&amp;gt; Regards, &lt;/P&gt;&lt;P&gt;&amp;gt; Kaushik&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Kaushik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code to do the above:-&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;INPUT is the IMPORTING parameter which will be your decimal variable and&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;OUTPUT is the EXPORTING parameter which will be a string.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lv_input TYPE string,      
        lv_numerator TYPE string,     
        lv_denumerator TYPE string,  
        lv_sign TYPE c,            
        lv_decimals TYPE i,           
        lv_output_c TYPE c LENGTH 31, 
        lv_output TYPE string.        

  lv_input = input. "Conversion of DEC to string
* Get sign

* Get position of last zero in denumerator
  SPLIT lv_input AT '.' INTO lv_numerator lv_denumerator.
  CONDENSE lv_denumerator. "Remove spaces
  lv_decimals = STRLEN( lv_denumerator ) - 1. "Need to substract 1 for position
  "Check for sign at end of string
  IF lv_decimals &amp;gt;= 0 AND lv_denumerator+lv_decimals(1) EQ '-'. "Sign found ?
    lv_sign = '-'.
    lv_decimals = lv_decimals - 1.
  ENDIF.
  WHILE lv_decimals &amp;gt;= 0 AND lv_denumerator+lv_decimals(1) EQ '0'.
    lv_decimals = lv_decimals - 1.
  ENDWHILE.
  lv_decimals = lv_decimals + 1. "Need to add one for length

* Create formatted output string
  WRITE input TO lv_output_c DECIMALS lv_decimals NO-GROUPING NO-SIGN USING NO EDIT MASK. "Convert to characters
  lv_output = lv_output_c. "Convert to string.
  CONDENSE lv_output.
  "Prepend sign
  IF lv_sign IS NOT INITIAL.
    CONCATENATE lv_sign lv_output INTO lv_output.
  ENDIF.

  output = lv_output.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Regards,&lt;/P&gt;&lt;P&gt;Ravi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Nov 2008 05:25:31 GMT</pubDate>
    <dc:creator>raviprakash</dc:creator>
    <dc:date>2008-11-03T05:25:31Z</dc:date>
    <item>
      <title>variable length</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707658#M1106031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have a Quantity field with 3 decimals. Now in the o/p I have to shoe that in special way..i.e. &lt;/P&gt;&lt;P&gt;4.000 = 4&lt;/P&gt;&lt;P&gt;4.120 = 4.12&lt;/P&gt;&lt;P&gt;4.100 = 4.1&lt;/P&gt;&lt;P&gt;So how to do that? Is there any FM 4 dat?&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;P&gt;Kaushik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 04:53:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707658#M1106031</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-03T04:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: variable length</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707659#M1106032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,copy these fields to a character field, then use remove zeros&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SHIFT w_quantity RIGHT DELETING TRAILING '0'. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After that u can use simple string operations(w_quatity+1(0)) to get the required output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it will solve u r problem,&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Rock.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 05:14:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707659#M1106032</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-03T05:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: variable length</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707660#M1106033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;... ROUND r &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;Scaled output of a field of type P. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The decimal point is first moved r places to the left (r &amp;gt; 0) or to the right (r &amp;lt; 0); this is the same as dividing with the appropriate exponent 10**r. The value determined in this way is output with the valid number of digits before and after the decimal point. If the decimal point is moved to the left, the number is rounded. &lt;/P&gt;&lt;P&gt;For further information about the interaction between the formatting options CURRENCY and DECIMALS, see the notes below. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Effect of different ROUND specifications: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: X TYPE P DECIMALS 2 VALUE '12493.97'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE: /X ROUND -2,   "output: 1,249,397.00 &lt;/P&gt;&lt;P&gt;       /X ROUND  0,   "output:    12,493.97 &lt;/P&gt;&lt;P&gt;       /X ROUND  2,   "output:       124.94 &lt;/P&gt;&lt;P&gt;       /X ROUND  5,   "output:         0.12 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Option &lt;/P&gt;&lt;P&gt;... UNIT u &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;Formats a value according to the unit specified in the field u. &lt;/P&gt;&lt;P&gt;The contents of f are treated as a quantity. The unit specified in u determines how many decimal places should be output. &lt;/P&gt;&lt;P&gt;If f has more places after the decimal point than determined in u, the output value will only have the number of decimal places determined by u, unless the operation truncates digits other than zero. &lt;/P&gt;&lt;P&gt;If f has fewer places after the decimal point than determined by u, the option has no effect. &lt;/P&gt;&lt;P&gt;The contents of u are used as a unit in the table T006, but if there is no entry, the formatting option has no effect. &lt;/P&gt;&lt;P&gt;The field f which is to be output must have the type P. This option is used for table fields which have the Dictionary type QUAN, or for fields defined with reference to such fields ( DATA ... LIKE ...). &lt;/P&gt;&lt;P&gt;This formatting option excludes the options DECIMALS and ROUND. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Suppose the unit 'STD' has 3 decimals &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA HOUR TYPE P DECIMALS 3 VALUE '1.200'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE (6) HOUR UNIT 'STD'. "output:   1,2 &lt;/P&gt;&lt;P&gt;HOUR = '1.230'. &lt;/P&gt;&lt;P&gt;WRITE (6) HOUR UNIT 'STD'. "output: 1,230&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 05:20:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707660#M1106033</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-03T05:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: variable length</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707661#M1106034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE level="1"&gt;&lt;/BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi&lt;/P&gt;&lt;P&gt;&amp;gt; I have a Quantity field with 3 decimals. Now in the o/p I have to shoe that in special way..i.e. &lt;/P&gt;&lt;P&gt;&amp;gt; 4.000 = 4&lt;/P&gt;&lt;P&gt;&amp;gt; 4.120 = 4.12&lt;/P&gt;&lt;P&gt;&amp;gt; 4.100 = 4.1&lt;/P&gt;&lt;P&gt;&amp;gt; So how to do that? Is there any FM 4 dat?&lt;/P&gt;&lt;P&gt;&amp;gt; Regards, &lt;/P&gt;&lt;P&gt;&amp;gt; Kaushik&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi Kaushik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code to do the above:-&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;INPUT is the IMPORTING parameter which will be your decimal variable and&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;OUTPUT is the EXPORTING parameter which will be a string.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lv_input TYPE string,      
        lv_numerator TYPE string,     
        lv_denumerator TYPE string,  
        lv_sign TYPE c,            
        lv_decimals TYPE i,           
        lv_output_c TYPE c LENGTH 31, 
        lv_output TYPE string.        

  lv_input = input. "Conversion of DEC to string
* Get sign

* Get position of last zero in denumerator
  SPLIT lv_input AT '.' INTO lv_numerator lv_denumerator.
  CONDENSE lv_denumerator. "Remove spaces
  lv_decimals = STRLEN( lv_denumerator ) - 1. "Need to substract 1 for position
  "Check for sign at end of string
  IF lv_decimals &amp;gt;= 0 AND lv_denumerator+lv_decimals(1) EQ '-'. "Sign found ?
    lv_sign = '-'.
    lv_decimals = lv_decimals - 1.
  ENDIF.
  WHILE lv_decimals &amp;gt;= 0 AND lv_denumerator+lv_decimals(1) EQ '0'.
    lv_decimals = lv_decimals - 1.
  ENDWHILE.
  lv_decimals = lv_decimals + 1. "Need to add one for length

* Create formatted output string
  WRITE input TO lv_output_c DECIMALS lv_decimals NO-GROUPING NO-SIGN USING NO EDIT MASK. "Convert to characters
  lv_output = lv_output_c. "Convert to string.
  CONDENSE lv_output.
  "Prepend sign
  IF lv_sign IS NOT INITIAL.
    CONCATENATE lv_sign lv_output INTO lv_output.
  ENDIF.

  output = lv_output.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Regards,&lt;/P&gt;&lt;P&gt;Ravi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 05:25:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707661#M1106034</guid>
      <dc:creator>raviprakash</dc:creator>
      <dc:date>2008-11-03T05:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: variable length</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707662#M1106035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It very simple.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Declare that output variable as CHAR.... Your problem will be solved...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 05:37:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707662#M1106035</guid>
      <dc:creator>raja_narayanan2</dc:creator>
      <dc:date>2008-11-03T05:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: variable length</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707663#M1106036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sorry...&lt;/P&gt;&lt;P&gt;Declare it as packeddecimal with decimal values 2 so that your output will come like this....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.000 = 4&lt;/P&gt;&lt;P&gt;4.1200 = 4.12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Raja...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 05:39:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707663#M1106036</guid>
      <dc:creator>raja_narayanan2</dc:creator>
      <dc:date>2008-11-03T05:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: variable length</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707664#M1106037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thnaks All&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2008 06:39:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/variable-length/m-p/4707664#M1106037</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-03T06:39:02Z</dc:date>
    </item>
  </channel>
</rss>

