In the first line of this post I want to warn you — this is my first blog post on SCN, and ask you to forgive me for my terrible English. My native language is C#. 🙂
So okay, recently I had a problem to get approval data for HCM Processes & Forms. It means, I needed data about who, when and what activity on the form was done. In the end, I needed a kind of such data:
From: Arthur Dent, Hitchhiker [process initiator]
To: Slartibartfast, Earth Mk. II Lead Designer [current processor]
Name | Position | Activity | Date |
---|---|---|---|
Arthur Dent | Hitchhiker | PROCESSED | 31.08.2012 |
Zaphod Beeblebrox | Galactic President | APPROVED | 01.09.2012 |
Vogon Jeltz | Prostetnic | APPROVED | 01.09.2012 |
Questular Rontok | Vice President of the Galaxy | APPROVED | 02.09.2012 |
So I want to share with you ABAP code, that processes HCM P&F by refernece ID number and processes this data.
Actual data is stored in variables app_name — current approvers name, app_pos — current approver position and table t_approval — the processing data. Process ref. id must be assigned to variable in_refid.
I hope it would help you.
Enjoy!
* BUGS, HEX & SOURCE CONTROL
* Kawabanga!
TABLES: t5asrprocesses, t5asrscenarios, t5asrsteps.
TYPES:
BEGIN OF struct_approval_data,
name TYPE char255,
position TYPE char255,
date TYPE d,
reaction TYPE char255,
END OF struct_approval_data.
DATA: t_t5asrpocesses LIKE t5asrprocesses,
t_t5asrscenarios LIKE t5asrscenarios OCCURS 0,
w_t5asrscenarios LIKE LINE OF t_t5asrscenarios,
w_t5asrsteps LIKE t5asrsteps,
in_refid LIKE t5asrprocesses-reference_number,
t_approval TYPE struct_approval_data OCCURS 0,
w_approval TYPE struct_approval_data,
app_name TYPE char255,
app_pos TYPE char255,
gt_return TYPE bapireturn,
gt_org LIKE bapip0001b OCCURS 0 WITH HEADER LINE,
lv_userid TYPE bapiemplb-userid.
* in_refid = '000000000035'.
* Dirty hack
SELECT SINGLE * INTO t_t5asrpocesses FROM t5asrprocesses WHERE reference_number = in_refid.
SELECT * INTO w_t5asrscenarios FROM t5asrscenarios WHERE parent_process = t_t5asrpocesses-case_guid.
APPEND w_t5asrscenarios TO t_t5asrscenarios.
ENDSELECT.
SORT t_t5asrscenarios DESCENDING.
* A kind of magic
LOOP AT t_t5asrscenarios INTO w_t5asrscenarios.
SELECT * FROM t5asrsteps INTO w_t5asrsteps WHERE parent_scenario = w_t5asrscenarios-case_guid.
MOVE w_t5asrsteps-processed_by TO lv_userid.
CALL FUNCTION 'BAPI_EMPLOYEE_GETDATA'
EXPORTING
userid = lv_userid
IMPORTING
return = gt_return
TABLES
org_assignment = gt_org.
IF ( w_t5asrsteps-proc_status ne '').
w_approval-name = gt_org-name.
w_approval-position = gt_org-postxt.
w_approval-date = w_t5asrsteps-completion_date.
w_approval-reaction = w_t5asrsteps-proc_status.
APPEND w_approval TO t_approval.
ELSE.
app_name = gt_org-name.
app_pos = gt_org-postxt.
ENDIF.
ENDSELECT.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Subject | Kudos |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User | Count |
---|---|
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |