Application Development and Automation 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: 
Read only

Sending email delayed

former_member293102
Participant
0 Likes
7,384

Hello Experts,

I have a ABAP program which checks for failed jobs and send emails to user providing job details. rsconn01 is running in the same program. So no seperate scot scheduling is required.

It works perfectly in dev. environment too. There is no delay in sending email. But the same program has delay in sending email in quality. There is no time zone difference in su01 setting of users compared with system time.

Actually issue I observe is when the program runs 1st time, the entry just sits in SOST. In the next ABAP run, old entry gets replaced by new entry and email is sent pertaining to the old entry in SOST. Now new entry just sits there in SOST until next ABAP run is done.

It says 'Wait for communications service' in SOST. Please note rsconn01 is scheduled and there is no time zone issue. Adding to it there is no specific hours of delay. Old entry just waits for new entry to come to SOST until it sends the email.

The ABAP program works perfectly in dev. without any delay. Any lights on this ??

Regards,

Mihir

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,559

Hi Mihir,

Make sure you have a "commit work and wait" statement before submitting rsconn1 after whatever function you are using to generate the output message. RSCONN01 seems to be running prior to other work being completed.

Regards,

sifter

Hi Mihir,

Make sure you have a "commit work and wait" statement before submitting rsconn1 after whatever function you are using to generate the output message. RSCONN01 seems to be running prior to other work being completed.

Regards,

sifter

17 REPLIES 17
Read only

Former Member
0 Likes
5,559

Hi,

Can you check the SAPconnect send job which need to trigger your mail which might take some time.

Read only

Former Member
0 Likes
5,559

Hi

Try to check if there's a different setting for job of report RSCON001: table SXJOBS

Max

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
5,559

This is not really an ABAP question. I think your local Basis admin would be of more help than the ABAP forum users.

But since we're in this forum, if I may suggest, I would not start RSCON001 from the same program. The program should just create an email and it should be sent through the regular process in SAP (usually this is a background job that runs very frequently in Production). In DEV/QA emails can be pushed out manually in SOST for testing purposes. This looks like a more "clean" solution and much less trouble.

By the way, check if you can send out any email from QA manually. Maybe it's not an issue with the program. And then it's definitely Basis.

Read only

0 Likes
5,559

Hi Jelena,

Thanks for your response. If I do not start RSCON001 through same program I will have 2 jobs and will have to make it RSCON001 job dependent on ABAP program job. I really dont want to increase maintenance of number of jobs. In dev, it was not pushed manually, ABAP program itself pushed it.

If I push it manually in quality, it goes through and email is received successfully. 

Below is the statement written in ABAP program. It was working perfectly end to end in dev.

  submit rsconn01 with mode = 'INT' and return.

Any light on this ?

Read only

0 Likes
5,559

Silambharasan Murugesan,

SAP connect job is not running dedicate. It is part of my main program.

Regards,

mihir

Read only

0 Likes
5,559

max bianchi

SXJOBS has one entry each in dev and qa and both have same parameters.

Regards,

mihir


Read only

0 Likes
5,559

  submit rsconn01 with mode = 'INT' and return.

Wow... Good thing this didn't work. It should never run like this in DEV/QA system. There could be thousands of old testing emails sitting there in the queue. This would send them all out (that's why this job is usually not scheduled in DEV/QA). Imagine thousands of workflow approval requests going to senior management from the test system. It's very dangerous in the test system.

Once again - just don't do this in your program. In our PRD system RSCONN01 runs every 5 minutes. It sends out everything. Why would you need a separate job? Your program's email is so important that it can't wait for 4 minutes? I bet it can...

Read only

0 Likes
5,559

Hi Mihir,

As already pointed out. This is a very dangerous area. Hope your dev/quality system SCOT settings restrict sending emails out to everyone. Check with your BASIS before progressing on this.

Regards,

Shravan

Read only

0 Likes
5,559

Excellent answer. Thank you!

Read only

Former Member
0 Likes
5,560

Hi Mihir,

Make sure you have a "commit work and wait" statement before submitting rsconn1 after whatever function you are using to generate the output message. RSCONN01 seems to be running prior to other work being completed.

Regards,

sifter

Read only

0 Likes
5,559

Jas hy,

I did write the commit work and wait statement before RSCONN01 and I did get the mail immediately in quality system too. But now the issue is entry didnt get removed from sost and in the next ABAP run I got 2 emails, one for the prior and one for the current. And know after 2nd ABAP run, in sost, old entry got deleted and new entry still remains in there. We are almost there, can you throw some light on this new issue ?

Jelena & Sharvan,

Thanks for your concern, ABAP program also controls the people who should get email. There is no other alerting setup except mine. i.e. this is the 1st attempt in the system to send alerts.

To give a background, its in our BI system, when the process chain job fails it sends email to team members.

Regards,

Mihir

Read only

0 Likes
5,559

Mihir,

  If I understand you correctly the problem of the  delayed e-mail is solved, it is just the message remaining in  SOST? I am not sure, once the message is sent it should be removed from SOST. 

Basically the code should end something like this:

   commit work and wait.
   submit rsconn01 with mode = 'INT' and return.

If you could provide more details or code maybe I can help, been a while since I used rsconn01.

Regards,

sifter

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
5,559

Instead of doing SUBMIT, just add RSCONN01 as a second step in a background job. Then if there is an issue, it would be easy to find the job and troubleshoot. This will also resolve any COMMIT issues.

Regarding the new entry / old entry - just check what's the status of the message and check your parameters in SOST (Send status tab). Naturally you got two emails because you ran the program two times but RSCONN01 sends out all the emails in queue, not just one email that the program has just generated. That's what's dangerous about it.

Read only

0 Likes
5,559

Jelena,

Plan B is to follow your method itself. Im just trying to avoid additional job.

Sifter,

Below is the code. zrspc_load_log is the view created.

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

*& Report  ZBIW_PROCESS_FAILURE_NOTIFY

*&

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

*&

*&

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

REPORT  ZBIW_PROCESS_FAILURE_NOTIFY.

TABLES: zrspc_load_log,adr6.

TYPES : BEGIN OF ty_log,

        zdata TYPE string,

        END OF ty_log.

DATA: var_date TYPE sy-datum.

DATA: var_time TYPE sy-uzeit.

DATA: var_diff TYPE sy-uzeit.

DATA: Out_date TYPE string.

DATA: Out_date1 TYPE string.

DATA: Out_time TYPE sy-uzeit.

DATA: Out_time1 TYPE sy-uzeit.

DATA: lrp_date TYPE sy-datum.

DATA: lrp_time TYPE sy-uzeit.

DATA: lrp_diff TYPE sy-uzeit.

DATA: Tot_time TYPE sy-uzeit.

DATA : it_log TYPE TABLE OF ty_log.

DATA : wa_log TYPE ty_log.

DATA: objcont LIKE solisti1 OCCURS 5 WITH HEADER LINE.

DATA: reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.

DATA: doc_chng LIKE sodocchgi1.

DATA: entries LIKE sy-tabix.

DATA: name(15).

DATA: it_error TYPE TABLE OF zrspc_load_log .

DATA : wa_error TYPE zrspc_load_log .

DATA:str_body TYPE string.

DATA: status(1) TYPE c VALUE 'R'.

DATA date TYPE d.

date = sy-datum - 1.

*Selection Screen

PARAMETER: vmonitor TYPE sy-uzeit,

           var_lrp TYPE sy-uzeit.

SELECT-OPTIONS : it_email FOR adr6-SMTP_ADDR.

TYPES  :BEGIN OF lty_email,

      ref(255) TYPE c,

     END OF lty_email.

data: lt_email TYPE STANDARD TABLE OF lty_email WITH HEADER LINE.

*           var_lrp1 TYPE sy-uzeit,

*           it_mail TYPE string.

*Fetch the data for process chain failures

loop AT it_email.

  IF it_email-low IS NOT INITIAL.

    MOVE it_email-low to  lt_email-ref.

    APPEND lt_email.

  endif.

  IF it_email-high IS NOT INITIAL.

    MOVE it_email-high to  lt_email-ref.

    APPEND lt_email.

  endif.

endloop.

Tot_time = var_lrp + vmonitor.

SELECT *

  FROM zrspc_load_log

  INTO TABLE it_error

*   WHERE batchdate = sy-datum

  WHERE batchdate BETWEEN  date AND sy-datum

   AND ( actual_state IN ('R','X','A') OR state IN ('R','X','A') ).

CLEAR var_date.

CLEAR var_time.

CLEAR lrp_date.

CLEAR lrp_time.

CLEAR out_date.

CLEAR out_date1.

CLEAR out_time.

CLEAR out_time1.

LOOP AT it_error

  INTO wa_error.

*For errors converts timestamp into Date and Time

  CONVERT TIME STAMP wa_error-endtimestamp TIME ZONE sy-zonlo

           INTO DATE var_date TIME var_time.

*For long running infopackages convert timestamp into Date and Time

  CONVERT TIME STAMP wa_error-starttimestamp TIME ZONE sy-zonlo

           INTO DATE lrp_date TIME lrp_time.

*Get the difference between input time and system time

  var_diff = sy-uzeit - var_time.

  lrp_diff = sy-uzeit - lrp_time.

  IF var_diff LE vmonitor.

*Check if the process is cancelled/Failed

    IF ( wa_error-actual_state EQ 'R'

    OR   wa_error-actual_state EQ 'X' or wa_error-state EQ 'R' OR wa_error-state EQ 'X' ) AND ( wa_error-type NE 'CHAIN' ).

      CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

        EXPORTING

          INPUT  = var_date

        IMPORTING

          OUTPUT = out_date.

      CALL FUNCTION 'CONVERT_TIME_INPUT'

        EXPORTING

          INPUT                           = var_time

*   PLAUSIBILITY_CHECK              = 'X'

       IMPORTING

         OUTPUT                          = out_time

* EXCEPTIONS

*   PLAUSIBILITY_CHECK_FAILED       = 1

*   WRONG_FORMAT_IN_INPUT           = 2

*   OTHERS                          = 3

                .

      IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      ENDIF.

      .

      CONCATENATE 'Process chain: ' wa_error-chain_id ' Process Type: ' wa_error-type ' Process Name: '

      wa_error-variante ' failed on ' out_date out_time

                   INTO wa_log-zdata  SEPARATED BY space.

      APPEND wa_log TO it_log.

      clear:wa_log .

      APPEND wa_log TO it_log.

    ENDIF.

  ENDIF.

  IF lrp_diff GE var_lrp AND lrp_diff LT Tot_time.

*Check the Long Running Process

    IF ( wa_error-actual_state EQ 'A' OR wa_error-state EQ 'A' )

    AND  ( wa_error-type NE 'CHAIN').

      CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

        EXPORTING

          INPUT  = lrp_date

        IMPORTING

          OUTPUT = out_date1.

      CALL FUNCTION 'CONVERT_TIME_INPUT'

        EXPORTING

          INPUT                           = lrp_time

*   PLAUSIBILITY_CHECK              = 'X'

       IMPORTING

         OUTPUT                          = out_time1

* EXCEPTIONS

*   PLAUSIBILITY_CHECK_FAILED       = 1

*   WRONG_FORMAT_IN_INPUT           = 2

*   OTHERS                          = 3

                .

      IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

      ENDIF.

      CONCATENATE 'Process chain: ' wa_error-chain_id ' Process Type: ' wa_error-type ' Process Name: ' wa_error-variante

      ' is Long Running since  ' out_date1 out_time1

             INTO wa_log-zdata  SEPARATED BY space.

      APPEND wa_log TO it_log.

      clear:wa_log .

      APPEND wa_log TO it_log.

    ENDIF.

  ENDIF.

ENDLOOP.

*Check if errors are logged

IF it_log IS NOT INITIAL.

*  MOVE '<table border = 1>' TO objcont.

*  APPEND objcont.

  LOOP AT it_log

    INTO wa_log.

    if wa_log-zdata is not initial.

      CONCATENATE ' ' wa_log-zdata ' ' INTO objcont.

    endif.

    APPEND objcont.

    clear:objcont.

  ENDLOOP.

*  MOVE '</table>' TO objcont.

*  APPEND objcont.

  doc_chng-obj_name = 'PC Monitor'.

  IF status EQ 'R'.

    CONCATENATE sy-sysid ': >>>>>> Process Detail - Need attention <<<<<< ' INTO doc_chng-obj_descr.

  ELSE.

    CONCATENATE sy-sysid ': Chain delayed' INTO doc_chng-obj_descr.

  ENDIF.

  doc_chng-sensitivty = 'O'.

  DESCRIBE TABLE objcont LINES entries.

  READ TABLE objcont INDEX entries.

  doc_chng-doc_size = ( entries - 1 ) * 255 + STRLEN( objcont ).

* Fill the receiver list

  LOOP AT lt_email.

    CLEAR reclist.

    reclist-rec_type = 'U'.

    reclist-com_type = 'INT'.

    reclist-express = 'X'.

    reclist-receiver = lt_email.

    APPEND reclist.

  ENDLOOP.

*Send the Email Notification

  CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

    EXPORTING

      document_type              = 'RAW'

      document_data              = doc_chng

      commit_work                = 'X'

    TABLES

      object_content             = objcont

      receivers                  = reclist[]

    EXCEPTIONS

      too_many_receivers         = 1

      document_not_sent          = 2

      operation_no_authorization = 4

      OTHERS                     = 99.

  CASE sy-subrc.

    WHEN 0.

      LOOP AT reclist.

        IF reclist-receiver = space.

          name = reclist-rec_id.

        ELSE.

          name = reclist-receiver.

        ENDIF.

        IF reclist-retrn_code NE 0.

          WRITE: / name, ': error occured'.

        ENDIF.

      ENDLOOP.

    WHEN 1.

      WRITE: / 'Too many receivers specified !'.

    WHEN 2.

      WRITE: / 'No receiver got the document !'.

    WHEN 4.

      WRITE: / 'Missing send authority !'.

    WHEN OTHERS.

      WRITE: / 'Unexpected error occurred !'.

  ENDCASE.

  commit work and wait.

  submit rsconn01 with mode = 'INT' and return.

ENDIF.

Read only

0 Likes
5,559

Sifter,

I checked the overnight job failures and compared with the emails I received. I found that it is behaving back like original problem I posted. i.e. delayed behavior.

Any lights ?

Regards,

Mihir

Read only

0 Likes
5,559

Hello,

There was a similar thread on delay of emails. If you are going to write the code as you have shown in Plan B, I would suggest you make use of class CL_BCS to send mails. You could do a where-used-list to check its how-to-use functionality. Under that, to avoid dealay, set the immediate flag to X as shown below, just before calling the SEND method.

  

  DATA: ylog TYPE REF TO cl_bcs.

    TRY.
      CALL METHOD ylog->set_send_immediately
        EXPORTING
          i_send_immediately = abap_true.
    CATCH cx_send_req_bcs .
  ENDTRY.

Do try this and let me know if the problem is solved. Thanks.

Regards,

Kumud

Read only

Former Member
0 Likes
5,559

Hi Mihir,

First off, I agree with Kumund. The function you are using seems to be outdated (there are better OOP ones available). However this is the same one I used and I know it to work just fine in ECC 6.0. I do see one thing that may be the culprit and you could test it. Please move the "commit work and wait" statement immediately  after the function call if SY-SUBRC = 0. This is what I  meant in my original post. You are opening another database cursor prior to issuing the the command and may not be relevant for the function where you have it now.

------------------------------------------------------------------------------

*Send the Email Notification

  CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

    EXPORTING

      document_type              = 'RAW'

      document_data              = doc_chng

      commit_work                = 'X'

    TABLES

      object_content             = objcont

      receivers                  = reclist[]

    EXCEPTIONS

      too_many_receivers         = 1

      document_not_sent          = 2

      operation_no_authorization = 4

      OTHERS                     = 99.

   IF SY-SUBRC = 0.

        commit work and wait.

        submit rsconn01 with mode = 'INT' and return.

ENDIF.

---------------------------------------------------------------------------

If this dies not fix, without changing the above recommendations, then try placing the "submit rsconn01 with mode = 'INT' and return" immediately after the "commit work and wait" statement.

If this dies not fix, without changing the above recommendations remove the brackets from "reclist" in the function as this should not be necessary.

If this dies not fix, without changing the above recommendations remove the commit work = 'X' from the function export.

Regards,

sifter