cancel
Showing results for 
Search instead for 
Did you mean: 

RERAIV - Real Estate Invoice mailing - BADI_RECP_SF

ananthula_sumanth
Participant

I am working for emailing of the smart form and found the same badi BADI_RECP_SF. But to update the recepient details i hope, i need to use cs_mail_recepeint. Please let me know how i need to fill this details. If not this CS_MAIL_RECEIPIENT, is there any other option to provide the mail id. I want to send the invoice to the mail-id updated in BP transaction.

My business requirement is when we creates the invoice through RERAIV, the output should go to customer through mail.

one way of doing is select check box "Email" in RECPA520, but my business don't want to execute this manually. And through this process i can send output only to one emial id (standard) which is maintained in business partner master.

Is there any way to send mail to other mail-ids which are maintained in business partner?

For achieving this functionality, we have badi: BADI_RECP_SF. But I am trying to know how to update or pass the parameters for this BADI method 'PRINT'.

If you have achieved this, please let me know.

Thanks in advance.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Can you pls try the following code in BadI BADI_RECP_SF-CHANGE_DOC_LIST to send mail with invoice to multiple mail id's of the same customer

FIELD-SYMBOLS : <WA_DOC_LIST> TYPE ANY,

                   <DYN_FIELD>   TYPE ANY,

                   <LT_DOC_LIST> TYPE TABLE.

   DATA : LV_ADDRNUMBER TYPE AD_ADDRNUM,

          LT_ADR6       TYPE TABLE OF ADR6,

          WA_ADR6       TYPE ADR6,

          LV_LINE       TYPE REF TO DATA.

   UNASSIGN <LT_DOC_LIST>.

   CASE IS_OPTIONS-TDDEST.

     WHEN 'MAIL'.

       LOOP AT CT_DOC_LIST ASSIGNING <WA_DOC_LIST>.

         IF <LT_DOC_LIST> IS NOT ASSIGNED.

           CREATE DATA LV_LINE LIKE TABLE OF <WA_DOC_LIST>.

           ASSIGN LV_LINE->* TO <LT_DOC_LIST>.

           <LT_DOC_LIST> = CT_DOC_LIST.

         ENDIF.

         CLEAR : LV_ADDRNUMBER.

         REFRESH : LT_ADR6[].

         ASSIGN COMPONENT 'PARTNER' OF STRUCTURE <WA_DOC_LIST> TO <DYN_FIELD>.

         IF SY-SUBRC = 0.

           SELECT SINGLE ADDRNUMBER

             FROM BUT020

             INTO LV_ADDRNUMBER

            WHERE PARTNER = <DYN_FIELD>.

           IF LV_ADDRNUMBER IS NOT INITIAL.

             SELECT *

               FROM ADR6

               INTO TABLE LT_ADR6

              WHERE ADDRNUMBER = LV_ADDRNUMBER

                AND FLGDEFAULT = ''

                AND HOME_FLAG = ''.

           ENDIF.

           LOOP AT LT_ADR6 INTO WA_ADR6.

             ASSIGN COMPONENT 'XMAILORFAXNO' OF STRUCTURE <WA_DOC_LIST> TO<DYN_FIELD>.

             IF SY-SUBRC = 0.

               <DYN_FIELD> = WA_ADR6-SMTP_ADDR.

               APPEND <WA_DOC_LIST> TO <LT_DOC_LIST>.

             ENDIF.

           ENDLOOP.

         ENDIF.

       ENDLOOP.


       IF <LT_DOC_LIST> IS ASSIGNED.

         CT_DOC_LIST = <LT_DOC_LIST>.

       ENDIF.

   ENDCASE.


Regards,

Linto

Former Member
0 Kudos

Thanks a lot for your kind reply.

T. Code RECPA520 running with the attachment but without mail body.

so in your given code I think I need to create attachment again right?

do you have any idea for standard attachment with  our customized mail text body if yes where can we put? how?

please do let me know if possible thn every steps.

I just need to enhance mail text body with standard mail attached in T. Code RECPA520.

thanks in advance,

Regards,

Vipul

former_member376779
Participant
0 Kudos

Hi,

     I just finished the code for the email with attachment and body text. I created a enhancement in the programme CL_RECP_SF_APP->_Print_Doc_List to take spool and create all the attachment and the body text.

Best regards

Former Member
0 Kudos

Hi Andre,

Thanks for reply.

Can you please send me that code with all steps. I must required it.

I need to implement that in our client side.

I hope your reply will be positive (vipul14228@gmail.com)

Regards,

Vipul

Former Member
0 Kudos

Hi Everyone

I can trigger email with attachment via T. Code RECPA520 but its come only with attachment without mail body.

can anyone tell me how can I have email body via standard configuration only.

no customization.

Regards,

Vipul Solanki

0 Kudos

Hi Vipul,

Sorry to reply you late, our client doesn't have internet access.

Standard process, doesn't give you mail body as per my analysis.

If you want mail body then u need to customize whole process. Maintain the mail body in SO10, using READ_TEXT attach mail body.

Eg.

  ld_guid = id_docguid.

CLEAR ls_doc_output.

READ TABLE is_job_output_info-spoolids ASSIGNING <gv_spoolid> INDEX 1.
if sy-subrc = 0.
SELECT SINGLE RQCLIEnt RQO1NAME INTO (lv_client, lv_rqname) FROM tsp01 WHERE rqident = <gv_spoolid>.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
AUTHORITY    
= 'SP01'
CLIENT        = lv_client
NAME         
= lv_rqname
PART         
= 1
IMPORTING
*           CHARCO        =
*           CREATER       =
*           CREDATE       =
*           DELDATE       =
*           MAX_CREDATE   =
*           MAX_DELDATE   =
*           NON_UNIQ      =
*           NOOF_PARTS    =
*           RECTYP        =
*           SIZE          =
*           STOTYP        =
TYPE          = type
OBJTYPE      
= objtype
EXCEPTIONS
FB_ERROR     
= 1
FB_RSTS_OTHER
= 2
NO_OBJECT    
= 3
NO_PERMISSION
= 4.
if objtype(3) = 'OTF'.
is_otf
= 'X'.
else.
is_otf
= space.
endif.
if is_otf = 'X'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID                   
= <gv_spoolid>
NO_DIALOG                     
= ' '
*       DST_DEVICE                     =
*       PDF_DESTINATION                =
IMPORTING
PDF_BYTECOUNT                 
= numbytes
PDF_SPOOLID                   
= pdfspoolid
*       OTF_PAGECOUNT                  =
BTC_JOBNAME                   
= jobname
BTC_JOBCOUNT                  
= jobcount
TABLES
PDF                           
= pdf
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB           
= 1
ERR_NO_SPOOLJOB               
= 2
ERR_NO_PERMISSION             
= 3
ERR_CONV_NOT_POSSIBLE         
= 4
ERR_BAD_DSTDEVICE             
= 5
USER_CANCELLED                
= 6
ERR_SPOOLERROR                
= 7
ERR_TEMSEERROR                
= 8
ERR_BTCJOB_OPEN_FAILED        
= 9
ERR_BTCJOB_SUBMIT_FAILED      
= 10
ERR_BTCJOB_CLOSE_FAILED       
= 11.
IF sy-subrc = 0.
CONCATENATE LINES OF pdf INTO l_string RESPECTING BLANKS.
l_len
= strlen( l_string ).
EXPORT my_data = l_string(l_len) TO DATA BUFFER l_buffer.
IMPORT my_data TO ls_doc_output-pdf FROM DATA BUFFER l_buffer IN CHAR-TO-HEX MODE.
ENDIF.
endif.
ENDIF.
CHECK ls_doc_output-pdf IS NOT INITIAL.
l_mm
= sy-datum+4(2) + 1.
IF ( strlen( l_mm ) = 1 ).
CONCATENATE '0' l_mm INTO l_mm.
ENDIF.
CONCATENATE l_mm '/' sy-datum+0(4) '.' INTO l_mmyyyy.
TRY .
*       create persistent send request
lo_send_request
= cl_bcs=>create_persistent( ).

*       get PDF xstring and convert it to BCS format
ld_pdf_size
= XSTRLEN( ls_doc_output-pdf ).

ld_pdf_content
= cl_document_bcs=>xstring_to_solix(
ip_xstring
= ls_doc_output-pdf ).

CALL FUNCTION 'READ_TEXT'
EXPORTING
*            CLIENT                        = SY-MANDT
ID                            = 'ST'
LANGUAGE                      = 'E'
NAME                         
= 'ZRE_INVOICE_MAIL'
OBJECT                       
= 'TEXT'
*            ARCHIVE_HANDLE                = 0
*            LOCAL_CAT                     = ' '
*          IMPORTING
*            HEADER                        =
TABLES
LINES                         = lt_tlines
EXCEPTIONS
ID                            = 1
LANGUAGE                      = 2
NAME                         
= 3
NOT_FOUND                    
= 4
OBJECT                       
= 5
REFERENCE_CHECK              
= 6
WRONG_ACCESS_TO_ARCHIVE      
= 7
OTHERS                        = 8                   .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT lt_tlines INTO ls_tlines.
IF ls_tlines-tdline cs 'MM/YYYY.'.
REPLACE FIRST OCCURRENCE OF 'MM/YYYY.' IN ls_tlines-tdline WITH l_mmyyyy .
ENDIF.
IF ls_tlines-tdline cs 'DD/MM/YYYY'.
REPLACE FIRST OCCURRENCE OF 'DD/MM/YYYY' IN ls_tlines-tdline WITH '01/08/2013' .
ENDIF.
ls_message_body
-line = ls_tlines-tdline.
APPEND ls_message_body to lt_message_body.
ENDLOOP.
ld_subject 
= is_options-tdtitle.
lo_document
= cl_document_bcs=>create_document(
i_type   
= 'RAW'
i_text   
= lt_message_body
i_subject
= ld_subject ).
CONCATENATE 'Invoice statement_' is_doc-buskey+4(13) INTO lv_filename.
TRY.
CALL METHOD LO_DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE   
= 'PDF'
I_ATTACHMENT_SUBJECT
= lv_filename
I_ATTACHMENT_SIZE   
= ld_pdf_size
I_ATT_CONTENT_HEX   
= ld_pdf_content.
CATCH CX_DOCUMENT_BCS .
ENDTRY.

*       add document to send request
lo_send_request
->set_document( lo_document ).

*           add recipient (e-mail address)
select single customer INTO lv_kunnr FROM but000 as a INNER JOIN
cvi_cust_link
as b ON b~partner_guid = a~partner_guid
WHERE partner = is_doc-partner.
select single adrnr into lv_addrcomm FROM kna1 WHERE kunnr = lv_kunnr.
if lv_addrcomm is NOT INITIAL.
select smtp_addr from adr6 INTO TABLE lt_recipient WHERE addrnumber = lv_addrcomm.
LOOP AT lt_recipient INTO lw_recipient.
ls_recipient
-smtp_addr = lw_recipient-smtp_addr.
lo_recipient
= cl_cam_address_bcs=>create_internet_address(
i_address_string
= ls_recipient-smtp_addr ).
*       add recipient to send request
lo_send_request
->add_recipient( i_recipient = lo_recipient ).
ENDLOOP.

*       send document
lf_sent_to_all
= lo_send_request->send(
i_with_error_screen
= 'X' ).
IF lf_sent_to_all = 'X'.
*          message i022(so). "Delete DEVK917667
ENDIF.

*   ---------- explicit 'commit work' is mandatory! ----------------
COMMIT WORK.
endif.

* ------------------------------------------------------------------
* *            exception handling
* ------------------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* ------------------------------------------------------------------
CATCH cx_bcs INTO lo_bcs_exception.
WRITE: text-002.
WRITE: text-003, lo_bcs_exception->error_type.
EXIT.

ENDTRY.
*  endif.

former_member376779
Participant
0 Kudos

Hi,

   I want to send email with many destination and body text. Can you please tell me where you put this code???

Best regards

0 Kudos

Hi Andre,

As per my requirement, I am manually triggering the invoice smartform from BADI_RECP_SF~SF_PRINT, then after that for triggering the email with attachment from BADI_RECP_SF~SF_AFTER_OUTPUT.

Thanks & best regards,

Former Member
0 Kudos

Hi Dhanamjaya,

Thanks a lot for your kind reply.

T. Code RECPA520 running with the attachment but without mail body.

so in your given code I think I need to create attachment again right?

do you have any idea for standard attachment with  our customized mail text body if yes where can we put? how?

please do let me know if possible thn every steps.

I just need to enhance mail text body with standard mail attached in T. Code RECPA520.

thanks in advance,

Regards,

Vipul

0 Kudos

Hi Vipul,

I didn't do it for standard attachment.

May be on BADI_RECP_SF~SF_AFTER_OUTPUT you might add the mail body in memory just like spool ID, But I didn't tried this.

You can make a try, whether it works or not.

Eg. ASSIGN ('(SAPFV50P)*LIKP-LFART') TO <fs_lfart>.

Thanks & best regards,

Dhanamjaya

0 Kudos

Hi Sumanth & Srini,

There were 2 solutions for this.

1) Standard process -  Which sends invoice attachment as pdf and send email to the address maintained on transaction RECPA520. No mail content like dear sir/madam..... thanks, XXXX.

To maintain the settings on table/view V_TIVCPBS on SM30.

2) Customization process - 

   Need to send email to multiple emails which were maintained on BP/Customer

   Mail content

   Invoice as attachment

This can be done by buliding a customized ZBADI_RECP_SF.

under method FP_AFTER_OUTPUT(adobe)/SF_AFTER_OUTPUT(smartform), try to get the spool request no to which it is alloted using

   ASSIGN ('(SAPLSPADS)SPOOL_HANDLES-RQID') TO <gv_spoolid> .
  ASSIGN ('(SAPLSPADS)SPOOL_HANDLES') TO <SPOOL_HANDLE>.
  ASSIGN ('(SAPLSPADS)PRTS') TO <parts>.

convert the spool into pdf using

  FPCOMP_CREATE_PDF_FROM_SPOOL where u need to pass the spool number and part number(sub number under spool).

Later use the CL_BCS to attach the pdf, mail content, recipients mail ids

It works fine. if you need any further info let me know.

Thanks & best regards,

Dhanamjaya

Former Member
0 Kudos

Hi Dhanamjaya,

I tried to use your solution but I am not getting any value in gv_spoolid. Any idea? While debugging I found that spool id is registered after this method is called.  Thanks for any input.

Regards,

Seema

0 Kudos

Hi Seema,

When you give a print check whether the program SAPLSPADS is calling or not(place a debugger and check on which stage it is calling this program).

If it is calling the program then check whether it is updating the structure(s) SPOOL_HANDLES  and PRTS.

If it has then it will retrieve and give u the spool ids.

If the amount is 0 or less than 0 that time it won't trigger the print( if you are using the same transaction RECPA520 ).

Thanks & best regards,

Dhanamjaya

Former Member
0 Kudos

Hi Dhanamjaya Yandrapu

I can trigger email with attachment via T. Code RECPA520 but its come only with attachment without mail body.

can anyone tell me how can I have email body via standard configuration only.

no customization.

Regards,

Vipul Solanki

Former Member
0 Kudos

1) Standard process -  Which sends invoice attachment as pdf and send email to the address maintained on transaction RECPA520. No mail content like dear sir/madam..... thanks, XXXX.

I wants to send email content via standard process How it possible??

To maintain the settings on table/view V_TIVCPBS on SM30.

Vipul

Former Member
0 Kudos

Hi Sumanth,

Through standard SAP, you can send it to ONE mail id which is maintained in customer master.

I am searching for a solution to send output to all mail id's maintained in customer master.

we are planning to do as under..

1. implement enhancement while saving invoice RERAIV (BADI_RERA_INVOICE, method After_store)

2. call the smartform.

3. convert OTF format to PDF, and read mail ids from customer master

4. Generate a mail using class CL_BCS

you can try...

rgds,

Srinivas

ananthula_sumanth
Participant
0 Kudos

Thanks Srinivas for your inputs. But currently, I want to send the Invoice only to the mail-id maintained in BP. In this case, do we require any configuration settings? If BADI_RECP_SF is to be used, how to pass RECEPIENTS details to IF_EX_RECP_SF~SF_PRINT method.

Appreciate your help.

Regards,

Sumanth Kumar.

Former Member
0 Kudos

Hi Sumanth,

BADI_RECP_SF basically used in enhancing functionality of RECPA520 (Print invoice).

your requirement is the moment you save the billing document (RERAIV) output should get generate automatically and send it to receipients through mail, i don't think BADI_RECP_SF will work.

you can use BADI_RERA_INVOICE, method AFTER_STORE.

regards,

Srini

ananthula_sumanth
Participant
0 Kudos

Hello Srinivas,

Thanks for your inputs. I am struck with few points here.

1. Current process takes the SFDOCGUID and based on that, Smartform was developed and configured to Print/Preview buttions using the BADI_RECP_SF. The existing smartform dont have Invoice number as input parameter. Based on SFDOCGUID only, the invoice details are retrieved.

2. If I am going to implement BADI_RERA_INVOICE, i have to create smartform with different parameters taking may be comp.code, invoice number and year. In that case i need to redesign the smartform extraction logic and get all the details.

Is there any method/function module that will solve this purpose.

For gathering of details of Invoice, existing logic is defined with the following methods.

Gather the Invoice details

call method cl_recp_data_ra_invoice=>get_invoice

exporting

id_guid = v_invguid_c "Smartform doc gui id

importing

es_ra_invoice = st_invoice

et_ra_invoice_item = it_invoice_item

et_ra_tax_subtotal = it_ra_tax_subtotal

et_ra_object = it_ra_object

changing

cf_error = v_error.

  • Get the Contract details

CALL METHOD cl_recp_data_cn_general=>get_contract

EXPORTING

id_guid = v_invguid_c

IMPORTING

es_contract = st_contract

et_partner_all = it_partners

CHANGING

cf_error = v_error.

But when i have to use this logic from BADI_RERA_INVOICE, i cannot use it as no smartform doc gui id is genreated during the BADI call. And also the GET_INVOICE method also has mac_* macros which are not working from outside because of not finding the object reference.

Please advice if i can use something else here. Most of the logic of RE_CN_120 smartform logic is required in my custom smartform. Please advice how i can make the changes. Do we have any function modules that can return these values.

If the smartform is generated in BADI_RERA_INVOICE, how i can keep the copy of the smartform and how it can be used for reprint/archive purposes. Which approach i have to follow on this.

Srinivas, Request you to keep this thread active until i get some clarifications.

Thanks

Former Member
0 Kudos

Hi Sumanth,

Through standard SAP, you can send it to ONE mail id which is maintained in customer master.

I am searching for a solution to send output to all mail id's maintained in customer master.

we are planning to do as under..

1. implement enhancement while saving invoice RERAIV (BADI_RERA_INVOICE, method After_store)

2. call the smartform.

3. convert OTF format to PDF, and read mail ids from customer master

4. Generate a mail using class CL_BCS

you can try...

rgds,

Srinivas