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 SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, code samples and tools and downloads for ASP.Net, SQL Server, R Script, Windows, Windows Phone, AWS, SAP HANA and ABAP, like SAP UI5, Screen Personas, etc.




Install SAP Free


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.
move 'XXXXXXXXXXXXXXXXX' TO ls_bapi_view."#EC CI_CONV_OK

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'.
endwhile.





SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table


Meetup Sunumu 1 meetup






Copyright © 2004 - 2019 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems