Plz increase performance of this report

hi all
i want to know how can i improve the performance of my report.
the code is given below and it takes so much time on production even for single record
plz help
HERE COMES THE CODE
*& Report  ZGRSTATUS
REPORT  ZGRSTATUS.
TYPE-POOLS slis.
TABLES: mseg, qamb, mkpf, rseg.
DATA : BEGIN OF itab OCCURS 0,
       mblnr LIKE mseg-mblnr,
       zeile LIKE mseg-zeile,
       uom LIKE mseg-erfme,
       matnr LIKE mseg-matnr,
       recqty LIKE mseg-erfmg,
       qcins LIKE mseg-insmk,               "INSPECTION SIGN
       ebeln LIKE mseg-ebeln,
       ebelp LIKE mseg-ebelp,
       lifnr LIKE mseg-lifnr,
       budat LIKE mkpf-budat,
       txz01 LIKE ekpo-txz01,
       name1 LIKE lfa1-name1,
       accqty LIKE mseg-erfmg,
       rejqty LIKE mseg-erfmg,
       belnr LIKE rseg-belnr,
       dqty LIKE mseg-menge,
       cqty LIKE mseg-menge,
       qcdat like mkpf-budat,
       miro_budat like rbkp-budat,
       accuom like mseg-erfme,
       rejuom like mseg-erfme,
       qcstat like mseg-insmk,
       acstat(1) type c,
       crnote(1) type c,
       END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
       mblnr LIKE mseg-mblnr,
       zeile LIKE mseg-zeile,
       mjahr LIKE mseg-mjahr,
       prueflos like qamb-prueflos,
       END OF itab1.
DATA: BEGIN OF imiro OCCURS 0,
      belnr LIKE rseg-belnr,
      lfbnr LIKE rseg-lfbnr,              "DOCMENT NO SAME AS MBLRN
      shkzg LIKE rseg-shkzg,              "DEBIT CREDIT SIGN
      menge LIKE rseg-menge,
      ebeln LIKE rseg-ebeln,
      ebelp LIKE rseg-ebelp,
      budat LIKE rbkp-budat,
      END OF imiro.
data: begin of iins occurs 0,             "NEW INTERNAL TABLE DECLARED for inspection lot numbers
      mblnr like mseg-mblnr,
      zeile like mseg-zeile,
      prueflos like qamb-prueflos,
      mjahr like qamb-mjahr,
      end of iins.
****************************CODE FOR SELECTION SCREEN****************************
selection-screen begin of block par1 WITH FRAME TITLE TEXT-001.
PARAMETERS : plant LIKE mseg-werks OBLIGATORY DEFAULT 'MFPL'.
PARAMETERS: year LIKE mseg-mjahr OBLIGATORY DEFAULT '2007'.
SELECT-OPTIONS : grno FOR mseg-mblnr,
                 grdate FOR mkpf-budat,
                 vendor FOR mseg-lifnr,
                 item for mseg-matnr.
SELECTION-SCREEN END OF BLOCK par1.
***************************END OF CODE FOR SELECTION SCREEN**********************
*************************FETCHING OF GR INFORMATION FROM MSEG AND MKPF*************************
SELECT amblnr zeile aerfme amatnr aerfmg ainsmk aebeln aebelp alifnr bbudat ctxz01 d~name1
FROM mseg AS a
INNER JOIN mkpf AS b ON amblnr = bmblnr AND amjahr = bmjahr
INNER JOIN ekpo AS c ON aebeln = cebeln AND aebelp = cebelp
INNER JOIN lfa1 as d ON dlifnr = alifnr
INTO TABLE itab
WHERE awerks = plant AND amblnr IN grno AND bwart = '101' AND a~mjahr = year
AND btcode2 = 'MIGO_GR' AND bbudat IN grdate AND alifnr IN vendor and amatnr IN item.
*************************END OF RETERIEVEL***************************************
if sy-subrc <> 0.
  Message 'NO RECORD FOUND' type 'E'.
endif.
*******************************SELECTING THE INSPECTED DOC NUMBERS AND CORROSPONDING INSPECTION LOT********************************
select mblnr zeile mjahr prueflos
from qamb into table itab1  for all entries in itab where mblnr = itab-mblnr and zeile = itab-zeile.
**********************************END OF SELECTING THE INSPECTED DOC. NUMBERS & INSPECTION LOTS************************************
**************************SELECTING THE DOC NO FOR ACCEPTED AND REJECTED QTY ACCORDING TO INSPECTION LOT***************************
select mblnr zeile prueflos mjahr into table iins from qamb
  for all entries in itab1 where prueflos = itab1-prueflos and mblnr <> itab1-mblnr.
**************************END OF SELECTING ACCEPTED AND REJECTED QTY DOCUMENTS****************************************************
**********************************SELECTING THE DEBIT AND CREDIT QTY FOR THE MIRO TCODE*******************************************
SELECT abelnr lfbnr shkzg menge ebeln ebelp bbudat INTO table imiro
    FROM rseg as a
    inner join rbkp as b on abelnr = bbelnr
    for all entries in itab where a~lfbnr = itab-mblnr.
DATA : v_qcidoc LIKE qamb-prueflos,
       v_qcdoc LIKE mseg-mblnr,
       v_qcdoc1 LIKE mseg-zeile,
       v_qty LIKE mseg-menge,
       v_bwart LIKE mseg-bwart,
       v_name1 LIKE lfa1-name1,
       v_budat like mkpf-budat,
       v_newrejqty like mseg-menge,
       v_newaccqty like mseg-menge,
       CMPACCQTY LIKE MSEG-MENGE,
       CMPREJQTY LIKE MSEG-MENGE,
       aa TYPE c.
data: begin of iartab occurs 0,
      mblnr like mseg-mblnr,
      bwart like mseg-bwart,
      qty like mseg-menge,
      erfme like mseg-erfme,
      zeile like mseg-zeile,
      budat like mkpf-budat,
      end of iartab.
clear iartab.
refresh iartab.
****************************************table for accept and reject qty************************************
SELECT a~mblnr bwart erfmg erfme zeile budat into table iartab
  FROM mseg as a
  inner join mkpf as b on amblnr = bmblnr
  for all entries in iins
  WHERE amblnr = iins-mblnr AND azeile = iins-zeile AND xauto <> 'X' AND a~mjahr = iins-mjahr.
******************************************END OF ACCEPT AND REJECTED QTY.***********************************
LOOP AT itab.
clear: itab-accuom, itab-rejuom.
SELECT SINGLE name1 FROM lfa1 INTO itab-name1 WHERE lifnr = itab-lifnr.
     **********************GETTING THE ACCEPTED AND REJECTED QTY FROM MSEG FOR ALL RECORDS OF ITAB*********************
  IF itab-qcins = 'X'.
  clear v_qcidoc.
  clear: v_bwart, v_qty, v_budat.
  read table itab1 with key mblnr = itab-mblnr zeile = itab-zeile.
    if sy-subrc = 0.
      v_qcidoc = itab1-prueflos.
    endif.
   LOOP AT itab1 where prueflos = v_qcidoc and mblnr <> itab-mblnr .
     LOOP AT iins where prueflos = v_qcidoc. " and mblnr <> itab-mblnr .
      v_qty = 0.
     SELECT single bwart erfmg budat
       INTO (v_bwart, v_qty, v_budat)
       FROM mseg as a
       inner join mkpf as b on amblnr = bmblnr
       WHERE amblnr = itab1-mblnr AND azeile = itab1-zeile AND xauto <> 'X' AND a~mjahr = itab1-mjahr.
       WHERE amblnr = iins-mblnr AND azeile = iins-zeile AND xauto <> 'X' AND a~mjahr = iins-mjahr.
      read table iartab with key mblnr = iins-mblnr zeile = iins-zeile.
      if sy-subrc = 0.
        v_bwart = iartab-bwart.
        v_qty = iartab-qty.
        v_budat = iartab-budat.
      endif.
      IF v_bwart = '321'.
        v_newaccqty = v_newaccqty + v_qty.
        itab-accqty = v_newaccqty.
        itab-qcdat = v_budat.
        itab-accuom = iartab-erfme.
      ELSEIF v_bwart = '122'.
        itab-qcdat = v_budat.
        v_newrejqty = v_newrejqty + v_qty.
        itab-rejqty = v_newrejqty.
        itab-rejuom = iartab-erfme.
      ENDIF.
    ENDLOOP.        "*********END OF LOOP FOR ITAB1**************
        clear: v_newaccqty, v_newrejqty.
  ENDIF.    "**********END OF MAIN ENDIF***********************
         *****************END OF CODE FOR ACCEPTED AND REJECTED QTY************************************
     ****************************GETTING DEBIT AND CREDIT QTY******************************************
  LOOP AT imiro WHERE lfbnr = itab-mblnr AND ebeln = itab-ebeln AND ebelp = itab-ebelp.
    ITAB-MIRO_BUDAT = IMIRO-BUDAT.
    itab-belnr = imiro-belnr.
    IF imiro-shkzg = 'S'.
      itab-dqty = imiro-menge.
    ELSEIF imiro-shkzg = 'H'.
      itab-cqty = imiro-menge.
    ENDIF.
  ENDLOOP.
     *****************************END OF CODE FOR DEBIT AND CREDIT QTY*******************************
  data v_sumqty like mseg-menge.
  CLEAR V_SUMQTY.
  if itab-qcins = 'X'.
  clear: cmpaccqty, cmprejqty.
  cmpaccqty = itab-accqty.
  cmprejqty = itab-rejqty.
    IF ITAB-UOM <> ITAB-ACCUOM AND ITAB-ACCUOM <> SPACE.
      CALL FUNCTION 'ZCONVERT_UOM_QTY'
       EXPORTING
         P_FR_UOM       = ITAB-UOM
         P_TO_UOM       = ITAB-ACCUOM
         P_QTY          = ITAB-ACCQTY
       IMPORTING
         P_RETVAL       = CMPACCQTY.
     ELSEIF ITAB-UOM <> ITAB-REJUOM AND ITAB-REJUOM <> SPACE.
       CALL FUNCTION 'ZCONVERT_UOM_QTY'
         EXPORTING
           P_FR_UOM       = ITAB-UOM
           P_TO_UOM       = ITAB-REJUOM
           P_QTY          = ITAB-REJQTY
         IMPORTING
           P_RETVAL       = CMPREJQTY.
     ENDIF.
    v_sumqty = CMPACCQTY + CMPREJQTY.
    if ( v_sumqty = itab-recqty ).
      itab-qcstat = 'C'.
      modify itab.
    ELSE.
      ITAB-QCSTAT = 'P'.
    endif.
  ELSE.
    ITAB-QCSTAT = 'C'.
  endif.
IF ITAB-QCSTAT = 'C'.
  IF ITAB-DQTY = ITAB-RECQTY.
    ITAB-ACSTAT = 'C'.
  ELSE.
    ITAB-ACSTAT = 'P'.
  ENDIF.
ELSEIF ITAB-QCSTAT = 'P'.
  IF ITAB-RECQTY = ITAB-DQTY.
    ITAB-ACSTAT = 'O'.
  ENDIF.
ENDIF.
IF ITAB-REJQTY > 0.
  IF ITAB-ACSTAT = 'C' AND ITAB-REJQTY > ITAB-CQTY.
    ITAB-CRNOTE = 'P'.
  ELSEIF ITAB-ACSTAT = 'C' AND ITAB-REJQTY < ITAB-CQTY.
    ITAB-CRNOTE = 'W'.
  ELSEIF ITAB-ACSTAT = 'C' AND ITAB-REJQTY = ITAB-CQTY.
    ITAB-CRNOTE = 'C'.
  ENDIF.
ELSE.
  ITAB-CRNOTE = 'N'.
ENDIF.
MODIFY itab.
ENDLOOP.    "*********************************************"END OF MAINT LOOP FOR ITAB.***********************
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
      wa_fieldcat TYPE slis_fieldcat_alv,
      wa_layout TYPE slis_layout_alv.
PERFORM f_layout.
PERFORM f_fieldcat.
PERFORM display.
*&      Form  F_LAYOUT
      text
FORM f_layout.
  wa_layout-colwidth_optimize = 'X'.
  wa_layout-no_subchoice = 'X'.
  wa_layout-zebra = 'X'.
ENDFORM.                    "F_LAYOUT
*&      Form  F_FIELDCAT
      text
FORM f_fieldcat.
  DATA wa_col TYPE i VALUE 1.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'GR. NO'.
  wa_fieldcat-fieldname = 'MBLNR'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'GR DATE'.
  wa_fieldcat-fieldname = 'BUDAT'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'PO NO'.
  wa_fieldcat-fieldname = 'EBELN'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-seltext_l = 'PARTY ID'.
  wa_fieldcat-fieldname = 'LIFNR'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'PARTY NAME'.
  wa_fieldcat-fieldname = 'NAME1'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-outputlen = '18'.
  wa_fieldcat-seltext_l = 'ITEM ID'.
  wa_fieldcat-fieldname = 'MATNR'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'DESCRIPTION'.
  wa_fieldcat-fieldname = 'TXZ01'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'UOM'.
  wa_fieldcat-fieldname = 'UOM'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'INS REQ'.
  wa_fieldcat-fieldname = 'QCINS'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-seltext_l = 'GR QTY'.
  wa_fieldcat-fieldname = 'RECQTY'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'QC DATE'.
  wa_fieldcat-fieldname = 'QCDAT'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-seltext_l = 'ACC QTY'.
  wa_fieldcat-fieldname = 'ACCQTY'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-seltext_l = 'ACC UOM'.
  wa_fieldcat-fieldname = 'ACCUOM'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-seltext_l = 'REJ QTY'.
  wa_fieldcat-fieldname = 'REJQTY'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-seltext_l = 'REJ UOM'.
  wa_fieldcat-fieldname = 'REJUOM'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'MIRO NO'.
  wa_fieldcat-fieldname = 'BELNR'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'MIRO DATE'.
  wa_fieldcat-fieldname = 'MIRO_BUDAT'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-seltext_l = 'DB.QTY'.
  wa_fieldcat-fieldname = 'DQTY'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-no_zero = 'X'.
  wa_fieldcat-seltext_l = 'CR.QTY'.
  wa_fieldcat-fieldname = 'CQTY'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'QC STATUS'.
  wa_fieldcat-fieldname = 'QCSTAT'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'A/C STATUS'.
  wa_fieldcat-fieldname = 'ACSTAT'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.
  wa_fieldcat-col_pos = wa_col + 1.
  wa_fieldcat-seltext_l = 'CR NOTE STATUS'.
  wa_fieldcat-fieldname = 'CRNOTE'.
  wa_fieldcat-tabname = itab.
  APPEND wa_fieldcat to it_fieldcat.
  clear wa_fieldcat.
ENDFORM.                    "F_FIELDCAT
*&      Form  DISPLAY
      text
FORM display.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = sy-repid
      is_layout          = wa_layout
      I_CALLBACK_USER_COMMAND  = 'HANDLE_USER_COMMAND'
      it_fieldcat        = it_fieldcat
    TABLES
      t_outtab           = itab.
ENDFORM.                    "DISPLAY
FORM HANDLE_USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                             RS_SELFIELD TYPE SLIS_SELFIELD.
   CASE R_UCOMM.
    WHEN '&IC1'.
    clear itab-ebeln.
      IF RS_SELFIELD-FIELDNAME = 'EBELN'.
        READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
        SET PARAMETER ID 'BES' FIELD ITAB-EBELN.
        call transaction 'ME23N' AND SKIP FIRST SCREEN.
        CLEAR RS_SELFIELD.
      ELSEIF RS_SELFIELD-FIELDNAME = 'MBLNR'.
        READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
        SET PARAMETER ID 'MBN' FIELD ITAB-MBLNR.
        SET PARAMETER ID 'MJA' FIELD year.
        call transaction 'MIGO' AND SKIP FIRST SCREEN.
        CLEAR RS_SELFIELD.
      ENDIF.
  ENDCASE.
ENDFORM.                    "HANDLE_USER_COMMAND

Ways of Performance Tuning
1.     Selection Criteria
2.     Select Statements
•     Select Queries
•     SQL Interface
•     Aggregate Functions
•     For all Entries
Select Over more than one internal table
Selection Criteria
1.     Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement. 
2.     Select with selection list.
SELECT * FROM SBOOK INTO SBOOK_WA.
  CHECK: SBOOK_WA-CARRID = 'LH' AND
         SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list
SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
  WHERE SBOOK_WA-CARRID = 'LH' AND
              SBOOK_WA-CONNID = '0400'.
Select Statements   Select Queries
1.     Avoid nested selects
SELECT * FROM EKKO INTO EKKO_WA.
  SELECT * FROM EKAN INTO EKAN_WA
      WHERE EBELN = EKKO_WA-EBELN.
  ENDSELECT.
ENDSELECT.
The above code can be much more optimized by the code written below.
SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
    FROM EKKO AS P INNER JOIN EKAN AS F
      ON PEBELN = FEBELN.
Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.
2.     Select all the records in a single shot using into table clause of select statement rather than to use Append statements.
SELECT * FROM SBOOK INTO SBOOK_WA.
  CHECK: SBOOK_WA-CARRID = 'LH' AND
         SBOOK_WA-CONNID = '0400'.
ENDSELECT.
The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list and puts the data in one shot using into table
SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
  WHERE SBOOK_WA-CARRID = 'LH' AND
              SBOOK_WA-CONNID = '0400'.
3.     When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index.
To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.
4.     For testing existence, use Select.. Up to 1 rows statement instead of a Select-Endselect-loop with an Exit. 
SELECT * FROM SBOOK INTO SBOOK_WA
  UP TO 1 ROWS
  WHERE CARRID = 'LH'.
ENDSELECT.
The above code is more optimized as compared to the code mentioned below for testing existence of a record.
SELECT * FROM SBOOK INTO SBOOK_WA
    WHERE CARRID = 'LH'.
  EXIT.
ENDSELECT.
5.     Use Select Single if all primary key fields are supplied in the Where condition .
If all primary key fields are supplied in the Where conditions you can even use Select Single.
Select Single requires one communication with the database system, whereas Select-Endselect needs two.
Select Statements SQL Interface
1.     Use column updates instead of single-row updates
to update your database tables.
SELECT * FROM SFLIGHT INTO SFLIGHT_WA.
  SFLIGHT_WA-SEATSOCC =
    SFLIGHT_WA-SEATSOCC - 1.
  UPDATE SFLIGHT FROM SFLIGHT_WA.
ENDSELECT.
The above mentioned code can be more optimized by using the following code
UPDATE SFLIGHT
       SET SEATSOCC = SEATSOCC - 1.
2.     For all frequently used Select statements, try to use an index.
SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
  WHERE CARRID = 'LH'
    AND CONNID = '0400'.
ENDSELECT.
The above mentioned code can be more optimized by using the following code
SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
  WHERE MANDT IN ( SELECT MANDT FROM T000 )
    AND CARRID = 'LH'
    AND CONNID = '0400'.
ENDSELECT.
3.     Using buffered tables improves the performance considerably.
Bypassing the buffer increases the network considerably
SELECT SINGLE * FROM T100 INTO T100_WA
  BYPASSING BUFFER
  WHERE     SPRSL = 'D'
        AND ARBGB = '00'
        AND MSGNR = '999'.
The above mentioned code can be more optimized by using the following code
SELECT SINGLE * FROM T100  INTO T100_WA
  WHERE     SPRSL = 'D'
        AND ARBGB = '00'
        AND MSGNR = '999'.
Select Statements  Aggregate Functions
•     If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself.
Some of the Aggregate functions allowed in SAP are  MAX, MIN, AVG, SUM, COUNT, COUNT( * )
Consider the following extract.
            Maxno = 0.
            Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
             Check zflight-fligh > maxno.
             Maxno = zflight-fligh.
            Endselect.
The  above mentioned code can be much more optimized by using the following code.
Select max( fligh ) from zflight into maxno where airln = ‘LF’ and cntry = ‘IN’.
Select Statements  For All Entries
•     The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
     The plus
•     Large amount of data
•     Mixing processing and reading of data
•     Fast internal reprocessing of data
•     Fast
     The Minus
•     Difficult to program/understand
•     Memory could be critical (use FREE or PACKAGE size)
Points to be must considered FOR ALL ENTRIES
•     Check that data is present in the driver table
•     Sorting the driver table
•     Removing duplicates from the driver table
Consider the following piece of extract
          Loop at int_cntry.
  Select single * from zfligh into int_fligh
  where cntry = int_cntry-cntry.
  Append int_fligh.
                      Endloop.
The above mentioned can be more optimized by using the following code.
Sort int_cntry by cntry.
Delete adjacent duplicates from int_cntry.
If NOT int_cntry[] is INITIAL.
            Select * from zfligh appending table int_fligh
            For all entries in int_cntry
            Where cntry = int_cntry-cntry.
Endif.
Select Statements Select Over more than one Internal table
1.     Its better to use a views instead of nested Select statements.
SELECT * FROM DD01L INTO DD01L_WA
  WHERE DOMNAME LIKE 'CHAR%'
        AND AS4LOCAL = 'A'.
  SELECT SINGLE * FROM DD01T INTO DD01T_WA
    WHERE   DOMNAME    = DD01L_WA-DOMNAME
        AND AS4LOCAL   = 'A'
        AND AS4VERS    = DD01L_WA-AS4VERS
        AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
The above code can be more optimized by extracting all the data from view DD01V_WA
SELECT * FROM DD01V INTO  DD01V_WA
  WHERE DOMNAME LIKE 'CHAR%'
        AND DDLANGUAGE = SY-LANGU.
ENDSELECT
2.     To read data from several logically connected tables use a join instead of nested Select statements. Joins are preferred only if all the primary key are available in WHERE clause for the tables that are joined. If the primary keys are not provided in join the Joining of tables itself takes time.
SELECT * FROM EKKO INTO EKKO_WA.
  SELECT * FROM EKAN INTO EKAN_WA
      WHERE EBELN = EKKO_WA-EBELN.
  ENDSELECT.
ENDSELECT.
The above code can be much more optimized by the code written below.
SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
    FROM EKKO AS P INNER JOIN EKAN AS F
      ON PEBELN = FEBELN.
3.     Instead of using nested Select loops it is often better to use subqueries.
SELECT * FROM SPFLI
  INTO TABLE T_SPFLI
  WHERE CITYFROM = 'FRANKFURT'
    AND CITYTO = 'NEW YORK'.
SELECT * FROM SFLIGHT AS F
    INTO SFLIGHT_WA
    FOR ALL ENTRIES IN T_SPFLI
    WHERE SEATSOCC < F~SEATSMAX
      AND CARRID = T_SPFLI-CARRID
      AND CONNID = T_SPFLI-CONNID
      AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
The above mentioned code can be even more optimized by using subqueries instead of for all entries.
SELECT * FROM SFLIGHT AS F INTO SFLIGHT_WA
    WHERE SEATSOCC < F~SEATSMAX
      AND EXISTS ( SELECT * FROM SPFLI
                     WHERE CARRID = F~CARRID
                       AND CONNID = F~CONNID
                       AND CITYFROM = 'FRANKFURT'
                       AND CITYTO = 'NEW YORK' )
      AND FLDATE BETWEEN '19990101' AND '19990331'.
ENDSELECT.
1.     Table operations should be done using explicit work areas rather than via header lines.
READ TABLE ITAB INTO WA WITH KEY K = 'X‘ BINARY SEARCH.
IS MUCH FASTER THAN USING
READ TABLE ITAB INTO WA WITH KEY K = 'X'.
If TAB has n entries, linear search runs in O( n ) time, whereas binary search takes only O( log2( n ) ).
2.     Always try to use binary search instead of linear search. But don’t forget to sort your internal table before that.
READ TABLE ITAB INTO WA WITH KEY K = 'X'. IS FASTER THAN USING
READ TABLE ITAB INTO WA WITH KEY (NAME) = 'X'.
3.     A dynamic key access is slower than a static one, since the key specification must be evaluated at runtime.
4.     A binary search using secondary index takes considerably less time.
5.     LOOP ... WHERE is faster than LOOP/CHECK because LOOP ... WHERE evaluates the specified condition internally.
LOOP AT ITAB INTO WA WHERE K = 'X'.
ENDLOOP.
The above code is much faster than using
LOOP AT ITAB INTO WA.
  CHECK WA-K = 'X'.
ENDLOOP.
6.     Modifying selected components using “ MODIFY itab …TRANSPORTING f1 f2.. “ accelerates the task of updating  a line of an internal table.
WA-DATE = SY-DATUM.
MODIFY ITAB FROM WA INDEX 1 TRANSPORTING DATE.
The above code is more optimized as compared to
WA-DATE = SY-DATUM.
MODIFY ITAB FROM WA INDEX 1.
7.     Accessing the table entries directly in a "LOOP ... ASSIGNING ..." accelerates the task of updating a set of lines of an internal table considerably
Modifying selected components only makes the program faster as compared to Modifying all lines completely.
e.g,
LOOP AT ITAB ASSIGNING <WA>.
  I = SY-TABIX MOD 2.
  IF I = 0.
    <WA>-FLAG = 'X'.
  ENDIF.
ENDLOOP.
The above code works faster as compared to
LOOP AT ITAB INTO WA.
  I = SY-TABIX MOD 2.
  IF I = 0.
    WA-FLAG = 'X'.
    MODIFY ITAB FROM WA.
  ENDIF.
ENDLOOP.
8.    If collect semantics is required, it is always better to use to COLLECT rather than READ BINARY and then ADD.
LOOP AT ITAB1 INTO WA1.
  READ TABLE ITAB2 INTO WA2 WITH KEY K = WA1-K BINARY SEARCH.
  IF SY-SUBRC = 0.
    ADD: WA1-VAL1 TO WA2-VAL1,
         WA1-VAL2 TO WA2-VAL2.
    MODIFY ITAB2 FROM WA2 INDEX SY-TABIX TRANSPORTING VAL1 VAL2.
  ELSE.
    INSERT WA1 INTO ITAB2 INDEX SY-TABIX.
  ENDIF.
ENDLOOP.
The above code uses BINARY SEARCH for collect semantics. READ BINARY runs in O( log2(n) ) time. The above piece of code can be more optimized by
LOOP AT ITAB1 INTO WA.
  COLLECT WA INTO ITAB2.
ENDLOOP.
SORT ITAB2 BY K.
COLLECT, however, uses a hash algorithm and is therefore independent
of the number of entries (i.e. O(1)) .
9.    "APPEND LINES OF itab1 TO itab2" accelerates the task of appending a table to another table considerably as compared to “ LOOP-APPEND-ENDLOOP.”
APPEND LINES OF ITAB1 TO ITAB2.
This is more optimized as compared to
LOOP AT ITAB1 INTO WA.
  APPEND WA TO ITAB2.
ENDLOOP.
10.   “DELETE ADJACENT DUPLICATES“ accelerates the task of deleting duplicate entries considerably as compared to “ READ-LOOP-DELETE-ENDLOOP”.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING K.
This is much more optimized as compared to
READ TABLE ITAB INDEX 1 INTO PREV_LINE.
LOOP AT ITAB FROM 2 INTO WA.
  IF WA = PREV_LINE.
    DELETE ITAB.
  ELSE.
    PREV_LINE = WA.
  ENDIF.
ENDLOOP.
11.   "DELETE itab FROM ... TO ..." accelerates the task of deleting a sequence of lines considerably as compared to “  DO -DELETE-ENDDO”.
DELETE ITAB FROM 450 TO 550.
This is much more optimized as compared to
DO 101 TIMES.
  DELETE ITAB INDEX 450.
ENDDO.
12.   Copying internal tables by using “ITAB2[ ] = ITAB1[ ]” as compared to “LOOP-APPEND-ENDLOOP”.
ITAB2[] = ITAB1[].
This is much more optimized as compared to
REFRESH ITAB2.
LOOP AT ITAB1 INTO WA.
  APPEND WA TO ITAB2.
ENDLOOP.
13.   Specify the sort key as restrictively as possible to run the program faster.
“SORT ITAB BY K.” makes the program runs faster as compared to “SORT ITAB.”
Internal Tables         contd…
Hashed and Sorted tables
1.     For single read access hashed tables are more optimized as compared to sorted tables.
2.      For partial sequential access sorted tables are more optimized as compared to hashed tables
Hashed And Sorted Tables
Point # 1
Consider the following example where HTAB is a hashed table and STAB is a sorted table
DO 250 TIMES.
  N = 4 * SY-INDEX.
  READ TABLE HTAB INTO WA WITH TABLE KEY K = N.
  IF SY-SUBRC = 0.
  ENDIF.
ENDDO.
This runs faster for single read access as compared to the following same code for sorted table
DO 250 TIMES.
  N = 4 * SY-INDEX.
  READ TABLE STAB INTO WA WITH TABLE KEY K = N.
  IF SY-SUBRC = 0.
  ENDIF.
ENDDO.
Point # 2
Similarly for Partial Sequential access the STAB runs faster as compared to HTAB
LOOP AT STAB INTO WA WHERE K = SUBKEY.
ENDLOOP.
This runs faster as compared to
LOOP AT HTAB INTO WA WHERE K = SUBKEY.
ENDLOOP.

Similar Messages

  • PERFORMANCE of this REPORT object

    Hi Experts
    I have a REPORT object, having a few SELECT Queries in it. I need to analyze the PERFORMANCE of this REPORT object.
    How can I analyze the performance of a SELECT Query alone in it - that is time taken to execute this SELECT Query alone?
    How can I find the total execution time taken by the REPORT object?
    Plz suggest.
    BD

    Hi Bobby,
    TYPES : BEGIN OF gtyp_rbkp,
              belnr TYPE re_belnr,
              gjahr TYPE gjahr,
              budat TYPE budat,
              usnam TYPE usnam,
              lifnr TYPE lifre,
              ivtyp TYPE ivtyp,
              lieffn TYPE lieffn,
            END OF gtyp_rbkp.
    DATA : gt_rbkp TYPE STANDARD TABLE OF gtyp_rbkp,
          gs_rbkp type gtyp_rbkp.
    DATA: gv_str_j TYPE i,
    gv_end_j TYPE i,
    gv_run_time_join TYPE p DECIMALS 2.
    constants : lc_a type char1 value 'A'.
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-015.
    SELECT-OPTIONS : so_belnr FOR gs_rbkp-belnr,
                     so_gjahr FOR gs_rbkp-gjahr NO-EXTENSION NO INTERVALS,
                     so_usnam FOR gs_rbkp-usnam,
                     so_lifnr FOR gs_rbkp-lifnr,
                     so_budat FOR gs_rbkp-budat NO-EXTENSION OBLIGATORY
                                                DEFAULT sy-datum.
    SELECTION-SCREEN: END OF BLOCK b1.
    start-of-selection.
    write: 'testing performance'.
    get RUN TIME FIELD gv_str_j.
    SELECT belnr
             gjahr
             budat
             usnam
             lifnr
             ivtyp
             lieffn
        FROM rbkp
        INTO TABLE gt_rbkp
        WHERE belnr IN so_belnr
          AND gjahr IN so_gjahr
          AND budat IN so_budat
          AND usnam IN so_usnam
          AND lifnr IN so_lifnr.
      IF sy-subrc EQ 0.
    **delete entries from GT_RBKP where IVTYP ne A(Invoice from Parking Function)
        DELETE gt_rbkp WHERE ivtyp NE lc_a.
      ENDIF.
    get RUN TIME FIELD gv_end_j.
    Now get the runtime.
    gv_run_time_join = ( gv_end_j - gv_str_j ) / 1000000 .
    write:/ 'Report RunTime with delete is ', gv_run_time_join, 'seconds'.
    clear : gv_str_j, gt_rbkp[], gv_end_j.
    Hope this will help you.
    Regards,
    Phani

  • How to increase performance in webi report?

    Hi Experts,
    I have create report top of universe with 1 query.But inside report i created multiple tabs.Data also less but while executing the report it will take so much time. How should decrease the waiting time.
    I followed performance optimization:
    1. ALL formula created in Bex itself.
    2.Enable Query Stripping
    3. Remove auto width and auto height.
    4.scheduling the report.
    Please tell another some performance tuning.

    You'll want to determine where the time is being spent.  You can trace the BW side to see how long it is taking on that end but it is probably the design of the report that is taking the time.  Are you using a UNV universe going to a BEx query or a BICs based connection?
    Query Stripping is automatically on for BI 4.0 SP5+ for BICs connectivity.  There are also a number of optimizations that can help improve performance in the newer Support Packages. 
    Determining where the bottleneck is is the first step.
    thanks
    Jb

  • Auto-increment column increase performance in this case ?

    hi.
    i have the following facts to construct a set of tables.
    1. A Lecturer has an ID, Name and Date Joined
    2. A Classroom has an ID, Number Of Students
    3. A Lecturer can Teach in Many Classes
    4. A Class Can be lectured by Many Lecturers
    5. Each Lecture Date should be Stored in the DB.
    considering those facts, the following schema can be derived
    Lecturer
    (Lecturer_ID (PK), Lecturer_name, Date_Joined)
    Classroom
    (Classroom_ID (PK), NumOfStudents)
    Class_Lectures
    (Classroom_ID, Lecturer_ID (Composte PK), LectureDate)
    this is the normal practice we do.
    but what if the 3rd Table is constructed as follows ?
    Class_Lectures
    (LectureSeriesID (Auto-Increment, PK), Classroom_ID, Lecturer_ID (Composte Unique Key), LectureDate)
    if the 3rd Table is created as above, will there be any performance differences ? will the performance improve or get reduced ? any advantages / disadvantages of having that structure ?
    please do advise my any further best practices as well.
    Thanks and Regards

    http://technet.oracle.com:89/ubb/Forum88/HTML/000944.html
    null

  • How to put header and how to insert logo in this report

    HI
    I want  a header and logo in this report.how to do this in ALV report.Also why we have to put the          sy-repid.Plz tell me in this report where i have to do all this.Plz show me in detail.
    REPORT  ZREPORT_ALV .
    TYPE-POOLS : slis.
    tables:vbak,vbap.
    *DATA:  report_id LIKE sy-repid.
    DATA: I_LAYOUT TYPE SLIS_LAYOUT_ALV.
    data: ivariant(1) type c,
          itvariant like disvariant,
          w_variant like disvariant.
    initialization.
    *REPORT_ID = SY-REPID.
    PERFORM F1000_LAYOUT_INIT. "using I_LAYOUT.
    ivariant = 'A'.
    itvariant = w_variant.
    select-options:so_vbeln for vbap-vbeln.
    data:itab like vbak occurs 0 with header line.
    data:itab1 like vbap occurs 0 with header line.
    start-of-selection.
    select * from vbak into table itab where vbeln in so_vbeln.
    if not itab[] is initial.
    select * from vbap into table itab1
    for all entries in itab
    where vbeln = itab-vbeln.
    endif.
    data:ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat1  TYPE slis_t_fieldcat_alv.
    ****For alv display
    IF NOT itab1[] IS INITIAL.
       DEFINE ls_fieldcat.
       add 1 to ls_fieldcat-col_pos.
        ls_fieldcat-fieldname    = &1.
        ls_fieldcat-outputlen    = &2.
        ls_fieldcat-seltext_l    = &3.
         ls_fieldcat-emphasize  = &4.
        append ls_fieldcat to lt_fieldcat1.
        clear ls_fieldcat.
      END-OF-DEFINITION.
        ls_fieldcat 'VBELN'           '10'     'Sales Order Number'.
       ls_fieldcat 'POSNR'           '6'        'SO Item'.
        ls_fieldcat 'MATNR'           '13'      'Material No'.
    m_fieldcat1 'NETWR'           '13'        'Amount'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = 'wf_report'
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
    I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
       IS_LAYOUT                         =  I_LAYOUT
       IT_FIELDCAT                       =  lt_fieldcat1
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =   ITVARIANT
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          =  itab1
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endif.
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
       I_SAVE              = ivariant
      CHANGING
       CS_VARIANT          = itvariant
    EXCEPTIONS
      WRONG_INPUT         = 1
      NOT_FOUND           = 2
      PROGRAM_ERROR       = 3
      OTHERS              = 4
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    FORM F1000_LAYOUT_INIT. "USING I_LAYOUT TYPE SLIS_LAYOUT_ALV.
    *CLEAR I_LAYOUT.
    i_layout-colwidth_optimize = 'X'.
    I_LAYOUT-key_hotspot = u2018Xu2019.
    I_LAYOUT-hotspot_fieldname =  MATNR.
    ENDFORM.

    hi,,,,
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = sy-repid >>>>>>>>>>>>> your report name.
    regarding logo and header,,,,
    first store the logo in T-code OAOR, then call that in your report.......
    data: heading        TYPE slis_t_listheader,
          wa_header      TYPE slis_listheader,
         events         TYPE slis_t_event.
    * To display TOP_OF_PAGE.
    FORM top_of_page.
      DATA : text(40),txtdt(40).
      CLEAR l_string.
      l_string = 'JCB India Limited'(hd2).
      wa_header-typ  = 'H'.
      wa_header-info = l_string.
      APPEND wa_header TO heading.                              " index 1.
      CLEAR l_string.
      WRITE :'Number of records:' TO text,dbcnt TO text+20 LEFT-JUSTIFIED.
      wa_header-typ  = 'S'.
      wa_header-info = text.
      APPEND wa_header TO heading.
      CLEAR l_string.
      wa_header-typ  = 'S'.
      WRITE : 'Report Run Date  :' TO txtdt,sy-datum TO txtdt+20 DD/MM/YY.
      WRITE sy-datum TO dat DD/MM/YY.
      wa_header-info = txtdt.
      APPEND wa_header TO heading.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'ENJOYSAP_LOGO'
          it_list_commentary = heading.
      CLEAR heading.
    ENDFORM.                    "top_of_page
    to execute top-of-page you have to create events.
    for ex......
    FORM create_event USING p_events TYPE slis_t_event.
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = p_events.
      READ TABLE p_events WITH KEY name = slis_ev_top_of_page
                               INTO ls_event.
      IF sy-subrc = 0.
        MOVE formname_top_of_page TO ls_event-form.
        APPEND ls_event TO p_events.
      ENDIF.
    ENDFORM.                    " create_event

  • U0095     Vendor performance report this report gives performance of supplier to se

    Vendor performance report this report gives performance of supplier to send an order to customer

    Kiran,
    The functionality you are asking sounds like standard functionality. Doesn't make sense to custom develop the same.
    Make sure you search and confirm that standard reports are NOT available for the same.
    Regards,
    Ravi
    Note : please mark the helpful answers

  • Performance tuning of this report

    Hello friends iam attaching my report give the performance tuning for this report to avoid nested endloops. how to do without using nested endloops.
    give me the reply urgent.
    REPORT  ZDEMO9          NO STANDARD PAGE HEADING
                            LINE-SIZE 250
                            LINE-COUNT 22(3).                             .
                TABLES DECLARATION                    *
    TABLES : MARA,              "general material data
             MAKT,              "material description
             MARC,              "plant data for material
             VBAP,              "sales document for item data
             EKKO,              "purchasing document header
             EKPO,              "purchasing document item
             KNA1.              "customer master details
                INTERNAL TABLE DECLARATION             *
    DATA : BEGIN OF T_MARA OCCURS 0,
           MATNR LIKE MARA-MATNR,
           MTART LIKE MARA-MTART,
           MEINS LIKE MARA-MEINS,
           END OF T_MARA.
    DATA : BEGIN OF T_MAKT OCCURS 0,
           MATNR LIKE MAKT-MATNR,
           MAKTX LIKE MAKT-MAKTX,
           SPRAS LIKE MAKT-SPRAS,
           END OF T_MAKT.
    DATA : BEGIN OF T_MARC OCCURS 0,
           MATNR LIKE MARC-MATNR,
           WERKS LIKE MARC-WERKS,
           END OF T_MARC.
    DATA : BEGIN OF T_KNA1 OCCURS 0,
           KUNNR LIKE KNA1-KUNNR,
           NAME1 LIKE KNA1-NAME1,
           LAND1 LIKE KNA1-LAND1,
           END OF T_KNA1.
    DATA : BEGIN OF T_VBAP OCCURS 0,
           MATNR LIKE VBAP-MATNR,
           POSNR LIKE VBAP-POSNR,
           MATKL LIKE VBAP-MATKL,
           VBELN LIKE VBAP-VBELN,
           END OF T_VBAP.
    DATA : BEGIN OF T_EKPO OCCURS 0,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           BUKRS LIKE EKPO-BUKRS,
           WERKS LIKE EKPO-WERKS,
           LGORT LIKE EKPO-LGORT,
           MATNR LIKE EKPO-MATNR,
           MANDT LIKE EKPO-MANDT,
           END OF T_EKPO.
                     FINAL INTERNAL TABLE                *
    DATA : BEGIN OF T_FINAL OCCURS 0,
           MATNR LIKE MARA-MATNR,
           MTART LIKE MARA-MTART,
           MEINS LIKE MARA-MEINS,
           WERKS LIKE MARC-WERKS,
           MAKTX LIKE MAKT-MAKTX,
           SPRAS LIKE MAKT-SPRAS,
           VBELN LIKE VBAP-VBELN,
           POSNR LIKE VBAP-POSNR,
           MATKL LIKE VBAP-MATKL,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           BUKRS LIKE EKPO-BUKRS,
           KUNNR LIKE KNA1-KUNNR,
           LAND1 LIKE KNA1-LAND1,
           NAME1 LIKE KNA1-NAME1,
           LGORT LIKE EKPO-LGORT,
           END OF T_FINAL.
    *DATA: BEGIN OF V_matnr OCCURS 0,
           matnr LIKE mara-matnr,
         END OF t_matnr.
    data:
          a(32) type c.
    a = 'IBT000000000000000001000000000000000050'.
                       SELECTION SCREEN                         *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_BUKRS FOR EKPO-BUKRS,
                     S_KUNNR FOR KNA1-KUNNR,
                     S_WERKS FOR MARC-WERKS,
                     S_MATNR FOR MARA-MATNR obligatory.
    SELECTION-SCREEN END OF BLOCK B1.
                     START OF SELECTION                           *
    START-OF-SELECTION.
      SELECT MATNR mtart meins
              FROM MARA
              INTO CORRESPONDING FIELDS OF TABLE T_MARA
              WHERE MATNR IN S_MATNR.
      SELECT MATNR WERKS
              FROM MARC
              INTO CORRESPONDING FIELDS OF TABLE T_MARC
              FOR ALL ENTRIES IN T_MARA
              WHERE MATNR = T_MARA-MATNR
              and werks in s_werks.
      select  matnr maktx spras
            from makt
            into corresponding fields of table t_makt
            for all entries in t_mara
            where matnr = t_mara-matnr
            and spras = sy-langu.
      select matnr posnr matkl vbeln
             from vbap
             into corresponding fields of table t_vbap
             for all entries in t_mara
             where matnr = t_mara-matnr.
    select matnr werks bukrs ebeln ebelp lgort
             from ekpo
             into corresponding fields of table t_ekpo
             for all entries in t_mara
             where matnr = t_mara-matnr
             and werks in s_werks.
      LOOP AT T_MARA.
        MOVE T_MARA-matnr TO T_FINAL-matnr.
        move t_mara-mtart to t_final-mtart.
        move t_mara-meins to t_final-meins.
        loop at t_marc where matnr eq t_mara-matnr.
          move t_marc-werks to t_final-werks.
          loop at t_makt.
            move t_makt-maktx to t_final-maktx.
            move t_makt-spras to t_final-spras.
            loop at t_vbap.
              move t_vbap-posnr to t_final-posnr.
              move t_vbap-matkl to t_final-matkl.
              move t_vbap-vbeln to t_final-vbeln.
            loop at t_ekpo.
            move t_ekpo-bukrs to t_final-bukrs.
            move t_ekpo-ebeln to t_final-ebeln.
            move t_ekpo-ebelp to t_final-ebelp.
            move t_ekpo-lgort to t_final-lgort.
              append t_final.
            endloop.
          endloop.
        endloop.
      endloop.
      endloop.
      SELECT werks KUNNR LAND1 NAME1
      INTO CORRESPONDING FIELDS OF TABLE T_KNA1
      FROM KNA1.
    WHERE WERKS in s_werks.
      loop at t_kna1.
        move t_kna1-kunnr to t_final-kunnr.
        move t_kna1-name1 to t_final-name1.
        move t_kna1-land1 to t_final-land1.
        append t_final.
      endloop.
      "endloop.
      loop at t_final.
        write :   4 t_final-matnr,
                 20 t_final-mtart,
                 28 t_final-meins,
                 46 t_final-werks,
                 58 t_final-maktx,
                 71 t_final-spras,
                 78 t_final-posnr,
                100 t_final-matkl,
                115 t_final-vbeln,
                130 t_final-kunnr,
                142 t_final-name1,
                156 t_final-land1,
                168 t_final-bukrs,
                190 t_final-ebeln,
                205 t_final-ebelp,
                208 t_final-lgort.
      endloop.
                  TOP-OF-PAGE                       *
    top-of-page.
      uline.
      write : /60 'G E N E R A L   D E T A I L S' COLOR 2 INVERSE OFF.
      ULINE.
      write :/ SY-VLINE,    'MATERIAL'       COLOR 4, "12 SY-VLINE,
            13 SY-VLINE,    'IND SECTOR',
            28 SY-VLINE,    'UNITS',
            43 SY-VLINE,    'PLANT',
            55 SY-VLINE,    'MAT DESC',
            68 SY-VLINE,    'LANGU',
            70 SY-VLINE,    'SALES DOC ITEM',
            95 SY-VLINE,    'MAT GROUP',
           110 SY-VLINE,    'SALES DOC',
           125 SY-VLINE,    'CUST ID',
           140 SY-VLINE,    'NAME',
           155 SY-VLINE,    'COUNTRY',
           165 sy-vline,    'company code',
           205 sy-vline,    'storge loc'.

    *& Report  YTESTCHA                                                    *
    REPORT ytestcha  NO STANDARD PAGE HEADING
    LINE-SIZE 250
    LINE-COUNT 22(3). .
    TABLES DECLARATION *
    TABLES : mara, "general material data
    makt, "material description
    marc, "plant data for material
    vbap, "sales document for item data
    ekko, "purchasing document header
    ekpo, "purchasing document item
    kna1. "customer master details
    INTERNAL TABLE DECLARATION *
    *DECLARE TYPES FIRST AND THE INTERNAL TABLES
    *DONT USE MATNR LIKE MARA-MATNR ,INSTEAD USE MARA TYPE MATNR WHERE MATNR
    *IS THE DATA ELEMENT FOR FIELD MATNR.
    TYPES: BEGIN OF ty_mara,
             matnr TYPE matnr,
             mtart TYPE mtart,
             meins TYPE meins,
             kunnr TYPE wettb,
           END OF ty_mara.
    TYPES: BEGIN OF ty_makt,
            matnr TYPE matnr,
            maktx TYPE maktx,
            spras TYPE spras,
           END OF ty_makt.
    TYPES: BEGIN OF ty_marc,
            matnr TYPE matnr,
            werks TYPE werks_d,
            END OF ty_marc.
    TYPES : BEGIN OF ty_kna1,
              kunnr TYPE kunnr,
              name1 TYPE name1_gp,
              land1 TYPE land1_gp,
              END OF ty_kna1.
    TYPES: BEGIN OF ty_vbap,
             matnr TYPE matnr,
             posnr TYPE posnr_va,
             matkl TYPE matkl,
             vbeln TYPE vbeln_va,
             END OF ty_vbap.
    TYPES: BEGIN OF ty_ekpo,
             ebeln TYPE ebeln,
             ebelp TYPE ebelp,
             bukrs TYPE bukrs,
             werks TYPE werks_d,
             lgort TYPE lgort_d,
             matnr TYPE matnr,
             mandt TYPE mandt,
            END OF ty_ekpo.
    DATA:t_mara TYPE TABLE OF ty_mara WITH HEADER LINE,
         t_makt TYPE TABLE OF ty_makt WITH HEADER LINE,
         t_marc TYPE TABLE OF ty_marc WITH HEADER LINE,
         t_kna1 TYPE TABLE OF ty_kna1 WITH HEADER LINE,
         t_vbap TYPE TABLE OF ty_vbap WITH HEADER LINE,
         t_ekpo TYPE TABLE OF ty_ekpo WITH HEADER LINE.
    FINAL INTERNAL TABLE *
    TYPES: BEGIN OF ty_final,
         matnr TYPE matnr,
         mtart TYPE mtart,
         meins TYPE meins,
         werks TYPE werks_d,
         maktx TYPE maktx,
         spras TYPE spras,
         vbeln TYPE vbeln_va,
         posnr TYPE posnr_va,
         matkl TYPE matkl,
         ebeln TYPE ebeln,
         ebelp TYPE ebelp,
         bukrs TYPE bukrs,
         kunnr TYPE kunnr,
         land1 TYPE land1_gp,
         name1 TYPE name1_gp,
         lgort TYPE lgort_d,
         END OF ty_final.
    DATA : t_final TYPE TABLE OF ty_final WITH HEADER LINE.
    *DATA: BEGIN OF V_matnr OCCURS 0,
    matnr LIKE mara-matnr,
    END OF t_matnr.
    DATA:
    a(32) TYPE c.
    a = 'IBT000000000000000001000000000000000050'.
    SELECTION SCREEN *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_bukrs FOR ekpo-bukrs,
                     s_kunnr FOR kna1-kunnr,
                     s_werks FOR marc-werks,
                     s_matnr FOR mara-matnr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    START OF SELECTION *
    START-OF-SELECTION.
    *USE SUBROUTINES
    *get data
      PERFORM get_data.
    *populate final table
      PERFORM populate_final_table.
    END-OF-SELECTION.
    *display output
      PERFORM display_output.
    TOP-OF-PAGE *
    TOP-OF-PAGE.
      ULINE.
      WRITE : /60 'G E N E R A L D E T A I L S' COLOR 2 INVERSE OFF.
      ULINE.
      WRITE :/ sy-vline, 'MATERIAL' COLOR 4, "12 SY-VLINE,
      13 sy-vline, 'IND SECTOR',
      28 sy-vline, 'UNITS',
      43 sy-vline, 'PLANT',
      55 sy-vline, 'MAT DESC',
      68 sy-vline, 'LANGU',
      70 sy-vline, 'SALES DOC ITEM',
      95 sy-vline, 'MAT GROUP',
      110 sy-vline, 'SALES DOC',
      125 sy-vline, 'CUST ID',
      140 sy-vline, 'NAME',
      155 sy-vline, 'COUNTRY',
      165 sy-vline, 'company code',
      205 sy-vline, 'storge loc'.
    *&      Form  GET_DATA
          text
    -->  p1        text
    <--  p2        text
    *TRY TO CLEAR AND REFRESH TABLES BEFORE SELECT
    FORM get_data .
      CLEAR t_mara.
      REFRESH t_mara.
      SELECT matnr
             mtart
             meins
             kunnr
             FROM mara
             INTO TABLE t_mara
             WHERE matnr IN s_matnr.
      IF NOT t_mara[] IS INITIAL.
        CLEAR t_marc.
        REFRESH t_marc.
        SELECT matnr
               werks
               FROM marc
               INTO TABLE t_marc
               FOR ALL ENTRIES IN t_mara
               WHERE matnr = t_mara-matnr
                     AND werks IN s_werks.
        CLEAR t_makt.
        REFRESH t_makt.
        SELECT matnr
               maktx
               spras
               FROM makt
               INTO TABLE t_makt
               FOR ALL ENTRIES IN t_mara
               WHERE matnr = t_mara-matnr
               AND spras = sy-langu.
        CLEAR t_vbap.
        REFRESH t_vbap.
        SELECT matnr
               posnr
               matkl
               vbeln
               FROM vbap
               INTO TABLE t_vbap
               FOR ALL ENTRIES IN t_mara
               WHERE matnr = t_mara-matnr.
        CLEAR t_ekpo.
        REFRESH t_ekpo.
        SELECT ebeln
               ebelp
               bukrs
               werks
               lgort
               matnr
               mandt
               FROM ekpo
               INTO TABLE t_ekpo
               FOR ALL ENTRIES IN t_mara
               WHERE matnr = t_mara-matnr
               AND werks IN s_werks.
      ENDIF.
      CLEAR t_kna1.
      REFRESH t_kna1.
      SELECT kunnr
             land1
             name1
             INTO  TABLE t_kna1
             FROM kna1.
    WHERE WERKS in s_werks.
    ENDFORM.                    " GET_DATA
    *&      Form  POPULATE_FINAL_TABLE
          text
    -->  p1        text
    <--  p2        text
    FORM populate_final_table .
    *AVOID LOOPS AND TRY  TO USE READ
      CLEAR t_final.
      REFRESH t_final.
      LOOP AT t_mara.
        MOVE t_mara-matnr TO t_final-matnr.
        MOVE t_mara-mtart TO t_final-mtart.
        MOVE t_mara-meins TO t_final-meins.
        READ TABLE t_marc WITH KEY matnr = t_mara-matnr.
        MOVE t_marc-werks TO t_final-werks.
        READ TABLE t_makt WITH KEY matnr = t_mara-matnr.
        MOVE t_makt-maktx TO t_final-maktx.
        MOVE t_makt-spras TO t_final-spras.
        READ TABLE t_vbap WITH KEY matnr = t_mara-matnr.
        MOVE t_vbap-posnr TO t_final-posnr.
        MOVE t_vbap-matkl TO t_final-matkl.
        MOVE t_vbap-vbeln TO t_final-vbeln.
        READ TABLE t_ekpo WITH KEY matnr = t_mara-matnr.
        MOVE t_ekpo-bukrs TO t_final-bukrs.
        MOVE t_ekpo-ebeln TO t_final-ebeln.
        MOVE t_ekpo-ebelp TO t_final-ebelp.
        MOVE t_ekpo-lgort TO t_final-lgort.
        READ TABLE t_kna1 WITH KEY kunnr  = t_mara-kunnr.
        MOVE t_kna1-kunnr TO t_final-kunnr.
        MOVE t_kna1-name1 TO t_final-name1.
        MOVE t_kna1-land1 TO t_final-land1.
        APPEND t_final.
        CLEAR :t_final,t_mara,t_marc,t_makt,t_ekpo,t_vbap.
      ENDLOOP.
    ENDFORM.                    " POPULATE_FINAL_TABLE
    *&      Form  DISPLAY_OUTPUT
          text
    -->  p1        text
    <--  p2        text
    FORM display_output .
      LOOP AT t_final.
        WRITE : 4 t_final-matnr,
        20 t_final-mtart,
        28 t_final-meins,
        46 t_final-werks,
        58 t_final-maktx,
        71 t_final-spras,
        78 t_final-posnr,
        100 t_final-matkl,
        115 t_final-vbeln,
        130 t_final-kunnr,
        142 t_final-name1,
        156 t_final-land1,
        168 t_final-bukrs,
        190 t_final-ebeln,
        205 t_final-ebelp,
        208 t_final-lgort.
      ENDLOOP.
    ENDFORM.                    " DISPLAY_OUTPUT

  • How to increase the performance of a report

    can any body tell me how to increase the performance of a report?////
    i have prepared a report to show the expense detail .I have used BSIS and BSAS table.
    But whenever I am executing it is facing runtime error (TIME_OUT error ).
    Moderator Message: Duplicate Post. Read my comments in your previous thread.
    Edited by: kishan P on Nov 25, 2010 1:38 PM

    Please SEARCH in SCN before posting.
    Also post performance related issues here.

  • Is there any alternative for this code to increase performance

    hi, i want alternate code for this to increase performance.
    DATA : BEGIN OF itab OCCURS 0,
                  matnr LIKE zcst-zmatnr,
                 checked TYPE i,
                 defected TYPE i,
               end of itab.
    SELECT DISTINCT zmatnr FROM zcst INTO TABLE itab WHERE
       zmatnr IN s_matnr AND
          zwerks EQ p_plant AND
          zcastpd IN s_castpd AND
          zcatg IN s_categ.
    LOOP AT itab.
        ind = sy-tabix.
    SELECT COUNT( DISTINCT zcst~zcastn )
           FROM zcst INNER JOIN zvtrans
           ON ( zcstzcastn = zvtranszcastn AND
                zcstzmatnr = zvtranszmatnr AND
                zcstzwerks = zvtranszwerks AND
                zcstgjahr  = zvtransgjahr )
           INTO itab-checked
           WHERE
               zcst~zmatnr = itab-matnr AND
               zcst~zwerks EQ p_plant AND
               zcastpd IN s_castpd AND
               zcatg IN s_categ.
    SELECT COUNT( DISTINCT zcst~zcastn )
          FROM zcst INNER JOIN zvtrans
          ON ( zcstzcastn = zvtranszcastn AND
               zcstzmatnr = zvtranszmatnr AND
               zcstzwerks = zvtranszwerks AND
               zcstgjahr  = zvtransgjahr )
          INTO itab-defected
          WHERE
              zcst~zmatnr = itab-matnr AND
              zcst~zwerks EQ p_plant AND
              zcastpd IN s_castpd AND
              zcatg IN s_categ AND
              zvtrans~zdcode <> '   '.
      MODIFY itab INDEX ind.
      ENDLOOP.
    i think, select within loop is reducing the performance
    pls reply

    Hi,
    types : BEGIN OF t_itab ,
        matnr LIKE zcst-zmatnr,
       checked TYPE i,
       defected TYPE i,
    end of t_itab.
    data : itab type table of t_itab,
             wa_itab type t_itab.
    and instead of looping as in ur code try to use for all entries and
    use nested loop.

  • Best way in using models & Increasing performance

    Hi all,
    I had some doubts in creation of model objects.
    1.How many RFCs can a model object can contain?
    2.I had a business senario where i had to use 4 Fm for performing a task.If i craete a single model object for this 4 Fun modules.Will it increase performance or else creating a model object for each fun module.will incresae the performance.
    3.Are there any good docs in SDN for Best practices or performance increasing in creation and using of model objects.please do paste the links or anyone have any docs plz send me.
    Thanks & Rgards,
    Lokesh

    HI...
    1.How many RFCs can a model object can contain?
    SAP recommonds...
    RFC Connection pools are specific to JCO Destination.
    Therefore, all deployed applications using the same model object pointing to the same JCO destination will share the SAME CONNECTION POOL.
    This fact defines both the scope of the connection management and determines the number of oncurrent application that may use the JCO destination.
    A MODEL OBJECT SHOULD CONTAIN THOSE RFMS THAT SUPPLY THE FUNCTIONALITY OF EITHER A DISCRETE BUSINESS TASK OR SOME ATOMIC SUBSET OF THE BUSINESS TASK
    -> HAVING ONE RFM PER MOEDL IS INEFFICIENT FROM A CONNECTION MANAGEMENT POINT OF VIEW.
    -> HAVING ALL YOUR RFMS IN ONE BIG MODEL OBJECT IS INEFFICIENT FROM A REUSE POINT OF VIEW
    2.I had a business senario where i had to use 4 Fm for performing a task.If i craete a single model object for this 4 Fun modules.Will it increase performance or else creating a model object for each fun module.will incresae the performance.
    As above described if the RFMs supply the functionality for a single task then put it in one model
    3.Are there any good docs in SDN for Best practices or performance increasing in creation and using of model objects.please do paste the links or anyone have any docs plz send me.
    This is described in JA310 ( Web dynpro JAVA) book. you can download it from marketplace.
    PradeeP

  • How to check the performance of a report

    plz tell me all the ways to check the performance of a report
    if u send me the step wise then it will be really helpful to me
    awaiting for u r reply

    I. Non Database Performance
    Dead Code (Program -> Check -> Extended Prog. Check) - unused subroutines appear as warnings under PERFORM/FORM interfaces. - unused variables appear as warnings under Field attributes. Transaction code is SLIN. This will also catch literals (section III below).
    When possible use MOVE instead of MOVE-CORRESPONDING (move bseg to *bseg or move t_prps[] to t_prps2[] if you want to copy entire table or t_prps to t_prps2 if you only want to copy header line.)
    Code executed more than once should be placed in a form routine.
    SORT and READ TABLE t_tab WITH KEY ... BINARY SEARCH when possible especially against non-buffered table (Data Dictionary -> Technical Info)
    SORT tables BY fields
    Avoid unnecessary moves to table header areas.
    Subroutine parameters should be typed for efficiency and to help prevent coding and runtime errors.
    II. Database Performanc
    Avoid ORDER BY unless there is index on the columns - sort internal table instead
    SELECT SINGLE when possible
    SELECT fields FROM database table INTO TABLE t_tab (an internal table) - Lengthy discussion.
    Views (inner join) are a fast way to access information from multiple tables. Be aware that the result set only includes rows that appear in both tables.
    Use subqueries when possible.
    "FOR ALL ENTRIES IN..." (outer join) are very fast but keep in the mind the special features and 3 pitfalls of using it.
    (a) Duplicates are removed from the answer set as if you had specified "SELECT DISTINCT"... So unless you intend for duplicates to be deleted include the unique key of the detail line items in your select statement. In the data dictionary (SE11) the fields belonging to the unique key are marked with an "X" in the key column.
    (b) If the "one" table (the table that appears in the clause FOR ALL ENTRIES IN) is empty, all rows in the "many" table (the table that appears in the SELECT INTO clause ) are selected. Therefore make sure you check that the "one" table has rows before issuing a select with the "FOR ALL ENTRIES IN..." clause.
    (c) If the 'one' table (the table that appears in the clause FOR ALL ENTRIES IN) is very large there is performance degradation Steven Buttiglieri created sample code to illustrate this.
    Where clause should be in order of index See example.
    This is important when there are multiple indexes for a table and you want to make sure a specific index is used. This will change when we convert from a "rules based" Oracle optimizer to a "cost based" Oracle optimizer. You should be aware of a bug in Oracle, lovingly referred to as the "3rd Column Blues". Click here for more information on indexes.
    Where clause should contain key fields in an appropriate db index or buffered tables. As long as we are using the Oracle Cost Based Optimizer, be aware fo the "Third Column Blues", an Oracle bug.
    Avoid nested SELECTs (SELECT...ENDSELECT within another SELECT...ENDSELECT). Load data in internal tables instead. See item 3 above.
    Use SQL statistical functions when possible (max, sum, ...)
    Delete all rows from a table. A where clause is mandatory. Specifying the client is the most efficient way.
    Put Check statements into where clause - caveat: Make sure that the index is still being used after you add the additional selection criteria. If the select statement goes from using an index to doing a db scan (reading each row in the database without going through an index) get it out of the where clause and go back to using "Check"!
    III. Literals
    Codes ('MD') should use contants (c_medical)
    Longer text should use text elements. Sample code is a good example because it uses the text element in conjunction with the hard coded text. This documents the text element and provides for the possibility of multi-language support.
    IV. Miscellaneous
    Use CASE statement instead of IF...ELSEIF when possible (It is only possible in equality tests)
    Nested If - encounter most likely to fail first (specific to general)
    And - encounter most likely to fail first (specific to general)
    OR's - encounter most likely to succeed first (general to specific)
    Variables should use Like when possible
    Subroutine usage - don't place decision to execute in the subroutine
    If not ( t_prps[] is initial ) (instead of describe table t_prps lines sy-tfill, if sy-tfill > 0...)
    New document types confirmed with the configuration team via MIT-ABAP mail list prior to coding a report to access the data.
    Dates need to be properly formatted using the user's default settings. For the explanation of the BDC example check out the developer's standards.
    regards,
    suryaprakash.

  • Best way to write this report

    I hope someone can help. I am fairly new to Oracle Reports.
    I need to compile a report with totals only. The problem is I need to pull the detail data in to perform fuctions on that detail data but I don't want to display the detail data, only the bottom line numbers. Each time I try this I get numerous blank pages where the detail would be.
    What is my best option if any and where can I find information on this?

    For performance your report should be based on a single query that returns only the total amounts. If you do not need to display the details, why return them? Using multi-level functions you can write a single query to return your desired totals - and rather than having the functions inside the report, you can have them on the server, further increasing performance.
    HTH,
    Troy
    I hope someone can help. I am fairly new to Oracle Reports.
    I need to compile a report with totals only. The problem is I need to pull the detail data in to perform fuctions on that detail data but I don't want to display the detail data, only the bottom line numbers. Each time I try this I get numerous blank pages where the detail would be.
    What is my best option if any and where can I find information on this?

  • How to use hints in Obiee to increase performance

    Anybody please tell me how can we use hints to increase performance of ad hoc and dashboard reports in obiee

    Hi,
    Check this,
    http://www.howtoexam.com/index.php?option=com_content&view=article&id=75%3Ausing-hints-in-obiee-rpd-and-answers&catid=790%3Acomputers-and-software&Itemid=166
    Rgds,
    Dpka

  • This report for Vendor Balance Reconcillation.......

    Hi Seniors,
    Please help me with this issue........i have to develope a New report Vendor balance Reconcillation ......Using the Standard report S_ALR_87012082 vendor balances in local currency.....it should be same like this Standard report but this Report is not Designed to give Line Items Because it has Picked up the Data only from few tables like LFA1 LFB1 LFC3.....which give Direct Balances in these tables......But i have Developed a report to Some Extent....But Finding it Difficult in Adding a Special GL Date which is Reflecting in the LFC3 Table....I have to Keep a Check Box Special GL balances in the Selection-Screen when when ever i select Special GL Balances indicator ....Date from LFC3
    should be Selected and Addred to the Final in the Internal Table....I have Written a program .......Based on GSBER And LIFNR SUBTOTALS.....I have to Add this New check box in this Slection-Screen.....this report should be same like this Standard Report....S_ALR_87012082...the Program for this Report is RFKSLD00...please tel me the logic or help me with the Modification my below Report.....If i am not clear please reply me back...
    waiting for your replys...
    Thank you...
    *& Report  ZVENDOR_BALANCES
    REPORT  ZMM_PO_CHECKLIST.
    TYPE-POOLS : SLIS.
    DATA:   it_fcat    TYPE slis_t_fieldcat_alv,
            wa_fcat    LIKE LINE OF it_fcat,
            lt_top_of_page TYPE slis_t_listheader,
            ls_layout      TYPE slis_layout_alv,
            gt_events      TYPE slis_t_event.
    TYPES : BEGIN OF TY_BSEG,
              LIFNR  TYPE BSEG-LIFNR,
              BUKRS  TYPE BSEG-BUKRS,
              BELNR  TYPE BSEG-BELNR,
              GJAHR  TYPE BSEG-GJAHR,
              SHKZG  TYPE BSEG-SHKZG,
              GSBER  TYPE BSEG-GSBER,
              DMBTR  TYPE BSEG-DMBTR,
              WRBTR  TYPE BSEG-WRBTR,
              SGTXT  TYPE BSEG-SGTXT,
           buzei TYPE bseg-buzei,
            buzid TYPE bseg-buzid,
            augdt TYPE bseg-augdt,
            augcp TYPE bseg-augcp,
            augbl TYPE bseg-augbl,
            bschl TYPE bseg-bschl,
            koart TYPE bseg-koart,
            umskz TYPE bseg-umskz,
            zuonr TYPE bseg-zuonr,
            saknr TYPE bseg-saknr,
            hkont TYPE bseg-hkont,
            END OF TY_BSEG,
            BEGIN OF TY_LFA1,
              LIFNR TYPE LFA1-LIFNR,
              LAND1 TYPE LFA1-LAND1,
              NAME1 TYPE LFA1-NAME1,
            END OF TY_LFA1,
            BEGIN OF TY_LFC1,
              LIFNR TYPE LFC1-LIFNR,
              BUKRS TYPE LFC1-BUKRS,
              GJAHR TYPE LFC1-GJAHR,
              UMSAV TYPE LFC1-UMSAV,
            END OF TY_LFC1,
            BEGIN OF TY_BKPF,
              BUKRS TYPE BKPF-BUKRS,
              BELNR TYPE BKPF-BELNR,
              GJAHR TYPE BKPF-GJAHR,
              BLart type bkpf-blart,
              BUDAT TYPE BKPF-BUDAT,
                      bldat TYPE bkpf-bldat,
                      monat TYPE bkpf-monat,
                      usnam TYPE bkpf-usnam,
                      xblnr TYPE bkpf-xblnr,
            END OF TY_BKPF,
         BEGIN OF it_bsak,
            bukrs TYPE bsak-bukrs,
            lifnr TYPE bsak-lifnr,
            umskz TYPE bsak-umskz,
            augdt TYPE bsak-augdt,
            augbl TYPE bsak-augbl,
            zuonr TYPE bsak-zuonr,
            gjahr TYPE bsak-gjahr,
            belnr TYPE bsak-belnr,
            buzei TYPE bsak-buzei,
            budat TYPE bsak-budat,
            bldat TYPE bsak-bldat,
            xblnr TYPE bsak-xblnr,
            blart TYPE bsak-blart,
            monat TYPE bsak-monat,
            bschl TYPE bsak-bschl,
            shkzg TYPE bsak-shkzg,
            gsber TYPE bsak-gsber,
            dmbtr TYPE bsak-dmbtr,
            wrbtr TYPE bsak-wrbtr,
            sgtxt TYPE bsak-sgtxt,
            saknr TYPE bsak-saknr,
            hkont TYPE bsak-hkont,
          END OF it_bsak,
            BEGIN OF it_skat,
                  spras TYPE skat-spras,
                  saknr TYPE skat-saknr,
                  txt20 TYPE skat-txt20,
                  txt50 TYPE skat-txt50,
            END OF it_skat,
          BEGIN OF TY_ITAB,
              GSBER  TYPE BSEG-GSBER,
              LIFNR  TYPE BSEG-LIFNR,
              BUKRS  TYPE BSEG-BUKRS,
              BELNR  TYPE BSEG-BELNR,
              GJAHR  TYPE BSEG-GJAHR,
              SHKZG  TYPE BSEG-SHKZG,
             GSBER  TYPE BSEG-GSBER,
              DMBTR  TYPE BSEG-DMBTR,
              WRBTR  TYPE BSEG-WRBTR,
              SGTXT  TYPE BSEG-SGTXT,
           buzei TYPE bseg-buzei,
            buzid TYPE bseg-buzid,
            augdt TYPE bseg-augdt,
            augcp TYPE bseg-augcp,
            augbl TYPE bseg-augbl,
            bschl TYPE bseg-bschl,
            koart TYPE bseg-koart,
            umskz TYPE bseg-umskz,
            zuonr TYPE bseg-zuonr,
            saknr TYPE bseg-saknr,
            hkont TYPE bseg-hkont,
             LIFNR TYPE LFA1-LIFNR,
              LAND1 TYPE LFA1-LAND1,
              NAME1 TYPE LFA1-NAME1,
              DMBTR_H  TYPE BSEG-WRBTR,
              DMBTR_S  TYPE BSEG-WRBTR,
              DH TYPE BSEG-WRBTR,
              DS TYPE BSEG-WRBTR,
              HS   TYPE BSEG-WRBTR,
              BAL  TYPE BSEG-WRBTR,
              FLAG TYPE C,
             LIFNR TYPE LFC1-LIFNR,
             BUKRS TYPE LFC1-BUKRS,
             GJAHR TYPE LFC1-GJAHR,
              UMSAV TYPE LFC1-UMSAV,
              UM(15) TYPE P DECIMALS 2,
             BUKRS TYPE BKPF-BUKRS,
             BELNR TYPE BKPF-BELNR,
             GJAHR TYPE BKPF-GJAHR,
              BLart type bkpf-blart,
              BUDAT TYPE BKPF-BUDAT,
                     bldat TYPE bkpf-bldat,
                      monat TYPE bkpf-monat,
                      usnam TYPE bkpf-usnam,
                      xblnr TYPE bkpf-xblnr,
                  spras TYPE skat-spras,
                 saknr TYPE skat-saknr,
                  txt20 TYPE skat-txt20,
                  txt50 TYPE skat-txt50,
               LINE_COLOR(4) TYPE C,
               LINE_CTR(4) TYPE C,
            END OF TY_ITAB,
            BEGIN OF TY_TEMP,
              LIFNR  TYPE BSEG-LIFNR,
                        GSBER  TYPE BSEG-GSBER,
              BUKRS  TYPE BSEG-BUKRS,
              BELNR  TYPE BSEG-BELNR,
              GJAHR  TYPE BSEG-GJAHR,
              SHKZG  TYPE BSEG-SHKZG,
             GSBER  TYPE BSEG-GSBER,
              DMBTR  TYPE BSEG-DMBTR,
              WRBTR  TYPE BSEG-WRBTR,
              SGTXT  TYPE BSEG-SGTXT,
           buzei TYPE bseg-buzei,
            buzid TYPE bseg-buzid,
            augdt TYPE bseg-augdt,
            augcp TYPE bseg-augcp,
            augbl TYPE bseg-augbl,
            bschl TYPE bseg-bschl,
            koart TYPE bseg-koart,
            umskz TYPE bseg-umskz,
            zuonr TYPE bseg-zuonr,
            saknr TYPE bseg-saknr,
            hkont TYPE bseg-hkont,
             LIFNR TYPE LFA1-LIFNR,
              LAND1 TYPE LFA1-LAND1,
              NAME1 TYPE LFA1-NAME1,
             LIFNR TYPE LFC1-LIFNR,
             BUKRS TYPE LFC1-BUKRS,
             GJAHR TYPE LFC1-GJAHR,
              UMSAV TYPE LFC1-UMSAV,
              DMBTR_H  TYPE BSEG-WRBTR,
              DMBTR_S  TYPE BSEG-WRBTR,
              HS       TYPE BSEG-WRBTR,
              BAL      TYPE BSEG-WRBTR,
              FLAG TYPE C,
             FLAG TYPE C,
             BUKRS TYPE BKPF-BUKRS,
             BELNR TYPE BKPF-BELNR,
             GJAHR TYPE BKPF-GJAHR,
              BLart type bkpf-blart,
              BUDAT TYPE BKPF-BUDAT,
                      bldat TYPE bkpf-bldat,
                      monat TYPE bkpf-monat,
                      usnam TYPE bkpf-usnam,
                      xblnr TYPE bkpf-xblnr,
           bukrs TYPE bsak-bukrs,
           lifnr TYPE bsak-lifnr,
           umskz TYPE bsak-umskz,
           augdt TYPE bsak-augdt,
           augbl TYPE bsak-augbl,
           zuonr TYPE bsak-zuonr,
           gjahr TYPE bsak-gjahr,
           belnr TYPE bsak-belnr,
           buzei TYPE bsak-buzei,
           budat TYPE bsak-budat,
           bldat TYPE bsak-bldat,
           xblnr TYPE bsak-xblnr,
           blart TYPE bsak-blart,
           monat TYPE bsak-monat,
           bschl TYPE bsak-bschl,
           shkzg TYPE bsak-shkzg,
           gsber TYPE bsak-gsber,
           dmbtr TYPE bsak-dmbtr,
           wrbtr TYPE bsak-wrbtr,
           sgtxt TYPE bsak-sgtxt,
           saknr TYPE bsak-saknr,
           hkont TYPE bsak-hkont,
                  spras TYPE skat-spras,
                 saknr TYPE skat-saknr,
                  txt20 TYPE skat-txt20,
                  txt50 TYPE skat-txt50,
               LINE_COLOR(4) TYPE C,
               LINE_CTR(4) TYPE C,
            END OF TY_TEMP.
    DATA : IT_BSEG TYPE STANDARD TABLE OF TY_BSEG WITH HEADER LINE,
           IT_LFA1 TYPE STANDARD TABLE OF TY_LFA1 WITH HEADER LINE,
           IT_LFC1 TYPE STANDARD TABLE OF TY_LFC1 WITH HEADER LINE,
           IT_BKPF TYPE STANDARD TABLE OF TY_BKPF WITH HEADER LINE,
          IT_BSIK TYPE STANDARD TABLE OF TY_BSIK WITH HEADER LINE,
          IT_BSAK TYPE STANDARD TABLE OF TY_BSAK WITH HEADER LINE,
          IT_BSIP TYPE STANDARD TABLE OF TY_BSIP WITH HEADER LINE,
           IT_SKAT TYPE STANDARD TABLE OF IT_SKAT WITH HEADER LINE,
           IT_ITAB TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE,
           IT_TEMP TYPE STANDARD TABLE OF TY_TEMP WITH HEADER LINE.
           TABLES : BSEG, LFA1, LFC1, BKPF ,SKAT.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE T001.
    SELECT-OPTIONS: Vendor FOR BSEG-LIFNR OBLIGATORY.
    PARAMETERS : CoCd LIKE BSEG-BUKRS  OBLIGATORY.
    PARAMETERS : Fiscal LIKE BSEG-GJAHR OBLIGATORY.
    SELECT-OPTIONS : Period FOR BKPF-MONAT .
    *SELECT-OPTIONS : b_monate for rfsdo-allgbmon          "Berichtsperioden
              no-extension,
    *SELECT-OPTIONS: SO_LIFNR FOR BSEG-LIFNR.
                   SO_BELNR FOR BSEG-BELNR.
    SELECTION-SCREEN END OF BLOCK B1.
    PERFORM DATA_RETRIVE.
    *PERFORM SUB_MOVE_DATA.
    **PERFORM SUB_FETCH_EXTRA_DATA.
    **PERFORM SUB_MOVE_EXTRA_DATA.
    PERFORM SUB_CALC.
    PERFORM SUB_FIELDCAT.
    PERFORM SUB_DISPLAY.
    *&      Form  DATA_RETRIVE
          text
    -->  p1        text
    <--  p2        text
    form DATA_RETRIVE .
    SELECT LIFNR BUKRS BELNR GJAHR SHKZG GSBER DMBTR WRBTR SGTXT BUZEI
           BUZID AUGDT AUGCP AUGBL BSCHL KOART UMSKZ ZUONR SAKNR HKONT
           FROM BSEG INTO TABLE IT_BSEG
           WHERE LIFNR IN vendor AND BUKRS = CoCd AND GJAHR = Fiscal.
    IF NOT IT_BSEG[] IS INITIAL.
    SELECT LIFNR LAND1 NAME1
           FROM LFA1 INTO TABLE IT_LFA1 FOR ALL ENTRIES IN IT_BSEG
           WHERE LIFNR = IT_BSEG-LIFNR.
    ENDIF.
    IF NOT IT_BSEG[] IS INITIAL.
    SELECT LIFNR BUKRS GJAHR UMSAV
           FROM LFC1 INTO TABLE IT_LFC1 FOR ALL ENTRIES IN IT_BSEG
           WHERE LIFNR = IT_BSEG-LIFNR AND BUKRS = IT_BSEG-BUKRS AND GJAHR = IT_BSEG-GJAHR.
    ENDIF.
    IF NOT IT_BSEG[] IS INITIAL.
    SELECT BUKRS BELNR GJAHR BLART BUDAT BLDAT MONAT USNAM XBLNR
           FROM BKPF INTO TABLE IT_BKPF FOR ALL ENTRIES IN IT_BSEG
           WHERE MONAT IN Period AND BUKRS = IT_BSEG-BUKRS AND GJAHR = IT_BSEG-GJAHR AND BELNR = IT_BSEG-BELNR.
    ENDIF.
    LOOP AT IT_BSEG.
    IT_ITAB-LIFNR = IT_BSEG-LIFNR.
    IT_ITAB-BUKRS = IT_BSEG-BUKRS.
    IT_ITAB-BELNR = IT_BSEG-BELNR.
    IT_ITAB-GJAHR = IT_BSEG-GJAHR.
    IT_ITAB-SHKZG = IT_BSEG-SHKZG.
    IT_ITAB-GSBER = IT_BSEG-GSBER.
    IT_ITAB-DMBTR = IT_BSEG-DMBTR.
    IT_ITAB-WRBTR = IT_BSEG-WRBTR.
    IT_ITAB-SGTXT = IT_BSEG-SGTXT.
    IT_ITAB-BUZEI = IT_BSEG-BUZEI.
    IT_ITAB-BUZID = IT_BSEG-BUZID.
    IT_ITAB-AUGDT = IT_BSEG-AUGDT.
    IT_ITAB-AUGCP = IT_BSEG-AUGCP.
    IT_ITAB-AUGBL = IT_BSEG-AUGBL.
    IT_ITAB-BSCHL = IT_BSEG-BSCHL.
    IT_ITAB-KOART = IT_BSEG-KOART.
    IT_ITAB-UMSKZ = IT_BSEG-UMSKZ.
    IT_ITAB-ZUONR = IT_BSEG-ZUONR.
    IT_ITAB-SAKNR = IT_BSEG-SAKNR.
    IT_ITAB-HKONT = IT_BSEG-HKONT.
    READ TABLE IT_LFA1 WITH KEY LIFNR = IT_ITAB-LIFNR.
      IF SY-SUBRC = 0.
      IT_ITAB-LAND1 = IT_LFA1-LAND1.
      IT_ITAB-NAME1 = IT_LFA1-NAME1.
      ENDIF.
    READ TABLE IT_LFC1 WITH KEY LIFNR = IT_ITAB-LIFNR
                                BUKRS = IT_ITAB-BUKRS
                                GJAHR = IT_ITAB-GJAHR
                                BINARY SEARCH.
      IF SY-SUBRC = 0.
      IT_ITAB-UMSAV = IT_LFC1-UMSAV.
      ENDIF.
    READ TABLE IT_BKPF WITH KEY BUKRS = IT_ITAB-BUKRS
                                BELNR = IT_ITAB-BELNR
                                GJAHR = IT_ITAB-GJAHR.
    IF SY-SUBRC = 0.
    IT_ITAB-BLART = IT_BKPF-BLART.
    IT_ITAB-BUDAT = IT_BKPF-BUDAT.
    IT_ITAB-BLDAT = IT_BKPF-BLDAT.
    IT_ITAB-MONAT = IT_BKPF-MONAT.
    IT_ITAB-USNAM = IT_BKPF-USNAM.
    IT_ITAB-XBLNR = IT_BKPF-XBLNR.
    ENDIF.
    APPEND IT_ITAB.
    CLEAR  IT_ITAB.
    ENDLOOP.
    endform.                    " DATA_RETRIVE
    *&      Form  SUB_CALC
          text
    -->  p1        text
    <--  p2        text
    form SUB_CALC .
    *SORT IT_ITAB BY LIFNR GSBER GJAHR.
    *LOOP AT IT_ITAB.
    *IF IT_ITAB-SHKZG = 'S'.
      IT_ITAB-DMBTR = IT_ITAB-DMBTR * ( -1 ).
    *ENDIF.
    *CLEAR IT_ITAB-DMBTR_S.
    *MODIFY IT_ITAB.
    *ENDLOOP.
    *LOOP AT IT_ITAB.
    *IT_ITAB-BAL = IT_ITAB-UMSAV + IT_ITAB-DMBTR.
    *MODIFY IT_ITAB.
    *CLEAR IT_ITAB.
    *ENDLOOP.
    *LOOP AT IT_ITAB.
      IF IT_ITAB-SHKZG = 'S'.
      IT_ITAB-DMBTR = IT_ITAB-DMBTR * ( -1 ).
      ENDIF.
      MODIFY IT_ITAB.
    *ENDLOOP.
      LOOP AT IT_ITAB.
        IF IT_ITAB-SHKZG = 'S'.
            IT_ITAB-DMBTR_S  = IT_ITAB-DMBTR .
        ELSE.
        IF IT_ITAB-SHKZG = 'H'.
          IT_ITAB-DMBTR_H  = IT_ITAB-DMBTR.
          ENDIF.
        ENDIF.
       IT_ITAB-DMBTR = ''.
        MODIFY IT_ITAB INDEX SY-TABIX TRANSPORTING DMBTR_H DMBTR_S DMBTR.
    "VAR.
        CLEAR IT_ITAB.
      ENDLOOP.
    *MOVE CORRESPONDING IT_LFC1-UMSAV = IT_ITAB-UMSAV.
      SORT IT_ITAB BY LIFNR GSBER.
    LOOP AT IT_ITAB.
         IT_ITAB-DMBTR_H = IT_ITAB-DMBTR_H.
         IT_ITAB-DMBTR_S = IT_ITAB-DMBTR_S.
         IT_ITAB-DH = IT_ITAB-DMBTR_H.
         IT_ITAB-DS = IT_ITAB-DMBTR_S.
           IT_ITAB-FLAG = 'X'.
           IT_ITAB-CTR = 'X'.
           IT_ITAB-HS = IT_ITAB-DMBTR_H - IT_ITAB-DMBTR_S.
           IT_ITAB-BAL = IT_ITAB-UMSAV + IT_ITAB-HS.
         MODIFY IT_ITAB INDEX SY-TABIX TRANSPORTING DMBTR_H DMBTR_S HS
                                                    FLAG BAL.
      CLEAR IT_ITAB.
    ENDLOOP.
    *LOOP AT IT_ITAB.
    **IF IT_ITAB-MONAT = ''.
      DELETE IT_ITAB[] WHERE MONAT = ''.
    *MODIFY IT_ITAB.
    *ENDLOOP.
    LOOP AT IT_ITAB.
       AT END OF GSBER.
         SUM.
         IT_ITAB-DMBTR_H = IT_ITAB-DMBTR_H.
         IT_ITAB-DMBTR_S = IT_ITAB-DMBTR_S.
         IT_ITAB-DH = IT_ITAB-DMBTR_H.
         IT_ITAB-DS = IT_ITAB-DMBTR_S.
           IT_ITAB-FLAG = 'X'.
           IT_ITAB-CTR = 'X'.
           IT_ITAB-DMBTR_H = IT_ITAB-DMBTR_H.
           IT_ITAB-DMBTR_S = IT_ITAB-DMBTR_S.
           IT_ITAB-HS   = IT_ITAB-DMBTR_S - IT_ITAB-DMBTR_H.
           IT_ITAB-BAL  = IT_ITAB-UMSAV - IT_ITAB-HS.
         MODIFY IT_ITAB INDEX SY-TABIX TRANSPORTING DMBTR_H DMBTR_S  HS
                                                    FLAG BAL.
       ENDAT.
      CLEAR IT_ITAB.
    ENDLOOP.
      LOOP AT IT_ITAB.
        AT END OF GSBER.
          SUM.
          IT_ITAB-DMBTR_H = IT_ITAB-DMBTR_H.
          IT_ITAB-DMBTR_S = IT_ITAB-DMBTR_S.
          IT_ITAB-DH = IT_ITAB-DMBTR_H.
          IT_ITAB-DS = IT_ITAB-DMBTR_S.
            IT_ITAB-FLAG = 'X'.
           IT_ITAB-CTR = 'X'.
            IT_ITAB-DMBTR_H = IT_ITAB-DMBTR_H.
            IT_ITAB-DMBTR_S = IT_ITAB-DMBTR_S.
            IT_ITAB-BAL = IT_ITAB-UMSAV + ( IT_ITAB-DMBTR_H - IT_ITAB-DMBTR_S ).
          MODIFY IT_ITAB INDEX SY-TABIX TRANSPORTING DMBTR_H DMBTR_S DH DS
                                                     FLAG BAL.
        ENDAT.
       CLEAR IT_ITAB.
      ENDLOOP.
    DELETE IT_ITAB[] WHERE FLAG <> 'X'.
    SORT IT_ITAB BY LIFNR GSBER.
    LOOP AT IT_ITAB.
       MOVE-CORRESPONDING IT_ITAB TO IT_TEMP.
       APPEND IT_TEMP.
    ENDLOOP.
    REFRESH IT_ITAB.
    SORT IT_TEMP BY LIFNR GSBER.
    LOOP AT IT_TEMP.
       MOVE-CORRESPONDING IT_TEMP TO IT_ITAB.
       APPEND IT_ITAB.
       CLEAR IT_ITAB.
       AT END OF LIFNR.
         SUM.
         IT_TEMP-FLAG = ''.
         MODIFY IT_TEMP INDEX SY-TABIX TRANSPORTING DMBTR_H DMBTR_S FLAG.
         MOVE-CORRESPONDING IT_ITEMP TO IT_ITAB.
         IT_ITAB-LIFNR = ''.
         IT_ITAB-NAME1 = ''.
         IT_ITAB-BELNR = ''.
         IT_ITAB-BUKRS = ''.
         IT_ITAB-GJAHR = ''.
         IT_ITAB-GSBER = ''.
         IT_ITAB-UMSAV = '0000'.
         IT_ITAB-DMBTR_H = IT_TEMP-DMBTR_H.
         IT_ITAB-DMBTR_S = IT_TEMP-DMBTR_S.
         IT_ITAB-BAL = IT_TEMP-DMBTR_H - IT_TEMP-DMBTR_S.
         IT_ITAB-FLAG = 'Y'.
         IT_ItAB-CTR = IT_TEMO-CTR.
         APPEND IT_ITAB.
       ENDAT.
       IF IT_ITAB-FLAG = 'Y'.
         it_itab-line_color = 'C600'.
         MODIFY IT_ITAB.
       ENDIF.
       CLEAR IT_TEMP.
    ENDLOOP.
    LOOP AT IT_ITAB WHERE FLAG = 'Y'.
         it_itab-line_color = 'C602'.
         MODIFY IT_ITAB INDEX SY-TABIX.
         CLEAR IT_ITAB.
    ENDLOOP.
    loop at it_itab WHERE FLAG  = ''.
         it_itab-line_color = 'C103'.
         IT_ITAB-LINE_CTR = 'C103'.
         MODIFY IT_ITAB INDEX SY-TABIX.
         CLEAR IT_ITAB.
    ENDLOOP.
    PERFORM SUB_CALC_1.
    endform.                    " SUB_CALC
    *&      Form  SUB_FIELDCAT
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_FIELDCAT .
      WA_FCAT-FIELDNAME = 'LIFNR'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'Vendor No'. "'VENDOR NAME'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-FIELDNAME = 'NAME1'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'Vendor Name'. "'VENDOR NAME'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
    WA_FCAT-FIELDNAME = 'BELNR'.
    WA_FCAT-TABNAME = 'IT_ITAB'.
    WA_FCAT-SELTEXT_M = 'SAP Document No'. "'DOC NUMBER'.
    APPEND WA_FCAT TO IT_FCAT.
    CLEAR WA_FCAT.
    WA_FCAT-FIELDNAME = 'BLDAT'.
    WA_FCAT-TABNAME = 'IT_ITAB'.
    WA_FCAT-SELTEXT_M = 'Doc Date'. "'FISCAL YEAR'.
    APPEND WA_FCAT TO IT_FCAT.
    CLEAR wa_fcat.
      WA_FCAT-FIELDNAME = 'GSBER'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'BusA'. "'BUSINESS AREA'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-FIELDNAME = 'UMSAV'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'Balance Carry Forward'. "'BAL  CARRIED FORWARD'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-FIELDNAME = 'FLAG'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'FLAG'. "'DOC NUMBER'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
    WA_FCAT-FIELDNAME = 'SHKZG'.
    WA_FCAT-TABNAME = 'IT_ITAB'.
    WA_FCAT-SELTEXT_M = 'SHKZG'. "'DOC NUMBER'.
    APPEND WA_FCAT TO IT_FCAT.
    CLEAR WA_FCAT.
      WA_FCAT-FIELDNAME = 'DMBTR_S'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'Credit'. "'DOC NUMBER'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-FIELDNAME = 'DMBTR_H'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'Debit'. "'DOC NUMBER'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
      WA_FCAT-FIELDNAME = 'MONAT'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'PERIOD'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
    WA_FCAT-FIELDNAME = 'DH'.
    WA_FCAT-TABNAME = 'IT_ITAB'.
    WA_FCAT-SELTEXT_M = 'DH'. "'DOC NUMBER'.
    APPEND WA_FCAT TO IT_FCAT.
    CLEAR WA_FCAT.
    WA_FCAT-FIELDNAME = 'DS'.
    WA_FCAT-TABNAME = 'IT_ITAB'.
    WA_FCAT-SELTEXT_M = 'DS'. "'DOC NUMBER'.
    APPEND WA_FCAT TO IT_FCAT.
    CLEAR WA_FCAT.
      WA_FCAT-FIELDNAME = 'BAL'.
      WA_FCAT-TABNAME = 'IT_ITAB'.
      WA_FCAT-SELTEXT_M = 'Accumlated Bal'.
      APPEND WA_FCAT TO IT_FCAT.
      CLEAR WA_FCAT.
    WA_FCAT-FIELDNAME = 'SGTXT'.
    WA_FCAT-TABNAME = 'IT_ITAB'.
    WA_FCAT-SELTEXT_M = 'Text'. "'DOC NUMBER'.
    APPEND WA_FCAT TO IT_FCAT.
    CLEAR WA_FCAT.
      ls_layout-info_fieldname = 'LINE_COLOR'.
    ENDFORM.                    " SUB_FIELDCAT
    *&      Form  SUB_DISPLAY
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_DISPLAY .
      IF NOT IT_ITAB[] IS INITIAL.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = 'SY-REPID'
            IT_FIELDCAT        = IT_FCAT
            I_SAVE             = 'A'
            is_layout          = ls_layout
          TABLES
            T_OUTTAB           = IT_ITAB
          EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.
        IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
    ENDFORM.                    " SUB_DISPLAY
    *&      Form  SUB_CALC_1
          text
    -->  p1        text
    <--  p2        text
    FORM SUB_CALC_1 .
      LOOP AT IT_ITAB WHERE FLAG = 'Y'.
          it_itab-line_color = 'C603'.
          MODIFY IT_ITAB INDEX SY-TABIX.
          CLEAR IT_ITAB.
      ENDLOOP.
    ENDFORM.                    " SUB_CALC_1

    This is the Report which i am trying to do....please help me with this Report....
    *& Report  ZVENDOR_RECONCILLATION
    REPORT  ZVENDOR_RECONCILLATION.
    *ALV
    TYPE-POOLS: SLIS.
    *TYPE-POOLS icon.
    DATA: It_SORT TYPE SLIS_T_SORTINFO_ALV ."WITH HEADER LINE.
    DATA: TOP TYPE slis_t_listheader,
          END TYPE slis_t_listheader,
          EVENTS TYPE slis_t_event.
    DATA : NAME1 LIKE T001W-NAME1,
          WERKS LIKE T001W-WERKS  .
    DATA : T_KEY TYPE SLIS_KEYINFO_ALV.
    DATA : FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          LAYOUT TYPE SLIS_LAYOUT_ALV OCCURS 1 WITH HEADER LINE ,
          LCAT TYPE SLIS_FIELDCAT_ALV.
    TABLES : BSAK , BSIK , LFC1 , LFC3 , LFA1.
    *INTERNAL TABLE
    DATA: BEGIN OF sd_bsak,
            bukrs TYPE bsak-bukrs,
            lifnr TYPE bsak-lifnr,
            umsks TYPE bsak-umsks,
            umskz TYPE bsak-umskz,
            augdt TYPE bsak-augdt,
            augbl TYPE bsak-augbl,
            zuonr TYPE bsak-zuonr,
            gjahr TYPE bsak-gjahr,
            belnr TYPE bsak-belnr,
            buzei TYPE bsak-buzei,
            budat TYPE bsak-budat,
            bldat TYPE bsak-bldat,
            xblnr TYPE bsak-xblnr,
            blart TYPE bsak-blart,
            monat TYPE bsak-monat,
            bschl TYPE bsak-bschl,
            zumsk TYPE bsak-zumsk,
            shkzg TYPE bsak-shkzg,
            gsber TYPE bsak-gsber,
            dmbtr TYPE bsak-dmbtr,
            wrbtr TYPE bsak-wrbtr,
            sgtxt TYPE bsak-sgtxt,
            saknr TYPE bsak-saknr,
            hkont TYPE bsak-hkont,
          END OF sd_bsak.
    DATA: BEGIN OF sd_bsik,
            bukrs TYPE bsik-bukrs,
            lifnr TYPE bsik-lifnr,
            umsks TYPE bsik-umsks,
            umskz TYPE bsik-umskz,
            augdt TYPE bsik-augdt,
            augbl TYPE bsik-augbl,
            zuonr TYPE bsik-zuonr,
            gjahr TYPE bsik-gjahr,
            belnr TYPE bsik-belnr,
            buzei TYPE bsik-buzei,
            budat TYPE bsik-budat,
            bldat TYPE bsik-bldat,
            xblnr TYPE bsik-xblnr,
            blart TYPE bsik-blart,
            monat TYPE bsik-monat,
            bschl TYPE bsik-bschl,
            zumsk TYPE bsik-zumsk,
            shkzg TYPE bsik-shkzg,
            gsber TYPE bsik-gsber,
            dmbtr TYPE bsik-dmbtr,
            wrbtr TYPE bsik-wrbtr,
            sgtxt TYPE bsik-sgtxt,
            saknr TYPE bsik-saknr,
            hkont TYPE bsik-hkont,
            zlsch TYPE bsik-zlsch,
          END OF sd_bsik.
    DATA: BEGIN OF it_lfa1,
            lifnr TYPE lfa1-lifnr,
            name1 TYPE lfa1-name1,
          END OF it_lfa1.
    DATA: BEGIN OF sd_lfc1,
            lifnr TYPE lfc1-lifnr,
            bukrs TYPE lfc1-bukrs,
            gjahr TYPE lfc1-gjahr,
            erdat TYPE lfc1-erdat,
            usnam TYPE lfc1-usnam,
            umsav TYPE lfc1-umsav,
          END OF sd_lfc1.
    DATA: BEGIN OF sd_lfc3,
            lifnr TYPE lfc3-lifnr,
            bukrs TYPE lfc3-bukrs,
            gjahr TYPE lfc3-gjahr,
            shbkz TYPE lfc3-shbkz,
            saldv TYPE lfc3-saldv,
            solll TYPE lfc3-solll,
            habnl TYPE lfc3-habnl,
          END OF sd_lfc3.
    *FINAL INTERNAL TABLE DECLARATION
    DATA: BEGIN OF IT_FINAL,
            gsber TYPE bsak-gsber,
            bukrs TYPE bsak-bukrs,
            lifnr TYPE bsak-lifnr,
            umsks TYPE bsak-umsks,
            umskz TYPE bsak-umskz,
            augdt TYPE bsak-augdt,
            augbl TYPE bsak-augbl,
            zuonr TYPE bsak-zuonr,
            gjahr TYPE bsak-gjahr,
            belnr TYPE bsak-belnr,
            buzei TYPE bsak-buzei,
            budat TYPE bsak-budat,
            bldat TYPE bsak-bldat,
            xblnr TYPE bsak-xblnr,
            blart TYPE bsak-blart,
            monat TYPE bsak-monat,
            bschl TYPE bsak-bschl,
            zumsk TYPE bsak-zumsk,
            shkzg TYPE bsak-shkzg,
           gsber TYPE bsak-gsber,
            dmbtr TYPE bsak-dmbtr,
            wrbtr TYPE bsak-wrbtr,
            sgtxt TYPE bsak-sgtxt,
            saknr TYPE bsak-saknr,
            hkont TYPE bsak-hkont,
            DMBTR_S  TYPE BSAK-DMBTR,
            DMBTR_H  TYPE BSAK-DMBTR,
            DS       TYPE P DECIMALS 2,
            DH       TYPE P DECIMALS 2,
            SUB      TYPE P DECIMALS 2,
            ADD      TYPE P DECIMALS 2,
            BAL      TYPE P DECIMALS 2,
           lifnr TYPE bsik-lifnr,
           umsks TYPE bsik-umsks,
           umskz TYPE bsik-umskz,
           augdt TYPE bsik-augdt,
           augbl TYPE bsik-augbl,
           zuonr TYPE bsik-zuonr,
           gjahr TYPE bsik-gjahr,
           belnr TYPE bsik-belnr,
           buzei TYPE bsik-buzei,
           budat TYPE bsik-budat,
           bldat TYPE bsik-bldat,
           xblnr TYPE bsik-xblnr,
           blart TYPE bsik-blart,
           monat TYPE bsik-monat,
           bschl TYPE bsik-bschl,
           zumsk TYPE bsik-zumsk,
           shkzg TYPE bsik-shkzg,
           gsber TYPE bsik-gsber,
           dmbtr TYPE bsik-dmbtr,
           wrbtr TYPE bsik-wrbtr,
           sgtxt TYPE bsik-sgtxt,
           saknr TYPE bsik-saknr,
           hkont TYPE bsik-hkont,
            zlsch TYPE bsik-zlsch,
                   lifnr TYPE lfa1-lifnr,
            name1 TYPE lfa1-name1,
                   lifnr TYPE lfc1-lifnr,
           bukrs TYPE lfc1-bukrs,
           gjahr TYPE lfc1-gjahr,
            erdat TYPE lfc1-erdat,
            usnam TYPE lfc1-usnam,
            umsav TYPE lfc1-umsav,
                   lifnr TYPE lfc3-lifnr,
           bukrs TYPE lfc3-bukrs,
           gjahr TYPE lfc3-gjahr,
            shbkz TYPE lfc3-shbkz,
            saldv TYPE lfc3-saldv,
            solll TYPE lfc3-solll,
            habnl TYPE lfc3-habnl,
    END OF IT_FINAL.
    DATA: BEGIN OF SD_FINAL,
            lifnr TYPE bsak-lifnr,
            bukrs TYPE bsak-bukrs,
           lifnr TYPE bsak-lifnr,
            umsks TYPE bsak-umsks,
            umskz TYPE bsak-umskz,
            augdt TYPE bsak-augdt,
            augbl TYPE bsak-augbl,
            zuonr TYPE bsak-zuonr,
            gjahr TYPE bsak-gjahr,
            belnr TYPE bsak-belnr,
            buzei TYPE bsak-buzei,
            budat TYPE bsak-budat,
            bldat TYPE bsak-bldat,
            xblnr TYPE bsak-xblnr,
            blart TYPE bsak-blart,
            monat TYPE bsak-monat,
            bschl TYPE bsak-bschl,
            zumsk TYPE bsak-zumsk,
            shkzg TYPE bsak-shkzg,
            gsber TYPE bsak-gsber,
            dmbtr TYPE bsak-dmbtr,
            wrbtr TYPE bsak-wrbtr,
            sgtxt TYPE bsak-sgtxt,
            saknr TYPE bsak-saknr,
            hkont TYPE bsak-hkont,
                   bukrs TYPE bsik-bukrs,
           lifnr TYPE bsik-lifnr,
           umsks TYPE bsik-umsks,
           umskz TYPE bsik-umskz,
           augdt TYPE bsik-augdt,
           augbl TYPE bsik-augbl,
           zuonr TYPE bsik-zuonr,
           gjahr TYPE bsik-gjahr,
           belnr TYPE bsik-belnr,
           buzei TYPE bsik-buzei,
           budat TYPE bsik-budat,
           bldat TYPE bsik-bldat,
           xblnr TYPE bsik-xblnr,
           blart TYPE bsik-blart,
           monat TYPE bsik-monat,
           bschl TYPE bsik-bschl,
           zumsk TYPE bsik-zumsk,
           shkzg TYPE bsik-shkzg,
           gsber TYPE bsik-gsber,
           dmbtr TYPE bsik-dmbtr,
           wrbtr TYPE bsik-wrbtr,
           sgtxt TYPE bsik-sgtxt,
           saknr TYPE bsik-saknr,
           hkont TYPE bsik-hkont,
            zlsch TYPE bsik-zlsch,
                   lifnr TYPE lfa1-lifnr,
            name1 TYPE lfa1-name1,
                   lifnr TYPE lfc1-lifnr,
           bukrs TYPE lfc1-bukrs,
           gjahr TYPE lfc1-gjahr,
            erdat TYPE lfc1-erdat,
            usnam TYPE lfc1-usnam,
            umsav TYPE lfc1-umsav,
                   lifnr TYPE lfc3-lifnr,
           bukrs TYPE lfc3-bukrs,
           gjahr TYPE lfc3-gjahr,
            shbkz TYPE lfc3-shbkz,
            saldv TYPE lfc3-saldv,
            solll TYPE lfc3-solll,
            habnl TYPE lfc3-habnl,
    line_color(4) TYPE c,
    END OF SD_FINAL.
    DATA IT_STD_BSAK  LIKE TABLE OF SD_BSAK  WITH HEADER LINE.
    DATA IT_STD_BSIK  LIKE TABLE OF SD_BSIK  WITH HEADER LINE.
    DATA IT_STD_LFA1  LIKE TABLE OF IT_LFA1  WITH HEADER LINE.
    DATA IT_STD_LFC1  LIKE TABLE OF SD_LFC1  WITH HEADER LINE.
    DATA IT_STD_LFC3  LIKE TABLE OF SD_LFC3  WITH HEADER LINE.
    DATA IT_STD_FINAL  LIKE TABLE OF IT_FINAL  WITH HEADER LINE.
    DATA IT_FINAL_DISPLAY LIKE TABLE OF SD_FINAL WITH HEADER LINE.
    *SELECTION-SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK HEADER WITH FRAME TITLE TEXT-001.
    PARAMETERS:  P_BUKRS LIKE BSAK-BUKRS OBLIGATORY,
                 P_GJAHR LIKE BSAK-GJAHR OBLIGATORY.
               P_EBELN LIKE EKPO-EBELN .
    *PARAMETER: PA_RPT AS CHECKBOX DEFAULT 'X'.
    SELECT-OPTIONS: S_LIFNR FOR BSAK-LIFNR.
    SELECT-OPTIONS: S_MONAT FOR BSAK-MONAT.
    SELECTION-SCREEN END OF BLOCK HEADER.
    START-OF-SELECTION.
      SET PF-STATUS 'STATUS'.
      PERFORM DATA_RETRIVAL.
      PERFORM FIELD.
      PERFORM SORT USING IT_SORT.
      PERFORM EVENTS USING EVENTS.
    PERFORM EVENTS_1 USING EVENTS.
    PERFORM HEADER USING TOP.
      PERFORM LAYOUT.
      PERFORM DISPLAY.
      END-OF-PAGE.
    *&      Form  DATA_RETRIVAL
         text
    -->  p1        text
    <--  p2        text
    FORM DATA_RETRIVAL .
      SELECT BUKRS  LIFNR UMSKS UMSKZ AUGDT AUGBL ZUONR GJAHR BELNR BUZEI BUDAT BLDAT XBLNR BLART
             MONAT BSCHL ZUMSK SHKZG GSBER DMBTR WRBTR SGTXT SAKNR HKONT
        FROM BSAK INTO TABLE IT_STD_BSAK
        WHERE BUKRS = P_BUKRS
              AND GJAHR = P_GJAHR AND ZUMSK = ''
        AND LIFNR IN S_LIFNR
        AND MONAT IN S_MONAT.
      IF NOT IT_STD_BSAK[] IS INITIAL.
        SELECT BUKRS LIFNR UMSKS UMSKZ AUGDT AUGBL ZUONR GJAHR BELNR BUZEI BUDAT BLDAT XBLNR
               BLART MONAT BSCHL ZUMSK SHKZG GSBER DMBTR WRBTR SGTXT SAKNR HKONT ZLSCH
        FROM BSIK INTO TABLE IT_STD_BSIK FOR ALL ENTRIES IN IT_STD_BSAK
        WHERE BUKRS = IT_STD_BSAK-BUKRS AND LIFNR = IT_STD_BSAK-LIFNR AND GJAHR = IT_STD_BSAK-GJAHR AND ZUMSK = ''.
      ENDIF.
    IF NOT IT_STD_BSAK[] IS INITIAL.
        SELECT LIFNR NAME1
               FROM LFA1  INTO TABLE IT_STD_LFA1 FOR ALL ENTRIES IN IT_STD_BSAK
               WHERE LIFNR = IT_STD_BSAK-LIFNR.
      ENDIF.
    IF NOT IT_STD_BSAK[] IS INITIAL.
        SELECT LIFNR BUKRS GJAHR ERDAT USNAM UMSAV
               FROM LFC1  INTO TABLE IT_STD_LFC1 FOR ALL ENTRIES IN IT_STD_BSAK
               WHERE LIFNR = IT_STD_BSAK-LIFNR AND BUKRS = IT_STD_BSAK-BUKRS AND GJAHR = IT_STD_BSAK-GJAHR.
      ENDIF.
    IF NOT IT_STD_BSAK[] IS INITIAL.
        SELECT LIFNR BUKRS GJAHR SHBKZ SALDV SOLLL HABNL
               FROM LFC3  INTO TABLE IT_STD_LFC3 FOR ALL ENTRIES IN IT_STD_BSAK
               WHERE LIFNR = IT_STD_BSAK-LIFNR AND BUKRS = IT_STD_BSAK-BUKRS AND GJAHR = IT_STD_BSAK-GJAHR.
      ENDIF.
      LOOP AT IT_STD_BSAK.
        IT_STD_FINAL-BUKRS = IT_STD_BSAK-BUKRS.
        IT_STD_FINAL-LIFNR = IT_STD_BSAK-LIFNR.
        IT_STD_FINAL-UMSKS = IT_STD_BSAK-UMSKS.
        IT_STD_FINAL-UMSKZ = IT_STD_BSAK-UMSKZ.
        IT_STD_FINAL-AUGDT = IT_STD_BSAK-AUGDT.
        IT_STD_FINAL-AUGBL = IT_STD_BSAK-AUGBL.
        IT_STD_FINAL-ZUONR = IT_STD_BSAK-ZUONR.
        IT_STD_FINAL-GJAHR = IT_STD_BSAK-GJAHR.
        IT_STD_FINAL-BELNR = IT_STD_BSAK-BELNR.
        IT_STD_FINAL-BUZEI = IT_STD_BSAK-BUZEI.
        IT_STD_FINAL-BUDAT = IT_STD_BSAK-BUDAT.
        IT_STD_FINAL-BLDAT = IT_STD_BSAK-BLDAT.
        IT_STD_FINAL-XBLNR = IT_STD_BSAK-XBLNR.
        IT_STD_FINAL-BLART = IT_STD_BSAK-BLART.
        IT_STD_FINAL-MONAT = IT_STD_BSAK-MONAT.
        IT_STD_FINAL-BSCHL = IT_STD_BSAK-BSCHL.
        IT_STD_FINAL-ZUMSK = IT_STD_BSAK-ZUMSK.
        IT_STD_FINAL-SHKZG = IT_STD_BSAK-SHKZG.
        IT_STD_FINAL-GSBER = IT_STD_BSAK-GSBER.
        IT_STD_FINAL-DMBTR = IT_STD_BSAK-DMBTR.
        IT_STD_FINAL-WRBTR = IT_STD_BSAK-WRBTR.
        IT_STD_FINAL-SGTXT = IT_STD_BSAK-SGTXT.
        IT_STD_FINAL-SAKNR = IT_STD_BSAK-SAKNR.
        IT_STD_FINAL-HKONT = IT_STD_BSAK-HKONT.
    READ TABLE IT_STD_LFA1 WITH KEY LIFNR = IT_STD_FINAL-LIFNR.
      IF SY-SUBRC = 0.
        IT_STD_FINAL-NAME1 = IT_STD_LFA1-NAME1.
      ENDIF.
    READ TABLE IT_STD_LFC1 WITH KEY  LIFNR = IT_STD_FINAL-LIFNR
                                     BUKRS = IT_STD_FINAL-BUKRS
                                     GJAHR = IT_STD_FINAL-GJAHR.
        IF SY-SUBRC = 0.
          IT_STD_FINAL-ERDAT = IT_STD_LFC1-ERDAT.
          IT_STD_FINAL-USNAM = IT_STD_LFC1-USNAM.
          IT_STD_FINAL-UMSAV = IT_STD_LFC1-UMSAV.
        ENDIF.
    *READ TABLE IT_STD_LFC3 WITH KEY LIFNR = IT_STD_FINAL-LIFNR
                                   BUKRS = IT_STD_FINAL-BUKRS
                                   GJAHR = IT_STD_FINAL-GJAHR.
       IF SY-SUBRC = 0.
         IT_STD_FINAL-SHBKZ = IT_STD_LFC3-SHBKZ.
         IT_STD_FINAL-SALDV = IT_STD_LFC3-SALDV.
         IT_STD_FINAL-SOLLL = IT_STD_LFC3-SOLLL.
         IT_STD_FINAL-HABNL = IT_STD_LFC3-HABNL.
       ENDIF.
        APPEND IT_STD_FINAL.
        CLEAR IT_STD_FINAL.
      ENDLOOP.
    LOOP AT IT_STD_BSIK.
    IF SY-SUBRC = 0.
        IT_STD_FINAL-BUKRS = IT_STD_BSIK-BUKRS.
        IT_STD_FINAL-LIFNR = IT_STD_BSIK-LIFNR.
        IT_STD_FINAL-UMSKS = IT_STD_BSIK-UMSKS.
        IT_STD_FINAL-UMSKZ = IT_STD_BSIK-UMSKZ.
        IT_STD_FINAL-AUGDT = IT_STD_BSIK-AUGDT.
        IT_STD_FINAL-AUGBL = IT_STD_BSIK-AUGBL.
        IT_STD_FINAL-ZUONR = IT_STD_BSIK-ZUONR.
        IT_STD_FINAL-GJAHR = IT_STD_BSIK-GJAHR.
        IT_STD_FINAL-BELNR = IT_STD_BSIK-BELNR.
        IT_STD_FINAL-BUZEI = IT_STD_BSIK-BUZEI.
        IT_STD_FINAL-BUDAT = IT_STD_BSIK-BUDAT.
        IT_STD_FINAL-BLDAT = IT_STD_BSIK-BLDAT.
        IT_STD_FINAL-XBLNR = IT_STD_BSIK-XBLNR.
        IT_STD_FINAL-BLART = IT_STD_BSIK-BLART.
        IT_STD_FINAL-MONAT = IT_STD_BSIK-MONAT.
        IT_STD_FINAL-BSCHL = IT_STD_BSIK-BSCHL.
        IT_STD_FINAL-ZUMSK = IT_STD_BSIK-ZUMSK.
        IT_STD_FINAL-SHKZG = IT_STD_BSIK-SHKZG.
        IT_STD_FINAL-GSBER = IT_STD_BSIK-GSBER.
        IT_STD_FINAL-DMBTR = IT_STD_BSIK-DMBTR.
        IT_STD_FINAL-WRBTR = IT_STD_BSIK-WRBTR.
        IT_STD_FINAL-SGTXT = IT_STD_BSIK-SGTXT.
        IT_STD_FINAL-SAKNR = IT_STD_BSIK-SAKNR.
        IT_STD_FINAL-HKONT = IT_STD_BSIK-HKONT.
        IT_STD_FINAL-ZLSCH = IT_STD_BSIK-ZLSCH.
        ENDIF.
        APPEND IT_STD_FINAL.
        CLEAR IT_STD_FINAL.
      ENDLOOP.
    LOOP AT IT_STD_LFC3.
       IF SY-SUBRC = 0.
         IT_STD_FINAL-SHBKZ = IT_STD_LFC3-SHBKZ.
         IT_STD_FINAL-SALDV = IT_STD_LFC3-SALDV.
         IT_STD_FINAL-SOLLL = IT_STD_LFC3-SOLLL.
         IT_STD_FINAL-HABNL = IT_STD_LFC3-HABNL.
       ENDIF.
       APPEND IT_STD_FINAL.
       CLEAR IT_STD_FINAL.
    ENDLOOP.
    LOOP AT IT_STD_FINAL.
        IF IT_STD_FINAL-SHKZG = 'S'.
            IT_STD_FINAL-DMBTR_S  = IT_STD_FINAL-DMBTR.
        ELSE.
        IF IT_STD_FINAL-SHKZG = 'H'.
          IT_STD_FINAL-DMBTR_H  = IT_STD_FINAL-DMBTR.
          ENDIF.
        ENDIF.
        IT_STD_FINAL-DMBTR = ''.
        MODIFY IT_STD_FINAL INDEX SY-TABIX TRANSPORTING DMBTR_H DMBTR_S DMBTR.
    "VAR.
        CLEAR IT_STD_FINAL.
      ENDLOOP.
      LOOP AT IT_STD_LFC3.
    *AT NEW LIFNR.
        IF SY-SUBRC = 0.
          IT_STD_FINAL-LIFNR = IT_STD_LFC3-LIFNR.
          IT_STD_FINAL-BUKRS = IT_STD_LFC3-BUKRS.
          IT_STD_FINAL-GJAHR = IT_STD_LFC3-GJAHR.
          IT_STD_FINAL-SHBKZ = IT_STD_LFC3-SHBKZ.
          IT_STD_FINAL-UMSAV = IT_STD_LFC3-SALDV.
          IT_STD_FINAL-DMBTR_S = IT_STD_LFC3-SOLLL.
          IT_STD_FINAL-DMBTR_H = IT_STD_LFC3-HABNL.
        ENDIF.
    *ENDAT.
        APPEND IT_STD_FINAL.
        CLEAR IT_STD_FINAL.
    ENDLOOP.
    LOOP AT IT_STD_FINAL.
         IT_STD_FINAL-DS  = IT_STD_FINAL-DMBTR_S.
         IT_STD_FINAL-DH  = IT_STD_FINAL-DMBTR_H.
         IT_STD_FINAL-SUB = ( IT_STD_FINAL-DS ) - ( IT_STD_FINAL-DH ).
         IT_STD_FINAL-ADD =  ( IT_STD_FINAL-UMSAV ) + ( IT_STD_FINAL-SUB ).
    MODIFY IT_STD_FINAL.
    ENDLOOP.
    ENDFORM.                    " DATA_RETRIVAL
    *&      Form  FIELD
         text
    -->  p1        text
    <--  p2        text
    form FIELD .
      LCAT-FIELDNAME = 'LIFNR'.
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'Vendor No'.
    *LCAT-REF_TABNAME = 'EKKO'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
      LCAT-FIELDNAME = 'NAME1'.
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'Vendor Name'.
    *LCAT-REF_TABNAME = 'EKKO'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
      LCAT-FIELDNAME = 'GJAHR'.                "MATERIAL GROUP
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'Fiscal Year'.
    *LCAT-REF_TABNAME = 'LFA1'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
      LCAT-FIELDNAME = 'GSBER'.                "MATERIAL GROUP
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'BussArea'.
    *LCAT-REF_TABNAME = 'LFA1'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
      LCAT-FIELDNAME = 'SHBKZ'.
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'S G/L'.
      LCAT-REF_TABNAME = 'LFC3'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
      LCAT-FIELDNAME = 'UMSAV'.
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'Bal Carry Forward'.
    *LCAT-REF_TABNAME = 'EKKO'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
      LCAT-FIELDNAME = 'DMBTR_S'.
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'Debit Balanace'.
    *LCAT-REF_TABNAME = 'EKKO'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
      LCAT-FIELDNAME = 'DMBTR_H'.
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'Credit Balance'.
    *LCAT-REF_TABNAME = 'EKKO'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
      LCAT-FIELDNAME = 'ADD'.
      LCAT-TABNAME = 'IT_STD_FINAL'.
      LCAT-SELTEXT_L = 'Accumulated Balance'.
    *LCAT-REF_TABNAME = 'EKKO'.
      LCAT-JUST = 'M'.
      APPEND LCAT TO FIELDCAT.
      CLEAR LCAT.
    LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'DMBTR_S'.
    LCAT-DO_SUM = 'X'.
    MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.
    ENDLOOP.
    LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'DMBTR_H'.
    LCAT-DO_SUM = 'X'.
    MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.
    ENDLOOP.
    LOOP AT FIELDCAT INTO LCAT WHERE FIELDNAME = 'ADD'.
    LCAT-DO_SUM = 'X'.
    MODIFY FIELDCAT FROM LCAT." TRANSPORTING DO_SUM.
    ENDLOOP.
    endform.                    " FIELD
    *&      Form  DISPLAY
         text
    -->  p1        text
    <--  p2        text
    form DISPLAY .
      CLEAR: IT_STD_BSAK,IT_STD_BSIK, IT_STD_LFA1 , IT_STD_LFC1, IT_STD_LFC3.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    I_INTERFACE_CHECK                = ' '
    I_BYPASSING_BUFFER                = ' '
    I_BUFFER_ACTIVE                  = ' '
        I_CALLBACK_PROGRAM                = SY-REPID
    I_CALLBACK_PF_STATUS_SET          = 'STATUS '
    I_CALLBACK_USER_COMMAND          = ' '
    I_CALLBACK_TOP_OF_PAGE            = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE      = ' '
    I_CALLBACK_HTML_END_OF_LIST      = ' '
    I_STRUCTURE_NAME                  =
    I_BACKGROUND_ID                  = ' '
    I_GRID_TITLE                      =
    I_GRID_SETTINGS                  =
        IS_LAYOUT                        = LAYOUT
        IT_FIELDCAT                      = FIELDCAT[]
    IT_EXCLUDING                      =
    IT_SPECIAL_GROUPS                =
          IT_SORT                          = IT_SORT
    IT_FILTER                        =
    IS_SEL_HIDE                      =
    I_DEFAULT                        = 'X'
    I_SAVE                            = ' '
    IS_VARIANT                        =
        IT_EVENTS                        = EVENTS
    IT_EVENT_EXIT                    =
    IS_PRINT                          =
    IS_REPREP_ID                      =
    I_SCREEN_START_COLUMN            = 0
    I_SCREEN_START_LINE              = 0
    I_SCREEN_END_COLUMN              = 0
    I_SCREEN_END_LINE                = 0
    I_HTML_HEIGHT_TOP                = 0
    I_HTML_HEIGHT_END                = 0
    IT_ALV_GRAPHICS                  =
    IT_HYPERLINK                      =
    IT_ADD_FIELDCAT                  =
    IT_EXCEPT_QINFO                  =
    IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER          =
    ES_EXIT_CAUSED_BY_USER            =
        TABLES
       t_outtab                          = IT_CHARG
          t_outtab                          = IT_STD_FINAL
    EXCEPTIONS
    PROGRAM_ERROR                    = 1
    OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "DISPLAY
    *&      Form  EVENTS
         text
    -->  p1        text
    <--  p2        text
    form EVENTS USING P_EVENTS TYPE slis_t_event.
      DATA: ls_event TYPE slis_alv_event.
      ls_event-name = 'TOP_OF_PAGE'.
      ls_event-form = 'TOP_OF_PAGE'.
      APPEND ls_event TO P_EVENTS.
    endform.                    " EVENTS
    *&      Form  TOP_OF_PAGE
         text
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = TOP.
    ENDFORM.                    "TOP_OF_PAGE
    **&      Form  SORT
         text
         -->P_IT_SORT  text
    form SORT  using    p_sort TYPE SLIS_T_SORTINFO_ALV.
      DATA : LT_SORT TYPE slis_sortinfo_alv.
      LT_SORT-fieldname = 'LIFNR'.
      LT_SORT-tabname = 'IT_STD_FINAL'.
      LT_SORT-up = 'X'.
    LT_SORT-SUBTOT      = 'X'.
      APPEND LT_SORT TO P_SORT.
      CLEAR LT_SORT.
      LT_SORT-fieldname = 'GSBER'.
      LT_SORT-tabname = 'IT_STD_FINAL'.
      LT_SORT-up = 'X'.
      LT_SORT-SUBTOT      = 'X'.
      APPEND LT_SORT TO P_SORT.
      CLEAR LT_SORT.
      LT_SORT-fieldname = 'UMSAV'.
      LT_SORT-tabname = 'IT_LFC3'.
      LT_SORT-up = 'X'.
    LT_SORT-SUBTOT      = 'X'.
      APPEND LT_SORT TO P_SORT.
      CLEAR LT_SORT.
    endform.                    " SORT
    *&      Form  LAYOUT
         text
    -->  p1        text
    <--  p2        text
    form LAYOUT .
    LAYOUT-ZEBRA = 'X'.
      LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.
      LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      APPEND LAYOUT." TO LAYOUT.
    endform.                    " LAYOUT
    *&      Form  EVENTS_1
         text
         -->P_EVENTS  text
    FORM EVENTS_1  USING    P_EVENTS TYPE slis_t_event.
      DATA: ls_event TYPE slis_alv_event.
      WRITE: SY-UNAME.
      ls_event-name = 'END_OF_PAGE'.
      ls_event-form = 'END_OF_PAGE'.
      APPEND ls_event TO P_EVENTS.
    ENDFORM.                    " EVENTS_1
    waiting for ur reply...

  • Spec for this report not able to get values in the output

    okSection 1: Document information
    Title     PP – Total Component Requirement by Sales Forecast Report     Create Date     5/2/2006
    Author     Ivie Ng     Revision     1.0     Last changed on     
    Program type     ( X ) Report    (   ) Form        (   ) Batch input    (   ) Dialog program
    Priority     (   ) High       ( X ) Medium    (   ) Low
    Frequency      (   ) As require     (X ) Daily     (  ) Weekly       (  ) Monthly         (  ) Yearly
    (   ) Conversion
    Doc-Ref.     
    Section 2: Contact Person
    Task/Responsibility     Name     Signature     Date
    JM Project Manager     Sean Gilgunn          
    ISS Project Manager     YB Cisse          
    JM-Business Team Lead     Sathe          
    Functional Consultant      Ivie          
    ABAP Consultant     Soh          
    User Acceptance Test / Approved by                
    Transport               
    Section 3: Functional Description
    Background (whatever; Ex.Why does this program have to develop?)
    This is to allow materials dept to view and analyze total component requirement base on sales forecast ie. budget forecast, inactive version within specific planning horizon.
    Requirements
    In SOP, material dept will maintain planning data (sales & production plan) in various version.
    1. Active version: A00
    This version is transferred to demand mgmt as active version. MRP will use this planning data to create order proposals (planned orders, purchase requisitions).
    2. Inactive version: 001 – 999
    There are 3 types of inactive version in SOP:
    a) Sales forecast – 000 – 799
    b) Budge forecast – 800 – 820
    c) Forecast report – 821 – 999
    This report should allow to read any version of the sales forecast and return the total component requirements in the planning horizon that specify.
    Section 3.1: Selection screen
    Field name     Technical name     Type of selection field
         (*Please specify Transparent Table and field name)     (X) Single value             (  ) Range             ( ) Required field
              (  ) Single value             (X) Range             (  ) Required field
              (X) Single value             (  ) Range             (  ) Required field
    Section 3.2: Program Logic
    Business Requirement
    This report will allow option to choose to read the source from SOP or COPA.
    Input Selection
    Main Menu:
    o     Total Component Requirement from SOP forecast
    o     Total Component Requirement from COPA forecast
    If SOP is selected, Source = SOP
    If COPA is selected, Source = COPA
    Option 1: SOP
    1.     Input Layout
    Material: _____________    (note: allow multiple materials entry, no entry indicate all materials)
    RM Material Group: __________     (note: allow multiple entry, no entry indicate all Mat Grp)
    Plant:  MY11  (note: default value)
    Standard Price as of : _____________  (YYYYMM)
    Version: ________    (note: allow F4 option with Version and Description)
    Output Type: ____  (Month/Year)
    (If the output type chosen is Month, the below is display)
    Period From:  _________  (YYYYMM)
    Period To:      _________  (YYYYMM)
    (If the output type chosen is Year, the below is display)
    Period From:  __________ (YYYY)
    Period To:      __________ (YYYY)
    2.     Output Layout
    Plant: MY11
    Source:
    Version:
    System Date/Time:
    Output Layout in Month:
    Material     Desc     Component     Desc     UOM     M04.2006     M05.2006     M06.2006     M07.2006     M08.2006     M09.2006     BOM
    TO2368          NGK0003          PC                                   TO2368
              SIN96-015          MG                                   TO2368
              SIN96-066F          MG                                   TO2368
              SIN96-066N          MG                                   TO2368
              SIN96-127          GCL                                   WCS2004
              SIN96-055          G                                   WCS2004
              SIN96-110          G                                   WCS2004
              SIN96-007          G                                   WCS2004
              SIN96-002          GCL                                   WCS1003
              SIN96-001          GCL                                   WCS1003
              SIN96-006          GCL                                   WCS1003
              TO2358/511          PC                                   TO2368
              TO2358/512          PC                                   TO2368
              WCS2004          GCL                                   TO2368
              WCS1003          GCL                                   WCS2004
    Output Layout in Year:
    Material     Desc     Component     Desc     UOM     2006     2007     2008     BOM
    TO2368          NGK0003          PC                    TO2368
              SIN96-015          MG                    TO2368
              SIN96-066F          MG                    TO2368
              SIN96-066N          MG                    TO2368
              SIN96-127          GCL                    WCS2004
              SIN96-055          G                    WCS2004
              SIN96-110          G                    WCS2004
              SIN96-007          G                    WCS2004
              SIN96-002          GCL                    WCS1003
              SIN96-001          GCL                    WCS1003
              SIN96-006          GCL                    WCS1003
              TO2358/511          PC                    TO2368
              TO2358/512          PC                    TO2368
              WCS2004          GCL                    TO2368
              WCS1003          GCL                    WCS2004
    3.     Header Section:
    Header Field: Plant
    Print input field Plant.
    Header Field: Source
    If SOP is selected, Source = SOP
    If COPA is selected, Source = COPA
    Print Source.
    Header Field: Version
    Print input field Version, Print RMCP2-VETXT (version description).
    Header Field: System Date/Time
    Print current system date and time.
    4.     Table: S076 (SOP - Sales & Operations Planning)
    Read S076 rows with input selection of Material, Plant, Year, Month, Version sorted by Material.
          This table provides sales forecast figure.
    Table: MAKT – Material Decription
    Table: MARA - General Material Data
    Table: CDHDR - Change document header
    Table: CDPOS - Change document items
    5.     Details Section: -
    Read S076.PMNUX(Material).                    Note: There will be multiple rows in S076.PMNUX (Material)
    Field: Material
    Print S076.PMNUX(Material).
    Field: Description
    Read MAKT.MATNR(Material), Print MAKT.MAKTX.
    6.     Read L1 (Level 1) BOM Transaction: CS03
                   Where Material = S076.PMNUX (Material), Plant = MY11 (input field), BOM Usage = ’1’, Status = ‘01’
    7.     This is to print BOM component.
    If Input Material Group = ‘ ’
    Read Component (Material), Component Qty from BOM sorted by MARA.MTART (material type) = ‘ZROH’, ‘ZHLB’ , ‘ZRUH’
    If Input Material Group <> ‘ ’
    Read Component (Material), Component Qty from BOM sorted by MARA.MTART (material type) = ‘ZROH’, ‘ZHLB’ , ‘ZRUH’
          Where MARA-MATKL (Material Group) = Input Material Group.
    If MARA.MTART (material type) = ‘ZRUH’,
          Read L1 (Level 1) BOM Transaction: CS03
                  Where Material = S076.PMNUX, Plant = MY11 (input field), BOM Usage = ’1’, Status = ‘02’.
    GET RC29K-BMENG (Base Qty)  ***
    Field: Material Group
    Print MARA-MATKL
    Field: Component
    Print BOM Component.
    Field: Description
    Print MAKT.MAKTX.
    Field: UOM
    Print MARA.MEINS.
    Field: Currency
    Field: Standard Price
    If Input Standard Price Date = ‘’
       Print Currency = ‘ ‘
       Print Standard Price = 0
    Else
    Read CDHDR-OBJECTID (Material), CDHDR-CHANGENR (ChgNo)
    Where CDHDR-OBJECTID (Material) = BOM Component
    And CDHDR-TCODE (Transaction) = ‘MR21’
    And YYYYMM[CDHDR-UDATE (Date)] = Input Standard Price Date
    If NOT Found, look up YYYYMM[CDHDR-UDATE (Date)] – 1  
    I.e.    Input Standard Price Date is 200702, If CDHDR-UDATE (Date) Not Found, look up 200701.
    If Not Found, look up 200612 until the record is found    **
    If row return > 1, select the latest CDHDR-UDATE (Date)
    i.e. If rows return 20070201 and 20070215, Select 20070215    **
    Read CDPOS-CUKY_NEW (Currency), CDPOS-VALUE_NEW (New Value)
    Where CDPOS-OBJECTID (Material) = CDHDR-OBJECTID (Material)
    And CDPOS-CHANGENR (ChgNo) = CDHDR-CHANGENR (ChgNo)
    Print CDPOS-CUKY_NEW (Currency)
    Print CDPOS-VALUE_NEW (New Value)
    8.     If the output type is Year, print Requirement Qty in Yearly bucket.
    Requirement Qty = sum[S076-ABSAT (Sales) for current Year] ie 2006
    Requirement Qty = sum[S076-ABSAT (Sales) for current Year + 1] ie 2007
    Requirement Qty = sum[S076-ABSAT (Sales) for current Year + 2] ie 2008
         If the output type is Month, print Requirement Qty in Monthly bucket.
    Field: Month (ie. M04.2006)
    Requirement Qty = S076-ABSAT (Sales) * Component Qty / RC29K-BMENG (Base Q)
    Print Requirement Qty.
    Field: Total Price (ie. M04.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
    Field: Month (ie. M05.2006)
    Requirement Qty = S076-ABSAT (Sales) * Component Qty / RC29K-BMENG (Base Q)
    Print Requirement Qty.
    Field: Total Price (ie. M05.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
    Field: Month (ie. M06.2006)
    Requirement Qty = S076-ABSAT (Sales) * Component Qty / RC29K-BMENG (Base Q)
    Print Requirement Qty.
    Field: Total Price (ie. M06.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
    Field: Month (ie. M07.2006)
    Requirement Qty = S076-ABSAT (Sales) * Component Qty / RC29K-BMENG (Base Q)
    Print Requirement Qty.
    Field: Total Price (ie. M07.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
    Field: Month (ie. M08.2006)
    Requirement Qty = S076-ABSAT (Sales) * Component Qty / RC29K-BMENG (Base Q)
    Print Requirement Qty.
    Field: Total Price (ie. M08.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
    Note: Repeat the requirement qty display in Monthly bucket base on period specified.
    Field: BOM
    Print L1 BOM which is S076.PMNUX (Material)  from Step 6.
    If Is end of component,
          Repeat Step 5 for next Material in SOP (S076.PMNUX).
    If MARA.MTART (material type) = ‘ZROH’,
    Perform Step 7 to read next L1 BOM Component.
    Perform Step 8 to print Requirement Qty.
    If [MARA.MTART (material type) = ‘ZHLB’] and [MARA.MATKL(material group) = ‘WP0100’, ‘WP0110’, or ‘WP0120’],
          Go Step 9 to read L2 BOM.
    If [MARA.MTART (material type) = ‘ZHLB’] and [MARA.MATKL (material group) <> ‘WP0100’, ‘WP0110’, ‘WP0120’],
          Perform Step 7 to read next BOM Component.
          Perform Step 8 to print Requirement Qty.
    9.     Read L2 (level 2) BOM for the ZHLB at Transaction: CS03
                Where Plant = MY11(input field), BOM Usage= ’1’, Status = ‘01’.
    GET RC29K-BMENG (Base Qty)  ***
    10.     Read Component (Material), Component Qty from BOM sorted by MARA.MTART (material type) = ‘ZROH’, ‘ZHLB’.
    Field: Material Group
    Print MARA-MATKL
    Field: Component
    Print BOM Component.
    Field: Description
    Print MAKT.MAKTX.
    Field: UOM
    Print MARA.MEINS.
    Field: Month (ie. M04.2006)
    Requirement Qty = Requirement Qty from L1 BOM  * Component Qty / RC29K-BMENG (Base Q)
    Print Requirement Qty.
    Field: Total Price (ie. M04.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
    Field: Month (ie. M05.2006)
    Requirement Qty = Requirement Qty from L1 BOM * Component Qty / / RC29K-BMENG (Base Q)
          Print Requirement Qty.
    Field: Total Price (ie. M05.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
          Note: Repeat until end of Period.
    Field: BOM
    Print L2 BOM from Step 9.
    If is end of component, perform Step 7 to read next L1 BOM component, and Step 8 to print Requirement Qty.
    If MARA.MTART (material type) = ‘ZROH’,
    Perform Step 10 to read next L2 BOM Component.
    If MARA.MTART (material type) = ‘ZHLB’ and MARA.MATKL(material group) = ‘WP0100’, ‘WP0110’, or ‘WP0120’,
          Go Step 11 to read L3 BOM.
    If [MARA.MTART (material type) = ‘ZHLB’] and [MARA.MATKL (material group) <> ‘WP0100’, ‘WP0110’, ‘WP0120’],
          Perform Step 10 to read next L2 BOM Component.
    11.     Read L3 (level 3) BOM for the ZHLB at Transaction: CS03 where Plant=MY11(input field), BOM Usage=’1’, Status =‘01’.
    12.     Read Component (Material), Component Qty from BOM sorted by MARA.MTART (material type) = ‘ZROH’, ‘ZHLB’.
    Field: Material Group
    Print MARA-MATKL
    Field: Component
    Print BOM Component.
    Field: Description
    Print MAKT.MAKTX.
    Field: UOM
    Print MARA.MEINS.
    Field: Currency
    Field: Standard Price
    Read CDHDR-OBJECTID (Material), CDHDR-CHANGENR (ChgNo)
    Where CDHDR-OBJECTID (Material) = BOM Component
    And CDHDR-TCODE (Transaction) = ‘MR21’
    And YYYYMM[CDHDR-UDATE (Date)] = Input Standard Price Date
    If NOT Found, look up YYYYMM[CDHDR-UDATE (Date)] – 1  
    I.e.    Input Standard Price Date is 200702, If CDHDR-UDATE (Date) Not Found, look up 200701.
    If Not Found, look up 200612 until the record is found    **
    If row return > 1, select the latest CDHDR-UDATE (Date)
    i.e. If rows return 20070201 and 20070215, Select 20070215    **
    Read CDPOS-CUKY_NEW (Currency), CDPOS-VALUE_NEW (New Value)
    Where CDPOS-OBJECTID (Material) = CDHDR-OBJECTID (Material)
    And CDPOS-CHANGENR (ChgNo) = CDHDR-CHANGENR (ChgNo)
    Print CDPOS-CUKY_NEW (Currency)
    Print CDPOS-VALUE_NEW (New Value)
    Field: Month (ie. M04.2006)
    Requirement Qty = Requirement Qty from L2 BOM  * Component Qty / RC29K-BMENG (Base Q)
    Print Requirement Qty.
    Field: Total Price (ie. M04.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
    Field: Month (ie. M05.2006)
    Requirement Qty = Requirement Qty from L2 BOM * Component Qty / RC29K-BMENG (Base Q)
          Print Requirement Qty.
    Field: Total Price (ie. M05.2006)
    Total Price = Requirement Qty * Standard Price
    Print Total Price
          Note: Repeat until end of Period.
    Field: BOM
    Print L3 BOM from Step 11.
    If is end of component,
          Perform Step 10 to read next L2 BOM Component.
    If MARA.MTART (material type) = ‘ZROH’,
    Perform Step 12 to read next L3 BOM Component.
    If MARA.MTART (material type) = ‘ZHLB’ and MARA.MATKL(material group) = ‘WP0100’, ‘WP0110’, or ‘WP0120’,
          Repeat for next level of BOM reading.      ** for future BOM expansion **
    If [MARA.MTART (material type) = ‘ZHLB’] and [MARA.MATKL (material group) <> ‘WP0100’, ‘WP0110’, ‘WP0120’],
          Perform Step 12 to read next L3 BOM Component.
    13.     The report is ALV format and should allow to export to Excel. See example below:
    Option 2: COPA
    1.     Input Layout
    Company Code:  ________ 
    Plant:  MY11   
    Material: _____________    (note: allow multiple materials entry, no entry indicate all materials)
    Material Group: __________     (note: allow multiple materials entry, no entry indicate all materials)
    Standard Price as of : _____________  (YYYYMM)
    Version: ________    (note: allow F4 option with Version and Description)
    Read  V_TKEVS_CL-VERSI (Version),  V_TKEVS_CL-VTEXT (Version Description)
    Output Type: ____  (Month/Year)
    (If the output type chosen is Month, the below is display)
    Period From:  _________  (YYYYMM)
    Period To:      _________  (YYYYMM)
    (If the output type chosen is Year, the below is display)
    Period From:  __________ (YYYY)
    Period To:      __________ (YYYY)
    2.     Header Section:
    Header Field: Plant
    Print input field Plant.
    Header Field: Source
    If SOP is selected, Source = SOP
    If COPA is selected, Source = COPA
    Print Source.
    Header Field: Version
    Print V_TKEVS_CL-VERSI (Version),  V_TKEVS_CL-VTEXT (Version Description)
    Header Field: System Date/Time
    Print current system date and time.
    3.     Report details: -
    Table: CE2ASIA - JM Operating Concern
    If input selection is Monthly Report:-
    Read CE2ASIA-ARTNR (Product No), Sum[CE2ASIA-ABSMG001 (Sales Qty)]
    Where CE2ASIA-BUKRS (Company Code) = Input Company Code
    And CE2ASIA-WERKS (Plant) = Input Plant
    And CE2ASIA-PALEDGER (Currency Type) = ‘10’
    And [CE2ASIA-PERBL (FI Period) > = Input Period From And CE2ASIA-PERBL (FI Period) < = Input Period To]
    Group by CE2ASIA-ARTNR (Product No)
    If input selection is Yearly Report:-
    Read CE2ASIA-ARTNR (Product No), CE2ASIA-ABSMG001 (Sales Qty)
    Where CE2ASIA-BUKRS (Company Code) = Input Company Code
    And CE2ASIA-WERKS (Plant) = Input Plant
    And CE2ASIA-PALEDGER (Currency Type) = ‘10’
    And [YYYY[CE2ASIA-PERBL (FI Period)] > = Input Period From And CE2ASIA-PERBL (FI Period) < = Input Period To]
    Note: The details similar to Option 1: SOP, refer section (5)  to (13)
    Section 3.3: Report Layout
    Field name     Technical name     Comment
         (Please specify Transparent Table and field name)     (Ex. In case field does not read directly from transparent table but derive from formular or sum or else. Please show the detail how to do that.)
    Section 3.3: Unit Test Criteria
    Section 4: Technical Description
    Section 4.1: Object information
    Development class     
    Transport number     
    Section 4.2: Input/output file layout (In case upload/download file)
    *Please determine structure of  file like as below:
    No.     Field description     Type (Char,Numeric,…)     Length     Note
    Section 4.3: Report/Form information
    Paper size     Inch 11 8” X 11”     Type of printer     ( ) Laser printer     (X) Dot matrix
    Output report / Pre-printed Attach
    Technical Issue

    Hi gurus,actually this program selecion screen is linked to ..as
    First screen is .Sop
                          .copa
    Again for sop is having a selection screen and in this it is divide based on month and year seperately in two more screens.
    same for copa also....
    so pls tell me a correct solution where to correct and get values.
    Priority is very highhhhhhhhhhhhhh,so pls help me in sorting out this.

Maybe you are looking for

  • Portable drive no longer recognized

    Hello. I have an HP PD1000a drive that is no longer recognized by my HP 9040n (Windows 7 Ultimate) computer.  This happened overnight.  The drive can be recognized and the driver installed by another computer (HP laptop running W7 Ultimate). When I p

  • Why does my Kodak printer not work with yosemite?

    ever since upgrading to yosemite, my kodak printer will not work. i got as far as being able to download a software update but still no joy.

  • Creating art in Flash 8 painfully slow

    Using Flash 8 on my new Mac Pro with 9G of memory and a fast hard drive... Creating art to animate is painfully slow for some reason. There is an annoying lag or pause - after every keystroke or individual brushstroke I have to wait a second or two f

  • How can i fix start botton ? Every time i need to press more to work.

    How can i fix start botton ? Every time i need to press more to work.

  • Update problem with N96

    Hello everybody, I have recieve this morning a message which said to me that a new update is available for my N96(from 11.018 to 11.101). I'm trying to upgrade it and the problem appear. Everything looks stucks. My cell phone switch off by itself (it