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: 

Failed in query

Former Member
0 Kudos
164

Good morning friends, I'm programming with objects the following query, I have as input values ​​the type of material and the center, but I get an error, this is the code:

MODULE user_command_0500 INPUT.

CASE ok_code.

      WHEN 'EXECUTE'.

           SELECT mapl~werks mapl~plnty mapl~plnnr mapl~plnal mapl~datuv mapl~matnr

                          plko~ktext mara~mtart

           FROM mapl INNER JOIN plko ON mapl~werks = plko~werks

                                                        AND mapl~plnty = plko~plnty

                                                        AND mapl~plnnr = plko~plnnr

                                                        AND mapl~plnal = plko~plnal

                             INNER JOIN mara ON mapl~matnr = mara~matnr

           INTO TABLE t_mapl

           WHERE mtart eq mara-mtart

           AND werks eq mapl-werks. "HERE THE FAILED"

          IF sy-subrc <> 0.

           ENDIF.

           CALL METHOD r_grid->refresh_table_display.

      WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.

           LEAVE TO SCREEN 0.

      WHEN OTHERS.

ENDCASE.

ENDMODULE.

The following message appears:
The column name "WERKS" is unclear .


The data type MARA can be enhanced in any way. After a structure enhancement, this assignment or parameter might be syntactically incorrect.


Please I hope you can help me. Thank you very much.


Best regards

1 ACCEPTED SOLUTION

former_member195402
Active Contributor
0 Kudos
109

Hi,

please replace line

AND werks eq mapl-werks.

with

AND mapl~werks eq mapl-werks.

for PLKO~WERKS is defined through JOIN and MTART is unique in the JOIN tables.

Regards,

Klaus

8 REPLIES 8

Former Member
0 Kudos
109

You need to specify from which table the werks is taken from

e.g: map1~werks (or map1-werks, check both)

0 Kudos
109

You have to specify the tables in the where condition:

                    WHERE mara~mtart eq mara-mtart 

           AND mapl~werks eq mapl-werks.

This make sense only in case you have workareas mara and mapl filled with the values in your program before.

Otherwise remove the where condition.

/Michael

Former Member
0 Kudos
109

Hi Brujo ,

From the code you have provided what my assumption is that there is some problem in the WHERE clause of the query .

Have you declared any workarea for mara and mapl tables , if yes , is there any data that you passing into the fields you are referring in the WHERE clause .

if there is no data in the fields used in the WHERE clause the query wil not work .

Regards,

Parth Sharma

former_member195402
Active Contributor
0 Kudos
110

Hi,

please replace line

AND werks eq mapl-werks.

with

AND mapl~werks eq mapl-werks.

for PLKO~WERKS is defined through JOIN and MTART is unique in the JOIN tables.

Regards,

Klaus

Former Member
0 Kudos
109

Hi Brujo ,

The column name "WERKS" is unclear . " says that for which WERKS you are equating for ?.

You have declared WERSK in MAPL & PLKO . So make clear for which WERKS you are equating.


For Example ::  AND plko~werks = mapl-werks.

Thanks,

S.Rajendranath Raparthi.

Former Member
0 Kudos
109

Hi,

You are trying to map map1 werks to itself in where condition.

Also there is no werks field in mara table, i think that condition is not required.

Please check and let me know.

Best Regards,

Abirami

raymond_giuseppi
Active Contributor
0 Kudos
109

Always use the syntax filename/id~fieldname, even if you are allowed to use a fieldname if it appears in only one of the joined table, a field may be appended to another table of the JOIN in a future version or in a customer append and the syntax would become invalid.

Regards,

Raymond

Former Member
0 Kudos
109

Thank you very much to all for your responses, all are correct.

Have a great day.