cancel
Showing results for 
Search instead for 
Did you mean: 

For all entries

Former Member
0 Kudos

Hi,

I belive I have some issue regarding "for all entries" ?

clear: i_mara,i_mara[].

  • i_mara now includes 0 row.

  • i_mvke now includes 1 row.

  • Get MARA

select *

from mara

into corresponding fields of table i_mara

for all entries in i_mvke

where matnr eq i_mvke-matnr.

i_mara now includes 10000 rows.

i_mvke now includes 1 row.

I'm confused.... a for all entries in should work as a INNER JOIN ...?

I want i_mara to include only 1 row after the select..

//Martin

Message was edited by: Martin Andersson

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The <b>where matnr eq i_mvke-matnr</b> condition will fetch all records that match the given criteria. It you want to fetch only one record:

1. Issue ...UPTO 1 ROWS, or

2. Specify the WHERE clause upto complete key fields to uniquely identify a single row, or

3. Issue SELECT SINGLE...

Hope this helps.

Regards

Former Member
0 Kudos

Hi,

Well.. the i_mvke tabel only have 1 row. One MATNR.

When I do the select to mara I get all kinds of MATNR in i_mara.

How is this possible ?

//Martin

Former Member
0 Kudos

Hi,

As per the SAP documentation on help.sap.com,

<b>In case of SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond>, if you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.

</b>

Only specifying matnr in your where clause might not be able to uniquely identify a particular record. So although you have a single entry in your itab, more than one entries correspond to it in the DB tab. See if you can further specify the complete primary key.

Take a look at http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/frameset.htm for further details on FOR ALL ENTRIES.

Hope this helps.

Regards

Message was edited by: Shehryar Khan

Answers (2)

Answers (2)

andreas_mann3
Active Contributor
0 Kudos

Hi Martin,

Have you really <b>1</b> entry in table i_mvke ?

if there's no entry in i_mvke you'll get all entries

of mara in i_mara.

regards Andreas

christian_wohlfahrt
Active Contributor
0 Kudos

Hello Martin,

you specify complete key of MARA, so this should work perfectly (just select into table, corresponding fields is slower).

Maybe your matnr in i_mvke hasn't correct format? Be sure, to use exact database format:

Most customers use rules, which are implemented in function module

CONVERSION_EXIT_ALPHA_INPUT

.

Regards,

Christian

Former Member
0 Kudos

Hello,

There is only 1 record in i_mvke. In the debugger I can see that it has the right format (I had some problem before...with this...)

The matnr is was transformed from 000000000000150062 to 150062, which gave me trouble in a previos FM.

Maybe the problem is that MVKE table has more than MATNR as a key...it has WERKS and VTWEG I belive..

//Martin

Former Member
0 Kudos

Hi,

I belive I found the problem.

i_mvke is empty!

But there is a record in the HEADER LINE (work area).

It seems that this is not a real record then....

Sorry...

Thanks for your help!

//Martin