服务分类,层数不限制。
from 下层 找 上层。
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(PROCESS_TYPE) TYPE CRMT_PROCESS_TYPE_DB OPTIONAL
*" VALUE(CAT_ID) TYPE CRM_ERMS_CAT_CA_ID OPTIONAL
*" EXPORTING
*" REFERENCE(ZZAFLD0000AS) TYPE ZADTEL0000SL
*" REFERENCE(ZZAFLD0000AT) TYPE ZADTEL0000SR
*" REFERENCE(ZZAFLD0000AU) TYPE ZADTEL0000SX
*"----------------------------------------------------------------------
DATA le_obj_guid TYPE crm_erms_cat_guid .
DATA le_cat_guid TYPE crm_erms_cat_guid .
DATA le_asp_guid TYPE crm_erms_cat_guid .
DATA subject_profile TYPE crmt_subject_profile .
DATA asp_id TYPE crm_erms_cat_as_id .
DATA pare_guid TYPE crm_erms_cat_guid .
DATA index TYPE i .
DATA lt_hierarchy LIKE crmc_erms_cat_hi OCCURS 0 WITH HEADER LINE .
DATA ge_timest TYPE crm_erms_cat_timestamp .
DATA ge_timezone TYPE systzonlo.
DATA BEGIN OF t_cat_id OCCURS 0.
DATA index TYPE i .
DATA cat_id TYPE crm_erms_cat_ca_id .
DATA cat_guid TYPE crm_erms_cat_guid .
DATA END OF t_cat_id .
*************************************************************************
CHECK cat_id IS NOT INITIAL .
CLEAR: subject_profile,le_obj_guid,le_asp_guid,le_cat_guid.
SELECT SINGLE subject_profile INTO subject_profile
FROM crmc_service_h
WHERE process_type = process_type .
CHECK subject_profile IS NOT INITIAL .
SELECT SINGLE obj_guid INTO le_obj_guid
FROM crmc_erms_cat_ok
WHERE obj_extkey = subject_profile .
CHECK le_obj_guid IS NOT INITIAL .
* 获取当前用户的时区
CALL FUNCTION 'TZON_GET_USER_TIMEZONE'
EXPORTING
if_username = sy-uname
IMPORTING
ef_timezone = ge_timezone
EXCEPTIONS
no_timezone_customizing = 1
no_valid_user = 2
OTHERS = 3.
CONVERT DATE sy-datum TIME sy-uzeit
INTO TIME STAMP ge_timest TIME ZONE ge_timezone.
SELECT SINGLE a~asp_guid a~asp_id
INTO (le_asp_guid,asp_id)
FROM crmc_erms_cat_as AS a JOIN crmc_erms_cat_ln AS b
ON a~asp_guid = b~cat_guid
WHERE a~val_from <= ge_timest AND a~val_to >= ge_timest
AND b~obj_guid = le_obj_guid AND b~lnk_type = 'IS_SUPRF'.
CHECK le_asp_guid IS NOT INITIAL .
SELECT SINGLE cat_guid INTO le_cat_guid
FROM crmc_erms_cat_ca
WHERE cat_id = cat_id AND asp_guid = le_asp_guid .
CHECK le_cat_guid IS NOT INITIAL .
REFRESH t_cat_id . CLEAR t_cat_id .
index = 1 .
t_cat_id-index = index .
t_cat_id-cat_id = cat_id .
t_cat_id-cat_guid = le_cat_guid .
APPEND t_cat_id . CLEAR t_cat_id .
DO 4 TIMES.
CLEAR pare_guid .
SELECT SINGLE pare_guid INTO pare_guid
FROM crmc_erms_cat_hi
WHERE tree_type = 'CAT'
AND node_guid = le_cat_guid .
IF sy-subrc = 0 AND pare_guid <> le_asp_guid.
index = index + 1 .
t_cat_id-index = index .
t_cat_id-cat_guid = pare_guid .
SELECT SINGLE cat_id INTO t_cat_id-cat_id
FROM crmc_erms_cat_ca
WHERE cat_guid = t_cat_id-cat_guid AND asp_guid = le_asp_guid .
APPEND t_cat_id . CLEAR t_cat_id .
le_cat_guid = pare_guid .
ENDIF.
IF pare_guid = le_asp_guid.
EXIT .
ENDIF.
ENDDO.
SORT t_cat_id BY index DESCENDING .
CLEAR index .
LOOP AT t_cat_id.
index = index + 1 .
CASE index.
WHEN '1'.
zzafld0000as = t_cat_id-cat_id .
WHEN '2'.
zzafld0000at = t_cat_id-cat_id .
WHEN '3'.
zzafld0000au = t_cat_id-cat_id .
ENDCASE.
ENDLOOP.
阅读(927) | 评论(0) | 转发(0) |