07-02-2007 1:11 PM
Hi friends,
can you plz explain this..
TYPES:BEGIN OF ITAB1,
MATNR TYPE MATNR,
ERNAM TYPE ERNAM,
END OF ITAB1,
ITAB2 TYPE STANDARD TABLE OF ITAB1 WITH NON-UNIQUE DEFAULT KEY.
DATA:WA_SELECT TYPE ITAB2 .
DATA:WA_READ TYPE ITAB1.
SELECT MATNR ERNAM FROM MARA INTO TABLE WA_SELECT..
plz let me know this logic... is this is correct or.. any misteque is there..
thanks
babu
07-02-2007 1:16 PM
just check the change in select in bold
SELECT MATNR ERNAM FROM MARA INTO TABLE <b>ITAB2..</b>
WA_SELECT is just a workarea , It holds only one record , instead use ITAB2
07-02-2007 1:16 PM
just check the change in select in bold
SELECT MATNR ERNAM FROM MARA INTO TABLE <b>ITAB2..</b>
WA_SELECT is just a workarea , It holds only one record , instead use ITAB2
07-02-2007 1:21 PM
Hi Chandra,
I already tryd with. this but.. that time i'm getting following error...
Error------"Field ITAB2 is unknown.. it is neither in one of the specified tables nor defined by DATA statement.."
plz any one explain... and let me know...
thanks
baby
07-02-2007 1:27 PM
Hi
No! See the code:
TYPES: BEGIN OF ITAB1,
MATNR TYPE MATNR,
ERNAM TYPE ERNAM,
END OF ITAB1,
ITAB2 TYPE STANDARD TABLE OF ITAB1 WITH NON-UNIQUE DEFAULT KEY.
DATA:WA_SELECT TYPE ITAB2 .
ITAB2 is a type table, so WA_SELECT is a table too, not a work area. Just as I said in my previuos answer here I think it's useless ITAB2, you can use WA_SELECT only:
TYPES: BEGIN OF ITAB1,
MATNR TYPE MATNR,
ERNAM TYPE ERNAM,
END OF ITAB1.
DATA: WA_SELECT TYPE STANDARD TABLE OF ITAB1 WITH NON-UNIQUE DEFAULT KEY .
Max
07-02-2007 1:28 PM
Hi
The line SELECT MATNR ERNAM FROM MARA INTO TABLE WA_SELECT is right.
Max
07-02-2007 1:21 PM
Hi
The MARA table has only one key (excepted the client): MATNR, so it should be better:
TYPES: BEGIN OF ITAB1,
MATNR TYPE MATNR,
ERNAM TYPE ERNAM,
END OF ITAB1,
ITAB2 TYPE STANDARD TABLE OF ITAB1 WITH UNIQUE KEY MATNR.
DATA: WA_SELECT TYPE ITAB2 .
DATA: WA_READ TYPE ITAB1.
SELECT MATNR ERNAM FROM MARA INTO TABLE WA_SELECT.
If you need to read the data using user name, u can insert ERNAM in the UNIQUE KEY too:
TYPES: BEGIN OF ITAB1,
MATNR TYPE MATNR,
ERNAM TYPE ERNAM,
END OF ITAB1,
ITAB2 TYPE STANDARD TABLE OF ITAB1 WITH UNIQUE KEY MATNR ERNAM.
DATA: WA_SELECT TYPE ITAB2 .
DATA: WA_READ TYPE ITAB1.
SELECT MATNR ERNAM FROM MARA INTO TABLE WA_SELECT.
I believe it's useless to define the type table ITAB2 in this situation, u need the type ITAB1 only:
TYPES: BEGIN OF ITAB1,
MATNR TYPE MATNR,
ERNAM TYPE ERNAM,
END OF ITAB1.
DATA: WA_SELECT TYPE STANDARD TABLE OF ITAB1 WITH UNIQUE KEY MATNR ERNAM.
.
DATA: WA_READ TYPE ITAB1.
SELECT MATNR ERNAM FROM MARA INTO TABLE WA_SELECT.
Max
07-02-2007 1:26 PM
hi Babu,
just change ur code like this
REPORT ychatest2.
TYPES:BEGIN OF itab1,
matnr TYPE matnr,
ernam TYPE ernam,
END OF itab1.
data : itab2 TYPE STANDARD TABLE OF itab1 WITH NON-UNIQUE DEFAULT KEY.
DATA:wa_select TYPE itab1 .
DATA:wa_read TYPE itab1.
SELECT matnr ernam FROM mara INTO TABLE itab2.
07-02-2007 1:36 PM
Hi.
You are selecting single fields into an internal table.
WA_SELECT is defined as table so thats right.
The logic is OK but you should change the naming. WA_ (work area) should be used as prefix for a variable representing a line of the internal table. Maybe you can use the prefix LT_ (local table) for internal tables.
TYPES:BEGIN OF ITAB1,
MATNR TYPE MATNR,
ERNAM TYPE ERNAM,
END OF ITAB1,
ITAB2 TYPE STANDARD TABLE OF ITAB1 WITH NON-UNIQUE DEFAULT KEY.
DATA:WA_READ TYPE ITAB1.
<b>DATA:LT_SELECT TYPE ITAB2 .</b>
SELECT MATNR ERNAM FROM MARA INTO TABLE LT_SELECT.
After executing this piece of code the internal table LT_SELECT holds the fields MATNR and ERNAM for all entries from the database table MARA.
Regards,
Timo.
07-02-2007 2:48 PM
hi
first u r creating one structure called itab1.
TYPES:BEGIN OF ITAB1,
MATNR TYPE MATNR,
ERNAM TYPE ERNAM,
END OF ITAB1,
then u r creating an internal table itab2 like the structure itab1 with non-unique key.
ITAB2 TYPE STANDARD TABLE OF ITAB1 WITH NON-UNIQUE DEFAULT KEY.
u r creating one one more internal table like itab2.
DATA:WA_SELECT TYPE ITAB2 .
u r creating one more structure like itab1.
DATA:WA_READ TYPE ITAB1.
u r fetching matnr ernam fields from mara and putting into internal table-wa_select.
SELECT MATNR ERNAM FROM MARA INTO TABLE WA_SELECT..
reward if useful.
07-02-2007 2:54 PM
Hi
Itab1 and wa_select are not internal table. itab1 is a structure. And wa_select is a work area for internal table itab2.
So itab2 is an internal table.
modify select statement by
SELECT MATNR ERNAM FROM MARA INTO TABLE ITAB2 where matnr = p_matnr.
Also its not necessary to declare WITH NON-UNIQUE DEFAULT KEY.
Reward me if its helpful
Regards
Ravi