<?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 SELECT STATMENT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statment/m-p/5249126#M1212758</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Colleagues,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you kindly help me with respect to below code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below select statement  has to fetch me all the rows which is corresponding to my work item id .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM (V_DO_CDS_NAME_MAIN) INTO TABLE &amp;lt;fs_itab&amp;gt; where C1 =
    V_WORK_ITEM_ID_MAIN.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As workitem id is not a primary key so it can have more than 1 corresponding value .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case the statement always displays the last row, can you kindly help me with this regard ? .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to display all the rows corresponding to the same workitem id .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you kindly help me here ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Complete Code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*Verification of Workitem/alert id on the DOE ( Middleware ).

*********************************************************************

V_WORK_ITEM_ID_MAIN = I_WORK_ITEM_ID_MAIN.

LOG ( V_WORK_ITEM_ID_MAIN ).  eCATT Function 

V_DO_CDS_NAME_MAIN =  I_DO_CDS_NAME_MAIN.

LOG ( V_DO_CDS_NAME_MAIN ).eCATT Function 

STATUS = I_STATUS.

*********************************************************************

* Displaying the fields of the table fetched from the above function.

*********************************************************************

IF ( V_DO_CDS_NAME_MAIN &amp;lt;&amp;gt; '' ) .

  ABAP.

    DATA: ref_it_tab TYPE REF TO data,
    ref_wa TYPE REF TO data.

    FIELD-SYMBOLS: &amp;lt;fs_itab&amp;gt; TYPE ANY TABLE.
    FIELD-SYMBOLS: &amp;lt;fs_wa&amp;gt; TYPE ANY.
    FIELD-SYMBOLS: &amp;lt;fs_field&amp;gt; TYPE ANY.


    CREATE DATA ref_it_tab TYPE STANDARD TABLE OF (V_DO_CDS_NAME_MAIN)
    WITH NON-UNIQUE DEFAULT KEY.
    ASSIGN ref_it_tab-&amp;gt;* TO &amp;lt;fs_itab&amp;gt;.

******** Fetching the row count for the workitem id******************

    SELECT COUNT(*) FROM (V_DO_CDS_NAME_MAIN) where C1 =
    V_WORK_ITEM_ID_MAIN.
    V_COUNT = sy-dbcnt.


    SELECT * FROM (V_DO_CDS_NAME_MAIN) INTO TABLE &amp;lt;fs_itab&amp;gt; where C1 =
    V_WORK_ITEM_ID_MAIN.

    CREATE DATA ref_wa LIKE LINE OF &amp;lt;fs_itab&amp;gt;.
    ASSIGN ref_wa-&amp;gt;* TO &amp;lt;fs_wa&amp;gt;.

**********************Generating the dynamic field*******************

   loop at &amp;lt;fs_itab&amp;gt; assigning &amp;lt;fs_wa&amp;gt;.
        assign component 'CLIENT' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_CLIENT = &amp;lt;fs_field&amp;gt;.
        assign component 'C0' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C0 = &amp;lt;fs_field&amp;gt;.
        assign component 'C1' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C1 = &amp;lt;fs_field&amp;gt;.
        assign component 'C2' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C2 = &amp;lt;fs_field&amp;gt;.
        assign component 'C3' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C3 = &amp;lt;fs_field&amp;gt;.
        assign component 'C4' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C4 = &amp;lt;fs_field&amp;gt;.
        assign component 'C5' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C5 = &amp;lt;fs_field&amp;gt;.
        assign component 'C6' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C6 = &amp;lt;fs_field&amp;gt;.
        assign component 'C7' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C7 = &amp;lt;fs_field&amp;gt;.
        assign component 'C8' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C8 = &amp;lt;fs_field&amp;gt;.
        assign component 'MESSAGE_ID' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_MESSAGE_ID = &amp;lt;fs_field&amp;gt;.
        assign component 'TIMESTAMP' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_TIMESTAMP = &amp;lt;fs_field&amp;gt;.
        assign component 'EXTRACTKEY' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_EXTRACTKEY = &amp;lt;fs_field&amp;gt;.
        assign component 'STATEID' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_STATEID = &amp;lt;fs_field&amp;gt;.
        assign component 'DEVICE_ID' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_DEVICE_ID = &amp;lt;fs_field&amp;gt;.


      ENDLOOP.


LOG== WRITE satement in ABAP it displays the variable .

LOG( V_COUNT ).
LOG ( V_CLIENT ).
LOG ( V_C0 ).
LOG ( V_C1 ).
LOG ( V_C2 ).
LOG ( V_C3 ).
LOG ( V_C4 ).
LOG ( V_C5 ).
LOG ( V_C6 ).
LOG ( V_C7 ).
LOG ( V_C8 ).
LOG ( V_TIMESTAMP ).
LOG ( V_EXTRACTKEY ).
LOG ( V_STATEID ).
LOG ( V_DEVICE_ID ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance and regards&lt;/P&gt;&lt;P&gt;Harsha&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Julius Bussche on Feb 24, 2009 10:14 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Feb 2009 19:25:56 GMT</pubDate>
    <dc:creator>harsha_s</dc:creator>
    <dc:date>2009-02-24T19:25:56Z</dc:date>
    <item>
      <title>SELECT STATMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statment/m-p/5249126#M1212758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Colleagues,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you kindly help me with respect to below code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below select statement  has to fetch me all the rows which is corresponding to my work item id .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM (V_DO_CDS_NAME_MAIN) INTO TABLE &amp;lt;fs_itab&amp;gt; where C1 =
    V_WORK_ITEM_ID_MAIN.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As workitem id is not a primary key so it can have more than 1 corresponding value .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my case the statement always displays the last row, can you kindly help me with this regard ? .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to display all the rows corresponding to the same workitem id .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you kindly help me here ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Complete Code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*Verification of Workitem/alert id on the DOE ( Middleware ).

*********************************************************************

V_WORK_ITEM_ID_MAIN = I_WORK_ITEM_ID_MAIN.

LOG ( V_WORK_ITEM_ID_MAIN ).  eCATT Function 

V_DO_CDS_NAME_MAIN =  I_DO_CDS_NAME_MAIN.

LOG ( V_DO_CDS_NAME_MAIN ).eCATT Function 

STATUS = I_STATUS.

*********************************************************************

* Displaying the fields of the table fetched from the above function.

*********************************************************************

IF ( V_DO_CDS_NAME_MAIN &amp;lt;&amp;gt; '' ) .

  ABAP.

    DATA: ref_it_tab TYPE REF TO data,
    ref_wa TYPE REF TO data.

    FIELD-SYMBOLS: &amp;lt;fs_itab&amp;gt; TYPE ANY TABLE.
    FIELD-SYMBOLS: &amp;lt;fs_wa&amp;gt; TYPE ANY.
    FIELD-SYMBOLS: &amp;lt;fs_field&amp;gt; TYPE ANY.


    CREATE DATA ref_it_tab TYPE STANDARD TABLE OF (V_DO_CDS_NAME_MAIN)
    WITH NON-UNIQUE DEFAULT KEY.
    ASSIGN ref_it_tab-&amp;gt;* TO &amp;lt;fs_itab&amp;gt;.

******** Fetching the row count for the workitem id******************

    SELECT COUNT(*) FROM (V_DO_CDS_NAME_MAIN) where C1 =
    V_WORK_ITEM_ID_MAIN.
    V_COUNT = sy-dbcnt.


    SELECT * FROM (V_DO_CDS_NAME_MAIN) INTO TABLE &amp;lt;fs_itab&amp;gt; where C1 =
    V_WORK_ITEM_ID_MAIN.

    CREATE DATA ref_wa LIKE LINE OF &amp;lt;fs_itab&amp;gt;.
    ASSIGN ref_wa-&amp;gt;* TO &amp;lt;fs_wa&amp;gt;.

**********************Generating the dynamic field*******************

   loop at &amp;lt;fs_itab&amp;gt; assigning &amp;lt;fs_wa&amp;gt;.
        assign component 'CLIENT' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_CLIENT = &amp;lt;fs_field&amp;gt;.
        assign component 'C0' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C0 = &amp;lt;fs_field&amp;gt;.
        assign component 'C1' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C1 = &amp;lt;fs_field&amp;gt;.
        assign component 'C2' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C2 = &amp;lt;fs_field&amp;gt;.
        assign component 'C3' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C3 = &amp;lt;fs_field&amp;gt;.
        assign component 'C4' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C4 = &amp;lt;fs_field&amp;gt;.
        assign component 'C5' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C5 = &amp;lt;fs_field&amp;gt;.
        assign component 'C6' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C6 = &amp;lt;fs_field&amp;gt;.
        assign component 'C7' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C7 = &amp;lt;fs_field&amp;gt;.
        assign component 'C8' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_C8 = &amp;lt;fs_field&amp;gt;.
        assign component 'MESSAGE_ID' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_MESSAGE_ID = &amp;lt;fs_field&amp;gt;.
        assign component 'TIMESTAMP' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_TIMESTAMP = &amp;lt;fs_field&amp;gt;.
        assign component 'EXTRACTKEY' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_EXTRACTKEY = &amp;lt;fs_field&amp;gt;.
        assign component 'STATEID' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_STATEID = &amp;lt;fs_field&amp;gt;.
        assign component 'DEVICE_ID' of structure &amp;lt;fs_wa&amp;gt; to &amp;lt;fs_field&amp;gt;.
        V_DEVICE_ID = &amp;lt;fs_field&amp;gt;.


      ENDLOOP.


LOG== WRITE satement in ABAP it displays the variable .

LOG( V_COUNT ).
LOG ( V_CLIENT ).
LOG ( V_C0 ).
LOG ( V_C1 ).
LOG ( V_C2 ).
LOG ( V_C3 ).
LOG ( V_C4 ).
LOG ( V_C5 ).
LOG ( V_C6 ).
LOG ( V_C7 ).
LOG ( V_C8 ).
LOG ( V_TIMESTAMP ).
LOG ( V_EXTRACTKEY ).
LOG ( V_STATEID ).
LOG ( V_DEVICE_ID ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance and regards&lt;/P&gt;&lt;P&gt;Harsha&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Julius Bussche on Feb 24, 2009 10:14 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2009 19:25:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statment/m-p/5249126#M1212758</guid>
      <dc:creator>harsha_s</dc:creator>
      <dc:date>2009-02-24T19:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statment/m-p/5249127#M1212759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try the ABAP forum. this had nothing to do with SAP on Unix.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2009 20:27:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statment/m-p/5249127#M1212759</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-24T20:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: SELECT STATMENT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statment/m-p/5249128#M1212760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Moved to ABAP General, duplicate post deleted, and "code tags" added...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Feb 2009 21:13:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statment/m-p/5249128#M1212760</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-24T21:13:54Z</dc:date>
    </item>
  </channel>
</rss>

