Skip to Content
author's profile photo Former Member
Former Member

select into a variable ???

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Posted on Nov 22, 2007 at 11:14 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 11:17 AM

    Hi,

    If u want to put the data into a variable use

    Select single FIELDNAME from TABLENAME into variable name

    where condition.

    Regards,

    Vani.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • Posted on Nov 22, 2007 at 11:21 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 11:22 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 11:23 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 11:26 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 23, 2007 at 09:32 AM

    solve thx

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.