Attach an Aquiller letter to a Floe e-mail

You can add an Aquiller-generated letter as an attachment to a Floe e-mail.

If you already have generated the Aquiller letter, then this can be read from the CMS:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  CALL FUNCTION '/FLM/PDF_OUT'
    EXPORTING
      im_ccode      = 'AQ1' "Aquiller customer code
      im_ftype      = '1021' "ctype
      im_flang      = 'E'
      im_fver       = '00'
      im_fid        = l_aqu_id"im_fpe-id
      im_fid_var    = '0001'
      im_user       = sy-uname
      im_fillable   = '-'
      im_ftransport = /flm/core=>c_co_finalise
      im_file_type  = 'AQU'
    IMPORTING
      ypdf          = l_attach_s-att_data
      ymess         = l_mess.

  l_attach_s-att_filename = 'Offer letter.pdf'.
  APPEND l_attach_s TO l_attach_t.

This can be done from the attachment user-exit, or before Floe is called. Then the attachment should be passed into Floe:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
  CALL FUNCTION '/FLOE/EMAIL_OUT'
    EXPORTING
      im_etype            = 'KFN2'  "Offer letter template
      im_elang            = 'E'
      im_send_immediately = 'X'
      im_importance       = '1'
      im_attachments      = l_attach_t
      im_form_data        = im_forms_data
*     IM_ESUBJECT_LONG    =
*     IM_DOCUMENT         =
*     IM_REC_EMAILS       =
    IMPORTING
      ex_subrc            = l_subrc
      ex_mess             = l_mess1
      ex_eid              = l_eid.

If you need to programmatically generate the Aquiller letter, then you can do this.

(Sample code is a posting adapter):

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
FUNCTION Z_FPE_AQU_GENERATE_295_700.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IM_FORMS_DATA) TYPE  /FLM/XML_TAB_T
*"     VALUE(IM_STEP) TYPE  /FLM/PROCESS_SEQ
*"     VALUE(IM_DIALOGUE_MODE) TYPE  CHAR1
*"     VALUE(IM_FPE) TYPE  /FLM/FPE
*"     VALUE(IM_STATUS_T) TYPE  /FLM/FPE_STATUS_T
*"     VALUE(IM_RFCDEST) TYPE  /FLM/FPE_RFCDEST
*"  EXPORTING
*"     VALUE(EX_POSTED_DOC) TYPE  /FLM/PDOC
*"     VALUE(EX_SUBRC) TYPE  SYSUBRC
*"     VALUE(EX_NO_POST_ATTEMPT) TYPE  FLAG
*"  CHANGING
*"     REFERENCE(CH_RETURN) TYPE  /FLM/MESS_T
*"----------------------------------------------------------------------
*----------------------------------------------------------------------------------------*
* This posting adaptor is used at the end of an FLM form process to                      *
* generate a trigger record on the /flmcg/trigger table; subsequently this is processed  *
* by the /flmcg/action_triggers report to create the actual letter.                      *
*----------------------------------------------------------------------------------------*
* (c) Arch Consulting Ltd, 2011.  All rights reserved.                                   *
*----------------------------------------------------------------------------------------*
* Version History:                                                                       *
*                                                                                        *
* Who    When     How        Rel Why                                               Where *
* Arch   01042011 DV1K901122 120 Initial version                                   -     *
*----------------------------------------------------------------------------------------*

*----------------------------------------------------------------------------------------*
* Check that this adaptor is configured to run for the FLM form type:                    *
*----------------------------------------------------------------------------------------*
  DATA: l_cref2       TYPE text40,
        l_cref3       TYPE text40,
        l_cref4       TYPE text40,
        l_xml         TYPE string,
        l_anchor_date TYPE string,
        l_para_t_data TYPE /flmcg/para_data_t,
        l_para_data   TYPE /flmcg/para_data,
        l_forms_data  TYPE /flm/xml_tab,
        l_result_tab  TYPE match_result_tab,
        l_result_wa   TYPE match_result,
        l_offset      TYPE int4,
        l_row         TYPE int4,
        L_V1          TYPE SYMSGV.
*----------------------------------------------------------------------------------------*
* Populate working variables:                                                            *
*----------------------------------------------------------------------------------------*
  g_ccode   = im_fpe-ccode.
  g_ftype   = im_fpe-ftype.
  g_flang   = im_fpe-flang.
  g_fver    = im_fpe-fver.
  g_fid     = im_fpe-id.
  g_fid_var = im_fpe-id_var.
*----------------------------------------------------------------------------------------*
* Read the link table to derive the correspondence type to use                           *
*----------------------------------------------------------------------------------------*
  SELECT SINGLE ctype FROM  /flmcg/flm_link INTO g_ctype
         WHERE  ccode  = g_ccode
         AND    ftype  = g_ftype
         AND    flang  = g_flang
         AND    fver   = g_fver.
*
  IF sy-subrc IS NOT INITIAL.
    g_v1 = g_ccode.
    g_v2 = l_cref2.
    CALL METHOD /flm/core=>error
      EXPORTING
        im_type   = /flm/core=>c_mess_error
        im_number = '094'
        im_id     = /flmcg/core=>c_aqui_mess_class
        im_v1     = g_v1
        im_v2     = g_v2
      RECEIVING
        re_mess   = g_mess.
    APPEND g_mess TO ch_return.
    ex_subrc = 4.
    RETURN.
  ENDIF.
*----------------------------------------------------------------------------------------*
* Get the target personnel number:                                                       *
*----------------------------------------------------------------------------------------*
  CLEAR g_pernr.
  g_pernr = 99999999.
*----------------------------------------------------------------------------------------*
* Create FLM Source CMS record                                                           *
*----------------------------------------------------------------------------------------*
  CALL METHOD /flm/core=>gen_cms_doc
    EXPORTING
      im_ccode   = g_ccode
      im_ftype   = g_ftype
      im_flang   = g_flang
      im_fver    = g_fver
      im_fid     = g_fid
      im_fid_var = g_fid_var
    IMPORTING
      ex_cms_doc = g_cont_cms.


  l_cref2 = sy-uname.
  "Generate Aquiller letter
  CALL FUNCTION '/FLMCG/GENERATE_LETTER'
    EXPORTING
      im_ctype      = '1021' "Aquiller template id
      im_clang      = 'E'
      im_cver       = '00'
      im_cref2      = l_cref2
      im_pernr      = g_pernr
      im_source_cms = g_cont_cms
    IMPORTING
      ex_return     = g_mess.

*----------------------------------------------------------------------------------------*
* Set the return message and posting reference                                           *
*----------------------------------------------------------------------------------------*
*
  IF g_mess-type = /flm/core=>c_mess_error OR
     g_mess-type = /flm/core=>c_mess_abend.
*
    ex_subrc  = 4.
*
  ELSE.

    L_V1 = G_MESS-PARAMETER.
    CALL METHOD /flm/core=>error
      EXPORTING
        im_type   = /flm/core=>c_mess_success
        im_number = '000'"Aquiller letter id: &1 successfully generated
        im_id     = 'ZCUSTOMER'
        im_v1     = L_V1
      RECEIVING
        re_mess   = g_mess.
    APPEND g_mess TO ch_return.

*
    ex_posted_doc =  L_V1.   "Aquiller letter id->saved onto posted doc.
    ex_subrc  = 0.
*
  ENDIF.
*----------------------------------------------------------------------------------------*
ENDFUNCTION.

This gives you the CMS reference you need to do the read.