Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dinamic SQL

Hi,

I have the following dinamic sql sentence:

<Code>

select single (p_campo) into vt_salida

from vt_table

</Code>

The type of p_campo is any. Which should be the type of vt_salida ?

I need that it never happens an error.

Thanks

Tags:
replied

Try with this code:

DATA: ITAB TYPE REF TO DATA.
FIELD-SYMBOLS: <ITAB> TYPE STANDARD TABLE.

DATA: TABLE_NAME(20).

DATA: BEGIN OF LT_FIELDS OCCURS 0,
      FIELD(20),
      END   OF LT_FIELDS.

TABLE_NAME = 'MARA'.

LT_FIELDS = 'MATNR'.
APPEND LT_FIELDS.

LT_FIELDS = 'MATKL'.
APPEND LT_FIELDS.

CREATE DATA ITAB TYPE STANDARD TABLE OF (TABLE_NAME).
ASSIGN ITAB->* TO <ITAB>.

SELECT (LT_FIELDS) "matnr MATKL
INTO CORRESPONDING FIELDS OF TABLE <ITAB>
FROM (TABLE_NAME)
 UP TO 10 ROWS.

Regards,

Naimesh Patel

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question