Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Size of fields in internal table

0 Kudos
874

Hello,

I have a couple of basic question about declaring internal tables and inserting/appending data.

Let's say I work with standard content and have a variable of type 0FISCPER. I declare two tables , each single column, one standard and one sorted:

TYPES: BEGIN OF z_s_fiscper,
        FISCPER TYPE /BI0/OIFISCPER,
       END OF z_s_fiscper.

DATA: l_t_fiscper TYPE TABLE OF /BI0/OIFISCPER,
      l_t_tfiscper TYPE SORTED TABLE OF z_s_fiscper WITH UNIQUE KEY FISCPER,
      l_v_fiscper TYPE /BI0/OIFISCPER.

l_v_fiscper = '2020001'.

APPEND l_v_fiscper TO l_t_fiscper.
"INSERT l_v_fiscper INTO TABLE l_t_tfiscper.

First thing that surprises me a bit is that the size of a field in standard table is twice as long as for undelying data type:

The single table column is (seemingly) 14 digits long ([1x1(14)], while its content (fiscal period) is only 7 digits long. Cannot understand te meaning of it.

Another trouble is that nonetheless appending a line to a standard table works fine, but trying to insert a line into a sorted table of the same size and structure results in compile time error L_V_FISCPER and the row type of "L_T_FISCPER" are incompatible.

Which is strange, as the structure of the sorted table looks pretty much the same:

I am sure the answers are simple and are already included someplace in the Product Assistance, but I currently fail to figure out.

Thank you,

Val

1 ACCEPTED SOLUTION

MateuszAdamus
Active Contributor
737

Hi val.teem

The field in the table is 7 digits long.

But the field is 14 bytes long. Because you have only that one field in table's row, the whole row is 14 bytes long.

As to the second issue.

Your standard table has no structure assigned (is a table of a data element records).

Where the sorted table has a structure (is a sorted table of a structured records).

That's why you can add your L_V_FISCPER variable to the standard table, but not the the sorted.

To add a record to the sorted you need to create a variable of structure type Z_S_FISCPER and add that variable (with INSERT INTO TABLE statement, because the table is sorted).

Regards,

Mateusz

6 REPLIES 6

MateuszAdamus
Active Contributor
738

Hi val.teem

The field in the table is 7 digits long.

But the field is 14 bytes long. Because you have only that one field in table's row, the whole row is 14 bytes long.

As to the second issue.

Your standard table has no structure assigned (is a table of a data element records).

Where the sorted table has a structure (is a sorted table of a structured records).

That's why you can add your L_V_FISCPER variable to the standard table, but not the the sorted.

To add a record to the sorted you need to create a variable of structure type Z_S_FISCPER and add that variable (with INSERT INTO TABLE statement, because the table is sorted).

Regards,

Mateusz

0 Kudos
737

Hi again,

Here some more information about the ABAP debugger: https://help.sap.com/viewer/ba879a6e2ea04d9bb94c7ccd7cdac446/7.5.8/en-US/49250c884d7216b5e10000000a4...


Regards,
Mateusz

737

Hi Mateusz,

Thank you for the input.

It looks crystal clear now.

Best regards,

Val

0 Kudos
737
TYPES: BEGIN OF z_s_fiscper,
        FISCPER TYPE /BI0/OIFISCPER,
       END OF z_s_fiscper.

DATA: l_t_fiscper TYPE TABLE OF /BI0/OIFISCPER,
      l_t_tfiscper TYPE SORTED TABLE OF z_s_fiscper WITH UNIQUE KEY FISCPER,
      l_v_fiscper TYPE /BI0/OIFISCPER,
      l_v_sfiscper TYPE z_s_fiscper.

FIELD-SYMBOLS: <fs_s_fiscper> TYPE ANY,
               <fs_v_fiscper> TYPE ANY.

ASSIGN l_v_sfiscper TO <fs_s_fiscper>.

ASSIGN COMPONENT 'FISCPER' OF STRUCTURE <fs_s_fiscper> TO <fs_v_fiscper>.

l_v_fiscper = '2020001'.
<fs_v_fiscper> = l_v_fiscper.

APPEND l_v_fiscper TO l_t_fiscper.
INSERT l_v_sfiscper INTO TABLE l_t_tfiscper.

... works like charm ..

0 Kudos
737

Well done!

Mateusz

Sandra_Rossi
Active Contributor
737

Concerning your first question:

  • 7 characters = 14 bytes because your ABAP system is Unicode, i.e. 2 bytes per character.
  • Since ABAP 7.50, all ABAP systems are Unicode.
  • Non-Unicode ABAP systems had 1 byte per character.

There must be some explanations in the ABAP documentation.