SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Capture Rejection Reason Text from User Decision in Workflow

...Previous

The details of the parameters are

Parameter WORKITEMID:

Parameter REASON_TXT:

We will be passing the work item ID of the workflow and this method will read the container _Attach_Objects and pass the Rejection Text to variable REASON_TXT.

The code that you will write in the method is given below: (You can write your own code to read and process the SOFM Attachment Object as per your need)

begin_method read_rejection_reason changing container.

DATA: reason_txt TYPE swcont-value,
      reason 
TYPE swc_object OCCURS 0,
      object_content 
LIKE solisti1 OCCURS 0,
      workitemid 
LIKE swr_struct-workitemid,
      subcontainer_all_objects 
LIKE TABLE OF swr_cont,
      lv_wa_reason 
LIKE LINE OF subcontainer_all_objects,
      lv_no_att 
LIKE  sy-index,
      document_id 
LIKE sofolenti1-doc_id,
      return_code 
LIKE  sy-subrc,
      ifs_xml_container 
TYPE  xstring,
      ifs_xml_container_schema 
TYPE  xstring,
      simple_container 
LIKE TABLE OF swr_cont,
      message_lines 
LIKE TABLE OF swr_messag,
      message_struct 
LIKE TABLE OF swr_mstruc,
      subcontainer_bor_objects 
LIKE TABLE OF swr_cont.

swc_get_table container 
'REASON' reason.
swc_get_element container 
'WORKITEMID' workitemid.

* Read the work item container from the work item ID
CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
  
EXPORTING
    workitem_id              = workitemid
    
language                 = sy-langu
    user                     = sy-uname
  
IMPORTING
    return_code              = return_code
    ifs_xml_container        = ifs_xml_container
    ifs_xml_container_schema = ifs_xml_container_schema
  
TABLES
    simple_container         = simple_container
    message_lines            = message_lines
    message_struct           = message_struct
    subcontainer_bor_objects = subcontainer_bor_objects
    subcontainer_all_objects = subcontainer_all_objects.

* Initialize
lv_no_att = 
0.

* Read the _ATTACH_OBJECTS element
LOOP AT subcontainer_all_objects INTO lv_wa_reason
                                 
WHERE element = '_ATTACH_OBJECTS'.
  lv_no_att = lv_no_att + 
1.
  document_id = lv_wa_reason-
value.

ENDLOOP.

* Read the SOFM Document
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
  
EXPORTING
    document_id    = document_id
  
TABLES
    object_content = object_content.

* Pass the text to the exporting parameter
IF sy-subrc = 0.
  
READ TABLE object_content INTO reason_txt INDEX 1.
  
SHIFT reason_txt BY 5 PLACES LEFT.
  swc_set_element container 
'REASON_TXT' reason_txt.
ENDIF.

end_method.

Note that the method we created, READ_REJECTION_REASON can be executed even without instantiating the BOR

The above method will be called in a standard task and called in the REJECT branch of the user decision step.

Click here to continue..

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image