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

Dinamic SQL

Former Member
0 Likes
521

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

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
495

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

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
496

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

Read only

Former Member
0 Likes
495

Hello,

I think it should be string...or a numeric char something like

DATA vt_salida(8) TYPE N.

OR

DATA vt_salida TYPE STRING

check this sample.

DATA: wa TYPE spfli,

ftab TYPE TABLE OF STRING.

APPEND 'CITYFROM' TO ftab.

APPEND 'CITYTO' TO ftab.

SELECT DISTINCT (ftab)

FROM spfli

INTO CORRESPONDING FIELDS OF wa

WHERE

carrid = 'LH'.

WRITE: / wa-cityfrom, wa-cityto.

ENDSELECT.

Bye

Gabriel

Read only

Former Member
0 Likes
495

Sorry but I don´t find the radio buttons to award points to replies...