ZCRM_AU_MAIL

Posted ^ω^SAp傻X^o^

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ZCRM_AU_MAIL相关的知识,希望对你有一定的参考价值。

FUNCTION ZCRM_AU_MAIL.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(EXGST) TYPE  ZZFPAMT OPTIONAL
*"     VALUE(INGST) TYPE  ZZFPAMT OPTIONAL
*"     VALUE(BELNR) TYPE  BELNR_D OPTIONAL
*"  TABLES
*"      ZCRMS004 STRUCTURE  ZCRMS004
*"----------------------------------------------------------------------
  DATA: LS_CONTROL_PARAM      TYPE SSFCTRLOP.
  DATA: LS_COMPOSER_PARAM     TYPE SSFCOMPOP.
  DATA: LS_RECIPIENT          TYPE SWOTOBJID.
  DATA: LS_SENDER             TYPE SWOTOBJID.
  DATA: LF_FORMNAME           TYPE TDSFNAME.
  DATA: JOBINFO TYPE SSFCRESCL.
  DATA: LF_FM_NAME            TYPE RS38L_FNAM.
  DATA: OTFDATA TYPE TSFOTF.
  DATA: GV_XSTRING            TYPE XSTRING,
        LV_LEN TYPE I,
        LT_PDF TYPE TABLE OF TLINE.
  DATA: GT_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
      GT_OBJHEX TYPE SOLIX_TAB,
      G_BENFILE TYPE XSTRING,
      P_SENDER LIKE ADR6-SMTP_ADDR,
      LV_SUBJECT          TYPE SO_OBJ_DES VALUE remittance for payment to be processed.
  DATA LO_SEND_REQUEST   TYPE REF TO CL_BCS.
  DATA LO_DOCUMENT       TYPE REF TO CL_DOCUMENT_BCS.
  DATA LO_RECIPIENT      TYPE REF TO IF_RECIPIENT_BCS.
  DATA LO_BCS_EXCEPTION  TYPE REF TO CX_BCS.
  DATA LO_SENDER         TYPE REF TO IF_SENDER_BCS.     " Sender address
  DATA LV_SIZE           TYPE SO_OBJ_LEN.
  DATA LV_ALL             TYPE OS_BOOLEAN.

  LF_FORMNAME = ZCRM_SETMENT_AU.
  LS_CONTROL_PARAM-LANGU     = E.
  LS_CONTROL_PARAM-NO_OPEN   = X.
  LS_CONTROL_PARAM-NO_CLOSE  = X.
  LS_COMPOSER_PARAM-TDDELETE = X.",打印后删除
  LS_COMPOSER_PARAM-TDIMMED  = X."立即打印
  LS_COMPOSER_PARAM-TDDEST   = LP03.
  LS_CONTROL_PARAM-GETOTF    = X.
  LS_CONTROL_PARAM-NO_DIALOG = X.
  LS_COMPOSER_PARAM-TDNOPREV = X.

  CALL FUNCTION SSF_OPEN
    EXPORTING
      CONTROL_PARAMETERS = LS_CONTROL_PARAM
      OUTPUT_OPTIONS     = LS_COMPOSER_PARAM
      USER_SETTINGS      = ‘‘
    EXCEPTIONS
      FORMATTING_ERROR   = 1
      INTERNAL_ERROR     = 2
      SEND_ERROR         = 3
      USER_CANCELED      = 4
      OTHERS             = 5.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION SSF_FUNCTION_MODULE_NAME
    EXPORTING
      FORMNAME           = LF_FORMNAME
    IMPORTING
      FM_NAME            = LF_FM_NAME
    EXCEPTIONS
      NO_FORM            = 1
      NO_FUNCTION_MODULE = 2
      OTHERS             = 3.
  IF SY-SUBRC <> 0.
    MESSAGE Call SSF_FUNCTION_MODULE_NAME Error TYPE E.
  ENDIF.

  CALL FUNCTION LF_FM_NAME
    EXPORTING
      CONTROL_PARAMETERS = LS_CONTROL_PARAM
      OUTPUT_OPTIONS     = LS_COMPOSER_PARAM
      USER_SETTINGS      =  
      EXGST              = EXGST
      INGST              = INGST
    TABLES
      GT_TABLE           = ZCRMS004
    EXCEPTIONS
      FORMATTING_ERROR   = 1
      INTERNAL_ERROR     = 2
      SEND_ERROR         = 3
      USER_CANCELED      = 4
      OTHERS             = 5.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION SSF_CLOSE
    IMPORTING
      JOB_OUTPUT_INFO  = JOBINFO
    EXCEPTIONS
      FORMATTING_ERROR = 1
      INTERNAL_ERROR   = 2
      SEND_ERROR       = 3
      OTHERS           = 4.
  IF SY-SUBRC <> 0.
    MESSAGE Print Error! TYPE E.
  ENDIF.

  OTFDATA = JOBINFO-OTFDATA[].
  CALL FUNCTION CONVERT_OTF
    EXPORTING
      FORMAT                = PDF
      MAX_LINEWIDTH         = 132
    IMPORTING
      BIN_FILESIZE          = LV_LEN
      BIN_FILE              = GV_XSTRING
    TABLES
      OTF                   = OTFDATA
      LINES                 = LT_PDF
    EXCEPTIONS
      ERR_MAX_LINEWIDTH     = 1
      ERR_FORMAT            = 2
      ERR_CONV_NOT_POSSIBLE = 3
      OTHERS                = 4.

  FREE LO_SEND_REQUEST.
  LO_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
  "
  CLEAR: GT_OBJTXT, GT_OBJTXT[].
  GT_OBJTXT =  .
  APPEND GT_OBJTXT.
  GT_OBJTXT = Dear Service Agent<br /> .
  APPEND GT_OBJTXT.
  GT_OBJTXT = <br />.
  APPEND GT_OBJTXT.
  CLEAR:GT_OBJTXT.
  MOVE INGST TO GT_OBJTXT.
  CONDENSE GT_OBJTXT NO-GAPS.
  CONCATENATE Please find attached remittance for GT_OBJTXT payment<br /> INTO GT_OBJTXT SEPARATED BY space.
*  GT_OBJTXT = ‘Please find attached remittance for xxx.xx payment<br />‘.
  APPEND GT_OBJTXT.
  GT_OBJTXT = Please allow up to 7 days for payment to be processed<br />.
  APPEND GT_OBJTXT.
  GT_OBJTXT = If you have any enquiries, please email [email protected]<br />.
  APPEND GT_OBJTXT.
  GT_OBJTXT = <br />.
  APPEND GT_OBJTXT.
  GT_OBJTXT = Thank you.<br />.
  APPEND GT_OBJTXT.

  LO_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
    I_TYPE    = HTM
    I_TEXT    = GT_OBJTXT[]
    I_SUBJECT = LV_SUBJECT ).

  TRY.
      GT_OBJHEX = CL_BCS_CONVERT=>XSTRING_TO_SOLIX(
      IV_XSTRING   = GV_XSTRING
      ).
    CATCH CX_BCS.
      MESSAGE E445(SO).
  ENDTRY.
  CONCATENATE BELNR .PDF INTO LV_SUBJECT.
  LO_DOCUMENT->ADD_ATTACHMENT(
        I_ATTACHMENT_TYPE    = PDF
        I_ATTACHMENT_SUBJECT = LV_SUBJECT
        I_ATT_CONTENT_HEX    = GT_OBJHEX ).
  DATA: FAULT TYPE REF TO CX_SEND_REQ_BCS.
  TRY.
      LO_SEND_REQUEST->SET_DOCUMENT( LO_DOCUMENT ).
    CATCH CX_SEND_REQ_BCS INTO FAULT.
      MESSAGE I605(SBCOMS) .
  ENDTRY.

  P_SENDER = XXXXXXX.

  CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
    EXPORTING
      I_ADDRESS_STRING = P_SENDER
      I_ADDRESS_NAME   = P_SENDER
    RECEIVING
      RESULT           = LO_SENDER.
  CALL METHOD LO_SEND_REQUEST->SET_SENDER
    EXPORTING
      I_SENDER = LO_SENDER.

  P_SENDER = [email protected].

  LO_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( P_SENDER ).
  LO_SEND_REQUEST->ADD_RECIPIENT( LO_RECIPIENT ).

  P_SENDER = XXXXXXXX.

  LO_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( P_SENDER ).
  LO_SEND_REQUEST->ADD_RECIPIENT( EXPORTING I_RECIPIENT = LO_RECIPIENT I_COPY = X ).

  LO_SEND_REQUEST->SET_SEND_IMMEDIATELY( X ).
  LV_ALL = LO_SEND_REQUEST->SEND( I_WITH_ERROR_SCREEN = X ).


ENDFUNCTION.

 

FUNCTION ZCRM_AU_MAIL.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(EXGST) TYPE  ZZFPAMT OPTIONAL
*"     VALUE(INGST) TYPE  ZZFPAMT OPTIONAL
*"     VALUE(BELNR) TYPE  BELNR_D OPTIONAL
*"  TABLES
*"      ZCRMS004 STRUCTURE  ZCRMS004
*"----------------------------------------------------------------------
  DATALS_CONTROL_PARAM      TYPE SSFCTRLOP.
  DATALS_COMPOSER_PARAM     TYPE SSFCOMPOP.
  DATALS_RECIPIENT          TYPE SWOTOBJID.
  DATALS_SENDER             TYPE SWOTOBJID.
  DATALF_FORMNAME           TYPE TDSFNAME.
  DATAJOBINFO TYPE SSFCRESCL.
  DATALF_FM_NAME            TYPE RS38L_FNAM.
  DATAOTFDATA TYPE TSFOTF.
  DATAGV_XSTRING            TYPE XSTRING,
        LV_LEN TYPE I,
        LT_PDF TYPE TABLE OF TLINE.
  DATAGT_OBJTXT LIKE SOLISTI1 OCCURS WITH HEADER LINE,
      GT_OBJHEX TYPE SOLIX_TAB,
      G_BENFILE TYPE XSTRING,
      P_SENDER LIKE ADR6-SMTP_ADDR,
      LV_SUBJECT          TYPE SO_OBJ_DES VALUE ‘remittance for payment to be processed‘.
  DATA LO_SEND_REQUEST   TYPE REF TO CL_BCS.
  DATA LO_DOCUMENT       TYPE REF TO CL_DOCUMENT_BCS.
  DATA LO_RECIPIENT      TYPE REF TO IF_RECIPIENT_BCS.
  DATA LO_BCS_EXCEPTION  TYPE REF TO CX_BCS.
  DATA LO_SENDER         TYPE REF TO IF_SENDER_BCS.     " Sender address
  DATA LV_SIZE           TYPE SO_OBJ_LEN.
  DATA LV_ALL             TYPE OS_BOOLEAN.

  LF_FORMNAME ‘ZCRM_SETMENT_AU‘.
  LS_CONTROL_PARAM-LANGU     ‘E‘.
  LS_CONTROL_PARAM-NO_OPEN   ‘X‘.
  LS_CONTROL_PARAM-NO_CLOSE  ‘X‘.
  LS_COMPOSER_PARAM-TDDELETE ‘X‘.",打印后删除
  LS_COMPOSER_PARAM-TDIMMED  ‘X‘."立即打印
  LS_COMPOSER_PARAM-TDDEST   ‘LP03‘.
  LS_CONTROL_PARAM-GETOTF    ‘X‘.
  LS_CONTROL_PARAM-NO_DIALOG ‘X‘.
  LS_COMPOSER_PARAM-TDNOPREV ‘X‘.

  CALL FUNCTION ‘SSF_OPEN‘
    EXPORTING
      CONTROL_PARAMETERS LS_CONTROL_PARAM
      OUTPUT_OPTIONS     LS_COMPOSER_PARAM
      USER_SETTINGS      ‘‘
    EXCEPTIONS
      FORMATTING_ERROR   1
      INTERNAL_ERROR     2
      SEND_ERROR         3
      USER_CANCELED      4
      OTHERS             5.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME‘
    EXPORTING
      FORMNAME           LF_FORMNAME
    IMPORTING
      FM_NAME            LF_FM_NAME
    EXCEPTIONS
      NO_FORM            1
      NO_FUNCTION_MODULE 2
      OTHERS             3.
  IF SY-SUBRC <> 0.
    MESSAGE ‘Call SSF_FUNCTION_MODULE_NAME Error‘ TYPE ‘E‘.
  ENDIF.

  CALL FUNCTION LF_FM_NAME
    EXPORTING
      CONTROL_PARAMETERS LS_CONTROL_PARAM
      OUTPUT_OPTIONS     LS_COMPOSER_PARAM
      USER_SETTINGS      ‘ ‘
      EXGST              EXGST
      INGST              INGST
    TABLES
      GT_TABLE           ZCRMS004
    EXCEPTIONS
      FORMATTING_ERROR   1
      INTERNAL_ERROR     2
      SEND_ERROR         3
      USER_CANCELED      4
      OTHERS             5.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION ‘SSF_CLOSE‘
    IMPORTING
      JOB_OUTPUT_INFO  JOBINFO
    EXCEPTIONS
      FORMATTING_ERROR 1
      INTERNAL_ERROR   2
      SEND_ERROR       3
      OTHERS           4.
  IF SY-SUBRC <> 0.
    MESSAGE ‘Print Error!‘ TYPE ‘E‘.
  ENDIF.

  OTFDATA JOBINFO-OTFDATA[].
  CALL FUNCTION ‘CONVERT_OTF‘
    EXPORTING
      FORMAT                ‘PDF‘
      MAX_LINEWIDTH         132
    IMPORTING
      BIN_FILESIZE          LV_LEN
      BIN_FILE              GV_XSTRING
    TABLES
      OTF                   OTFDATA
      LINES                 LT_PDF
    EXCEPTIONS
      ERR_MAX_LINEWIDTH     1
      ERR_FORMAT            2
      ERR_CONV_NOT_POSSIBLE 3
      OTHERS                4.

  FREE LO_SEND_REQUEST.
  LO_SEND_REQUEST CL_BCS=>CREATE_PERSISTENT).
  "
  CLEARGT_OBJTXTGT_OBJTXT[].
  GT_OBJTXT ‘ ‘.
  APPEND GT_OBJTXT.
  GT_OBJTXT ‘Dear Service Agent<br /> ‘.
  APPEND GT_OBJTXT.
  GT_OBJTXT ‘<br />‘.
  APPEND GT_OBJTXT.
  CLEAR:GT_OBJTXT.
  MOVE INGST TO GT_OBJTXT.
  CONDENSE GT_OBJTXT NO-GAPS.
  CONCATENATE ‘Please find attached remittance for‘ GT_OBJTXT ‘payment<br />‘ INTO GT_OBJTXT SEPARATED BY space.
*  GT_OBJTXT = ‘Please find attached remittance for xxx.xx payment<br />‘.
  APPEND GT_OBJTXT.
  GT_OBJTXT ‘Please allow up to 7 days for payment to be processed<br />‘.
  APPEND GT_OBJTXT.
  GT_OBJTXT ‘If you have any enquiries, please email [email protected]<br />‘.
  APPEND GT_OBJTXT.
  GT_OBJTXT ‘<br />‘.
  APPEND GT_OBJTXT.
  GT_OBJTXT ‘Thank you.<br />‘.
  APPEND GT_OBJTXT.

  LO_DOCUMENT CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
    I_TYPE    ‘HTM‘
    I_TEXT    GT_OBJTXT[]
    I_SUBJECT LV_SUBJECT ).

  TRY.
      GT_OBJHEX CL_BCS_CONVERT=>XSTRING_TO_SOLIX(
      IV_XSTRING   GV_XSTRING
      ).
    CATCH CX_BCS.
      MESSAGE E445(SO).
  ENDTRY.
  CONCATENATE BELNR ‘.PDF‘ INTO LV_SUBJECT.
*  LV_SUBJECT = ‘test.PDF‘.
  LO_DOCUMENT->ADD_ATTACHMENT(
        I_ATTACHMENT_TYPE    ‘PDF‘
        I_ATTACHMENT_SUBJECT LV_SUBJECT
        I_ATT_CONTENT_HEX    GT_OBJHEX ).
  DATAFAULT TYPE REF TO CX_SEND_REQ_BCS.
  TRY.
      LO_SEND_REQUEST->SET_DOCUMENTLO_DOCUMENT ).
    CATCH CX_SEND_REQ_BCS INTO FAULT.
      MESSAGE I605(SBCOMS.
  ENDTRY.

  P_SENDER [email protected].

  CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
    EXPORTING
      I_ADDRESS_STRING P_SENDER
      I_ADDRESS_NAME   P_SENDER
    RECEIVING
      RESULT           LO_SENDER.
  CALL METHOD LO_SEND_REQUEST->SET_SENDER
    EXPORTING
      I_SENDER LO_SENDER.

  P_SENDER [email protected].

  LO_RECIPIENT CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESSP_SENDER ).
  LO_SEND_REQUEST->ADD_RECIPIENTLO_RECIPIENT ).

  P_SENDER [email protected].

  LO_RECIPIENT CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESSP_SENDER ).
  LO_SEND_REQUEST->ADD_RECIPIENTEXPORTING I_RECIPIENT LO_RECIPIENT I_COPY ‘X‘ ).

  LO_SEND_REQUEST->SET_SEND_IMMEDIATELY‘X‘ ).
  LV_ALL LO_SEND_REQUEST->SENDI_WITH_ERROR_SCREEN ‘X‘ ).


ENDFUNCTION.

以上是关于ZCRM_AU_MAIL的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数