Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

Display a negative value with signage to the left instead of the right -100.00 not 100.00-

$
0
0

In the past I have had more than 1 client request that the negative numbers with signage on the right are displayed in ALV reports and / or extracted to files with the signage to the left.

 

-100.00 NOT100.00-

 

I decided to create a conversion exit to perform this format conversion, as below. And this then is implemented in my alv / file extract logic.

conv_exit.jpg

" ALV field cat coding...apply the conv exit accordingly to the edit_mask attribute...

....

if <fieldcat>-inttype = 'P'.
    <fieldcat>-edit_mask = '==ZSIGD'.
  endif.

.....

similarly, if you are extracting the data to a file,

the conversion can also be called to format the number

.......

   do.
        assign component sy-index of structure <table_line> to <field>.
        if sy-subrc is initial. "we still processing fields
          clear lv_value.
          describe field <field> type lv_typ1.
          if lv_typ1 = 'D'. " format for date
            yyyymmdd_date_format <field> lv_value.
          elseif lv_typ1 = 'h'.
            move space to lv_value.
          elseif lv_typ1 = 'P'.
            call function 'CONVERSION_EXIT_ZSIGD_OUTPUT'
              exporting
                input  = <field>
              importing
                output = lv_value.
          else. "all other formats
            move <field> to lv_value.
          endif.

          ">>>build up the row that will be written to the file
          concatenate lv_fileline lv_value into lv_fileline
            separated by cl_abap_char_utilities=>horizontal_tab.

.......

Result of ALV
result.jpg

Result of File extract

excel.jpg


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>