SAP G_VALUE_CONVERT Function Module for Transfer a Value with Type Conversion









G_VALUE_CONVERT is a standard g value convert SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Transfer a Value with Type Conversion processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.


See here to view full function module documentation and code listing for g value convert FM, simply by entering the name G_VALUE_CONVERT into the relevant SAP transaction such as SE37 or SE38.

Function Group: GSDD
Program Name: SAPLGSDD
Main Program:
Appliation area: G
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:



Function G_VALUE_CONVERT pattern details

In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.
CALL FUNCTION 'G_VALUE_CONVERT'"Transfer a Value with Type Conversion
EXPORTING
FROMVALUE = "Value to be Transferred
* TO_DATATYPE = 'CHAR' "Screen Data Type for Screen Painter
* TO_DECIMALS = 000000 "Number of decimal places
* TO_LENG = 000000 "Length of Target Field (Number of Characters)
* TO_LOWERCASE = ' ' "Flag: Lower Case Letters allowed
* TO_OUTPUTLEN = 000000 "Output Length of Target Field
* TO_SIGN = ' ' "Sign Flag for Numeric Fields (X=set)
* FROM_CONVEXIT = ' ' "Conversion Routine (such as ALPHA)
* FROM_DATATYPE = 'CHAR' "Screen Data Type for Screen Painter
* FROM_DECIMALS = 000000 "Number of Decimal Places
* FROM_LENG = 000000 "Length of Source Field (Number of Characters)
* FROM_LOWERCASE = ' ' "Flag: Lower Case Letters allowed
* FROM_OUTPUTLEN = 000000 "Output Length of Source Field
* FROM_SIGN = ' ' "Sign Flag for Numeric Fields (X=set)
* TO_CONVEXIT = ' ' "Conversion Routine (such as ALPHA)

IMPORTING
TOVALUE = "Value after Type Conversion

EXCEPTIONS
ILLEGAL_LENGTH = 1 TYPE_MISMATCH = 2 VALUE_NOT_CONVERTIBLE = 3 WRONG_FORMAT = 4
.



IMPORTING Parameters details for G_VALUE_CONVERT

FROMVALUE - Value to be Transferred

Data type: C
Optional: No
Call by Reference: No ( called with pass by value option)

TO_DATATYPE - Screen Data Type for Screen Painter

Data type: DFIES-DATATYPE
Default: 'CHAR'
Optional: Yes
Call by Reference: No ( called with pass by value option)

TO_DECIMALS - Number of decimal places

Data type: DFIES-DECIMALS
Default: 000000
Optional: Yes
Call by Reference: No ( called with pass by value option)

TO_LENG - Length of Target Field (Number of Characters)

Data type: DFIES-LENG
Default: 000000
Optional: Yes
Call by Reference: No ( called with pass by value option)

TO_LOWERCASE - Flag: Lower Case Letters allowed

Data type: DFIES-LOWERCASE
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

TO_OUTPUTLEN - Output Length of Target Field

Data type: DFIES-OUTPUTLEN
Default: 000000
Optional: Yes
Call by Reference: No ( called with pass by value option)

TO_SIGN - Sign Flag for Numeric Fields (X=set)

Data type: DFIES-SIGN
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

FROM_CONVEXIT - Conversion Routine (such as ALPHA)

Data type: DFIES-CONVEXIT
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

FROM_DATATYPE - Screen Data Type for Screen Painter

Data type: DFIES-DATATYPE
Default: 'CHAR'
Optional: Yes
Call by Reference: No ( called with pass by value option)

FROM_DECIMALS - Number of Decimal Places

Data type: DFIES-DECIMALS
Default: 000000
Optional: Yes
Call by Reference: No ( called with pass by value option)

FROM_LENG - Length of Source Field (Number of Characters)

Data type: DFIES-LENG
Default: 000000
Optional: Yes
Call by Reference: No ( called with pass by value option)

FROM_LOWERCASE - Flag: Lower Case Letters allowed

Data type: DFIES-LOWERCASE
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

FROM_OUTPUTLEN - Output Length of Source Field

Data type: DFIES-OUTPUTLEN
Default: 000000
Optional: Yes
Call by Reference: No ( called with pass by value option)

FROM_SIGN - Sign Flag for Numeric Fields (X=set)

Data type: DFIES-SIGN
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

TO_CONVEXIT - Conversion Routine (such as ALPHA)

Data type: DFIES-CONVEXIT
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXPORTING Parameters details for G_VALUE_CONVERT

TOVALUE - Value after Type Conversion

Data type: C
Optional: No
Call by Reference: No ( called with pass by value option)

EXCEPTIONS details

ILLEGAL_LENGTH - Length of a Transferring Field not Correct

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

TYPE_MISMATCH - Source and Target Type do not match

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

VALUE_NOT_CONVERTIBLE - Transferred Value not Convertable

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

WRONG_FORMAT - Transferred Value in Incorrect Format

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

Copy and paste ABAP code example for G_VALUE_CONVERT Function Module

The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.

DATA:
lv_tovalue  TYPE C, "   
lv_fromvalue  TYPE C, "   
lv_illegal_length  TYPE C, "   
lv_to_datatype  TYPE DFIES-DATATYPE, "   'CHAR'
lv_to_decimals  TYPE DFIES-DECIMALS, "   000000
lv_to_leng  TYPE DFIES-LENG, "   000000
lv_to_lowercase  TYPE DFIES-LOWERCASE, "   SPACE
lv_to_outputlen  TYPE DFIES-OUTPUTLEN, "   000000
lv_to_sign  TYPE DFIES-SIGN, "   SPACE
lv_from_convexit  TYPE DFIES-CONVEXIT, "   SPACE
lv_type_mismatch  TYPE DFIES, "   
lv_from_datatype  TYPE DFIES-DATATYPE, "   'CHAR'
lv_value_not_convertible  TYPE DFIES, "   
lv_wrong_format  TYPE DFIES, "   
lv_from_decimals  TYPE DFIES-DECIMALS, "   000000
lv_from_leng  TYPE DFIES-LENG, "   000000
lv_from_lowercase  TYPE DFIES-LOWERCASE, "   SPACE
lv_from_outputlen  TYPE DFIES-OUTPUTLEN, "   000000
lv_from_sign  TYPE DFIES-SIGN, "   SPACE
lv_to_convexit  TYPE DFIES-CONVEXIT. "   SPACE

  CALL FUNCTION 'G_VALUE_CONVERT'  "Transfer a Value with Type Conversion
    EXPORTING
         FROMVALUE = lv_fromvalue
         TO_DATATYPE = lv_to_datatype
         TO_DECIMALS = lv_to_decimals
         TO_LENG = lv_to_leng
         TO_LOWERCASE = lv_to_lowercase
         TO_OUTPUTLEN = lv_to_outputlen
         TO_SIGN = lv_to_sign
         FROM_CONVEXIT = lv_from_convexit
         FROM_DATATYPE = lv_from_datatype
         FROM_DECIMALS = lv_from_decimals
         FROM_LENG = lv_from_leng
         FROM_LOWERCASE = lv_from_lowercase
         FROM_OUTPUTLEN = lv_from_outputlen
         FROM_SIGN = lv_from_sign
         TO_CONVEXIT = lv_to_convexit
    IMPORTING
         TOVALUE = lv_tovalue
    EXCEPTIONS
        ILLEGAL_LENGTH = 1
        TYPE_MISMATCH = 2
        VALUE_NOT_CONVERTIBLE = 3
        WRONG_FORMAT = 4
. " G_VALUE_CONVERT




ABAP code using 7.40 inline data declarations to call FM G_VALUE_CONVERT

The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.

 
 
 
"SELECT single DATATYPE FROM DFIES INTO @DATA(ld_to_datatype).
DATA(ld_to_datatype) = 'CHAR'.
 
"SELECT single DECIMALS FROM DFIES INTO @DATA(ld_to_decimals).
DATA(ld_to_decimals) = 000000.
 
"SELECT single LENG FROM DFIES INTO @DATA(ld_to_leng).
DATA(ld_to_leng) = 000000.
 
"SELECT single LOWERCASE FROM DFIES INTO @DATA(ld_to_lowercase).
DATA(ld_to_lowercase) = ' '.
 
"SELECT single OUTPUTLEN FROM DFIES INTO @DATA(ld_to_outputlen).
DATA(ld_to_outputlen) = 000000.
 
"SELECT single SIGN FROM DFIES INTO @DATA(ld_to_sign).
DATA(ld_to_sign) = ' '.
 
"SELECT single CONVEXIT FROM DFIES INTO @DATA(ld_from_convexit).
DATA(ld_from_convexit) = ' '.
 
 
"SELECT single DATATYPE FROM DFIES INTO @DATA(ld_from_datatype).
DATA(ld_from_datatype) = 'CHAR'.
 
 
 
"SELECT single DECIMALS FROM DFIES INTO @DATA(ld_from_decimals).
DATA(ld_from_decimals) = 000000.
 
"SELECT single LENG FROM DFIES INTO @DATA(ld_from_leng).
DATA(ld_from_leng) = 000000.
 
"SELECT single LOWERCASE FROM DFIES INTO @DATA(ld_from_lowercase).
DATA(ld_from_lowercase) = ' '.
 
"SELECT single OUTPUTLEN FROM DFIES INTO @DATA(ld_from_outputlen).
DATA(ld_from_outputlen) = 000000.
 
"SELECT single SIGN FROM DFIES INTO @DATA(ld_from_sign).
DATA(ld_from_sign) = ' '.
 
"SELECT single CONVEXIT FROM DFIES INTO @DATA(ld_to_convexit).
DATA(ld_to_convexit) = ' '.
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!