-2

I created a structure in SE11 with the following columns:

column name      type (data element)
-----------      -------------------
mandt            mandt
itemdesc         arktx
quantity         lfimg
tweight          gsgew

I created a table type ZPACK_DETAIL in SE11 whose line type is the structure above.

Then I used the code below to declare an internal table and fill it with data from the database table:

DATA : dresult TYPE zpack_detail .

SELECT arktx lfimg ntgew 
    FROM lips AS detail LEFT JOIN marm AS material
    ON detail~matnr = material~matnr
    LEFT OUTER JOIN vbak
    ON detail~vgbel = vbak~vbeln
    INTO TABLE dresult
WHERE detail~vbeln = '001'.

The activation reports this warning message:

The data type of the component ITEMDESC of DRESULT is not compatible with the data type of LFIMG.

Can someone give me a hint what's wrong? Is there something wrong with the way I'm declaring the internal table?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
kk luo
  • 549
  • 1
  • 9
  • 22
  • I edited your question to make it coherent: if you get this message, it means that `zpack_detail` is a Table Type (if it was a structure, you'd get another message: `dresult is not an internal table`). Moreover, in ABAP 7.52, it's a warning, not an error. Either I'm correct or you really have an error because maybe in systems before 7.52 it was still an error. Please clarify these 2 points :) – Sandra Rossi Aug 05 '19 at 08:28
  • zpack_detail is a transparent table, not a structure. and for ABAP version I don't know how to check it. But the ABAP platform version is 1809 and SAP_UI version is 753. – kk luo Aug 05 '19 at 08:57
  • It's the same issue with a transparent table, `DATA dresult TYPE zpack_detail` would declare a **structure**, not an internal table (this is just how ABAP works), and so you'd still get the error `dresult is not an internal table`. 1809 is recent so it must be something like 7.52. Did you try the code you show here in a dedicated program to make sure the error is the one you indicate? – Sandra Rossi Aug 05 '19 at 09:12
  • [Here](https://stackoverflow.com/questions/37709936/abap-syntax-for-creating-internal-table-from-existing-database-table/37710407) is a somehow related question. – Jagger Aug 05 '19 at 09:28
  • I updated the code like below to using dresult as importing parameter for smartforms and error occurred when try to process it. `DATA : dresult TYPE STANDARD TABLE OF zpack_detail WITH EMPTY KEY , call function fm_name exporting zdetail = dresult` The error code is `only fields of a paticular type can be sepcified under "ZDETAIL".FIeld "DRESULT" specified here has a different filed type however.` – kk luo Aug 06 '19 at 06:20

1 Answers1

2

In fact there are couple of issues with your code.

You have to declare your variable as an internal table. ZPACK_DETAIL is a structure table and not a table type.

DATA: dresult TYPE STANDARD TABLE OF zpack_detail WITH EMPTY KEY.

Second of all. You should not use MANDT field as your query is not client indepentent. Remove this field from your structure or use INTO CORRESPONDING FIELDS OF TABLE and adjust your projection to SELECT arktx AS itemdesc lfimg AS quantity ntgew AS tweight.

Jagger
  • 10,350
  • 9
  • 51
  • 93
  • 1
    There's a problem in the question, I asked the OP to clarify (either `zpack_detail` is a structure and the error message is different, or `zpack_detail` is a table type or the actual code is `DATA dresult TYPE TABLE OF zpack_detail` and the message is the one shown). – Sandra Rossi Aug 05 '19 at 08:31
  • Thx.I updated the code like `DATA : dresult TYPE STANDARD TABLE OF zpack_detail WITH EMPTY KEY . SELECT arktx lfimg ntgew from lips as detail LEFT JOIN marm as material on detail~matnr = material~matnr left outer join vbak on detail~vgbel = vbak~vbeln INTO CORRESPONDING FIELDS OF TABLE dresult where detail~vbeln = packo. ` and got error message 'The work area DRESULT does not contain any corresponding components.' – kk luo Aug 05 '19 at 09:39
  • You need to change also your projection to SELECT arktx AS itemdesc lfimg AS quantity ntgew AS tweight. It is mentioned in my answer. Alternatively you can remove the MANDT field from your structure/transparent table type and leave `INTO TABLE`. – Jagger Aug 05 '19 at 13:22