Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SELECT STATMENT

harsha_s
Advisor
Advisor
0 Likes
342

Hello Colleagues,

Can you kindly help me with respect to below code .

The below select statement has to fetch me all the rows which is corresponding to my work item id .

SELECT * FROM (V_DO_CDS_NAME_MAIN) INTO TABLE <fs_itab> where C1 =
    V_WORK_ITEM_ID_MAIN.

As workitem id is not a primary key so it can have more than 1 corresponding value .

In my case the statement always displays the last row, can you kindly help me with this regard ? .

I want to display all the rows corresponding to the same workitem id .

Can you kindly help me here ?

Complete Code

*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 <> '' ) .

  ABAP.

    DATA: ref_it_tab TYPE REF TO data,
    ref_wa TYPE REF TO data.

    FIELD-SYMBOLS: <fs_itab> TYPE ANY TABLE.
    FIELD-SYMBOLS: <fs_wa> TYPE ANY.
    FIELD-SYMBOLS: <fs_field> 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->* TO <fs_itab>.

******** 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 <fs_itab> where C1 =
    V_WORK_ITEM_ID_MAIN.

    CREATE DATA ref_wa LIKE LINE OF <fs_itab>.
    ASSIGN ref_wa->* TO <fs_wa>.

**********************Generating the dynamic field*******************

   loop at <fs_itab> assigning <fs_wa>.
        assign component 'CLIENT' of structure <fs_wa> to <fs_field>.
        V_CLIENT = <fs_field>.
        assign component 'C0' of structure <fs_wa> to <fs_field>.
        V_C0 = <fs_field>.
        assign component 'C1' of structure <fs_wa> to <fs_field>.
        V_C1 = <fs_field>.
        assign component 'C2' of structure <fs_wa> to <fs_field>.
        V_C2 = <fs_field>.
        assign component 'C3' of structure <fs_wa> to <fs_field>.
        V_C3 = <fs_field>.
        assign component 'C4' of structure <fs_wa> to <fs_field>.
        V_C4 = <fs_field>.
        assign component 'C5' of structure <fs_wa> to <fs_field>.
        V_C5 = <fs_field>.
        assign component 'C6' of structure <fs_wa> to <fs_field>.
        V_C6 = <fs_field>.
        assign component 'C7' of structure <fs_wa> to <fs_field>.
        V_C7 = <fs_field>.
        assign component 'C8' of structure <fs_wa> to <fs_field>.
        V_C8 = <fs_field>.
        assign component 'MESSAGE_ID' of structure <fs_wa> to <fs_field>.
        V_MESSAGE_ID = <fs_field>.
        assign component 'TIMESTAMP' of structure <fs_wa> to <fs_field>.
        V_TIMESTAMP = <fs_field>.
        assign component 'EXTRACTKEY' of structure <fs_wa> to <fs_field>.
        V_EXTRACTKEY = <fs_field>.
        assign component 'STATEID' of structure <fs_wa> to <fs_field>.
        V_STATEID = <fs_field>.
        assign component 'DEVICE_ID' of structure <fs_wa> to <fs_field>.
        V_DEVICE_ID = <fs_field>.


      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 ).

Thanks in advance and regards

Harsha

Edited by: Julius Bussche on Feb 24, 2009 10:14 PM

2 REPLIES 2
Read only

Former Member
0 Likes
323

try the ABAP forum. this had nothing to do with SAP on Unix.

Read only

Former Member
0 Likes
323

Moved to ABAP General, duplicate post deleted, and "code tags" added...