Shift negative sign from back to front

This is a post on how to fix minor issue which I recently came across at work. The message I was sending to receiver Oracle DB through JDBC adapter was not accepted because it contained a number followed by a ‘-‘ (dash) sign.

There’s standard SAP simple Function Module that came with help to resolve the issue: CLOI_PUT_SIGN_IN_FRONT

In case the FM is not available in your system, you can always create custom FM with the following body:

FUNCTION CLOI_PUT_SIGN_IN_FRONT.
 *"--------------------------------------------------------------------
 *"*"Lokale Schnittstelle:
 *"  CHANGING
 *"     VALUE(VALUE) TYPE  CLIKE
 *"--------------------------------------------------------------------
 
   DATATEXT1(1TYPE C.
 
   SEARCH VALUE FOR '-'.
   IF SY-SUBRC AND SY-FDPOS <> 0.
     SPLIT VALUE AT '-' INTO VALUE TEXT1.
     CONDENSE VALUE.
     CONCATENATE '-' VALUE INTO VALUE.
   ELSE.
     CONDENSE VALUE.
   ENDIF.
 
 ENDFUNCTION.


Screenshot presenting the result of executing the FM:

scrn_4

About maciejbialek

Hello! I'm passionate, certified ABAP developer and SAP Consultant with many years of hands-on experience gained across several projects in Telco and Energy & Utilities industries. I've worked as Integration Architect, PI and ABAP Developer as well as BPC (NW) Consultant for local and international clients.

Leave a Reply