## How To Remove Decimal Points In ABAP

Today I want to share to you how to remove decimal points using ABAP.

This task is very simple, for example you have this number:

X = 1.235,934

And then you want to display the X number as 1.234.

To do this all you need to do is switching the X variable from Decimal into Integer.

Let’s see below example:

Data: x type P decimal 3,

y type i.

X = ’1.235,934′.

I = X.

Write I.

The result will be 1.235.

If you don’t want to use Integer data type you can also declare a decimal variable but using zero decimal point. e.g. Data x type p decimal 0.

And that’s how to remove decimal point using ABAP, Easy right?

Popularity: 2% [?]

## How To Find A List Of Table Names In SAP

Hi there,

I just got a request from the function analyst to list all the custom tables in SAP.There is actually a table that stores the custom table names in SAP.

The table name is DD02L

All you need to do is fill in Z* the TABNAME field and the TABCLASS as TRANSP. After that you will see all the custom tables in the SAP.

Popularity: 9% [?]

## How To Find The Calling Program Of a SmartForms

Today I want to show you how to find the calling program of a SmartForms.

Sometimes we are asked to modify a certain programs that are using SmartForms, and if you want to know how to find the calling program of a Smartforms then you can use the table TNAPR.

In this table you can see the driver program and the FORMS (SAPSCRIPT OR SMARTFORMS.

In table TNAPR you can filter based on the Output Type as well, or the program name to get the FORM name.

Popularity: 9% [?]

## Function To Convert Exponential Number

I received a program specification to convert an exponential number such as 4,0000000000000000E+05 into an integer.

Here’s the function I used to do just that.

Function to convert exponential number.

data cycle type CHA_CLASS_VIEW-SOLLWERT.
data v_float type CHA_CLASS_DATA-SOLLWERT.

CALL FUNCTION ’QSS0_FLTP_TO_CHAR_CONVERSION’
EXPORTING
I_NUMBER_OF_DIGITS             = 0
I_FLTP_VALUE                   = v_float
*       I_VALUE_NOT_INITIAL_FLAG       = ’X’
*       I_SCREEN_FIELDLENGTH           = 16
IMPORTING
E_CHAR_FIELD                   = cycle.

Popularity: 9% [?]

## Exception “CX_SY_OPEN_SQL_DB”

When you see this exception Exception “CX_SY_OPEN_SQL_DB” the main reason is because you’re trying to pass more than the allowed number of values for a field in the WHERE clause while using SELECT

For Example:

SELECT column FROM table_name INTO itab WHERE field1 in r_values

What causing the error to occured is the variable r_values is containing more than 1000 rows. You need to split them into more smaller units or you can use for all entries statement in your select statement.

See the correct example:

SELECT column FROM table_name INTO itab FOR ALL ENTRIES IN r_values WHERE field1 = r_values-field1

Popularity: 13% [?]

## How To Attach F4 Help Into Parameters Dynamically Using ABAP

Sometimes we need to attach the F4 help into our selection screen parameter dynamically based on the given parameters.

For example, you have 3 screen parameters, sales org (VKORG), sales document type (AUART) and VBELN. Based on the selected VKORG, AUART ( document type ) we want to filter the Vbeln data and show it in search help pop up.

To do this scenario, we need 3 steps, the first step is by using

After that we need the

F4IF_INT_TABLE_VALUE_REQUEST function to load the query result from VBAK table based on the AUART values.

After that we use the

DYNP_VALUES_UPDATE function to get the value into the target field parameter.

Now here’s the sample code.

REPORT ZTEST100.
li_retutab LIKE STANDARD TABLE OF ddshretval WITH HEADER LINE.

CONSTANTS :
dyname LIKE d020s-prog VALUE ‘ZTEST100′,
dynumb LIKE d020s-dnum VALUE ’1000′,
prog LIKE sy-repid VALUE ‘ZTEST100′,
dynr LIKE sy-dynnr VALUE ’1000′.

DATA:
BEGIN OF t_vbak OCCURS 0,
vbeln type vbak-vbeln,
auart type vbak-auart,
END OF t_vbak.

DATA:
GV_VKORG TYPE VBAK-VKORG,
GV_AUART TYPE VBAK-auart.

PARAMETERS:
p_vkorg type vbak-vkorg,
p_auart type vbak-auart,
p_vbeln type vbak-vbeln.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vbeln.
PERFORM GET_VBELN.

FORM GET_VBELN.

REFRESHdynpfieldsli_retutab.
MOVE ‘P_VKORG’ TO dynpfields-fieldname.
APPEND dynpfields.

EXPORTING
dyname     dyname
dynumb     sy-dynnr
TABLES
dynpfields dynpfields
EXCEPTIONS
OTHERS.

IF sy-subrc 0.
GV_VKORG dynpfields-fieldvalue.
ENDIF.

REFRESHdynpfieldsli_retutab.
MOVE ‘P_AUART’ TO dynpfields-fieldname.
APPEND dynpfields.

EXPORTING
dyname     dyname
dynumb     sy-dynnr
TABLES
dynpfields dynpfields
EXCEPTIONS
OTHERS.

IF sy-subrc 0.
GV_AUART dynpfields-fieldvalue.
ENDIF.

IF GV_VKORG NE SPACE AND GV_AUART NE SPACE.
SELECT VKORG VBELN AUART INTO CORRESPONDING FIELDS OF TABLE
t_vbak from vbak WHERE
vkorg gv_vkorg AND auart gv_auart.

ENDIF.

CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST’
EXPORTING
retfield        ‘VBELN’
value_org       ‘S’

TABLES
value_tab       t_vbak
return_tab      li_retutab
EXCEPTIONS
parameter_error 1
no_values_found 2
OTHERS          3.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MOVE ‘P_VBELN’ TO dynpfields-fieldname.
MOVE li_retutab-fieldval TO dynpfields-fieldvalue.

APPEND dynpfields.

CALL FUNCTION ‘DYNP_VALUES_UPDATE’
EXPORTING
dyname               dyname
dynumb               dynumb
TABLES
dynpfields           dynpfields
EXCEPTIONS
invalid_abapworkarea 1
invalid_dynprofield  2
invalid_dynproname   3
invalid_dynpronummer 4
invalid_request      5
no_fielddescription  6
undefind_error       7
OTHERS               8.
ENDIF.

ENDFORM.

The Result:

Popularity: 13% [?]

Today I want to share to you how to download your ABAP report program. You can do this by using REPTRAN program that is available in SAP. This task is useful when you want to have a backup files for your ABAP program.

1. Execute REPTRAN program using SE38. Type in the program name you want to download.

2. Execute the program, you can also change the directory path to your prefered folder. The downloaded ABAP Code will be saved in text files format.

Popularity: 14% [?]

## How To Check If A Number Contains Decimal Points

In this tutorial I want to teach you how to find out if there’s a decimal point in a number.

Earlier, I need this logic to change the decimal symbol from ‘.’ to ‘,’ because I want to pass the values into an Excel Worksheet.

DATA: lv_char(10) type c value ’27.500′.

find ’.' in lv_char.

if sy-subrc = 0.
REPLACE ’.' IN lv_char  WITH ’,’.
ENDIF.

Popularity: 14% [?]

## Using Field Symbol In SAP

Today I want to share to you about how to tune your ABAP program using Field Symbol. Usually when you’re trying to update an internal table, you’re using working area and the MODIFY command to update the internal table.

But when using Field Symbol you don’t need to use the MODIFY syntax anymore because once you’ve assigned the working area into that field symbol then it will automatically update the column with the given values and this will enhance your ABAP Performance significantly.

Here’s the sample code of using Field Symbol, below code is pretty simple, we’re trying to modify the sgtxt in the MSEG internal table and as you can see we don’t need to put any MODIFY command but the internal table will be updated with the supplied values.

```DATA: lt_bseg TYPE STANDARD TABLE OF bseg,
wa_bseg LIKE LINE OF i_bseg,
lv_flag TYPE flag,

FIELD-SYMBOLS: <fs_bseg> LIKE LINE OF lt_bseg.

LOOP AT lt_bseg ASSIGNING <fs_bseg>.

IF lv_flag = 'X'.
<fs_bseg>-sgtxt = 'TEST'.
ENDIF.

IF lv_flag IS INITIAL.
lv_flag = 'X'.
ENDIF.

ENDLOOP.```

Popularity: 14% [?]

## Printing Several Forms In One Request Using ABAP

Have you ever had a requirement to print several SmartForms in one request? This scenario ofter used when you want to print out several forms in a loop process.

For example you need to print 10 different Sales Order in one form, in common practise you would need to input each SO number and print the form 10 times.

But there’s a way to combine all these 10 forms into one request. Here’s the code implementation.

```Data: lv_fmname type rs38l_fnam,
lw_out_option TYPE ssfcompop,
lw_control    TYPE ssfctrlop.```
```data : d_tabix like sy-tabix,
d_lines type int4.
Loop At t_so.
select * from vbak into table t_data_send where vbeln = t_so-vbeln.
d_lines = sy-tabix.```
```    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME                 = 'ZFORM_SO'
*       VARIANT                  = ' '
*       DIRECT_CALL              = ' '
IMPORTING
FM_NAME                  = lv_fmname
EXCEPTIONS
NO_FORM                  = 1
NO_FUNCTION_MODULE       = 2
OTHERS                   = 3```
```    if d_lines > 1.
if d_tabix = 1.
lw_control-NO_OPEN = space.
lw_control-NO_close = 'X'.
elseif d_tabix < d_lines.
lw_control-NO_OPEN = 'X'.
lw_control-NO_close = 'X'.
else.
lw_control-NO_OPEN = 'X'.
lw_control-NO_close = space.
endif.
endif.```
```    CALL FUNCTION lv_fmname
EXPORTING
*       ARCHIVE_INDEX              =
*       ARCHIVE_INDEX_TAB          =
*       ARCHIVE_PARAMETERS         =
CONTROL_PARAMETERS         = lw_control
*       MAIL_APPL_OBJ              =
*       MAIL_RECIPIENT             =
*       MAIL_SENDER                =
OUTPUT_OPTIONS             = lw_out_option
USER_SETTINGS              = 'X'
*     IMPORTING
*       DOCUMENT_OUTPUT_INFO       =
*       JOB_OUTPUT_INFO            =
*       JOB_OUTPUT_OPTIONS         =
TABLES
T_DATA                     = t_data_send
EXCEPTIONS
FORMATTING_ERROR           = 1
INTERNAL_ERROR             = 2
SEND_ERROR                 = 3
USER_CANCELED              = 4
OTHERS                     = 5
EndLoop.```

Popularity: 14% [?]