Field symbol and data reference concept in ABAP

后端 未结 4 1982
野性不改
野性不改 2021-02-06 02:03

If we compare ABAP field symbols and data references with the pointer in C, we observe :-

In C, say we declare a variable \"var\" type \"integer\" with default value \"5

4条回答
  •  鱼传尺愫
    2021-02-06 03:02

    A field symbol, which has been around in ABAP much longer, allows you to manipulate and pass values of fields at runtime, without knowing the name of the field beforehand. Consider this use case: You have a structure with 20 fields, you can reference each field by name and assign it to a field symbol, and then change the value of a particular field etc.

    A data reference (TYPE REF TO DATA), which is a relatively newer addition to ABAP, allows you to instantiate data at runtime without knowing the type beforehand using the 'CREATE DATA' statement.

    For an example of the use of CREATE DATA, see the following SAP Help page. It shows you how you can for example get a reference to a reference object (i.e. ABAP Objects reference) using CREATE DATA, which is something you could not do with a field symbol: http://help.sap.com/abapdocu_70/en/ABAPCREATE_DATA_REFERENCE.htm

提交回复
热议问题