<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<workitems>
<tt:loop name= "line" ref=".ROOT">
<order>
<tt:value ref="$line.order"/>
</order>
<req>
<tt:value ref="$line.req"/>
</req>
<netvalue>
<tt:value ref="$line.nvalue"/>
</netvalue>
<workitem>
<id>
<tt:value ref="$line.wi_id"/>
</id>
<title>
<tt:value ref="$line.wi_title"/>
</title>
<description>
<tt:loop name="html" ref="$line.wi_text">
<tt:value ref="$html.TEXTLINE"/>
</tt:loop>
</description>
<decisions>
<tt:loop name="dec_line" ref="$line.decisions">
<decision>
<key>
<tt:value ref="$dec_line.ALTKEY"/>
</key>
<text>
<tt:value ref="$dec_line.ALTTEXT"/>
</text>
</decision>
</tt:loop>
</decisions>
</workitem>
</tt:loop>
</workitems>
</tt:template>
</tt:transform>
Create a SICF Service Name : zmyinbox
TYPES: BEGIN OF ty_wi_info,
order type string,
req type string,
supplier type string,
* quan type string,
nvalue type string,
wi_id TYPE swr_struct-workitemid,
wi_title TYPE swr_wihdr-wi_text,
wi_text TYPE STANDARD TABLE OF swr_txtlin WITH NON-UNIQUE DEFAULT KEY,
wi_htext TYPE STANDARD TABLE OF swr_txtlin WITH NON-UNIQUE DEFAULT KEY,
decisions TYPE STANDARD TABLE OF swr_decialts WITH NON-UNIQUE DEFAULT KEY,
END OF ty_wi_info.
TYPES: BEGIN OF local_wi2obj.
TYPES: wi_id TYPE sww_wiid.
TYPES: catid TYPE sibfcatid.
TYPES: instid TYPE sibfboriid.
TYPES: typeid TYPE sibftypeid.
TYPES: wi_reltype TYPE sww_reltyp.
TYPES: removed TYPE sww_relrmv.
TYPES: END OF local_wi2obj.
types : BEGIN OF ty_po,
ebeln type ekko-ebeln,
lifnr type ekko-lifnr,
RLWRT type ekko-RLWRT,
END OF ty_po .
types : BEGIN OF ty_po1,
ebeln type ekko-ebeln,
wi_id TYPE swr_struct-workitemid,
wi_text type WITEXT,
END OF ty_po1.
data : lt_po type TABLE OF ty_po,
lt_pod type TABLE OF ty_po1,
ls_po type ty_po,
ls_po1 type ty_Po1.
DATA: lt_wi2obj TYPE STANDARD TABLE OF local_wi2obj.
DATA: ls_wi2obj LIKE LINE OF lt_wi2obj.
DATA: lt_all_ids TYPE swfgpaciidtab,
l_subrc TYPE sysubrc,
l_aci_id TYPE swfgpaciid,
lt_uwlitems TYPE uwlitemlist,
lt_filter TYPE STANDARD TABLE OF swr_task,
ls_filter TYPE swr_task,
lt_sim_cont TYPE STANDARD TABLE OF swr_cont.
DATA: lv_param TYPE string,
lv_path TYPE string,
l_rc TYPE sy-subrc,
lv_split_tab TYPE TABLE OF string,
lv_param1 TYPE string,
lv_param2 TYPE string,
lv_res_xml TYPE xstring,
dec_key TYPE swr_decikey,
dec_wiid TYPE swr_struct-workitemid,
wi_text TYPE swr_wihdr-wi_text,
lv_nodes TYPE TABLE OF swr_decialts,
ls_nodes type swr_decialts,
items TYPE TABLE OF swr_wihdr,
t_wi_info TYPE TABLE OF ty_wi_info,
wi_info TYPE ty_wi_info,
lv_id type SWR_STRUCT-WORKITEMID,
lv_user type sy-uname,
lv_action type c.
DATA: lh_inbox TYPE REF TO cl_wapi_mobile_inbox.
DATA: lt_inbox TYPE cl_wapi_mobile_inbox=>table_inbox_header.
DATA: ls_inbox LIKE LINE OF lt_inbox.
DATA: ls_decision_alternatives TYPE cl_wapi_mobile_user_decision=>workitem_header_decision.
DATA: lt_wiis TYPE cl_wapi_mobile_user_decision=>table_workitem_header.
DATA: ls_wiis LIKE LINE OF lt_wiis.
DATA: l_fail TYPE xfeld.
DATA: lt_alternatives TYPE STANDARD TABLE OF swr_decialts.
DATA: m_user_decision TYPE REF TO cl_wapi_mobile_user_decision.
DATA text TYPE string .
DATA writer TYPE REF TO cl_sxml_string_writer.
DATA json TYPE xstring.
DATA: m_user TYPE syuname.
DATA: m_language TYPE sylangu,
lv_text type SWR_TXTLIN.
FIELD-SYMBOLS: <item> LIKE LINE OF lt_inbox,"items,
<uwlitems> TYPE UWLITEM,
<PO> type ty_po1.
data : lt_form_fields TYPE tihttpnvp.
FIELD-SYMBOLS:
<FS_form_field> TYPE ihttpnvp,
<fs_wi_info> type ty_wi_info.
CONSTANTS : lc_f(1) TYPE c VALUE 'F',
lc_completed(9) TYPE c VALUE 'COMPLETED',
lc_cancelled(9) TYPE c VALUE 'CANCELLED',
lc_error(5) TYPE c VALUE 'ERROR',
lc_bus2012 TYPE swotobjid-objtype VALUE 'BUS2012'.
CALL METHOD server->request->get_form_fields( CHANGING fields = lt_form_fields ).
READ TABLE lt_form_fields ASSIGNING <FS_form_field> WITH KEY name = 'user' ."co_ff_clear_cache.
IF sy-subrc = 0.
lv_user = <FS_form_field>-value.
ENDIF.
READ TABLE lt_form_fields ASSIGNING <fs_form_field> WITH KEY name = 'task' ."co_ff_clear_cache.
IF sy-subrc = 0.
* lv_rev = <fs_form_field>-value.
ENDIF.
READ TABLE lt_form_fields ASSIGNING <fs_form_field> WITH KEY name = 'action' ."co_ff_clear_cache.
IF sy-subrc = 0.
lv_param = <fs_form_field>-value.
ENDIF.
READ TABLE lt_form_fields ASSIGNING <fs_form_field> WITH KEY name = 'WI' ."co_ff_clear_cache.
IF sy-subrc = 0.
lv_id = <fs_form_field>-value.
ENDIF.
READ TABLE lt_form_fields ASSIGNING <fs_form_field> WITH KEY name = 'DEC' ."co_ff_clear_cache.
IF sy-subrc = 0.
lv_param2 = <fs_form_field>-value.
ENDIF.
TRANSLATE lv_param TO UPPER CASE.
IF lv_param <> 'GET' AND lv_param <> 'PUT'.
CALL METHOD server->response->set_header_field(
name = 'Allow' value = 'GET, PUT' ).
CALL METHOD server->response->set_status( code = '405' reason = 'Method not allowed' ).
EXIT.
ENDIF.
CASE lv_param. "Get user decisions to make…
WHEN 'GET'.
TRY.
lh_inbox = cl_wapi_mobile_inbox=>get_instance(
im_user = lv_user
im_language = m_language
).
lt_inbox = lh_inbox->get_current_inbox( ).
CATCH cx_wapi_exception.
CALL METHOD cl_aunit_assert=>fail
EXPORTING
msg = 'TEST_GET_ALTERNATIVES_VIA_WORKITEM: Programm Error ' "#EC NOTEXT
quit = cl_aunit_assert=>method.
ENDTRY.
if lt_inbox IS NOT INITIAL.
SELECT wi_id catid instid typeid wi_reltype removed FROM sww_wi2obj INTO TABLE lt_wi2obj
FOR ALL ENTRIES IN lt_inbox
WHERE wi_id EQ lt_inbox-wi_id.
loop at lt_inbox ASSIGNING <item> WHERE workflow_id = 'WSXXXXXX'. "INTO ls_wi2obj.
READ TABLE lt_wi2obj INTO ls_wi2obj with key wi_id = <item>-wi_id.
if sy-subrc is INITIAL.
ls_po1-ebeln = ls_wi2obj-instid.
ls_po1-wi_id = ls_wi2obj-wi_id.
ls_po1-wi_text = <item>-title.
APPEND ls_po1 to lt_pod.
endif.
ENDLOOP.
if lt_pod is not INITIAL .
SELECT ebeln lifnr rlwrt from ekko INTO TABLE lt_po
FOR ALL ENTRIES IN lt_pod
WHERE ebeln = lt_pod-ebeln.
endif.
endif .
CLEAR: l_rc, wi_info, wi_text, lv_nodes.
LOOP AT lt_pod ASSIGNING <po> . "WHERE wi_aagent = sy-uname.
lv_id = <po>-wi_id.
wi_text = <po>-wi_text.
lv_text = <po>-wi_text.
clear : lv_nodes, wi_info-decisions.
READ TABLE lt_po INTO ls_po with key ebeln = <po>-ebeln.
if sy-subrc is INITIAL.
wi_info-order = ls_po-ebeln.
wi_info-nvalue = ls_po-rlwrt.
wi_info-supplier = ls_po-lifnr.
wi_info-wi_id = <po>-wi_id.
ls_nodes-ALTKEY = '0001'.
ls_nodes-ALTTEXT = 'APPROVE'.
APPEND ls_nodes to lv_nodes.
ls_nodes-ALTKEY = '0002'.
ls_nodes-ALTTEXT = 'Reject'.
APPEND ls_nodes to lv_nodes.
wi_info-wi_title = wi_text.
wi_info-decisions = lv_nodes.
CLEAR l_rc.
CALL FUNCTION 'SAP_WAPI_WORKITEM_DESCRIPTION'
EXPORTING
workitem_id = lv_id
IMPORTING
return_code = l_rc
TABLES
text_lines = wi_info-wi_text
html_text_lines = wi_info-wi_htext.
APPEND wi_info TO t_wi_info.
endif.
ENDLOOP.
* if lv_format is INITIAL.
CALL TRANSFORMATION ZMY_INBOX
SOURCE root = t_wi_info
RESULT XML lv_res_xml.
CALL METHOD server->response->set_header_field(
name = 'Content-Type'
value = 'text/xml; charset=utf-8' ).
CALL METHOD server->response->set_data( data = lv_res_xml ).
CALL METHOD server->response->set_status( code = '200' reason = 'OK' ).
WHEN 'PUT'.
dec_key = lv_param2.
dec_wiid = lv_id .
CLEAR l_rc.
CALL FUNCTION 'SAP_WAPI_DECISION_COMPLETE'
EXPORTING
workitem_id = dec_wiid
decision_key = dec_key
IMPORTING
return_code = l_rc.
IF l_rc <> 0.
CALL METHOD server->response->set_status( code = '500' reason = 'Error (RC <> 0' ).
ELSE.
CALL METHOD server->response->set_status( code = '200' reason = 'OK' ).
ENDIF.
ENDCASE.
<?xml version="1.0" encoding="utf-8" ?>
- <workitems>
<order>6510249899</order>
<req />
<netvalue>141599.90</netvalue>
- <workitem>
<id>000002787012</id>
<title>The Purchasing Document 6510249899 has been approved</title>
<description>The Purchasing Document 6510249899 created by MN
.</description>
- <decisions>
- <decision>
<key>0001</key>
<text>APPROVE</text>
</decision>
- <decision>
<key>0002</key>
<text>Reject</text>
</decision>
</decisions>
</workitem>
<order>4510249902</order>
<req />
<netvalue>200000000.00</netvalue>
- <workitem>
<id>000002787059</id>
<title>The Purchasing Document 6510249902 has been approved</title>
<description>The Purchasing Document 6510249899 created by nm
.</description>
- <decisions>
- <decision>
<key>0001</key>
<text>APPROVE</text>
</decision>
- <decision>
<key>0002</key>
<text>Reject</text>
</decision>
</decisions>
</workitem>
<order>4510249950</order>
<req />
<netvalue>1000000.00</netvalue>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.