<?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 making select statement according to 2 fields in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394011#M1995016</link>
    <description>&lt;P&gt;Hi&lt;BR /&gt;In a table tab_1 there are fields werks , date , fklmg , kzwi1 , udf1 , udf2&lt;/P&gt;
  &lt;P&gt;and udf1 , udf2 are extra field that contain data and sometime the field udf1 could be empty but udf2 is not .&lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;I need to build a report from table tab_1 based on the udf1 (as primary key) where udf1 is not initial , but if udf1 is initial get the value from udf2 .&lt;/P&gt;
  &lt;P&gt;table like &lt;BR /&gt;date werks fklmg kzwi1 udf1 udf2&lt;BR /&gt;date1 werks 70 105 pr1 &lt;BR /&gt;date2 werks 65 206 pr6&lt;BR /&gt;date3 werks 66 103 pr3&lt;/P&gt;
  &lt;P&gt;date4 werks 35 623 pr2&lt;BR /&gt;&lt;BR /&gt;report :&lt;BR /&gt;udf2 total of kzwi1&lt;/P&gt;</description>
    <pubDate>Mon, 10 May 2021 13:25:24 GMT</pubDate>
    <dc:creator>former_member745554</dc:creator>
    <dc:date>2021-05-10T13:25:24Z</dc:date>
    <item>
      <title>making select statement according to 2 fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394011#M1995016</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;In a table tab_1 there are fields werks , date , fklmg , kzwi1 , udf1 , udf2&lt;/P&gt;
  &lt;P&gt;and udf1 , udf2 are extra field that contain data and sometime the field udf1 could be empty but udf2 is not .&lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;I need to build a report from table tab_1 based on the udf1 (as primary key) where udf1 is not initial , but if udf1 is initial get the value from udf2 .&lt;/P&gt;
  &lt;P&gt;table like &lt;BR /&gt;date werks fklmg kzwi1 udf1 udf2&lt;BR /&gt;date1 werks 70 105 pr1 &lt;BR /&gt;date2 werks 65 206 pr6&lt;BR /&gt;date3 werks 66 103 pr3&lt;/P&gt;
  &lt;P&gt;date4 werks 35 623 pr2&lt;BR /&gt;&lt;BR /&gt;report :&lt;BR /&gt;udf2 total of kzwi1&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 13:25:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394011#M1995016</guid>
      <dc:creator>former_member745554</dc:creator>
      <dc:date>2021-05-10T13:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: making select statement according to 2 fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394012#M1995017</link>
      <description>&lt;P&gt;Please try to format your question like that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;date  werks fklmg kzwi1 udf1 udf2
----- ----- ----- ----- ---- ----
date1 werks 70    105   pr1
date2 werks 65    206   pr6
date3 werks 66    103   pr3
date4 werks 35    623   pr2&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sorry I don't get what is your expected result.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 13:50:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394012#M1995017</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2021-05-10T13:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: making select statement according to 2 fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394013#M1995018</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;SELECT werks , date , fklmg , kzwi1 , udf1
  INTO TABLE @my_table
  FROM tab_1
  WHERE udf1 NE @space

  UNION

SELECT werks , date , fklmg , kzwi1 , udf2 AS udf1
  INTO TABLE @my_table
  FROM tab_1
  WHERE udf1 EQ @space
    AND udf2 NE @space.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or (old syntax)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT werks date fklmg kzwi1 udf1
  INTO TABLE my_table
  FROM tab_1
  WHERE udf1 NE space.

SELECT werks date fklmg kzwi1 udf2 AS udf1
  APPENDING TABLE my_table
  FROM tab_1
  WHERE udf1 EQ space
    AND udf2 NE space.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 May 2021 14:19:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394013#M1995018</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2021-05-10T14:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: making select statement according to 2 fields</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394014#M1995019</link>
      <description>&lt;P&gt;Depending on the version of your NW stack, you could try the code below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT werks, 
       date, 
       fklmg, 
       kzwi1, 
       COALESCE( udf1, udf2 ) AS udf
  INTO TABLE @my_table
  FROM tab_1.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 May 2021 14:51:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/making-select-statement-according-to-2-fields/m-p/12394014#M1995019</guid>
      <dc:creator>Patrick_vN</dc:creator>
      <dc:date>2021-05-10T14:51:25Z</dc:date>
    </item>
  </channel>
</rss>

