<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071542#M973421</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have select-option for material code it's very easy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES MARA.

SELECT-OPTIONS: SO_MATNR FOR MARA-MATNR.

DATA T_MARA TYPE STANDARD TABLE OF MARA.

START-OF-SELECTION.

  SELECT * FROM MARA INTO TABLE T_MARA WHERE MATNR IN SO_MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Jul 2008 14:26:29 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-04T14:26:29Z</dc:date>
    <item>
      <title>Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071541#M973420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having a requirement where there is a selection screen in a report  with material number.The select statement should fetch the material details from MARA table even if user enters the partial material number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example there is a material called G1240-094-1 in the database.&lt;/P&gt;&lt;P&gt;if suppose the user enters only a partial material number say &lt;/P&gt;&lt;P&gt;G1240-094* and eexcutes the program, the program should fetch the details of material G1240-094-1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can we write a select statement for this type of requirement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:22:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071541#M973420</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071542#M973421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have select-option for material code it's very easy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES MARA.

SELECT-OPTIONS: SO_MATNR FOR MARA-MATNR.

DATA T_MARA TYPE STANDARD TABLE OF MARA.

START-OF-SELECTION.

  SELECT * FROM MARA INTO TABLE T_MARA WHERE MATNR IN SO_MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:26:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071542#M973421</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071543#M973422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi check this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables:mara .&lt;/P&gt;&lt;P&gt;data:v_matnr like mara-matnr.&lt;/P&gt;&lt;P&gt;selection-screen : s_matnr for mara-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;select matnr &lt;/P&gt;&lt;P&gt;         from mara&lt;/P&gt;&lt;P&gt;          into v_matnr &lt;/P&gt;&lt;P&gt;          where matnr in s_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write:/ v_matnr .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:27:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071543#M973422</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071544#M973423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;select * from mara where matnr like val1.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It might be that you need to replace the * with %.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option is:&lt;/P&gt;&lt;P&gt;select * from mara where matnr cp val1.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the last case it might be neccesary to remove the wildcard.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the SAP help and look at the part about logical conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Arthur Parisius&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:33:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071544#M973423</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071545#M973424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Venkat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have not understood my requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the selection screen, suppose the user enters only partial material number like G123456-9 and executes the report. The user doesn't knows the correct material so he enters material number partially. &lt;/P&gt;&lt;P&gt;The actual material number is G123456-9-11.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;parameters: p_matnr like mara-matnr.&lt;/P&gt;&lt;P&gt;data : begin of itab occurs 100,&lt;/P&gt;&lt;P&gt;        matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;       end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select  matnr from mara into table itab&lt;/P&gt;&lt;P&gt;where matnr = p_matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to code for this type of requirement?&lt;/P&gt;&lt;P&gt;IS there any wild card search possible in select statement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:37:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071545#M973424</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071546#M973425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have a parameter, u can use a range instead of select-option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES MARA.

SELECT-OPTIONS SO_MATNR FOR MARA-MATNR.

PARAMETERS: P_MATNR LIKE MARA-MATNR.

DATA: T_MARA TYPE STANDARD TABLE OF MARA.

RANGES: R_MATNR FOR MARA-MATNR.

DATA: V_LEN TYPE I,
      V_POS TYPE I,
      OK    TYPE C.

START-OF-SELECTION.

  V_LEN = STRLEN( P_MATNR ).

  DO V_LEN TIMES.
    IF P_MATNR+V_POS(1) = '*'.
      OK = 'X'.
      EXIT.
    ENDIF.
    V_POS = V_POS + 1.
  ENDDO.

  IF OK IS INITIAL.
    R_MATNR(3) = 'IEQ'.
    R_MATNR-LOW = P_MATNR.
  ELSE.
    R_MATNR(3) = 'ICP'.
    R_MATNR-LOW = P_MATNR.
  ENDIF.
  APPEND R_MATNR.

  SELECT * FROM MARA INTO TABLE T_MARA WHERE MATNR IN R_MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:40:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071546#M973425</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071547#M973426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES:mara .
PARAMETERS p_matnr TYPE mara-matnr.
DATA: 
  t_mara TYPE STANDARD TABLE OF mara,
  w_mara LIKE LINE OF t_mara.

CONCATENATE  p_matnr '%' INTO p_matnr.

SELECT * 
  FROM mara 
  INTO TABLE t_mara 
 WHERE matnr LIKE p_matnr.

LOOP AT t_mara INTO w_mara.
  WRITE:/
  w_mara-matnr,
  w_mara-ernam.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Adil&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:44:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071547#M973426</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071548#M973427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi check this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables:mara.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-options: s_matnr for mara-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab occurs 100,&lt;/P&gt;&lt;P&gt;matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select matnr&lt;/P&gt;&lt;P&gt;      from mara&lt;/P&gt;&lt;P&gt;      into table itab&lt;/P&gt;&lt;P&gt;      where matnr like 'G123456-%'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;write:/ itab-matnr.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:45:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071548#M973427</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071549#M973428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You Syed. It works..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 14:50:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071549#M973428</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T14:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071550#M973429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you tried Max bianchi's or Venkat's code?&lt;/P&gt;&lt;P&gt;No need for wild cards logic if you use a select-option instead of a parameter.&lt;/P&gt;&lt;P&gt;The system will take care of the whole thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jul 2008 15:02:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement/m-p/4071550#M973429</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-04T15:02:22Z</dc:date>
    </item>
  </channel>
</rss>

