Performance of Big Report Programs

Hi SAP Experts,
I want to know whether we can put the trace on the Report Programs which are taking on almost around 10 hours to execute or how can we put a trace on background jobs.
Thanks and Regards,
Harsh Goel

Hi Harsh,
The problem with the report will be mostly due to the select queries.
So better do one thing, execute your program in debug mode, keep a break point before the select query, activate the trace in ST05 transaction and after executing the select query deactivate the trace
Now look in display trace for the time it takes for the query.
you can follow the same method for each query and check which query takes a long time and rectify that.
To reduce ABAP/4 program runtime, always follow the ABAP/4 program optimization techniques given below:
1. Avoid 'SELECT *'. Instead use select with field names i.e. SELECT f1 f2 f3 and so on.
2. Use table (primary) keys (as far as possible) in the WHERE clause of the select statements. Else, check for secondary indexes.
3. Avoid nested selects or nested loops.
4. Use binary search wherever possible.
5. Avoid use of joins in the select queries.
5. You can evaluate the performance using GET RUN TIME command for small pieces of program. Try using this statement for SELECT queries to know how much time your SELECT query takes to execute.
Example
DATA: gv_runtime1       TYPE i,
      gv_runtime2       TYPE i,
      gv_final          TYPE i.
GET RUN TIME FIELD gv_runtime1.
SELECTu2026u2026
GET RUN TIME FIELD gv_runtime2.
gv_final = gv_runtime2 - gv_runtime1.
WRITE: 'Execution time=', gv_final.
If you still have any doubts please let me know.
Regards,
Shobana.K
Edited by: Shobana k on Sep 18, 2008 8:27 AM

Similar Messages

  • Performance issue in report programming..

    Hi,
    I am using one customized Function Module  whithin a loop of internal table containing fields of PROJ table for about 200 records . And in  the source code of function module there is set of select queries for different tables like COSS COSP , AUFK , PRPS , BPJA PRHI , AFPO , AFKO etc . so due to that my performance of a report is very low , So how can i improve it .
    Is there any other way to change a code.
    regards
    Chetan

    Hi  John ,
    I am using SAP ECC 6.0 .
    The report  is used to update a  ztable which is already created for Project System plan data .
    So i am calling function module  which will return a internal table , I am appending this to other internal table and refreshing it , like this I  am doing for each project within a loop of PROJ internal table , finaly by using the final itab I am modifying the ztable fields.
    Code is as below..
    select pspid from proj client specified into corresponding fields of
              table t_itab1 where mandt = sy-mandt
                              and pspnr in s_pspnr
                              and vbukr = p_vbukr
                              and prctr in s_prctr.
    loop at t_itab1.
        l_pspid = t_itab1-pspid.
    CALL FUNCTION 'ZPS_FUN_BUDGETS'
          EXPORTING
            L_PSPID       = l_pspid
            L_VBUKR       = p_vbukr
          TABLES
            T_DATA        = t_itab2 .
      loop at t_itab2.
          append t_itab2 to t_itab.
        endloop.
        clear   : t_itab2.
        refresh : t_itab2.
      endloop.
    LOOP AT t_itab.
    ***MODIFY ZTABLE.*****
    ENDLOOP.
    Regards
    Chetan

  • Performance of the Report Program

    Hello experts,
    I had a requirement like following
    Selection parameters:
    Material (lips-matnr)
    Sold to party(likp-kunag): can hardcode it to 5090
    Sales Org(likp-vkorg)
    Plant(lips-werks) : hard code it to plant:9000
    Sales order(likp-vbeln)
    Actual goods movement dates(likp-wadat_ist)
    Invoice number
    Sales order
    Output
    material numberlips~matnr ( should Display only S* materials and material type FERT)
    Serial number of the device shipped (objk-sernr)
    Delivery number (lips~vbeln)
    Invoice number (vbrp-vbeln)
    Invoice price=Vbrp-vbeln/quantity (invoice price)
    Notification number (Viqmel-QMNUm)
    KBB Repair Level(VIQMEL-QMTXT from QMCOD )
    KBC Repair level(VIQMMA-MNCOD from KBC-SM07 code group(VIQMMA-MNGRP))
    and I wrote a program but its taking lot of time to run
    Can anyone help me in changing the logic of the program,
    TABLES: likp, lips, vbfa, vbak.
    TYPE-POOLS: slis.
       / Selection and Input Parameters
    SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-003.
    SELECT-OPTIONS: s_matnr FOR lips-matnr,
                    s_kunag FOR likp-kunag.
    SELECT-OPTIONS: s_vkorg FOR likp-vkorg NO INTERVALS,
                    s_werks FOR lips-werks.
    SELECT-OPTIONS: s_vbeln FOR likp-vbeln,
                    s_waist FOR likp-wadat_ist.
    SELECT-OPTIONS: s_vgbel FOR lips-vgbel.
    SELECTION-SCREEN END OF BLOCK block2.
    DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
    TYPES: BEGIN OF ty_data,
            matnr LIKE lips-matnr,
            lsernr LIKE mase-lsernr,
            vbeln LIKE likp-vbeln,
            invno like vbrp-vbeln,
            netwr like vbrp-netwr,
            qmnum LIKE viqmel-qmnum,
            mngrp like viqmma-mngrp,
            mncod like viqmma-mncod,
           END OF ty_data.
    DATA: gt_data TYPE TABLE OF ty_data WITH HEADER LINE.
    START-OF-SELECTION.
      PERFORM get_data.
      IF NOT gt_data[] IS INITIAL.
        PERFORM display_data.
      ELSE.
        MESSAGE s000(z1) WITH 'No data found'.
      ENDIF.
    *& Form get_data
    FORM get_data.
      SELECT lips~matnr mase~lsernr likp~vbeln vbrp~vbeln vbrp~netwr
              viqmel~qmnum viqmel~qmcod viqmma~mngrp viqmma~mncod
      INTO CORRESPONDING FIELDS OF TABLE gt_data
      FROM likp INNER JOIN lips ON lips~vbeln = likp~vbeln
                INNER JOIN vbrp ON vbrp~vgbel = lips~vgbel AND
                                   vbrp~matnr = lips~matnr
                INNER JOIN mase ON mase~matnr = lips~matnr
                INNER JOIN viqmel ON viqmel~matnr = lips~matnr AND
                                     viqmel~serialnr = mase~lsernr
                INNER JOIN viqmma ON viqmma~qmnum = viqmel~qmnum
                  WHERE lips~matnr IN s_matnr
                  AND lips~werks IN s_werks
                  AND likp~kunag IN s_kunag
                  AND likp~wadat_ist IN s_waist
                  AND lips~vgbel IN s_vgbel
                  AND likp~vkorg IN s_vkorg
                  and likp~vbeln in s_vbeln
                  AND lips~matnr LIKE 'S%'
                  AND EXISTS ( SELECT * FROM mara WHERE matnr = lips~matnr
                                             AND mtart = 'FERT' ).
    ENDFORM. " get_data
                 & Form display_data
    FORM display_data.
      DATA: lv_repid TYPE sy-repid.
      lv_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                i_program_name     = lv_repid
                i_internal_tabname = 'GT_DATA'
           CHANGING
                ct_fieldcat        = gt_fieldcat[].
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_callback_program = lv_repid
                it_fieldcat        = gt_fieldcat
                i_save             = 'A'
           TABLES
                t_outtab           = gt_data.
    ENDFORM.

    U can try two things instead of the EXISTS where clause.
    1. U have select-option for matnr so need to use that
    2. Inner join LIPS to mara on matnr and apply the filter on MTART field.
    SELECT lipsmatnr maselsernr likpvbeln vbrpvbeln vbrp~netwr
    viqmelqmnum viqmelqmcod viqmmamngrp viqmmamncod
    INTO CORRESPONDING FIELDS OF TABLE gt_data
    FROM likp INNER JOIN lips ON lipsvbeln = likpvbeln
    INNER JOIN vbrp ON vbrpvgbel = lipsvgbel AND
    vbrpmatnr = lipsmatnr
    INNER JOIN mase ON masematnr = lipsmatnr
    INNER JOIN mara on lipsmatnr = maramatnr
    INNER JOIN viqmel ON viqmelmatnr = lipsmatnr AND
    viqmelserialnr = maselsernr
    INNER JOIN viqmma ON viqmmaqmnum = viqmelqmnum
    WHERE lips~matnr IN s_matnr
    AND lips~werks IN s_werks
    AND likp~kunag IN s_kunag
    AND likp~wadat_ist IN s_waist
    AND lips~vgbel IN s_vgbel
    AND likp~vkorg IN s_vkorg
    and likp~vbeln in s_vbeln
    AND lips~matnr LIKE 'S%'
    and mara~mtart = 'FERT'.
    Regards
    Anurag
    Message was edited by: Anurag Bankley

  • Report program Performance problem

    Hi All,
       one object is taking 30hr for executing.some one develped this in 1998 but this time it is a big Performance problem.please some one helep what to do i am giving that code.
    *--DOCUMENTATION--
    Programe written by :  31.03.1998 .
    Purpose : this programe updates the car status into the table zsdtab1
    This programe is to be schedule in the backgroud periodically .
    Querries can be fired on the table zsdtab1 to get the details of the
        Car .
    This programe looks at the changes made in the material master from
    last updated date and the new entries in material master and updates
    the tables zsdtab1 .
    Changes in the Sales Order are not taken into account .
    To get a fresh data set the value of zupddate in table ZSTATUS as
    01.01.1998 . All the data will be refreshed from that date .
    Program Changed on 23/7/2001 after version upgrade 46b by jyoti
    Addition of New tables for Ibase
    tables used -
    tables : mara ,                        " Material master
             ausp ,                        " Characteristics table .
             zstatus ,                     " Last updated status table .
             zsdtab1 ,    " Central database table to be maintained .
             vbap ,                        " Sales order header table .
             vbak ,                        " Sales order item table .
             kna1 ,                        " Customer master .
             vbrk ,
             vbrp ,
             bkpf ,
             bseg ,
             mseg ,
             mkpf ,
             vbpa ,
             vbfa ,
             t005t .                         " Country details tabe .
    --NEW TABLES ADDEDFOR VERSION 4.6B--
    tables :   ibsymbol ,ibin , ibinvalues .
    data : vatinn like ibsymbol-atinn , vatwrt like ibsymbol-atwrt ,
           vatflv like ibsymbol-atflv .
    *--types definition--
    types : begin of mara_itab_type ,
               matnr like mara-matnr ,
               cuobf like mara-cuobf ,
            end of mara_itab_type ,
            begin of ausp_itab_type ,
               atinn like ausp-atinn ,
               atwrt like ausp-atwrt ,
               atflv like ausp-atflv ,
            end of ausp_itab_type .
    data : mara_itab type mara_itab_type occurs 500 with header line ,
           zsdtab1_itab like zsdtab1 occurs 500 with header line ,
           ausp_itab type ausp_itab_type occurs 500 with header line ,
           last_date type d ,
           date type d .
    data: length type i.
    clear mara_itab . refresh mara_itab .
    clear zsdtab1_itab . refresh zsdtab1_itab .
    select single  zupddate into last_date from zstatus
           where programm = 'ZSDDET01' .
    select matnr cuobf into (mara_itab-matnr , mara_itab-cuobf) from mara
          where mtart eq 'FERT' or mtart = 'ZCBU'.
        where MATNR IN MATERIA
         and ERSDA IN C_Date
         and MTART in M_TYP.
        append mara_itab .
    endselect .
    loop at mara_itab.
    clear zsdtab1_itab .
    zsdtab1_itab-commno = mara_itab-matnr .
       Get the detailed data into internal table ausp_itab .----------->>>
    clear ausp_itab . refresh ausp_itab .
    --change starts--
    select atinn atwrt atflv into (ausp_itab-atinn , ausp_itab-atwrt ,
                               ausp_itab-atflv) from ausp
          where objek = mara_itab-matnr .
          append ausp_itab .
       endselect .
       clear ausp_itab .
    select  atinn  atwrt atflv  into (ausp_itab-atinn , ausp_itab-atwrt ,
    ausp_itab-atflv) from ibin as a inner join ibinvalues as b
                      on ain_recno = bin_recno
           inner join  ibsymbol as c
                      on bsymbol_id = csymbol_id
        where a~instance = mara_itab-cuobf  .
      append ausp_itab .
    endselect .
    ----CHANGE ENDS HERE -
    sort ausp_itab by atwrt.
    loop at ausp_itab .
    clear date .
    case ausp_itab-atinn .
      when '0000000094' .
        zsdtab1_itab-model = ausp_itab-atwrt .  " model  .
      when '0000000101' .
        zsdtab1_itab-drive = ausp_itab-atwrt .  " drive
      when '0000000095' .
        zsdtab1_itab-converter = ausp_itab-atwrt . "converter
      when '0000000096' .
        zsdtab1_itab-transmssn = ausp_itab-atwrt . "transmission
      when '0000000097' .
        zsdtab1_itab-colour = ausp_itab-atwrt .    "colour
      when '0000000098' .
        zsdtab1_itab-ztrim = ausp_itab-atwrt .     "trim
      when '0000000103' .
    *=========Sujit 14-Mar-2006
       IF AUSP_ITAB-ATWRT(3) EQ 'WDB' OR AUSP_ITAB-ATWRT(3) EQ 'WDD'
       OR AUSP_ITAB-ATWRT(3) EQ 'WDC' OR AUSP_ITAB-ATWRT(3) EQ 'KPD'.
           ZSDTAB1_ITAB-CHASSIS_NO = AUSP_ITAB-ATWRT+3(14).
       ELSE.
           ZSDTAB1_ITAB-CHASSIS_NO = AUSP_ITAB-ATWRT .     "chassis no
       ENDIF.
        zsdtab1_itab-chassis_no = ausp_itab-atwrt .     "chassis no
    *=========14-Mar-2006
      when '0000000166' .
    ----25.05.04
      length = strlen( ausp_itab-atwrt ).
      if length < 15.                       "***aded by patil
       zsdtab1_itab-engine_no = ausp_itab-atwrt .     "ENGINE NO
      else.
    zsdtab1_itab-engine_no = ausp_itab-atwrt+13(14)."Aded on 21.05.04 patil
      endif.
    ----25.05.04
      when '0000000104' .
        zsdtab1_itab-body_no = ausp_itab-atwrt .     "BODY NO
      when '0000000173' .                                          "21.06.98
        zsdtab1_itab-cockpit = ausp_itab-atwrt .     "COCKPIT NO . "21.06.98
      when '0000000102' .
        zsdtab1_itab-dest = ausp_itab-atwrt .     "destination
      when '0000000105' .
        zsdtab1_itab-airbag = ausp_itab-atwrt .     "AIRBAG
      when '0000000110' .
        zsdtab1_itab-trailer_no = ausp_itab-atwrt .     "TRAILER_NO
      when '0000000109' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-fininspdat = date .   "FIN INSP DATE
      when '0000000108' .
        zsdtab1_itab-entrydate = ausp_itab-atwrt .     "ENTRY DATE
      when '0000000163' .
        zsdtab1_itab-regist_no = ausp_itab-atwrt .     "REGIST_NO
      when '0000000164' .
        zsdtab1_itab-mech_key = ausp_itab-atwrt .     "MECH_KEY
      when '0000000165' .
        zsdtab1_itab-side_ab_rt = ausp_itab-atwrt .     "SIDE_AB_RT
      when '0000000171' .
        zsdtab1_itab-side_ab_lt = ausp_itab-atwrt .     "SIDE_AB_LT
      when '0000000167' .
        zsdtab1_itab-elect_key = ausp_itab-atwrt .     "ELECT_KEY
      when '0000000168' .
        zsdtab1_itab-head_lamp = ausp_itab-atwrt .     "HEAD_LAMP
      when '0000000169' .
        zsdtab1_itab-tail_lamp = ausp_itab-atwrt .     "TAIL_LAMP
      when '0000000170' .
        zsdtab1_itab-vac_pump = ausp_itab-atwrt .     "VAC_PUMP
      when '0000000172' .
        zsdtab1_itab-sd_ab_sn_l = ausp_itab-atwrt .     "SD_AB_SN_L
      when '0000000174' .
        zsdtab1_itab-sd_ab_sn_r = ausp_itab-atwrt .     "SD_AB_SN_R
      when '0000000175' .
        zsdtab1_itab-asrhydunit = ausp_itab-atwrt .     "ASRHYDUNIT
      when '0000000176' .
        zsdtab1_itab-gearboxno = ausp_itab-atwrt .     "GEARBOXNO
      when '0000000177' .
        zsdtab1_itab-battery = ausp_itab-atwrt .     "BATTERY
      when '0000000178' .
        zsdtab1_itab-tyretype = ausp_itab-atwrt .     "TYRETYPE
      when '0000000179' .
        zsdtab1_itab-tyremake = ausp_itab-atwrt .     "TYREMAKE
      when '0000000180' .
        zsdtab1_itab-tyresize = ausp_itab-atwrt .     "TYRESIZE
      when '0000000181' .
        zsdtab1_itab-rr_axle_no = ausp_itab-atwrt .     "RR_AXLE_NO
      when '0000000183' .
        zsdtab1_itab-ff_axl_nor = ausp_itab-atwrt .     "FF_AXLE_NO_rt
      when '0000000182' .
        zsdtab1_itab-ff_axl_nol = ausp_itab-atwrt .     "FF_AXLE_NO_lt
      when '0000000184' .
        zsdtab1_itab-drivairbag = ausp_itab-atwrt .     "DRIVAIRBAG
      when '0000000185' .
        zsdtab1_itab-st_box_no = ausp_itab-atwrt .     "ST_BOX_NO
      when '0000000186' .
        zsdtab1_itab-transport = ausp_itab-atwrt .     "TRANSPORT
      when '0000000106' .
        zsdtab1_itab-trackstage = ausp_itab-atwrt .  " tracking stage
      when '0000000111' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_1 = date .    " tracking date for 1.
      when '0000000112' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_5 = date .    " tracking date for 5.
      when '0000000113' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_10 = date .   "tracking date for 10
      when '0000000114' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_15 = date .   "tracking date for 15
      when '0000000115' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_20 = date .   " tracking date for 20
      when '0000000116' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_25 = date .   " tracking date for 25
      when '0000000117' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_30 = date .   "tracking date for 30
      when '0000000118' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_35 = date .   "tracking date for 35
      when '0000000119' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_40 = date .   " tracking date for 40
      when '0000000120' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_45 = date .   " tracking date for 45
      when '0000000121' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_50 = date .   "tracking date for 50
      when '0000000122' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_55 = date .   "tracking date for 55
      when '0000000123' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_60 = date .   " tracking date for 60
      when '0000000124' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_65 = date .   " tracking date for 65
      when '0000000125' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_70 = date .   "tracking date for 70
      when '0000000126' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_75 = date .   "tracking date for 75
      when '0000000127' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_78 = date .   " tracking date for 78
      when '0000000203' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_79 = date .   " tracking date for 79
      when '0000000128' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_80 = date .   " tracking date for 80
      when '0000000129' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_85 = date .   "tracking date for 85
      when '0000000130' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_90 = date .   "tracking date for 90
      when '0000000131' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dat_trk_95 = date .   "tracking date for 95
      when '0000000132' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dattrk_100 = date .   " tracking date for100
      when '0000000133' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dattrk_110 = date .   " tracking date for110
      when '0000000134' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dattrk_115 = date .   "tracking date for 115
      when '0000000135' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dattrk_120 = date .   "tracking date for 120
      when '0000000136' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-dattrk_105 = date .   "tracking date for 105
      when '0000000137' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_1 = date .     "plan trk date for 1
      when '0000000138' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_5 = date .     "plan trk date for 5
      when '0000000139' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_10 = date .    "plan trk date for 10
      when '0000000140' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_15 = date .    "plan trk date for 15
      when '0000000141' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_20 = date .    "plan trk date for 20
      when '0000000142' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_25 = date .    "plan trk date for 25
      when '0000000143' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_30 = date .    "plan trk date for 30
      when '0000000144' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_35 = date .    "plan trk date for 35
      when '0000000145' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_40 = date .    "plan trk date for 40
      when '0000000146' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_45 = date .    "plan trk date for 45
      when '0000000147' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_50 = date .    "plan trk date for 50
      when '0000000148' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_55 = date .    "plan trk date for 55
      when '0000000149' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_60 = date .    "plan trk date for 60
      when '0000000150' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_65 = date .    "plan trk date for 65
      when '0000000151' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_70 = date .    "plan trk date for 70
      when '0000000152' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_75 = date .    "plan trk date for 75
      when '0000000153' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_78 = date .    "plan trk date for 78
      when '0000000202' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_79 = date .    "plan trk date for 79
      when '0000000154' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_80 = date .    "plan trk date for 80
      when '0000000155' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_85 = date .    "plan trk date for 85
      when '0000000156' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_90 = date .    "plan trk date for 90
      when '0000000157' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_95 = date .    "plan trk date for 95
      when '0000000158' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_100 = date .   "plan trk date for 100
      when '0000000159' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_105 = date .   "plan trk date for 105
      when '0000000160' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_110 = date .   "plan trk date for 110
      when '0000000161' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_115 = date .   "plan trk date for 115
      when '0000000162' .
        perform date_convert using  ausp_itab-atflv changing date .
        zsdtab1_itab-pdt_tk_120 = date .   "plan trk date for 120
    ********Additional fields / 24.05.98**********************************
      when '0000000099' .
        case ausp_itab-atwrt .
          when '540' .
            zsdtab1_itab-roll_blind = 'X' .
          when '482' .
            zsdtab1_itab-ground_clr = 'X' .
          when '551' .
            zsdtab1_itab-anti_theft = 'X' .
          when '882' .
            zsdtab1_itab-anti_tow = 'X' .
          when '656' .
            zsdtab1_itab-alloy_whel = 'X' .
          when '265' .
            zsdtab1_itab-del_class = 'X' .
          when '280' .
            zsdtab1_itab-str_wheel = 'X' .
          when 'CDC' .
            zsdtab1_itab-cd_changer = 'X' .
          when '205' .
            zsdtab1_itab-manual_eng = 'X' .
          when '273' .
            zsdtab1_itab-conn_handy = 'X' .
          when '343' .
            zsdtab1_itab-aircleaner = 'X' .
          when '481' .
            zsdtab1_itab-metal_sump = 'X' .
          when '533' .
            zsdtab1_itab-speaker = 'X' .
          when '570' .
            zsdtab1_itab-arm_rest = 'X' .
          when '580' .
            zsdtab1_itab-aircond = 'X' .
          when '611' .
            zsdtab1_itab-exit_light = 'X' .
          when '613' .
            zsdtab1_itab-headlamp = 'X' .
          when '877' .
            zsdtab1_itab-readlamp = 'X' .
          when '808' .
            zsdtab1_itab-code_ckd = 'X' .
          when '708' .
            zsdtab1_itab-del_prt_lc = 'X' .
          when '593' .
            zsdtab1_itab-ins_glass = 'X' .
          when '955' .
            zsdtab1_itab-zelcl = 'Elegance' .
          when '593' .
            zsdtab1_itab-zelcl = 'Classic' .
        endcase .
    endcase .
    endloop .
    *--Update the sales data .--
    perform get_sales_order using mara_itab-matnr .
    perform get_cartype using mara_itab-matnr .
    append zsdtab1_itab .
    endloop.
    <<<
    loop at zsdtab1_itab .
      if zsdtab1_itab-cartype <> 'W-203'
      or zsdtab1_itab-cartype <> 'W-210'
      or zsdtab1_itab-cartype <> 'W-211'.
          clear zsdtab1_itab-zelcl.
      endif.
    SELECT SINGLE * FROM ZSDTAB1 WHERE COMMNO = MARA_ITAB-MATNR .
    select single * from zsdtab1 where commno = zsdtab1_itab-commno.
    if sy-subrc <> 0 .
        insert into zsdtab1 values zsdtab1_itab .
    else .
        update zsdtab1 set :vbeln = zsdtab1_itab-vbeln
                       bill_doc = zsdtab1_itab-bill_doc
                       dest = zsdtab1_itab-dest
                       lgort = zsdtab1_itab-lgort
                       ship_tp = zsdtab1_itab-ship_tp
                       country = zsdtab1_itab-country
                       kunnr = zsdtab1_itab-kunnr
                       vkbur = zsdtab1_itab-vkbur
                       customer = zsdtab1_itab-customer
                       city   = zsdtab1_itab-city
                       region = zsdtab1_itab-region
                       model = zsdtab1_itab-model
                       drive = zsdtab1_itab-drive
                       converter = zsdtab1_itab-converter
                       transmssn = zsdtab1_itab-transmssn
                       colour = zsdtab1_itab-colour
                       ztrim = zsdtab1_itab-ztrim
                       commno = zsdtab1_itab-commno
                       trackstage = zsdtab1_itab-trackstage
                       chassis_no    =   zsdtab1_itab-chassis_no
                       engine_no     =   zsdtab1_itab-engine_no
                       body_no       =   zsdtab1_itab-body_no
                       cockpit       =   zsdtab1_itab-cockpit
                       airbag        =   zsdtab1_itab-airbag
                       trailer_no    =   zsdtab1_itab-trailer_no
                       fininspdat    =   zsdtab1_itab-fininspdat
                       entrydate     =   zsdtab1_itab-entrydate
                       regist_no     =   zsdtab1_itab-regist_no
                       mech_key      =   zsdtab1_itab-mech_key
                       side_ab_rt    =   zsdtab1_itab-side_ab_rt
                       side_ab_lt    =   zsdtab1_itab-side_ab_lt
                       elect_key     =   zsdtab1_itab-elect_key
                       head_lamp     =   zsdtab1_itab-head_lamp
                       tail_lamp     =   zsdtab1_itab-tail_lamp
                       vac_pump      =   zsdtab1_itab-vac_pump
                       sd_ab_sn_l    =   zsdtab1_itab-sd_ab_sn_l
                       sd_ab_sn_r    =   zsdtab1_itab-sd_ab_sn_r
                       asrhydunit    =   zsdtab1_itab-asrhydunit
                       gearboxno     =   zsdtab1_itab-gearboxno
                       battery       =   zsdtab1_itab-battery
                       tyretype      =   zsdtab1_itab-tyretype
                       tyremake      =   zsdtab1_itab-tyremake
                       tyresize      =   zsdtab1_itab-tyresize
                       rr_axle_no    =   zsdtab1_itab-rr_axle_no
                       ff_axl_nor    =   zsdtab1_itab-ff_axl_nor
                       ff_axl_nol    =   zsdtab1_itab-ff_axl_nol
                       drivairbag    =   zsdtab1_itab-drivairbag
                       st_box_no     =   zsdtab1_itab-st_box_no
                       transport     =   zsdtab1_itab-transport
    OPTIONS-
                       roll_blind    = zsdtab1_itab-roll_blind
                       ground_clr    = zsdtab1_itab-ground_clr
                       anti_theft    = zsdtab1_itab-anti_theft
                       anti_tow      = zsdtab1_itab-anti_tow
                       alloy_whel    = zsdtab1_itab-alloy_whel
                       del_class     = zsdtab1_itab-del_class
                       str_wheel     = zsdtab1_itab-str_wheel
                       cd_changer    = zsdtab1_itab-cd_changer
                       manual_eng    = zsdtab1_itab-manual_eng
                       conn_handy    = zsdtab1_itab-conn_handy
                       aircleaner    = zsdtab1_itab-aircleaner
                       metal_sump    = zsdtab1_itab-metal_sump
                       speaker       = zsdtab1_itab-speaker
                       arm_rest      = zsdtab1_itab-arm_rest
                       aircond       = zsdtab1_itab-aircond
                       exit_light    = zsdtab1_itab-exit_light
                       headlamp      = zsdtab1_itab-headlamp
                       readlamp      = zsdtab1_itab-readlamp
                       code_ckd      = zsdtab1_itab-code_ckd
                       del_prt_lc    = zsdtab1_itab-del_prt_lc
                       ins_glass     = zsdtab1_itab-ins_glass
                       dat_trk_1 = zsdtab1_itab-dat_trk_1
                       dat_trk_5 = zsdtab1_itab-dat_trk_5
                       dat_trk_10 = zsdtab1_itab-dat_trk_10
                       dat_trk_15 = zsdtab1_itab-dat_trk_15
                       dat_trk_20 = zsdtab1_itab-dat_trk_20
                       dat_trk_25 = zsdtab1_itab-dat_trk_25
                       dat_trk_30 = zsdtab1_itab-dat_trk_30
                       dat_trk_35 = zsdtab1_itab-dat_trk_35
                       dat_trk_40 = zsdtab1_itab-dat_trk_40
                       dat_trk_45 = zsdtab1_itab-dat_trk_45
                       dat_trk_50 = zsdtab1_itab-dat_trk_50
                       dat_trk_55 = zsdtab1_itab-dat_trk_55
                       dat_trk_60 = zsdtab1_itab-dat_trk_60
                       dat_trk_65 = zsdtab1_itab-dat_trk_65
                       dat_trk_70 = zsdtab1_itab-dat_trk_70
                       dat_trk_75 = zsdtab1_itab-dat_trk_75
                       dat_trk_78 = zsdtab1_itab-dat_trk_78
                       dat_trk_79 = zsdtab1_itab-dat_trk_79
                       dat_trk_80 = zsdtab1_itab-dat_trk_80
                       dat_trk_85 = zsdtab1_itab-dat_trk_85
                       dat_trk_90 = zsdtab1_itab-dat_trk_90
                       dat_trk_95 = zsdtab1_itab-dat_trk_95
                       dattrk_100 = zsdtab1_itab-dattrk_100
                       dattrk_105 = zsdtab1_itab-dattrk_105
                       dattrk_110 = zsdtab1_itab-dattrk_110
                       dattrk_115 = zsdtab1_itab-dattrk_115
                       dattrk_120 = zsdtab1_itab-dattrk_120
                       pdt_tk_1 = zsdtab1_itab-pdt_tk_1
                       pdt_tk_5 = zsdtab1_itab-pdt_tk_5
                       pdt_tk_10 = zsdtab1_itab-pdt_tk_10
                       pdt_tk_15 = zsdtab1_itab-pdt_tk_15
                       pdt_tk_20 = zsdtab1_itab-pdt_tk_20
                       pdt_tk_25 = zsdtab1_itab-pdt_tk_25
                       pdt_tk_30 = zsdtab1_itab-pdt_tk_30
                       pdt_tk_35 = zsdtab1_itab-pdt_tk_35
                       pdt_tk_40 = zsdtab1_itab-pdt_tk_40
                       pdt_tk_45 = zsdtab1_itab-pdt_tk_45
                       pdt_tk_50 = zsdtab1_itab-pdt_tk_50
                       pdt_tk_55 = zsdtab1_itab-pdt_tk_55
                       pdt_tk_60 = zsdtab1_itab-pdt_tk_60
                       pdt_tk_65 = zsdtab1_itab-pdt_tk_65
                       pdt_tk_70 = zsdtab1_itab-pdt_tk_70
                       pdt_tk_75 = zsdtab1_itab-pdt_tk_75
                       pdt_tk_78 = zsdtab1_itab-pdt_tk_78
                       pdt_tk_79 = zsdtab1_itab-pdt_tk_79
                       pdt_tk_80 = zsdtab1_itab-pdt_tk_80
                       pdt_tk_85 = zsdtab1_itab-pdt_tk_85
                       pdt_tk_90 = zsdtab1_itab-pdt_tk_90
                       pdt_tk_95 = zsdtab1_itab-pdt_tk_95
                       pdt_tk_100 = zsdtab1_itab-pdt_tk_100
                       pdt_tk_105 = zsdtab1_itab-pdt_tk_105
                       pdt_tk_110 = zsdtab1_itab-pdt_tk_110
                       pdt_tk_115 = zsdtab1_itab-pdt_tk_115
                       pdt_tk_120 = zsdtab1_itab-pdt_tk_120
                       cartype = zsdtab1_itab-cartype
                       zelcl = zsdtab1_itab-zelcl
                       excise_no = zsdtab1_itab-excise_no
    where commno = zsdtab1_itab-commno .
       Update table .---------<<<
    endif .
    endloop .
    perform update_excise_date .
    perform update_post_goods_issue_date .
    perform update_time.
    *///////////////////// end of programe /////////////////////////////////
    Get sales data -
    form get_sales_order using matnr .
      data : corr_vbeln like vbrk-vbeln .
    ADDED BY ADITYA / 22.06.98 **************************************
    perform get_order using matnr .
    select single vbeln lgort into (zsdtab1_itab-vbeln , zsdtab1_itab-lgort)
                from vbap where matnr = matnr .   " C-22.06.98
                  from vbap where vbeln = zsdtab1_itab-vbeln .
      if sy-subrc = 0 .
    ************Get the Excise No from Allocation Field*******************
        select single * from zsdtab1 where commno = matnr .
        if zsdtab1-excise_no =  '' .
          select * from vbrp where matnr = matnr .
            select single vbeln into corr_vbeln from vbrk where
            vbeln = vbrp-vbeln and vbtyp = 'M'.
            if sy-subrc eq 0.
              select single * from vbrk where vbtyp = 'N'
              and sfakn = corr_vbeln.      "cancelled doc.
              if sy-subrc ne 0.
                select single * from vbrk where vbeln = corr_vbeln.
                if sy-subrc eq 0.
                  data : year(4) .
                  move sy-datum+0(4) to year .
      select single * from bkpf where awtyp = 'VBRK' and awkey = vbrk-vbeln
                                      and  bukrs = 'MBIL' and gjahr = year .
                  if sy-subrc = 0 .
      select single * from bseg where bukrs = 'MBIL' and belnr = bkpf-belnr
                                       and gjahr = year and koart = 'D' and
                                                               shkzg = 'S' .
                    zsdtab1_itab-excise_no = bseg-zuonr .
                  endif .
                endif.
              endif.
            endif.
          endselect.
        endif .
        select single kunnr vkbur into (zsdtab1_itab-kunnr ,
                zsdtab1_itab-vkbur) from vbak
                where vbeln = zsdtab1_itab-vbeln .
        if sy-subrc = 0 .
          select single name1 ort01 regio into (zsdtab1_itab-customer ,
             zsdtab1_itab-city , zsdtab1_itab-region) from kna1
             where kunnr = zsdtab1_itab-kunnr .
        endif.
      Get Ship to Party **************************************************
        select single * from vbpa where vbeln = zsdtab1_itab-vbeln and
                        parvw = 'WE' .
        if sy-subrc = 0 .
            zsdtab1_itab-ship_tp = vbpa-kunnr .
      Get Destination Country of Ship to Party .************
            select single * from kna1 where kunnr = vbpa-kunnr .
            if sy-subrc = 0 .
               select single * from t005t where land1 = kna1-land1
                                       and spras = 'E' .
               if sy-subrc = 0 .
                   zsdtab1_itab-country = t005t-landx .
               endif .
            endif .
        endif .
      endif .
    endform.                               " GET_SALES
    form update_time.
      update zstatus set zupddate = sy-datum
                         uzeit = sy-uzeit
      where programm = 'ZSDDET01' .
    endform.                               " UPDATE_TIME
    *&      Form  DATE_CONVERT
    form date_convert using atflv changing date .
      data : dt(8) , dat type i .
      dat = atflv .
      dt = dat .
      date = dt .
    endform.                               " DATE_CONVERT
    *&      Form  UPDATE_POST_GOODS_ISSUE_DATE
    form update_post_goods_issue_date .
      types : begin of itab1_type ,
                mblnr like mseg-mblnr ,
                budat like mkpf-budat ,
              end of itab1_type .
      data : itab1 type itab1_type occurs 10 with header line .
      loop at mara_itab .
        select single * from zsdtab1 where commno = mara_itab-matnr .
        if sy-subrc =  0  and zsdtab1-postdate =  '00000000' .
          refresh itab1 . clear itab1 .
        select * from mseg where matnr = mara_itab-matnr and bwart = '601' .
            itab1-mblnr = mseg-mblnr .
            append itab1 .
          endselect .
          loop at itab1 .
            select single * from mkpf where mblnr = itab1-mblnr .
            if sy-subrc = 0 .
              itab1-budat = mkpf-budat .
              modify itab1 .
            endif .
          endloop .
          sort itab1 by budat .
          read table itab1 index 1 .
          if sy-subrc = 0 .
            update zsdtab1 set postdate = itab1-budat
                         where commno = mara_itab-matnr .
          endif .
        endif .
      endloop .
    endform.                               " UPDATE_POST_GOODS_ISSUE_DATE
    *&      Form  UPDATE_EXCISE_DATE
    form update_excise_date.
      types : begin of itab2_type ,
                mblnr like mseg-mblnr ,
                budat like mkpf-budat ,
              end of itab2_type .
      data : itab2 type itab2_type occurs 10 with header line .
      loop at mara_itab .
        select single * from zsdtab1 where commno = mara_itab-matnr .
        if sy-subrc =  0  and zsdtab1-excise_dat  = '00000000' .
          refresh itab2 . clear itab2 .
          select * from mseg where matnr = mara_itab-matnr and
                                  (  bwart = '601' or  bwart = '311' ) .
            itab2-mblnr = mseg-mblnr .
            append itab2 .
          endselect .
          loop at itab2 .
            select single * from mkpf where mblnr = itab2-mblnr .
            if sy-subrc = 0 .
              itab2-budat = mkpf-budat .
              modify itab2 .
            endif .
          endloop .
          sort itab2 by budat .
          read table itab2 index 1 .
          if sy-subrc = 0 .
            update zsdtab1 set excise_dat = itab2-budat
                         where commno = mara_itab-matnr .
          endif .
        endif .
      endloop .
    endform.                               " UPDATE_EXCISE_DATE
    form get_order using matnr .
    types :  begin of itab_type ,
                vbeln like vbap-vbeln ,
                posnr like vbap-posnr ,
             end of itab_type .
    data : itab type itab_type occurs 10 with header line .
    refresh itab . clear itab .
    select * from vbap where matnr = mara_itab-matnr .
       itab-vbeln = vbap-vbeln .
       itab-posnr = vbap-posnr .
       append itab .
    endselect .
    loop at itab .
      select single * from vbak where vbeln = itab-vbeln .
      if vbak-vbtyp <> 'C' .
        delete itab .
      endif .
    endloop .
    loop at itab .
    select single * from vbfa where vbelv = itab-vbeln and
             posnv = itab-posnr and vbtyp_n = 'H' .
    if sy-subrc = 0 .
      delete itab .
    endif .
    endloop .
    clear :  zsdtab1_itab-vbeln ,  zsdtab1_itab-bill_doc .
    loop at itab .
      zsdtab1_itab-vbeln = itab-vbeln .
      select single * from vbfa where vbelv = itab-vbeln and
             posnv = itab-posnr and vbtyp_n = 'M' .
    if sy-subrc = 0 .
      zsdtab1_itab-bill_doc = vbfa-vbeln .
    endif .
    endloop .
    endform .
    *&      Form  GET_CARTYPE
    form get_cartype using matnr .
    select single * from mara where matnr = matnr .
    zsdtab1_itab-cartype = mara-satnr .
    endform.                    " GET_CARTYPE

    Hi,
    I have analysed your program and i would like to share following points for better performance of this report :
    (a)  Use the field Names instead of Select * or Select Single * as if you use the field names it will consume less amount of resources inside the loop as well as you have lot many Select Single * and u r using very big tables like VBAP and many more.
    (b) Trace on ST05 which particular query is mostly effecting your system or use ST12 in current mode to trace for less inputs which run the report for 20-30 min so that we get an idea which queries are effecting the system and taking a lot of time.
    (c) In Case of internal tables sort the data properly and use binary search for getting the data.
    I think this will help.
    Thanks and Regards,
    Harsh

  • Performance issue in Report (getting time out error)

    Hi experts,
    I am doing Performance for a Report (getting time out error)
    Please see the code below and .
    while looping internal table IVBAP after 25 minutes its showing  time out error at this poit ->
    SELECT MAX( ERDAT ) .
    please send alternate code for this .
    Advance thanks
    from
    Nagendra
    Get Sales Order Details
    CLEAR IVBAP.
    REFRESH IVBAP.
    SELECT VBELN POSNR MATNR NETWR KWMENG WERKS FROM VBAP
       INTO CORRESPONDING FIELDS OF TABLE IVBAP
         FOR ALL ENTRIES IN IVBAK
           WHERE VBELN =  IVBAK-VBELN
           AND   MATNR IN Z_MATNR
           AND   WERKS IN Z_WERKS
           AND   ABGRU = ' '.
    Check for Obsolete Materials - Get Product Hierarhy/Mat'l Description
      SORT IVBAP BY MATNR WERKS.
      CLEAR: WK_MATNR, WK_WERKS, WK_PRDHA, WK_MAKTX,
             WK_BLOCK, WK_MMSTA, WK_MSTAE.
      LOOP AT IVBAP.
          CLEAR WK_INVDATE.                                   "I6677.sn
          SELECT MAX( ERDAT ) FROM VBRP INTO WK_INVDATE WHERE
          AUBEL EQ IVBAP-VBELN AND
          AUPOS EQ IVBAP-POSNR.
          IF SY-SUBRC = 0.
              MOVE WK_INVDATE TO IVBAP-INVDT.
              MODIFY IVBAP.
          ENDIF.                                               "I6677.e n
          SELECT SINGLE * FROM MBEW WHERE             "I6759.sn
          MATNR EQ IVBAP-MATNR AND
          BWKEY EQ IVBAP-WERKS AND
          BWTAR EQ SPACE.
          IF SY-SUBRC = 0.
             MOVE MBEW-STPRS TO IVBAP-STPRS.
             IVBAP-TOT = MBEW-STPRS * IVBAP-KWMENG.
             MODIFY IVBAP.
          ENDIF.                                      "I6759.en
        IF IVBAP-MATNR NE WK_MATNR OR IVBAP-WERKS NE WK_WERKS.
          CLEAR: WK_BLOCK, WK_MMSTA, WK_MSTAE, WK_PRDHA, WK_MAKTX.
          MOVE IVBAP-MATNR TO WK_MATNR.
          MOVE IVBAP-WERKS TO WK_WERKS.
          SELECT SINGLE MMSTA FROM MARC INTO MARC-MMSTA
            WHERE MATNR = WK_MATNR
            AND   WERKS = WK_WERKS.
          IF NOT MARC-MMSTA IS INITIAL.
            MOVE '*' TO WK_MMSTA.
          ENDIF.
          SELECT SINGLE LVORM PRDHA MSTAE MSTAV FROM MARA
            INTO (MARA-LVORM, MARA-PRDHA, MARA-MSTAE, MARA-MSTAV)
            WHERE MATNR = WK_MATNR.
          IF ( NOT MARA-MSTAE IS INITIAL ) OR
             ( NOT MARA-MSTAV IS INITIAL ) OR
             ( NOT MARA-LVORM IS INITIAL ).
             MOVE '*' TO WK_MSTAE.
          ENDIF.
          MOVE MARA-PRDHA TO WK_PRDHA.
          SELECT SINGLE MAKTX FROM MAKT INTO WK_MAKTX
            WHERE MATNR = WK_MATNR
              AND SPRAS = SY-LANGU.
        ENDIF.
        IF Z_BLOCK EQ 'B'.
          IF WK_MMSTA EQ ' ' AND WK_MSTAE EQ ' '.
            DELETE IVBAP.
            CONTINUE.
          ENDIF.
        ELSEIF Z_BLOCK EQ 'U'.
          IF WK_MMSTA EQ '' OR WK_MSTAE EQ ''.
            DELETE IVBAP.
            CONTINUE.
          ENDIF.
        ELSE.
          IF WK_MMSTA EQ '' OR WK_MSTAE EQ ''.
            MOVE '*' TO WK_BLOCK.
          ENDIF.
        ENDIF.
        IF WK_PRDHA IN Z_PRDHA.                                    "I4792
          MOVE WK_BLOCK TO IVBAP-BLOCK.
          MOVE WK_PRDHA TO IVBAP-PRDHA.
          MOVE WK_MAKTX TO IVBAP-MAKTX.
          MODIFY IVBAP.
        ELSE.                                                     "I4792
          DELETE IVBAP.                                           "I4792
        ENDIF.                                                    "I4792
        IF NOT Z_ALNUM[] IS INITIAL.                              "I9076
          SELECT SINGLE * FROM MAEX                               "I9076
            WHERE MATNR = IVBAP-MATNR                             "I9076
              AND ALNUM IN Z_ALNUM.                               "I9076
          IF SY-SUBRC <> 0.                                       "I9076
            DELETE IVBAP.                                         "I9076
          ENDIF.                                                  "I9076
        ENDIF.                                                    "I9076
      ENDLOOP.

    Hi Nagendra!
    Get Sales Order Details
    CLEAR IVBAP.
    REFRESH IVBAP.
    check ivbak is not initial
    SELECT VBELN POSNR MATNR NETWR KWMENG WERKS FROM VBAP
    INTO CORRESPONDING FIELDS OF TABLE IVBAP
    FOR ALL ENTRIES IN IVBAK
    WHERE VBELN = IVBAK-VBELN
    AND MATNR IN Z_MATNR
    AND WERKS IN Z_WERKS
    AND ABGRU = ' '.
    Check for Obsolete Materials - Get Product Hierarhy/Mat'l Description
    SORT IVBAP BY MATNR WERKS.
    CLEAR: WK_MATNR, WK_WERKS, WK_PRDHA, WK_MAKTX,
    WK_BLOCK, WK_MMSTA, WK_MSTAE.
    avoid select widin loop. instead do selection outside loop.u can use read statement......and then loop if required.
    LOOP AT IVBAP.
    CLEAR WK_INVDATE. "I6677.sn
    SELECT MAX( ERDAT ) FROM VBRP INTO WK_INVDATE WHERE
    AUBEL EQ IVBAP-VBELN AND
    AUPOS EQ IVBAP-POSNR.
    IF SY-SUBRC = 0.
    MOVE WK_INVDATE TO IVBAP-INVDT.
    MODIFY IVBAP.
    ENDIF. "I6677.e n
    SELECT SINGLE * FROM MBEW WHERE "I6759.sn
    MATNR EQ IVBAP-MATNR AND
    BWKEY EQ IVBAP-WERKS AND
    BWTAR EQ SPACE.
    IF SY-SUBRC = 0.
    MOVE MBEW-STPRS TO IVBAP-STPRS.
    IVBAP-TOT = MBEW-STPRS * IVBAP-KWMENG.
    MODIFY IVBAP.
    ENDIF. "I6759.en
    IF IVBAP-MATNR NE WK_MATNR OR IVBAP-WERKS NE WK_WERKS.
    CLEAR: WK_BLOCK, WK_MMSTA, WK_MSTAE, WK_PRDHA, WK_MAKTX.
    MOVE IVBAP-MATNR TO WK_MATNR.
    MOVE IVBAP-WERKS TO WK_WERKS.
    SELECT SINGLE MMSTA FROM MARC INTO MARC-MMSTA
    WHERE MATNR = WK_MATNR
    AND WERKS = WK_WERKS.
    IF NOT MARC-MMSTA IS INITIAL.
    MOVE '*' TO WK_MMSTA.
    ENDIF.
    SELECT SINGLE LVORM PRDHA MSTAE MSTAV FROM MARA
    INTO (MARA-LVORM, MARA-PRDHA, MARA-MSTAE, MARA-MSTAV)
    WHERE MATNR = WK_MATNR.
    IF ( NOT MARA-MSTAE IS INITIAL ) OR
    ( NOT MARA-MSTAV IS INITIAL ) OR
    ( NOT MARA-LVORM IS INITIAL ).
    MOVE '*' TO WK_MSTAE.
    ENDIF.
    MOVE MARA-PRDHA TO WK_PRDHA.
    SELECT SINGLE MAKTX FROM MAKT INTO WK_MAKTX
    WHERE MATNR = WK_MATNR
    AND SPRAS = SY-LANGU.
    ENDIF.
    IF Z_BLOCK EQ 'B'.
    IF WK_MMSTA EQ ' ' AND WK_MSTAE EQ ' '.
    DELETE IVBAP.
    CONTINUE.
    ENDIF.
    ELSEIF Z_BLOCK EQ 'U'.
    IF WK_MMSTA EQ '' OR WK_MSTAE EQ ''.
    DELETE IVBAP.
    CONTINUE.
    ENDIF.
    ELSE.
    IF WK_MMSTA EQ '' OR WK_MSTAE EQ ''.
    MOVE '*' TO WK_BLOCK.
    ENDIF.
    ENDIF.
    IF WK_PRDHA IN Z_PRDHA. "I4792
    MOVE WK_BLOCK TO IVBAP-BLOCK.
    MOVE WK_PRDHA TO IVBAP-PRDHA.
    MOVE WK_MAKTX TO IVBAP-MAKTX.
    MODIFY IVBAP.
    ELSE. "I4792
    DELETE IVBAP. "I4792
    ENDIF. "I4792
    IF NOT Z_ALNUM[] IS INITIAL. "I9076
    SELECT SINGLE * FROM MAEX "I9076
    WHERE MATNR = IVBAP-MATNR "I9076
    AND ALNUM IN Z_ALNUM. "I9076
    IF SY-SUBRC 0. "I9076
    DELETE IVBAP. "I9076
    ENDIF. "I9076
    ENDIF. "I9076
    endloop.
    U have used many select queries widin loop-endloop which is a big hindrance as far as performance is concerned.Avoid such practice.
    Thanks
    Deepika

  • Performance issue of report

    Hi Friends,
    Can you please give me the exact answer for the below question.
    Suppose my report program is taking long time to execute, what are the reasons that may effect the report.
    and what are the remedies should i follow, please provide appropriate answer.
    Advance thanks,
    Chandra.

    hi,,
    Go to tranx SE30 here you will get Tips and Trciks for the performance tuning.
    Check it carefully and check whether you can do something for improving performance of you code.
    It will help you a lot and will reduce your Execution time.
    If you are using READ TABLE command in your program then you can check whether you can use HASHED TABLE it will improve performance of your code a lot but it has some restrictions.
    I will explain some of the points to improve the performance of the report try to write code according to that ok.
    SOME STEPS USED TO IMPROVE UR PERFORMANCE:
    1. Avoid using SELECT...ENDSELECT... construct and use SELECT ... INTO TABLE.
    2. Use WHERE clause in your SELECT statement to restrict the volume of data retrieved.
    3. Design your Query to Use as much index fields as possible from left to right in your WHERE statement
    4. Use FOR ALL ENTRIES in your SELECT statement to retrieve the matching records at one shot.
    5. Avoid using nested SELECT statement, SELECT within LOOPs.
    6. Avoid using INTO CORRESPONDING FIELDS OF TABLE. Instead use INTO TABLE.
    7. Avoid using SELECT * and Select only the required fields from the table.
    8. Avoid nested loops when working with large internal tables.
    9. Use assign instead of into in LOOPs for table types with large work areas
    10. When in doubt call transaction SE30 and use the examples and check your code
    11. Whenever using READ TABLE use BINARY SEARCH addition to speed up the search. Be sure to sort the internal table before binary search. This is a general thumb rule but typically if you are sure that the data in internal table is less than 200 entries you need not do SORT and use BINARY SEARCH since this is an overhead in performance.
    12. Use "CHECK" instead of IF/ENDIF whenever possible.
    13. Use "CASE" instead of IF/ENDIF whenever possible.
    14. Use "MOVE" with individual variable/field moves instead of "MOVE-
    CORRESPONDING", creates more coding but is more effcient.
    Reward points if helpful.
    regards,
    rekha

  • How to Populate Internal table data to Table Control in a Report Program

    Dear All,
           How to Populate Internal table data to Table Control in a Report Program? It is a pure report program with out any Module pool coding involved, which is just used to display data. Till now it is being displayed in a report. Now the user wants the data to be displayed in a table control. Could someone tell me how to go about with this.
    Thanks in Advance,
    Joseph Reddy

    If you want to use a table control, you will need to create a screen.
    In your report....
    start-of-selection.
    perform get_data.  " Get all your data here
    call screen 100. " Now present to the user.
    Double click on the "100" in your call screen statement.  This will forward navigate you to the screen.  If you have not created it yet, it will ask you if you want to create it, say yes.  Go into screen painter or layout of the screen.  Use the table control wizard to help you along the process.  It will write the code for you.  Since it is an output only table control, it will be really easy with not a lot of code. 
    A better way to present the data to the user would be to give it in a ALV grid.  If you want to go that way, it is a lot easier.  Here is a sample of the ALV function module.  You don't even have to create a screen.
    report zrich_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          maktx type makt-maktx,
          end of imara.
    * Selection Screen
    selection-screen begin of block b1 with frame title text-001 .
    select-options: s_matnr for imara-matnr .
    selection-screen end of block b1.
    start-of-selection.
      perform get_data.
      perform write_report.
    *  Get_Data
    form get_data.
      select  mara~matnr makt~maktx
                into corresponding fields of table imara
                  from mara
                   inner join makt
                     on mara~matnr = makt~matnr
                        where mara~matnr in s_matnr
                          and makt~spras = sy-langu.
    endform.
    *  WRITE_REPORT
    form write_report.
      perform build_field_catalog.
    * CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_fieldcat = fieldcat
           tables
                t_outtab    = imara.
    endform.
    * BUILD_FIELD_CATALOG
    form build_field_catalog.
      data: fc_tmp type slis_t_fieldcat_alv with header line.
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Number'.
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      fc_tmp-col_pos    = 2.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-col_pos    = 3.
      append fc_tmp to fieldcat.
    endform.
    Regards,
    Rich Heilman

  • Need help in the Report Program!!!

    Hi,
    This is SAI KUMAR.
    <b>Selection Screen</b>
    Sales Org: <b>VKORG</b>
    Distribution Channel: <b>VTWEG</b>
    Division: <b>SPART</b>
    Billing Type: <b>FKART</b>
    Plant: <b>WERKS</b>
    Payment Terms: <b>ZTERM</b>
    Sold-to Party: <b>KUNAG</b>
    Billing Date: <b>FKDAT</b>
    Now Using the above Selection screen inputs, I want to generate the following fields in the output.
    <b>Output Screen</b>
    Invoice No: <b>VBELN</b>
    Invoice Date: <b>FKDAT</b>
    Customer Number: <b>KUNNR</b>
    Customer Name: <b>NAME1</b>
    Material Description: <b>MAKTX</b>
    Payment Terms: <b>ZTERM</b>
    Net Value: <b>NETWR</b>
    Ship-to City: <b>ORT01</b>
    Sold-to party: <b>KUNAG</b>
    Ship-to party: <b>KUNNR</b>
    <u><b>Tables Used: </b></u>
    Delivery: <b>LIKP, LIPS</b>
    Invoice:<b>VBRK, VBRP</b>
    Customer: <b>KNA1</b>
    Material: <b>MARA</b>
    Material Description: <b>MAKT</b>
    <b>
    Now the Problem what I got is....How to link between these tables...ie., what common fields can be used between these tables so that I can use FOR ALL ENTRIES and retrieve the above output fields.</b>
    Can anyone please help me out in giving a REPORT program or a pseudo code for the above data.
    Thanks & Regards,
    SAI KUMAR
    <b>ID: [email protected]</b>

    See the below code :
    REPORT zjpvrom323 NO STANDARD PAGE HEADING LINE-SIZE 200 LINE-COUNT 35
    MESSAGE-ID zjpv001 .
    *& Development ID:   OM_DD_323_LJP                                    *
    *& Report        :   ZJPVROM323                                       *
    *& This application is used to Develop a new billing document that    *
    *& fulfills  the  NPKK  Requirement That does not exist in JSP        *
    *& functionality.according to the delivery date it displays Monthly   *
    sales notes report                                                *
    *& Change Log:                                                        *
    *&  Init.        Who             Date         Text                    *
    *& MALIKDH1     Seshu Reddy     2003/07/20   Initial Development      *
              Constants
    CONSTANTS :c_vkorg(4) VALUE 'JP20', " Sale Organization
               c_vtweg(2) VALUE 'TR',   " Distribution Channel
               c_rfbsk VALUE 'C',       " Status for transfer to accounting
               c_spart(2) VALUE '01',   " Division
               c_kvgr2(3) VALUE 'Z51',  " Customer Group 2
               c_fkart(4) TYPE c VALUE 'ZJPW', " Billing Type
               c_waerk(5) TYPE c VALUE 'JPY',  " SD document currency
               c_kschl(4) TYPE c VALUE 'ZJPC', " Condition type
               c_no_of_lines TYPE i VALUE '35',
               C_CONS_5(1) TYPE C VALUE '5',
               C_CONS_8(1) TYPE C VALUE '8',
               C_CONS_10(2) TYPE C VALUE '10',
               c_konwa(5) TYPE c VALUE 'JPY'. " Rate unit (currency or
    "            percentage)
              DB-Tables                                                *
    *TABLES : vbrk,           " Billing : Header Data
            vbrp,           " Billing : Item Data
            kna1,           " Customer master : General data
            knvv,           " Customer master : sales data
            likp,           " Delivery : Header data
            konv,           " Condition : Transaction data
            konp,           " Condition : items
            zjpv_torihiki,  " Add on table:Business transaction category
            zjpv_rebate.    " Add on table : rebate table
               Variables/Internal table                                 *
    DATA :g_date(2) TYPE n,           " Date
          g_month(2) TYPE n,          " Month
          g_year(4) TYPE n ,          " Year
          g_bill_low(10) TYPE n,       " From date
          g_bill_high(10) TYPE n,      " To date
          g_month1(2) TYPE n,         " Month
          g_year1(4) TYPE n,          " Year
          g_date1(2) TYPE n,          " Date
          g_year2(4) TYPE n,          " Year
          g_datum LIKE sy-datum,      " System date
          g_skip(4) TYPE c ,          " Line break
          g_ctax(8) TYPE c,           " Consumption tax
          g_ctax1(10) TYPE c,         " Consumption tax
          g_ctax2(16) TYPE c,         " Consumption tax
          g_vol(6) TYPE c,            " Volume
          g_vol1(6) TYPE c,           " Volume
          g_vol2(7) TYPE c,           " Volume
          g_tamt(10) TYPE c,          " Total amount
          g_tamt1(13) TYPE c,         " Total amount
          g_tamt2(16) TYPE c,         " Total amount
          g_gtotal(10) TYPE c,        " Net total
          g_gtotal1(13) TYPE c,       " Net total
          g_gtotal2(16) TYPE c,       " Net total
          g_uprice(8)  TYPE c,        " Unit Price
          g_uprice1(10)  TYPE c,      " Unit Price
          g_uprice2(11)  TYPE c,      " Unit Price
          g_amount(10) TYPE c,        " Amount
          g_amount1(13) TYPE c,       " Amount
          g_amount2(14) TYPE c,       " Amount
          g_fctax(16) TYPE c,      " Consumption Tax (Total)
          g_ftamnt(16) TYPE c,     " Total amount (Total)
          g_ftotal(16) TYPE c,     " net total (Total)
          g_fctax1(8) TYPE c,      " Totals with Comma (Consumption tax)
          g_fctax2(10) TYPE c,     " Totals with Comma (Consumption tax)
          g_fctax3(11) TYPE c,     " Totals with Comma (Consumption tax)
          g_ftamt1(10) TYPE c,     " Totals with comma (Total amount)
          g_grand_total(16),
          g_grand_total1(14),
          g_net_total(16),
          g_net_total1(14),
          g_middle_val(16),
          g_middle_val1(11),
          g_ftamt2(13) TYPE c,     " Totals with Comma(Total amount)
          g_ftamt3(14) TYPE c,     " Totals with comma(Total amount)
          g_ftotal1(10) TYPE c,    " Totals with comma(Net total)
          g_ftotal2(13) TYPE c,    " Totals with comma(Net total)
          g_ftotal3(14) TYPE c.    " Totals with comma(Net total)
    *Internal table for billing document header
    DATA : BEGIN OF t_vbrk OCCURS 0,
           vbeln LIKE vbrk-vbeln,      " Billing Doc number
           vbtyp LIKE vbrk-vbtyp,      " Document Category
           kunag LIKE vbrk-kunag,      " sold-to-party
           vkorg LIKE vbrk-vkorg,      " sales organization
           vtweg LIKE vbrk-vtweg,      " Distribution Channel
           kunrg LIKE vbrk-kunrg,      " Payer
           fkart_rl LIKE vbrk-fkart_rl," Billing Type
           fkdat LIKE vbrk-fkdat,      " Billing date
           mwsbk LIKE vbrk-mwsbk,      " Tax amount in document currency
           netwr LIKE vbrk-netwr,      " Net value in document currency
           waerk LIKE vbrk-waerk,      " SD document currency
           knumv LIKE vbrk-knumv,      " Number of the document condition
           END OF t_vbrk.
    internal table for Output formatting
    DATA : BEGIN OF t_oput OCCURS 0,
           rbcode(4) TYPE c,                     " Regulating Branch Code
           tpcode(10)  TYPE c,                   " trading partner code
           bdgrp(3) TYPE c,                      " Billing Document Group
           zjd_torihikikubn(3) TYPE c,           "   business transaction
                                                  "category
           tpname1(35) TYPE c,                   " trading partner name 1
           tpname2(35) TYPE c,                   " trading partner name 2
           bdgnm(10) TYPE c,                     " Billing Doc Group Name
           dcode(10) TYPE c,                     " destination code
           dname(35),                            " destination name
           fkdat(10) TYPE c,                     " Date of Issue
           vbeln(10) TYPE c,                     " Billing Doc No
           zzjp_remarks(30) TYPE c,              " Remarks
           ctax(16) TYPE c,                      " Consumption Tax
           tamnt(16) TYPE c,                    " Total Amount
           gtotal(16) TYPE c,                    " Grand total,
           pcode(9) TYPE n,                      " Product Code
           pname(40) TYPE c,                     " Product name
           volume(16) TYPE p decimals 3,          " volume
           volume1 type i,
           volume2(16) type c,
           uprice(13) TYPE c,                    " Unit Price
           amount(16) TYPE c,                    " Amount
           posnr(6) TYPE n,                      " Billing Item
           END OF t_oput.
    *Internal table for Customer Master Sales Data
    DATA : BEGIN OF t_knvv OCCURS 0,
           kunnr LIKE knvv-kunnr, " Customer Number
           vkorg LIKE knvv-vkorg, " Sales Organization
           vtweg LIKE knvv-vtweg, " Distribution Channel
           spart LIKE knvv-spart, " Division
           kvgr2 LIKE knvv-kvgr2, " Customer Group 2
           vkbur LIKE knvv-vkbur, " sales office
           END OF t_knvv.
    *Internal table for Customer Master Data
    DATA : BEGIN OF t_kna1 OCCURS 0,
           kunnr LIKE kna1-kunnr,   " Customer number
           name1 LIKE kna1-name1,   " Customer Name 1
           name2 LIKE kna1-name2,   " Customer Name 2
           END OF t_kna1.
    Internal table used for billing document items
    DATA : BEGIN OF t_vbrp OCCURS 0,
           vbeln LIKE vbrp-vbeln,                       " Billing Document
           posnr LIKE vbrp-posnr,        " Billing item
           zjd_torihikikubn LIKE vbrp-zjd_torihikikubn, " Business
                                                      " Transaction Category
           vgbel LIKE vbrp-vgbel,                   " Document number of the
                                                    "   reference  document
           vgtyp LIKE vbrp-vgtyp,                   " Document category of
                                                    " preceding SD document
           zzjp_remarks LIKE vbrp-zzjp_remarks,     " Remarks
           zjd_kanamei LIKE vbrp-zjd_kanamei,
           fkimg LIKE vbrp-fkimg,                   " Actual billed quantity
           netwr LIKE vbrp-netwr,        " Net value of the
                                         " billing item in document currency
           zjd_touitsumatnr LIKE vbrp-zjd_touitsumatnr,
           END OF t_vbrp.
    Internal table used for Rebate Table
    DATA : BEGIN OF t_zjpv_rebate OCCURS 0,
           fkart LIKE zjpv_rebate-fkart,              " Billing type
           rebate_code LIKE zjpv_rebate-rebate_code,  " Rebate Code
           rebate_name LIKE zjpv_rebate-rebate_name,  " Rebate Name
           END OF t_zjpv_rebate.
    *Internal table used for Delivery Header
    DATA : BEGIN OF t_likp OCCURS 0,
           vbeln LIKE likp-vbeln,    " Delivery  No
           kunnr LIKE likp-kunnr,    " Ship-to party
           END OF t_likp.
    *Internal table for conditions (Transaction Data)
    DATA : BEGIN OF t_konv OCCURS 0,
           knumv LIKE konv-knumv,      " Number of the document condition
           kposn LIKE konv-kposn,      " Condition item number
           kschl LIKE konv-kschl,      " Condition type
           knumh LIKE konv-knumh,      " Condition type
           END OF t_konv.
    Internal table for conditions (Item)
    DATA : BEGIN OF t_konp OCCURS 0,
           knumh LIKE konp-knumh,      " Number of the document condition
           kbetr LIKE konp-kbetr,      " Rate (condition amount or
                                       " percentage) where no scale exists
           konwa LIKE konp-konwa,      " Rate unit (currency or percentage)
           END OF t_konp.
    Internal table for table Torihiki Kubun
    DATA : BEGIN OF t_zjpv_torihiki OCCURS 0,
           kubun LIKE zjpv_torihiki-kubun,      " Condition type
           rep_grp LIKE zjpv_torihiki-rep_grp,   " Shikiri Report Group
           rep_grp_name LIKE zjpv_torihiki-rep_grp_name, " Shikiri Report
                                                         " Group NAME
           END OF t_zjpv_torihiki.
    DATA:  l_tpname1(35) TYPE c,                   " trading partner name 1
           l_tpname2(35) TYPE c,                   " trading partner name 2
           l_bdgnm(10) TYPE c,                     " Billing Doc Group Name
           G_FLG(1)    type c,
           G_FLG1(1)    type c.
              Selection screen                                           *
    SELECTION-SCREEN : BEGIN OF BLOCK zjpv WITH FRAME TITLE text-001.
    PARAMETER : p_date LIKE sy-datum OBLIGATORY. " Delivery date
    SELECTION-SCREEN : END OF BLOCK zjpv.
    RANGES : r_bdate  FOR vbrk-fkdat.             " Billing date
           Initialization                                                *
    INITIALIZATION.
      p_date = sy-datum.
               MAIN PROCESSING                                           *
    START-OF-SELECTION.
    This Perform is used for getting Billing date  According to Delivery
    Date(Output date)
      PERFORM f_bill_date_move.
    Selecting the data from tables VBRK,VBRP,KNVV,KNA1,KONV,KONP,LIKP,
    ZJPV_TORIHIKI and ZJPV_REBATE
      PERFORM f_get_data.
    Passing the data from the internal tables (T_VBRK,T_VBRP,T_KNVV,
    T_KNA1,T_KONV,T_KONP,T_LIKP, T_ZJPV_TORIHIKI and T_ZJPV_REBATE)
    to out put Internal table(T_OPUT)
      PERFORM f_process_data.
              END OF SELECTION                                          *
    END-OF-SELECTION.
    Out put formatting
      PERFORM f_output_data.
    *&      Form  F_Bill_DATE_MOVE
    This Perform is used for getting Billing date  According to Delivery *
    Date(Output date)                                                    *
    FORM f_bill_date_move.
      g_datum = p_date + 10.
      g_month = g_datum+4(2).
      g_year = g_datum+0(4).
      IF g_month = 1.
        g_year = g_year - 1.
        g_month = 12.
        g_date = 1.
      ELSE.
        g_month = g_month - 1.
        g_date = 1.
      ENDIF.
    Passing the date to billing date-low
      CONCATENATE  g_year g_month g_date  INTO g_bill_low.
      r_bdate-low = g_bill_low.
      r_bdate-sign = 'I'.
      r_bdate-option = 'BT'.
      g_month1 = g_datum+4(2).
      g_year1 = g_datum+0(4).
      IF g_month1 = 1.
        g_year1 = g_year1 - 1.
        g_month1 = 12.
      ELSE.
        g_month1 = g_month1 - 1.
      ENDIF.
      CASE g_month1.
        WHEN 1.g_date1 = '31'.
        WHEN 3.g_date1 = '31'.
        WHEN 4.g_date1 = '30'.
        WHEN 5.g_date1 =  '31'.
        WHEN 6.g_date1 = '30'.
        WHEN 7.g_date1 = '31'.
        WHEN 8.g_date1 = '31'.
        WHEN 9.g_date1 = '30'.
        WHEN 10.g_date1 = '31'.
        WHEN 11.g_date1 = '30'.
        WHEN 12.g_date1 = '31'.
      ENDCASE.
      g_year2 = g_year1.
      IF g_month1 = 2.
        g_year2 = g_year2 MOD 4 .
        IF g_year2 = 0.
          g_date1 = 29.
        ELSE.
          g_date1 = 28.
        ENDIF.
      ENDIF.
    Passing the date to billing date-high
      CONCATENATE  g_year1  g_month1  g_date1 INTO g_bill_high.
      r_bdate-high = g_bill_high.
      APPEND r_bdate.
    ENDFORM.                    " F_Bill_DATE_MOVE
    *&      Form  f_get_data
    Selecting the data from tables VBRK,VBRP,KNVV,KNA1,KONV,KONP,LIKP,   *
    ZJPV_TORIHIKI and ZJPV_REBATE                                        *
    FORM f_get_data.
    Selecting the data from VBRK into internal table T_VBRK.
      SELECT   vbeln
               vbtyp
               kunag
               vkorg
               vtweg
               kunrg
               fkart_rl
               fkdat
               mwsbk
               netwr
               waerk
               knumv
               FROM vbrk
               INTO TABLE t_vbrk
               WHERE fkdat BETWEEN r_bdate-low and r_bdate-high
                     and RFBSK = C_RFBSK
                     AND  vbtyp IN ('N' , 'S' , 'M' , 'O' , 'P')
                     AND vkorg = c_vkorg
                     AND vtweg = c_vtweg
                     AND netwr <> 0.
      IF sy-subrc Eq 0.
        sort t_vbrk.
      ENDIF.
    Selecting the data from KNVV into internal table T_KNVV.
      SELECT kunnr
             vkorg
             vtweg
             spart
             kvgr2
             vkbur
             FROM knvv
             INTO TABLE t_knvv
             FOR ALL ENTRIES IN t_vbrk WHERE ( kunnr = t_vbrk-kunag
                                       OR    kunnr = t_vbrk-kunrg )
                                       AND   vkorg = t_vbrk-vkorg
                                       AND   vtweg = t_vbrk-vtweg
                                       AND   spart = c_spart
                                       AND   kvgr2 = c_kvgr2.
    Selecting the data from VBRP into internal table T_VBRP.
      SELECT vbeln
             posnr
             zjd_torihikikubn
             vgbel
             vgtyp
             zzjp_remarks
             zjd_kanamei
             fkimg
             netwr
             zjd_touitsumatnr
             FROM vbrp
             INTO TABLE  t_vbrp
             FOR ALL ENTRIES IN t_vbrk
             WHERE vbeln = t_vbrk-vbeln.
    Selecting the data from ZJPV_REBATE into internal table T_ZJPV_REBATE.
      SELECT fkart
             rebate_code
             rebate_name
             FROM zjpv_rebate
             INTO TABLE t_zjpv_rebate
             FOR ALL ENTRIES IN t_vbrk
             WHERE fkart = t_vbrk-fkart_rl.
    Selecting the data from KNA1 into internal table T_KNA1.
      SELECT kunnr
             name1
             name2
             FROM kna1
             INTO TABLE t_kna1
             FOR ALL ENTRIES IN t_knvv
             WHERE kunnr = t_knvv-kunnr.
      IF NOT t_vbrp[] IS INITIAL.
    Selecting the data from LIKP into internal table T_LIKP.
        SELECT vbeln
               kunnr
               FROM likp
               INTO TABLE t_likp
               FOR ALL ENTRIES IN t_vbrp
               WHERE vbeln = t_vbrp-vgbel.
      ENDIF.
    Selecting the data from KONV into internal table T_KONV.
      SELECT knumv
             kposn
             kschl
             knumh
             FROM konv
             INTO TABLE t_konv
             FOR ALL ENTRIES IN t_vbrk
             WHERE knumv = t_vbrk-knumv
             AND   kschl = c_kschl.
    Selecting the data from KONP into internal table T_KONP.
      SELECT knumh
             kbetr
             konwa
             FROM konp
             INTO TABLE t_konp
             FOR ALL ENTRIES IN t_konv
             WHERE knumh = t_konv-knumh.
    Selecting the data from ZJPV_TORIHIKI into internal table
    T_ZJPV_TORIHIKI.
      SELECT kubun
             rep_grp
             rep_grp_name
             FROM zjpv_torihiki
             INTO TABLE t_zjpv_torihiki
             FOR ALL ENTRIES IN t_vbrp
             WHERE kubun = t_vbrp-zjd_torihikikubn.
    ENDFORM.                    " f_get_data
    *&      Form  f_process_data
    Reading The Data from Internal tables (T_VBRK,T_VBRP,T_KNVV,T_KNA1,  *
    T_LIKP,T_KONV,T_KONP,T_ZJPV_REBATE and T_ZJP_TORIHIKI)               *
    FORM f_process_data.
    Sorting the internal table t_kna1, t_vbrk, t_vbrp ,t_knvv,t_kna1,
    t_likp and t_zjpv_rebate
      SORT: t_kna1 BY kunnr,
            t_vbrk BY vbeln,
            t_vbrp BY vbeln,
            t_knvv BY kunnr,
            t_zjpv_rebate BY fkart,
            t_knvv BY kunnr vkorg vtweg spart,
            t_likp BY vbeln.
      LOOP AT t_vbrk.
    Reading the data from internal table t_knvv
        READ TABLE t_knvv WITH KEY kunnr = t_vbrk-kunag
                                     vkorg = t_vbrk-vkorg
                                     vtweg = t_vbrk-vtweg
                                     spart = c_spart
                                     kvgr2 = c_kvgr2.
        IF sy-subrc NE 0.
          g_flg = 'X'.
        ENDIF.
    Reading the data from internal table t_knvv
        READ TABLE t_knvv WITH KEY kunnr = t_vbrk-kunrg
                                    vkorg = t_vbrk-vkorg
                                    vtweg = t_vbrk-vtweg
                                    spart = c_spart
                                    kvgr2 = c_kvgr2.
        IF sy-subrc NE 0.
          G_FLG1 = 'X'.
        ENDIF.
        IF G_FLG = 'X' AND G_FLG1 = 'X'.
          DELETE T_VBRK.
          CLEAR: G_FLG, G_FLG1.
          CONTINUE.
        ENDIF.
      ENDLOOP.
      DATA :  l_sign(1) TYPE c VALUE '-',
              l_ctax(15) TYPE n ,
              l_tamnt(15) TYPE n ,
              l_volume(16) TYPE c,
              l_gtotal(15) TYPE n,
              l_amnt(15) TYPE n.
      SORT t_konv BY knumv kposn kschl.
      SORT t_konp BY knumh.
      LOOP AT t_vbrp.
        READ TABLE t_vbrk WITH KEY vbeln = t_vbrp-vbeln.
        IF sy-subrc <> 0.
          DELETE t_vbrp.
          CONTINUE.
        ENDIF.
    Reading the data from Internal table T_zjpv_rebate(Rebate table)
        READ TABLE t_zjpv_rebate WITH KEY
                            fkart = t_vbrk-fkart_rl
                            BINARY SEARCH.
        IF sy-subrc NE 0 OR t_vbrk-fkart_rl EQ c_fkart.
          MOVE t_vbrk-kunag TO t_oput-tpcode.
        ELSE .
          IF t_vbrk-fkart_rl NE c_fkart.
            MOVE t_vbrk-kunrg TO t_oput-tpcode.
          ENDIF.
        ENDIF.
        READ TABLE t_zjpv_rebate WITH KEY
                            fkart = t_vbrk-fkart_rl
                            BINARY SEARCH.
        IF sy-subrc NE 0.
    Passing the last 6 values of ZJD_TOUITSUMANTR into product code.
          MOVE t_vbrp-zjd_touitsumatnr+3(6) TO t_oput-pcode.
          MOVE t_vbrp-zjd_kanamei TO t_oput-pname.
        ELSE.
          MOVE t_zjpv_rebate-rebate_code+3(6) TO t_oput-pcode.
          MOVE t_zjpv_rebate-rebate_name TO t_oput-pname.
        ENDIF.
    Reading the data from Internal table T_KNA1(Customer Master)
        READ TABLE t_kna1 WITH KEY
                     kunnr = t_oput-tpcode BINARY SEARCH.
        IF sy-subrc = 0.
          MOVE t_kna1-name1 TO t_oput-tpname1.
          MOVE t_kna1-name2 TO t_oput-tpname2.
        ENDIF.
    Reading the data from Internal table T_vbrp(Billing Documnet: Item)
        MOVE t_vbrp-zjd_torihikikubn TO t_oput-zjd_torihikikubn.
    Reading the data from Internal table T_KNVV
        READ TABLE t_knvv WITH KEY kunnr = t_vbrk-kunrg
                                   vkorg = c_vkorg
                                   vtweg = c_vtweg
                                   spart = c_spart
                                   BINARY SEARCH.
        IF sy-subrc EQ 0.
          MOVE t_knvv-vkbur TO t_oput-rbcode.
        ENDIF.
    Reading the data from Internal table T_LIKP (Delivery : Header)
        IF  t_vbrp-vgtyp =  'J' OR t_vbrp-vgtyp = 'T'.
          READ TABLE t_likp WITH KEY
                        vbeln = t_vbrp-vgbel
                        BINARY SEARCH.
          IF sy-subrc = 0.
            MOVE t_likp-kunnr TO t_oput-dcode.
          ENDIF.
        ENDIF.
    Reading the data from Internal table T_KNA1.
        READ TABLE t_kna1 WITH KEY kunnr = t_likp-kunnr BINARY SEARCH.
        IF sy-subrc = 0 AND NOT t_oput-dcode IS INITIAL.
          MOVE t_kna1-name2 TO t_oput-dname.
        ENDIF.
    *Passing the values from internal table t_vbrk and t_vbrp to
    *out put internal table.
        MOVE t_vbrk-fkdat TO t_oput-fkdat.
        CONCATENATE t_oput-fkdat0(4) '.' t_oput-fkdat4(2) '.'
            t_oput-fkdat+6(2) INTO t_oput-fkdat.
        MOVE t_vbrk-vbeln TO t_oput-vbeln.
        MOVE t_vbrp-posnr TO t_oput-posnr.
        MOVE t_vbrp-zzjp_remarks TO t_oput-zzjp_remarks.
    *Checking for billing document category.
        IF t_vbrk-vbtyp = 'M' OR t_vbrk-vbtyp = 'P' OR t_vbrk-vbtyp = 'S'.
          IF t_vbrk-waerk = c_waerk.
            t_oput-ctax = t_vbrk-mwsbk * 100.
            t_oput-tamnt = t_vbrk-netwr * 100.
            t_oput-gtotal = t_oput-ctax + t_oput-tamnt.
          ELSE.
            t_oput-ctax = t_vbrk-mwsbk .
            t_oput-tamnt = t_vbrk-netwr.
            t_oput-gtotal = t_oput-ctax + t_oput-tamnt.
          ENDIF.
        ENDIF.
        IF t_vbrk-vbtyp = 'O' OR  t_vbrk-vbtyp = 'N' .
          IF t_vbrk-waerk = c_waerk.
            l_ctax = ( t_vbrk-mwsbk * 100 ) .
    *The contents of the consumption tax are converted to display format.
            PERFORM F_ALPHA_CONV USING L_CTAX.
            CONCATENATE l_sign l_ctax INTO t_oput-ctax.
            CONDENSE t_oput-ctax.
            l_tamnt  = ( t_vbrk-netwr * 100 ).
    *The contents of the total amount are converted to display format.
            PERFORM F_ALPHA_CONV USING L_TAMNT.
            CONCATENATE l_sign l_tamnt INTO t_oput-tamnt.
            CONDENSE t_oput-tamnt.
            l_gtotal = t_oput-ctax + t_oput-tamnt.
    *The contents of the grand total are converted to display format.
            PERFORM F_ALPHA_CONV USING L_GTOTAL.
            CONCATENATE l_sign l_gtotal INTO t_oput-gtotal.
          ELSE.
            l_ctax = t_vbrk-mwsbk.
    *The contents of the consumption tax are converted to display format.
            PERFORM F_ALPHA_CONV USING L_CTAX.
            CONCATENATE l_sign l_ctax INTO t_oput-ctax.
            l_tamnt = ( t_vbrk-netwr ).
    *The contents of the total amount are converted to display format.
            PERFORM F_ALPHA_CONV USING L_TAMNT.
            CONCATENATE l_sign l_tamnt INTO t_oput-tamnt.
            l_gtotal =  ( t_oput-ctax + t_oput-tamnt ).
    *The contents of the grand total are converted to display format.
            PERFORM F_ALPHA_CONV USING L_GTOTAL.
            CONCATENATE l_sign l_gtotal INTO t_oput-gtotal.
          ENDIF.
        ENDIF.
    Comparing the volume with given conditions.
        IF t_vbrp-fkimg EQ 0.
          t_oput-volume = space.
        ELSEIF t_vbrp-fkimg NE 0.
         IF t_vbrk-vbtyp = 'M' OR  t_vbrk-vbtyp = 'P' OR t_vbrk-vbtyp = 'S'.
            t_oput-volume = t_vbrp-fkimg.
            CALL FUNCTION 'ROUND'
                 EXPORTING
                      DECIMALS      = 3
                      input         = t_oput-volume
                      SIGN          = ' '
                 IMPORTING
                      OUTPUT        = t_oput-volume1
                 EXCEPTIONS
                      INPUT_INVALID = 1
                      OVERFLOW      = 2
                      TYPE_INVALID  = 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.
            move t_oput-volume1 to t_oput-volume2.
            condense t_oput-volume2 no-gaps.
          ELSEIF t_vbrk-vbtyp = 'O' OR  t_vbrk-vbtyp = 'N'.
            t_oput-volume = t_vbrp-fkimg.
            CALL FUNCTION 'ROUND'
                 EXPORTING
                      DECIMALS      = 3
                      input         = t_oput-volume
                      SIGN          = ' '
                 IMPORTING
                      OUTPUT        = t_oput-volume1
                 EXCEPTIONS
                      INPUT_INVALID = 1
                      OVERFLOW      = 2
                      TYPE_INVALID  = 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.
            l_volume = t_oput-volume1.
    *The contents of the volume are converted to display format.
            PERFORM F_ALPHA_CONV USING L_VOLUME.
            CONCATENATE l_sign l_volume INTO t_oput-volume2.
            condense t_oput-volume2 no-gaps.
          ENDIF.
        ENDIF.
    *Unit price
        IF t_vbrp-fkimg EQ 0.
          t_oput-uprice = space.
        ELSE.
    Reading The data from Internal Table T_KONV(Condition :Transactional)
          READ TABLE t_konv WITH KEY   knumv = t_vbrk-knumv
                                       kposn = t_vbrp-posnr
                                       kschl = c_kschl
                                       BINARY SEARCH.
          IF sy-subrc = 0.
    Reading The data from Internal Table T_KONP(Condition : Items)
            READ TABLE t_konp WITH KEY
                    knumh = t_konv-knumh
                    BINARY SEARCH.
            IF sy-subrc = 0.
              IF t_konp-konwa = c_konwa.
                t_oput-uprice = 100 * t_konp-kbetr.
              ELSE.
                t_oput-uprice = t_konp-kbetr.
              ENDIF.
            ENDIF.
          ENDIF.
        ENDIF.
    Caluculating the amount with given conditions
        IF t_zjpv_rebate-fkart = t_vbrk-fkart_rl.
          t_oput-amount = t_vbrk-netwr.
        ELSE.
          t_oput-amount = t_vbrp-netwr.
        ENDIF.
        IF t_vbrk-waerk EQ c_waerk.
          t_oput-amount =  100 * t_oput-amount.
        ENDIF.
        IF t_vbrk-vbtyp ='M' OR t_vbrk-vbtyp = 'P' OR
                               t_vbrk-vbtyp  = 'S'.
        ELSE.
          IF t_vbrk-vbtyp  = 'O' OR t_vbrk-vbtyp = 'N'.
            IF t_oput-amount+15(1) = l_sign.
              l_amnt = t_oput-amount+0(15).
              PERFORM F_ALPHA_CONV USING L_AMNT.
              CONCATENATE l_sign l_amnt INTO t_oput-amount.
            ELSE.
              l_amnt = t_oput-amount.
              PERFORM F_ALPHA_CONV USING L_AMNT.
              CONCATENATE l_sign l_amnt INTO t_oput-amount.
            ENDIF.
          ENDIF.
        ENDIF.
    Reading the data from Internal Table T_ZPV_TORIHIKI
        READ TABLE t_zjpv_torihiki WITH KEY
                   kubun = t_vbrp-zjd_torihikikubn
                   BINARY SEARCH.
        IF sy-subrc = 0.
          t_oput-bdgrp = t_zjpv_torihiki-rep_grp.
          t_oput-bdgnm = t_zjpv_torihiki-rep_grp_name.
        ENDIF.
        APPEND t_oput.
    Clearing the memory of the internal tables.
        CLEAR: t_oput,
               t_vbrp,
               t_vbrk,
               t_kna1,
               t_knvv,
               t_zjpv_rebate,
               t_zjpv_torihiki,
               t_likp,
               t_konv,
               t_konp.
      ENDLOOP.
    ENDFORM.                    " f_process_data
    *&      Form  f_output_data
          Output formatting
    FORM f_output_data.
    SORT t_oput BY rbcode
                    tpcode
                    bdgrp
                    fkdat
                    zjd_torihikikubn
                    vbeln
                    posnr.
      DATA : l_volume(5) TYPE c,
             l_ctax(8) TYPE c.
      MOVE t_oput-volume TO l_volume.
      MOVE t_oput-ctax TO l_ctax.
      DATA : l_ctax1(16) ,
             l_ctax2(16),
             l_vol1(14) ,
             l_vol3(8),
             l_vol2(14),
             l_tamt1(16),
             l_tamt2(16),
             l_gtotal1(16),
             l_gtotal2(16),
             l_uprice1(16),
             l_uprice2(16),
             l_amount1(16) TYPE c,
             l_amount2(16) TYPE c,
             l_fctax1(16) TYPE c,
             l_fctax2(16) TYPE c,
             l_ftamt1(16) TYPE c,
             l_ftamt2(16) TYPE c,
             l_ftotal1(16) TYPE c,
             l_ftotal2(16) TYPE c,
             l_sign(1) TYPE c VALUE '-'.
      CONSTANTS c_minus VALUE '-'.
      SORT t_konv BY knumv kposn kschl.
      SORT t_oput BY zjd_torihikikubn vbeln posnr.
    Printing Final Values.
      LOOP AT t_oput.
    Perform F_FORMAT_SUBTOTAL is used to align the value with the commas
    for display purpose.
        L_CTAX2 = T_OPUT-CTAX.
        G_CTAX2 = T_OPUT-CTAX.
        PERFORM F_FORMAT_SUBTOTAL USING G_CTAX2
                                        C_CONS_8.
        CONDENSE T_OPUT-CTAX.
    Perform F_FORMAT_SUBTOTAL is used to align the value with the commas
    for display purpose.
        L_TAMT2 = T_OPUT-TAMNT.
        G_TAMT2 = T_OPUT-TAMNT.
        PERFORM F_FORMAT_SUBTOTAL USING G_TAMT2
                                        C_CONS_10.
        CONDENSE T_OPUT-TAMNT.
    Perform F_FORMAT_SUBTOTAL is used to align the value with the commas
    for display purpose.
        L_GTOTAL2 = T_OPUT-GTOTAL.
        G_GTOTAL2 = T_OPUT-GTOTAL.
        PERFORM F_FORMAT_SUBTOTAL USING G_GTOTAL2
                                        C_CONS_10.
        CONDENSE T_OPUT-GTOTAL.
    Perform F_FORMAT_SUBTOTAL is used to align the value with the commas
    for display purpose.
    *Volume
        IF t_oput-volume >= 99999 OR t_oput-volume <= -99999.
          t_oput-volume = space.
        ELSE.
          l_vol1 = t_oput-volume.
          l_vol2 = t_oput-volume.
          CONDENSE l_vol1.
          CONDENSE l_vol2.
          IF  l_vol1+0(1) EQ '-'.
            REPLACE '-' WITH space INTO  l_vol1.
          ENDIF.
          CONDENSE l_vol1.
          WRITE l_vol1 TO g_vol RIGHT-JUSTIFIED.
          REPLACE '.' WITH ',' INTO l_vol1.
    write :85 l_vol1.
          IF NOT g_vol+0(2) IS  INITIAL.
            g_vol10(2) = g_vol0(2).
            g_vol1+2(1) = ','.
          ENDIF.
          IF NOT g_vol+2(3) IS  INITIAL.
            g_vol13(3) = g_vol2(3).
          ENDIF.
    replace '.' with ',' into t_oput-volume.
          l_vol2 = t_oput-volume.
          IF  l_vol2+0(1) EQ '-'.
            g_vol2 = g_vol1 .
            CONDENSE g_vol2.
            CONCATENATE c_minus g_vol2 INTO g_vol2.
          ELSE.
            g_vol2 = g_vol1 .
            CONDENSE g_vol2.
          ENDIF.
        ENDIF.
    L_VOL1 = T_OPUT-VOLUME.
    PERFORM F_FORMAT_SUBTOTAL USING L_VOL1
                                     C_CONS_5.
    CONDENSE L_VOL1.
    Unit Price
        IF t_oput-uprice >= 99999999 OR t_oput-uprice <= -99999999.
          t_oput-uprice = space.
        ELSE.
          l_uprice1 = t_oput-uprice .
          l_uprice2 = t_oput-uprice.
          CONDENSE l_uprice1.
          CONDENSE l_uprice2.
          IF  l_uprice1+0(1) EQ '-'.
            REPLACE '-' WITH space INTO  l_uprice1.
          ENDIF.
          CONDENSE l_uprice1.
          WRITE l_uprice1 TO g_uprice RIGHT-JUSTIFIED.
          IF NOT g_uprice+0(2) IS  INITIAL.
            g_uprice10(2) = g_uprice0(2).
            g_uprice1+2(1) = ','.
          ENDIF.
          IF NOT g_uprice+2(3) IS  INITIAL.
            g_uprice13(3) = g_uprice2(3).
            g_uprice1+6(1) = ','.
          ENDIF.
          IF NOT g_uprice+5(3) IS  INITIAL.
            g_uprice17(3) = g_uprice5(3).
          ENDIF.
          IF  l_uprice2+0(1) EQ '-'.
            g_uprice2 = g_uprice1 .
            CONDENSE g_uprice2.
            CONCATENATE c_minus g_uprice2 INTO g_uprice2.
          ELSE.
            g_uprice2 = g_uprice1 .
            CONDENSE g_uprice2.
          ENDIF.
        ENDIF.
    Amount
        IF t_oput-amount >= 99999999 OR t_oput-amount <= -99999999 .
          t_oput-amount = space.
        ELSE.
          l_amount1 = t_oput-amount.
          l_amount2 = t_oput-amount.
          CONDENSE l_amount1.
          CONDENSE l_amount2.
          IF  l_amount1+0(1) EQ '-'.
            REPLACE '-' WITH space INTO  l_amount1.
          ENDIF.
          CONDENSE l_amount1.
          WRITE l_amount1 TO g_amount RIGHT-JUSTIFIED.
          IF NOT g_amount+0(1) IS  INITIAL.
            g_amount0(1) = g_amount0(1).
            g_amount1+1(1) = ','.
          ENDIF.
          IF NOT g_amount+1(3) IS  INITIAL.
            g_amount12(3) = g_amount1(3).
            g_amount1+5(1) = ','.
          ENDIF.
          IF NOT g_amount+4(3) IS  INITIAL.
            g_amount16(3) = g_amount4(3).
            g_amount1+9(1) = ','.
          ENDIF.
          IF NOT g_amount+7(3) IS  INITIAL.
            g_amount110(3) = g_amount7(3).
          ENDIF.
          IF  l_amount2+0(1) EQ '-'.
            g_amount2 = g_amount1 .
            CONDENSE g_amount2.
            CONCATENATE c_minus g_amount2 INTO g_amount2.
          ELSE.
            g_amount2 = g_amount1 .
            CONDENSE g_amount2.
          ENDIF.
        ENDIF.
       NEW-PAGE.
        MOVE t_oput-tpname1 TO l_tpname1.
        MOVE t_oput-tpname2 TO l_tpname2.
        MOVE t_oput-bdgnm   TO l_bdgnm.
        AT NEW bdgrp.
          IF t_oput-rbcode CO '*'.
            t_oput-rbcode = space.
          ENDIF.
          IF t_oput-tpcode CO '*'.
            t_oput-tpcode = space.
          ENDIF.
          IF t_oput-tpname1 CO '*'.
            t_oput-tpname1 = space.
          ENDIF.
          IF t_oput-tpname2 CO '*'.
            t_oput-tpname2 = space.
          ENDIF.
          IF t_oput-bdgnm CO '*'.
            t_oput-bdgnm = space.
          ENDIF.
          PERFORM f_write_heading.
        ENDAT.
        AT NEW vbeln.
          IF sy-linno = 35 OR sy-linno = 1.
            NEW-PAGE.
            PERFORM f_write_heading.
            WRITE:/6 t_oput-fkdat , 18 t_oput-dcode+3(7) ,
                   28 t_oput-vbeln+2(8) ,
                   37 t_oput-dname+0(20) .
          ELSE.
            WRITE:/6 t_oput-fkdat , 18 t_oput-dcode+3(7) ,
                   28 t_oput-vbeln+2(8) ,
                   37 t_oput-dname+0(20) .
          ENDIF.
        ENDAT.
       WRITE:/6 t_oput-fkdat, 18 t_oput-dcode+3(7),
              28 t_oput-vbeln+2(8),
              37 t_oput-dname+0(20).
        IF sy-linno = 35 OR sy-linno = 1.
          NEW-PAGE.
          PERFORM f_write_heading.
             CONDENSE L_VOL1 NO-GAPS.
          MOVE l_vol1 TO l_vol3.
          WRITE:/6 t_oput-fkdat , 18 t_oput-dcode+3(7) ,
                 28 t_oput-vbeln+2(8) ,
                 37 t_oput-dname+0(20) .
          WRITE:/39 t_oput-pcode+3(6) ,
                 50 t_oput-pname+0(25) ,
                 79 t_oput-zjd_torihikikubn ,
                 85 t_oput-volu

  • Performance analysis of report or transaction

    Hello Experts,
    How do we analyse the performance of a report or a transacton in SAP. I want to know thetransactions and the steps that needs to be followed in order to get this.
    points are guaranteed...
    thanks
    sankar

    hi,
    SE30 - gives you a run time analysis and points out the issues more at design time.
    ST05 - Is the most useful if you want to track time taken for execution of each of the sections.
    SM50 - Will give you a work process overview, not sure at a program level how can it help you.
    Some times you will have to use a combination of SE30 and ST05.
    I would like to use St05 personally.
    SQL Trace (ST05) we use for performance tuning
    In se38,you have a report and you want to test the performance of that report
    ST05 tells about the summary of sql statements used in that program.
    -Go to Tcode ST05
    -Select Trace on
    -In se38,Execute your report-
    -Come back to st05 and select Trace off
    -Select Trace list.
    Now you check your select stmnts and how much time taking
    -Some columns showing pink color are expensive select stmnts
    You have so many options inside to check for summary and also index..
    http://help.sap.com/saphelp_47x200/helpdata/en/f2/31adaa810c11d288ec0000e8200722/frameset.htm
    ST02 --> Memory management
    ST03 --> Dialog Service
    OS06 --> Operating System
    SCI --> Code Inspector
    Regards
    Reshma

  • Choose fields option in Selection Screen of report program.

    Hi Experts,
          Actually In my requirement , the user wants to display the output fields in ALV Grid and also in Block ALV format.They need 10 fields to be displayed by default and the additional fields has to be displayed based on the choose fields option
    ( i.e like SE11 choose fields option ) provided in the selection screen of this report program.So based on this the output has to be displayed.
    Pls suggest ur ideas.....
    Thanks in advance.
    Regards,
    Srinivas.

    Hi ,
    The following code will be helpful for your requirement...
    REPORT  ypm_hist_dyn.
    *              T Y P E - P O O L S                *
    TYPE-POOLS: slis.
    *                   T Y P E S                     *
    TYPES :   BEGIN OF t_equz,
                datbi TYPE datbi,     " Valid To Date
                equnr TYPE equnr,     " Equipment Number
                erdat TYPE erdat,     " Date on Which Record Was Created
                aedat TYPE aedat,    " Changed On
                iloan TYPE iloan,     " Location and account assignment for technical object
                gewrk TYPE lgwid,     " Object ID of the Work Center
                ingrp TYPE ingrp,      " Planner Group for Customer Service and Plant Maintenance
             END OF t_equz,
               BEGIN OF t_equz1,
                 datbi TYPE datbi,     " Valid To Date
                 equnr TYPE equnr,     " Equipment Number
                 erdat TYPE erdat,     " Date on Which Record Was Created
                 aedat TYPE aedat,    " Changed On
              END OF t_equz1,
              BEGIN OF t_iloa,
                iloan TYPE iloan,   "Location and account assignment for technical object
                tplnr TYPE tplnr,    " Functional Location
                msgrp TYPE raumnr,  " Room
             END OF t_iloa,
             BEGIN OF t_iflotx,
               tplnr TYPE tplnr,   "Functional Location
               pltxt TYPE pltxt,  " Description of functional location
             END OF t_iflotx,
            BEGIN OF t_equi,
              equnr TYPE equnr,   " Equipment Number
              eqart TYPE eqart,   "Type of Technical Object
           END OF t_equi,
           BEGIN OF t_crhd,
              objid TYPE cr_objid,  "Object ID of the resource
              arbpl TYPE arbpl,     "Work center
          END OF t_crhd,
              BEGIN OF t_eqkt,
              equnr TYPE equnr,    "Equipment Number
              eqktx TYPE ktx01,    "Description of technical object
              END OF t_eqkt,
              BEGIN OF t_t370k_t,
              eqart TYPE eqart,  "Type of Technical Object
              eartx TYPE eartx,  "Text for Object Type
              END OF t_t370k_t,
              BEGIN OF t_t024i,
              ingrp TYPE ingrp,  "Planner Group for Customer Service and Plant Maintenance
              innam TYPE innam,  "Name of the Maintenance Planner Group
              END OF t_t024i,
              BEGIN OF t_viqmel,
              equnr TYPE equnr,  "Equipment Number
              qmnum TYPE qmnum,  "Notification No
              qmdat TYPE qmdat,  "Date of Notification
              bequi TYPE bequi,  "Equipment Affected
              iloan TYPE iloan,  "Location and account assignment for technical object
              END OF t_viqmel,
              BEGIN OF t_final,
               equnr TYPE equz-equnr,
               eqktx TYPE eqkt-eqktx,
               tplnr TYPE iloa-tplnr,
               pltxt TYPE iflotx-pltxt,
               iloan TYPE iloan,
               datbi TYPE equz-datbi,
               ingrp TYPE t024i-ingrp,
               erdat TYPE equz-erdat,
               enddt1 TYPE char10,
               aedat TYPE equz-aedat,
               innam TYPE t024i-innam,
               equart TYPE equi-eqart,
               eartx TYPE t370k_t-eartx,
              qmnum TYPE viqmel-qmnum,
              arbpl TYPE crhd-arbpl,
              msgrp TYPE iloa-msgrp,
              dat_diff TYPE char10,
              END OF t_final,
              BEGIN OF t_final1,
               equnr TYPE equz-equnr,
               eqktx TYPE eqkt-eqktx,
               tplnr TYPE iloa-tplnr,
               pltxt TYPE iflotx-pltxt,
              END OF t_final1.
    DATA:   it_equz TYPE STANDARD TABLE OF t_equz,
            it_iloa TYPE STANDARD TABLE OF t_iloa,
            it_iflotx TYPE STANDARD TABLE OF t_iflotx,
            it_equi TYPE STANDARD TABLE OF t_equi,
            it_crhd TYPE STANDARD TABLE OF t_crhd,
            it_eqkt TYPE STANDARD TABLE OF t_eqkt,
            it_t370k_t TYPE STANDARD TABLE OF t_t370k_t,
            it_t024i TYPE STANDARD TABLE OF  t_t024i,
            it_viqmel TYPE STANDARD TABLE OF  t_viqmel,
            it_final TYPE STANDARD TABLE OF t_final,
            it_final1 TYPE STANDARD TABLE OF t_final1,
            it_equz1 TYPE STANDARD TABLE OF t_equz1.
    DATA:   wa_equz TYPE  t_equz,
           wa_iloa TYPE t_iloa,
           wa_iflotx TYPE  t_iflotx,
           wa_equi TYPE  t_equi,
           wa_crhd TYPE t_crhd,
           wa_eqkt TYPE t_eqkt,
           wa_t370k_t TYPE  t_t370k_t,
           wa_t024i TYPE  t_t024i,
           wa_viqmel TYPE t_viqmel,
           wa_final TYPE t_final,
           wa_final1 TYPE t_final1,
           wa_equz1 TYPE t_equz.
    DATA: t_equnr TYPE equz-equnr,          "EQUZ-EQUNR
          t_tplnr TYPE iloa-tplnr,          "Functional Location
          t_datbi TYPE equz-datbi,          "Date
          t_ingrp TYPE equz-ingrp,          "Planner Group
          t_eqart TYPE equi-eqart,          "Technical Object
          w_diff TYPE p,
          w_time TYPE t.
    *            ALV DATA DECLARATION                 *
    * Field Catalog
    TYPES:  BEGIN OF t_fldnam,
              fld TYPE fieldname,
              desc TYPE char30,
            END OF t_fldnam.
    DATA:   is_layout TYPE slis_layout_alv,
            it_fieldcat TYPE slis_t_fieldcat_alv,
            is_fieldcat TYPE slis_fieldcat_alv,
            it_fldnam TYPE STANDARD TABLE OF t_fldnam,
            wa_fldnam TYPE t_fldnam,
            it_sort TYPE STANDARD TABLE OF slis_t_sortinfo_alv,
            wa_sort LIKE LINE OF it_sort.
    DATA:   i_events   TYPE slis_t_event,
            ls_line TYPE slis_listheader,
            gt_list_top_of_page TYPE slis_t_listheader,  "FOR TOP OF PAGE
            gt_list_end_of_page TYPE slis_t_listheader.  "FOR END OF PAGE
    DATA : formname_top_of_page TYPE slis_formname VALUE
                                                  'GENERATE_TOP_OF_PAGE',
           formname_end_of_page TYPE slis_formname VALUE
                                                  'GENERATE_END_OF_PAGE',
           formname_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
    *                C O N S T A N T S                *
    *CONSTANTS: c_top         TYPE slis_formname VALUE 'TOP_OF_PAGE',
    *           c_final(40)   TYPE c VALUE 'IT_FINAL',
    *           c_detail(15)  TYPE c VALUE 'IT_FINAL1'.
    DATA :      g_save(1) TYPE c,
          g_exit(1) TYPE c,
          g_variant LIKE disvariant,
          gx_variant LIKE disvariant.
    *        S E L E C T I O N   S C R E E N          *
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_equnr FOR t_equnr,
                    s_tplnr FOR   t_tplnr,
                    s_datbi FOR  t_datbi ,
                    s_ingrp FOR t_ingrp,
                    s_eqart FOR t_eqart.
    SELECTION-SCREEN: END OF BLOCK b1.
    SELECTION-SCREEN  :  BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 3(16) text-007.
    SELECTION-SCREEN POSITION 22.
    PARAMETERS        :  11_flds RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND g1.
    SELECTION-SCREEN COMMENT 39(13) text-009.
    SELECTION-SCREEN POSITION 54.
    PARAMETERS        :  6_flds RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN  :  END OF BLOCK blk2.
    SELECTION-SCREEN:BEGIN OF BLOCK b2 WITH FRAME TITLE text-003.
    PARAMETERS:     alv_list RADIOBUTTON GROUP gp1 DEFAULT 'X'.
    PARAMETERS:  alv_grid RADIOBUTTON GROUP gp1.
    SELECTION-SCREEN:END OF BLOCK b2.
    SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE text-005.
    PARAMETERS  : p_vari LIKE disvariant-variant.
    SELECTION-SCREEN: END OF BLOCK b3.
    AT SELECTION-SCREEN.
      PERFORM date_range.
      IF s_datbi[] IS INITIAL.
        MESSAGE e398(00) WITH 'ENTER A VALUE FOR DATE'(012).
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
      PERFORM f4_for_variant.
    START-OF-SELECTION.
      IF 11_flds EQ 'X'.
        PERFORM fill_equz.
        PERFORM fill_iloa.
        PERFORM fill_iflotx.
        PERFORM fill_equi.
        PERFORM fill_t370k_t.
        PERFORM fill_t024i.
        PERFORM fill_crhd.
        PERFORM fill_eqkt.
        PERFORM fill_viqmel.
      ELSE.
        PERFORM fill_equz.
        PERFORM fill_iloa.
        PERFORM fill_iflotx.
        PERFORM haha_final.
        PERFORM dyn_tab.
      ENDIF.
      PERFORM fill_final.
      PERFORM get_day_diff.
    *                      END-OF-SELECTION                                *
    END-OF-SELECTION.
    *Display Output in ALV Format
    *  PERFORM populate_layout.
      PERFORM populate_fcat.
      PERFORM populate_events .
    *  PERFORM gen_top.
      PERFORM display_alv .
    *&      Form  FILL_EQUZ
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_equz .
      IF s_datbi-high IS INITIAL.
        s_datbi-high = '99990701'.
      ENDIF.
    *  IF s_datbi-LOW IS INITIAL.
    *    s_datbi-LOW = '20071201'.
    *  ENDIF.
        SELECT datbi
                equnr
                erdat
                aedat
                iloan
                gewrk
                ingrp
                FROM equz
            INTO CORRESPONDING FIELDS OF TABLE  it_equz
    *      WHERE datbi IN s_datbi AND equnr IN s_equnr.
            WHERE equnr IN s_equnr
             AND  ingrp IN s_ingrp
             AND  datbi LE s_datbi-high
            AND  datbi GE s_datbi-low.
    ENDFORM.                    " FILL_EQUZ
    *&      Form  FILL_ILOA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_iloa .
      SELECT iloan
              tplnr
              msgrp
             INTO CORRESPONDING FIELDS OF TABLE it_iloa
              FROM iloa
              FOR ALL ENTRIES IN it_equz
              WHERE iloan = it_equz-iloan.
    ENDFORM.                    " FILL_ILOA
    *&      Form  FILL_IFLOTX
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_iflotx .
      SELECT tplnr
              pltxt
              INTO CORRESPONDING FIELDS OF TABLE it_iflotx
              FROM iflotx
              FOR ALL ENTRIES IN it_iloa
              WHERE tplnr = it_iloa-tplnr.
    ENDFORM.                    " FILL_IFLOTX
    *&      Form  FILL_EQUI
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_equi .
      SELECT equnr
            eqart
            INTO CORRESPONDING FIELDS OF TABLE  it_equi
            FROM equi
            FOR ALL ENTRIES IN it_equz
            WHERE equnr = it_equz-equnr.
    ENDFORM.                    " FILL_EQUI
    *&      Form  FILL_T370K_T
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_t370k_t .
      SELECT eqart
            eartx
            INTO CORRESPONDING FIELDS OF TABLE it_t370k_t
            FROM t370k_t
            FOR ALL ENTRIES IN it_equi
            WHERE eqart = it_equi-eqart.
    ENDFORM.                    " FILL_T370K_T
    *&      Form  FILL_T024I
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_t024i .
      SELECT ingrp
              innam
              INTO CORRESPONDING FIELDS OF TABLE it_t024i
              FROM t024i
              FOR ALL ENTRIES IN it_equz
              WHERE ingrp = it_equz-ingrp.
    ENDFORM.                    " FILL_T024I
    *&      Form  FILL_CRHD
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_crhd .
      SELECT objid
              arbpl
              INTO CORRESPONDING FIELDS OF TABLE it_crhd
              FROM crhd
              FOR ALL ENTRIES IN it_equz
              WHERE objid = it_equz-gewrk.
    ENDFORM.                    " FILL_CRHD
    *&      Form  FILL_EQKT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_eqkt .
      SELECT equnr
             eqktx
             INTO CORRESPONDING FIELDS OF TABLE it_eqkt
             FROM eqkt
             FOR ALL ENTRIES IN it_equz
             WHERE equnr = it_equz-equnr.
    ENDFORM.                    " FILL_EQKT
    *&      Form  FILL_VIQMEL
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_viqmel .
    ENDFORM.                    " FILL_VIQMEL
    *&      Form  SHW_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM shw_data .
      LOOP AT it_final1 INTO wa_final1.
        WRITE : wa_final1-equnr , wa_final1-eqktx , wa_final1-tplnr , wa_final1-pltxt.
        CLEAR wa_final1.
      ENDLOOP.
    ENDFORM.                    " SHW_DATA
    *&      Form  POPULATE_LAYOUT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    *FORM populate_layout .
    *  is_layout-zebra = 'X'.
    *  is_layout-colwidth_optimize = 'X'.
    *  APPEND is_layout.
    *ENDFORM.                    " POPULATE_LAYOUT
    *&      Form  POPULATE_FCAT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM populate_fcat .
      IF 11_flds EQ 'X'.
        APPEND 'EQUNR                         EQUIP NUMBER         ' TO it_fldnam.
        APPEND 'EQKTX                         DESC OF EQUIP        '  TO it_fldnam.
        APPEND 'ERDAT                         START DATE           ' TO it_fldnam.
        APPEND 'DATBI                         END DATE             ' TO it_fldnam.
        APPEND 'AEDAT                         CHND ON              '  TO it_fldnam.
        APPEND 'ILOAN                         LOC ON ACCOUNT       '  TO it_fldnam.
        APPEND 'TPLNR                         FUNC LOC             '  TO it_fldnam.
        APPEND 'PLTXT                         DESC FUNC LOC        '  TO it_fldnam.
        APPEND 'INGRP                         PLANNER GRP          '  TO it_fldnam.
        APPEND 'INNAM                         MAINT PLN GRP        '  TO it_fldnam.
        APPEND 'DAT_DIFF                      DATE DIFF            '  TO it_fldnam.
      ENDIF.
      IF 6_flds EQ 'X'.
        APPEND 'TPLNR                         FUNC LOCATION        ' TO it_fldnam.
        APPEND 'PLTXT                         DESC OF FUC LOC      ' TO it_fldnam.
        APPEND 'DATBI                         END DATE             ' TO it_fldnam.
        APPEND 'EQUNR                         EQUIP NUMBER         ' TO it_fldnam.
        APPEND 'ERDAT                         START DATE           ' TO it_fldnam.
        APPEND 'AEDAT                         CHND ON              '  TO it_fldnam.
      ENDIF.
    ENDFORM.                    " POPULATE_FCAT
    *&      Form  DISPLAY_ALV
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_alv .
    *--------------------------------------------------Preparing the Layout*
      is_layout-colwidth_optimize = 'X'.
      is_layout-zebra = 'X'.
    *-------------------------------------------Preparing the Field Catalog*
        BREAK-POINT.
      LOOP AT it_fldnam INTO wa_fldnam.
        is_fieldcat-tabname       = 'IT_FINAL'.
        is_fieldcat-fieldname     = wa_fldnam-fld.
        is_fieldcat-seltext_l     = wa_fldnam-desc.
        is_fieldcat-col_pos       = sy-tabix.
        IF wa_fldnam-fld = 'EQKTX'.
          is_fieldcat-lowercase       = ' '.
        ENDIF.
        APPEND is_fieldcat TO it_fieldcat.
        CLEAR : is_fieldcat, wa_fldnam.
      ENDLOOP.
    *-------------------------------------------------------Calling Display*
      IF alv_list = 'X'.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            i_callback_program = sy-repid
            is_layout          = is_layout
            it_fieldcat        = it_fieldcat
            it_events          = i_events[]
            i_default          = 'X'
          TABLES
            t_outtab           = it_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.
      ELSE.
    *    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *      EXPORTING
    *        i_callback_program     = sy-repid
    *        i_callback_top_of_page = 'GEN_TOP'
    *        is_layout              = is_layout
    *        it_fieldcat            = it_fieldcat
    *        it_events              = i_events[]
    *        i_save                 = g_save
    *        is_variant             = g_variant
    *        i_default              = 'A'
    *      TABLES
    *        t_outtab               = it_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.
        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          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
           i_callback_top_of_page            = 'GEN_TOP'
    *   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                         = is_layout
           it_fieldcat                       = it_fieldcat
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
           i_save                            = 'A'
    *   IS_VARIANT                        = g_variant
    *   IT_EVENTS                         = i_events[]
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 20
    *   I_SCREEN_START_LINE               = 30
    *   I_SCREEN_END_COLUMN               = 100
    *   I_SCREEN_END_LINE                 = 40
    *   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_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.
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV
    *&      Form  GET_DAY_DIFF
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_day_diff .
      w_time = '00:00:00'.
      FIELD-SYMBOLS: <deb> LIKE LINE OF it_final.
      LOOP AT it_final ASSIGNING <deb>.
        CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
          EXPORTING
            date1                  = <deb>-datbi
            time1                  = w_time
            date2                  = <deb>-erdat
            time2                  = w_time
         IMPORTING
           datediff               = w_diff
    *   TIMEDIFF               =
    *   EARLIEST               =
    * EXCEPTIONS
    *   INVALID_DATETIME       = 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.
        ELSEIF sy-subrc = 0.
          <deb>-dat_diff = w_diff.
    *      MODIFY it_final FROM WA_FINAL TRANSPORTING dat_diff.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " GET_DAY_DIFF
    *&      Form  HAHA_FINAL
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM haha_final .
    *  FIELD-SYMBOLS: <deb> LIKE LINE OF it_final.
      LOOP AT it_iflotx INTO wa_iflotx.
    *    wa_final1-equnr = wa_iflotx-equnr.
    *    wa_final1-eqktx = wa_iflotx-eqktx.
        wa_final1-tplnr = wa_iflotx-tplnr.
        wa_final1-pltxt = wa_iflotx-pltxt.
        APPEND wa_final1 TO it_final1.
      ENDLOOP.
    ENDFORM.                    " HAHA_FINAL
    *&      Form  DYN_TAB
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM dyn_tab .
      LOOP AT it_equz INTO wa_equz.
        wa_equz1-datbi = wa_equz-datbi.
        wa_equz1-equnr = wa_equz-equnr.
        wa_equz1-erdat = wa_equz-erdat.
        wa_equz1-aedat = wa_equz-aedat.
        APPEND wa_equz1 TO it_equz1.
      ENDLOOP.
    ENDFORM.                    " DYN_TAB
    *&      Form  FILL_FINAL1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_final.
      IF 11_flds EQ 'X'.
        FIELD-SYMBOLS: <deb> LIKE LINE OF it_equz,
                     <deb1> LIKE LINE OF it_final.
        CLEAR wa_equz.
        REFRESH : it_final[].
        LOOP AT it_equz ASSIGNING <deb>.
          wa_final-equnr = <deb>-equnr.
          wa_final-datbi = <deb>-datbi.
          wa_final-erdat = <deb>-erdat.
          wa_final-aedat = <deb>-aedat.
          wa_final-iloan = <deb>-iloan.
          wa_final-ingrp = <deb>-ingrp.
          APPEND wa_final TO it_final.
          CLEAR wa_final.
        ENDLOOP.
        LOOP AT it_final ASSIGNING <deb1>.
          READ TABLE it_iloa INTO wa_iloa WITH KEY iloan = <deb1>-iloan.
          <deb1>-tplnr = wa_iloa-tplnr.
        ENDLOOP.
        LOOP AT it_final ASSIGNING <deb1>.
          READ TABLE it_iflotx INTO wa_iflotx WITH KEY tplnr = <deb1>-tplnr.
          <deb1>-pltxt = wa_iflotx-pltxt.
        ENDLOOP.
        LOOP AT it_final ASSIGNING <deb1>.
          READ TABLE it_eqkt INTO wa_eqkt WITH KEY equnr = <deb1>-equnr.
          <deb1>-eqktx = wa_eqkt-eqktx.
        ENDLOOP.
        LOOP AT it_final ASSIGNING <deb1>.
          READ TABLE it_t024i INTO wa_t024i WITH KEY ingrp = <deb1>-ingrp.
          <deb1>-innam = wa_t024i-innam.
        ENDLOOP.
      ELSE.
        REFRESH : it_final[].
        LOOP AT it_equz INTO wa_equz.
          wa_final-datbi = wa_equz-datbi.
          wa_final-equnr = wa_equz-equnr.
          wa_final-erdat = wa_equz-erdat.
          wa_final-aedat = wa_equz-aedat.
          wa_final-iloan = wa_equz-iloan.
          APPEND wa_final TO it_final.
          CLEAR wa_final.
        ENDLOOP.
        FIELD-SYMBOLS: <deb2> LIKE LINE OF it_final.
        LOOP AT it_final ASSIGNING <deb2>.
          READ TABLE it_iloa INTO wa_iloa WITH KEY iloan = <deb2>-iloan.
          <deb2>-tplnr = wa_iloa-tplnr.
        ENDLOOP.
        LOOP AT it_final ASSIGNING <deb2>.
          READ TABLE it_iflotx INTO wa_iflotx WITH KEY tplnr = <deb2>-tplnr.
          <deb2>-pltxt = wa_iflotx-pltxt.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " FILL_FINAL
    *&      Form  DATE_RANGE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM date_range .
      DATA :l_dat TYPE i.
      IF s_datbi-high IS NOT INITIAL.
        CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
          EXPORTING
            i_datum_bis             = s_datbi-high
            i_datum_von             = s_datbi-low
          IMPORTING
            e_tage                  = l_dat
          EXCEPTIONS
            days_method_not_defined = 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.
        IF l_dat GT '31'.
          MESSAGE e398(00) WITH 'Split Your Planning for a range of 31 Days'(012).
          LEAVE LIST-PROCESSING.
        ENDIF.
      ENDIF.
    ENDFORM.                    " DATE_RANGE
    *&      Form  GEN_TOP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM gen_top .
      DATA: info(60),
            w_dt TYPE d.
      CLEAR ls_line.
      ls_line-typ = 'H'.
      ls_line-info = 'ALV DISPLAY'.
      APPEND ls_line TO gt_list_top_of_page.
      CONCATENATE 'Date :' s_datbi-low ' TO ' s_datbi-high INTO info SEPARATED BY space.
      CLEAR ls_line.
      ls_line-typ = 'S'.
      ls_line-info = info.
      APPEND ls_line TO gt_list_top_of_page.
      CLEAR ls_line.
      ls_line-typ = 'A'.
      ls_line-info = 'By Debarshi Roy'.
      APPEND ls_line TO gt_list_top_of_page.
    * Generate the End of Page
    *  CLEAR ls_line.
    *  ls_line-typ = 'H'.
    *  ls_line-info = 'ECL'.
    *  APPEND ls_line TO gt_list_end_of_page.
      CLEAR: ls_line.
    *  PERFORM generate_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = gt_list_top_of_page
          i_logo             = 'DEB'.
    ENDFORM.                    " GEN_TOP
    *&      Form  POPULATE_EVENTS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM populate_events .
      DATA: l_i_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = i_events[].
    *----- Pass top-of-page
      READ TABLE i_events WITH KEY name = slis_ev_top_of_page
                               INTO l_i_event.
      IF sy-subrc = 0.
        MOVE formname_top_of_page TO l_i_event-form.
        APPEND l_i_event TO i_events.
      ENDIF.
      CLEAR l_i_event.
    *----- Pass end-of-page
      READ TABLE i_events WITH KEY name = slis_ev_end_of_page
                               INTO l_i_event.
      IF sy-subrc = 0.
        MOVE formname_end_of_page TO l_i_event-form.
        APPEND l_i_event TO i_events.
      ENDIF.
      CLEAR l_i_event.
    *----- Pass user-command
      READ TABLE i_events WITH KEY name = slis_ev_user_command
                               INTO l_i_event.
      IF sy-subrc = 0.
        MOVE formname_user_command TO l_i_event-form.
        APPEND l_i_event TO i_events.
      ENDIF.
    ENDFORM.                    " POPULATE_EVENTS
    *&      Form  generate_top_of_page
    *       text
    *FORM generate_top_of_page.
    *  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    *    EXPORTING
    *      it_list_commentary = gt_list_top_of_page
    *      i_logo             = 'DEB'.
    *ENDFORM.                    "generate_top_of_page
    *&      Form  generate_end_of_page
    *       text
    FORM generate_end_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = gt_list_end_of_page
    *   I_LOGO                   =
    ENDFORM.                    "generate_end_of_page
    *&      Form  F4_FOR_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM f4_for_variant .
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = g_variant
          i_save     = g_save
        IMPORTING
          e_exit     = g_exit
          es_variant = gx_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 2.
        MESSAGE ID sy-msgid TYPE 'S'      NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        IF g_exit = space.
          p_vari = gx_variant-variant.
        ENDIF.
      ENDIF.
    ENDFORM.                    " F4_FOR_VARIANT

  • Need example report program using PNPCE LDB in SAP HR

    Need example report program using PNPCE LDB in SAP HR.
    and how to create a report category in sap hr for using it as cutomised selection screen.

    Hi,
    Go through the following links, i hope it will help you.....
    /people/alvaro.tejadagalindo/blog/2006/02/19/how-to-deal-with-hr-payroll-reports
    http://sap.ittoolbox.com/groups/technical-functional/sap-r3-dev/893908#
    A sample prog with LDB PNP
    *& Report ZH_REPT_PAYMENT *
    report zh_rept_payment line-size 80 no standard page
    heading.
    tables: pernr, " Standard Selections for HR Master Data Reporting
    pcl1, " HR Cluster 1
    pcl2, " HR Cluster 2
    pa0009,
    PA9001,
    PA9006,
    pa0002,
    pc260 , " Cluster Directory for Payroll Results
    bnka .
    Infotypes
    infotypes: 0001. " Organizational Assignment
    Declaration of Internal Tables
    data : bnka1 like bnka occurs 0 with header line .
    data: begin of t_int_rep occurs 100,
    bankl like pc209-bankl, " Bank Number
    zlsch like pc209-zlsch, " Payment method
    pernr like pernr-pernr, " Employee Number
    ename like pernr-ename, " Employee Name
    bankn like pc209-bankn, " Bank Account Number
    betrg like pc209-betrg, " Amount to be transfered
    zweck like pa0009-zweck, " Purpose
    end of t_int_rep.
    data: begin of int_rep occurs 100,
    bankl like pc209-bankl, " Bank Number
    zlsch like pc209-zlsch, " Payment method
    pernr like pernr-pernr, " Employee Number
    ename like pernr-ename, " Employee Name
    bankn like pc209-bankn, " Bank Account Number
    betrg like pc209-betrg, " Amount to be transfered
    zweck like pa0009-zweck, " Purpose
    begda like pa0009-begda, "Begin date
    end of int_rep.
    Declaration of Data Variables
    data: ws_betrg like pc209-betrg, " BT Amount
    w_val like spell occurs 0 with header line,
    int_rep1(6), " TYPE I, " Employee Number
    cnt type i value 0, " Counter
    calcmolga like t500l-molga value '40', " Country Grouping
    v_id(15),
    calc_currency like t001-waers value 'INR'. " Currency
    data : ctr type i,
    dt_merge like pa0009-begda.
    data: ws_totemp(6) type c,
    ws_totamt(20) type c,
    r_mth(9) type c,
    ws_fpbeg(6) type c,
    ws_fpend(6) type c,
    ws_mthyr(6) type c,
    ws_mthyr_r(14) type c,
    r_mth_t(3) type c,
    ws_amt(8) type c,
    ws_bankl(14) type c,
    ws_date(6) type c,
    amount_word(500),
    total_page type i,
    pages type i,
    remain type i.
    data begin of i_spell.
    include structure spell .
    data end of i_spell .
    data : c_molga type t500l-molga value '40',
    c_banks type bnka-banks value 'IN'.
    Standard Includes
    include rpc2cd09. "Cluster CD data definition
    include pc2rxin0.
    include rpc2rx09.
    include rpppxd00. " Data Definition buffer PCL1/PCL2
    include rpppxd10. " Common Part buffer PCL1/PCL2
    include rpppxm00. " Buffer Handling RoutinePCL1/PCL2
    include zrpc2rox2. " Data Definition POCLSTERS (not J,K,U)
    Selection Screen
    selection-screen begin of block b1 with frame title text-001.
    parameter: pa_mth(2) type c default sy-datum+4(2) obligatory,
    pa_year(4) type c default sy-datum(4) obligatory,
    p_bankl like pc209-bankl, " Bank Number
    p_zlsch like pc209-zlsch. " Payment method
    selection-screen end of block b1.
    save_calc_currency = calc_currency.
    count_top = 0.
    get_pernr_flag = 0.
    Top-Of-Page
    top-of-page.
    perform convert_month using pa_mth(2) r_mth.
    ws_mthyr_r = r_mth.
    concatenate ws_mthyr_r pa_year into ws_mthyr_r separated by space.
    SKIP 5.
    skip 1.
    skip 4.
    if int_rep-bankl eq ' '.
    if int_rep-zlsch eq 'C' or int_rep-zlsch eq 'E' or
    int_rep-zlsch eq ' '.
    write: /1(85) 'CHEQUE PAYMENT STATEMENT'(047) centered.
    elseif int_rep-zlsch eq 'L'.
    write: /1(85) 'DEMAND DRAFT STATEMENT'(047) centered.
    endif.
    else.
    write: /1(85) 'BANK TRANSFER STATEMENT'(002) centered.
    endif.
    skip.
    write: /34 ws_mthyr_r,
    62 'Page :'(008),69(2) sy-pagno intensified off,
    ' Of ',78(2) pages intensified off.
    clear pages.
    read table bnka1 with key bankl = int_rep-bankl .
    if sy-subrc = 0.
    if int_rep-zlsch eq 'T'.
    write:/03(10) 'Bank Name : ', bnka1-banka.
    write:/03(10) 'Branch : ', bnka1-brnch.
    write:/03(10) 'Address : ', bnka1-stras.
    endif.
    endif.
    skip.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 2(5) 'Sl.No'(002),
    7 sy-vline, 8(8) 'Emp.No.'(003),
    16 sy-vline,17(35) 'Employee Name'(004).
    *--added for Demand Draft
    if ( int_rep-zlsch = 'l' or int_rep-zlsch = 'L' ).
    write : 47 sy-vline, 48(15) 'Payable at'(005).
    else.
    write : 47 sy-vline,48(15) 'Account No.'(005).
    endif.
    write: 63 sy-vline,64(16) 'Amount'(006),
    80 sy-vline.
    write:/1(80) sy-uline.
    end-of-page.
    write:/1(80) sy-uline.
    write:/2 'Printed on ', sy-datum.
    Start-of-selection.
    start-of-selection.
    *perform h_headr.
    ctr = 0.
    set margin 5.
    call function 'RP_GET_CURRENCY'
    exporting
    molga = calcmolga
    importing
    waers = calc_currency
    exceptions
    others.
    if sy-subrc ne 0.
    calc_currency = 'DEM'.
    calc_currency = save_calc_currency.
    endif.
    get pernr.
    cd-key-pernr = pernr-pernr.
    perform import_cluster.
    get_pernr_flag = 1.
    check : ocd-version-molga eq calcmolga.
    The table 'tabpernr' is filled with the personnel numbers
    and is used after selection is finished.
    move-corresponding pernr to tabpernr.
    append tabpernr.
    The table 'tab_rgdir' is filled
    loop at rgdir.
    rx-key-pernr = pernr-pernr.
    unpack rgdir-seqnr to rx-key-seqno.
    perform int_tab. "fill tab_rgdir
    perform import_bt.
    perform validate.
    endloop.
    End of Selection
    end-of-selection.
    *perform h_headr.
    perform convert_date_a using pa_mth r_mth_t.
    sort int_rep by bankl zlsch pernr betrg descending.
    delete adjacent duplicates from int_rep
    comparing bankl zlsch pernr .
    sort int_rep by bankl zlsch bankn . "PERNR.
    loop at int_rep.
    at new bankl.
    select single * into bnka1 from bnka
    where banks = c_banks and
    bankl = int_rep-bankl .
    append bnka1.
    clear bnka1.
    endat.
    endloop.
    for Demand Draft - purpose added
    loop at int_rep.
    concatenate pa_year(4) pa_mth(2) '01' into dt_merge.
    select single * "zweck into int_rep-zweck
    from pa0009 where
    pernr = int_rep-pernr and
    bankl = int_rep-bankl and
    zlsch = int_rep-zlsch
    and begda <= dt_merge and
    endda >= dt_merge .
    if sy-subrc = 0.
    int_rep-zweck = pa0009-zweck.
    modify int_rep.
    endif.
    endloop.
    *-for DD and Chq sorted by PAyable at and EMPNO wise
    if p_zlsch = 'T' .
    sort int_rep by bankl zlsch bankn . "PERNR.
    else. "added for "payable at" for DD/Chq
    else.
    sort int_rep by zweck pernr . "PERNR.
    endif.
    *delete adjacent duplicates from int_rep.
    t_int_rep] = int_rep[.
    loop at int_rep.
    *-for page of page no.
    total_page = 0.
    loop at t_int_rep where bankl = int_rep-bankl
    and zlsch = int_rep-zlsch.
    total_page = total_page + 1.
    endloop.
    pages = total_page div 25.
    remain = total_page mod 25.
    comment bcoz its adding one extra page no.
    done as on 29/11/2004
    if remain > 0.
    pages = pages + 1.
    endif.
    **-end
    at new bankl.
    ctr = 0 .
    new-page.
    endat.
    at new zlsch.
    ctr = 0 .
    new-page.
    endat.
    clear v_id.
    select single natio
    into pa0002-natio
    from pa0002
    where pernr eq int_rep-pernr.
    *-testing......for soma
    if ctr > 24.
    ctr = 0 .
    write:/1(80) sy-uline.
    new-page .
    endif.
    ctr = ctr + 1 .
    cnt = cnt + 1.
    pack int_rep-pernr to int_rep1.
    write:/1 sy-vline, 2(3) cnt intensified off,
    7 sy-vline, 9(6) int_rep1 intensified off,
    16 sy-vline,17(35) int_rep-ename intensified off .
    if ( int_rep-zlsch = 'l' or int_rep-zlsch = 'L' ).
    write : 47 sy-vline,48(15) int_rep-zweck intensified off.
    else.
    write:
    47 sy-vline,48(15) int_rep-bankn intensified off .
    endif.
    write: 63 sy-vline,64(16) int_rep-betrg
    intensified off currency 'INR',
    80 sy-vline.
    ws_betrg = ws_betrg + int_rep-betrg.
    *-testing......for soma
    skip.
    write :
    /1 sy-vline, 7 sy-vline ,16 sy-vline ,47 sy-vline,63 sy-vline,80
    sy-vline .
    *-end testing......for soma
    at end of zlsch.
    if int_rep-bankl = ' '.
    call function 'HR_IN_CHG_INR_WRDS'
    exporting
    amt_in_num = ws_betrg
    importing
    amt_in_words = amount_word
    EXCEPTIONS
    DATA_TYPE_MISMATCH = 1
    OTHERS = 2
    w_val-word = amount_word.
    concatenate 'INR.' w_val-word into w_val-word
    separated by space.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 7 'Total transfer:'(009),
    64(16) ws_betrg intensified off currency 'INR',
    80 sy-vline.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 3 w_val-word+0(76) intensified off,
    80 sy-vline.
    write :/1 sy-vline, 10 w_val-word+76(70) intensified off,
    80 sy-vline.
    write:/1(80) sy-uline.
    clear: ws_betrg,cnt.
    skip 2.
    write: /2 'Prepared by :'(010), '_______________'(013),
    45 'Checked by :'(011),'_______________'(013).
    skip 2.
    write: /2 'Printed On ', sy-datum,
    45 'Approved by :'(012),'_______________'(013).
    clear sy-pagno.
    endif.
    endat.
    at end of bankl.
    if int_rep-bankl ' '.
    call function 'HR_IN_CHG_INR_WRDS'
    exporting
    amt_in_num = ws_betrg
    importing
    amt_in_words = amount_word
    EXCEPTIONS
    DATA_TYPE_MISMATCH = 1
    OTHERS = 2
    w_val-word = amount_word.
    concatenate 'INR.' w_val-word into w_val-word
    separated by space.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 7 'Total transfer:'(009),
    64(16) ws_betrg intensified off currency 'INR',
    80 sy-vline.
    write:/1(80) sy-uline.
    write: /1 sy-vline, 3 w_val-word+0(76) intensified off,
    80 sy-vline.
    write :/1 sy-vline, 10 w_val-word+76(70) intensified off,
    80 sy-vline.
    write:/1(80) sy-uline.
    clear: ws_betrg,cnt.
    skip 2.
    write: /2 'Prepared by :'(010), '_______________'(013),
    45 'Checked by :'(011),'_______________'(013).
    skip 2.
    write: /2 'Printed on ', sy-datum,
    45 'Approved by :'(012),'_______________'(013).
    clear sy-pagno.
    NEW-PAGE.
    endif.
    endat.
    endloop.
    End of Page
    end-of-page.
    write: /2 'Prepared by :'(010), '_______________',
    45 'Checked by :'(011),'_______________'.
    *& Form IMPORT_CLUSTER
    Importing Data from Cluster *
    form import_cluster.
    sy-subrc = 0.
    rp-imp-c2-cd.
    if sy-subrc eq 0.
    if cd-version-number ne ocd-version-number.
    endif.
    endif. " SY-SUBRC EQ 0
    endform. " IMPORT_CLUSTER
    *& Form INT_TAB
    Filling internal table tab_rgdir form int_tab.
    *Fill internal table tab_rgdir.
    move-corresponding rgdir to tab_rgdir.
    tab_rgdir-pernr = pernr-pernr.
    append tab_rgdir.
    endform. " INT_TAB
    *& Form IMPORT_bt
    Import Values from Bank Transactions Table (BT) form import_bt.
    rp-init-buffer.
    RP-IMP-C2-RX.
    rp-imp-c2-in.
    if rp-imp-in-subrc eq 0.
    if in-version-number ne oin-version-number.
    write: / 'Schlüssel des Clusters RX:'(015),
    rx-key-pernr, rx-key-seqno.
    write: / 'The imported version of the cluster'(016), 'RX',
    'is not current'(017).
    write: / 'Imported version :'(018),
    oin-version-number.
    write: / 'Current version of cluster :'(019),
    in-version-number.
    stop.
    else.
    sy-subrc = 0.
    endif.
    else.
    sy-subrc = 8.
    write: /
    'Inconsistencies between cluster directory and directory for'(020).
    write: /
    'No payroll results found for data in cluster directory'(021).
    write : /
    'Please contact hotline to solve the current problem'(022).
    endif.
    ws_fpbeg(2) = versc-fpbeg+4(2).
    ws_fpbeg+2(4) = versc-fpbeg(4).
    ws_fpend(2) = versc-fpend+4(2).
    ws_fpend+2(4) = versc-fpend(4).
    ws_mthyr(2) = pa_mth.
    ws_mthyr+2(4) = pa_year.
    check ws_mthyr = ws_fpbeg.
    check ws_mthyr = ws_fpend.
    loop at bt. "from pc209
    int_rep-pernr = pernr-pernr.
    int_rep-ename = pernr-ename.
    int_rep-bankl = bt-bankl.
    int_rep-bankn = bt-bankn.
    int_rep-betrg = bt-betrg.
    int_rep-zlsch = bt-zlsch.
    append int_rep.
    endloop.
    IF P_BANKL ' ' AND P_ZLSCH ' '.
    DELETE INT_REP WHERE BANKL P_BANKL.
    ELSEIF P_BANKL = ' ' AND P_ZLSCH ' '.
    DELETE INT_REP WHERE ZLSCH P_ZLSCH.
    ELSEIF P_BANKL ' ' AND P_ZLSCH = ' '.
    DELETE INT_REP WHERE BANKL P_BANKL.
    ENDIF.
    endform. " IMPORT_BT
    *& Form CONVERT_MONTH
    Fetching Month Text form convert_month using mth t_mth.
    case mth.
    when '01'.
    t_mth = 'January'(023).
    when '02'.
    t_mth = 'February'(024).
    when '03'.
    t_mth = 'March'(025).
    when '04'.
    t_mth = 'April'(026).
    when '05'.
    t_mth = 'May'(027).
    when '06'.
    t_mth = 'June'(028).
    when '07'.
    t_mth = 'July'(029).
    when '08'.
    t_mth = 'August'(030).
    when '09'.
    t_mth = 'September'(031).
    when '10'.
    t_mth = 'October'(032).
    when '11'.
    t_mth = 'November'(033).
    when '12'.
    t_mth = 'December'(034).
    endcase.
    endform. " CONVERT_MONTH
    *& Form CONVERT_DATE_A
    Fetching Month Text * form convert_date_a using mth_t t_mth_t.
    case mth_t.
    when '01'.
    t_mth_t = 'Jan.'(035).
    when '02'.
    t_mth_t = 'Feb.'(036).
    when '03'.
    t_mth_t = 'Mar.'(037).
    when '04'.
    t_mth_t = 'Apr.'(038).
    when '05'.
    t_mth_t = 'May.'(039).
    when '06'.
    t_mth_t = 'Jun.'(040).
    when '07'.
    t_mth_t = 'Jul.'(041).
    when '08'.
    t_mth_t = 'Aug.'(042).
    when '09'.
    t_mth_t = 'Sep.'(043).
    when '10'.
    t_mth_t = 'Oct.'(044).
    when '11'.
    t_mth_t = 'Nov.'(045).
    when '12'.
    t_mth_t = 'Dec.'(046).
    endcase.
    endform. " CONVERT_DATE_A
    *& Form VALIDATE
    text
    --> p1 text
    <-- p2 text form validate .
    if p_bankl <> ' ' and p_zlsch ' '.
    delete int_rep where bankl p_bankl.
    elseif p_bankl = ' ' and p_zlsch ' '.
    delete int_rep where zlsch p_zlsch.
    elseif p_bankl ' ' and p_zlsch = ' '.
    delete int_rep where bankl p_bankl.
    endif.
    endform. " VALIDATE
    check this weblog.....
    /people/dj.adams/blog/2003/11/13/food-for-thought-ldbs-and-abap-objects
    Also , check the following link too.
    http://www.datamanagementgroup.com/Resources/Articles/Article_1005_2.asp
    Regards,
    Harish

  • Is it possible in report program

    Hi ,
    I have one report program with some ' WRITE ' statement (Write : /   ' This is SAP world ' .)..For this report program i have got the output as  ( This is SAP world ) .
    My requirement is i want to edit this statement (This is SAP world ) in the out put screen ,after that i want to perform some other steps...
    For Eg: write : / ' This is SAP world ' .
    Output : This is SAP world..
    After the execution of the report program i have got the output
    (This is SAP world ). then i need to edit this line for further requirement...Please help me out for this
    Regards,
    Ambili B

    Hi,
    try like below
    write 'NORMAL FIELD'.
    write / 'EDITABLE FIELD' input on.
    Example
    DATA lv_comment TYPE char80.
    MOVE 'Enter ur comment here' TO lv_comment.
    WRITE: / 'Comment : ',lv_comment INPUT ON.
    AT LINE-SELECTION.
      CLEAR lv_comment.
      READ LINE sy-curow FIELD VALUE lv_comment.
      WINDOW STARTING AT 10 10
             ENDING   AT 40 15.
      WRITE 'COMMENT'.
      SKIP.
      WRITE lv_comment.
    Cheers,
    Jose.
    Edited by: Jose on May 12, 2008 8:40 AM

  • Which is the mandatory event in report program?

    which is the mandatory event in report program?
    Plz its urgent

    Hi,
    Its true, there is no mandatory event in a report program as such. You use events to organize your statements and control the flow of your program.
    For eg, following are some of the events used with their purpose :
    First event -
    Initialization : triggered when the report is loaded in memory.
    At selection-screen output : triggered when the selection screen is loaded in memory before being displayed.
    At selection-screen : before leaving the selection screen.
    start-of-selection : the first event for displaying the report.
    end-of-selection : after the start-of-selection is completed.
    classiscal report events.
    top-of-page : every time a new page is started in the list.
    end-of-page : every time the list data reaches the footer region of the page.
    interactive report events.
    top of page during line selection : top of page event for secondary list.
    at line-selection : evey time user dbl-clicks(F2) on the list data.
    at pF<key> : function key from F5 to F12 to perform interactive action on the list.
    at user-command
    And If the program contains no explicitly defined event blocks, all the statements in the program form the entire event block START-OF-SELECTION, which need not be defined explicitly but is taken by default.
    Hope it helps.

  • How to make Collapsible scrren thru Report Program

    Hi Experts,
    I have a report program, In the selection screen i have 15 check box. But the requirement is we need 5 + 5 + 5 in a collapsible format.
    If the user clicks the left corner it should open the 5 check box.
    Anyone having the knowledge of this kindly share the logic so its easy for me to build the same.
    Thanx in advance.
    Mohana

    Hi try this...
    The code is for the radio button, but if you use this code with a button it will work for your issue.
    use        
            screen-INVISIBLE = '1'.
            istead of screen-input = 0.
    REPORT  ztest.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-003.
    *           Order Documents
    PARAMETERS: rb_view RADIOBUTTON GROUP gr1 DEFAULT 'X' USER-COMMAND ucomm,
                rb_ins  RADIOBUTTON GROUP gr1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-002.
    PARAMETERS:  pagente TYPE zzagente MATCHCODE OBJECT zagent_get MODIF ID sc1,
                 pdat_in TYPE crmt_posting_date MODIF ID sc1 DEFAULT sy-datum,
                 pdat_fin TYPE crmt_posting_date MODIF ID sc1,
                 pbud_om TYPE crmt_net_value_*** MODIF ID sc1,
                 p_datl TYPE crmt_posting_date MODIF ID sc3,
                 p_last TYPE crmt_net_value_*** MODIF ID sc3.
    SELECTION-SCREEN END OF BLOCK b3.
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN OUTPUT.
      PERFORM at_selection_screen.
    *&      Form  AT_SELECTION_SCREEN
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form AT_SELECTION_SCREEN .
    IF rb_view = 'X'.
        LOOP AT SCREEN.
          IF screen-group1 = 'SC1'.
            screen-input = 0.
            screen-INVISIBLE = '1'.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'SC3'.
            screen-input = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSEIF rb_ins = 'X'.
        LOOP AT SCREEN.
          IF screen-group1 = 'SC2'.
            screen-input = 0.
            MODIFY SCREEN.
          ENDIF.
          IF screen-group1 = 'SC3'.
            screen-input = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    endform.                    " AT_SELECTION_SCREEN
    Edited by: Menegazzo Marco on Sep 7, 2010 10:41 AM

  • Is there a way to improve the performance of a report group?

    Hi gurus,
    Is there a way to improve the performance of a report group? 
    Points will be given later....
    Thanks!

    Hi there,
    Thank you for your response. I thought there's no answer for this issue and planning to change it to ALV.
    I looked at the codes and debugged it. After the select statement from ZZUWT table (customized), there's a loop that takes much time (10-12mins) for 1000 records. and several nested perform routines. It's a standard program so I'm hesitant to edit it.
    I'll be checking on the primary keys. If it's ok, may I ask for your assistance in this part? Though I'm not that familiar and haven't tried creating a report painter before.
    Thanks anyway...:D

Maybe you are looking for