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

Function module for table SWWWIHEAD

Former Member
0 Likes
3,034

Hello,

I want to use the table SWWWIHEAD (2 times in my program).

The requirment is :

select data (ie WI_CHCKWI,higher level item)

from SWWWIHEAD

where WI_RH_TASK = 'TS90000007' &

WI_STAT = u2018COMPLETEDu2019 &

WI_AED = date entered on selection screen

select data

from SWWWIHEAD

where WI_CHCKWI = WI_CHCKWI-found from above select query.

Please help me with the function module, so that there will not be any performance issues in future.

Thanks in Advance

Regards,

Darshana

9 REPLIES 9
Read only

Former Member
0 Likes
1,941

1

Read only

0 Likes
1,941

Hi,

First select return me the 'Higher level item' (ie WI_CHCKWI)

and second one will retrun me the data (ie i need to evaluate the status depending on some tasks) corresponding to that higher level item (ie WI_CHCKWI).

Regards,

Darshana

Read only

0 Likes
1,941

select data into table IT_TAB

from SWWWIHEAD

where WI_RH_TASK = 'TS90000007' &

WI_STAT = u2018COMPLETEDu2019 &

WI_AED = date entered on selection screen

If you pass WI_CHCKWI to WI_CHCKWI in second select statement you will get same info.

The table will return the required data for you. Just check it . If my understanding is correct, I am sure you don't require 2nd select.

Read only

0 Likes
1,941

Hi,

I need the second select also,Please look at the query again .

Regards,

Darshana

Read only

0 Likes
1,941

Hi,

i don't think so there is a FM for the logic you have given, FYI you can check on this SWW_WI* in se37 ,

if u havent checked. If you find any FM Please do share with us , as iam developing a report on workflow

Read only

Former Member
0 Likes
1,941

If your requirement is to get details of only Superordinate Work Item if it exists, may be after the following select statement you can delete entries from internal table.

select data into table IT_TAB

from SWWWIHEAD

where WI_RH_TASK = 'TS90000007' &

WI_STAT = u2018COMPLETEDu2019 &

WI_AED = date entered on selection screen

Delete it_tab where WI_CHCKWI IS INITIAL. Will it help you?

Read only

Former Member
0 Likes
1,941

Use

SAP_WAPI_WORKITEMS_TO_OBJECT

Read only

Former Member
0 Likes
1,941

Hi,

Instead of two select query, just get all the required data in an internal table IT_SWWIHEAD and copied that to a another temporary table IT_TEMP.You can process your logic with the new internal table IT_TEMP. At last instead of second select query you can go and pick the value from main internal table IT_SWWIHEAD.

Just play with internal table instead of repeated select query

Read only

Former Member
0 Likes
1,941

Hello,

Please, analyse the program RSWUWFML2, find a perform statement select_workitems. In my system it is line 623.

This program is very efficient as it reads this table to send notifications on e-mail about new work items in users' inboxes.

Here is the code.

FORM select_workitems.

* Select those workitems with the correct task, state and creation
* date and time.

************************************************************************
* The select statement encourages one of the database indices          *
* to be used. Either the task index or the status/type index.          *
* Tests show that this really does influence the database access       *
* positively.                                                          *
* This algorithm will be inefficient when tasks are excluded rather    *
* than included.                                                       *
* The combination 'Waiting' and Notification/deadline type             *
* cannot occur.                                                        *
************************************************************************
  IF task_sel[] IS INITIAL.            "No tasks
*   Use the type/status index.

    SELECT wi_id tclass
      INTO CORRESPONDING FIELDS OF TABLE lt_wi_data
      FROM swwwihead
      WHERE
         wi_type = wi_normal       AND
         wi_stat = wi_status_ready AND
         retry_cnt = '0'           AND
*        note 969538:
         crea_tmp > l_from_tstamp  AND
         crea_tmp <= l_to_tstamp.

    SELECT wi_id tclass
      APPENDING CORRESPONDING FIELDS OF TABLE lt_wi_data
      FROM swwwihead
      WHERE
         wi_type = wi_deadline     AND
         wi_stat = wi_status_ready AND
         retry_cnt = '0'           AND
*        note 969538:
         crea_tmp > l_from_tstamp  AND
         crea_tmp <= l_to_tstamp
*     note 0000790920
      %_hints
      oracle 'INDEX("&TABLE&" "SWWWIHEAD~C" "SWWWIHEAD^C" "SWWWIHEAD_C" "SWWWIHEAD_C__X")'
      DB2    'USE VALUES FOR OPTIMIZATION'
      DB2    '&SUBSTITUTE VALUES&'. "#EC CI_HINTS

*   no longer select waiting work items

  ELSE.
*   Use the task index.
    SELECT wi_id tclass
      INTO CORRESPONDING FIELDS OF TABLE lt_wi_data
      FROM swwwihead
      WHERE
        wi_rh_task IN task_sel AND
        wi_stat = wi_status_ready AND
        wi_type = wi_normal       AND
*       note 969538:
        crea_tmp > l_from_tstamp  AND
        crea_tmp <= l_to_tstamp.

*   Add all the deadline items.
    SELECT wi_id tclass
      APPENDING CORRESPONDING FIELDS OF TABLE lt_wi_data
      FROM swwwihead
      WHERE
        wi_stat = wi_status_ready AND
        wi_type = wi_deadline     AND
*       note 969538:
        crea_tmp > l_from_tstamp  AND
        crea_tmp <= l_to_tstamp
*   note 0000790920
    %_hints
    oracle 'INDEX("&TABLE&" "SWWWIHEAD~C" "SWWWIHEAD^C" "SWWWIHEAD_C" "SWWWIHEAD_C__X")'
    DB2    'USE VALUES FOR OPTIMIZATION'
    DB2    '&SUBSTITUTE VALUES&'. "#EC CI_HINTS

*   Filter out the deadline items with wrong task
    DATA: l_wi_header LIKE swwwihead.

    LOOP AT lt_wi_data.

      CLEAR l_wi_header.
      CALL FUNCTION 'SWW_WI_HEADER_READ'
        EXPORTING
          wi_id     = lt_wi_data-wi_id
        IMPORTING
          wi_header = l_wi_header
        EXCEPTIONS
          OTHERS    = 1.

      CHECK l_wi_header-wi_type = wi_deadline.

      CLEAR swwwihead.
      SELECT SINGLE * FROM swwwihead
                      WHERE wi_id = l_wi_header-wi_chckwi.

      IF NOT swwwihead-wi_rh_task IN task_sel.
        DELETE lt_wi_data.
      ENDIF.
    ENDLOOP.

  ENDIF.

ENDFORM.                    "select_workitems