SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.

Install SAP Free

Move Minus Sign from Right to Left of Negative Number in SAP Smartform

In ABAP when displaying or printing negative numeric value the minus sign is on the right of the value instead of left of the number. So ABAP developers or Smartform developers are required to format negative numbers and move minus sign from right to left of the number before printing it.

This ABAP tutorial includes a following methods :
number format option for SAP Smartform to shift the negative sign from right to the left of the number
ABAP codes to move minus sign from right to the left of the negative number
ABAP function module CLOI_PUT_SIGN_IN_FRONT to set negative sign to the left side of the number value

move minus from right side to left of negative value

As best practice to print negative values with minus sign leading the value instead of trailing is to format negative numeric values according to your requirements. And the solution is as simple as using the (<C) formatting option in the Text control where you print the numeric value.

move minus sign to left from right

Here is ABAP code block which can help you convert a numeric value into string, condense string value to remove leading spaces and then move minus sign to left from right of negative number value.
Please note that the following ABAP code reads numeric value into a local variable. Then checks if it is a negative number or not. If it has a negative numeric value then multiplies with -1 in order to take the absolute value of the numeric data. After making the number positive, the ABAP code saves it into a character variable which is used to display numeric value on Text object on SAP Smartform document. We've now get rid of the minus sign of the number value. Using SHIFT ... LEFT DELETE LEADING ' ' statement the leading space characters are cleared. If the original number value is negative, as last step of the ABAP script, the minus sign "-" is added in front of the character value by using CONCATENATE command.

This is how ABAP developers can move minus sign from right of the negative number to left side by using ABAP code and display value on a Text object on SAP Smartform document.

*DATA GV_CONDVALUE_TXT TYPE CHAR20. " in Global Data definition
DATA lv_kwert TYPE kwert.

lv_kwert = gs_it_kond-kwert.

IF gs_it_kond-kwert < 0.
 lv_kwert = -1 * lv_kwert .
WRITE lv_kwert TO gv_condvalue_txt.
SHIFT gv_condvalue_txt LEFT DELETING LEADING ' '.
IF gs_it_kond-kwert < 0.
 CONCATENATE '-' gv_condvalue_txt INTO gv_condvalue_txt.

leading minus sign

You can create a form method in order to simplify this ABAP code block for using every numeric value you print on your SAP Smartforms output documents.

Using ABAP function module CLOI_PUT_SIGN_IN_FRONT is an other option to bring the minus sign to front of the negative number value.
In order to use the CLOI_PUT_SIGN_IN_FRONT function module, ABAP developers should store the numeric value in a character like CLIKE data type. Here is an example where you can use the codes in your ABAP programs.

DATA gv_negativenumericvalue TYPE kwert VALUE -100.
DATA gv_negativenumericvalue_txt TYPE char40.

WRITE gv_negativenumericvalue TO gv_negativenumericvalue_txt.
  value = gv_negativenumericvalue_txt.
WRITE :/ 'negative number : ', gv_negativenumericvalue.
WRITE :/ 'FM format number: ', gv_negativenumericvalue_txt.

The output of the above ABAP sample report is as seen in below screenshot

ABAP function module cloi_put_sign_in_front

SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table

Related Articles and Tutorials(http://www.kodyaz.com/sap-abap/move-minus-sign-from-right-to-left.aspx)
SAPScript Transaction Codes
Complex Conditions in SAP Smartform with AND/OR
Prevent DYNPRO_SEND_IN_BACKGROUND Error in Background Process
How to find string length using STRLEN ABAP string function
ABAP Tutorial - SAP Split and ABAP Split String Function
Free Adobe LiveCycle Designer Download
Change Output Condition Records
Check Existence using ABAP SELECT
Convert Smartform to PDF in Print Preview Mode
Create Business Object in SAP
Delete All Data from SAP Database Table
How to Execute SAP Program in Background Task
How to Find Internal Table Row Count in ABAP
Export SAP Data to Fixed Length Text File
Code Inspector: Unsecure use of FOR ALL ENTRIES
How to Upload Data to SAP from Excel File using alsm_excel_to_internal_table Function Module
ABAP - Create Hierarchy Tree List using rs_tree_construct, rs_tree_list_display and snodetext
ABAP Tutorial - ABAP String Split Example Code
Upload Data from Excel File in ABAP using TEXT_CONVERT_XLS_TO_SAP
Create CL_GUI_ALV_GRID ALV Grid Column Header using ABAP Data Element
Email Spool Request using SAPOffice - Spool to PDF
How to Create SAPScript Text using SO10 Transaction Code
ALV Grid Color - Table Row Background Color in ALV List
SAP ABAP Tutorial - ALV Grid Example with cl_gui_alv_grid and Screen Painter
SAP Invoice Output Determination Analysis for Not Created Output Message
SAP Smartforms - How to Call Smartform within ABAP Program
SAP Smartforms Table for Sales Order and Invoice Outputs
SAP Smartforms Tutorial - How to Create Smartform
SAP Smartforms Tutorial - Table Calculations using Count
SAP Smartforms Tutorial - Table Calculations using Sum Total
SAP Tutorial - Convert Spool Request to PDF File using RSTXPDFT4 ABAP Report
Set Default Single Values List for SAP Selection Screen Parameter
ABAP Debugging using Log Point and Break Point
ABAP RegEx for ABAP Regular Expression to fetch Date from String
ABAP Runtime Error ST22 Transaction using Short Dump Analysis
ABAP Shared Memory Objects Tutorial with Sample ABAP Code
ABAP Try Catch for exception is neither caught Code Inspector Error
Add Year, Month or Day to Date Variable in ABAP using RP_CALC_DATE_IN_INTERVAL
Read Address Data using FM ADDR_GET instead of Querying ADRC Table
Adobe Forms Table Header is Missing After Second Page
ABAP Authority-Check Object For User Other Than Current
SAP Code Inspector for ABAP Break-Point Statement
Call Function Module using RFC Destination in ABAP
Message no XS826: Cannot process message; no node determined for 76550052
How to Spell Numbers using ABAP Spell_Amount Function Module
Convert the table using the Database Utility (SE14)
Convert Sales Unit into Text using Function Module in Target Language
Create SAP Dynamic Variant using Date Calculation
Create SAP Transaction to Maintain ABAP Table using SM30
Database Hint Pseudo-Comment for SAP Code Inspector
Delete Entries in NAST Table using RSCLNAST ABAP Program
Dynamic Programming using Field Symbols in ABAP Reports
Execute ABAP Program Automatically After Transport Request Import
How to Export IDOC as Excel and Save as Local File from WE02 Transaction
Export SAP Spool Requests as PDF using SP01 Transaction
How to Find Output Determination Procedure for a Billing Document
Get Fullname of SAP user using Function Module in ABAP Program
How to Debug Popup Screen in ABAP
How to Disable Word Editor in SAP Smartform Text
How to Find User Exits in ABAP Codes of SAP Transaction
Read Integer and Decimals of a Numeric Value in ABAP Programming
Import and Export SO10 Standard Text using RSTXSCRP ABAP Program
ABAP LOOP Statement with At New and At End
Move Minus Sign from Right to Left of Negative Number in SAP Smartform
Primary key change not permitted for value table
Print SAP Outputs From Two Printers at the Same Time
Get Proforma Invoice from Commercial Invoice in ABAP
Read Pricing Condition Text using ABAP in SAP Sales Document Output
Read Text Symbols in Specific Language using ABAP RS_TEXTPOOL_READ
Get SAP Document Flow using SD_DOCUMENT_FLOW_GET ABAP Function Module
SAP Invoice Output ZZZZ is not Defined
SAP Output Management - Create New SAP Output Type
Export Table Contents into Text File and Download File
ABAP Tutorial for SET and GET PARAMETER ID Command
SAP Smartforms Table Parameter in Form Routine
SAP Purchase Order Tables, Transaction Codes and Output
Graphics White Background Displayed Grey on SAP Smartform Output
SE63 Smartform Translation and Export using SLXT Program
Search and Find SAP Transaction Code using SE93 or SEARCH_SAP_MENU
SAP Code Inspector Error: Select For Cluster Table Without Order By
ABAP Select Statement using Space instead of Null or Initial
SAP Code Inspector: Select-Statement can be Transformed
Window MAIN does not fit onto page PAGE (height)
ABAP CONVT_NO_NUMBER Error on SP01 due SP01_WARN Parameter
ABAP Submit Report to Run Another ABAP Program within Code
Transport Variants of an ABAP Program into Workbench Request
Trigger Output Re-Determination for Billing Documents
TVAP Item Category and SAP Table TVAPT for Text Translations
Update Multiple Variables in ABAP Select Single Statement
VF31 SAP Transaction to Reprocess Billing Output Messages
Web DynPro Tutorial - Display Spool Requests using Web DynPro Table
Function module is not released for the Internet
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement

Copyright © 2004 - 2018 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems