Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Remove zeros to the right

Former Member
0 Kudos

Good day friends, i can help erase the zeros of this structure of code:


SELECT SUM( ntgew ) SUM( brgew ) INTO (st_texto-pes_net, st_texto-pes_bru)
       FROM vbap
       WHERE vbeln EQ <fs_data>-vbeln.
     <fs_data>-ntgew = st_texto-pes_net.  "
21,402,720.000" Erase HERE
     <fs_data>-brgew = st_texto-pes_bru.  "
21,822,230.400" Erase HERE

   CLEAR gs_fcat.
   gs_fcat-col_pos   = 17 .
   gs_fcat-fieldname = 'NTGEW'.  
Are displayed here
   gs_fcat-tabname   = 1.
   gs_fcat-datatype  = 'QUAN'.
   gs_fcat-inttype   = 'P'.
   gs_fcat-domname   = 'MENG15'.
   gs_fcat-outputlen = gs_fcat-intlen.
   APPEND gs_fcat TO gt_fcat.

   CLEAR gs_fcat.
   gs_fcat-col_pos   = 18  .
   gs_fcat-fieldname = 'BRGEW'
Are displayed here
   gs_fcat-tabname   = 1.
   gs_fcat-datatype  = 'QUAN'.
   gs_fcat-inttype   = 'P'.
   gs_fcat-domname   = 'MENG15'.
   gs_fcat-outputlen = gs_fcat-intlen.
   APPEND gs_fcat TO gt_fcat.

They can guide me with some example.....

Thanks for everything
Regards

1 ACCEPTED SOLUTION

former_member209120
Active Contributor
0 Kudos

Hi

ntgew,    " Net Weight
brgew.    " Gross Weight

    Domin     - MENG13
    DATA type - QUAN

    


Default having 3 Decimals Places

Example 1

DATA : ntgew TYPE ntgew,    " Net Weight
             brgew TYPE brgew.    " Gross Weight

ntgew   '21402720'.
brgew   '21822230'.

WRITE : / ntgew,
                /  brgew.

Out put

Default we will get 3 decimals

if you try like this

DATA : ntgew TYPE p length 16,    " Net Weight
            brgew TYPE p length 16.    " Gross Weight

ntgew   '21402720'.
brgew   '21822230'.

WRITE : / ntgew,
         /  brgew.

Output


Example 2


DATA : ntgew TYPE ntgew,    " Net Weight
        brgew TYPE brgew.    " Gross Weight

Data: ntgew_c(17) TYPE c,
       brgew_c(17) type c.

ntgew   '21402720.000'.
brgew   '21822230.400'.

ntgew_c = ntgew.
brgew_c = brgew.


CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
   CHANGING
     c_value       = ntgew_c.


CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
   CHANGING
     c_value       = brgew_c.

WRITE : / ntgew_c,
         /  brgew_c.


Output


11 REPLIES 11

former_member339717
Active Participant
0 Kudos

Brujo ,

     use this following code before appending in itab.

data: v_char type char25,

         v_char1 type char25.

SELECT SUM( ntgew ) SUM( brgew ) INTO (st_texto-pes_net, st_texto-pes_bru)
       FROM vbap
       WHERE vbeln EQ <fs_data>-vbeln.

        move st_texto-pes_net to v_char.

       move st_texto-pes_bru to v_char1.

       condense v_char no-gap.

       SHIFT v_char RIGHT DELETING TRAILING '0'.

       condense v_char1 no-gaps.

       SHIFT v_char1 RIGHT DELETING TRAILING '0'.


* use character values to display the results of <fs_data>-ntgew and    

<fs_data>-brgew. I will resolve

*  your problem. Don't use the quantity values in field catalog.

    <fs_data>-ntgew = v_char
     <fs_data>-brgew = v_char1.

regards,

arindam_m
Active Contributor
0 Kudos

Hi,

Looking by your code I think you are trying to do an ALV output. Check the field DECIMALS_O in LVC_S_FCAT structure if you are using it. This field controls number of decimal places for output at ALV. should be ok if your requirement is for display only.

Cheers,

Arindam

former_member215424
Active Participant
0 Kudos

Hi Brujo,

If I understand your requirement of removing zeros at the end of the number. You can use the below code.

DATA : l_string1 TYPE string,

           l_string2 TYPE string.
l_string1 = st_texto-pes_net.

l_string2 = st_texto-pes_bru.

condense string1 no-gaps.


condense string2 no-gaps.

FIND '.' IN l_string1 IN CHARACTER MODE.

IF sy-subrc EQ 0.
SHIFT l_string1 RIGHT DELETING TRAILING: '0','.'.

ENDIF.


FIND '.' IN l_string2 IN CHARACTER MODE.

IF sy-subrc EQ 0.
SHIFT l_string2 RIGHT DELETING TRAILING: '0','.'.

ENDIF.


    <fs_data>-ntgew = l_string1.  "21,402,720.000" Erase HERE
     <fs_data>-brgew = l_string2.  "
21,822,230.400" Erase HERE


output :


21,402,720

21,822,230.4


Regards,

Shruti


A-J-S
Active Participant
0 Kudos

Hi,

Try using the FMs.

CONVERSION_EXIT_ALPHA_INPUT

CONVERSION_EXIT_ALPHA_OUTPUT

Or

Use TRUNC statment.

Regards.

0 Kudos

Its about delete zeros right and don´t delete zeros left...

former_member209120
Active Contributor
0 Kudos

Hi

ntgew,    " Net Weight
brgew.    " Gross Weight

    Domin     - MENG13
    DATA type - QUAN

    


Default having 3 Decimals Places

Example 1

DATA : ntgew TYPE ntgew,    " Net Weight
             brgew TYPE brgew.    " Gross Weight

ntgew   '21402720'.
brgew   '21822230'.

WRITE : / ntgew,
                /  brgew.

Out put

Default we will get 3 decimals

if you try like this

DATA : ntgew TYPE p length 16,    " Net Weight
            brgew TYPE p length 16.    " Gross Weight

ntgew   '21402720'.
brgew   '21822230'.

WRITE : / ntgew,
         /  brgew.

Output


Example 2


DATA : ntgew TYPE ntgew,    " Net Weight
        brgew TYPE brgew.    " Gross Weight

Data: ntgew_c(17) TYPE c,
       brgew_c(17) type c.

ntgew   '21402720.000'.
brgew   '21822230.400'.

ntgew_c = ntgew.
brgew_c = brgew.


CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
   CHANGING
     c_value       = ntgew_c.


CALL FUNCTION 'FTR_CORR_SWIFT_DELETE_ENDZERO'
   CHANGING
     c_value       = brgew_c.

WRITE : / ntgew_c,
         /  brgew_c.


Output


0 Kudos

Thanks Ramesh, use this:

In the select enter these variables

Types: Begin of ....

           ......

           ......

           ntgew TYPE p length 16,    " Net Weight
           brgew TYPE p length 16.

          End of.....

DATA : ntgew TYPE p length 16,    " Net Weight
           brgew TYPE p length 16.    " Gross Weight
     SELECT SUM( ntgew ) SUM( brgew ) INTO (st_texto-pes_net, st_texto-pes_bru)
       FROM vbap
       WHERE vbeln EQ <fs_data>-vbeln.

     MOVE st_texto-pes_net to ntgew.
     MOVE st_texto-pes_bru to brgew.

     <fs_data>-ntgew = ntgew.
     <fs_data>-brgew = brgew.

Former Member
0 Kudos

Hi Brujo,

Go through this thread.

http://scn.sap.com/thread/723495

Regards,

Anoop

Former Member
0 Kudos

Hi,

First remove the space in your variable,

Then use the following code

SHIFT <variable_name> RIGHT DELETING TRAILING '0'.

Regards,

Riju Thomas.

Former Member
0 Kudos

Hello

Please find the logic below:

DATA: brgew_c_yo TYPE string.

DATA: str1 TYPE string,

           str2 TYPE string.

DATA gt_tab TYPE STANDARD TABLE OF string.

DATA : brgew TYPE brgew.

brgew   '20822300.400'.

brgew_c_yo = brgew.

SPLIT brgew_c_yo AT '.' INTO : str1 str2 , TABLE gt_tab.

replace all OCCURRENCES OF '0' in str2 WITH ' '.

CONDENSE str2 NO-GAPS.

CONCATENATE str1 '.' str2 INTO brgew_c_yo.

WRITE brgew_c_yo.

OUTPUT:


Thanks and Kind Regards,

Yovish.

former_member493515
Discoverer
0 Kudos

Hi,

Try this FM:

FTR_CORR_SWIFT_DELETE_ENDZERO