Send mail using CL_BCS through function module, run in background task.

Hi,
I am running a function module in Background task. in this function module I am sending mail using CL_BCS class.
but mail is not generated. if I run the same function Module in foreground mail generated successfully....
can anyone please tell me the reason behind this.

Hi i realise that The LIST_TO_ASCII thing is not working correctly in background because the the list-processing in beckground is working not the same as in dialog i think.
I can only get the last page of the list out when running in background. Any solution to this?
my code:
    CALL FUNCTION 'LIST_TO_ASCI'
         EXPORTING
              list_index         = sy-lsind
         TABLES
             list_dyn_ascii = downtab
         EXCEPTIONS
              empty_list         = 1
              list_index_invalid = 2
              OTHERS             = 3.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
Thanks ,
LH

Similar Messages

  • How to DEBUG a function module running in background mode? Please help!

    Hi Experts,
       I am calling a function module in my ABAP code in background module using the following syntax:
      CALL FUNCTION 'YBBC2_CREATE_SNAPSHOT' IN BACKGROUND TASK
              TABLES
                itab_std_format_inv = itab_std_format_inv
                itab_snapshot_inv = itab_snapshot_inv.
            COMMIT WORK.
    If I put the breakpoint in the CALL FUNCTION line and execute the program, the debugger does not take me to the valled function module. This may be because I am running the function module as background task.
    I cannot comment this  "IN BACKGROUND TASK" statement as well since i am debugging in Quality system where I don't have change access.
    So how to DEBUG a function module running in background mode? Please help!
    Thanks
    Gopal

    Hi,
    You could try to use the following trick:
    (1) Put an endless loop into the coding of your function module where you want to start debugging, e.g.
      DATA:
        lx_exit_loop(1)     TYPE c.
      lx_exit_loop = ' '.
      DO.
        IF ( lx_exit_loop = 'X' ).
          EXIT.
        ENDIF.
      ENDDO.
    (2) Call your function module in background task
    (3) Call transaction SM50 and search for the background process.
    (3) Choose from menu Program/Mode -> Program -> Debugging
    Now you the debugger should bring you right to your endless loop. Set lx_loop_exit = 'X' in the debugger and continue (F5 or F6).
    <b>Reward points</b>
    Regards

  • Calling function module in the background task

    Hello everybody,
    I have a function module which wil create conditon records,the problem is it has performance problems because of which i am planning to make this as background job.
    Can any one of please tell me how the call function ' fun name ' in background task behaves.
    Regards,
    Aruna

    hi,
    try to refer to the link below:
    http://help.sap.com/saphelp_nw04/helpdata/EN/8f/53b67ad30be445b0ccc968d69bc6ff/content.htm
    i hope it helps
    regards
    arjun

  • Send mail using cl_bcs. need text in mail body

    Hi friends,
    please provide me some solution to send mail with out attachment and the message should only be in mail body.
    Code :
    TRY.
    *     -------- create persistent send request ------------------------
            send_request = cl_bcs=>create_persistent( ).
    *     -------- create and set document -------------------------------
    *     create document from internal table with text
            CLEAR lv_const.
            CONCATENATE 'Dear' gs_cust-name1 ',' INTO lv_const SEPARATED BY space.
            APPEND lv_const TO text.
            CLEAR lv_const.
            CONCATENATE 'at' gs_cust-new_date 'planned delivery for you with following items:'
                        INTO lv_const SEPARATED BY space.
            APPEND lv_const TO text.
            l_space = '                                       ' .
            APPEND l_space TO text .
            CLEAR : gs_mat,
                    lv_const.
            CLEAR l_quan.
            LOOP AT gt_mat INTO gs_mat WHERE new_date = gs_cust-new_date.
              l_quan = gs_mat-zmeng.
              CONCATENATE gs_mat-matnr gs_mat-maktx l_quan INTO lv_const SEPARATED BY space.
              APPEND lv_const TO text.
              CLEAR :
                      lv_const.
            ENDLOOP.
            l_space = '                                       ' .
            APPEND l_space TO text .
            APPEND 'Please contact with us if you confirm whether above products are' TO text.
            CLEAR lv_const.
            CONCATENATE 'required on' gs_cust-new_date 'with specified quantity.'
                        INTO lv_const SEPARATED BY space .
            APPEND lv_const TO text.
            APPEND 'You can contact with us via e-mail:xxxxxx or via' TO text.
            APPEND 'phone +xxxxxxxxxxxxxx' TO text.
            l_space = '                                       ' .
            APPEND l_space TO text .
            APPEND 'Best regards' TO text.
            APPEND 'Linde Central Logistic Team' TO text.
            lo_document = cl_document_bcs=>create_document(
                            i_type    = 'RAW'
                            i_text    = text
    *                        i_length  = '12'
                            i_subject = 'test mail' ).
    *     add document to send request
            CALL METHOD send_request->set_document( lo_document ).
    *     --------- add recipient (e-mail address) -----------------------
    *     create recipient - please replace e-mail address !!!
            recipient = cl_cam_address_bcs=>create_internet_address(
                                              'address' ).
    *     add recipient with its respective attributes to send request
            CALL METHOD send_request->add_recipient
              EXPORTING
                i_recipient = recipient
                i_express   = 'X'.
    *     ---------- send document ---------------------------------------
              CALL METHOD send_request->send(
                EXPORTING
                  i_with_error_screen = 'X'
                RECEIVING
                  result              = sent_to_all ).
              COMMIT WORK.
    *  Send Immediately
              send_request->set_send_immediately( i_send_immediately = 'X' ).
          CATCH cx_bcs INTO bcs_exception.
            WRITE: text-001.
            WRITE: text-002, bcs_exception->error_type.
            EXIT.
        ENDTRY.
    Please provide me the solution if i am missing any thing.
    Thanks,
    Kat

    thank you for looking into this thread,
    i have configured the in scot.
    currently sending all RAW type as TXT. this has resolved my issues.

  • Help needed on workin with LDBs using call through Function Module LDB_PROC

    Hi All
    I am new to Logical Databases. I found on net that I can use a dynamic call to a Logical Database using Function Module
    "LDB_PROCESS".
    I tried implementing the same using the following logic.
    REPORT  zsa_test2.
    TABLES: pernr.
    SELECT-OPTIONS s_pernr FOR pernr-pernr.
    DATA: callback TYPE TABLE OF ldbcb,
               callback_wa LIKE LINE OF callback.
    callback_wa-ldbnode     = 'PERNR'.
    callback_wa-get            = 'X'.
    callback_wa-cb_prog     = sy-repid.
    callback_wa-cb_form     = 'CALLBACK_PERNR'.
    APPEND callback_wa TO callback.
    START-OF-SELECTION.
      CALL FUNCTION 'LDB_PROCESS'
           EXPORTING
                ldbname                       = 'PNP'
             VARIANT                       = ' '
             EXPRESSIONS              = TEXPR
             FIELD_SELECTION        = FSEL
           TABLES
                callback                         = callback
             SELECTIONS                 = SELTAB
        EXCEPTIONS
             LDB_NOT_REENTRANT      = 1
             LDB_INCORRECT               = 2
             LDB_ALREADY_RUNNING  = 3
             LDB_ERROR                      = 4
             LDB_SELECTIONS_ERROR = 5
             LDB_SELECTIONS_NOT_ACCEPTED = 6
             VARIANT_NOT_EXISTENT      = 7
             VARIANT_OBSOLETE            = 8
             VARIANT_ERROR                  = 9
             FREE_SELECTIONS_ERROR = 10
             CALLBACK_NO_EVENT         = 11
             CALLBACK_NODE_DUPLICATE     = 12
             OTHERS                                       = 13.
      IF sy-subrc <> 0.
       WRITE: 'Exception with SY-SUBRC', sy-subrc.
      ENDIF.
    *&      Form  CALLBACK_SPFLI
          text
         -->NAME       text
         -->WA         text
         -->EVT        text
         -->CHECK      text
    FORM callback_pernr USING name  TYPE ldbn-ldbnode
                                                wa    TYPE pernr
                                                evt   TYPE c
                                                check TYPE c.
      BREAK-POINT.
      WRITE: / wa-pernr.
      ULINE.
    ENDFORM.                    "CALLBACK_SPFLI
    But I am unable to transfer the control to the subroutine. The break-point isn't reached.
    Can someone please guide me? Am I using the wrong node or something??

    look at the below code ..
    pass  sstab  to the selection in the FM
    data cbtab type table of ldbcb.
    data wa_cbtab like line of cbtab.
    data sstab type table of rsparams.
    data wa_sstab like line of sstab.
    wa_cbtab-ldbnode  = 'SPFLI'.
    wa_cbtab-get      = 'X'.
    wa_cbtab-get_late = ' '.
    wa_cbtab-cb_prog  = sy-cprog.
    wa_cbtab-cb_form  = 'CB_SPFLI'.
    append wa_cbtab to cbtab.
    wa_cbtab-ldbnode  = 'SFLIGHT'.
    wa_cbtab-get      = 'X'.
    wa_cbtab-get_late = ' '.
    wa_cbtab-cb_prog  = sy-cprog.
    wa_cbtab-cb_form  = 'CB_SFLIGHT'.
    append wa_cbtab to cbtab.
    wa_sstab-selname  = 'AIRP_FR'.
    wa_sstab-kind     = 'S'.
    wa_sstab-sign     = 'I'.
    wa_sstab-option   = 'EQ'.
    wa_sstab-low      = 'FRA'.
    append wa_sstab to sstab.
    call function 'LDB_PROCESS'
      exporting
        ldbname     = 'F1S'
      tables
        callback    = cbtab
        selections  = sstab .
    form cb_spfli  using  nodename  type ldbn-ldbnode
                          wa_spfli  type spfli
                          mode      type c
                          selected  type c.
       write: / wa_spfli-carrid,
                wa_spfli-connid,
                wa_spfli-airpfrom,
                wa_spfli-airpto.
    endform.
    form cb_sflight  using  nodename   type ldbn-ldbnode
                            wa_sflight type sflight
                            mode       type c
                            selected   type c.
       write: /3 wa_sflight-fldate,
                 wa_sflight-seatsmax,
                 wa_sflight-seatsocc.
    endform.

  • Unable to send mail using javamail through gmail

    can anyone plz help me by sending the code to [email protected] send mail through gmail server as i always get exception of authentication failed even when i supply correct userid & password

    Include the following when setting your mail properties:
    props.put("mail.smtp.auth", "true");

  • Problem when calling function module CV120_DOC_CHECKOUT_VIEW in background

    Hi ,
    I'm currently developping an abap program which extract document from KPRO for printing into a windows Folder.
    For this I use standard function module CV120_DOC_CHECKOUT_VIEW.
    When i run my program in foreground task there's no problem, but when i run it in background task the extract doesn't work. It seems that the system cannot connect to the Windows Network.
    Whe the program is running in foreground task, the function module user SAPHHTP RFC destination, when it runs in background task it use SAPFTP destination .
    Does somebody can help me ?
    thanks in advance

    Hi Ajay,
    The program extract document into a folder on Windows Network that means on a server not on a PC .
    I know that in background task ther's no connection with sapgui.
    For example when i want to create a file on network n background task i use OPEN_DATASET instruction and that works fine.
    My problem is the use of the standard function module CV120_DOC_CHECKOUT_VIEW in background task because when this function module is running in background task it use the SAPFTP rfc destination instead of SAPHHTP rfc destination in foreground task . I check the RFC destination , thoses works both . SO i think the problem comes from parameters given to the function module.
    Regards.

  • Better way of Sending E-Mail Notifications -- Workflow or Function Module ?

    Hi All,
    I have an implicit enhancement written in a t-code and based on some conditions I am creating event which inturn will trigger the workflow which inturn send e-mail notification via send mail step.
    My question is:
    Which one of the ways is better in terms of performance or overhead to send an e-mail notification. (There are no Approval processes in the workflow.. Just One Step E-mail Notification).
    1) In the Implicit Enhancement, Trigger an event which inturn will trigger the workflow and e-mail is sent via send mail step.
    2) In the Implicit Enhancement, Send the e-mail notification via standard function modules available... such as
       "SO_OBJECT_SEND", "SO_DOCUMENT_SEND_API1".........
    Would be grateful if someone can post the Advantages and Disadvantages in the above 2 ways of sending e-mail notifications..
    Regards,
    PR.

    Just to throw in some additional factors, consider exception handling:
    An event-based send mail step is decoupled and thus independent of your application. This means your exception handling is separate. It means you do not need to hold up the transaction if there is a failure. All this depends on how important the mail is. You could of course add validation code to ensure the mail address is valid and send it elsewhere if not.
    Regarding performance, consider how often this happens. If it's an infrequent occurrence then I wouldn't worry about performance. Hundreds or thousands a day is a different story.
    So the answer is:
    Workflow for low-volume scenarios (low performance impact) that are important (better error handling in WF),
    Direct mail for high volume and noncritical
    In between these, use whatever you like
    One more thing to perhaps consider the future. What are the chances of the mail being replaced by a work item in furture? Sometimes it's only by observing a process after go live that you can identify the best solution. e.g. you may decide to replace the mail with a "Please go fix this" work item because you need deadline monitoring

  • Printing ALV Report output through Function Modules

    Hi All,
    I want to print my ALV Grid output through function modules/statement (not through print option in menu).
    This is because, i am generating a PDF from spool when user clicks on a button. If any changes happened in the ALV output layout, they will be captured in spool through printing it.
    So can you please tell me how to print the ALV Output through FMs or sending the ALV output to spool.
    Thanks & Regards,
    Senthil.
    Edited by: senthil nathan on May 17, 2010 2:49 PM

    Hi Dev,
    Thanks for the reply.
    I want to print the ALV when the user clicks on a button in toolbar. Lets say the user has made some changes to the layout, (E.g hiding a field) and when i print that output it should use the changed layout, If i use the FM suggested by you, i cant acheive this.
    If you try to print this manually, the system uses the changed layout and not the original. Thats why i want to know FMs/statement to print.
    Regards,
    Senthil.

  • Issue  while sending mails using classes

    Hi Experts ,
    i have one issue when i try to send mails using classes cl_document_bcs,cl_cam_address_bcs,cl_bcs etc
    ISSUE :
    i put some data in selection screen and i get some output ( say i got 5 records), i select 3 records and press some button to trigger mail and mail is send, and now again the OUTPUT screen is  shown with  sended records but we can not send these records again ............ now i selcect remaining two records  and press button to trigger mail and THIS TIME MAIL IS NOT SEND.
    amd my code is :
    CREATE OBJECT l_document.
      CREATE OBJECT l_recipient.
      TRY.
          cl_bcs_convert=>string_to_solix(
          EXPORTING
          iv_string = fp_wa_output
          iv_codepage = fp_v_code_page
          iv_add_bom = 'X'
          IMPORTING
          et_solix = l_wa_output_binary
          ev_size = l_v_size ).
          l_send_request = cl_bcs=>create_persistent( ).
    *-->Creating Document
          l_document = cl_document_bcs=>create_document(
          i_type = 'RAW'
          i_text = fp_it_content[]
          i_subject = fp_text_48 ) .
    *-->Adding Attachment*
          CALL METHOD l_document->add_attachment
            EXPORTING
              i_attachment_type    = fp_text_049
              i_attachment_size    = l_v_size
              i_attachment_subject = fp_v_file
              i_att_content_hex    = l_wa_output_binary.
    *-->Add document to send request*
          CALL METHOD l_send_request->set_document( l_document ).
    *    do send delivery info for successful mails
          CALL METHOD l_send_request->set_status_attributes
            EXPORTING
              i_requested_status = 'E'
              i_status_mail      = 'A'.
    *-->Get Sender Object
          l_uname = sy-uname.
          l_sender = cl_sapuser_bcs=>create( l_uname ).
          CALL METHOD l_send_request->set_sender
            EXPORTING
              i_sender = l_sender.
          LOOP AT fp_s_mail INTO l_wa_mail.
            l_v_objid = l_wa_mail-low.
            l_v_mail = l_v_smtpadr.
            TRANSLATE l_v_mail TO LOWER CASE.
            l_recipient = cl_cam_address_bcs=>create_internet_address( l_v_mail ).
            CALL METHOD l_send_request->add_recipient
              EXPORTING
                i_recipient  = l_recipient
                i_express    = 'X' .
    *            i_copy       = ' '
    *            i_blind_copy = ' '
    *            i_no_forward = ' '.
          ENDLOOP.
    **-->Trigger E-Mail immediately*
    *      IF fp_send_all EQ 'X'.
    *        l_send_request->set_send_immediately( 'X' ).
    *      ENDIF.
          CALL METHOD l_send_request->send(
          EXPORTING
          i_with_error_screen = 'X'
            RECEIVING result = l_v_sent_to_all ).
          BREAK TARK.
          IF l_v_sent_to_all = 'X'.
            MESSAGE i000 .
          ENDIF.
        COMMIT WORK.
        CATCH cx_document_bcs INTO l_bcs_exception.
        CATCH cx_send_req_bcs INTO l_send_exception.
        CATCH cx_address_bcs INTO l_addr_exception.
        CATCH cx_bcs INTO l_exp.
      ENDTRY.
    thanks in advance
    rahul

    Every time when i choose other network or dongle to send those mails it gets sent.
    As per the description, seems it's an issue related to this specific network. Probably, they've adjusted their security policy, like blocked some port numbers, etc.
    You might need to contact the support of your ISP to confirm what SMTP settings you need. Check port number, and security settings.
    By the way, this is the forum to discuss questions and feedback for Windows-based Microsoft Office client. Since your query is directly related to
    Office for mac, I would suggest you to post in the forum of
    Office for Mac, where you can get more experienced responses:
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011?tab=Threads
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • How to make use of SE37- Function Module & how to find out the table?

    Hi ,
    1.Could anyone help me what's this SE37-Function module is all about,How to make use of this?
    For Eg,If i want to delete a BOM permanently from the system then I have to use the Function module CM_DB_DEL_FROM_ROOT_BOM.
    But after giving the particular name what should i do?
    Please help me.
    2.How to find out the respective table for a particular field sya for T code-COGI, T code MFBF,where its values are getting populated.,Please help in this issue.
    Thanks in adavnce for spending some time
    Raj.S

    Hi Raj
    Function Modules
    Function modules are procedures that are defined in special ABAP programs only, so-called function groups, but can be called from all ABAP programs. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.
    Function modules allow you to encapsulate and reuse global functions in the SAP System. They are managed in a central function library. The SAP System contains several predefined functions modules that can be called from any ABAP program. Function modules also play an important role during updating  and in interaction between different SAP systems, or between SAP systems and remote systems through remote communications.
    Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder. The actual ABAP interface definition remains hidden from the programmer. You can define the input parameters of a function module as optional. You can also assign default values to them. Function modules also support exception handling. This allows you to catch certain errors while the function module is running. You can test function modules without having to include them in a program using the Function Builder.
    The Function Builder  also has a release process for function modules. This ensures that incompatible changes cannot be made to any function modules that have already been released. This applies particularly to the interface. Programs that use a released function module will not cease to work if the function module is changed.
    Check this link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
    You can execute function module in SE37ie you can perform the activiites defined in the function module by executing it.
    By deleting BOM you mention the FM name in se37 and execute. In some function module it will ask input parameters as developed in the program , you have to give the input parameters and execute.

  • Save EAN11 field while creating POrder creation through Function module

    Hi All,
    I want to update EAN11 field in material master while creating Purchase Order through function module. I am using function module BAPI_PO_CREATE1 for creating purchase order. There are no structures in the PO creation FM in which EAN11 field is there. I have also tried using function module MEPO_DOC_ITEM_PROCESS for updating EAN11 field. It is not working. Please suggest some method to do that.
    Note: I am receiving EAN11 through an external system by proxy.
    Thanks,
    Chinmay

    Hi,
    Use BAPI_MATERIAL_SAVEDATA to updat ean numbers for materials.
    tables INTERNATIONALARTNOS is used to update EAN.
    Regards,
    Shanmugavel Chandrasekaran

  • Delivery Receipt After Sending Mail Using JavaMail ?

    Hi Friends,
    I have written an application using JavaMail which would be used to send mail
    using my organisation's SMTP Server.I would like to include the following functionality in it.Just as
    Microsoft's Outlook has an option to get Delivery Receipt of the mail and Read Receipt of the mail sent
    (Provided the email Client supports it) i would like to have a similar option in my application to.I would like to of how i can do it using JavaMail.I heard that basically we need to set some SMTP properties which the Mail Transfer Agent would recognize and send us the Delivery and Read Receipts.But,i am not sure of what those properties.Can anyone help me regarding this ?

    You might look into creating a custom header that provides a return reciept to the email address you specify. I'm not 100% sure that all mail servers support this but you might want to look into it as a solution.
    -Dave

  • Is it necessary to use the standard function modules always?

    Hi All,
       Suppose i can retrieve the BUSINEES PARTNER ID from the table BUT000 with the help of 'BP_GUID' field through a select query statement. 
    Now is it necessary to use a standard function module to retrieve the same data. what about the performance? which is the better solution. to implement our own code or to use the function module available.
    Please someone clarify me about this issue.
    Regards,
    Sharry.

    If you'd ask the question in general it's obvious that there is no good answer as it always would depend on the circumstance. However, as you've posted your question in the performance tuning forum, let's look at your question in this context first. I think it's fairly safe to say, that in almost 100% of the cases a standard function module will not be as fast as any well implemented and custom tailored code. If in doubt, just try reading the code of the function module you want to read; most likely you will find lots of unnecessary fluff in there, often they read data that you don't even need.
    And as far as buffering is concerned, that can also be an issue. E.g. let's say you do a massive read of distinct business partners and you only need the data once for each partner. Obviously buffering is silly in this case and it might even slow down your program, because the implemented buffering is not necessarily well implemented. I've come across a few cases, where the buffer tables where standard tables with no efficient read access (so no sorted table or hash table) and once tons of data were buffered, it actually took a moment to look up if the record already was buffered (just to find it wasn't there yet).
    Now most of the times this slowdown is not an issue as the lookup is still fast compared to the (usually) prevalent database accesses with their slower IO timing. But another factor to consider is memory consumption and why buffer data in memory (and waste it), if you can't use the buffer anyway? So when I do use standard function modules, I usually try to see what they retain in global memory, to better understand if I need to call some initialization/clearing/refresh function...
    Note also that often you need to process lots of data, but don't find a standard function module for "mass access", so you need to read your object one by one. Obviously that's another good candidate for implementing your own queries, where you can process the data in packages.
    So what might be the reason to use a standard function module? Well, often it's required because the logic is so complex that it would take you too much time to implement it (not to mention that we often simply don't know all the logic that's coded in there). Another advantage is that you might get independent of the data model. E.g. for IDoc interfaces SAP switched in some release the tables where the data is stored. So if you had coded your own queries to get IDoc data, they wouldn't have worked after this particular release upgrade. The standard function on the other hand, checks both the old and new tables, so by using it you would have been fine.
    The one major caveat I'd give though is to always check whether the function module is released or at least documented to some degree. I.e. if it's not released, SAP won't support it and does not guarantee that the interface or logic stays the same. In my experience lots of functions I do want to use are not released (or documented), but I will still use them because they seem to be the best alternative in certain scenarios.
    Cheers, harald

  • How to get tables used by a Function Module

    Hi,
    How to know the tables used by a function module dynamically.
    Cuurently im using BAPI_MATERIAL_SAVEDATA in my report program.
    I tried FM GET_TABLES to know the tables, but could see only tables used in the report.
    Main issue in my case is when im running this update program, could observe different tables being displayed as updated in SM50(Process Overview).Want to clarify as why these tables which are not being used in my report are being displayed in SM50.
    So was doubtin weather this FM is using these displayed tables.
    Thanks in advance for u r replys.
    Regards,
    Dedeepya

    Hi Dedeepya,
    you could use a SQL Trace (tx. ST05) to list all tables affected and operations that realize. Just active the trace, execute FM, and Deactive trace. Then click in "Display trace" and check it.
    Best regards,
    Pablo

Maybe you are looking for