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

Insert specific values into internal table problem

Former Member
0 Likes
691

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

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
655

delete the field list that you inserted after "INTO TABLE it_mat" and before "WHERE".

Cheers

Thomas

4 REPLIES 4
Read only

ThomasZloch
Active Contributor
0 Likes
656

delete the field list that you inserted after "INTO TABLE it_mat" and before "WHERE".

Cheers

Thomas

Read only

0 Likes
655

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

Read only

0 Likes
655

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 ...

Read only

0 Likes
655

Sounds great Thomas - thank you very much.

Have a nice weekend

Kind regards,

Torben