Shopping Cart Data Extract (Dale Brown)
Magalhaes, Marcia
marcia.magalhaes at ocps.net
Fri Apr 1 10:06:46 EDT 2011
Dale, below is the code I wrote to get the approval levels and approvers.
*&---------------------------------------------------------------------*
*& Report ZGETAPPROVERS
*&---------------------------------------------------------------------*
REPORT ZGETAPPROVERS.
* Data declarations
* Internal table contains shopping carts that are approved
data: begin of gt_sc_approved occurs 0,
sc_no like crmd_orderadm_h-object_id ,
guid like crmd_orderadm_h-guid,
created_by type crmt_created_by,
posting_date like sy-datum,
description like crmd_orderadm_h-description,
status like tj02t-txt30,
end of gt_sc_approved.
* Internal table for approved shopping carts with each level of approval
data: begin of gt_sc_apprv_all_levels occurs 0,
wi_id like swwwihead-wi_id,
top_wi_id like swwwihead-top_wi_id,
wi_rh_task like swwwihead-wi_rh_task,
guid like crmd_orderadm_h-guid,
sc_no like crmd_orderadm_h-object_id ,
created_by type crmt_created_by,
posting_date like sy-datum,
description like crmd_orderadm_h-description,
resolver_name like /sapsrm/d_wf_003-resolver_name,
wi_aed like swwwihead-wi_aed, "Date approval was processed
* wi_ct LIKE swwwihead-wi_ct,
end of gt_sc_apprv_all_levels.
START-OF-SELECTION.
sort gt_sc_approved by sc_no.
loop at gt_sc_approved.
move gt_sc_approved to lt_sc_appr.
at new sc_no. "Get SC from first line only
refresh: lt_sww_wi2obj, gt_sc_apprv_all_levels.
clear: lt_sww_wi2obj, gt_sc_apprv_all_levels.
* Get work item ID from the workflow
select * from sww_wi2obj
into table lt_sww_wi2obj
where instid = lt_sc_appr-sc_no
and catid = 'BO'.
perform get_levels tables lt_sww_wi2obj using lt_sc_appr.
endat.
endloop.
*&---------------------------------------------------------------------*
*& Form GET_LEVELS
*&---------------------------------------------------------------------*
form GET_LEVELS tables pt_sww_wi2obj structure sww_wi2obj
using p_sc_appr.
data: l_swwwihead like swwwihead,
l_rslv like /sapsrm/c_wf_l-resolver_name,
l_eval_id like /sapsrm/c_wf_l-evaluation_id,
lvl_stat like /sapsrm/d_wf_003-level_status,
l_scheme like /sapsrm/d_wf_000-scheme,
idx like sy-tabix value 1,
l_first_lvl_id like /sapsrm/d_wf_000-first_lvl_id,
l_next_lvl_id like /sapsrm/d_wf_003-next_level_id,
l_next_id like /sapsrm/d_wf_003-next_level_id.
* For each approval level, get the workflow details
sort pt_sww_wi2obj by wi_id.
loop at pt_sww_wi2obj.
clear: l_first_lvl_id, l_next_lvl_id.
* First read the header table for all work items
call function 'BBP_PDH_WFL_WI_DETAILS_GET'
exporting
iv_workitem_id = pt_sww_wi2obj-wi_id
importing
es_wi_header = l_swwwihead
* EV_WI_TASK =
* EV_WI_WEBTA =
* TABLES
* ET_WI_AGENTS =
exceptions
wi_read_failed = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
continue.
endif.
* Move the workflow related fields
move-corresponding p_sc_appr to gt_sc_apprv_all_levels.
move: l_swwwihead-wi_aed to gt_sc_apprv_all_levels-wi_aed,
l_swwwihead-wi_id to gt_sc_apprv_all_levels-wi_id,
l_swwwihead-top_wi_id to gt_sc_apprv_all_levels-top_wi_id,
l_swwwihead-wi_rh_task to gt_sc_apprv_all_levels-wi_rh_task.
append gt_sc_apprv_all_levels. clear gt_sc_apprv_all_levels.
endloop.
* Now determine what each level of approval represents, that is, the
* resolver_name - bookkeeper, manager, budget, etc
sort gt_sc_apprv_all_levels by wi_id.
* Get the first level of approval
select single scheme first_lvl_id
from /sapsrm/d_wf_000
into (l_scheme, l_first_lvl_id)
where document_type = 'BUS2121' "Or BUS2201 for POs
and workflow_inst_id = l_swwwihead-top_wi_id.
move l_first_lvl_id to l_next_id.
while l_next_id is not initial.
clear: l_rslv, lvl_stat, l_next_lvl_id.
* Get resolver for each level
select single resolver_name level_status next_level_id
from /sapsrm/d_wf_003
into (l_rslv, lvl_stat, l_next_lvl_id)
where id = l_next_id.
move l_next_lvl_id to l_next_id.
* COMPLETED statuses indicate a valid and completed
* approval level for the shopping cart
if lvl_stat = 'COMPLETED'.
read table gt_sc_apprv_all_levels index idx.
if sy-subrc ne 0.
clear l_next_id.
endif.
move l_rslv to gt_sc_apprv_all_levels-resolver_name.
modify gt_sc_apprv_all_levels index idx.
add 1 to idx.
endif.
endwhile.
endform. " GET_LEVELS
Marcia Magalhaes
Orange County Public Schools
Orlando, FL
----------------------------------------------------------------------
The information contained in this e-mail message is intended solely for
the recipient(s) and may contain privileged information. Tampering with
or altering the contents of this message is prohibited. This information
is the same as any written document and may be subject to all rules
governing public information according to Florida Statutes. Any message
that falls under Chapter 119 shall not be altered in a manner that
misrepresents the activities of Orange County Public Schools.
[References: Florida State Constitution I.24, Florida State Statutes
Chapter 119, and OCPS Management Directive A-9.] If you have received
this message in error, or are not the named recipient notify the sender
and delete this message from your computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20110401/f9cb42ed/attachment.htm
More information about the SAP-WUG
mailing list