Skip to Content
author's profile photo Former Member
Former Member

SO Changes Report Repor Slow

hii

i have made report for any SO Changes for a day using standard SAP Functions, but it is very slow i have made index on CDHDR table also but still its very slow

below is the code for the same.

REPORT  z_sd_report_so_change.

TABLES :  cdhdr, cdpos.

DATA: BEGIN OF icdhdr OCCURS 50.
        INCLUDE STRUCTURE cdhdr.
DATA: END OF icdhdr.

DATA: BEGIN OF icdshw OCCURS 50.
        INCLUDE STRUCTURE cdshw.
DATA: END OF icdshw.

DATA: BEGIN OF ausg OCCURS 50.
        INCLUDE STRUCTURE cdshw.
        INCLUDE STRUCTURE cdhdr.
        fkdat(10),
        ccaua(1),
        ccins(4),
        ccnum(25),
        audat(10),
        autim(10),
        autwr(30),
        ccwae(10),
        aunum(10),
        indtext(200).
DATA: END OF ausg.

*----------------------------------------------------------------------*
*  Selection Options and Parameter Declaration                         *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 1 .
PARAMETERS p_date LIKE sy-datum OBLIGATORY.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.
  IF p_date IS INITIAL.
    p_date = sy-datum - 1 .
  ENDIF.

START-OF-SELECTION.
  PERFORM f_read_headers.
  PERFORM f_read_details.

END-OF-SELECTION.
*  PERFORM f_display_alv.
*&---------------------------------------------------------------------*
*&      Form  f_read_headers
*&---------------------------------------------------------------------*
FORM f_read_headers .
  cdhdr-objectclas = 'VERKBELEG'.
  cdhdr-udate      = p_date.

  CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
    EXPORTING
      date_of_change    = cdhdr-udate
      objectclass       = cdhdr-objectclas
      date_until        = cdhdr-udate
    TABLES
      i_cdhdr           = icdhdr
    EXCEPTIONS
      no_position_found = 1
      OTHERS            = 2.
ENDFORM.                    " f_read_headers
*&---------------------------------------------------------------------*
*&      Form  f_read_details
*&---------------------------------------------------------------------*
FORM f_read_details .
  LOOP AT icdhdr.
    CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
      EXPORTING
        changenumber      = icdhdr-changenr
        tablekey          = cdpos-tabkey
        tablename         = cdpos-tabname
      IMPORTING
        header            = cdhdr
      TABLES
        editpos           = icdshw
      EXCEPTIONS
        no_position_found = 1
        OTHERS            = 2.
    CASE sy-subrc.
      WHEN '0000'.
        LOOP AT icdshw.
          CLEAR ausg.
          MOVE-CORRESPONDING icdhdr TO ausg.
          MOVE-CORRESPONDING icdshw TO ausg.
          MOVE icdshw-tabkey+3(10)  TO ausg-vbeln.
          MOVE icdshw-tabkey+13(6)  TO ausg-posnr.
          APPEND ausg.
        ENDLOOP.
    ENDCASE.
  ENDLOOP.

  DELETE ausg WHERE ftext IS INITIAL OR f_old IS INITIAL OR
                    f_new IS INITIAL.
ENDFORM.                    " f_read_details

any ideas

Abhishek Suppal

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Nov 25, 2005 at 05:30 AM

    Change documents are always a performance issue. See if using CHANGEDOCUMENT_READ makes any difference. This does the selection of CDHDR and CDPOS at the same time.

    Srinivas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 25, 2005 at 08:08 AM

    Hi Abhishek,

    Have a look at oss note 557683 & 459838. Hope this note gives some inputs.

    Thanks

    Lakshman

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 25, 2005 at 09:17 AM

    Hello,

    if you look into 'CHANGEDOCUMENT_READ_HEADERS', it's reading CDHDR and CDPOS (Form READ_CD_FROM_DB). In

    'CHANGEDOCUMENT_READ_POSITIONS' it's the same, it reads the headers too.

    So i'd read the cdhdr-table directly via select , get from there the changenr and then use 'CHANGEDOCUMENT_READ_POSITIONS' to get the interesting positions.

    Best regards Wolfgang

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 25, 2005 at 09:43 AM

    Hi,

    Avoid reading function module in a loop by fetching the related informations from CDHDR and CDPOS tables directly.I had this similar problem in my project i have successfully resolved by removing the FM from the loop...

    Regards,

    Abdul

    Message was edited by: Abdul Hakim

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.