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
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

ATC Check: Suspect Conversion from Literal to ABAP Type

A recent ATC ABAP Test Cockpit tool check for code quality and code security (VCA) showed following error: Suspect Conversion from Literal to ABAP Type and with following details.

Suspect Conversions
Suspect Conversion from Literal to ABAP Type
The message can be suppressed with pseudo comment "#EC CI_CONV_OK

Or in some cases another very similar ATC error can be displayed

The literal "'XXXXXXXXXXXXXXXXX'" is not type-compatible with the formal parameter "I_BAPI_VIEW".
Results can be hidden using pragma ##LIT_COMPATIBLE

The solution I suggest in this tutorial can be used as assigning the same value to all fields of a structure dynamically without knowing the field names of the structure or the structure type code variable in your SAP developments.

The ABAP code block that catched the attention of ATC tool is following value assignment statement.

data ls_bapi_view like order_view.
move 'XXXXXXXXXXXXXXXXX' TO ls_bapi_view.

Although the code works without throwing any execution error at runtime and assigning 'X' abap_true value to each field of order_view structure, ATC tool shows this code fragment as a warning.

assign literal value to ABAP type variable

As mentioned in the ATC check error details, using pseudo comment "#EC CI_CONV_OK as in below ABAP code block can suppress the error.

data ls_bapi_view like order_view.

But I think following assignment ABAP code routine is a better approach for assigning the same value, in this case the abap_true 'X' to all field values of ABAP structure type variable.
Here is the ABAP code for assigning the same value to all fields of a ABAP structure.

data ls_bapi_view like order_view.
field-symbols: <fs_fieldsymbol>.
clear sy-subrc.
while sy-subrc = 0.
assign component sy-index of structure ls_bapi_view to <fs_fieldsymbol>.
<fs_fieldsymbol> = 'X'.


Install SAP Free
CRM Companies List
Web Based CRM Software

Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.