关于SAP内置类型SIMPLE及JSON变量适配类型的技术咨询
Let me break this down clearly based on ABAP's type system and your specific use case:
What is the SIMPLE type in ABAP?
In ABAP's type classification, SIMPLE refers to a category of elementary (single-value) data types that can't be broken down into smaller components. This stands in contrast to structured types (like structures or internal tables) which are made up of multiple elements.
Specifically, SIMPLE covers all standard elementary types you're likely to work with, including:
- Character types:
C,STRING,N(numeric text),D(date),T(time) - Numeric types:
I,F,P(packed) - Binary types:
X,XSTRING
When a method parameter is typed as SIMPLE, it means the method accepts any of these elementary types—no structured or complex types are allowed.
What data type should you use for your JSON variable?
For your scenario with cl_abap_conv_in_ce=>convert( ) and lo_json_writer->get_output( ), the best choice is STRING—here's why:
lo_json_writer->get_output( )returns a UTF-8 encoded JSON string by default, so aSTRINGvariable perfectly matches the input data format.STRINGis a validSIMPLEtype, so it fully complies with the method's parameter requirements.- Using
STRINGmakes subsequent JSON processing (like parsing withcl_abap_json_parseror sending the JSON over HTTP) straightforward, as most ABAP JSON utilities work natively with string inputs.
If you ever need to handle binary-encoded JSON (a rare edge case for standard use), you could use XSTRING instead—but STRING is the standard and most practical choice here.
Example code with the correct type declaration:
DATA(json) TYPE string. cl_abap_conv_in_ce=>create( )->convert( EXPORTING input = lo_json_writer->get_output( ) IMPORTING data = json ).
内容的提问来源于stack exchange,提问作者guettli

