Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7202620
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2007-12-31 18:12:00

 

 

REPORT z_barry_job_list .

TYPE-POOLS: slis.
TABLES:p0105_af,btch2170.
DATA: gd_fieldcat TYPE slis_t_fieldcat_alv.
DATA: sla TYPE slis_layout_alv ,
      ivariant LIKE disvariant,
      i_repid LIKE sy-repid ,
      i_excluding TYPE slis_t_extab.

DATA: BEGIN OF in_wa  .
        INCLUDE STRUCTURE btcselect.
DATA: END OF in_wa.

DATA: BEGIN OF itab OCCURS 0 .
        INCLUDE STRUCTURE tbtcjob_bk.
DATA: END OF itab.

DATA:   it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
        it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
        it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
        it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
        gd_cnt TYPE i,
        gd_sent_all(1) TYPE c,
        gd_doc_data LIKE sodocchgi1,
        gd_error TYPE sy-subrc.

DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                WITH HEADER LINE.
PARAMETERS : p_user LIKE btch2170-username OBLIGATORY DEFAULT sy-uname .
SELECT-OPTIONS: s_date FOR btch2170-from_date NO-EXTENSION
                                                    DEFAULT sy-datum ,
                s_addr FOR p0105_af-email DEFAULT .

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS p_pre AS CHECKBOX DEFAULT 'X' .
SELECTION-SCREEN COMMENT (10) text-001 FOR FIELD p_pre .
PARAMETERS p_sch AS CHECKBOX DEFAULT 'X' .
SELECTION-SCREEN COMMENT (10) text-002 FOR FIELD p_sch .
PARAMETERS p_rea AS CHECKBOX  DEFAULT 'X'.
SELECTION-SCREEN COMMENT (10) text-003 FOR FIELD p_rea .
PARAMETERS p_run AS CHECKBOX  DEFAULT 'X'.
SELECTION-SCREEN COMMENT (10) text-004 FOR FIELD p_run .
PARAMETERS p_fin AS CHECKBOX  DEFAULT 'X'.
SELECTION-SCREEN COMMENT (10) text-005 FOR FIELD p_fin .
PARAMETERS p_abo AS CHECKBOX  DEFAULT 'X'.
SELECTION-SCREEN COMMENT (10) text-006 FOR FIELD p_abo .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
  PERFORM getdata.
  PERFORM outdata.
*  PERFORM send_mail.

*---------------------------------------------------------------------*
*       FORM getdata                                                  *
*---------------------------------------------------------------------*
FORM getdata.
  in_wa-jobname = '*'.
  in_wa-username = p_user .
  in_wa-from_date = s_date-low.
  in_wa-to_date = s_date-high .

***Job的状态
  in_wa-prelim = p_pre.
  in_wa-schedul = p_sch.
  in_wa-ready = p_rea .
  in_wa-running = p_run.
  in_wa-finished = p_fin.
  in_wa-aborted = p_abo.

  CALL FUNCTION 'BP_JOB_SELECT_SM37B'
    EXPORTING
      jobselect_dialog          = 'N'
      jobsel_param_in           = in_wa
    TABLES
*   JOBSELECT_JOBLIST         =
      jobselect_joblist_b       = itab
   EXCEPTIONS
     invalid_dialog_type       = 1
     jobname_missing           = 2
     no_jobs_found             = 3
     selection_canceled        = 4
     username_missing          = 5
     OTHERS                    = 6   .
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  outdata
*&---------------------------------------------------------------------*
FORM outdata.
  sla-colwidth_optimize = 'X'.
  sla-zebra             = 'X'.
  i_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program = i_repid
            i_structure_name   = 'TBTCJOB_BK'
            is_layout          = sla
       TABLES
            t_outtab           = itab
       EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
ENDFORM.                    " outdata

*---------------------------------------------------------------------*
*       FORM send_email_message                                       *
*---------------------------------------------------------------------*
FORM send_mail.
  DATA: txt TYPE string .

  gd_doc_data-doc_size = 1.
  gd_doc_data-obj_langu = sy-langu.
  gd_doc_data-obj_name  = 'SAPRPT'.
  CONCATENATE 'Job监控自动发送邮件' '' INTO gd_doc_data-obj_descr.
  gd_doc_data-sensitivty = 'F'.

  LOOP AT itab.
    CASE itab-status.
      WHEN 'P'.
        txt = 'PRELIMINARY'.
      WHEN 'S'.
        txt = 'SCHEDULED'.
      WHEN 'Y'.
        txt = 'READY'.
      WHEN 'R'.
        txt = 'RUNNING'.
      WHEN 'F'.
        txt = 'FINISHED'.
      WHEN 'A'.
        txt = 'ABORTED'.
    ENDCASE.

    CONCATENATE itab-jobname ',' txt INTO it_message .
    APPEND it_message.
  ENDLOOP.

  CLEAR it_packing_list.
  REFRESH it_packing_list.
  it_packing_list-transf_bin = space.
  it_packing_list-head_start = 1.
  it_packing_list-head_num = 0.
  it_packing_list-body_start = 1.
  DESCRIBE TABLE it_message LINES it_packing_list-body_num.
  it_packing_list-doc_type = 'RAW'.
  APPEND it_packing_list.

  CLEAR it_receivers.
  REFRESH it_receivers.
  LOOP AT s_addr.
    it_receivers-receiver = s_addr-low.
    it_receivers-rec_type = 'U'.
    it_receivers-com_type = 'INT'.
    it_receivers-notif_del = 'X'.
    it_receivers-notif_ndel = 'X'.
    APPEND it_receivers.
    CLEAR it_receivers.
  ENDLOOP.

  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            document_data              = gd_doc_data
            put_in_outbox              = 'X'
       IMPORTING
            sent_to_all                = gd_sent_all
       TABLES
            packing_list               = it_packing_list
            contents_txt               = it_message
            receivers                  = it_receivers
       EXCEPTIONS
            too_many_receivers         = 1
            document_not_sent          = 2
            document_type_not_exist    = 3
            operation_no_authorization = 4
            parameter_error            = 5
            x_error                    = 6
            enqueue_error              = 7
            OTHERS                     = 8.

  IF sy-subrc = 0 .
    WAIT UP TO 2 SECONDS.
    SUBMIT rsconn01 WITH mode = 'INT'
                  WITH output = 'X'
                  AND RETURN.
  ENDIF.
ENDFORM.                    " SEND_EMAIL_MESSAGE

阅读(6729) | 评论(5) | 转发(0) |
0

上一篇:判断胎儿性别

下一篇:InfoRecord的修改记录

给主人留下些什么吧!~~

qdbarry2010-01-13 19:30:34

P 专用分配表 C 共享发送列表 O SAPoffice 用户 B SAP用户 U 互联网地址 X X.400 地址 R 另一 SAP 系统中的 SAP 用户 A 外部地址 F 传真号 D X.500 地址 L 电传号码 H 组织单位/位置 J SAP 对象 G 组织对象/标识 K 寻呼机/SMS DESCRIBE TABLE it_message LINES it_packing_list-body_num. 就是DESCRIBE 关键字而已,你F1

星0爷2010-01-12 17:28:21

老白,你好 请问 it_receivers-rec_type = 'U'. 接受者TYPE为‘U’是什么意思,还有其他的TYPE吗; 还有 DESCRIBE TABLE it_message LINES it_packing_list-body_num. 这段代码是基于什么逻辑? 十分迷惑,望指点

chinaunix网友2010-01-05 15:03:24

不对啊,put_in_outbox = 'X' 应该在SAP邮箱里能看到。明明有记录,但我的提示也是NO MESSGAE SENT 。奇怪!

chinaunix网友2009-06-01 12:46:00

应该是发送到外部的Email功能没有配好

chinaunix网友2009-05-26 13:40:24

为什么拷贝你的程序在我的电脑上会显示NO MESSGAE SENT 呢?