Application Development 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: 

Excluding all the Archived Purchasing document

former_member612750
Participant

I am getting all the Purchasing document that is archived and I'm getting an error that "The work area "I_TAB" has fewer fields than selected." Can you tell me what is wrong with my code below?

TYPES: BEGIN OF t_tab,
ebeln LIKE ekpo-ebeln,
loekz LIKE ekko-loekz,
matnr LIKE ekpo-matnr,
werks LIKE ekpo-werks,
ewebaz LIKE ekpo-webaz,
eplifz LIKE ekpo-plifz,
END OF t_tab

DATA: i_tab TYPE STANDARD TABLE OF t_tab,
wa_tab TYPE t_tab.

SELECT
a~ebeln,
a~matnr,
a~werks,
a~webaz,
a~plifz,
b~ebeln,
b~loekz
INTO TABLE @i_tab
FROM ekpo AS a
LEFT OUTER JOIN
ekko AS b
ON a~ebeln EQ b~ebeln
WHERE
b~loekz NE 'X'.

1 ACCEPTED SOLUTION

ahmed_esmat1
Explorer

You are selecting 7 fields while the work area have 6 fields , you selected ebeln twice & you should make a corresponding field to the selected fields in order to recognize it so this should look like :

TYPES: BEGIN OF t_tab,
ebeln LIKE ekpo-ebeln,
loekz LIKE ekko-loekz,
matnr LIKE ekpo-matnr,
werks LIKE ekpo-werks,
webaz LIKE ekpo-webaz,
plifz LIKE ekpo-plifz,
END OF t_tab.

DATA: i_tab TYPE STANDARD TABLE OF t_tab,
wa_tab TYPE t_tab.

SELECT
a~ebeln,
a~matnr,
a~werks,
a~webaz,
a~plifz,
b~loekz
INTO CORRESPONDING FIELDS OF TABLE @i_tab
FROM ekpo AS a
LEFT OUTER JOIN
ekko AS b
ON a~ebeln EQ b~ebeln
WHERE
b~loekz NE 'X'. 
4 REPLIES 4

ahmed_esmat1
Explorer

You are selecting 7 fields while the work area have 6 fields , you selected ebeln twice & you should make a corresponding field to the selected fields in order to recognize it so this should look like :

TYPES: BEGIN OF t_tab,
ebeln LIKE ekpo-ebeln,
loekz LIKE ekko-loekz,
matnr LIKE ekpo-matnr,
werks LIKE ekpo-werks,
webaz LIKE ekpo-webaz,
plifz LIKE ekpo-plifz,
END OF t_tab.

DATA: i_tab TYPE STANDARD TABLE OF t_tab,
wa_tab TYPE t_tab.

SELECT
a~ebeln,
a~matnr,
a~werks,
a~webaz,
a~plifz,
b~loekz
INTO CORRESPONDING FIELDS OF TABLE @i_tab
FROM ekpo AS a
LEFT OUTER JOIN
ekko AS b
ON a~ebeln EQ b~ebeln
WHERE
b~loekz NE 'X'. 

0 Kudos

Thank you!

Sandra_Rossi
Active Contributor
0 Kudos

Please use the CODE button to format your code so that it's shown in a more user-friendly format (colorized).

Sandra_Rossi
Active Contributor
0 Kudos

The 6 fields of i_tab:

TYPES: BEGIN OF t_tab,
ebeln LIKE ekpo-ebeln,
loekz LIKE ekko-loekz,
matnr LIKE ekpo-matnr,
werks LIKE ekpo-werks,
ewebaz LIKE ekpo-webaz,
eplifz LIKE ekpo-plifz,
END OF t_tab

The 7 fields that you take to put into i_tab:

SELECT
a~ebeln,
a~matnr,
a~werks,
a~webaz,
a~plifz,
b~ebeln,
b~loekz
INTO TABLE @i_tab

The message:

The work area "I_TAB" has fewer fields than selected.

What do you not understand?

Moreover, pay attention to the order of fields (MATNR will go into LOEKZ, WERKS will go into MATNR, etc.)