<?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: help to improve this code in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816832#M1588593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the first part seems to be o.k., I don't see serious performance problems&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But be aware that the generated SELECT can have kind of performance from extremely good to extremely poor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_my_table&lt;/P&gt;&lt;P&gt;    FROM ZMYCUSTOMTABLE&lt;/P&gt;&lt;P&gt;    WHERE (lv_cond_syntax).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 May 2011 13:10:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-05-24T13:10:53Z</dc:date>
    <item>
      <title>help to improve this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816830#M1588591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the scenario;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a selection screen with all the field of a custom table, all the selection fields are parameters not ranges...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ok, i need to make a select statement only with the fields are filled. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(All the fields of my selection screen are stored in the structuer ls_selection_screen)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lv_cond_syntax TYPE string,
      lv_field2read TYPE string,
      lt_fields TYPE TABLE OF dd03l,
      ls_fields LIKE LINE OF lt_campos,
      lv_number TYPE CHAR24,
      lv_cont TYPE i.
  
* Get all the field of my custom table;
  SELECT * INTO TABLE lt_fields
   FROM dd03l WHERE tabname EQ 'ZMYCUSTOMTABLE'.

* Fill the WHERE conditons
  LOOP AT lt_fields INTO ls_fields.

    ASSIGN COMPONENT ls_fields-fieldname OF STRUCTURE ls_selection_screen TO &amp;lt;fs_field&amp;gt;.
    CHECK sy-subrc EQ 0.

*   Add the field only if are filled;
    CHECK &amp;lt;fs_field&amp;gt; IS NOT INITIAL.
    ADD 1 TO lv_cont.

*   ---  Concatenate the field to the WHERE ----   *
    IF lv_cont GT 1. "The first without 'AND'
      CONCATENATE lv_cond_syntax 'AND' INTO lv_cond_syntax SEPARATED BY SPACE.
    ENDIF.

*   Concatenate field's value with quotation marks
    IF ls_fields-inttype EQ 'P' OR ls_fields-inttype EQ 'F' OR ls_fields-inttype EQ 'I'.
*     If is numeric, first we must to translate the value to a character type var...    
      WRITE &amp;lt;fs_field&amp;gt; TO lv_number LEFT-JUSTIFIED.
      REPLACE ',' WITH '.' INTO lv_number.
      CONCATENATE '''' lv_number '''' INTO lv_field2read.
    ELSE.
      CONCATENATE '''' &amp;lt;fs_field&amp;gt; '''' INTO lv_field2read.
    ENDIF.

    CONCATENATE lv_cond_syntax ls_fields-fieldname 'EQ' lv_field2read INTO lv_cond_syntax SEPARATED BY SPACE.
  ENDLOOP.

* Select data:
  SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_my_table
    FROM ZMYCUSTOMTABLE
    WHERE (lv_cond_syntax).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Works fine, but i don't know it is there any other easiest way to do it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message: please choose more descriptive subject lines for your posts.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Thomas Zloch on May 24, 2011 3:08 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 12:15:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816830#M1588591</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-24T12:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: help to improve this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816831#M1588592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using select-options instead of parameters, they have the desired functionality built in, empty ranges are not being passed to the database, you could have a static WHERE-clause.&lt;/P&gt;&lt;P&gt;On the selection screen, you can use the NO-EXTENSION and NO INTERVALS options of SELECT-OPTIONS  to create a "parameter look-a-like". Or define your own ranges with DATA ... TYPE RANGE OF ...&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 13:08:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816831#M1588592</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2011-05-24T13:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: help to improve this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816832#M1588593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the first part seems to be o.k., I don't see serious performance problems&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But be aware that the generated SELECT can have kind of performance from extremely good to extremely poor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select data:&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_my_table&lt;/P&gt;&lt;P&gt;    FROM ZMYCUSTOMTABLE&lt;/P&gt;&lt;P&gt;    WHERE (lv_cond_syntax).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 13:10:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816832#M1588593</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-24T13:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: help to improve this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816833#M1588594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Thomas, I know that, my program is a webdynpro so i can do it with the component WDR_SELECT_OPTIONS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just wondering if you had some knowledge to do it in a less complicated way... perhaps i'll do with a static WHERE-clause...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks also Siegfried. I'm going to try to measure the performance...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2011 14:16:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-to-improve-this-code/m-p/7816833#M1588594</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-05-24T14:16:23Z</dc:date>
    </item>
  </channel>
</rss>

