ABAP - Minus sign last to first

Monday, 11 July 2016

*Move minus sign from end to begining of number value
*i.e. from 100.00- to -100.00
 
* check if negative amount
IF p_amount LT 0.
   SHIFT p_amount RIGHT DELETING TRAILING '-'.
   SHIFT p_amount LEFT DELETING LEADING ' '.
   CONCATENATE '-' p_amount INTO p_amount.
ELSE.
  SHIFT p_amount LEFT DELETING LEADING ' '.
ENDIF.
*Same thing can be achieved by using the FM CLOI_PUT_SIGN_IN_FRONT.
*Ex:
REPORT  z_demo_jg1.
 
PARAMETERS p_amount(10) TYPE c OBLIGATORY DEFAULT '100.15-'.
 
WRITE:/ 'BEFORE:', p_amount.
 
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
  CHANGING
    value = p_amount.
 
WRITE:/ 'AFTER:', p_amount.


Share

2 comments:

  1. It was very nice blog to learn about Selenium.Thanks for sharing new things.selenium training in chennai

    ReplyDelete
  2. Thanks for sharing this Information,

    Got to learn new things from your Blog on Sap abap.

    http://thecreatingexperts.com/sap-abap-training-in-chennai/

    Both online and classroom training is provided.

    Contact 8122241286

    ReplyDelete

 
Copyright © 2015 Sap 4 All
Distributed By SAP 4 ALL |