7 Replies Latest reply: Apr 17, 2012 3:40 PM by Naimesh Patel RSS

how to restrict the report execution for 5 times when users run at same time in parallel

raj kumar
Currently Being Moderated

Hi,

 

As apart of performance i need to restrict the one custom report execution for 5 times only when users executed at the same time in parallel.

Any clues............

 

Regards

Ram

  • Re: how to restrict the report execution for 5 times when users run at same time in parallel
    Rajesh Sadula
    Currently Being Moderated

    Hi,

     

    Ask basis person to create authorization for that report, and give permission to specific users only.....

    It might help you....

     

    Go to the below link....

    http://scn.sap.com/thread/1909186

     

     

    regards,

    Rajesh Sadula.

  • Re: how to restrict the report execution for 5 times when users run at same time in parallel
    Raymond Giuseppi
    Currently Being Moderated

    You could use a lock object, at start of execution try to enqueue the object with 5 different values (from key = value 1 to value 5) until success or reject with error, perform a commit, rollback or dequeue at end of report.

     

    Regards,

    Raymond

  • Re: how to restrict the report execution for 5 times when users run at same time in parallel
    Kumar Gaurav
    Currently Being Moderated

    Intresting..

     

    As Rajesh suggested limit the number of people having authoriztion.
    I can think of a work around.

    Create a customizing table say with just 2 key feilds

    Report name and Lock index .

    Say if you want the report to restrict to five user then matintain 5 rows and with same report name and lock index

    (01,02,03,04,05).

    Check the below code

    INITIALIZATION.
      DATA : v_key TYPE rstable-varkey,
             v_flag_ok TYPE char1.
    *zconfig has keys mandt repname lockindex.
      SELECT * FROM zconfig
        INTO TABLE it_zconfig WHERE repname = sy-repid.
      IF sy-subrc = 0.
        LOOP AT it_zconfig ASSIGNING <fs_zconfig>.

          CONCATENATE  <fs_zconfig>-mandt <fs_zconfig>-repname <fs_zconfig>-lockindex
          INTO  v_key.
          CALL FUNCTION 'ENQUEUE_E_TABLE'
           EXPORTING
    *     MODE_RSTABLE         = 'E'
             tabname              = zconfig
             varkey               = v_key
    *     X_TABNAME            = ' '
    *     X_VARKEY             = ' '
    *     _SCOPE               = '2'
    *     _WAIT                = ' '
    *     _COLLECT             = ' '
           EXCEPTIONS
             foreign_lock         = 1
             system_failure       = 2
             OTHERS               = 3
                    .
          IF sy-subrc <> 0.
            CLEAR V_CONFIG.
            CONTINUE.
          ELSE.
            v_flag_ok = 'X'.
            EXIT.
          ENDIF.
        ENDLOOP.
        IF v_flag_ok IS INITIAL.

          MESSAGE 'Max no. of user reached! cannot run report ' TYPE 'E'.
        ENDIF.

      ENDIF.

     

  • Re: how to restrict the report execution for 5 times when users run at same time in parallel
    Manu D'Haeyer
    Currently Being Moderated

    Hi,

     

    I would rather play with an IMPORT/EXPORT..FROM/TO DATABASE indx(xy) at start and end of your program... you could import the current running number of programs with IMPORT statement at initialization event and increase it by one, and the reverse operation at the end with an EXPORT.

    No need to create ddic object here.

     

    Cheers,

    Manu.

  • Re: how to restrict the report execution for 5 times when users run at same time in parallel
    Rob Burbank
    Currently Being Moderated

    The trouble with using any sort of persistent objects to hold the entries is that they could persist after the program finishes (if it terminates abnormally say).

     

    Lock objects are normally used for this requirement.

     

    Rob

    • Re: how to restrict the report execution for 5 times when users run at same time in parallel
      Suhas Saha
      Currently Being Moderated

      Hello Ram,

       

      There is no need to create a custom table. And as Rob has already highlighted what problems the custom table data might pose - what if your program terminates & the table entries are not cleared?

       

      You can build you solution using Lock objects without the need to store any persistent data.

       

      • Create a structure which looks like the one below:

      Restrict report structure.JPG

      • Create a  lock object based on this structure

           Restrict report structure.JPG

      • Use the following code to restrict the number of sessions to 5:

        START-OF-SELECTION.

        DATA: gt_enq_list TYPE STANDARD TABLE OF seqg3 INITIAL SIZE 0,
              gv_count    TYPE i,
              gv_arg      TYPE eqegraarg.

        gv_arg = sy-repid. "Argument of the report

      * Check the no. of lock entries
        CALL FUNCTION 'ENQUEUE_READ'
          EXPORTING
            gname                 = 'ZRESTRICTREPORT'
            garg                  = gv_arg
            GUNAME                = '*'
          IMPORTING
            number                = gv_count
          TABLES
            enq                   = gt_enq_list
          EXCEPTIONS
            communication_failure = 1
            system_failure        = 2
            OTHERS                = 3.
        IF sy-subrc = 0 AND gv_count > 5.
          MESSAGE 'Maxm. number of users running the report' TYPE 'E'.
        ENDIF.

      * Set the lock on the report execution
        CALL FUNCTION 'ENQUEUE_EZRESTRICTREP'
          EXPORTING
            report         = sy-repid
            _scope         = '1'
          EXCEPTIONS
            foreign_lock   = 1
            system_failure = 2
            OTHERS         = 3.
        IF sy-subrc <> 0.
      *    Error handling
        ENDIF.

      END-OF-SELECTION.

      * Release the lock after the execution is complete
        CALL FUNCTION 'DEQUEUE_EZRESTRICTREP'
          EXPORTING
            report = sy-repid
            _scope = '1'.

       

      So even if your program terminates, the lock object will be enqueued & the lock counter will be reduced by 1!

       

      Hope i'm clear.

       

      BR,

      Suhas

  • Re: how to restrict the report execution for 5 times when users run at same time in parallel
    Naimesh Patel
    Currently Being Moderated

    I know I am late to reply, but this could be another solution of your problem:

    • Get the Work Processes list using the FM TH_GET_WPINFO
    • Check if your program is being running in multiple WPs - read table WPLIST with key WP_REPORT = your_report_name
    • If exceeds the limit, give the message and exit the program execution.

     

    Regards,
    Naimesh Patel

Actions