Mail using ABAP program

Hi all,
see below it.
TABLES: ZST2.
DATA : BEGIN OF ITAB OCCURS 0,
EMPNO LIKE ZST2-EMPNO,
EMPNAME LIKE ZST2-EMPNAME,
END OF ITAB.
DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
listobject LIKE abaplist OCCURS 10,
compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
w_object_hd_change LIKE sood1,
compressed_size LIKE sy-index.
START-OF-SELECTION.
SELECT EMPNO EMPNAME "PERNR ENAME
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM ZST2."WHERE PERNR < 50.
LOOP AT ITAB.
WRITE :/02 SY-VLINE , ITAB-EMPNO, 15 SY-VLINE , ITAB-EMPNAME.
*SY-VLINE.
ENDLOOP.
Receivers
receiver_list-recextnam = 'ur@company'. "-->
EMAIL ADDRESS
RECEIVER_list-RECESC = 'E'. "<-
RECEIVER_list-SNDART = 'INT'."<-
RECEIVER_list-SNDPRI = '1'."<-
APPEND receiver_list.
General data
w_object_hd_change-objla = sy-langu.
w_object_hd_change-objnam = 'Object name'.
w_object_hd_change-objsns = 'P'.
Mail subject
w_object_hd_change-objdes = 'Message subject'.
Mail body
APPEND 'Message content' TO message_content.
Attachment
CALL FUNCTION 'SAVE_LIST'
EXPORTING
list_index = '0'
TABLES
listobject = listobject.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
compressed_size = compressed_size
TABLES
in = listobject
out = compressed_attachment.
DESCRIBE TABLE compressed_attachment.
CLEAR packing_list.
packing_list-transf_bin = 'X'.
packing_list-head_start = 0.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = sy-tfill.
packing_list-objtp = 'ALI'.
packing_list-objnam = 'Object name'.
packing_list-objdes = 'Attachment description'.
packing_list-objlen = compressed_size.
APPEND packing_list.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
object_hd_change = w_object_hd_change
object_type = 'RAW'
owner = sy-uname
TABLES
objcont = message_content
receivers = receiver_list
packing_list = packing_list
att_cont = compressed_attachment.
how prepared it?
thx,
s.suresh

hi,
chek this,,
TABLES :VARID.                   "Variant directory
DATA:  GV_NAMES     LIKE TSP01-RQ2NAME,
      GD_BYTECOUNT        LIKE TST01-DSIZE,
            GD_BUFFER          TYPE STRING,
      PDF_LINES          TYPE TLINE OCCURS 0 WITH HEADER LINE,
SEND_REQUEST       TYPE REF TO CL_BCS,
      L_SUBJECT          LIKE SOOD-OBJDES,
      DOCUMENT           TYPE REF TO CL_DOCUMENT_BCS,
      BCS_EXCEPTION      TYPE REF TO CX_BCS,
      V_CTR              TYPE I VALUE 0,
      IT_INPUT           LIKE BDI_LINE OCCURS 0 WITH HEADER LINE,
      IT_MESS_ATT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
      IT_BINARY_CONT     TYPE SOLIX_TAB,
      LEN_OUT            TYPE I,
T_SPONO LIKE TSP01SYS OCCURS 0 WITH HEADER LINE.
DATA :GV_RQCRETIME LIKE TSP01-RQCRETIME.
DATA IT_VALUE LIKE  RSPARAMS OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF T_VARID OCCURS 0,
      VARIANT LIKE VARID-VARIANT,
      END OF T_VARID.
SELECTION SCREEN                                                     *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS: S_VAR FOR VARID-VARIANT.
SELECTION-SCREEN END OF BLOCK B1.
Select the varinat name from the table VARID
SELECT VARIANT INTO TABLE T_VARID
                      FROM VARID
                      WHERE REPORT EQ 'ZAMRP003'
                        AND VARIANT IN S_VAR.
SORT T_VARID.
CHECK NOT T_VARID[] IS INITIAL.
LOOP AT T_VARID.
  SUBMIT ZAMRP003 USING SELECTION-SET T_VARID-VARIANT
                  TO SAP-SPOOL SAP COVER PAGE ' '
                         DESTINATION  ' '
                         IMMEDIATELY  'X'
                         KEEP IN SPOOL  'X'
                         LINE-COUNT 60000
                         LINE-SIZE 134
                         LAYOUT      'X_58_170'
                         WITHOUT SPOOL DYNPRO AND RETURN.
  COMMIT WORK AND WAIT.
  CONCATENATE SY-DATUM '000000' INTO GV_RQCRETIME.
  CONCATENATE 'ZAMRP003_' SY-UNAME+0(3) INTO GV_NAMES.
  SELECT * FROM TSP01 INTO TABLE T_SPONO
              WHERE RQCLIENT = SY-MANDT
              AND   RQ0NAME  = 'LIST1S'
              AND   RQ2NAME  = GV_NAMES
              AND   RQOWNER  = SY-UNAME
              AND   RQCRETIME GE GV_RQCRETIME.
  SORT T_SPONO BY RQIDENT DESCENDING.
  CALL FUNCTION 'RS_VARIANT_CONTENTS'
    EXPORTING
      REPORT               = 'ZAMRP003'
      VARIANT              = T_VARID-VARIANT
    TABLES
      VALUTAB              = IT_VALUE
    EXCEPTIONS
      VARIANT_NON_EXISTENT = 1
      VARIANT_OBSOLETE     = 2
      OTHERS               = 3.
  IF SY-SUBRC <> 0.
    MESSAGE E000(ZH) WITH 'Error in processing variant'.
  ENDIF.
Create the email request
  PERFORM CREATE_EMAIL .
  SORT T_SPONO BY RQIDENT DESCENDING.
  READ TABLE T_SPONO INDEX 1.
  IF SY-SUBRC NE 0.
    MESSAGE E000(ZH) WITH 'Error creating spool'
                          RAISING CONVERSION_ERROR.
  ENDIF.
  CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
      SRC_SPOOLID              = T_SPONO-RQIDENT
      NO_DIALOG                = ' '
    IMPORTING
      PDF_BYTECOUNT            = GD_BYTECOUNT
    TABLES
      PDF                      = PDF_LINES
    EXCEPTIONS
      ERR_NO_ABAP_SPOOLJOB     = 1
      ERR_NO_SPOOLJOB          = 2
      ERR_NO_PERMISSION        = 3
      ERR_CONV_NOT_POSSIBLE    = 4
      ERR_BAD_DESTDEVICE       = 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
      OTHERS                   = 12.
  IF SY-SUBRC <> 0.
    MESSAGE E000(ZH) WITH 'Error converting spool to PDF'
                          RAISING CONVERSION_ERROR.
  ENDIF.
Transfer the 132-long strings to 255-long strings
  LOOP AT PDF_LINES.
    TRANSLATE PDF_LINES USING ' ~'.
    CONCATENATE GD_BUFFER PDF_LINES INTO GD_BUFFER.
  ENDLOOP.
  TRANSLATE GD_BUFFER USING '~ '.
  DO.
    IT_MESS_ATT = GD_BUFFER.
    APPEND IT_MESS_ATT.
    SHIFT GD_BUFFER LEFT BY 255 PLACES.
    IF GD_BUFFER IS INITIAL.
      EXIT.
    ENDIF.
  ENDDO.
Convert format of PDF data to that required for email
  REFRESH IT_BINARY_CONT.
  PERFORM CONVERT_134_TO_255_STR TABLES IT_MESS_ATT
                                        IT_BINARY_CONT.
Now add it as an attachment
  CONCATENATE 'ZAMRP003' '.pdf' INTO L_SUBJECT.
  TRY.
      CALL METHOD DOCUMENT->ADD_ATTACHMENT
        EXPORTING
          I_ATTACHMENT_TYPE    = 'PDF'
          I_ATTACHMENT_SUBJECT = L_SUBJECT
          I_ATT_CONTENT_HEX    = IT_BINARY_CONT.
Add document to send request
      CALL METHOD SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
    CATCH CX_BCS INTO BCS_EXCEPTION.
    Send the message that occurred and then exit
      MESSAGE ID     BCS_EXCEPTION->MSGID
              TYPE   BCS_EXCEPTION->MSGTY
              NUMBER BCS_EXCEPTION->MSGNO
              WITH   BCS_EXCEPTION->MSGV1 BCS_EXCEPTION->MSGV2
                     BCS_EXCEPTION->MSGV3 BCS_EXCEPTION->MSGV4.
      EXIT.
  ENDTRY.
Send the email now
  PERFORM SEND_THE_EMAIL CHANGING SEND_REQUEST.
  COMMIT WORK.
ENDLOOP.
*&      Form  convert_134_to_255_str
      text
FORM CONVERT_134_TO_255_STR  TABLES   PT_134
                                      PT_255.
  DATA: L_DSN(100).
  L_DSN = 'c:\temp\text_workarea.txt'.
Output file in 134 byte blocks
  OPEN DATASET L_DSN FOR OUTPUT IN BINARY MODE.
  IF SY-SUBRC NE 0.
    WRITE :/ 'Error in PDF Conversion'.
    STOP.
  ENDIF.
  LOOP AT PT_134.
    TRANSFER PT_134 TO L_DSN.
  ENDLOOP.
  CLOSE DATASET L_DSN.
Read file in 255 byte blocks
  OPEN DATASET L_DSN FOR INPUT IN BINARY MODE.
  IF SY-SUBRC NE 0.
    WRITE :/ 'Error in PDF Conversion'.
    STOP.
  ENDIF.
  READ DATASET L_DSN INTO PT_255.
  WHILE SY-SUBRC = 0.
    APPEND PT_255.
    READ DATASET L_DSN INTO PT_255.
  ENDWHILE.
  APPEND PT_255.
  CLOSE DATASET L_DSN.
Clear file
  OPEN DATASET L_DSN FOR OUTPUT IN BINARY MODE.
  CLOSE DATASET L_DSN.
ENDFORM.                    " convert_134_to_255_str
*&      Form  send_the_email
      text
FORM SEND_THE_EMAIL  CHANGING P_SEND_REQUEST TYPE REF TO CL_BCS.
  DATA: L_RECIPIENT          TYPE REF TO IF_RECIPIENT_BCS,
        L_SENT_TO_ALL        TYPE OS_BOOLEAN,
        LT_RECIP_ERROR       TYPE BCSY_RE,
        LT_ORIG_ERROR        TYPE BCSY_ERCP,
        LV_STR               TYPE SZA5_D0700-SMTP_ADDR.
  TRY.
Add recipients (e-mail address) ----------------------
      LOOP AT IT_VALUE WHERE SELNAME = 'S_USER'.
  Create recipient
        LV_STR = IT_VALUE-LOW.
        L_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
                                        LV_STR ).
  Add recipient with its respective attributes to send request
        SEND_REQUEST->ADD_RECIPIENT( L_RECIPIENT ).
      ENDLOOP.
Send document ---------------------------------------
      CALL METHOD SEND_REQUEST->SEND_WITHOUT_DIALOG(
         IMPORTING
           E_RECIPIENTS_WITH_ERROR = LT_RECIP_ERROR
           E_ORIG_RECS_WITH_ERROR  = LT_ORIG_ERROR
           E_SENT_TO_ALL           = L_SENT_TO_ALL ).
For internet addresses, this should always be OK. It is only later
that an express message is sent if it fails. Hence no need to do
much error processing here.
      IF L_SENT_TO_ALL = 'X'.
        MESSAGE I217(ZH).       "Sent to all recipients.
      ENDIF.
    CATCH CX_BCS INTO BCS_EXCEPTION.
    Send the message that occurred and then exit
      MESSAGE ID     BCS_EXCEPTION->MSGID
              TYPE   BCS_EXCEPTION->MSGTY
              NUMBER BCS_EXCEPTION->MSGNO
              WITH   BCS_EXCEPTION->MSGV1 BCS_EXCEPTION->MSGV2
                     BCS_EXCEPTION->MSGV3 BCS_EXCEPTION->MSGV4.
      EXIT.
  ENDTRY.
ENDFORM.                    " send_the_email
*&      Form  create_email
FORM CREATE_EMAIL.
  DATA: SUB TYPE SO_OBJ_DES,
    WA_TEXT TYPE SOLI,
    LT_TEXT TYPE SOLI_TAB.
  TRY.
-------- create persistent send request ------------------------
      SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
      SEND_REQUEST->SET_STATUS_ATTRIBUTES( 'E' ).
      SEND_REQUEST->SEND_REQUEST->SET_LINK_TO_OUTBOX( 'X' ).
-------- create and set document with attachment ---------------
      WA_TEXT        = 'Dear Recipient,'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = ' '.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = ' '.
      APPEND WA_TEXT TO LT_TEXT.
     wa_text        = 'We apologise for the inaccurate Fixed Asset '.
     APPEND wa_text TO lt_text.
     wa_text =  'Reports sent to you and any inconvenience caused by'.
     APPEND wa_text TO lt_text.
     wa_text = 'this error.'.
     APPEND wa_text TO lt_text.
     wa_text        = ' '.
     APPEND wa_text TO lt_text.
     wa_text = 'The changing of the report from a manual to '.
     APPEND wa_text TO lt_text.
     wa_text = 'automatic process could not be fully tested in a test'
     APPEND wa_text TO lt_text.
     wa_text = ' environment and this has led to the problems that'.
     APPEND wa_text TO lt_text.
     wa_text = ' you have seen. We have now corrected these errors '.
     APPEND wa_text TO lt_text.
     wa_text = 'and the automated process will continue from now on'.
     APPEND wa_text TO lt_text.
     wa_text = ''.
     APPEND wa_text TO lt_text.
     wa_text = 'Thank you for your patience during this time.'.
     APPEND wa_text TO lt_text.
     wa_text = ''.
     APPEND wa_text TO lt_text.
     wa_text = ''.
     APPEND wa_text TO lt_text.
      WA_TEXT  = 'This is the monthly fixed asset report for your'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT = 'cost centre(s) which shows assets'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT = 'for the previous calendar month.'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = ' '.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = ' '.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = 'N.B. The asset locations shown on this report'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = 'may be long out-of-date and are offered for'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = 'guidance only.'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = 'Please note that it is your responsibility to'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = 'know: Where each asset is; What it is; and Why'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = 'it is needed?'.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = ' '.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = ' '.
      APPEND WA_TEXT TO LT_TEXT.
      WA_TEXT        = 'For any queries regarding the email or report'.
      APPEND WA_TEXT TO LT_TEXT.
*-- Start of changes by SPUSA (001)
     wa_text        = 'please contact abc@com'.
      WA_TEXT        = 'please contact abc@com'.com'.
*-- End of changes by SPUSA (001)
      APPEND WA_TEXT TO LT_TEXT.
      SUB = 'Asset Management'.
      DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
                        I_TYPE    = 'RAW'
                        I_TEXT    = LT_TEXT
                        I_LENGTH  = '24'
                        I_SUBJECT = SUB ).
    CATCH CX_BCS INTO BCS_EXCEPTION.
    Send the message that occurred and then exit
      MESSAGE ID     BCS_EXCEPTION->MSGID
              TYPE   BCS_EXCEPTION->MSGTY
              NUMBER BCS_EXCEPTION->MSGNO
              WITH   BCS_EXCEPTION->MSGV1 BCS_EXCEPTION->MSGV2
                     BCS_EXCEPTION->MSGV3 BCS_EXCEPTION->MSGV4.
      EXIT.
  ENDTRY.
ENDFORM.                    " create_email
reward if helpful,
N.Rekha

Similar Messages

  • After sending attachment through mail using ABAP program.....

    Hello Experts,
    I am facing a problem to fulfill a requirement.
    My requirement is....sending the data of the internal table to an external mail with attachment(excel format). I have done with this. But when o am opening the excel sheet(attachment) it is showing a message that 'The file you are trying to open is in different format than specified by the file extension'
    I am using the extension 'XLS' and 'RAW ' in the coding for the file formats.
    You can please suggest your solutions if you know or already faced this type of issues.
    Thank you.
    Regards,
    Anand

    Hi,
    The system does not trust you....
    I have the feeling that the file you are sending is a text file with the extension 'XLS'
    If the file is comma separated values (http://en.wikipedia.org/wiki/Comma-separated_values) then
    use the extension 'CSV' if it is a tab separated then use the extension 'TXT' .
    Regards.
    CSV is also good for tab separated  I just checked by a copy of BCS_EXAMPLE_7 and changing:
            i_attachment_type    = 'CSV'                        "#EC NOTEXT

  • Is it possible to reset password for any user using abap program

    Hi friends,
    Is it possible to reset password for any user using abap program by specifying client number and user id. in selection screen.
    if any code for that to reset password please mail me.
    Thanks & Regards,
    Yogesh

    Hello Yogesh,
    Yes you can reset the password for any body using ABAP Code. But for that you really don't need any client number.
    If this process is on regular basis, then recommended is to use BAPI for changing the user details Otherwise BDC also works fine.
    => Function Module - BAPI_USER_CHANGE
    Call this in the program for resetting the password.
    => CALL TRANSACTION 'SU01' USING InternalTable
    This will be executed in the BDC of SU01 transaction recording. Use the Password Change button in the application toolbar of transaction while recording.
    Hope this helps.
    PS If the answer solves your query, plz close the thread by marking it solved and rewarding each reply.
    Regards

  • Send a mail via ABAP program

    Hello Experts,
    I want to send mail via ABAP program with the following requirements :
    1. Recipient is OUTLOOK email -id
    2. Sender address has to be an external email-id
    3. Send mail as CC and BCC also to other email-id.
    Is there any function module which can satisfy all the above requirements.
    Regards,
    Mansi.

    hi,
    this code will definately help you just go through it:
    firstly  exported the data to memory using the FM LIST_FROM_MEMORY.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = t_listobject
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE e000(su) WITH text-001.
    ENDIF.
    then i converted it into ASCII using LIST_TO_ASCI,
    CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
    listasci = t_xlstab
    listobject = t_listobject
    EXCEPTIONS
    empty_list = 1
    list_index_invalid = 2
    OTHERS = 3.
    IF sy-subrc NE 0.
    MESSAGE e003(yuksdbfzs).
    ENDIF.
    This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
    cl_abap_char_utilities=>horizontal_tab.
    Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
    This will create an excel attachment.
    Sample code for formatting the data for the attachment in excel format.
    u2022     Format the data for excel file download
    LOOP AT t_xlstab INTO wa_xlstab .
    DESCRIBE TABLE t_xlstab LINES lw_cnt.
    CLEAR lw_sytabix.
    lw_sytabix = sy-tabix.
    u2022     If not new line then replace '|' by tabs
    IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
    REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
    WITH cl_abap_char_utilities=>horizontal_tab.
    MODIFY t_xlstab FROM wa_xlstab .
    CLEAR wa_xlstab.
    wa_xlstab = cl_abap_char_utilities=>newline.
    IF lw_cnt NE 0 .
    lw_sytabix = lw_sytabix + 1.
    u2022     Insert new line for the excel data
    INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
    lw_cnt = lw_cnt - 1.
    ENDIF.
    CLEAR wa_xlstab.
    ENDIF.
    ENDLOOP.
    Sample code for creating attachment and sending mail:
    FORM send_mail .
    u2022     Define the attachment format
    lw_doc_type = 'XLS'.
    u2022     Create the document which is to be sent
    lwa_doc_chng-obj_name = 'List'.
    lwa_doc_chng-obj_descr = w_subject. "Subject
    lwa_doc_chng-obj_langu = sy-langu.
    u2022     Fill the document data and get size of message
    LOOP AT t_message.
    lt_objtxt = t_message-line.
    APPEND lt_objtxt.
    ENDLOOP.
    DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
    IF lw_tab_lines GT 0.
    READ TABLE lt_objtxt INDEX lw_tab_lines.
    lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
    lwa_doc_chng-obj_langu = sy-langu.
    lwa_doc_chng-sensitivty = 'F'.
    ELSE.
    lwa_doc_chng-doc_size = 0.
    ENDIF.
    u2022     Fill Packing List For the body of e-mail
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = 'RAW'.
    APPEND lt_packing_list.
    u2022     Create the attachment (the list itself)
    DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
    u2022     Fill the fields of the packing_list for creating the attachment:
    lt_packing_list-transf_bin = 'X'.
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = lw_doc_type.
    lt_packing_list-obj_name = 'Attach'.
    lt_packing_list-obj_descr = w_docdesc.
    lt_packing_list-doc_size = lw_tab_lines * 255.
    APPEND lt_packing_list.
    u2022     Fill the mail recipient list
    lt_reclist-rec_type = 'U'.
    LOOP AT t_recipient_list.
    lt_reclist-receiver = t_recipient_list-address.
    APPEND lt_reclist.
    ENDLOOP.
    u2022     Finally send E-Mail
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc_chng
    put_in_outbox = 'X'
    commit_work = 'X'
    IMPORTING
    sent_to_all = lw_sent_to_all
    TABLES
    packing_list = lt_packing_list
    object_header = lt_objhead
    contents_bin = t_xlstab
    contents_txt = lt_objtxt
    receivers = lt_reclist
    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.
    Hope it will help you
    regards
    Rahul sharma

  • Reading email using abap program

    Hi All,
    I have a requirement to read inbox mails through abap program.
    Also from address, to address, subject.
    Could someone help me  !!
    Thanks in advance,
    Venkat
    Moderator message : Requirements dumping not allowed, show the work you have already done.  Thread locked.
    Edited by: Vinod Kumar on Jan 30, 2012 11:37 AM

    Hi,
       Please find below the tables if you are usinG BI 7.0
    For 3.5 also they are almost similar...
    Getting Details regarding DSO
    1) RSDODSO
    2) RSDODSOT
    3) RSDODSOIOBJ
    4) RSDODSOATRNAV
    Getting Details regarding InfoObjects
    5)  RSDIOBJ
    6)  RSDIOBJT
    Getting Details regarding DataSource
    7)   RSDSSEG
    8)   RSDS
    9)   RSDST
    10) RSDSSEGFD
    Getting Details regarding Transformation
    11)   RSTRAN
    12)   RSTRANFIELD
    13)   RSTRANRULE
    Getting Details regarding InfoCube
    14) RSDDIME
    15) RSDCUBE
    16) RSDCUBEIOBJ
    17) RSDDIMEIOBJ
    18) RSDCUBET
    19) RSDDIMET
    Getting Details regarding MultiProvider
    20) RSDCUBEMULTI
    21) RSDICMULTIIOBJ
    Getting Details regarding Queries
    22) RSREPDIR
    23) RSZELTTXT
    Based on the above tables ,we can write our own generic program based on your needs.....
    These tables help you a lot in order to achieve that.
    Regards
    vamsi

  • Synchronizing Two Custom Z Tables Using Abap Program

    Hi,
        My requirement is Synchronizing two custom z tables using abap program me.
    I have vendors in two tables, i have to select the common vendors from first which are existing in second  table also.
    In first table each vendor can have more than one supplier types in one field only. In second table these supplier types are divided into
    different fields.
         My requirement is I have to check supplier types in first table and i have to pass X to corresponding supplier types in second table vendor.
    I have to pass X value for each depending in Second table depending upon supplier type in first table.
    . How to do it can any one suggest with code.
    Thanks in Advance,
    Vivek
    <subject edited by moderator>
    Message was edited by: Manish Kumar

    Hi,
    Imho, you need to get (meaning, extract into separate fields) the different supplier types from Table1 first. Your key for Table1 is the vendor no, which is also the key in Table2 (or the key for Table2 is Vendor no & Type).
    For better performance, better select multiple/all required entries from Table1 instead of doing a select endselect.
    Depending on the format of the vendortypes in Table1, put them in a new itab (for our purpose named Table1New where vendor no & type are the only 2 fields. For example, if the type length is fixed to 2 chars, or divided by space,... use your coding accordingly.
    Next step is to select all vendor no's in Table2 which you have selected in Table1. If in Table2, the vendor no is the only key (and the all vendor types are filled in a single record), then loop check the vendor types from Table1New against the types in Table2.
    If the key of Table2 is vendor no & vendor type, then do a read table for the key.
    The logic in pseudo-code:
    Select from Table1 into table. If you'd like to limit the selection size, add package size statement.
         extract the vendor types in to itab Table1New.
         Select the vendor & types from Table2 by using the for all entries option (better performance).
         loop at Table1New
              check in Table2:
                   if the unique key is vendor no: check all fields for the vendor type from Table1New
                   if the unique key combo is vendor no & type: check by using a read table.
              If not found => add entry to Table2
         endloop.
    endselect Table1 (when using package size)
    I guess the most difficult step is to extract the types from Table1 into separate fields, all the rest seems straight forward. Please keep in mind the itab type definitions for a better performance.
    Good luck!
    Best regards,
    Zhou

  • Fork in process chain using ABAP program

    Hello everyone.
    I need a fork in my chain. Depending on the values in some db table I will make a decision: do some process or skip and go further. The only solution I can see is using ABAP program. But unfortunately It doesn't return status. Any suggestion will be appreciated.

    Hi,
    You have few process to run after the abap program. So make all those process as a different chain, and at the end of the ABAP program include a function module to trigger this chain, based on your condition.
    If you like this idea, please revert for more information.
    Hope this helps.
    Thank you,

  • How to send mail using jsp program

    am very new to jsp and doing my final year project. i need to send mails using my jsp program.can anyone say wht to do that is wht to include to send mails using jsp program. n also a sample code to send mail using jsp program.
    Thanx in advance

    Use below script.
    <%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
    <%
    Properties props = new Properties();
    props.put("mail.smtp.host", "mailserver.com");
    Session s = Session.getInstance(props,null);
    InternetAddress from = new InternetAddress("[email protected]");
    InternetAddress to = new InternetAddress([email protected]");
    MimeMessage message = new MimeMessage(s);
    message.setFrom(from);
    message.addRecipient(Message.RecipientType.TO, to);
    message.setSubject("Your subject");
    message.setText("Your text");
    Transport.send(message);
    %>{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Unzip files using ABAP program

    Hi All,
    Can anybody guide me how to Unzip a .zip file using ABAP program... Appreciate your immediate reply...
    actually, my scenario is to check whether zip file is created in appl.server or not.., and if zip file created then i need to check whether its blank file or any content exist inside the file...
    Thanks in advance
    Bhasker

    hi
    good
    parameters: command(236) lower case.
    data: std_lines(255) occurs 0 with header line.
      call function 'RFC_REMOTE_PIPE'
        destination 'SERVER_EXEC'
        exporting
          command = command
          read = 'X'
        tables
          pipedata = std_lines
        exceptions
          communication_failure = 1
          system_failure = 2.
    You should put your Unix command in the command parameter. "gunzip /yourfilepath/yourfilename" works on my Unix system. Once you determine the proper Unix command, you should be set. This technique is also nice because it provides you with echos back from Unix in table std_lines. For more complex Unix activity, you may want to consider throwing together a Unix script, and calling that via this code.
    reward point if helpful.
    thanks
    mrutyun^

  • Access table using ABAP program in other database

    Dear SAP Expert,
    We have requirement that related to SAP interface.
    Our SAP system run on Oracle database 11g (Unix).
    Illustration: SAP system = A non SAP system = B
    We need to access a table using ABAP program (from SAP system A) in other database (system B) that are not necessarily SAP database. The non-SAP system using SQL Server 2008 (Windows).
    What is the best practice for this interface
    Do we need database link? If yes, please help to inform me the details step to configure it.
    Thanks and Regards

    Hi Friend,
    You try using an intermediate system..passing your input required to fetch the data..and PI should call the respective query to retrive record..once the full flow is completed you should get the return through some table in the calling program.
    else.
    ask the other system guy to write a function with select query and ask him to expose as RFC and that RFC we have to call it as RFC in our program to get the required values and only thing we need here is a proper connector in place.
    Regards
    S.Janagar

  • How to print external file using ABAP program

    Hello
    I want to print an external file which is located in server (
    20.99.0.18\GUI\xyz\8.0QUALITY\QM_TS.DOC) .....i want to print these kind of files(which i have retrieved from table 'DRAW' field 'filep' )......i need to print these files using ABAP program.
    thank you
    Vikram.
    Message was edited by:
            Vikram Bojja

    extract the data and pass to script or smartform for printing

  • Can a transaction be called in background dynamically using ABAP program??

    Hi Experts,
    Can a transaction be called in background dynamically using ABAP program without BDC???
    Regards,
    Mansi.

    u can create job dynamically through programming..Try this sample code..
    data: jobname like tbtcjob-jobname value
                                 ' TRANSFER TRANSLATION'.
    data: jobcount like tbtcjob-jobcount,
          host like msxxlist-host.
    data: begin of starttime.
            include structure tbtcstrt.
    data: end of starttime.
    data: starttimeimmediate like btch0000-char1.
    Job open
      call function 'JOB_OPEN'
           exporting
                delanfrep        = ' '
                jobgroup         = ' '
                jobname          = jobname
                sdlstrtdt        = sy-datum
                sdlstrttm        = sy-uzeit
           importing
                jobcount         = jobcount
           exceptions
                cant_create_job  = 01
                invalid_job_data = 02
                jobname_missing  = 03.
      if sy-subrc ne 0.
                                           "error processing
      endif.
    Insert process into job
    SUBMIT zreport and return               << Here it is a static call but u can make it dynamic
                    with p_param1 = 'value'
                    with p_param2 = 'value'
                    user sy-uname
                    via job jobname
                    number jobcount.
      if sy-subrc > 0.
                                           "error processing
      endif.
    Close job
      starttime-sdlstrtdt = sy-datum + 1.
      starttime-sdlstrttm = '220000'.
      call function 'JOB_CLOSE'
           exporting
                event_id             = starttime-eventid
                event_param          = starttime-eventparm
                event_periodic       = starttime-periodic
                jobcount             = jobcount
                jobname              = jobname
                laststrtdt           = starttime-laststrtdt
                laststrttm           = starttime-laststrttm
                prddays              = 1
                prdhours             = 0
                prdmins              = 0
                prdmonths            = 0
                prdweeks             = 0
                sdlstrtdt            = starttime-sdlstrtdt
                sdlstrttm            = starttime-sdlstrttm
                strtimmed            = starttimeimmediate
                targetsystem         = host
           exceptions
                cant_start_immediate = 01
                invalid_startdate    = 02
                jobname_missing      = 03
                job_close_failed     = 04
                job_nosteps          = 05
                job_notex            = 06
                lock_failed          = 07
                others               = 99.
      if sy-subrc eq 0.
                                           "error processing
      endif.
    Regards,
    JOy.

  • HOW TO creat  BAR CHART using ABAP Programming

    DEAR ALL,
    I want some help as to how to creat GRAPHICAL display using ABAP programing (BAR CHART) any sample codes Example will be very helpful.
    Regards,
    VJ

    On earlier versions, you can do something like this.
    [code]
    REPORT ZRICH_0005 .
    DATA: BEGIN OF ITAB_DATA OCCURS 0,
               DATANAME(15),
               QUANTITY1 TYPE I,
               QUANTITY2 TYPE I,
               QUANTITY3 TYPE I,
          END OF ITAB_DATA.
    Data: BEGIN OF ITAB_OPTIONS OCCURS 0,
               OPTION(20),
          END OF ITAB_OPTIONS.
    ITAB_DATA-DATANAME = 'Maple'.
    ITAB_DATA-QUANTITY1 = 5500.
    ITAB_DATA-QUANTITY2 = 6200.
    ITAB_DATA-QUANTITY3 = 5900.
    APPEND ITAB_DATA.
    ITAB_DATA-DATANAME = 'Oak'.
    ITAB_DATA-QUANTITY1 = 3500.
    ITAB_DATA-QUANTITY2 = 5200.
    ITAB_DATA-QUANTITY3 = 4400.
    APPEND ITAB_DATA.
    ITAB_DATA-DATANAME = 'Cherry'.
    ITAB_DATA-QUANTITY1 = 1800.
    ITAB_DATA-QUANTITY2 = 2200.
    ITAB_DATA-QUANTITY3 = 1900.
    APPEND ITAB_DATA.
    CALL FUNCTION 'GRAPH_MATRIX_3D'
         EXPORTING
              COL1        = 'Jan'
              COL2        = 'Feb'
              COL3        = 'Mar'
              TITL        = 'Lumber Usage in $'
         TABLES
              DATA        = ITAB_DATA
              OPTS        = ITAB_OPTIONS
         EXCEPTIONS
              OTHERS      = 1.
    [/code]
    Regards,
    Rich Heilman

  • Name the infotypes we uplode using abap programs

    Hi,
    can anyboby let me know, Name the infotypes we uplode using abap programs?
    Thanks

    IT0008
    IT0045
    IT0589  ETC
    some of them can be made through LSMW also but we use BDC . the main reason is we wont find Feilds to upload those data in templates

  • How to Move file / call UNIX command using ABAP Program

    Hi, ABAP Guru.
    I need to Cut & Paste file (Move file from one location to another location) on Network Shared Drive using ABAP program.
    But I can't figured out how to do this and what ABAP Command / FM / Method (and maybe UNIX command) that being used.
    Please give me the advice.
    Best regard and Thank you all.
    Nattapash C.

    all methods for your requirements should be in class CL_GUI_FRONTEND_SERVICES

Maybe you are looking for

  • How to find summation inside a loop?

    Hi Experts, Please refer following code: for (int i=0 ; i<wdContext.nodeWorklist().size() ; i++){   wdContext.nodeWorklist().setLeadSelection(i);   categoryElement = wdContext.createCategoriesElement();   category_1Element = wdContext.createCategorie

  • IO6 upgrade, now music will not sync to iPhone 4S????

    I recently upgraded my iPhone 4S to IO6.  Since then my music will no longer sync.  I have over 5,200 songs and all were on the iPhone before I upgraded. However, once I upgraded to IO6 the music disappeared off the iPhone (it's still in iTunes).  Be

  • Switching iMessaging to a different phone using the same Apple ID

    I'm setting up my old iPhone as an iPod touch for my son.  I am using the same Apple ID for both phones so we can share some content.  But now the old phone is receiving all of my iMessages instead of my current phone.  How can I switch that?

  • How can I tell which object is causing my error

    How can I determine which object has the lock, and for brownie points, release it? The SP is using a view, are view read only by default in Oracle, so I can rule that out as the 'locker'? If not, I'd like to modify with the equivalent of WITH(NO_LOCK

  • Can't FaceTime with family outside of home ?

    Can't FaceTime with family outside house