11-12-2007 12:02 PM
Hello all,
select * from mara
into corresponding fields of tabel itab_mara
for all entries in table itab
where matnr LIKE itab-matnr.
for my requirement, I want to use the above statement. because in ITAB, i have MATNR with only 10 digit.
But the problem is system does not allow this syntax.
Do you have an idea which will avoid any other SELECT s and get away with it.
Thanks.
11-12-2007 12:07 PM
Hi,
do like this..
IF NOT ITAB[] IS INITIAL.
select * from mara
into corresponding fields of table itab_mara
for all entries in itab
where matnr = itab-matnr.
ENDIF..
Reward if helpful.
Regards,
Nagaraj
11-12-2007 12:22 PM
Thanks for reply.
But if I do like you said, I will not get any data from MARA. Right ? because ITAB-MATNR is only 10 digit
11-12-2007 12:32 PM
Hi,
Then do like this before the select statement.
LOOP AT ITAB.
CALL FUNCTION "CONVERSION_EXIT_ALPHA_OUTPUT"
PASS THE MATERIAL NUMBER
ANDTHEN MODIFY THE ITAB.
ENDLOOP.
Reward if helpful.
Regards,
nagaraj
11-12-2007 12:07 PM
HI,
select * from mara
into corresponding fields of <b>table</b> itab_mara
for all entries in table itab
where matnr <b>=</b> itab-matnr.
rgds,
bharat.
11-12-2007 12:09 PM
Hi
Select Statements contd For All Entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Points to be must considered FOR ALL ENTRIES
Check that data is present in the driver table
Sorting the driver table
Removing duplicates from the driver table
Consider the following piece of extract
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
The above mentioned can be more optimized by using the following code.
Sort int_cntry by cntry.
Delete adjacent duplicates from int_cntry.
If NOT int_cntry[] is INITIAL.
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
Endif.
11-12-2007 12:10 PM
Hi Kumar,
try like this..take one extra variable like..
DATA : matnr LIKE mara-matnr.
CONCATENATE itab-matnr '%' INTO matnr.
then change your select statement.
select * from mara
into corresponding fields of tabel itab_mara
for all entries in table itab
where matnr LIKE matnr.
IT should work..I've tried...:)
Message was edited by:
Sudhakar G
11-12-2007 12:10 PM
Hi,
while defining structure of internal table put datatype of both the matrial numbers same. then use
if not itab[] is inital.
select * from mara
into corresponding fields of tabel itab_mara
for all entries in table itab
where matnr EQ itab-matnr.
endif.
Regards,
Prashant
11-12-2007 12:11 PM
Hi,
do like this
select * from mara
into tabel itab_mara
for all entries in table itab
where matnr = itab-matnr+0(10).
Reward if it helps,
Satish
11-12-2007 12:32 PM
Hi Surendra,
Try This Out
concatenate '%' itab-matnr '%' into variable.
select * from mara
into corresponding fields of tabel itab_mara
for all entries in table itab
where matnr LIKE variable.
Surely it will work
Kindly reward if useful
Rohit G
11-12-2007 12:40 PM
hi,
before writing for all enteries.
it's better check where the internal table is initial or not.
if not itab[] is initial.
select * from mara
into corresponding fields of table itab_mara
for all entries into table itab
where matnr = itab-matnr.
endif.
delete adjacent duplicates from itab[].
11-12-2007 1:30 PM
11-12-2007 3:03 PM
Thats only a temporary fix, once you get a few thousand entries in your range table you WILL get a shortdump.
11-12-2007 3:07 PM
Better solution is to add an extra column to your internal table say field MATNR2 that is 18 char long like MARA-MATNR. Then loop over your internal table copying MATNR to MATNR2 using conversion_exit_alpha_input. Once done you can use the FOR ALL ENTRIES command on the new column MATNR2.
11-12-2007 9:02 PM
Your idea wouldn't even work if the syntax allowed if, since LIKE would only work if the values were wild-carded.
What you need to do is LOOP AT itab_mara and run the conversion exit on MATNR to get it into the right format, and then do your select with an equal condition.
If you need to preserve the original data, make a copy of the table before running the conversion exit.
FIELD-SYMBOLS: <itab_mara> TYPE mara. "use same type as for itab_mara
IF itab_mara[] IS NOT INITIAL.
LOOP AT itab_mara ASSIGNING <itab_mara>.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <itab_mara-matnr>
IMPORTING
output = <itab_mara-matnr>.
ENDLOOP.
SELECT * FROM mara
INTO CORRESPONDING FIELDS OF TABLE itab_mara
FOR ALL ENTRIES IN table itab_mara
WHERE matnr = itab_mara-matnr.
ENDIF.
Good luck
Brian
fix spelling
Message was edited by:
Brian Sammond