2020 May 19 4:33 PM
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
2020 May 19 5:02 PM
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
2020 May 19 5:02 PM
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
2020 May 19 5:07 PM
Hi again,
Here some more information about the ABAP debugger: https://help.sap.com/viewer/ba879a6e2ea04d9bb94c7ccd7cdac446/7.5.8/en-US/49250c884d7216b5e10000000a4...
2020 May 19 5:44 PM
Hi Mateusz,
Thank you for the input.
It looks crystal clear now.
Best regards,
Val
2020 May 20 8:10 AM
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 ..
2020 May 20 8:15 AM
2020 May 19 7:43 PM
Concerning your first question:
There must be some explanations in the ABAP documentation.