Chinaunix首页 | 论坛 | 博客
  • 博客访问: 203326
  • 博文数量: 54
  • 博客积分: 2056
  • 博客等级: 大尉
  • 技术积分: 568
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 12:07
文章分类

全部博文(54)

文章存档

2014年(1)

2013年(1)

2012年(1)

2011年(2)

2010年(1)

2009年(11)

2008年(28)

2007年(9)

我的朋友

分类:

2008-06-30 16:38:05

*&---------------------------------------------------------------------*
*& Report  Z14841_TEST010
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  z14841_test010.
TYPES: BEGIN OF stru_master,
kunnr       TYPE kunnr,   
                                                            "客户编号1
bukrs       TYPE bukrs,        "公司代码
pro_mill    TYPE werks_d,  "工厂
*quota       TYPE zcdfquota,  "额度
*account TYPE char10,  "帐期
*zdays       TYPE zcdfdays,  "天数
*valid_beg TYPE zcdfdatum1,  "有效起始日期
*valid_end TYPE zcdfdatum2,  "有效结束日期
*docno       TYPE zcdfdocno,  "授信申请编号
*name1       TYPE name1_gp,  
*                                                            "名称 1
*assure_mode TYPE char10,             "授信类别
*quota1 TYPE zcdfquota,  "额度
*route  TYPE char1,        "审批路径
*uname       TYPE uname,        "签准人
*zlevel TYPE zcdflevel,       "评级
*zclass      TYPE zcdfclass,         "客户类型
*zjye       TYPE dmbtr,             "当月交易额
*zqmye       TYPE dmbtr,             "期末余额
*zyqzk       TYPE dmbtr,             "逾期金额
END OF stru_master.
TYPES : tab_master TYPE TABLE OF stru_master.
DATA:lt_master TYPE
 tab_master,
     wa_master TYPE stru_master.
*************************************************************
DATA: object_hd_change LIKE sood1 OCCURS 10 WITH HEADER LINE,
"邮件正文的头信息
      receivers LIKE soos1 OCCURS 10 WITH HEADER LINE,
       packing_list LIKE soxpl OCCURS 10 WITH HEADER LINE,
 "邮件附件的头信息
       objcont LIKE soli OCCURS 10 WITH HEADER LINE,   " 邮件正文
       att_cont LIKE soli OCCURS 10 WITH HEADER LINE,
" 邮件附件
       att_head LIKE soli OCCURS 10 WITH HEADER LINE.  " 头行
DATA : count TYPE i,length TYPE i.
DATA: lc_item1(24) TYPE c.
DATA: lc_item2(24) TYPE c.
DATA: lc_line_sub(29) TYPE c.
DATA: lc_line_sub2(52) TYPE c.
DATA: ls_data TYPE string.
DATA: li_len TYPE i.
DATA: ls_title TYPE string.
DATA: gs_string TYPE string.
REFRESH: objcont,receivers,packing_list,
         objcont,att_cont,att_head.
CLEAR: att_cont-line.
att_cont-line =  '附件文本的标题'.
ls_title = att_cont-line.
APPEND att_cont.
* 放入附件内表
*   Retrieve sample data from table ekpo
*PERFORM data_retrieval.
*   Populate table with detaisl to be entered into .xls file
*PERFORM build_xls_data_table.
CLEAR: att_cont-line.
att_cont-line =  '附件文本内容'.
APPEND att_cont. "如果有行内容,可以append多次
 
MOVE  '邮件内容标题' TO objcont-line.
APPEND objcont.
MOVE 'file' TO att_head-line.
APPEND att_head.
DESCRIBE TABLE objcont LINES count.
DESCRIBE FIELD objcont-line LENGTH length IN BYTE MODE .
object_hd_change-objla = 'E'.              "创建文档使用的语言
object_hd_change-objnam = 'LIST'.    "文档,文件夹或分配清单的名称
object_hd_change-objdes = gs_string.       "内容的简短描述CHAR50
object_hd_change-objsns = 'O'.       "对象:灵敏度  P机密 F功能 O标准
object_hd_change-objlen = count * length.  "文档内容的大小
APPEND object_hd_change.
* 接收者
receivers-recextnam =
.
receivers-recesc = 'U'.          " 地址类型, U: 互联网地址
APPEND receivers. " 收件人地址
DESCRIBE TABLE att_cont LINES count.          " 邮件附件总行数
DESCRIBE FIELD att_cont-line LENGTH length    " 邮件每行的长度
 IN BYTE MODE .
packing_list-head_start = '1'.           "传输包中的对象表头开始行
packing_list-body_start = '1'.           "对象包中的对象内容开始行
packing_list-head_num = '0'.             "在对象包内的对象表头行号
packing_list-body_num = count * length.  "在对象包内的对象内容行号
packing_list-objtp = 'RAW'.              "文档类别代码
packing_list-objdes = gs_string.
packing_list-objnam = gs_string.
*  OBJDES OBJNAM
APPEND packing_list.
* 调用函数发送邮件
CALL FUNCTION 'SO_OBJECT_SEND'
  EXPORTING
*     New object: General header data
    object_hd_change           = object_hd_change
    object_type                = 'RAW'       " RAW  SAP编辑程序文件
    sender                     = sy-uname    " 发送者用户名
  TABLES
    objcont                    = objcont      " Content
*     Recipient table with send attributes
    receivers                  = receivers      " 接收人地址
    packing_list            = packing_list   " 邮件内容
    att_cont                   = att_cont       " 附件
    att_head           = att_head       " 标题
  EXCEPTIONS
    active_user_not_exist      = 1
    communication_failure      = 2
    component_not_available    = 3
    folder_not_exist           = 4
    folder_no_authorization    = 5
    forwarder_not_exist        = 6
    note_not_exist             = 7
    object_not_exist           = 8
    object_not_sent            = 9
    object_no_authorization    = 10
    object_type_not_exist      = 11
    operation_no_authorization = 12
    owner_not_exist            = 13
    parameter_error            = 14
    substitute_not_active      = 15
    substitute_not_defined     = 16
    system_failure             = 17
    too_much_receivers         = 18
    user_not_exist             = 19
    originator_not_exist       = 20
    x_error                    = 21
    OTHERS                     = 22.
*pr_subrc = sy-subrc.
IF sy-subrc = 0.
  COMMIT WORK.
ENDIF.
*   Instructs mail send program for SAPCONNECT to send email(rsconn01)
*  PERFORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
                WITH output = 'X'
                AND RETURN.
*&---------------------------------------------------------------------*
*&      Form  data_retrieval
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM data_retrieval .
  DATA wa_vkorg TYPE char4.
  DATA temp_item TYPE zcdfitem .
*****抓上月第一天*******
  DATA wa_date TYPE dats .
  DATA temp TYPE char6 .
  temp = sy-datum.
  CONCATENATE temp '01' INTO wa_date .
  wa_date = wa_date - 1 .
  temp = wa_date.
  CONCATENATE temp '01' INTO wa_date .
*******************
*-销售公司
  SELECT SINGLE vkorg
  FROM zcdtrole_assi
  INTO wa_vkorg
*  WHERE pernr = application->username AND defa = 'X'.
  WHERE pernr = '50010001' AND defa = 'X'.
***抓额度 两张表都抓
  SELECT *
  FROM zcdtquota
  INTO CORRESPONDING FIELDS OF TABLE lt_master
  WHERE bukrs  = wa_vkorg AND valid_end >= wa_date .
  CLEAR wa_master .
  SELECT *
  FROM zcdtquota_histy
  INTO CORRESPONDING FIELDS OF  wa_master
  WHERE bukrs  = wa_vkorg AND valid_end >= wa_date .
    APPEND wa_master TO lt_master .
    CLEAR wa_master .
  ENDSELECT .
*  LOOP AT lt_master INTO wa_master .
****抓名称
*    SELECT SINGLE name1
*    FROM zcdtcust
*    INTO  wa_master-name1
*    WHERE kunnr  = wa_master-kunnr .
*
*    IF wa_master-docno IS NOT INITIAL .
****抓授信类别
*      SELECT SINGLE assure_mode
*      FROM zcdtcrea
*      INTO  wa_master-assure_mode
*      WHERE docno  = wa_master-docno .
****抓授信额度
*      SELECT SINGLE  quota1
*      FROM zcdtcrea
*      INTO   wa_master-quota1
*      WHERE docno  = wa_master-docno .
****抓签准人
*      SELECT SINGLE  route
*      FROM zcdtcrea
*      INTO   wa_master-route
*      WHERE docno  = wa_master-docno .
*
*      IF wa_master-route = 'A'.
*        SELECT MAX( item )
*        FROM zcdtwf_text
*        INTO   temp_item
*        WHERE docno  = wa_master-docno .
*
*        SELECT SINGLE  uname
*       FROM zcdtwf_text
*       INTO   wa_master-uname
*       WHERE docno  = wa_master-docno
*       AND item = temp_item .
*
*
*      ENDIF.
*      IF wa_master-route = 'B'.
*        SELECT MAX( item )
*        FROM zcdtwf_text
*        INTO   temp_item
*        WHERE docno  = wa_master-docno .
*
*        SELECT SINGLE  uname
*       FROM zcdtwf_text
*       INTO   wa_master-uname
*       WHERE docno  = wa_master-docno
*       AND item = temp_item .
*
*      ENDIF.
*      IF wa_master-route = 'C'.
*        wa_master-uname = '信用管理委员会' .
*      ENDIF.
*      IF wa_master-route = 'D'.
*        wa_master-uname = '股份公司董事长' .
*      ENDIF.
*    ENDIF.
****抓客户评级
*    SELECT SINGLE zlevel
*      FROM zcdtgrade_h
*      INTO  wa_master-zlevel
*      WHERE kunnr  = wa_master-kunnr .
*
****抓客户类型
*    SELECT SINGLE zclass
*      FROM zcdtgrade_h
*      INTO  wa_master-zclass
*      WHERE kunnr  = wa_master-kunnr .
*
****抓交易记录
*    SELECT SINGLE zjye
*    FROM zccd9month
*    INTO  wa_master-zjye
*    WHERE kunnr  = wa_master-kunnr
*    AND bukrs = wa_vkorg
*    AND z1dat = temp.
*
*    SELECT SINGLE zyqzk
*    FROM zccd9month
*    INTO  wa_master-zyqzk
*    WHERE kunnr  = wa_master-kunnr
*    AND bukrs = wa_vkorg
*    AND z1dat = temp.
*
*    SELECT SINGLE zqmye
*    FROM zccd9month
*    INTO  wa_master-zqmye
*    WHERE kunnr  = wa_master-kunnr
*    AND bukrs = wa_vkorg
*    AND z1dat = temp.
*
*******修饰
*    IF wa_master-assure_mode = 'A'.
*      wa_master-assure_mode = 'A纯信用' .
*    ENDIF.
*    IF wa_master-assure_mode = 'B'.
*      wa_master-assure_mode = 'B抵押' .
*    ENDIF.
*    IF wa_master-assure_mode = 'C'.
*      wa_master-assure_mode = 'C质押' .
*    ENDIF.
*    IF wa_master-assure_mode = 'D'.
*      wa_master-assure_mode = 'D保证' .
*    ENDIF.
*    IF wa_master-account = 'A'.
*      wa_master-account = 'A月结' .
*    ENDIF.
*    IF wa_master-account = 'B'.
*      wa_master-account = 'B天结' .
*    ENDIF.
*
*
*
*    MODIFY lt_master FROM wa_master .
*    CLEAR:wa_master .
*
*
*  ENDLOOP.
ENDFORM.                    " data_retrieval
*&---------------------------------------------------------------------*
*&      Form  build_xls_data_table
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_xls_data_table .
*  CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
*             con_tab TYPE x VALUE '09'.   "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
  CONSTANTS:
      con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
      con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
*  CONCATENATE 'kunnr' 'bukrs' 'PRO_MILL'" 'QUOTA'
*         INTO it_attach SEPARATED BY con_tab.
  CONCATENATE 'KUNNR' 'BUKRS' 'PRO_MILL'" 'QUOTA'
         INTO att_cont-line SEPARATED BY ','.
  CONCATENATE con_cret att_cont-line  INTO att_cont.
  APPEND  att_cont.
  LOOP AT lt_master INTO wa_master.
*  CONCATENATE wa_master-kunnr wa_master-bukrs
*                wa_master-PRO_MILL "wa_master-QUOTA
*           INTO it_attach SEPARATED BY con_tab.
    CONCATENATE wa_master-kunnr wa_master-bukrs
                wa_master-pro_mill "wa_master-QUOTA
                INTO att_cont-line SEPARATED BY ','.
    CONCATENATE con_cret att_cont-line  INTO att_cont.
    APPEND  att_cont.
  ENDLOOP.

ENDFORM.                    " build_xls_data_table
阅读(2271) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~