Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

send mail to coustomer biirthday

Former Member
0 Kudos

hello scn,

i have  to create a background code which is related to automatically send coustomer  birthday mail...i have some fields in kna1 like date of birthday, name, and mail id.... please provide any sample scenarion and code...

thanks and regards

Rahul SInha

1 ACCEPTED SOLUTION

thanga_prakash
Active Contributor
0 Kudos

Hello Rahul,

SELECT * FROM kna1 INTO wa WHERE <date of birth> LIKE '%MMDD'.

then you can send the mail using the below program.

Here MMDD is current month and date.


*&---------------------------------------------------------------------*

*& Report  ZTP_TEST_SEND_MAIL

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  ZTP_TEST_SEND_MAIL.

TABLES: EKKO.

PARAMETERS: P_EMAIL   TYPE SOMLRECI1-RECEIVER

                                  DEFAULT 'test@sapdev.co.uk'.

TYPES: BEGIN OF T_EKPO,

  EBELN TYPE EKPO-EBELN,

  EBELP TYPE EKPO-EBELP,

  AEDAT TYPE EKPO-AEDAT,

  MATNR TYPE EKPO-MATNR,

END OF T_EKPO.

DATA: IT_EKPO TYPE STANDARD TABLE OF T_EKPO INITIAL SIZE 0,

      WA_EKPO TYPE T_EKPO.

TYPES: BEGIN OF T_CHAREKPO,

  EBELN(10) TYPE C,

  EBELP(5)  TYPE C,

  AEDAT(8)  TYPE C,

  MATNR(18) TYPE C,

END OF T_CHAREKPO.

DATA: WA_CHAREKPO TYPE T_CHAREKPO.

DATA:   IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0

                WITH HEADER LINE.

DATA:   IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0

                WITH HEADER LINE.

DATA:   T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

        T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

        T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,

        T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

        T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

        W_CNT TYPE I,

        W_SENT_ALL(1) TYPE C,

        W_DOC_DATA LIKE SODOCCHGI1,

        GD_ERROR    TYPE SY-SUBRC,

        GD_RECIEVER TYPE SY-SUBRC.

************************************************************************

*START_OF_SELECTION

START-OF-SELECTION.

*   Retrieve sample data from table ekpo

  PERFORM DATA_RETRIEVAL.

*   Populate table with detaisl to be entered into .xls file

  PERFORM BUILD_XLS_DATA_TABLE.

************************************************************************

*END-OF-SELECTION

END-OF-SELECTION.

* Populate message body text

  PERFORM POPULATE_EMAIL_MESSAGE_BODY.

* Send file by email as .xls speadsheet

  PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT

                               TABLES IT_MESSAGE

                                      IT_ATTACH

                                USING P_EMAIL

                                      'Example .xls documnet attachment'

                                      'XLS'

                                      'filename'

                                      ' '

                                      ' '

                                      ' '

                             CHANGING GD_ERROR

                                      GD_RECIEVER.

*   Instructs mail send program for SAPCONNECT to send email(rsconn01)

  PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.

*&---------------------------------------------------------------------*

*&      Form  DATA_RETRIEVAL

*&---------------------------------------------------------------------*

*       Retrieve data form EKPO table and populate itab it_ekko

*----------------------------------------------------------------------*

FORM DATA_RETRIEVAL.

  SELECT EBELN EBELP AEDAT MATNR

   UP TO 10 ROWS

    FROM EKPO

    INTO TABLE IT_EKPO.

ENDFORM.                    " DATA_RETRIEVAL

*&---------------------------------------------------------------------*

*&      Form  BUILD_XLS_DATA_TABLE

*&---------------------------------------------------------------------*

*       Build data table for .xls document

*----------------------------------------------------------------------*

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 'EBELN' 'EBELP' 'AEDAT' 'MATNR'

         INTO IT_ATTACH SEPARATED BY CON_TAB.

  CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.

  APPEND  IT_ATTACH.

  LOOP AT IT_EKPO INTO WA_CHAREKPO.

    CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP

                WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR

           INTO IT_ATTACH SEPARATED BY CON_TAB.

    CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.

    APPEND  IT_ATTACH.

  ENDLOOP.

ENDFORM.                    " BUILD_XLS_DATA_TABLE

*&---------------------------------------------------------------------*

*&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT

*&---------------------------------------------------------------------*

*       Send email

*----------------------------------------------------------------------*

FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE

                                          PIT_ATTACH

                                    USING P_EMAIL

                                          P_MTITLE

                                          P_FORMAT

                                          P_FILENAME

                                          P_ATTDESCRIPTION

                                          P_SENDER_ADDRESS

                                          P_SENDER_ADDRES_TYPE

                                 CHANGING P_ERROR

                                          P_RECIEVER.

  DATA: LD_ERROR    TYPE SY-SUBRC,

        LD_RECIEVER TYPE SY-SUBRC,

        LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,

        LD_EMAIL LIKE  SOMLRECI1-RECEIVER,

        LD_FORMAT TYPE  SO_OBJ_TP ,

        LD_ATTDESCRIPTION TYPE  SO_OBJ_NAM ,

        LD_ATTFILENAME TYPE  SO_OBJ_DES ,

        LD_SENDER_ADDRESS LIKE  SOEXTRECI1-RECEIVER,

        LD_SENDER_ADDRESS_TYPE LIKE  SOEXTRECI1-ADR_TYP,

        LD_RECEIVER LIKE  SY-SUBRC.

  LD_EMAIL  = P_EMAIL.

  LD_MTITLE = P_MTITLE.

  LD_FORMAT             = P_FORMAT.

  LD_ATTDESCRIPTION     = P_ATTDESCRIPTION.

  LD_ATTFILENAME        = P_FILENAME.

  LD_SENDER_ADDRESS     = P_SENDER_ADDRESS.

  LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.

* Fill the document data.

  W_DOC_DATA-DOC_SIZE = 1.

* Populate the subject/generic message attributes

  W_DOC_DATA-OBJ_LANGU = SY-LANGU.

  W_DOC_DATA-OBJ_NAME = 'SAPRPT'.

  W_DOC_DATA-OBJ_DESCR = LD_MTITLE .

  W_DOC_DATA-SENSITIVTY = 'F'.

* Fill the document data and get size of attachment

  CLEAR W_DOC_DATA.

  READ TABLE IT_ATTACH INDEX W_CNT.

  W_DOC_DATA-DOC_SIZE =

     ( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).

  W_DOC_DATA-OBJ_LANGU = SY-LANGU.

  W_DOC_DATA-OBJ_NAME  = 'SAPRPT'.

  W_DOC_DATA-OBJ_DESCR = LD_MTITLE.

  W_DOC_DATA-SENSITIVTY = 'F'.

  CLEAR T_ATTACHMENT.

  REFRESH T_ATTACHMENT.

  T_ATTACHMENT[] = PIT_ATTACH[].

* Describe the body of the message

  CLEAR T_PACKING_LIST.

  REFRESH T_PACKING_LIST.

  T_PACKING_LIST-TRANSF_BIN = SPACE.

  T_PACKING_LIST-HEAD_START = 1.

  T_PACKING_LIST-HEAD_NUM = 0.

  T_PACKING_LIST-BODY_START = 1.

  DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.

  T_PACKING_LIST-DOC_TYPE = 'RAW'.

  APPEND T_PACKING_LIST.

* Create attachment notification

  T_PACKING_LIST-TRANSF_BIN = 'X'.

  T_PACKING_LIST-HEAD_START = 1.

  T_PACKING_LIST-HEAD_NUM  = 1.

  T_PACKING_LIST-BODY_START = 1.

  DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.

  T_PACKING_LIST-DOC_TYPE  = LD_FORMAT.

  T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.

  T_PACKING_LIST-OBJ_NAME  = LD_ATTFILENAME.

  T_PACKING_LIST-DOC_SIZE  = T_PACKING_LIST-BODY_NUM * 255.

  APPEND T_PACKING_LIST.

* Add the recipients email address

  CLEAR T_RECEIVERS.

  REFRESH T_RECEIVERS.

  T_RECEIVERS-RECEIVER = LD_EMAIL.

  T_RECEIVERS-REC_TYPE = 'U'.

  T_RECEIVERS-COM_TYPE = 'INT'.

  T_RECEIVERS-NOTIF_DEL = 'X'.

  T_RECEIVERS-NOTIF_NDEL = 'X'.

  APPEND T_RECEIVERS.

  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

       EXPORTING

            DOCUMENT_DATA             = W_DOC_DATA

            PUT_IN_OUTBOX             = 'X'

            SENDER_ADDRESS            = LD_SENDER_ADDRESS

            SENDER_ADDRESS_TYPE       = LD_SENDER_ADDRESS_TYPE

            COMMIT_WORK               = 'X'

       IMPORTING

            SENT_TO_ALL               = W_SENT_ALL

       TABLES

            PACKING_LIST              = T_PACKING_LIST

            CONTENTS_BIN              = T_ATTACHMENT

            CONTENTS_TXT              = IT_MESSAGE

            RECEIVERS                 = T_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.

* Populate zerror return code

  LD_ERROR = SY-SUBRC.

* Populate zreceiver return code

  LOOP AT T_RECEIVERS.

    LD_RECEIVER = T_RECEIVERS-RETRN_CODE.

  ENDLOOP.

ENDFORM.

*&---------------------------------------------------------------------*

*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM

*&---------------------------------------------------------------------*

*       Instructs mail send program for SAPCONNECT to send email.

*----------------------------------------------------------------------*

FORM INITIATE_MAIL_EXECUTE_PROGRAM.

  WAIT UP TO 2 SECONDS.

  SUBMIT RSCONN01 WITH MODE = 'INT'

                WITH OUTPUT = 'X'

                AND RETURN.

ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM

*&---------------------------------------------------------------------*

*&      Form  POPULATE_EMAIL_MESSAGE_BODY

*&---------------------------------------------------------------------*

*        Populate message body text

*----------------------------------------------------------------------*

FORM POPULATE_EMAIL_MESSAGE_BODY.

  REFRESH IT_MESSAGE.

  IT_MESSAGE = 'Please find attached a list test ekpo records'.

  APPEND IT_MESSAGE.

ENDFORM.                    " POPULATE_EMAIL_MESSAGE_BODY

Regards,

Tp

7 REPLIES 7

Former Member
0 Kudos

Hello Rahul,

Are you sure that it is KNA1 to be used?

This relates to HR information,try any of the personnel related data IT0021 or IT0002 for this- if you have the PERNR in hand.

Use IT0105 for the e-mail address.

Thanks,

Chandni

0 Kudos

hello chandni,

yes m using kna1 table.... basically we use our costomer data and i have zzz field like dob and emailid....

thanga_prakash
Active Contributor
0 Kudos

Hello Rahul,

SELECT * FROM kna1 INTO wa WHERE <date of birth> LIKE '%MMDD'.

then you can send the mail using the below program.

Here MMDD is current month and date.


*&---------------------------------------------------------------------*

*& Report  ZTP_TEST_SEND_MAIL

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  ZTP_TEST_SEND_MAIL.

TABLES: EKKO.

PARAMETERS: P_EMAIL   TYPE SOMLRECI1-RECEIVER

                                  DEFAULT 'test@sapdev.co.uk'.

TYPES: BEGIN OF T_EKPO,

  EBELN TYPE EKPO-EBELN,

  EBELP TYPE EKPO-EBELP,

  AEDAT TYPE EKPO-AEDAT,

  MATNR TYPE EKPO-MATNR,

END OF T_EKPO.

DATA: IT_EKPO TYPE STANDARD TABLE OF T_EKPO INITIAL SIZE 0,

      WA_EKPO TYPE T_EKPO.

TYPES: BEGIN OF T_CHAREKPO,

  EBELN(10) TYPE C,

  EBELP(5)  TYPE C,

  AEDAT(8)  TYPE C,

  MATNR(18) TYPE C,

END OF T_CHAREKPO.

DATA: WA_CHAREKPO TYPE T_CHAREKPO.

DATA:   IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0

                WITH HEADER LINE.

DATA:   IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0

                WITH HEADER LINE.

DATA:   T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,

        T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

        T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,

        T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

        T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,

        W_CNT TYPE I,

        W_SENT_ALL(1) TYPE C,

        W_DOC_DATA LIKE SODOCCHGI1,

        GD_ERROR    TYPE SY-SUBRC,

        GD_RECIEVER TYPE SY-SUBRC.

************************************************************************

*START_OF_SELECTION

START-OF-SELECTION.

*   Retrieve sample data from table ekpo

  PERFORM DATA_RETRIEVAL.

*   Populate table with detaisl to be entered into .xls file

  PERFORM BUILD_XLS_DATA_TABLE.

************************************************************************

*END-OF-SELECTION

END-OF-SELECTION.

* Populate message body text

  PERFORM POPULATE_EMAIL_MESSAGE_BODY.

* Send file by email as .xls speadsheet

  PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT

                               TABLES IT_MESSAGE

                                      IT_ATTACH

                                USING P_EMAIL

                                      'Example .xls documnet attachment'

                                      'XLS'

                                      'filename'

                                      ' '

                                      ' '

                                      ' '

                             CHANGING GD_ERROR

                                      GD_RECIEVER.

*   Instructs mail send program for SAPCONNECT to send email(rsconn01)

  PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.

*&---------------------------------------------------------------------*

*&      Form  DATA_RETRIEVAL

*&---------------------------------------------------------------------*

*       Retrieve data form EKPO table and populate itab it_ekko

*----------------------------------------------------------------------*

FORM DATA_RETRIEVAL.

  SELECT EBELN EBELP AEDAT MATNR

   UP TO 10 ROWS

    FROM EKPO

    INTO TABLE IT_EKPO.

ENDFORM.                    " DATA_RETRIEVAL

*&---------------------------------------------------------------------*

*&      Form  BUILD_XLS_DATA_TABLE

*&---------------------------------------------------------------------*

*       Build data table for .xls document

*----------------------------------------------------------------------*

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 'EBELN' 'EBELP' 'AEDAT' 'MATNR'

         INTO IT_ATTACH SEPARATED BY CON_TAB.

  CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.

  APPEND  IT_ATTACH.

  LOOP AT IT_EKPO INTO WA_CHAREKPO.

    CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP

                WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR

           INTO IT_ATTACH SEPARATED BY CON_TAB.

    CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.

    APPEND  IT_ATTACH.

  ENDLOOP.

ENDFORM.                    " BUILD_XLS_DATA_TABLE

*&---------------------------------------------------------------------*

*&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT

*&---------------------------------------------------------------------*

*       Send email

*----------------------------------------------------------------------*

FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE

                                          PIT_ATTACH

                                    USING P_EMAIL

                                          P_MTITLE

                                          P_FORMAT

                                          P_FILENAME

                                          P_ATTDESCRIPTION

                                          P_SENDER_ADDRESS

                                          P_SENDER_ADDRES_TYPE

                                 CHANGING P_ERROR

                                          P_RECIEVER.

  DATA: LD_ERROR    TYPE SY-SUBRC,

        LD_RECIEVER TYPE SY-SUBRC,

        LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,

        LD_EMAIL LIKE  SOMLRECI1-RECEIVER,

        LD_FORMAT TYPE  SO_OBJ_TP ,

        LD_ATTDESCRIPTION TYPE  SO_OBJ_NAM ,

        LD_ATTFILENAME TYPE  SO_OBJ_DES ,

        LD_SENDER_ADDRESS LIKE  SOEXTRECI1-RECEIVER,

        LD_SENDER_ADDRESS_TYPE LIKE  SOEXTRECI1-ADR_TYP,

        LD_RECEIVER LIKE  SY-SUBRC.

  LD_EMAIL  = P_EMAIL.

  LD_MTITLE = P_MTITLE.

  LD_FORMAT             = P_FORMAT.

  LD_ATTDESCRIPTION     = P_ATTDESCRIPTION.

  LD_ATTFILENAME        = P_FILENAME.

  LD_SENDER_ADDRESS     = P_SENDER_ADDRESS.

  LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.

* Fill the document data.

  W_DOC_DATA-DOC_SIZE = 1.

* Populate the subject/generic message attributes

  W_DOC_DATA-OBJ_LANGU = SY-LANGU.

  W_DOC_DATA-OBJ_NAME = 'SAPRPT'.

  W_DOC_DATA-OBJ_DESCR = LD_MTITLE .

  W_DOC_DATA-SENSITIVTY = 'F'.

* Fill the document data and get size of attachment

  CLEAR W_DOC_DATA.

  READ TABLE IT_ATTACH INDEX W_CNT.

  W_DOC_DATA-DOC_SIZE =

     ( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).

  W_DOC_DATA-OBJ_LANGU = SY-LANGU.

  W_DOC_DATA-OBJ_NAME  = 'SAPRPT'.

  W_DOC_DATA-OBJ_DESCR = LD_MTITLE.

  W_DOC_DATA-SENSITIVTY = 'F'.

  CLEAR T_ATTACHMENT.

  REFRESH T_ATTACHMENT.

  T_ATTACHMENT[] = PIT_ATTACH[].

* Describe the body of the message

  CLEAR T_PACKING_LIST.

  REFRESH T_PACKING_LIST.

  T_PACKING_LIST-TRANSF_BIN = SPACE.

  T_PACKING_LIST-HEAD_START = 1.

  T_PACKING_LIST-HEAD_NUM = 0.

  T_PACKING_LIST-BODY_START = 1.

  DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.

  T_PACKING_LIST-DOC_TYPE = 'RAW'.

  APPEND T_PACKING_LIST.

* Create attachment notification

  T_PACKING_LIST-TRANSF_BIN = 'X'.

  T_PACKING_LIST-HEAD_START = 1.

  T_PACKING_LIST-HEAD_NUM  = 1.

  T_PACKING_LIST-BODY_START = 1.

  DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.

  T_PACKING_LIST-DOC_TYPE  = LD_FORMAT.

  T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.

  T_PACKING_LIST-OBJ_NAME  = LD_ATTFILENAME.

  T_PACKING_LIST-DOC_SIZE  = T_PACKING_LIST-BODY_NUM * 255.

  APPEND T_PACKING_LIST.

* Add the recipients email address

  CLEAR T_RECEIVERS.

  REFRESH T_RECEIVERS.

  T_RECEIVERS-RECEIVER = LD_EMAIL.

  T_RECEIVERS-REC_TYPE = 'U'.

  T_RECEIVERS-COM_TYPE = 'INT'.

  T_RECEIVERS-NOTIF_DEL = 'X'.

  T_RECEIVERS-NOTIF_NDEL = 'X'.

  APPEND T_RECEIVERS.

  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

       EXPORTING

            DOCUMENT_DATA             = W_DOC_DATA

            PUT_IN_OUTBOX             = 'X'

            SENDER_ADDRESS            = LD_SENDER_ADDRESS

            SENDER_ADDRESS_TYPE       = LD_SENDER_ADDRESS_TYPE

            COMMIT_WORK               = 'X'

       IMPORTING

            SENT_TO_ALL               = W_SENT_ALL

       TABLES

            PACKING_LIST              = T_PACKING_LIST

            CONTENTS_BIN              = T_ATTACHMENT

            CONTENTS_TXT              = IT_MESSAGE

            RECEIVERS                 = T_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.

* Populate zerror return code

  LD_ERROR = SY-SUBRC.

* Populate zreceiver return code

  LOOP AT T_RECEIVERS.

    LD_RECEIVER = T_RECEIVERS-RETRN_CODE.

  ENDLOOP.

ENDFORM.

*&---------------------------------------------------------------------*

*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM

*&---------------------------------------------------------------------*

*       Instructs mail send program for SAPCONNECT to send email.

*----------------------------------------------------------------------*

FORM INITIATE_MAIL_EXECUTE_PROGRAM.

  WAIT UP TO 2 SECONDS.

  SUBMIT RSCONN01 WITH MODE = 'INT'

                WITH OUTPUT = 'X'

                AND RETURN.

ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM

*&---------------------------------------------------------------------*

*&      Form  POPULATE_EMAIL_MESSAGE_BODY

*&---------------------------------------------------------------------*

*        Populate message body text

*----------------------------------------------------------------------*

FORM POPULATE_EMAIL_MESSAGE_BODY.

  REFRESH IT_MESSAGE.

  IT_MESSAGE = 'Please find attached a list test ekpo records'.

  APPEND IT_MESSAGE.

ENDFORM.                    " POPULATE_EMAIL_MESSAGE_BODY

Regards,

Tp

0 Kudos

hello tp

i m basically use multiple email id for particular birthdate..... and email id is stored in kna1 table... how it can be fetch data like email id... and send it to same date...

0 Kudos

Hello Rahul,

You can do a query from KNA1 table as suggested earlier and store all the e-mails to an internal table.

Then loop at the internal table and send a mail accordingly for every mail id, like below.

SELECT * FROM kna1 INTO TABLE itab WHERE <dob> LIKE '%MMDD'.

LOOP AT itab INTO str.

***E-mail sending logic****

ENDLOOP.

Regards,

Tp

Former Member
0 Kudos

Hi Rahul,

get customer data from kna1 table by comparing current date.

SELECT single * FROM kna1 INTO wa WHERE <date of birth> = current date.

then add the logic to send mail to respective customer.

Thanks,

Sree

0 Kudos

Hello Polu,

You code won't work, please check your where condition. you have written date of birth EQ current date.

How can it be possible ?

Regards,

Tp