分类: Web开发
2015-01-12 11:31:05
REPORT zcs0024_local.
TYPE-POOLS: slis.
DATA: g_repid LIKE sy-repid.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv .
DATA: gs_fieldcat TYPE slis_fieldcat_alv .
DATA: gs_layout TYPE slis_layout_alv.
DATA: gs_variant LIKE disvariant.
DATA: i_t_params TYPE rsti_t_par .
DATA: i_s_params TYPE rsparams .
TABLES: ztcs1038,ztcs1023,ztcs2008 .
DATA: lt_t1038 LIKE ztcs1038 OCCURS 0 WITH HEADER LINE .
DATA: lt_t1023 LIKE ztcs1023 OCCURS 0 WITH HEADER LINE .
DATA: lt_jest LIKE crm_jest OCCURS 0 WITH HEADER LINE .
DATA: lt_order LIKE zszcs0024 OCCURS 0 WITH HEADER LINE .
DATA: lt_header_guid TYPE crmt_object_guid_tab,
lt_orderadm_h TYPE TABLE OF crmd_orderadm_h,
ls_orderadm_h TYPE crmd_orderadm_h,
lt_status TYPE crmt_status_wrkt,
ls_status TYPE crmt_status_wrk,
lt_requested_objects TYPE crmt_object_name_tab.
INCLUDE crm_object_names_con.
DATA: BEGIN OF lt_guid OCCURS 0,
guid TYPE crmt_object_guid,
END OF lt_guid .
DATA: lt_return TYPE bapiret2_t ,
ls_return TYPE bapiret2.
*----------------------------------------------------------------------*
* 选择屏幕
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-001.
SELECT-OPTIONS r_time FOR ztcs1038-order_date.
PARAMETERS: r1 RADIOBUTTON GROUP rad1.
SELECT-OPTIONS r_no1 FOR ztcs1038-order_no.
PARAMETERS: r2 RADIOBUTTON GROUP rad1.
SELECT-OPTIONS r_no2 FOR ztcs1023-object_id.
SELECT-OPTIONS r_pty2 FOR ztcs1023-process_type.
SELECT-OPTIONS r_bp2 FOR ztcs1023-media_org.
SELECT-OPTIONS r_crdat FOR ztcs1023-crdat.
SELECT-OPTIONS r_crby FOR ztcs1023-created_by.
PARAMETERS: r3 RADIOBUTTON GROUP rad1.
SELECT-OPTIONS r_no3 FOR ztcs2008-object_id.
SELECT-OPTIONS r_pty3 FOR ztcs2008-process_type.
SELECT-OPTIONS r_bp3 FOR ztcs2008-zcus_channel.
PARAMETERS: r4 RADIOBUTTON GROUP rad1.
SELECT-OPTIONS r_no4 FOR ztcs2008-object_id.
SELECT-OPTIONS r_pty4 FOR ztcs2008-process_type.
SELECT-OPTIONS r_crdat4 FOR ztcs1023-crdat.
SELECT-OPTIONS r_crby4 FOR ztcs1023-created_by.
SELECTION-SCREEN END OF BLOCK blk2.
INITIALIZATION.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR r_time-low.
PERFORM timeset_value_help CHANGING r_time-low ."打开文件
AT SELECTION-SCREEN ON VALUE-REQUEST FOR r_time-high.
PERFORM timeset_value_help CHANGING r_time-high ."打开文件
*----------------------------------------------------------------------*
* 处理流
*----------------------------------------------------------------------*
START-OF-SELECTION.
REFRESH: lt_header_guid,lt_guid .
IF r1 = 'X'.
REFRESH lt_t1038 .
SELECT * INTO TABLE lt_t1038
FROM ztcs1038
WHERE order_no IN r_no1
AND order_date IN r_time
AND created_flag = 'X' .
CHECK lt_t1038[] IS NOT INITIAL .
SELECT guid INTO TABLE lt_guid
FROM crmd_orderadm_h
FOR ALL ENTRIES IN lt_t1038
WHERE object_id = lt_t1038-object_id .
ELSEIF r2 = 'X'.
SELECT guid INTO TABLE lt_guid
FROM ztcs1023
WHERE object_id IN r_no2
AND process_type IN r_pty2
AND media_org IN r_bp2
AND created_at IN r_time
AND created_by IN r_crby
AND crdat IN r_crdat .
ELSEIF r3 = 'X' .
SELECT guid INTO TABLE lt_guid
FROM ztcs2008
WHERE object_id IN r_no3
AND process_type IN r_pty3
AND zcus_channel IN r_bp3
AND created_at IN r_time .
ELSEIF r4 = 'X' .
SELECT guid INTO TABLE lt_guid
FROM crmd_orderadm_h
WHERE object_id IN r_no4
AND process_type IN r_pty4
AND created_at IN r_time
AND created_by IN r_crby4
AND posting_date IN r_crdat4 ..
ENDIF.
CHECK lt_guid[] IS NOT INITIAL .
REFRESH lt_jest .
SELECT * INTO TABLE lt_jest
FROM crm_jest
FOR ALL ENTRIES IN lt_guid
WHERE objnr = lt_guid-guid
AND stat = 'I1030'
AND inact <> 'X'.
* LOOP AT lt_guid .
* INSERT lt_guid-guid INTO TABLE lt_header_guid.
* ENDLOOP.
* INSERT gc_object_name-orderadm_h INTO TABLE lt_requested_objects.
** INSERT gc_object_name-orderadm_i INTO TABLE lt_requested_objects.
* INSERT gc_object_name-status INTO TABLE lt_requested_objects.
*
* REFRESH:lt_status, lt_orderadm_h.
* CALL FUNCTION 'CRM_ORDER_READ'
* EXPORTING
* it_header_guid = lt_header_guid
* it_requested_objects = lt_requested_objects
** iv_mode = 'C'
* IMPORTING
* et_orderadm_h = lt_orderadm_h
* et_status = lt_status
* EXCEPTIONS
* document_not_found = 1
* error_occurred = 2
* document_locked = 3
* no_change_authority = 4
* no_display_authority = 5
* no_change_allowed = 6
* OTHERS = 7.
*
* DELETE lt_status WHERE kind <> 'A' .
* DELETE lt_status WHERE status <> 'I1030' .
* LOOP AT lt_status INTO ls_status.
CHECK lt_jest[] IS NOT INITIAL .
REFRESH lt_orderadm_h .
SELECT * INTO TABLE lt_orderadm_h
FROM crmd_orderadm_h
FOR ALL ENTRIES IN lt_jest
WHERE guid = lt_jest-objnr .
LOOP AT lt_jest .
REFRESH lt_return .
CALL FUNCTION 'ZFMTEST05'
EXPORTING
iv_guid = lt_jest-objnr
IMPORTING
et_return = lt_return.
DELETE lt_return WHERE type <> 'E' .
IF lt_return[] IS NOT INITIAL.
CLEAR: ls_orderadm_h,lt_order,ls_return .
lt_order-guid = lt_jest-objnr .
READ TABLE lt_orderadm_h INTO ls_orderadm_h WITH KEY guid = lt_jest-objnr.
lt_order-object_id = ls_orderadm_h-object_id .
lt_order-process_type = ls_orderadm_h-process_type .
LOOP AT lt_return INTO ls_return .
CONCATENATE lt_order-message ls_return-message INTO lt_order-message .
ENDLOOP.
CONDENSE lt_order-message .
APPEND lt_order .
ENDIF.
CLEAR lt_jest .
ENDLOOP.
END-OF-SELECTION.
gs_layout-zebra = 'X'.
gs_layout-cell_merge = 'X'.
gs_layout-colwidth_optimize = 'X'.
g_repid = sy-repid.
gs_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* i_background_id = 'ALV_BACKGROUND'
i_callback_pf_status_set = 'MENU_SET'
i_callback_user_command = 'USER_COMMAND'
i_callback_program = g_repid
i_structure_name = 'ZSZCS0024'
is_layout = gs_layout
TABLES
t_outtab = lt_order.
FORM menu_set USING lt_extab TYPE slis_t_extab.
DATA: ls_extab TYPE slis_extab.
SET PF-STATUS '101'. "定义屏幕状态,然后在里面定义自己的按钮
ENDFORM. "menu_set
FORM user_command USING ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE ucomm.
WHEN '&IC1'.
READ TABLE lt_order INDEX rs_selfield-tabindex .
REFRESH : i_t_params . CLEAR: i_s_params .
i_s_params-selname = 'IV_GUID' .
i_s_params-kind = 'S' .
i_s_params-sign = 'I' .
i_s_params-option = 'EQ' .
i_s_params-low = lt_order-guid .
APPEND i_s_params TO i_t_params .
SUBMIT crm_report_start AND RETURN WITH SELECTION-TABLE i_t_params.
ENDCASE.
ENDFORM. "execute_command
*&---------------------------------------------------------------------*
*& Form TIMESET_VALUE_HELP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_R_DATE_LOW text
*----------------------------------------------------------------------*
FORM timeset_value_help CHANGING p_r_date_low.
DATA lv_timeset TYPE tztf_io_field .
DATA lv_date TYPE d .
DATA lv_time TYPE t .
CLEAR: lv_timeset,lv_date,lv_time .
CALL FUNCTION 'TZ_TIMEFIELD_F4_DISP_PROFILE'
EXPORTING
if_profile = 'ZDATE_TIME' "数据元素 TZTF_IO COMT_CREATED_AT_USR
if_type = 'DATE_FROM' "随便找一个SRV_APPT_BEG
IMPORTING
ef_timefield = lv_timeset.
lv_date+0(4) = lv_timeset+0(4).
lv_date+4(2) = lv_timeset+5(2).
lv_date+6(2) = lv_timeset+8(2).
lv_time+0(2) = lv_timeset+11(2).
lv_time+2(2) = lv_timeset+14(2).
lv_time+4(2) = '00'.
CONVERT DATE lv_date TIME lv_time
INTO TIME STAMP p_r_date_low TIME ZONE sy-zonlo.
ENDFORM. " TIMESET_VALUE_HELP
函数
SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
} FUNCTION zfmtest05.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" REFERENCE(IV_GUID) TYPE CRMT_OBJECT_GUID OPTIONAL
*" EXPORTING
*" VALUE(ET_RETURN) TYPE BAPIRET2_T
*"----------------------------------------------------------------------
DATA: lv_object_guid TYPE crmt_object_guid.
DATA: mtext TYPE string.
DATA: lt_msg_handle TYPE bal_t_msgh,
ls_applog_info TYPE crmt_bsp_applog.
DATA: lt_msg_info TYPE crmt_msg_info_tab,
ls_msg_info TYPE bal_s_msg,
lv_message_text(100) TYPE c,
ls_msg_handle TYPE balmsghndl,
lv_ref_object TYPE crmt_ref_obj_text.
DATA: et_message TYPE crmt_fm_acl_ref_err,
ls_message LIKE LINE OF et_message.
DATA: lt_lines TYPE tsftext ,
ls_line TYPE tline,
ls_help TYPE help_info .
*******************************************************************
CHECK iv_guid IS NOT INITIAL .
CALL FUNCTION 'CRM_MESSAGES_DISPLAY'
EXPORTING
iv_document_number = iv_guid
iv_in_transaction = abap_true
iv_subscreen_set_data = abap_true
iv_surpress_output = abap_true
iv_amodal = abap_false
IMPORTING
et_msg_handle = lt_msg_handle
EXCEPTIONS
OTHERS = 99.
* No messages found -> Leave with no action
LOOP AT lt_msg_handle INTO ls_msg_handle.
CLEAR: ls_msg_info,lv_ref_object,ls_applog_info,mtext.
CALL FUNCTION 'CRM_MESSAGES_GET_MSG_INFO'
EXPORTING
is_msg_handle = ls_msg_handle
IMPORTING
es_msg = ls_msg_info
ev_ref_object = lv_ref_object
EXCEPTIONS
not_found = 1
wrong_context_structure = 2
data_error = 3.
CHECK sy-subrc = 0.
CHECK ls_msg_info-msgty = 'E' .
IF ls_msg_info-msgid = 'CRM_ORDER_MISC' AND ls_msg_info-msgno = '020'.
CLEAR:lt_lines,ls_help,ls_line .
CALL FUNCTION 'CRM_MESSAGES_GET_LONGTEXT'
EXPORTING
is_msgh = ls_msg_handle
iv_language = sy-langu
iv_add_technical_info = 'X'
IMPORTING
et_lines = lt_lines
es_help = ls_help.
ls_message-type = 'E' .
LOOP AT lt_lines INTO ls_line WHERE tdformat = 'B1' .
IF ls_line-tdline CS '通知 E'.
CONCATENATE ls_message-message ls_line-tdline INTO ls_message-message .
ENDIF.
ENDLOOP.
CONDENSE ls_message-message .
APPEND ls_message TO et_message.
ELSE.
MESSAGE ID ls_msg_info-msgid
TYPE ls_msg_info-msgty
NUMBER ls_msg_info-msgno
INTO mtext
WITH ls_msg_info-msgv1
ls_msg_info-msgv2
ls_msg_info-msgv3
ls_msg_info-msgv4.
MOVE-CORRESPONDING ls_msg_info TO ls_message.
ls_message-type = ls_msg_info-msgty.
ls_message-id = ls_msg_info-msgid.
ls_message-number = ls_msg_info-msgno.
CONCATENATE lv_ref_object mtext INTO ls_message-message.
* ls_message-message = mtext.
ls_message-message_v1 = ls_msg_info-msgv1.
ls_message-message_v2 = ls_msg_info-msgv2.
ls_message-message_v3 = ls_msg_info-msgv3.
ls_message-message_v4 = ls_msg_info-msgv4.
APPEND ls_message TO et_message.
ENDIF.
ENDLOOP.
APPEND LINES OF et_message TO et_return.
ENDFUNCTION.