Application Development and Automation 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: 
Read only

read table

Former Member
0 Likes
843

Hi,

could u pls help me to know the functionality of the following lines?

DEFINE list_poitm_amnt>.

read table &1 with key &2.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
756

hi

good

DEFINE->

If you want to reuse the same set of statements more than once in a program, you can include them in a macro. For example, this can be useful for long calculations or complex WRITE statements. You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.

The following statement block defines a macro macro:

DEFINE makro.

statements

END-OF-DEFINITION.

You must specify complete statements between DEFINE and END‑OF‑DEFINITION. These statements can contain up to nine placeholders &1, &2,...., &9). You must define the macro before the point in the program at which you want to use it.

READ TABLE->

To read a single line of any table, use the statement:

READ TABLE <itab> <key> <result>.

For the statement to be valid for any kind of table, you must specify the entry using the key and not the index. You specify the key in the <key> part of the statement. The <result> part can specify a further processing option for the line that is retrieved.

If the system finds an entry, it sets SY-SUBRC to zero, if not, it takes the value 4, as long as it is not influenced by one of the possible additions. If the internal table is an index table, SY-TABIX is set to the index of the line retrieved. If the table has a non-unique key and there are duplicate entries, the first entry is read.

THANKS

MRUTYUN^

5 REPLIES 5
Read only

former_member673464
Active Contributor
0 Likes
756

hi,

This is definition of a macro.If you want to reuse the same set of statements more than once in a program, you can include them in a macro. For example, this can be useful for long calculations or complex WRITE statements. You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.

The following statement block defines a macro <macro>:

DEFINE <macro>.

<statements>

END-OF-DEFINITION.

You must specify complete statements between DEFINE and END-OF-DEFINITION. These statements can contain up to nine placeholders (&1, &2, ..., &9). You must define the macro before the point in the program at which you want to use it.

To use a macro, use the following form:

<macro> [<p1> <p2> ... <p9>].

When the program is generated, the system replaces <macro> by the defined statements and each placeholder &i by the parameter <p i >. You can use macros within macros.

null

Read only

Former Member
0 Likes
756

see this

READ TABLE itab

Syntax

READ TABLE itab { table_key

| free_key

| index } result.

Effect

This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read.

If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.

System Fields

The statement READ TABLE sets system fields sy-subrc and sy-tabix.

sy-subrc Relevance

0 Row found. sy-tabix is set to the table index of the entry for index tables, and to the value 0 for hashed-tables.

2 Like sy-subrc equals 0. Differentiates cases that use the addition COMPARING in result.

4 Row not found. For sorted tables and when the BINARY SEARCH in free_key addition is used, sy-tabix is set to the table index of the entry before it was inserted with INSERT. Otherwise, sy-tabix is not defined.

8 Like sy-subrc equals 4. For sorted tables, however, and when the addition BINARY SEARCH is used, the end of the table was reached, and sy-tabix is set to the number of rows + 1.

The system fields sy-tfill and sy-tleng are also supplied with data.

Note

Besides the alternatives shown above for specifying the row to be read, there is another obsolete key specification obsolete_key possible.

Message was edited by:

sunil kumar

Read only

Former Member
0 Likes
756

Hi...

that is a macro where &1 refers a table name and &2 refers a key in that intenal table..

see...the calling stmt. may be...

list_poitm_amnt itab f1.

Read only

Former Member
0 Likes
756

Hi Raja,

Look at the below SAP Link, you will understand about the Macros, These &1 ... are Place holders of macros, you can define upto 9 , and these will have the values, when you write the Read statment, then it will read from the valuw which &1 will have at that time

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm

Regards

Sudheer

Read only

Former Member
0 Likes
757

hi

good

DEFINE->

If you want to reuse the same set of statements more than once in a program, you can include them in a macro. For example, this can be useful for long calculations or complex WRITE statements. You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.

The following statement block defines a macro macro:

DEFINE makro.

statements

END-OF-DEFINITION.

You must specify complete statements between DEFINE and END&#8209;OF&#8209;DEFINITION. These statements can contain up to nine placeholders &1, &2,...., &9). You must define the macro before the point in the program at which you want to use it.

READ TABLE->

To read a single line of any table, use the statement:

READ TABLE <itab> <key> <result>.

For the statement to be valid for any kind of table, you must specify the entry using the key and not the index. You specify the key in the <key> part of the statement. The <result> part can specify a further processing option for the line that is retrieved.

If the system finds an entry, it sets SY-SUBRC to zero, if not, it takes the value 4, as long as it is not influenced by one of the possible additions. If the internal table is an index table, SY-TABIX is set to the index of the line retrieved. If the table has a non-unique key and there are duplicate entries, the first entry is read.

THANKS

MRUTYUN^