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 Kodyaz SAP and ABAP Programming Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.




Win FREE BOOK
from Kodyaz



CRM Companies List
Web Based CRM Software

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

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.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
 CHANGING
  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






Recent and Top SAP Tutorial and ABAP Tutorials

Unicode Character Problem in IFS File Interface
Read Pricing Condition Text using ABAP in SAP Sales Document Output
Export SAP Data to Fixed Length Text File
Save Table Contents into Text File and Download File
Business Document Service Error: Error when accessing graphic (BDS), RC = 5
Get Proforma Invoice from Commercial Invoice in ABAP
Convert Sales Unit into Text using Function Module in Target Language
Get Fullname of SAP user using Function Module in ABAP Program
ABAP Submit Report to Run Another ABAP Program within Code
Message no XS826: Cannot process message; no node determined for 76550052
SE63 Smartform Translation and Export using SLXT Program
VF31 SAP Transaction to Reprocess Billing Output Messages
Import and Export SO10 Standard Text using RSTXSCRP ABAP Program
CALL_FUNCTION_NOT_FOUND ABAP Run Time Error
SAP Output Management - Create New SAP Output Type
SAP Purchase Order Tables, Transaction Codes and Output
Assign SAP Item Category to Sales Document Type using SPRO
Window MAIN does not fit onto page PAGE (height)
SAP Invoice Output ZZZZ is not Defined
Invoice Output fail because of missing Billing Type text in TVFKT table
Read Integer and Decimals of a Numeric Value in ABAP Programming
SAP Smartforms Table Parameter in Form Routine
Complex Conditions in SAP Smartform with AND/OR
Free Adobe LiveCycle Designer Download
Create SAP Dynamic Variant using Date Calculation
Translate Web Dynpro Header Title displayed on Web Browser
ABAP RegEx for ABAP Regular Expression to fetch Date from String
Change Output Condition Records
Web Dynpro Text Translation using Assistance Class
Move Minus Sign from Right to Left of Negative Number in SAP Smartform
Read Address Data using FM ADDR_GET instead of Querying ADRC Table
Add Value Help to Web Dynpro Select Options
Add Web Dynpro Applications to SAP Favorites Menu
Component Usage ALV Does Not Have an Active Component
Web Dynpro Component Service Syntax Error in Program /1BCWDY/O3EC1AX6A3OVKK9L5FXO==CP
Web DynPro Tutorial - Display Spool Requests using Web DynPro Table
Web DynPro Tutorial - How to create Web Dynpro Application (Web Dynpro Component)
Display Data on Web DynPro Table Element
Test Web Dynpro ABAP Component by Creating Web Dynpro Application
Insert SAP Icons and Symbols on Smartform Documents
How to Display Text on Sap Smart Forms
Graphics White Background Displayed Grey on SAP Smartform Output
Get SAP Document Flow using SD_DOCUMENT_FLOW_GET ABAP Function Module
Convert Numeric Value or Currency into String Spell_Amount Function Module
How to Transport SAP Graphics using SE78 Transaction
How to Delete Standard Text using SO10 SAP Transaction
Dynamic Programming using Field Symbols in ABAP Reports
How to Disable Word Editor in SAP Smartform Text
How to Debug Popup Screen in ABAP
TVAP Item Category and SAP Table TVAPT for Text Translations
ABAP Runtime Error ST22 Transaction using Short Dump Analysis
Create Transport Request for Text Translations using RS_LXE_RECORD_TORDER
SAP Invoice Output Determination Analysis for Not Created Output Message
Set Default Single Values List for SAP Selection Screen Parameter
SAP Payment Terms Table and ZTERM Texts Table for ABAP Developers
How to Create SAPScript Text using SO10 Transaction Code
SAP Smartforms Tutorial - Table Calculations using Sum Total
SAP Smartforms Tutorial - Table Calculations using Count
SAP Smartforms Tutorial - How to Create Smartform
SAP NetWeaver Installation Guide using installshield wizard
SAP Smartforms Table for Sales Order and Invoice Outputs
Email Spool Request using SAPOffice - Spool to PDF
How to Display SAP Graphics using SE78 Transaction Code
SAPScript Transaction Codes
ABAP Tutorial - ABAP String Split Example Code
Sales Tables among ABAP Tables (SAP Sales and Distribution SD Tables)
How to Upload Data to SAP from Excel File using alsm_excel_to_internal_table Function Module
ALV Grid Color - Table Row Background Color in ALV List
Multi Color ALV Grid Color Alternate using ALV Layout info_fname Property
How to Debug SmartForms - Debugging SAP SmartForm in ABAP ?
ABAP - Create Hierarchy Tree List using rs_tree_construct, rs_tree_list_display and snodetext
Create CL_GUI_ALV_GRID ALV Grid Column Header using ABAP Data Element
ABAP Tutorial - SAP Split and ABAP Split String Function
Upload Data from Excel File in ABAP using TEXT_CONVERT_XLS_TO_SAP
SAP Tutorial - Convert Spool Request to PDF File using RSTXPDFT4 ABAP Report
SAP ABAP Tutorial - ALV Grid Example with cl_gui_alv_grid and Screen Painter
Convert Smartform to PDF in Print Preview Mode
SAP Smartforms Tutorial - Create Smartforms Example
SAP Smartforms - How to Call Smartform within ABAP Program
Complete List of SAP Modules






Copyright © 2004 - 2013 Eralper Yilmaz. All rights reserved.
Community Server by Telligent Systems