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

Problem with Select Statement - Possibly too big?

Former Member
0 Likes
662

Hey fellow devs,

I've tried a myriad of select statements with little success on this one particular table.

It is a custom table based on MARA but with more fields called ZLSC_MARA.

Anyway, I keep getting the error: "The work table _____ is not long enough" when the definition is exactly the same as the structure i'm selecting into.

Here is what I have already tried.

DATA: I_ZLSCMARA TYPE TABLE OF ZLSC_MARA.

SELECT *

   INTO TABLE I_ZLSCMARA

   FROM ZLSC_MARA

   INNER JOIN MVKE ON MVKE~MATNR = ZLSC_MARA~MATNR

   WHERE LVORM NE 'X'.


Tried a few different ways of defining it:

DATA: I_ZLSCMARA LIKE ZLSC_MARA OCCURS 0.

DATA: I_ZLSCMARA LIKE ZLSC_MARA OCCURS 0 with header line.

Even this terribly inefficient way:

DATA: I_ZLSCMARA LIKE ZLSC_MARA OCCURS 0,

          WA_ZLSCMARA LIKE LINE OF I_ZLSCMARA.

SELECT *

   INTO WA_ZLSCMARA

   FROM ZLSC_MARA

   INNER JOIN MVKE ON MVKE~MATNR = ZLSC_MARA~MATNR

   WHERE LVORM NE 'X'.

   APPEND WA_ZLSCMARA TO I_ZLSCMARA.

ENDSELECT.


Am i missing something basic here?...  How the heck do I select everything out of this table into an internal table in my program?!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
626

Hi Brian,

Correct code is:

DATA: i_zlscmara TYPE TABLE OF ZLSC_MARA WITH HEADER LINE.

SELECT *
   INTO CORRESPONDING FIELDS OF TABLE i_zlscmara
   FROM
ZLSC_MARA

   INNER JOIN mvke ON mvke~matnr = ZLSC_MARA~matnr
   WHERE
ZLSC_MARA~lvorm NE 'X'.

3 REPLIES 3
Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
626

Hi Brian,

In the WHERE clause, did you try adding the table name before the field name? Like MVKE-LVORM?

Read only

Former Member
0 Likes
627

Hi Brian,

Correct code is:

DATA: i_zlscmara TYPE TABLE OF ZLSC_MARA WITH HEADER LINE.

SELECT *
   INTO CORRESPONDING FIELDS OF TABLE i_zlscmara
   FROM
ZLSC_MARA

   INNER JOIN mvke ON mvke~matnr = ZLSC_MARA~matnr
   WHERE
ZLSC_MARA~lvorm NE 'X'.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
626

You use a JOIN in the SELECT so when you select * all fields, Open-SQL expects a work area which is at least as wide as concatenation of both table structures.

  • If wou want some data from second table use a CORRESPONDING FIELDS and extend the target internal table structure
  • If you want no field  of second table, use a subquery, replace JOIN mvke ON with a AND EXISTS ( SELECT * FROM mvke WHERE matnr = zlsc_mara~matnr )

Regards,

Raymond