ABAP - Minus sign last to first - Sap 4 All

Latest

Please enter your email and get the updates in your inbox.

Monday, 11 July 2016

ABAP - Minus sign last to first

*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.


1 comment:

  1. 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