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: 

select into a variable ???

Former Member
0 Kudos

hi i want to do

select xxx from xxx

into variable

for all entries in table

i know i can't do that since puting the data into a variable won't work in for all entries. i tried with up to 1 row or select single but i won't work

plzzz mee urgent help

8 REPLIES 8

former_member195698
Active Contributor
0 Kudos

If your requirement is to select any single record, and as you said <b>its not taking SELECT SINGLE</b>, For entries in the table (used for for all entries ) why don't you try this.

A) Get the first record in the table and then Fire your select single query

B) Loop at the table

Fire Select single query, if it is successful

exit the loop.

endloop.

Former Member
0 Kudos

Hi,

If u want to put the data into a variable use

Select single FIELDNAME from TABLENAME into variable name

where condition.

Regards,

Vani.

0 Kudos

Select single FIELDNAME from TABLENAME into variable name

where condition.

that's what i say i can't fo cozzz

Select single FIELDNAME from TABLENAME into variable name

for all entries TABLEx

where tablename = table x.

former_member404244
Active Contributor
0 Kudos

Hi.

Inorder to achieve ur requirement u have to do like this

loop at itab.

select single werks from marc into v_werks

where matnr = itab-matnr.

endloop.

Reward if helpful.

Regards,

Nagaraj

Former Member
0 Kudos

hi,

select single is working, may be u gave wrong data type

data : m type string.

select single matnr from mara into m.

write: / m.

regards,

pavan

Former Member
0 Kudos

See this example.....

PARAMETERS p_city TYPE spfli-cityfrom.

TYPES: BEGIN OF entry_tab_type,

carrid TYPE spfli-carrid,

connid TYPE spfli-connid,

END OF entry_tab_type.

DATA: entry_tab TYPE TABLE OF entry_tab_type,

sflight_tab TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY carrid connid fldate.

SELECT carrid connid

FROM spfli

INTO CORRESPONDING FIELDS OF TABLE entry_tab

WHERE cityfrom = p_city.

SELECT carrid connid fldate

FROM sflight

INTO CORRESPONDING FIELDS OF TABLE sflight_tab

FOR ALL ENTRIES IN entry_tab

WHERE carrid = entry_tab-carrid AND

connid = entry_tab-connid.

Former Member
0 Kudos

Hi newbie82,

have you given the type for the selection-screen field??

just have a look at this code,

tables: vbak.

data: wa_vbak-vkorg(4).

<b>data: wa_vbak-vbeln type vbak-vbeln.</b>

select-options: s_vbeln for wa_vbak-vbeln.

<b>SELECT single vkorg

INTO wa_vbak-vkorg FROM vbak

WHERE

vbeln in s_vbeln.</b>

WRITE: / wa_vbak-vkorg.

hope this works.

Former Member
0 Kudos

solve thx