Performance issue in this code

public int[][] init(int[][] a, int m, int n){
  for(int j=0; j<n; j++){
    for(int i=0; i<m; i++){
      a[i][j] = i+j;
  return a;
}Just a technical quest faced in one of the interview...
There is a performance issue in this code. Can you identify, correct and justify your answer?
Edited by: EJP on 17/10/2011 20:29

mithu wrote:
public int[][] init(int[][] a, int m, int n){
for(int j=0; j<n; j++){
for(int i=0; i<m; i++){
a[i][j] = i+j;
return a;
}Just a technical quest faced in one of the interview...
There is a performance issue in this code. Can you identify, correct and justify your answer?Not a good question at all. There's no performance issue here that can be positively identified by inspection. The only potentially significant one is, as EJP pointed out, loss of locality of reference because of the order of the loops. But even that's not a guarantee, since I don't think array layouts are defined by the spec. We could only determine for sure that that's a performance problem by profiling.

Similar Messages

  • Performance issue of this code

    Hi folks,
    This report is working fine.But it is taking lot of time if i enter only company code.Could any one suggest me where is the problem.
    kaki
    REPORT  Z1F_RFKEPL00 no standard page heading
            line-size 140
            line-count 65
            message-id Z1.
    TABLES: LFA1,t005t,bsak,bseg,t001,skat.
    data: begin of t_bsak occurs 0,
            bukrs like bsak-bukrs,        "company code
            lifnr like bsak-lifnr,        "Vendor acc number
            augdt like bsak-augdt,        "Clearing date
            AUGBL like bsak-AUGBL,        "Clearing Document
            GJAHR like bsak-GJAHR,        "year
            belnr like bsak-belnr,        "Document number
            BUZEI like bsak-BUZEI,        "Line Item
            budat like bsak-budat,        "Posting Date in the Document
            bldat like bsak-bldat,        "Document date in document
            blart like bsak-blart,        "Document type
            BSCHL like bsak-BSCHL,        "Posting key
            WAERS like bsak-WAERS,        "Currency key
            CPUDT like bsak-cpudt,        "Accounting Document Entry Date
            SHKZG like bsak-shkzg,        "Debit/Credit Indicator
            DMBTR like bsak-dmbtr,        "Amount in local currency
            WRBTR like bsak-wrbtr,        "Amount in document currency
            SGTXT like bsak-sgtxt,        "Item Text
            SAKNR LIKE bsak-saknr,        "G/L Account Number
            hkont like bsak-hkont,        "General Ledger Account
            SKFBT LIKE BSAK-SKFBT,        "Amount Eligible for Cash Discount
            KOSTL LIKE BSEG-KOSTL,        "Cost center
            ktopl like t001-ktopl,        "chart of accounts
            txt20 like skat-txt20,        "Short test for the GL acc
            name1 like lfa1-name1,
            land1 like lfa1-land1,
            landx like t005t-landx,
          end of t_bsak.
    data: begin of t_header occurs 0,
            bukrs like bsak-bukrs,
            hkont like bsak-hkont,
            lifnr like bsak-lifnr,
            waers like bsak-waers,
            land1 like lfa1-land1,
            name1 like lfa1-name1,
            landx like t005t-landx,
          end of t_header.
    data: begin of t_lfa1 occurs 0,
            lifnr like lfa1-lifnr,
            name1 like lfa1-name1,
            land1 like lfa1-land1,
            landx like t005t-landx,
          end of t_lfa1.
    data: t_bseg like t_bsak occurs 0 with header line.
    data: t_data like t_bsak occurs 0 with header line.
    selection-screen begin of block blk1 with frame title text-001.
    select-options: s_lifnr for bsak-lifnr,
                    s_bukrs for bsak-bukrs.
    selection-screen end of block blk1.
    selection-screen begin of block blk2 with frame title text-002.
    parameters s_budat like bsik-budat default sy-datum.
    select-options: s_augdt for bsak-augdt.
    selection-screen end of block blk2.
    selection-screen begin of block blk3 with frame title text-003.
    parameters: stand as checkbox default 'X',
                park as checkbox.
    selection-screen end of block blk3.
    start-of-selection.
      perform process_data.
    top-of-page.
      perform set_page_header.
    *&      Form  process_data
          text
    form process_data.
      data: line like t_bsak occurs 0 with header line.
      data: l_wrbtr(10) type c.
      data: l_debit type bsak-wrbtr,l_credit type bsak-wrbtr,
            l_balance type bsak-wrbtr.
      data:l_hkont(10) type n.
      select BUKRS LIFNR AUGDT AUGBL GJAHR BELNR BUZEI BUDAT BLDAT
              CPUDT WAERS BLART BSCHL SHKZG DMBTR WRBTR SGTXT HKONT SKFBT
             from bsak
             into corresponding fields of table t_bsak
              where
              lifnr in s_lifnr and
              BUKRS in s_bukrs and
              budat le s_budat and                 " Open  items
              augdt in s_augdt order by lifnr.
      if sy-subrc ne 0.
        message i016.
        leave list-processing.
      endif.
      sort t_bsak by BUDAT.
      CHECK NOT t_bsak[] IS INITIAL.
      select MANDT BUKRS LIFNR AUGDT AUGBL GJAHR BELNR
             SHKZG DMBTR WRBTR SGTXT SKFBT KOSTL BSCHL hkont BUZEI
       into corresponding fields of table t_bseg from bseg
                FOR ALL ENTRIES IN t_bsak
                where belnr = t_bsak-belnr and
                      bukrs = t_bsak-bukrs and
                      gjahr = t_bsak-gjahr
                     ORDER BY PRIMARY KEY .
      loop at t_bsak.
    to get vendor name
        select single * from lfa1 where lifnr = t_bsak-lifnr.
        move lfa1-lifnr to t_header-lifnr.
        move lfa1-name1 to t_header-name1.
        move lfa1-land1 to t_header-land1.
        move t_bsak-bukrs to t_header-bukrs.
        move t_bsak-hkont to t_header-hkont.
        move t_bsak-waers to t_header-waers.
        if sy-subrc = 0.
          append t_header.
          clear t_header.
        endif.
    to get vendor country
        loop at t_header.
          select single * from t005t where land1 = t_header-land1 and
                                           SPRAS = 'E'.
          move t005t-landx to t_header-landx.
          if sy-subrc = 0.
            modify t_header.
            clear t_header.
          endif.
        endloop.
        loop at t_bseg where belnr = t_bsak-belnr and
                             bukrs = t_bsak-bukrs and
                             gjahr = t_bsak-gjahr.
          l_hkont = t_bseg-hkont.
    *To get chart of accounts
          select single * from t001 where bukrs = t_bseg-bukrs.
          move t001-ktopl to t_bseg-ktopl.
    *To get short text for the chart of accounts
          select single * from skat where ktopl = t_bseg-ktopl and
                                          saknr = l_hkont and
                                          spras = 'E'.
          t_data-bukrs = t_bsak-bukrs.
          t_data-lifnr = t_bsak-lifnr.
          t_data-augdt = t_bseg-augdt.
          t_data-AUGBL = t_bseg-AUGBL.
          t_data-GJAHR = t_bseg-GJAHR.
          t_data-belnr = t_bsak-belnr.
          t_data-BUZEI = t_bseg-BUZEI.
          t_data-budat = t_bsak-budat.
          t_data-bldat = t_bsak-bldat.
          t_data-blart = t_bsak-blart.
          t_data-BSCHL = t_bseg-BSCHL.
          t_data-WAERS = t_bsak-WAERS.
          t_data-CPUDT = t_bsak-cpudt.
          t_data-SHKZG = t_bseg-shkzg.
          t_data-DMBTR = t_bseg-dmbtr.
          t_data-WRBTR = t_bseg-wrbtr.
          t_data-SGTXT = t_bsak-sgtxt.
          t_data-SAKNR = t_bseg-saknr.
          t_data-hkont = t_bseg-hkont.
          t_data-SKFBT = t_bseg-SKFBT.
          t_data-KOSTL = t_bseg-KOSTL.
          t_data-ktopl = t_bseg-ktopl.
          t_data-txt20 = skat-txt20.
          append t_data.
          clear t_data.
        endloop.
      endloop.
      sort t_header by lifnr.
      delete adjacent duplicates from t_header.
    *Display----
    *to display header
      data: l_buzei type bseg-buzei.
      loop at t_header.
        write:/1(6) t_header-bukrs    color 2,
                7(8) t_header-hkont    color 2,
                18(10) t_header-lifnr   color 2.
        write:/30(10) t_header-name1.
        write:/30(10) t_header-landx.
        uline.
        loop at t_data where lifnr = t_header-lifnr.
          l_wrbtr = t_data-wrbtr.
          if t_data-wrbtr = t_data-skfbt.
            concatenate l_wrbtr '-' into l_wrbtr.
          endif.
          write:/15(11) t_data-BUDAT no-zero    color 7,
                  26(5) t_data-BLART            color 7,
                  30(12) t_data-belnr           color 7,
                  42(16) t_data-BLDAT           color 7,
                  58(5)  t_data-buzei           color 7,
                  63(12)  t_data-BSCHL          color 7,
                  75(9)  t_data-AUGDT           color 7,
                  84(35) t_data-AUGBL           color 7,
                  119(7) t_data-WAERS           color 7,
                  126(12) l_wrbtr               color 7.
          write:/55 t_data-sgtxt.
          write:/60(10) t_data-kostl,
                70(10) t_data-hkont,
                80(20) t_data-txt20.
          clear l_wrbtr.
        endloop.
        write:/1(6) t_data-bukrs    color 2,
               7(8) t_data-hkont    color 2,
               18(10) t_data-lifnr  color 2.
        uline.
        line[] = t_data[].
        loop at line where lifnr = t_header-lifnr.
          if line-shkzg = 'H'.
            l_debit = l_debit + line-wrbtr.
          endif.
          if line-shkzg = 'S'.
            l_credit = l_credit + line-wrbtr.
          endif.
        endloop.
       write:/1(6) t_data-bukrs    color 3,
              7(8) t_data-hkont    color 3,
              18(10) t_data-lifnr  color 3.
        write:/1(6) t_data-bukrs    color 3,
               7(11) t_data-hkont    color 3,
               18(102) t_data-lifnr  color 3.
        l_balance = l_debit -  l_credit.
       write:115(15) l_debit  color 3.   write:135(1) 'D' color 3.
       write:/115(15) l_credit color 3. write:135(1) 'C' color 3.
      for balnce
       write:/90(25) 'Bal.:' color 3.
       write:115(15) l_balance color 3.
        write:120(15) l_debit  color 3.
        write:138(2) 'D' color 3.
        write:/120(15) l_credit color 3.
        write:138(2) 'C' color 3.
      for balnce
        write:/90(00) 'Bal.:' color 3.
        write:120(15) l_balance color 3.
        clear: l_debit,l_credit,l_balance.
        uline.
      endloop.
    endform.                    "process_data
    *&      Form  set_page_header
          text
    FORM set_page_header.
      call function 'Z_REPORT_TITLE'
        EXPORTING
          line_size       = sy-linsz
          sy_title        = 'List of Vendor Line Items'
          uline           = 'X'
          first_page_only = ' '.
      write :1(15)  'Allocation'            color col_heading,
             15(10) 'Pstng'         color col_heading,
             25(5)  'Do'             color col_heading,
             30(10) 'Documnet'          color col_heading,
             40(10) 'Doc'        color col_heading,
             50(8)  'BusA'              color col_heading,
             58(5)  'LIm'        color col_heading,
             63(4)  'PK'         color col_heading,
             67(4)  'S'       color col_heading,
             71(4)  'P'       color col_heading,
             75(7)  'Clrg'       color col_heading,
             82(10) 'Clearing'       color col_heading,
             92(20) 'D/c discount Amnt'       color col_heading,
             112(5) 'Rsn'       color col_heading,
             117(2) 'G'       color col_heading,
             119(7)  'Curr-'       color col_heading,
             126(12) 'Amount in'       color col_heading,
             138(2)  'T'       color col_heading.
      write space.
      write :1(15)  'number'            color col_heading,
             15(10) 'date'            color col_heading,
             25(5)  'ty'      color col_heading,
             30(10) 'number'     color col_heading,
             40(18) 'date'         color col_heading,
             58(5)  ''        color col_heading,
             63(4)  ''         color col_heading,
             67(4)  'I'       color col_heading,
             71(4)  'K'       color col_heading,
             75(7)  'date'       color col_heading,
             82(24) 'doc.no'       color col_heading,
             105(20) 'in LC'       color col_heading,
             112(5) 'code'       color col_heading,
             117(2) 'L'       color col_heading,
             119(7) 'ency'       color col_heading,
             126(12) 'doc.curr.'       color col_heading,
             138(2) 'X'       color col_heading.
      write space.
      uline.
    ENDFORM.                    " set_page_header

    it will better to optimize the below part of your code -
    loop at t_bsak.
    to get vendor name
    select single * from lfa1 where lifnr = t_bsak-lifnr.
    move lfa1-lifnr to t_header-lifnr.
    move lfa1-name1 to t_header-name1.
    move lfa1-land1 to t_header-land1.
    move t_bsak-bukrs to t_header-bukrs.
    move t_bsak-hkont to t_header-hkont.
    move t_bsak-waers to t_header-waers.
    if sy-subrc = 0.
    append t_header.
    clear t_header.
    endif.
    to get vendor country
    loop at t_header.
    select single * from t005t where land1 = t_header-land1 and
    SPRAS = 'E'.
    move t005t-landx to t_header-landx.
    if sy-subrc = 0.
    modify t_header.
    clear t_header.
    endif.
    endloop.
    loop at t_bseg where belnr = t_bsak-belnr and
    bukrs = t_bsak-bukrs and
    gjahr = t_bsak-gjahr.
    l_hkont = t_bseg-hkont.
    *To get chart of accounts
    select single * from t001 where bukrs = t_bseg-bukrs.
    move t001-ktopl to t_bseg-ktopl.
    *To get short text for the chart of accounts
    select single * from skat where ktopl = t_bseg-ktopl and
    saknr = l_hkont and
    spras = 'E'.
    t_data-bukrs = t_bsak-bukrs.
    t_data-lifnr = t_bsak-lifnr.
    t_data-augdt = t_bseg-augdt.
    t_data-AUGBL = t_bseg-AUGBL.
    t_data-GJAHR = t_bseg-GJAHR.
    t_data-belnr = t_bsak-belnr.
    t_data-BUZEI = t_bseg-BUZEI.
    t_data-budat = t_bsak-budat.
    t_data-bldat = t_bsak-bldat.
    t_data-blart = t_bsak-blart.
    t_data-BSCHL = t_bseg-BSCHL.
    t_data-WAERS = t_bsak-WAERS.
    t_data-CPUDT = t_bsak-cpudt.
    t_data-SHKZG = t_bseg-shkzg.
    t_data-DMBTR = t_bseg-dmbtr.
    t_data-WRBTR = t_bseg-wrbtr.
    t_data-SGTXT = t_bsak-sgtxt.
    t_data-SAKNR = t_bseg-saknr.
    t_data-hkont = t_bseg-hkont.
    t_data-SKFBT = t_bseg-SKFBT.
    t_data-KOSTL = t_bseg-KOSTL.
    t_data-ktopl = t_bseg-ktopl.
    t_data-txt20 = skat-txt20.
    append t_data.
    clear t_data.
    endloop.
    endloop.
    You are selecting data from database inside the loop and specially you are populating t_header inside the loop and again looping on the same table to get value of t005t-landx. Here you are updating even those records which are already update by initial loop pass so multiple updation for already updated records.
    Thanks,
    Rajeev

  • Performance Issue with this code

    Hi Gurus,
    Can anyone please help tweak the performance of this program.
    REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SPREPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]2 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]3 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]4 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]5 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]6 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]7 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP[code]REPORT ZSQ01_AUDITSALESORD4_1.
    TABLES: VBAP, MATERIALID, VBAK, VBEP.
    SELECTION-SCREEN: BEGIN OF BLOCK PROG WITH FRAME TITLE TEXT-F58.
    SELECT-OPTIONS SP$00001 FOR VBAK-VBELN MEMORY ID AUN.
    SELECT-OPTIONS SP$00002 FOR VBAP-POSNR MEMORY ID APO.
    SELECT-OPTIONS SP$00003 FOR MATERIALID-MATNR_EXT.
    SELECT-OPTIONS SP$00004 FOR VBAK-ERDAT.
    SELECT-OPTIONS SP$00005 FOR VBAP-KWMENG.
    SELECT-OPTIONS SP$00006 FOR VBAP-UEPOS.
    SELECT-OPTIONS SP$00007 FOR VBAP-MATWA MEMORY ID MAT.
    SELECT-OPTIONS SP$00008 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       KUNNR(10),                                              
       AUGRU(3),                                               
       KZTLF(1),                                               
       FILLER(12),                                             
    END OF ITAB2_SALESORD4.
    CONSTANTS: C_REASON_VR LIKE VBAK-AUGRU VALUE 'VR',                      
               C_REASON_EM LIKE VBAK-AUGRU VALUE 'EM'.
    DATA: L_VBELN TYPE VBFA-VBELN,                             
          L_POSNR TYPE VBFA-POSNN,                             
          L_LVBELN TYPE VBFA-VBELN.                            
    DATA: BEGIN OF ITAB_SUPER OCCURS 0,                        
          VBELN TYPE VBAP-VBELN,                               
         POSNR  TYPE VBAP-POSNR,                               
        END OF ITAB_SUPER.
    START-OF-SELECTION.
      SELECT VBAK~ERDAT VBAK~VBELN VBAP~KWMENG VBAP~MATNR VBAP~MATWA
               VBAP~POSNR VBAP~PSTYV VBAP~UEPOS VBAP~VBELN VBAP~VRKME
                VBAP~ABGRU MATERIALID~MATNR_EXT MATERIALID~MATNR_INT
            VBAP~Z_PROM_SHP_DT VBAK~AUART VBAP~WERKS VBAK~BSTNK VBAK~KUNNR    VBAK~AUGRU  VBAP~KZTLF  
                                  INTO (VBAK-ERDAT , VBAK-VBELN , VBAP-KWMENG , VBAP-MATNR , VBAP-MATWA
           , VBAP-POSNR , VBAP-PSTYV , VBAP-UEPOS , VBAP-VBELN , VBAP-VRKME
            , VBAP-ABGRU  , MATERIALID-MATNR_EXT , MATERIALID-MATNR_INT,
              VBAP-Z_PROM_SHP_DT, VBAK-AUART, VBAP-WERKS, VBAK-BSTNK,
              VBAK-KUNNR, VBAK-AUGRU, VBAP-KZTLF)
        FROM ( VBAK
               INNER JOIN VBAP
               ON VBAP~VBELN = VBAK~VBELN
               INNER JOIN MATERIALID
               ON MATERIALID~MATNR_INT = VBAP~MATNR )
               WHERE VBAK~ERDAT IN SP$00004
                 AND VBAK~VBELN IN SP$00001
                 AND VBAP~KWMENG IN SP$00005
                 AND VBAP~MATWA IN SP$00007
                 AND VBAP~POSNR IN SP$00002
                 AND VBAP~PSTYV IN SP$00008
                 AND VBAP~UEPOS IN SP$00006
                 AND MATERIALID~MATNR_EXT IN SP$00003.
    SELECT SINGLE VBELN POSNN
           FROM VBFA
           INTO (L_VBELN, L_POSNR)
           WHERE VBELV = VBAK-VBELN AND
           POSNV       = VBAP-POSNR AND
           VBTYP_N     = 'J'.
        IF SY-SUBRC = 0 AND NOT L_VBELN IS INITIAL.
          SELECT SINGLE VBELN
          FROM LIPS
          INTO L_LVBELN
          WHERE VBELN = L_VBELN AND
                POSNR = L_POSNR.
          IF SY-SUBRC NE 0.
            IF NOT VBAP-UEPOS IS INITIAL.                      
              MOVE VBAP-VBELN TO ITAB_SUPER-VBELN.             
              MOVE VBAP-UEPOS TO ITAB_SUPER-POSNR.             
              APPEND ITAB_SUPER.                               
            ENDIF.                                             
            CONTINUE.
          ENDIF.
        ENDIF.
        MOVE VBAK-VBELN TO ITAB2_SALESORD4-VBELN.              
        MOVE VBAK-AUART TO ITAB2_SALESORD4-AUART.              
        MOVE VBAP-POSNR TO ITAB2_SALESORD4-POSNR.              
        MOVE VBAP-WERKS TO ITAB2_SALESORD4-WERKS.              
        MOVE MATERIALID-MATNR_EXT TO ITAB2_SALESORD4-MATNR_EXT.
        MOVE VBAK-ERDAT TO ITAB2_SALESORD4-ERDAT.              
        MOVE VBAP-KWMENG TO ITAB2_SALESORD4-KWMENG.            
        MOVE VBAP-VRKME TO ITAB2_SALESORD4-VRKME.              
        MOVE VBAP-UEPOS TO ITAB2_SALESORD4-UEPOS.              
        MOVE VBAP-MATWA TO ITAB2_SALESORD4-MATWA.              
        MOVE VBAP-PSTYV TO ITAB2_SALESORD4-PSTYV.              
        MOVE VBAP-ABGRU TO ITAB2_SALESORD4-ABGRU.              
        MOVE VBAP-Z_PROM_SHP_DT TO ITAB2_SALESORD4-Z_PROM_SHP_DT.
        MOVE VBAK-BSTNK TO ITAB2_SALESORD4-BSTNK.              
        MOVE VBAK-KUNNR TO ITAB2_SALESORD4-KUNNR.              
        IF VBAK-AUGRU = C_REASON_VR.                           
          MOVE  C_REASON_EM TO ITAB2_SALESORD4-AUGRU.          
        ELSE.                                                  
          MOVE VBAK-AUGRU TO ITAB2_SALESORD4-AUGRU.            
        ENDIF.                                                 
        MOVE VBAP-KZTLF TO ITAB2_SALESORD4-KZTLF.              
        ITAB2_SALESORD4-KWMENG = ITAB2_SALESORD4-KWMENG * 1000.
        WRITE ITAB2_SALESORD4-KWMENG TO ITAB2_SALESORD4-KWMENG 
                        DECIMALS 0 RIGHT-JUSTIFIED.
        OVERLAY ITAB2_SALESORD4-KWMENG WITH '00000000000000000'.
        APPEND ITAB2_SALESORD4.                                
        CLEAR ITAB2_SALESORD4.                                 
      ENDSELECT.
      SORT ITAB2_SALESORD4 BY VBELN POSNR Z_PROM_SHP_DT.       
      SORT ITAB_SUPER BY VBELN POSNR.
      DATA: G_FILE LIKE RLGRAP-FILENAME,
            ZDFLTVAL11(40),
            ZDFLTVAL22(40).
      SELECT SINGLE Z_DFLT_VAL1 Z_DFLT_VAL2 INTO
                        (ZDFLTVAL11,ZDFLTVAL22)
                             FROM ZLE_LOG_DFLT_VAL
                                    WHERE LGNUM = ' '
                                 AND Z_DFLT_TYP = 'IMAS_SAP_SALESORD4_G1'.
      TRANSLATE ZDFLTVAL22 TO LOWER CASE.
      CONCATENATE ZDFLTVAL11 ZDFLTVAL22 INTO G_FILE.
      OPEN DATASET G_FILE FOR OUTPUT IN TEXT MODE.
      LOOP AT ITAB2_SALESORD4.
        READ TABLE ITAB_SUPER WITH KEY VBELN = ITAB2_SALESORD4-VBELN
                                         POSNR = ITAB2_SALESORD4-POSNR
                                        BINARY SEARCH.         
        IF SY-SUBRC EQ 0.
          CONTINUE.
        ENDIF.
        TRANSFER ITAB2_SALESORD4 TO G_FILE.
      ENDLOOP.
      CLOSE DATASET G_FILE.
    [/code]8 FOR VBAP-PSTYV.
    SELECTION-SCREEN: END OF BLOCK PROG.
    DATA: BEGIN OF ITAB2_SALESORD4 OCCURS 0,
       VBELN(10),
       AUART(4),
       POSNR(6),
       WERKS(4),
       MATNR_EXT(40),
       ERDAT(8),
       KWMENG(19),
       VRKME(3),
       UEPOS(6),
       MATWA(40),
       PSTYV(4),
       ABGRU(2),
       Z_PROM_SHP_DT(8),                                       
       BSTNK(20),                                              
       K

    The first SELECT looks a bit shaky. Have you done a performance trace (ST05) to find out where the problem is?
    Rob

  • Performance issue for this function-module(HR_TIM_REPORT_ABSENCE_DATA)

    Hi Friends
    I am having performance issue for this function-module(HR_TIM_REPORT_ABSENCE_DATA) and one my client got over 8 thousend employees . This function-module taking forever to read the data. is there any other function-module to read the absences data IT2001 .
    I did use like this .if i take out this F.M 'HR_TIM_REPORT_ABSENCE_DATA_INI' its not working other Function-module.please Suggest me .
    call function 'HR_TIM_REPORT_ABSENCE_DATA_INI'
    exporting "Publishing to global memory
    option_string = option_s "string of sel org fields
    trig_string = trig_s "string of req data
    alemp_flag = sw_alemp "all employee req
    infot_flag = space "split per IT neccessary
    sel_modus = sw_apa
    importing
    org_num = fdpos_lines "number of sel org fields
    tables
    fieldtab = fdtab "all org fields
    field_sel = fieldnametab_m. "sel org fields
    To Read all infotypes from Absences type.
    RP_READ_ALL_TIME_ITY PN-BEGDA PN-ENDDA.
    central function unit to provide internal tables: abse orgs empl
    call function 'HR_TIM_REPORT_ABSENCE_DATA'
    exporting
    pernr = pernr-pernr
    begda = pn-begda
    endda = pn-endda
    IMPORTING
    SUBRC = SUBRC_RTA
    tables
    absences = absences_01
    org_fields = orgs
    emp_fields = empl
    REFTAB =
    APLTAB =
    awart_sel_p = awart_s[]
    awart_sel_a = awart_s[]
    abstp_sel = abstp_s[]
    i0000 = p0000
    i0001 = p0001
    i0002 = p0002
    i0007 = p0007
    i2001 = p2001
    i2002 = p2002
    i2003 = p2003.
    Thanks & Regards
    Reddy

    guessing will not help you much, check with SE30 to get a better insight
    SE30
    The ABAP Runtime Trace (SE30) -  Quick and Easy
    what is the total time, what are the Top 10 in the hitlist.
    Siegfried

  • Performance issue on this.a = a

    Hello to all the java gurus. I was wondering on whether there is a performance issue on the coding below :
    [1] public void setName( String name ) { this.name = name; }
    vs.
    [2] public void setName( String _name ) { name = _name; }
    If i use [1], will it requires extra computation of finding current object followed by finding its name data member compare to [2] which directly distinguished by using different variable name?
    many thanks for those who try to solve this puzzle of mine.

    I agree with dubwai.. my variable names are pretty
    long, but descriptive. I also use (as a holdover from
    my corporate project days) a naming convention that
    specifies which variables are local, passed as params,
    or global, which eliminates the need for this. in most
    cases. If you need to use this. because you
    have two variable names that are identical, I would be
    questioning if one couldn't be named something else.I think it there are just some errors that can't be avoided by anything less than careful programming. I think a lot of times people obsess over things like variable naming schemes while writing 200 line methods with multiple nested and unnested loops. The easiest way to make code readable is to break out everything in 5 to 20 line methods (give or take some lines depending on how you count.) Of course, sometimes this isn't feasible or useful but it's still a good rule of thumb. If you can acheive this, the variable naming scheme isn't really a significant factor in readability. You could name everything like y4gr5x6 and you'd still be able to figure it out.

  • Can you help me with the WHERE clause? Any issue with this code block?

    Hi,
    I am looking for blogs or any document on how to implement a Lookup during data loads in BW.
    The problem is that all those that I find on this site are mostly about u201CLookup in XIu201D
    I have read bits and hints on different postings on this site and this is the best I could do for the scenario shown below:
    I need to add the Chars: Char1, Char2, Char3 to CubeX
    so that I can display the data for these 3 Chars in a report.
    Char1 and Char2 are filled in ODS12 and Char3 is filled in Cube3.
    Can you help me write a routine so that while loading data to CubeX, it will read Char1, Char2, Char3 from ODS12 and Cube3; and make them available in CubeX?
    This is my attempt so far:   continue:
    u201C----
    select /bic/Char1 from /bic/ODS12
    select /bic/Char2 from /bic/ODS12
    select /bic/Char3 from /bic/Cube3
    into result
    WHERE u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
    and objvers = 'A' .        
    end select.
    u201C----
    1. What should be my WHERE clause?
    2. In the select statement, by studying samples on this where should there be an u201CMu201D in front of the ODS? e.g. select /bic/Char1 from /bic/MODS12
    If so, what is the significance and the other options?
    3. Should this code be in the Start routing of CubeX? Or any other possible location? Also, in the start routine does it matter where within the start routine this code needs to be placed?
    4. Can you please fix this code and add any lines I may be missing?
    Is what I am looking to do refer to as u201Cdoing a lookupu201D?
    Thanks

    ok

  • Performance issue in this query:

    Hi,
    Here is the query:
    SELECT COLLECTIONKEY, FLOWSYSKEY, LIFECYCLENUMBER, PUBLICVERSION, PUBLICOPERATION,
    STATUSCODE, VALUEDATE, REASONCODE FROM AA out WHERE COLLECTIONKEY
    LIKE '1437023L%' AND COLLECTIONVERSION = ( SELECT MAX(COLLECTIONVERSION) FROM cfdg_owner.AA inn WHERE inn.FLOWSYSKEY=out.FLOWSYSKEY)
    Now this table AA has non clustered index on CollectionKey and CollectionVersion.
    The above query will return only 4 records, but still the optimizer is using index .
    Fyi, AA table is huge table with records in millions.
    SELECT STATEMENT     8.0     8     58591     1     108     8                         ALL_ROWS                                                       
    FILTER                              1                                                                                
    TABLE ACCESS (BY INDEX ROWID)     5.0     5     36827     2     216     1     CFDG_OWNER     TB_PUBLIC_CF     BY INDEX ROWID     TABLE     ANALYZED     1                                                  
    INDEX (RANGE SCAN)     3.0     3     21764     2          1     CFDG_OWNER     IDX2_TB_PUBLIC_CF     RANGE SCAN     INDEX     ANALYZED                    1                                   
    SORT (AGGREGATE)                    1     41     2               AGGREGATE                                                                 
    INDEX (RANGE SCAN)     3.0     3     21764     1     41     1     CFDG_OWNER     IDX1_TB_PUBLIC_CF     RANGE SCAN     INDEX     ANALYZED                    1
    Plus the response time of this query is very fast. When i am forcing optimizer not to use Index, its taking more time.
    How come Index range scan is performing better in this case as compared to FULL Scan?
    Version is:
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE     10.2.0.4.0     Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Any more information required, please let me know.
    Thanks.
                                                      1

    It only returns 4 records, but how many does it have to scan through and eliminate to satisfy the MAX condition? ie) how many versions are there per key?
    It's quite possible this would be a more efficient query for you (it will obviate the secondary index range scan the current query is utilizing).
    SELECT
      COLLECTIONKEY,
      FLOWSYSKEY,
      LIFECYCLENUMBER,
      PUBLICVERSION,
      PUBLICOPERATION,
      STATUSCODE,
      VALUEDATE,
      REASONCODE
    FROM
      SELECT
        COLLECTIONKEY,
        FLOWSYSKEY,
        LIFECYCLENUMBER,
        PUBLICVERSION,
        PUBLICOPERATION,
        STATUSCODE,
        VALUEDATE,
        REASONCODE,
        COLLECTIONVERSION,
        MAX(COLLECTIONVERSION) OVER (PARTITION BY FLOWSYSKEY) AS MAX_COLLECTIONVERSION
      FROM AA
      WHERE COLLECTIONKEY LIKE '1437023L%'
    WHERE COLLECTIONVERSION = MAX_COLLECTIONVERSION;But without knowing a lot more about your data distributions, etc... it's just a guess.

  • Performance issue with this complex query

    Please ignore this thread(post)
    This query fetches a lot of data and takes more than 4 t0 5 hrs to retrieve them.
    I have tried to get the explain plan the display cursor and the TKPROF for the same but then the query utilizes more than 100GB temp space and it fails to generate any.
    What I have is the spool file which is pasted below along with the query.
    Database version: 11g
    I'm looking forward for suggestions how to improve the performance of this statement
    Please ignore this thread(post)
    Edited by: user13319084 on May 30, 2011 12:34 AM

    You provide no information that can be used in answering your question on how to improve the query.
    In absence of technical information, all that we can discuss is conceptual issues. Like why is the query that complex? A common answer is that the underlying data model lacks the intelligence and this now requires the intelligence to be build into the query.
    You need to look at the data model and the query in order to address this performance problem - and make sure that the actual business requirements is clearly identified and understood.

  • Performance issue with JavaFX code

    Hi, I'm experienced in Java, but not in JavaFX. I wrote simple LIFE cellular automata, it has two options: randomize cells, and take a step forward in simulation. My problem is that following simulation steps are slower and slower. NetBeans profiler suggests that if I take more steps in simulation then get method's self time (get$impl$$bound$int__int method exactly) is getting slower in time -- at first it takes about 0.054 (270/5000) ms per call, but later the average jumps to 0.55 (12709/23000) ms per call. I don't really know how bind mechanism works, could this be a bind issue? Maybe I create many unneccessary objects? Here's the code:
    import java.lang.Math;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.paint.Color;
    import javafx.scene.Scene;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    import javafx.ext.swing.SwingButton;
    import java.lang.System;
    var tab : CellTable = CellTable {
         width: 10
         height: 10
    def rects =
    for (i in [0..tab.width-1]) {
         for (j in [0..tab.height-1]) {
              Rectangle {
                   x: 20 * i + 1
                   y: 20 * j + 1
                   width: 17
                   height: 17
                   stroke: Color.RED
                   fill: bind if (tab.get(i, j)) Color.RED else Color.WHITE;
    def stage = Stage {
         title: "LIFE"
         resizable: false
         scene: Scene {
              width: 200
              height: 250
              content: [
                   rects,
                   SwingButton {
                        text: "random!"
                        translateX: 0
                        translateY: 210
                        width: 100
                        action: function() {
                             tab.random();
                   SwingButton {
                        text: "next>"
                        translateX: 100
                        translateY: 210
                        width: 100
                        action: function() {
                             tab.next();
    class CellTable {
         postinit {
              for (i in [0..width-1]) {
                   for (j in [0..height-1]) {
                        insert false into cells;
                        insert false into tmp;
              xrange = [0..width-1];
              yrange = [0..height-1];
         var cells : Boolean[];
         var tmp : Boolean[];
         var width : Integer;
         var height : Integer;
         var xrange : Integer[];
         var yrange : Integer[];
         function random() {
              for (x in [0..width-1]) {
                   for (y in [0..height-1]) {
                        set(x, y, Math.random() < 0.5);
         function next() {
              for (x in xrange) {
                   for (y in yrange) {
                        var ct = 0;
                        for (xx in [-1..1]) {
                             for (yy in [-1..1]) {
                                  if (get((x + width + xx) mod width, (y + height + yy) mod height)) {
                                       ++ct;
                        if (get(x,y)) {
                             --ct;
                             tmp[idx(x,y)] = (ct == 2 or ct == 3);
                        } else {
                             tmp[idx(x,y)] = (ct == 3);
              for (x in xrange) {
                   for (y in yrange) {
                        set(x, y, tmp[idx(x, y)]);
         function idx(x : Integer, y : Integer) : Integer {
              return x * height + y;
         bound function get(x : Integer, y : Integer) : Boolean {
              return cells[idx(x,y)];
         function set(x : Integer, y : Integer, b : Boolean) {
              cells[idx(x,y)] = b;
    }I would be very grateful if anyone could tell me what could be the issue or at least what should I check to figure it out.

    I tried to solve your problem.
    First, I eliminated the keyword 'bound' from the function in CellTable class. Then I rewrite the value of 'fill' attribute in the Rectangle as below :
    fill: bind if (tab.cells[tab.idx(i, j)]) Color.RED else Color.WHITE;As a result, I found your code ran faster than before. But I don't know why it became so.
    Could it be that the 'bound function' creates some new Boolean instances every time it was called ???
    Sorry, I can not help you.
    I hope anyone would tell me why the 'bound function' made the code slower.

  • Performance issue with the code

    hi,
    i have below code.for printing it is taking enough time..
    which way i can improve the performance of below piece of code and what changes i will do for improving performance??
    kindly help me..
    form get_komgd.
      tables: kotd994.                     "kondd
      data : tfill_auswahl type i.
      data: begin of auswahl occurs 10,
               kappl like kotd994-kappl ,
               kschl like kotd994-kschl ,
               vkorg like kotd994-vkorg ,
               vtweg like kotd994-vtweg ,
               spart like kotd994-spart ,
               kvgr1 like kotd994-kvgr1 ,
               matwa like kotd994-matwa ,
               datbi like kotd994-datbi ,
               datab like kotd994-datab ,
               knumh like kotd994-knumh ,
               smatn like kondd-smatn,
               meins like kondd-meins,
                 sugrd like kondd-sugrd,
         end of auswahl.
      tables: kondd.
      select * from  kondd
             where  smatn       = ltap-matnr.
        select * from  kotd994
               where  kappl       = 'V'
             and    kschl       = vbak-kschl
               and    vkorg       = vbak-vkorg
               and    vtweg       = vbak-vtweg
         and    spart       = vbak-spart
               and    kvgr1       = vbak-kvgr1
         and    matwa       = vbak-matwa
               and    datbi       >= sy-datum
               and    datab       <= sy-datum
               and    knumh       = kondd-knumh    .
        endselect.
        if sy-subrc = 0.
       and kotd994-kvgr1(1) = 'Z'.
          move-corresponding kotd994 to auswahl.
          move-corresponding kondd to auswahl.
          append auswahl   .
        endif.                             " sy-subrc = 0.
    write: / auswahl.
      endselect.
      describe table auswahl lines tfill_auswahl.
      if tfill_auswahl = 1.
        komgd-matwa = auswahl-matwa.
      else.
        clear komgd-matwa.
      endif.                               " tfill_auswahl = 1.
    endform.                               " ZHX_GET_COSTUMER_NR

    Hi,
    Using two select statements will take more time.
    Rather use this sample code:
    select *    from kondd in to corresponding fields of table auswahl
            where smatn = ltap-matnr.
        select *      from kotd994 into corresponding fields of auswahl
                 for all entries of auswahl
                  where kappl = 'V'
                  and vkorg = vbak-vkorg
                  and vtweg = vbak-vtweg
                  and kvgr1 = vbak-kvgr1
                  and datbi >= sy-datum
                  and datab <= sy-datum
                  and knumh = auswahl-knumh .
    however, in the structure of auswahl maintain the field of knumh as well, so that we can pass the values in the second select directly.
    This will improve the performance very well.
    if possible, try and use the primary key combinations in the where clause while extracting the data.

  • Performance ISSUE of JAVA Code

    Hello,
    We are having Delphi application. But as per our requirements we have to migrated the Delphi code to java. We have done this but it is consuming the 3 times more time as compare to Delphi Application.
    We have used simple primitive types and arrays. But there are some loops which runs 4-8lac (800000) times.
    Colud you please suggest me some ways to improve the performance, as it is very critical for me ?
    Thanks,
    Satbir

    We have done this but it is consuming the 3
    times more time as compare to Delphi Application.
    We have used simple primitive types and arrays. But
    there are some loops which runs 4-8lac (800000)
    times.Sometimes trying too hard will make things slower.
    I have some suggestions:
    1) Do not inline functions yourself. This will in the best case have no effect and in the worst case make your code buggy. If your code is written according to good object-oriented methods it is probably not even possible.
    2) Don't flog the garbage collector. If your inner loop creates new objects, don't release them for the collector to clean up. Instead put them in a free list and reuse them. For general coding this isn't such a great idea, because the collector can reclaim objects about as efficiently as you can recycle them yourself. But inside a tight loop it can help a lot.
    2.1) Objects with finalizers are slow to garbage collect. Avoid finalizers in performance-critical code. (You can use classes that have finalizers, you just don't want them to be garbage collected while in tight code). Some of the classes provided by the Java API have finalizers also.
    3) Try using the server VM.
    4) Try different versions of the JDK. Some people have found that 1.4 is slower than 1.3, others find it is faster. Both are much faster than 1.2.
    5) String operations in Java are very slow. Much slower even than they usually are. StringBuffers can be 4-5 times faster than Strings, but even then string handling is just not fast. See if you can minimize the amount of string handling in your tight loops.
    6) Synchronization is quite slow also. It is faster in 1.4, but it is still slow. Don't synchronize unless absolutely necessary. Some synchronized operations can be done instead with volatile variables, unfortunately many things cannot.
    7) Make sure you have enough heap space for everything to fit comfortably. If the garbage collector is running during a tight loop, this will kill your performance.
    8) Some of the calls to the Java API are very slow. Some standard API classes, such as Hashtable, have synchronized methods, which can cause hidden slowing. Other functions are just plain slow in general.
    9) Try using the -Xrunhprof option to profile your code. While it will run much more slowly with the profiler enabled, it will at least indicate where the slowness is. It might not be what you expect.

  • Performance tuning of this code.

    Hello Friends,
    Following is the piece of Code.. can some one please help me to optimise the code.
    I want to do performance tuning on the same.
    Any inputs on this would be valuable to me .
    Thanking you all in anticipation.
    << Unformatted code removed >>
    Edited by: Jitesh Pamnani on Apr 7, 2009 10:09 AM
    Edited by: Jitesh Pamnani on Apr 7, 2009 10:09 AM
    Edited by: Rob Burbank on Apr 7, 2009 11:05 AM

    please read,
    SQL trace:
    /people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
    for the first part, without SQL Trace it does not make much sense, to check your select statements.
    I guess that one or several are slow. But there are too many.
    Second part, use sorted tables or binary search!!!!!
    Your coding is highly nonlinear, not only quadratic but even cubic!!!!
    Read here for table types and runtimes
    Measurements on internal tables: Reads and Loops:
    /people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables
    Read here about nonlinearity:
    Nonlinearity: The problem and background
    /people/siegfried.boes/blog/2007/02/12/performance-problems-caused-by-nonlinear-coding
    Read here for measuring:
    SE30
    /people/siegfried.boes/blog/2007/11/13/the-abap-runtime-trace-se30--quick-and-easy
    Z_SE30_COMPARE
    /people/siegfried.boes/blog/2008/01/15/a-tool-to-compare-runtime-measurements-zse30compare
    Nonlinearity Check
    /people/siegfried.boes/blog/2008/01/24/nonlinearity-check-using-the-zse30compare
    If you do ot all I assume that your coding can becomes faster by factors 10 ... 100 or even more.
    Siegfried

  • Flickr API and cflickr - performance issue with my code.

    I using cflickr to access the Flickr api and display photos in a lightbox. My code is working, but incredibly slow. I'm assuming that I'm going about it in an incorrect way and hoping someone can point out a better way to do what I'm trying to accomplish. My speed issues develop when I'm trying to extract the image descriptions within a loop that is outputing the images to the page.
    Here is an example of the code that I'm using:
    using the following to grab the photos:
    <cfset photos = cflickr.photosets_getPhotos(photoset_id=72157624340881708 , auth_token=token) />
    I am then using the following to loop through the array of photos and and also retrieve the description for each image.
    <div style="width:423px; margin: auto;" id="gallery">
            <cfloop from="1" to="#arraylen(photos.photoset.photo)#" index="i">
                <cfset p = photos.photoset.photo[i] />
                <cfset img_desc = cflickr.photos_getInfo(photo_id=p.id).photo.description />
                <cfset img_desc = replace(img_desc, 'TRIP', '<br />TRIP') />
                <cfset title = photos.photoset.photo[i].title />
                <cfset title = title & "<br />" & img_desc />
                <cfoutput>
                <a href="#cflickr.getPhotoUrl(p, '')#" title="#title#"><img src="#cflickr.getPhotoUrl(p, 's')#"  /></a>
                </cfoutput>
            </cfloop>
        </div>
    The problem with the code is when it is making the request for img_desc inside of the loop to the Flickr api. Each instance of that call is taking on average 300 to 400ms and the array has over 300 items so it times out. Should I be retrieveing all of the image descritpions at once before the loop and if so how would I best link these with image data that they belong with? It seems like I'm going about this in a rather inefficient manner.
    I was hoping that I could call a function that retrieved all of the data that I need in one call, but so far I've been unable to find that.

    ( Grrr... this forum trashes emails better than any application I have ever seen.  Here is what my previous response actually said ...)
    <cfset photos = cflickr.photosets_getPhotos(photoset_id=72157624340881708 , auth_token=token)>
    I cannot say I have used it. But the cfc usage seems to follow the API pretty closely. So I took a quick look at the flickr forums, and one person suggests you can grab the descriptions too by adding the "extras" parameter.
    http://www.flickr.com/groups/api/discuss/72157594456853637/#comment72157623785775034
    So try using:
        <cflickr.photosets_getPhotos(photoset_id=72157624340881708 ,
             auth_token=token, extras="description")>

  • Performance Issue - sitting this one out

    Hi,
    as mentioned in a previous post, I am having serious difficulty with navigation in the grid view. There is no way I am getting any kind of satisfactory scroll movement, either with the mouse nor with the tablet. For a program which is expicitely intended to handle large number of pictures and navigating through them, this is not acceptable.
    To make this clear: I love the new features in LR3, especially the noise reduction improvements and the lens corrections; also the fine tuning instruments for sharpening are worth mentioning. However, if I spend most of my time (and nerves) to get to the picture I want to manipulate instead of getting any of my actual work done, it is time to do something about it.
    On the ohter hand, LR 2.7 was working just fine; no performance problem (asside from occasional hangups using the correction brush for too long, getting a lot of brush strokes where god himself would't want 'em).
    After fiddeling with my graphics card settings, cache settings, even turning off my anti- virus software for testing, and trying what not, I decided to sit this one out: I'll rather use an inferior LR 2.7 that works than a superior LR 3 which doesn't work (talking about contradition in terms...).
    So I'll keep on using third- party noise reduction and lens correction software and wait if the adobe engineers find the time to tackle the problem.
    Just a finshing thought: distributing menory- hog- software usually is the domain of Microsoft, isn't it? I believe mass- market- compatible software should run (not walk...) on mass- market- hardware.
    I hope enough people may comment this in the like of "me, too", so that the adobe guys might take notice.
    Thanks,
    Mike.

    Same for me! Editing pictures with LR3 takes soooooo long on my computer (Win 7 64 bits, Intel Core i7 860 , ATI Radeon 48700, 4 Go RAM) that is it not possible to work. LR3 is using 60% of my RAM each time I zoom in the picture, chnage picture or do a local correction. It often crashes. Open in PS CS4 can be painful too.
    Listening to Victoria Bampton's advice, I have deleted the lrpreview folder and rebuilt the standard preview. FOr a few days it worked bbetter, but after imprting a bunch of pictures, it is slow again.
    Photo is my job and LR my every day tool. I hope the fix will come very soon, just can't wait!
    eric

  • Performance issue with this query.

    Hi Experts,
    This query is fetching 500 records.
    SELECT
    RECIPIENT_ID ,FAX_STATUS
    FROM
    FAX_STAGE WHERE LOWER(FAX_STATUS) like 'moved to%'
    Execution Plan
    | Id  | Operation                   | Name                | Rows  | Bytes | Cost (%CPU)|
    |   0 | SELECT STATEMENT            |                     |   159K|    10M|  2170   (1)|
    |   1 |  TABLE ACCESS BY INDEX ROWID| FAX_STAGE           |   159K|    10M|  2170   (1)|
    |   2 |   INDEX RANGE SCAN          | INDX_FAX_STATUS_RAM | 28786 |       |   123   (0)|
    Note
       - 'PLAN_TABLE' is old version
    Statistics
              1  recursive calls
              0  db block gets
             21  consistent gets
              0  physical reads
              0  redo size
            937  bytes sent via SQL*Net to client
            375  bytes received via SQL*Net from client
              3  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
             19  rows processed
    Total number of records in the table.
    SELECT COUNT(*) FROM FAX_STAGE--3679418
    Distinct reccords are low for this column.
    SELECT DISTINCT FAX_STATUS FROM FAX_STAGE;
    Completed
    BROKEN
    Broken - New
    moved to - America
    MOVED to - Australia
    Moved to Canada and australia
    Functional based indexe on FAX_STAGE(LOWER(FAX_STATUS))
    stats are upto date.
    Still the cost is high
    How to improve the performance of this query.
    Please help me.
    Thanks in advance.

    With no heavy activity on your fax_stage table a bitmap index might do better - see  CREATE INDEX
    I would try FTS (Full Table Scan) first as 6 vs. 3679418 is low cardinality for sure so using an index is not very helpful in this case (maybe too much Exadata oriented)
    There's a lot of web pages where you can read: full table scans are not always evil and indexes are not always good or vice versa Ask Tom &amp;quot;How to avoid the full table scan&amp;quot;
    Regards
    Etbin

Maybe you are looking for