Application Development 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: 

Modify Statement acting strange. Workflow

Former Member
0 Kudos

Hi all, we are in the middle of an EhP 6 upgrade and ran into a MODIFY statment that is acting strange with workflow items.  When the MODIFY statement runs, it updates the desired row/columns correctly but also overwrites the first few columns of the very next row in the table with the TRANSPORTING fields.  Any help would be appreciated.

Here is the type for the internal table:

TYPES: BEGIN OF t_list.

INCLUDE  TYPE swr_wihdr.

TYPESkey            TYPE sweinstcou-objkey,

        classification TYPE swlwp1-dyncol_c2,

        imagepriority  TYPE zfapr024_alv-imagepriority,

        barcode        TYPE ztwfapinvcimage-barcode,

        documenttype   TYPE toav0-ar_object,

        documentclass  TYPE toadd-doc_type,

        changed(1)    TYPE c,

END OF t_list.

DATA: wa_list          TYPE t_list,

      it_list          TYPE STANDARD TABLE OF t_list

This is the function that loads the internal table:

CALL FUNCTION 'SAP_WAPI_CREATE_WORKLIST'

    EXPORTING

      translate_wi_text = 'X'

      read_task_text    = 'X'

      im_task_filter    = it_task

      im_status_filter  = it_status

    IMPORTING

      return_code       = l_return_code

    TABLES

      worklist          = it_list.

Then the code loads some additional information from the container and updates the work area with those fields. 

LOOP AT it_list INTO wa_list .

    l_tabix = sy-tabix.

    CLEAR: it_container, it_all_objects.

    CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'

      EXPORTING

        workitem_id              = wa_list-wi_id

      IMPORTING

        return_code              = w_rc

      TABLES

        simple_container         = it_container

        subcontainer_all_objects = it_all_objects.

    CHECK w_rc = 0.



    CLEAR wa_all_objects.

    READ TABLE it_all_objects

          INTO wa_all_objects

      WITH KEY element = g_c_wi_object_id.

    IF sy-subrc = 0.

      wa_list-key = wa_all_objects-value(42)."42 key length of ZIMAGE

    ENDIF.



    CLEAR: wa_container.

    READ TABLE it_container

          INTO wa_container

      WITH KEY element = g_c_classification.

    IF sy-subrc = 0.

      wa_list-classification = wa_container-value.

    ENDIF.



    CLEAR: wa_container.

    READ TABLE it_container

          INTO wa_container

      WITH KEY element = g_c_imagepriority.

    IF sy-subrc = 0.

      wa_list-imagepriority = wa_container-value.

    ENDIF.



    CLEAR: wa_container.

    READ TABLE it_container

          INTO wa_container

      WITH KEY element = g_c_barcode.

    IF sy-subrc = 0.

      wa_list-barcode = wa_container-value.

    ENDIF.



    CLEAR: wa_container.

    READ TABLE it_container

          INTO wa_container

      WITH KEY element = g_c_documenttype.

    IF sy-subrc = 0.

      wa_list-documenttype = wa_container-value.

    ENDIF.



    CLEAR: wa_container.

    READ TABLE it_container

          INTO wa_container

      WITH KEY element = g_c_documentclass.

    IF sy-subrc = 0.

      wa_list-documentclass = wa_container-value.

    ENDIF.


Here is the statement that causes the problem. 


    MODIFY it_list

      INDEX l_tabix

      FROM wa_list

      TRANSPORTING

                  key

                  classification

                  imagepriority

                  barcode

                  documenttype

                  documentclass.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

At first sight this looks quite strange indeed... Have you tried using the ASSIGNING option instead of INTO and MODIFY?... Better in term of performance and cleaner anyway...

Kr,

Manu.

3 REPLIES 3

Former Member
0 Kudos

Hi,

At first sight this looks quite strange indeed... Have you tried using the ASSIGNING option instead of INTO and MODIFY?... Better in term of performance and cleaner anyway...

Kr,

Manu.

0 Kudos

Thanks for the response!

I didn't try ASSIGNING, but I tried using FIELD SYMBOLS instead but that didn't fix it.  Even when I tried to clear the fields first, KEY for example, the first few columns of the next record of the table were cleared as well. 

I was able to find a workaround though,  I called the 'SAP_WAPI_CREATE_WORKLIST' function using an internal table with only the swr_wihdr include fields, then I just looped through and copied to it_list.   After that, I just let the code run through the it_list loop and everything worked fine.  It seemes like 'SAP_WAPI_CREATE_WORKLIST' was doing something with those extra fields (Key, Classification, ImagePriority, etc), but I have no idea what.

   

Former Member
0 Kudos

Hi Jason,

The part of the code seems to be fine. I would suggest you to please check, if l_tabix is of type sy-tabix and you are clearing the varirables including l_tabix at the end of loop. Also, just see if COMMIT WORK statement is present in the code, immediately after modify statement.

Regards,

Hardik Mehta