‎2008 Jan 18 9:28 AM
Hi Guys
In order to avoid reading all material master data attributes I would like to read only the ones that I need into an internal table. But I cannot make it work.
Error: E:Unable to interpret "(MATERIAL, ZTYPEVAR, ZPRODAREA, ZPRDGRP, ZPRDSUBGR, ZVCIVAR, RDBTYPE, ZAPOMAT, Z_SC_DSP, Z_SC_E, Z_SC_F, Z_SC_I, Z_SC_S)". Possible causes of error: Incorrect spelling or comma
Hope you can assist me.
TYPES:
BEGIN OF mat_doc,
material LIKE /BIC/AZAPOBOM200-material,
ztypevar LIKE /BIC/AZAPOBOM200-/BIC/ZTYPEVAR,
zprodarea LIKE /BIC/AZAPOBOM200-/BIC/ZPRODAREA,
zprdgrp LIKE /BIC/AZAPOBOM200-/BIC/ZPRDGRP,
zprdsubgr LIKE /BIC/AZAPOBOM200-/BIC/ZPRDSUBGR,
zvcivar LIKE /BIC/AZAPOBOM200-/BIC/ZVCIVAR,
rdbtype LIKE /BIC/AZAPOBOM200-/BIC/RDBTYPE,
zapomat LIKE /BIC/AZAPOBOM200-/BIC/ZAPOMAT,
z_sc_dsp LIKE /BIC/AZAPOBOM200-/BIC/Z_SC_DSP,
z_sc_e LIKE /BIC/AZAPOBOM200-/BIC/Z_SC_E,
z_sc_f LIKE /BIC/AZAPOBOM200-/BIC/Z_SC_F,
z_sc_i LIKE /BIC/AZAPOBOM200-/BIC/Z_SC_I,
z_sc_s LIKE /BIC/AZAPOBOM200-/BIC/Z_SC_S,
END OF mat_doc.
DATA: it_mat TYPE SORTED TABLE OF mat_doc
WITH UNIQUE KEY material
WITH HEADER LINE.
TABLES: /bi0/pmaterial.
....
....
SELECT material /BIC/ZTYPEVAR /BIC/ZPRODAREA /BIC/ZPRDGRP /BIC/ZPRDSUBGR
/BIC/ZVCIVAR /BIC/RDBTYPE /BIC/ZAPOMAT /BIC/Z_SC_DSP /BIC/Z_SC_E
/BIC/Z_SC_F /BIC/Z_SC_I /BIC/Z_SC_S
FROM /bi0/pmaterial INTO TABLE it_mat (material, ztypevar,
zprodarea, zprdgrp, zprdsubgr, zvcivar, rdbtype, zapomat, z_sc_dsp,
z_sc_e, z_sc_f, z_sc_i, z_sc_s)
WHERE objvers = 'A'.
SORT tempmat BY material.
Thanks in advance, kind regards
Torben
‎2008 Jan 18 9:34 AM
delete the field list that you inserted after "INTO TABLE it_mat" and before "WHERE".
Cheers
Thomas
‎2008 Jan 18 9:34 AM
delete the field list that you inserted after "INTO TABLE it_mat" and before "WHERE".
Cheers
Thomas
‎2008 Jan 18 9:39 AM
Hi Thomas
Thanks for your reply.
But how will the system know what fields to insert into, when the fieldnames in the select statement is not the same as the field names in mat_doc?
Kind regards,
Torben
‎2008 Jan 18 9:42 AM
Hi Torben,
as long as the sequence of fields in your internal table is the same as in your select statement, the system will just move them in that order into the final table. You don't need to match by field name.
If the order is not the same, but the field names do match, one can use the addition SELECT ... INTO CORRESPONDING FIELDS OF TABLE ...
Cheers
Thomas
P.S. if even the field names are different, you could select like this:
SELECT field1 AS fieldA field2 AS fieldB ... INTO TABLE ...
‎2008 Jan 18 9:50 AM
Sounds great Thomas - thank you very much.
Have a nice weekend
Kind regards,
Torben