Learning ABAP (2) through examples -- assigning values to the inner table

Source: Internet
Author: User
This is an interesting example to show the differences between an internal table with a table header and an internal table without a table header assignment.

In this example, we first define a structured field line, which contains the col1 and col2 fields. Pass

Append Line ToEtab. After the value is assigned to etab, the result of DEBUG is:

In this case, you can use the move etab [] to ftab1. statement to assign the value to itab1. The result of the ftab1 table is as follows:

You can clearly see that etab and ftab1 tables with and without headers have different results, so the assignment and output methods are also different. For a table without a table header, You need to define Another workspace object with the same structure as the table in the tableProgramWhen writing data to an inner table, you must first assign a value to the workspace, and then add or insert an inner table in the workspace. When taking values from an inner table, you need to overwrite the content of the workspace with the content of the defined inner table row, and then use the content of the workspace from the program.

 

*&---------------------------------------------------------------------*
* & Report ztest_sd1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

ReportZtest_sd1.
* Move

data : begin of line ,
col1 ( 1 ) type C ,
col2 ( 1 ) type C ,
end of line .

Data: EtabLike Table Of Line With Header Line,
Ftab1Like Table Of Line.

Line-Col1 ='A'.Line-Col2 ='B'.

Append Line ToEtab.
Loop AtEtab.
Write:/ETAB-COL1, ETAB-COL2.
Endloop.

MoveEtab []ToFtab1.
DataWaLike Line OfFtab1.

Loop AtFtab1IntoWa.
Write:/WA-COL1, WA-COL2.
Endloop.

Loop AtFtab1Into Line.
Write:/Line-Col1,Line-Col2.
Endloop.

Skip.
Uline.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.