Site Search

Saturday, February 19, 2011

Function Module to place negative Sign Before a Number

In SAP the negative sign by default come after the number. In case if you wish to place the negative sign before the number the following function module should be used.
SAP ABAP Function Module to place the sign before a number.

CLOI_PUT_SIGN_IN_FRONT
The above mentioned function module has the following parameters.
VALUE
Note: This is a changing parameter and accepts the value with Data Type Character.
Find the code below.


REPORT ZEXAMPLE_SIGN .


PARAMETERS : p_num1  TYPE  i,
                             p_num2  TYPE  i.

DATA: d_sum TYPE i,
            d_value(10).

d_sum = p_num1 + p_num2.
d_value = d_sum.

Write: d_sum.

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'

  CHANGING

    VALUE         =  d_value

          .

SKIP.

write:/ d_value RIGHT-JUSTIFIED.

Saturday, January 15, 2011

Totals/Subtotals Display with Currency/Quantity Unit in ALV

Pass the QFIELDNAME for quantity fields, CFIELDNAME for currency fields in fieldcatlog.

Go through the following link for fieldcat of quantity and currency fields. 
http://help.sap.com/saphelp_46c/helpdata/pt/ff/4649b1f17411d2b486006094192fe3/content.htm

Example:

check the below code:

CLEAR WA_FIELDCAT.
WA_FIELDCAT_ALV-FIELDNAME = 'MEINS'. "internal table unit field
WA_FIELDCAT_ALV-SELTEXT_L = 'UoM'.
APPEND WA_FIELDCAT_ALV TO IT_FIELDCAT_ALV.


CLEAR WA_FIELDCAT.
WA_FIELDCAT_ALV-FIELDNAME = 'MENGE'.
WA_FIELDCAT_ALV-SELTEXT_L = 'Quantity'.
WA_FIELDCAT_ALV-QFIELDNAME = 'MEINS'. "pass your intenal table unit field  as quantity unit
APPEND WA_FIELDCAT_ALV TO IT_FIELDCAT_ALV.

Output: