Taking long time to run a jobs-in programRBDMIDOC

hi expert
hope all r doing well.i have one issue related to jobs which is taking long time
40 hrs.so please any body help me on this issue. i am giving information related
to issue as below
job name:"J4674-sd-pric-cond-chng-for-vncl" this job is running with program
RBDMIDOC
Job name:"j2378-fi-auto-clear-wo-curr-all" this job is running with program
SAPFI24
can anybady tell me what is the reason its taking so long time.or for improving
performance any OSS note require .
please suggest me the solution
awating for quick response.
Regards
Nisha A

Dear rob,
thanks for your quick response,as you have given the OSS note
but i  discussed with ABAPER but they say this  will not support
so please can you give me other note no so,that we can do some
thing to wipe out problem.i am awaiting for your valuable response
Regds
Nisha A

Similar Messages

  • Queries taking long time to run

    Hi BW Folks,
    I am working on virtual cube 0bcs_vc10 for bcs(business consolidation) the base cube is 0bcs_c10. We compressed and partitioned the base cube. The queries which i developed are running fine and are in production.
    Now  when a new req came for some more queries after developing them and running in DEv they are taking 20 to 25 mins to run.
    Suprisingly the queries which are running in production they are also taking long time to run, we havent disturbed the performance tuning process we did earlier .
    Can any one of share their experience in how to tackle this. Will assign full points
    THanks

    Hi Nick,
    Do you have a lot of navigational attributes?  That could be slowing you down.  Also, if it's going too slow, try caching and pre-calculation (pre-loads the cache).  Although I'm not sure if this will work with a Virtual Cube.  By their nature they will be much slower than a physical cube.....so worst case scenario for me would be to load the VC data into a regular cube.  If the query is still slow, then at least you know it's a query issue and not the VC.
    Brian

  • Query taking long time to run.

    The following query is taking long time to run, is there anything can be done to make it run faster by changing the sql etc.
    select distinct
    A.DEPTID,
    A.POSITION_NBR,
    A.EMPLID,
    A.EMPL_RCD_NBR,
    A.EFFDT,
    B.NAME,
    A.EMPL_STATUS,
    A.JOBCODE,
    A.ANNUAL_RT,
    A.STD_HOURS,
    A.PRIMARY_JOB,
    C.POSN_STATUS,
    case when A.POSITION_NBR = ' ' then 0 else C.STD_HOURS end,
    case when A.POSITION_NBR = ' ' then ' ' else C.DEPTID end
    from PS_JOB A,
    PS_PERSONAL_DATA B,
    PS_POSITION_DATA C
    where A.EMPLID = B.EMPLID
    and
    ((A.POSITION_NBR = C.POSITION_NBR
    and A.EFFSEQ = (select max(D.EFFSEQ)
    from PS_JOB D
    where D.EMPLID = A.EMPLID
    and D.EMPL_RCD_NBR = A.EMPL_RCD_NBR
    and D.EFFDT = A.EFFDT)
    and C.POSN_STATUS <> 'G'
    and C.EFFDT = (select max(E.EFFDT)
    from PS_POSITION_DATA E
    where E.POSITION_NBR = A.POSITION_NBR
    and E.EFFDT <= A.EFFDT)
    and C.EFFSEQ = (select max(F.EFFSEQ)
    from PS_POSITION_DATA F
    where F.POSITION_NBR = A.POSITION_NBR
    and F.EFFDT = C.EFFDT))
    or
    (A.POSITION_NBR = C.POSITION_NBR
    and A.EFFDT = (select max(D.EFFDT)
    from PS_JOB D
    where D.EMPLID = A.EMPLID
    and D.EMPL_RCD_NBR = A.EMPL_RCD_NBR
    and D.EFFDT <= C.EFFDT)
    and A.EFFSEQ = (select max(E.EFFSEQ)
    from PS_JOB E
    where E.EMPLID = A.EMPLID
    and E.EMPL_RCD_NBR = A.EMPL_RCD_NBR
    and E.EFFDT = A.EFFDT)
    and C.POSN_STATUS <> 'G'
    and C.EFFSEQ = (select max(F.EFFSEQ)
    from PS_POSITION_DATA F
    where F.POSITION_NBR = A.POSITION_NBR
    and F.EFFDT = C.EFFDT)))
    or
    (A.POSITION_NBR = ' '
    and A.EFFSEQ = (select max(E.EFFSEQ)
    from PS_JOB D
    where D.EMPLID = A.EMPLID
    and E.EMPL_RCD_NBR = A.EMPL_RCD_NBR
    and D.EFFDT = A.EFFDT)))

    Using distributive law A and (B or C) = (A and B) or (A and C) from right to left we can have:
    select distinct A.DEPTID,A.POSITION_NBR,A.EMPLID,A.EMPL_RCD_NBR,A.EFFDT,B.NAME,A.EMPL_STATUS,
                    A.JOBCODE,A.ANNUAL_RT,A.STD_HOURS,A.PRIMARY_JOB,C.POSN_STATUS,
                    case when A.POSITION_NBR = ' ' then 0 else C.STD_HOURS end,
                    case when A.POSITION_NBR = ' ' then ' ' else C.DEPTID end
      from PS_JOB A,PS_PERSONAL_DATA B,PS_POSITION_DATA C
    where A.EMPLID = B.EMPLID
       and (
             A.POSITION_NBR = C.POSITION_NBR
         and A.EFFSEQ = (select max(D.EFFSEQ)
                           from PS_JOB D
                          where D.EMPLID = A.EMPLID
                            and D.EMPL_RCD_NBR = A.EMPL_RCD_NBR
                            and D.EFFDT = A.EFFDT
         and C.EFFSEQ = (select max(F.EFFSEQ)
                           from PS_POSITION_DATA E
                          where E.POSITION_NBR = A.POSITION_NBR
                            and E.EFFDT = C.EFFDT
         and C.POSN_STATUS != 'G'
         and (
               C.EFFDT = (select max(E.EFFDT) 
                            from PS_POSITION_DATA E
                           where E.POSITION_NBR = A.POSITION_NBR
                             and E.EFFDT <= A.EFFDT
           or
               A.EFFDT = (select max(D.EFFDT) 
                            from PS_JOB D
                           where D.EMPLID = A.EMPLID
                             and D.EMPL_RCD_NBR = A.EMPL_RCD_NBR
                             and D.EFFDT <= C.EFFDT
         or
             A.POSITION_NBR = ' '
               and A.EFFSEQ = (select max(E.EFFSEQ)
                                 from PS_JOB D
                                where D.EMPLID = A.EMPLID
                                  and E.EMPL_RCD_NBR = A.EMPL_RCD_NBR
                                  and D.EFFDT = A.EFFDT
           )may not help much as the optimizer might have guessed it already
    Regards
    Etbin

  • This part of query is taking long time to run, its about 40 minutes. Can anyone help wit it.

    ------Load Dataset into Temp table---------------
    SELECT
    z.SYSTEMNAME
    --,Case when ZXC.[Subsystem Name] <> 'NULL' Then zxc.[SubSystem Name]
    --else NULL
    --End AS SubSystemName
    , CASE
    WHEN z.PROV_TAX_ID IN
    (SELECT DISTINCT zxc.TIN
    FROM dbo.SQS_Provider_Tracking zxc
    WHERE zxc.[SubSystem Name] <> 'NULL'
    THEN
    (SELECT DISTINCT [Subsystem Name]
    FROM dbo.SQS_Provider_Tracking zxc
    WHERE z.PROV_TAX_ID = zxc.TIN)
    End As SubSYSTEMNAME
    ,z.PROVIDERNAME
    ,z.STATECODE
    ,z.PROV_TAX_ID
    ,z.SRC_PAR_CD
    ,SUM(z.SEQUEST_AMT) Actual_Sequestered_Amt
    , CASE
    WHEN z.SRC_PAR_CD IN ('E','O','S','W')
    THEN 'Nonpar Waiver'
    --**Amendment Mailed**
    --WHEN z.PROV_TAX_ID IN
    When EXISTS
    (SELECT DISTINCT b.PROV_TIN
    FROM dbo.SQS_Mailed_TINs_010614 b WITH (NOLOCK )
    where not exists (select * from dbo.sqs_objector_TINs t where b.PROV_TIN = t.prov_tin))
    THEN
    (SELECT DISTINCT b.Mailing
    FROM dbo.SQS_Mailed_TINs_010614 b WITH (NOLOCK )
    WHERE z.PROV_TAX_ID = b.PROV_TIN
    -- --**Amendment Mailed Wave 3 and 4**
    --WHEN z.PROV_TAX_ID In
    When EXISTS
    (SELECT
    qz.PROV_TIN
    FROM
    [SQS_Mailed_TINs] qz WITH (NOLOCK )
    where qz.Mailing = 'Amendment Mailed (3rd Wave)'
    and not exists (select * from dbo.sqs_objector_TINs t WITH (NOLOCK ) where qz.PROV_TIN = t.prov_tin))
    THEN 'Amendment Mailed (3rd Wave)'
    WHEN EXISTS
    (SELECT
    qz.PROV_TIN
    FROM
    [SQS_Mailed_TINs] qz WITH (NOLOCK )
    where qz.Mailing = 'Amendment Mailed (4th Wave)'
    and not exists (select * from dbo.sqs_objector_TINs t WITH (NOLOCK ) where qz.PROV_TIN = t.prov_tin))
    THEN 'Amendment Mailed (4th Wave)'
    -- --Is Puerto Rico of Lifesynch
    WHEN EXISTS
    (SELECT DISTINCT a.PROV_TAX_ID
    FROM PACT.dbo.SQS_NonPar_PR_LS_TINs a WITH (NOLOCK )
    WHERE a.Bucket <> 'Nonpar'
    THEN
    (SELECT DISTINCT a.Bucket
    FROM PACT.dbo.SQS_NonPar_PR_LS_TINs a WITH (NOLOCK )
    WHERE a.PROV_TAX_ID = z.PROV_TAX_ID)
    -- --**Top Objecting Systems**
    WHEN z.SYSTEMNAME IN
    ('ADVENTIST HEALTH SYSTEM','ASCENSION HEALTH ALLIANCE','AULTMAN HEALTH FOUNDATION','BANNER HEALTH SYSTEM','BERT FISH MEDICAL CENTER','BETHESDA MEMORIAL HOSPITAL','BJC HEALTHCARE','BLOUNT MEMORIAL HOSPITAL','BOCA RATON REGIONAL HOSPITAL','CAROMONT HEALTH SYSTEM','CATHOLIC HEALTH INITIATIVES','CATHOLIC HEALTHCARE PARTNERS','CHRISTUS HEALTH',/*'CLEVELAND CLINIC HEALTH SYSTEM',*/'COLUMBUS REGIONAL HEALTHCARE SYSTEM','COMMUNITY HEALTH SYSTEMS, INC','COXHEALTH','HCA','HEALTH MANAGEMENT ASSOCIATES','HUNTSVILLE HOSPITAL HEALTH SYSTEM','INTEGRIS HEALTH','JUPITER MEDICAL CENTER','LEE MEMORIAL HEALTH SYSTEM','MARTIN MEMORIAL HEALTH SYSTEM','MERCY','MT SINAI MEDICAL CENTER (MIAMI)','MUNROE REGIONAL MEDICAL CENTER','NORMAN REGIONAL HEALTH SYSTEM','NORTHSIDE HEALTH SYSTEM','SHANDS HEALTHCARE','SISTERS OF MERCY - SPRINGFIELD, MO','SSM HEALTH CARE','ST LUKES HEALTH SYSTEM','SUMMA HEALTH SYSTEM','SUSQUEHANNA HEALTH SYSTEM','TBD -- TRINITY HEALTH - CATHOLIC HEALTH EAST','UNIVERSITY OF MISSOURI HEALTH SYSTEM','UNIVERSITY OF NEW MEXICO HOSPITALS','UNIVERSITY OF UTAH HEALTH CARE')
    THEN 'Top Objecting Systems'
    WHEN EXISTS
    (SELECT
    h.PROV_TAX_ID
    FROM
    #HIHO_Records h
    INNER JOIN SQS_Provider_Tracking obj WITH (NOLOCK )
    ON h.PROV_TAX_ID = obj.TIN
    AND obj.[Objector?] = 'Top Objector'
    WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
    OR h.SMG_ID IS NOT NULL
    )and z.LCLM_RSTMT_TREND_CAT_CD IN ('HO','HI')
    THEN 'Top Objecting Systems'
    -- --**Other Objecting Hospitals**
    WHEN EXISTS
    (SELECT
    h.PROV_TAX_ID
    FROM
    #HIHO_Records h
    INNER JOIN SQS_Provider_Tracking obj WITH (NOLOCK )
    ON h.PROV_TAX_ID = obj.TIN
    AND obj.[Objector?] = 'Objector'
    WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
    OR h.SMG_ID IS NOT NULL
    )and z.LCLM_RSTMT_TREND_CAT_CD IN ('HO','HI')
    THEN 'Other Objecting Hospitals'
    -- --**Objecting Physicians**
    WHEN EXISTS
    (SELECT z.PROV_TAX_ID
    FROM SQS_EDW_Source z WITH (NOLOCK)
    WHERE EXISTS
    (SELECT DISTINCT
    obj.TIN
    FROM SQS_Provider_Tracking obj WITH (NOLOCK )
    WHERE obj.[Objector?] in ('Objector','Top Objector')
    and z.PROV_TAX_ID = obj.TIN
    and z.LCLM_RSTMT_TREND_CAT_CD not IN ('HO','HI')
    THEN 'Objecting Physicians'
    --****Rejecting Hospitals****
    WHEN EXISTS
    (SELECT
    h.PROV_TAX_ID
    FROM
    #HIHO_Records h
    INNER JOIN SQS_Provider_Tracking obj WITH (NOLOCK )
    ON h.PROV_TAX_ID = obj.TIN
    AND obj.[Objector?] = 'Rejector'
    WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
    OR h.SMG_ID IS NOT NULL
    )and z.LCLM_RSTMT_TREND_CAT_CD IN ('HO','HI')
    THEN 'Rejecting Hospitals'
    --****Rejecting Physciains****
    WHEN EXISTS
    (SELECT obj.TIN
    FROM SQS_Provider_Tracking obj WITH (NOLOCK )
    WHERE z.PROV_TAX_ID = obj.TIN
    AND obj.[Objector?] = 'Rejector')
    and z.LCLM_RSTMT_TREND_CAT_CD NOT IN ('HO','HI')
    THEN 'REjecting Physicians'
    ----**********ALL OBJECTORS SHOULD HAVE BEEN BUCKETED AT THIS POINT IN THE QUERY**********
    -- --**Non-Objecting Hospitals**
    WHEN EXISTS
    (SELECT DISTINCT
    h.PROV_TAX_ID
    FROM
    #HIHO_Records h WITH (NOLOCK )
    WHERE
    (z.PROV_TAX_ID = h.PROV_TAX_ID)
    OR h.SMG_ID IS NOT NULL
    )and z.LCLM_RSTMT_TREND_CAT_CD IN ('HO','HI')
    THEN 'Non-Objecting Hospitals'
    -- **Outstanding Contracts for Review**
    WHEN EXISTS
    (SELECT qz.PROV_TIN
    FROM
    [PACT].[HUMAD\ARS3766].[SQS_Mailed_TINs] qz WITH (NOLOCK )
    where qz.Mailing = 'Non-Objecting Bilateral Physicians'
    AND z.PROV_TAX_ID = qz.PROV_TIN)
    Then 'Non-Objecting Bilateral Physicians'
    When EXISTS
    (select
    p.prov_tax_id
    from dbo.SQS_CoC_Potential_Mail_List p WITH (NOLOCK )
    where p.amendmentrights <> 'Unilateral'
    AND z.prov_tax_id = p.prov_tax_id)
    THEN 'Non-Objecting Bilateral Physicians'
    WHEN EXISTS
    (SELECT
    qz.PROV_TIN
    FROM
    [SQS_Mailed_TINs] qz WITH (NOLOCK )
    where qz.Mailing = 'More Research Needed'
    AND qz.PROV_TIN = z.PROV_TAX_ID)
    THEN 'More Research Needed'
    WHEN EXISTS (SELECT qz.PROV_TIN FROM [SQS_Mailed_TINs] qz WITH (NOLOCK ) where qz.Mailing = 'Objector' AND qz.PROV_TIN = z.PROV_TAX_ID)
    THEN 'ERROR'
    else 'Market Review/Preparing to Mail'
    END AS [Updated Bucket]
    ,COALESCE(q.INDdesc, f.IND_desc) AS INDdesc
    ,f.Time_Period_for_Dispute
    ,f.Renew_Term_Ind
    ,f.Renewal_Date
    ,z.SMG_ID
    ,'' AS OrderedRank
    INTO SQS_Bucketed_Details_SMG_on_SMGXXX
    From #SQS_EDW_SOURCE_WithSMG z
    left join #F f ON f.PROV_TAX_ID = z.PROV_TAX_ID
    AND z.SYSTEMNAME = f.SYSTEM_NAME
    AND z.PROVIDERNAME = f.Provider
    Left join #Q q ON z.PROV_TAX_ID = q.TIN
    GROUP BY z.SYSTEMNAME
    --,Z.[SubsystemName]
    ,z.PROVIDERNAME
    ,z.STATECODE
    ,z.PROV_TAX_ID
    ,z.SRC_PAR_CD
    ,q.INDdesc
    ,f.IND_Desc
    ,f.Time_Period_for_Dispute
    ,f.Renew_Term_Ind
    ,f.Renewal_Date
    ,z.SMG_ID
    ,z.LCLM_RSTMT_TREND_CAT_CD
    As I am a developer I do not have the access to Sql profiler or tuning agent to optimize my query, I have used some joins over the temp table #HIHO which indeed pulling the records from table EDW_Source which has 5 million records, I also added Non clustered
    indexes on prov_ID, SMG_ID and Incurred month for this table, but still it is taking longer time. Need help

    Hi, It needs some more tweaks but pls try this one
    USE
    Go
    --****Create sqs_objector_TINs (Objections and Rejections)****
    --Drop table .dbo.sqs_objector_TINs
    select distinct a.TIN as Prov_TIN
    Into #sqs_objector_TINs
    from .dbo.sqs_provider_tracking as a with (nolock)
    where a.[Objector?] in ('Top Objector','Objector','Rejector')
    /*********** Query for SQS_TINtoSyst***********/
    --DROP TABLE .dbo.SQS_TINtoSystem
    select distinct
    b.SRC_PROV_ID
    --,case
    -- when a.SYSTEM_NAME is null
    -- then
    -- case
    -- when a.CTRCT_GRP_NAME is null
    -- then a.PROV_SMG_NAME
    -- else a.CTRCT_GRP_NAME
    -- end
    -- else a.SYSTEM_NAME
    --end as SYSTEM_NAME
    ,COALESCE(a.SYSTEM_NAME, a.CTRCT_GRP_NAME, a.PROV_SMG_NAME) AS SYSTEM_NAME
    INTO #SQS_TINtoSystem
    from
    PARE.dbo.EDW_PROD_HOSPITAL_MASTER a with (nolock)
    Inner Join PARE.dbo.EDW_PROD_HOSPITAL_ID_XREF b with (nolock)
    on a.SMG_ID = b.SMG_ID
    -- Inner Join .dbo.SQS_EDW_Source q
    --on b.SRC_PROV_ID = q.PROV_TAX_ID
    where b.SRC_PLATFORM_CD = 'TX'
    and exists
    select
    SMG_ID
    from PARE.dbo.EDW_PROD_HOSPITAL_ID_XREF as t1 with (nolock)
    where SRC_PLATFORM_CD = 'TX'
    and exists (select q.PROV_TAX_ID from .dbo.SQS_EDW_Source q with (nolock) where q.PROV_TAX_ID = b.SRC_PROV_ID)
    and a.SMG_ID = t1.SMG_ID
    /************** Query for SQS_Bucketed_Details_SMG*****************/
    DROP TABLE .dbo.SQS_Bucketed_Details_SMG
    --Create temp table
    SELECT z.SYSTEMNAME
    ,Z.PROV_TAX_ID
    ,z.PROVIDERNAME
    ,z.STATECODE
    ,z.SRC_PAR_CD
    ,z.SEQUEST_AMT
    ,case when Z.LCLM_RSTMT_TREND_CAT_CD IN ('HI','HO') Then 'H' else 'P' end as Hosp_Ind
    ,Z.SMG_ID
    INTO #SQS_EDW_SOURCE_WithSMG
    FROM dbo.SQS_EDW_SOURCE_WithSMG z with (nolock)
    WHERE (Z.Incurred_Mth >= convert(datetime,'01/01/2013')) and (Z.Incurred_Mth < convert(datetime, '1/1/2014'))
    --between convert(datetime,'01/01/2013') and convert(datetime, '12/31/2013 23:59:59.996')
    --YEAR(Z.Incurred_Mth)=2013
    -- Create Temp table Q
    select
    x.TIN,
    case when max(x.IND) = 'NYN'
    then 'Standard'
    when max(x.IND) = 'YNN'
    then 'Express'
    when max(x.IND) = 'NNY'
    then 'Non_Standard' else 'Mixed'
    end as INDdesc
    Into #Q
    FROM
    (SELECT
    a.tin,
    MAX(a.express) + MAX(a.StandardInd) + MAX(NonstandardIND) as IND
    from
    (select r.TIN,
    case when MAX(r.Express) like 'Y%' then 'Y' else 'N' end As Express,
    case when MAX(r.Standard) = 'Y' then 'Y' else 'N' end As StandardInd,
    case when MAX(r.[Non-Standard]) = 'Y' then 'Y' else 'N' end AS NonstandardIND
    FROM DBO.SQS_Objectors_01032014 r with (nolock)
    GROUP BY r.TIN) a
    group by a.TIN) x
    group by x.TIN
    --Create Temp table F
    Select *
    INTO #F
    FROM(
    SELECT distinct g.prov_tax_id
    ,g.system_name
    ,g.provider
    ,case when g.reimburse_mixed = 'Y' then 'Mixed'
    when g.reimburse_express = 'Y' then 'Express'
    when g.reimburse_standard = 'Y' then 'Standard'
    when g.reimburse_NonStandard = 'Y' then 'NonStandard'
    end as IND_Desc
    ,g.Time_Period_for_Dispute
    ,case when g.Renewal_Date = 'N' and g.Expiration_Date = 'N'
    then 'Unclear'
    when g.Renewal_Date = 'N' and g.Expiration_Date <> 'N'
    then 'Termination'
    when g.Renewal_Date <> 'N' and g.Expiration_Date = 'N'
    then 'Evergreen'
    when g.Renewal_Date <> 'N' and g.Expiration_Date <> 'N'
    then 'Termination'
    else 'Unknown'
    end as 'Renew_Term_Ind'
    ,g.Renewal_Date
    FROM
    (select distinct
    bb.PROV_TAX_ID1 as prov_tax_id
    ,aa.*
    from
    [dbo].[Top_600_Hospitals3] aa with (nolock)
    left join pare.dbo.EDW_PROD_HOSPITAL_MASTER bb with (nolock)
    on --a.CTRCT_GRP_NAME = b.CTRCT_GRP_NAME
    aa.Provider = bb.PROV_SMG_NAME
    -- and (a.SYSTEM_NAME = b.SMG_SYS_NAME or a.SYSTEM_NAME = b.SYSTEM_NAME)
    --and a.ADDR_LINE1 = b.ADDR_LINE1
    and aa.STATE_CD = bb.STATE_CD
    --and a.ZIP_CD = b.ZIP_CD
    and aa.City1 = bb.CITY_NAME
    where aa.SYSTEM_NAME <> 'SEE ABOVE') g
    where g.system_name <> 'SEE ABOVE') h
    where h.ind_Desc is not null
    SELECT DISTINCT z.PROV_TAX_ID
    , z.SMG_ID
    INTO #HIHO_Records
    FROM SQS_EDW_SOURCE_WithSMG z with (nolock)
    WHERE z.LCLM_RSTMT_TREND_CAT_CD IN ('HO', 'HI')
    AND Z.Incurred_Mth >=convert(datetime, '1/1/2013') and Z.Incurred_Mth <convert(datetime, '1/1/2014')
    --YEAR(Z.Incurred_Mth)=2013
    ---------------------------------Load Dataset into Temp table---------------
    SELECT
    z.SYSTEMNAME
    --,Case when ZXC.[Subsystem Name] <> 'NULL' Then zxc.[SubSystem Name]
    --else NULL
    --End AS SubSystemName
    , CASE
    WHEN z.PROV_TAX_ID IN
    (SELECT zxc.TIN
    FROM dbo.SQS_Provider_Tracking zxc with (nolock)
    WHERE zxc.[SubSystem Name] <> 'NULL'
    THEN
    (SELECT top 1 [Subsystem Name]
    FROM dbo.SQS_Provider_Tracking zxc with (nolock)
    WHERE z.PROV_TAX_ID = zxc.TIN)
    End As SubSYSTEMNAME
    ,z.PROVIDERNAME
    ,z.STATECODE
    ,z.PROV_TAX_ID
    ,z.SRC_PAR_CD
    ,SUM(z.SEQUEST_AMT) Actual_Sequestered_Amt
    , CASE
    WHEN z.SRC_PAR_CD IN ('E','O','S','W')
    THEN 'Nonpar Waiver'
    -- --Is Puerto Rico of Lifesynch
    WHEN z.PROV_TAX_ID IN
    (SELECT a.PROV_TAX_ID
    FROM .dbo.SQS_NonPar_PR_LS_TINs a with (nolock)
    WHERE a.Bucket <> 'Nonpar'
    THEN
    (SELECT top 1 a.Bucket
    FROM .dbo.SQS_NonPar_PR_LS_TINs a with (nolock)
    WHERE a.PROV_TAX_ID = z.PROV_TAX_ID)
    --**Amendment Mailed**
    WHEN z.PROV_TAX_ID IN
    (SELECT b.PROV_TIN
    FROM dbo.SQS_Mailed_TINs_010614 b WITH (NOLOCK )
    where not exists (select * from dbo.sqs_objector_TINs t with (nolock) where b.PROV_TIN = t.prov_tin))
    and z.Hosp_Ind = 'P'
    THEN
    (SELECT top 1 b.Mailing
    FROM dbo.SQS_Mailed_TINs_010614 b with (nolock)
    WHERE z.PROV_TAX_ID = b.PROV_TIN
    -- --**Amendment Mailed Wave 3-5**
    WHEN z.PROV_TAX_ID In
    (SELECT
    qz.PROV_TIN
    FROM
    [SQS_Mailed_TINs] qz
    where qz.Mailing = 'Amendment Mailed (3rd Wave)'
    and not exists (select * from dbo.sqs_objector_TINs t with (nolock) where qz.PROV_TIN = t.prov_tin))
    and z.Hosp_Ind = 'P'
    THEN 'Amendment Mailed (3rd Wave)'
    WHEN z.PROV_TAX_ID IN
    (SELECT
    qz.PROV_TIN
    FROM
    [SQS_Mailed_TINs] qz
    where qz.Mailing = 'Amendment Mailed (4th Wave)'
    and not exists (select * from dbo.sqs_objector_TINs t with (nolock) where qz.PROV_TIN = t.prov_tin))
    and z.Hosp_Ind = 'P'
    THEN 'Amendment Mailed (4th Wave)'
    WHEN z.PROV_TAX_ID IN
    (SELECT
    qz.PROV_TIN
    FROM
    [SQS_Mailed_TINs] qz
    where qz.Mailing = 'Amendment Mailed (5th Wave)'
    and not exists (select * from dbo.sqs_objector_TINs t with (nolock) where qz.PROV_TIN = t.prov_tin))
    and z.Hosp_Ind = 'P'
    THEN 'Amendment Mailed (5th Wave)'
    -- --**Top Objecting Systems**
    WHEN z.SYSTEMNAME IN
    ('ADVENTIST HEALTH SYSTEM','ASCENSION HEALTH ALLIANCE','AULTMAN HEALTH FOUNDATION')
    THEN 'Top Objecting Systems'
    WHEN z.PROV_TAX_ID IN
    (SELECT
    h.PROV_TAX_ID
    FROM
    #HIHO_Records h
    INNER JOIN .dbo.SQS_Provider_Tracking obj with (nolock)
    ON h.PROV_TAX_ID = obj.TIN
    AND obj.[Objector?] = 'Top Objector'
    WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
    OR h.SMG_ID IS NOT NULL
    )and z.Hosp_Ind = 'H'
    THEN 'Top Objecting Systems'
    -- --**Other Objecting Hospitals**
    WHEN (z.PROV_TAX_ID IN
    (SELECT
    h.PROV_TAX_ID
    FROM
    #HIHO_Records h
    INNER JOIN .dbo.SQS_Provider_Tracking obj with (nolock)
    ON h.PROV_TAX_ID = obj.TIN
    AND obj.[Objector?] = 'Objector'
    WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
    OR h.SMG_ID IS NOT NULL
    )and z.Hosp_Ind = 'H')
    THEN 'Other Objecting Hospitals'
    -- --**Objecting Physicians**
    WHEN (z.PROV_TAX_ID IN
    (SELECT
    obj.TIN
    FROM .dbo.SQS_Provider_Tracking obj with (nolock)
    WHERE obj.[Objector?] in ('Objector','Top Objector')
    and z.PROV_TAX_ID = obj.TIN
    and z.Hosp_Ind = 'P')
    THEN 'Objecting Physicians'
    --****Rejecting Hospitals****
    WHEN (z.PROV_TAX_ID IN
    (SELECT
    h.PROV_TAX_ID
    FROM
    #HIHO_Records h
    INNER JOIN .dbo.SQS_Provider_Tracking obj with (nolock)
    ON h.PROV_TAX_ID = obj.TIN
    AND obj.[Objector?] = 'Rejector'
    WHERE z.PROV_TAX_ID = h.PROV_TAX_ID
    OR h.SMG_ID IS NOT NULL
    )and z.Hosp_Ind = 'H')
    THEN 'Rejecting Hospitals'
    --****Rejecting Physciains****
    WHEN
    (z.PROV_TAX_ID IN
    (SELECT
    obj.TIN
    FROM .dbo.SQS_Provider_Tracking obj with (nolock)
    WHERE z.PROV_TAX_ID = obj.TIN
    AND obj.[Objector?] = 'Rejector')
    and z.Hosp_Ind = 'P')
    THEN 'REjecting Physicians'
    ----**********ALL OBJECTORS SHOULD HAVE BEEN BUCKETED AT THIS POINT IN THE QUERY**********
    -- --**Non-Objecting Hospitals**
    WHEN z.PROV_TAX_ID IN
    (SELECT
    h.PROV_TAX_ID
    FROM
    #HIHO_Records h
    WHERE
    (z.PROV_TAX_ID = h.PROV_TAX_ID)
    OR h.SMG_ID IS NOT NULL)
    and z.Hosp_Ind = 'H'
    THEN 'Non-Objecting Hospitals'
    -- **Outstanding Contracts for Review**
    WHEN z.PROV_TAX_ID IN
    (SELECT
    qz.PROV_TIN
    FROM
    [SQS_Mailed_TINs] qz with (nolock)
    where qz.Mailing = 'Non-Objecting Bilateral Physicians'
    AND z.PROV_TAX_ID = qz.PROV_TIN)
    Then 'Non-Objecting Bilateral Physicians'
    When z.prov_tax_id in
    (select
    p.prov_tax_id
    from dbo.SQS_CoC_Potential_Mail_List p with (nolock)
    where p.amendmentrights <> 'Unilateral'
    AND z.prov_tax_id = p.prov_tax_id)
    THEN 'Non-Objecting Bilateral Physicians'
    WHEN z.PROV_TAX_ID IN
    (SELECT
    qz.PROV_TIN
    FROM
    [SQS_Mailed_TINs] qz
    where qz.Mailing = 'More Research Needed'
    AND qz.PROV_TIN = z.PROV_TAX_ID)
    THEN 'More Research Needed'
    WHEN z.PROV_TAX_ID IN (SELECT qz.PROV_TIN FROM [SQS_Mailed_TINs] qz with (nolock) where qz.Mailing = 'Objector' AND qz.PROV_TIN = z.PROV_TAX_ID)
    THEN 'ERROR'
    else 'Market Review/Preparing to Mail'
    END AS [Updated Bucket]
    ,COALESCE(q.INDdesc, f.IND_desc) AS INDdesc
    ,f.Time_Period_for_Dispute
    ,f.Renew_Term_Ind
    ,f.Renewal_Date
    ,z.SMG_ID
    ,'' AS OrderedRank
    INTO dbo.SQS_Bucketed_Details_SMG with (nolock)
    From #SQS_EDW_SOURCE_WithSMG z
    left join #F f ON f.PROV_TAX_ID = z.PROV_TAX_ID
    AND z.SYSTEMNAME = f.SYSTEM_NAME
    AND z.PROVIDERNAME = f.Provider
    Left join #Q q ON z.PROV_TAX_ID = q.TIN
    GROUP BY z.SYSTEMNAME
    --,Z.[SubsystemName]
    ,z.PROVIDERNAME
    ,z.STATECODE
    ,z.PROV_TAX_ID
    ,z.SRC_PAR_CD
    ,q.INDdesc
    ,f.IND_Desc
    ,f.Time_Period_for_Dispute
    ,f.Renew_Term_Ind
    ,f.Renewal_Date
    ,z.SMG_ID
    ,z.Hosp_Ind
    /************************** Drop temp tables*********************/
    --DROP TABLE #SQS_EDW_SOURCE_WithSMG
    --DROP TABLE #Q
    --DROP TABLE #F
    --DROP TABLE #HIHO_Records
    --DROP TABLE #SQS_TINtoSystem
    --DROP TABLE #SQS_EDW_SOURCE_WithSMG
    --DROP TABLE #sqs_objector_TINs

  • Infopackage in process chain taking long time to run

    HI Experts,
    One of the element (Infopackage) in process chain(Daily process chain) is taking much longer time(6 hr and still runing) as generally it takes 15-20 mins to complete and the status is in yellow and still running in process monitor without giving any clear picture of  error. Manually we are making the staus red and we are updating from PSA and this time it is getting completed in time as specified.
    Flow from PSA to datatarget(DSO) in series
    For last one week we are facing same issue and i would like to mention that we don't have access to SM37,SM12 to look the logs
    and any locks.
    without this i need to investigate what is the root cause for the same.
    with regards,
    murali

    Hi,
    please find the job log.
    Date
    Time
    Message
    MsgID/No./Ty
    13.12.2010
    21:45:30
    Job started
    00
    516
    S
    13.12.2010
    21:45:30
    Step 001 started (program SBIE0001, variant &0000000109368, user ID RFCUSER)
    00
    550
    S
    13.12.2010
    21:45:30
    Asynchronous transmission of info IDoc 2 in task 0001 (0 parallel tasks)
    R3
    413
    S
    13.12.2010
    21:45:30
    DATASOURCE = 2LIS_17_I3HDR
    R3
    299
    S
    13.12.2010
    21:45:30
    RLOGSYS    = PBACLNT200
    R3
    299
    S
    13.12.2010
    21:45:30
    REQUNR     = REQU_D9GSSV08BTS93Z6Y7XWP1ZEUJ
    R3
    299
    S
    13.12.2010
    21:45:30
    UPDMODE    = D
    R3
    299
    S
    13.12.2010
    21:45:30
    LANGUAGES  = *
    R3
    299
    S
    13.12.2010
    21:45:30
    R8
    048
    S
    13.12.2010
    21:45:30
             Current Values for Selected Profile Parameters               *
    R8
    049
    S
    13.12.2010
    21:45:30
    R8
    048
    S
    13.12.2010
    21:45:30
    abap/heap_area_nondia......... 0                                       *
    R8
    050
    S
    13.12.2010
    21:45:30
    abap/heap_area_total.......... 25500319744                             *
    R8
    050
    S
    13.12.2010
    21:45:30
    abap/heaplimit................ 40000000                                *
    R8
    050
    S
    13.12.2010
    21:45:30
    zcsa/installed_languages...... ED                                      *
    R8
    050
    S
    13.12.2010
    21:45:30
    zcsa/system_language.......... E                                       *
    R8
    050
    S
    13.12.2010
    21:45:30
    ztta/max_memreq_MB............ 2047                                    *
    R8
    050
    S
    13.12.2010
    21:45:30
    ztta/roll_area................ 3000320                                 *
    R8
    050
    S
    13.12.2010
    21:45:30
    ztta/roll_extension........... 2000000000                              *
    R8
    050
    S
    13.12.2010
    21:45:30
    R8
    048
    S
    13.12.2010
    21:45:31
    70 LUWs confirmed and 70 LUWs to be deleted with function module RSC2_QOUT_CONFIRM_DATA
    RSQU
    036
    S
    13.12.2010
    21:45:33
    Call customer enhancement BW_BTE_CALL_BW204010_E (BTE) with 9,895 records
    R3
    407
    S
    13.12.2010
    21:45:33
    Result of customer enhancement: 9,895 records
    R3
    408
    S
    13.12.2010
    21:45:33
    Call customer enhancement EXIT_SAPLRSAP_001 (CMOD) with 9,895 records
    R3
    407
    S
    13.12.2010
    21:45:33
    Result of customer enhancement: 9,895 records
    R3
    408
    S
    13.12.2010
    21:45:33
    PSA=0 USING & STARTING SAPI SCHEDULER
    R3
    299
    S
    13.12.2010
    21:45:33
    Asynchronous send of data package 1 in task 0002 (1 parallel tasks)
    R3
    409
    S
    13.12.2010
    21:45:34
    IDOC: Info IDoc 2, IDoc No. 5136702, Duration 00:00:00
    R3
    088
    S
    13.12.2010
    21:45:34
    IDoc: Start = 13.12.2010 21:45:30, End = 13.12.2010 21:45:30
    R3
    089
    S
    13.12.2010
    21:45:35
    Asynchronous transmission of info IDoc 3 in task 0003 (1 parallel tasks)
    R3
    413
    S
    13.12.2010
    21:45:35
    Altogether, 0 records were filtered out through selection conditions
    RSQU
    037
    S
    13.12.2010
    21:45:35
    IDOC: Info IDoc 3, IDoc No. 5136703, Duration 00:00:00
    R3
    088
    S
    13.12.2010
    21:45:35
    IDoc: Start = 13.12.2010 21:45:35, End = 13.12.2010 21:45:35
    R3
    089
    S
    13.12.2010
    21:55:37
    tRFC: Data Package = 1, TID = 0AF0842B00C84D0694000F00, Duration = 00:10:03, ARFCSTATE = SYSFAIL
    R3
    038
    S
    13.12.2010
    21:55:37
    tRFC: Start = 13.12.2010 21:45:34, End = 13.12.2010 21:55:37
    R3
    039
    S
    13.12.2010
    21:55:37
    Synchronized transmission of info IDoc 4 (0 parallel tasks)
    R3
    414
    S
    13.12.2010
    21:55:37
    IDOC: Info IDoc 4, IDoc No. 5136717, Duration 00:00:00
    R3
    088
    S
    13.12.2010
    21:55:37
    IDoc: Start = 13.12.2010 21:55:37, End = 13.12.2010 21:55:37
    R3
    089
    S
    13.12.2010
    21:55:37
    Job finished
    00
    517
    S

  • Where would you check performance of webi? query is taking long time to run

    Hello All,
    In the bex query world running on portal you were able to go to sm50 and check what the query is doing and where it is taking a long time or atleast you were able to see the processes runing.
    Where would you check the running processes when you are running a webi query, we are trying to write a webi report which is on universe which is created on bex query. The report is very simple just two fields and an mandatory variable which is coming from bex query (have defined the variable in bex query). When we exeute the query it is taking a long time just spinning and I am not getting any data back, on the same query before even hitting the run query button, I am trying to put a object in query filters and set the filter as In list from Value(s) from list and it is taking forever to set that filter.
    Can we go to CMC or BW backend and check anywhere we are using sap authentication, I see the number of sessions in CMC but that is it.
    Thanks for help in advance.

    Thank you both for the replies.
    How would I get the MDX that is generated by the query, I remember there is a note for starting the MDX logging. Can you please let em know how would I get the MDX statement. Thanks.
    Gowtham - What is the optimal array fetch size that needs to set for the universes, can you explain bit more about array fetch size?
    All our universes are on BEx queries designed in SAP BW in that case does the array fetch size matter and array bind size matter? I had read this in oneof the universe designer manuals for OLAP universes The Array fetch size, Array bind size, and Login timeout parameters are not used for OLAP connections
    Thanks again for replies.

  • Select Query taking long time to run second time

    Hi All,
    I have Oracle 11gR1 in windows server 2008 R2 .
    I have some tables with 10 million records . When i run the select query for those tables first time it gives me result in 15 seconds but if i am running the same script second time from the same session I am getting the result in 15 minutes to complete ..
    Why it is happening? What may be the solution for this ?
    Thanks & Regards,
    Vikash jain(Junior DBA)

    Hi Mohamed,
    I just saw that both the times for the same query execution plan is different ..
    here are the details :
    First time Second Time
    g84m3qqjv2p3q g84m3qqjv2p3q
    2733045235 1310485984
    So plz tell me how should i force database to use the first execution plan ?
    I got this script for forcing the Db to use the same execution plan
    accept sql_id -
    prompt 'Enter value for sql_id: ' -
    default 'X0X0X0X0'
    accept plan_hash_value -
    prompt 'Enter value for plan_hash_value: ' -
    default 'X0X0X0X0'
    accept fixed -
    prompt 'Enter value for fixed (NO): ' -
    default 'NO'
    accept enabled -
    prompt 'Enter value for enabled (YES): ' -
    default 'YES'
    accept plan_name -
    prompt 'Enter value for plan_name (ID_sqlid_planhashvalue): ' -
    default 'X0X0X0X0'
    set feedback off
    set sqlblanklines on
    set serveroutput on
    declare
    l_plan_name varchar2(40);
    l_old_plan_name varchar2(40);
    l_sql_handle varchar2(40);
    ret binary_integer;
    l_sql_id varchar2(13);
    l_plan_hash_value number;
    l_fixed varchar2(3);
    l_enabled varchar2(3);
    major_release varchar2(3);
    minor_release varchar2(3);
    begin
    select regexp_replace(version,'\..*'), regexp_substr(version,'[0-9]+',1,2) into major_release, minor_release from v$instance;
    minor_release := 2;
    l_sql_id := '&&sql_id';
    l_plan_hash_value := to_number('&&plan_hash_value');
    l_fixed := '&&fixed';
    l_enabled := '&&enabled';
    ret := dbms_spm.load_plans_from_cursor_cache(
    sql_id=>l_sql_id,
    plan_hash_value=>l_plan_hash_value,
    fixed=>l_fixed,
    enabled=>l_enabled);
    if minor_release = '1' then
    -- 11gR1 has a bug that prevents renaming Baselines
    dbms_output.put_line(' ');
    dbms_output.put_line('Baseline created.');
    dbms_output.put_line(' ');
    else
    -- This statements looks for Baselines create in the last 4 seconds
    select sql_handle, plan_name,
    decode('&&plan_name','X0X0X0X0','SQLID_'||'&&sql_id'||'_'||'&&plan_hash_value','&&plan_name')
    into l_sql_handle, l_old_plan_name, l_plan_name
    from dba_sql_plan_baselines spb
    where created > sysdate-(1/24/60/15);
    ret := dbms_spm.alter_sql_plan_baseline(
    sql_handle=>l_sql_handle,
    plan_name=>l_old_plan_name,
    attribute_name=>'PLAN_NAME',
    attribute_value=>l_plan_name);
    dbms_output.put_line(' ');
    dbms_output.put_line('Baseline '||upper(l_plan_name)||' created.');
    dbms_output.put_line(' ');
    end if;
    end;
    undef sql_id
    undef plan_hash_value
    undef plan_name
    undef fixed
    set feedback on
    Output:
    Enter value for sql_id: g84m3qqjv2p3q
    Enter value for plan_hash_value: 2733045235
    Enter value for fixed (NO):
    Enter value for enabled (YES):
    Enter value for plan_name (ID_sqlid_planhashvalue): g84m3qqjv2p3q
    old 16: l_sql_id := '&&sql_id';
    new 16: l_sql_id := 'g84m3qqjv2p3q';
    old 17: l_plan_hash_value := to_number('&&plan_hash_value');
    new 17: l_plan_hash_value := to_number('2733045235');
    old 18: l_fixed := '&&fixed';
    new 18: l_fixed := 'NO';
    old 19: l_enabled := '&&enabled';
    new 19: l_enabled := 'YES';
    old 40: decode('&&plan_name','X0X0X0X0','SQLID_'||'&&sql_id'||'_'||'&&plan_hash_value','&&plan_name')
    new 40: decode('g84m3qqjv2p3q','X0X0X0X0','SQLID_'||'g84m3qqjv2p3q'||'_'||'2733045235','g84m3qqjv2p3q')
    declare
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 39
    Kindly help me to resolve the issue ..
    Thanks & Regards,
    Vikash Jain(Junior DBA)

  • BEA query is taking long time to run

    Hi All,
    I am using BEA Weblogic 10.2. I am performing seraching in the repository.
    The query string is:
    cm_lifeCycleStatus==4&&SERVICE == 'RBT' &&COPYRIGHTTO >= toDate('yyyy-MM-dd', '2010-07-01')&&COPYRIGHTFROM <= toDate('yyyy-MM-dd', '2010-07-01')
    Here SERVICE,COPYRIGHTTO,COPYRIGHTFROM are the property.
    If i am using cm_midifiedDate instead of COPYRIGHTTO,COPYRIGHTFROM , it giving result very fast.
    But the the need is to use COPYRIGHTTO,COPYRIGHTFROM .
    Please suggest me how can i optimize this query.
    The code to fecth is:
    ctx = new ContentContext(this.getRequest());
    IVersionManager ivm = ContentManagerFactory.getVersionManager();
    Expression exp = ExpressionHelper.parse(query);
    Search search = new Search();
    search.setExpression(exp);
    search.setFullTextSearch(false);
    nodeList = ivm.search(ctx, search);
    Thnaks
    Arvind

    I'm not completely sure that the Version tables have indices that are optimized for query performance. Based on your original post, I'm assuming that you are eventually getting the correct results back but it just takes too long? You might want to do some database diagnostics to see how the query is being executed and if any index is being consulted. I would assume not and that is where your performance issue might be coming from. The published content tables (such as CM_NODE) are optimized for query response.
    Explicit properties only apply to the Published CM_NODE table. To do this, you'd add a column to the CM_NODE database table, ensure that the datatype on the column matches your desired Property data type. Then, in your Content Type definition, in the Portal Admin, you'd mark the "Is Explicit" attribute on the Property and enter the name of the database column which you created to store the values. Of course, in the database, you'd probably want to create an index on this new column to make it faster for searching.
    Brad

  • Report Taking long time in QA system

    Gurus,
    I have developed a report which works fine in dev.Though in QA system its performance is not okay.Please go through th ecode and help me through.
    TABLES: REGUH,BSAK,BSIS,LFA1,LFB1,BSAS.
    ****    Internal table declaration starts.
    ***    To Store Vendor clearing Document.
    ***    Internal table for credit card sub total.
    DATA : BEGIN OF I_BSAK OCCURS 0,
           XBLNR LIKE BSAK-XBLNR,
           LIFNR LIKE REGUH-LIFNR,
           PRCTR LIKE BSEG-PRCTR,
           NAME1 LIKE LFA1-NAME1,
           AUGDT LIKE BSAK-AUGDT,
           AUGBL LIKE BSAK-AUGBL,
           XBLNR1 LIKE BSAK-XBLNR,
           GJAHR LIKE BSAK-GJAHR,
           BELNR LIKE BSAK-BELNR,
           BLDAT LIKE BSAK-BLDAT,
           BLART LIKE BSAK-BLART,
           SHKZG LIKE BSAK-SHKZG,
           DMBTR LIKE BSAK-DMBTR,
           AUGGJ LIKE BSAK-AUGGJ,
           CPUDT LIKE BSAK-CPUDT,
           LAUFD LIKE REGUH-LAUFD,
           KTOKK LIKE LFA1-KTOKK,
           RWBTR LIKE REGUH-RWBTR,
           VBLNR LIKE REGUH-VBLNR,
           HKONT LIKE BSEG-HKONT,
           END OF I_BSAK.
    ***    Internal table for Vendor sub total.
    DATA : BEGIN OF I_BSAK_LIFNR OCCURS 0,
           LIFNR LIKE REGUH-LIFNR,
           XBLNR LIKE BSAK-XBLNR,
           PRCTR LIKE BSEG-PRCTR,
           NAME1 LIKE LFA1-NAME1,
           AUGDT LIKE BSAK-AUGDT,
           AUGBL LIKE BSAK-AUGBL,
           XBLNR1 LIKE BSAK-XBLNR,
           GJAHR LIKE BSAK-GJAHR,
           BELNR LIKE BSAK-BELNR,
           BLDAT LIKE BSAK-BLDAT,
           BLART LIKE BSAK-BLART,
           SHKZG LIKE BSAK-SHKZG,
           DMBTR LIKE BSAK-DMBTR,
           AUGGJ LIKE BSAK-AUGGJ,
           CPUDT LIKE BSAK-CPUDT,
           LAUFD LIKE REGUH-LAUFD,
           KTOKK LIKE LFA1-KTOKK,
           RWBTR LIKE REGUH-RWBTR,
           VBLNR LIKE REGUH-VBLNR,
           HKONT LIKE BSEG-HKONT,
           END OF I_BSAK_LIFNR.
    ***    Internal table for Profit center sub total.
    DATA : BEGIN OF I_BSAK_PRCTR OCCURS 0,
           PRCTR LIKE BSEG-PRCTR,
           BELNR LIKE BSAK-BELNR,
           GJAHR LIKE BSAK-GJAHR,
           LIFNR LIKE REGUH-LIFNR,
           XBLNR LIKE BSAK-XBLNR,
           HKONT LIKE BSEG-HKONT,
           NAME1 LIKE LFA1-NAME1,
           AUGDT LIKE BSAK-AUGDT,
           AUGBL LIKE BSAK-AUGBL,
           XBLNR1 LIKE BSAK-XBLNR,
           BLDAT LIKE BSAK-BLDAT,
           BLART LIKE BSAK-BLART,
           SHKZG LIKE BSAK-SHKZG,
           DMBTR LIKE BSAK-DMBTR,
           AUGGJ LIKE BSAK-AUGGJ,
           CPUDT LIKE BSAK-CPUDT,
           LAUFD LIKE REGUH-LAUFD,
           KTOKK LIKE LFA1-KTOKK,
           RWBTR LIKE REGUH-RWBTR,
           VBLNR LIKE REGUH-VBLNR,
           END OF I_BSAK_PRCTR.
    ***  Work area for sub totals.
    DATA: WA LIKE I_BSAK.
    DATA : I_BSAK_INIT LIKE I_BSAK OCCURS 0 WITH HEADER LINE.
    ***    To store line item.
    DATA : BEGIN OF I_BSEG OCCURS 0,
           BELNR LIKE BSEG-BELNR,
           GJAHR LIKE BSEG-GJAHR,
           BUZEI LIKE BSEG-BUZEI,
           HKONT LIKE BSEG-HKONT,
           SHKZG LIKE BSEG-SHKZG,
           DMBTR LIKE BSEG-DMBTR,
           PRCTR LIKE BSEG-PRCTR,
           LIFNR LIKE REGUH-LIFNR,
           AUGDT LIKE BSAK-AUGDT,
           AUGBL LIKE BSAK-AUGBL,
           XBLNR LIKE BSAK-XBLNR,
           XBLNR1 LIKE BSAK-XBLNR,
           BLDAT LIKE BSAK-BLDAT,
           BLART LIKE BSAK-BLART,
           NAME1 LIKE LFA1-NAME1,
           END OF I_BSEG.
    DATA : BEGIN OF I_BSEG_COPY OCCURS 0,
          PRCTR LIKE BSEG-PRCTR,
          BELNR LIKE BSEG-BELNR,
          GJAHR LIKE BSEG-GJAHR,
          BUZEI LIKE BSEG-BUZEI,
          HKONT LIKE BSEG-HKONT,
          SHKZG LIKE BSEG-SHKZG,
          DMBTR LIKE BSEG-DMBTR,
          LIFNR LIKE REGUH-LIFNR,
          AUGDT LIKE BSAK-AUGDT,
          AUGBL LIKE BSAK-AUGBL,
          XBLNR LIKE BSAK-XBLNR,
          XBLNR1 LIKE BSAK-XBLNR,
          BLDAT LIKE BSAK-BLDAT,
          BLART LIKE BSAK-BLART,
          NAME1 LIKE LFA1-NAME1,
          END OF I_BSEG_COPY.
    ***    To store GL account name
    DATA: BEGIN OF I_SKAT OCCURS 0,
          SAKNR LIKE SKAT-SAKNR,
          TXT50 LIKE SKAT-TXT50,
          END OF I_SKAT.
    ***   To store Vendor detail
    DATA: BEGIN OF I_LFA1 OCCURS 0,
          LIFNR LIKE LFA1-LIFNR,
          NAME1 LIKE LFA1-NAME1,
          KTOKK LIKE LFA1-KTOKK,
          END OF I_LFA1.
    DATA: I_INACT TYPE TABLE OF SY-UCOMM.
    ***  End of Internal table declaration.
    ***  Constant for company code
    CONSTANTS : C_BUKRS(4) VALUE '0010'.
    ***  Data declaration.
    DATA: FR_LAUFDT LIKE REGUH-LAUFD,
          TO_LAUFDT LIKE REGUH-LAUFD,
          COL,
          HEADING(80),
          HEADING1(10),
          HEADING2(80),
          AUTH_RESTRICT,
          G_DETAIL,
          G_SORTV,
          G_SORTP,
          G_SORTC,
          G_FLAG,
          V_XBLNR LIKE BSAK-XBLNR,
          V_UCOMM LIKE SY-UCOMM,
          V_AUGBL LIKE BSAS-AUGBL,
          V_BELNR LIKE BSAS-BELNR.
    DATA : BEGIN OF I_SEL OCCURS 0 ,
           AUGBL LIKE BSAK-AUGBL,
           END OF I_SEL.
    DATA: PROGNAME TYPE SY-REPID,
          DYNNUM   TYPE SY-DYNNR,
          DYNPRO_VALUES TYPE TABLE OF DYNPREAD,
          FIELD_VALUE LIKE LINE OF DYNPRO_VALUES,
          VALUES_TAB LIKE I_SEL OCCURS 0 WITH HEADER LINE.
    DATA : RETURN_TAB LIKE  DDSHRETVAL OCCURS 0 WITH HEADER LINE.
    ***  Selection screen.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(30) TXT_PD FOR FIELD P_LAUFDF.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS P_LAUFDF LIKE REGUH-LAUFD OBLIGATORY.
    SELECTION-SCREEN COMMENT 52(5) TXT_TO FOR FIELD P_LAUFDT.
    SELECTION-SCREEN POSITION POS_HIGH.
    PARAMETERS P_LAUFDT LIKE REGUH-LAUFD.
    SELECTION-SCREEN END OF LINE.
    SELECT-OPTIONS: S_KTOKK FOR LFA1-KTOKK.
    PARAMETERS: P_RWBTR LIKE REGUH-RWBTR.
    SELECT-OPTIONS: S_LIFNR FOR REGUH-LIFNR.
    * S_XBLNR FOR BSAK-XBLNR MATCHCODE OBJECT ZXBLNR.
    **** Added By Rajesh On 17 OCT 08 (DEVK914797) ****
    SELECT-OPTIONS: S_BELNR  FOR BSAK-BELNR.
    **** End of Addition By Rajesh *****
    *** Added By Samir On 04 Sep 08 (DEVK914623) ***
    SELECTION-SCREEN SKIP.
    PARAMETERS: CHK_REC AS CHECKBOX.
    *** End Of Addition By Samir ***
    SELECTION-SCREEN END OF BLOCK B1.
    ***  Initialization.
    INITIALIZATION.
      TXT_PD = 'Payment Date'.
      TXT_TO = 'to' .
      G_SORTC = 'X'.
    ***  At selection-screen.
    AT SELECTION-SCREEN.
      FR_LAUFDT =  P_LAUFDF.
      IF P_LAUFDT IS INITIAL.
        TO_LAUFDT = FR_LAUFDT.
      ELSE.
        IF P_LAUFDT LT P_LAUFDF.
          MESSAGE E000(ZMSG) WITH 'To Date is less than From date'.
        ENDIF.
        TO_LAUFDT = P_LAUFDT.
      ENDIF.
    ***  Heading.
      WRITE FR_LAUFDT TO HEADING1.
      WRITE TO_LAUFDT TO HEADING2.
      IF HEADING1 <> HEADING2.
        CONCATENATE 'Vendor Credit Card(s) Report for the Payment Date'
        HEADING1 'To' HEADING2 INTO HEADING2 SEPARATED BY SPACE.
      ELSE.
        CONCATENATE 'Vendor Credit Card(s) Report for the Payment Date'
        HEADING1 INTO HEADING2 SEPARATED BY SPACE.
      ENDIF.
    ***  Start of selection.
    START-OF-SELECTION.
      G_DETAIL = 'X'.
      PERFORM GET_DATA.
      PERFORM MODIFY_ITAB.                          "Process and for authority check.
    *** Added By Samir On 04 Sep 08 (DEVK914623) ***
    **** Changed By Rajesh On 17 OCT 08 (DEVK914797) ****
      IF CHK_REC = 'X'.
        LOOP AT I_BSAK.
          SELECT SINGLE BELNR
          INTO   V_BELNR
          FROM   BSAS
          WHERE  BUKRS = C_BUKRS
            AND  HKONT = '0000002012'
            AND  BELNR = I_BSAK-AUGBL
            AND  BUDAT = I_BSAK-AUGDT
            AND  BELNR IN S_BELNR.               " For displaying only reconciled items.
    **** End of Addition By Rajesh *****
          IF SY-SUBRC <> 0.
            DELETE I_BSAK.
          ENDIF.
        ENDLOOP.
      ENDIF.
    *** End Of Addition By Samir ***
      LOOP AT I_BSAK.
        MOVE-CORRESPONDING I_BSAK TO: I_BSAK_LIFNR.
        APPEND: I_BSAK_LIFNR.
        CLEAR:  I_BSAK_LIFNR.
      ENDLOOP.
      LOOP AT I_BSAK.
        MOVE-CORRESPONDING I_BSAK TO: I_BSAK_PRCTR.
        READ TABLE I_BSEG WITH KEY BELNR = I_BSAK-BELNR.
        I_BSAK_PRCTR-HKONT = I_BSEG-HKONT.
        APPEND: I_BSAK_PRCTR.
        CLEAR:  I_BSAK_PRCTR.
      ENDLOOP.
    *loop at i_bseg.
    *   MOVE-CORRESPONDING I_BSAK TO: I_BSAK_PRCTR.
    *endloop.
    *perform write_data.
      PERFORM DISPLAY_OUTPUT.
    AT USER-COMMAND.
      CASE SY-UCOMM.
        WHEN 'EXPA'.
          G_DETAIL = 'X'.
        WHEN 'COLL'.
          CLEAR G_DETAIL.
        WHEN 'SORTV'.
          CLEAR: V_UCOMM.
          V_UCOMM = 'SORTV'.
          G_SORTV = 'X'.
          CLEAR G_SORTP.
          CLEAR G_SORTC.
        WHEN 'SORTC'.
          CLEAR: V_UCOMM.
          V_UCOMM = 'SORTC'.
          CLEAR G_SORTV.
          CLEAR G_SORTP.
          G_SORTC = 'X'.
        WHEN 'SORTP'.
          CLEAR: V_UCOMM.
          V_UCOMM = 'SORTP'.
          CLEAR G_SORTV.
          CLEAR G_SORTC.
          G_SORTP = 'X'.
      ENDCASE.
      PERFORM DISPLAY_OUTPUT.
    *perform write_data.
    ***  To get the header text in the output.
    TOP-OF-PAGE.
      PERFORM TOP_OF_PAGE.
    TOP-OF-PAGE DURING LINE-SELECTION.
      PERFORM TOP_OF_PAGE.
    *&      Form  GET_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_DATA .
      SY-LSIND = 0.
      P_RWBTR = P_RWBTR * -1.
      REFRESH I_BSAK_INIT.
      CLEAR I_BSAK_INIT.
      SELECT A~LIFNR A~LAUFD A~VBLNR A~RWBTR
              B~KTOKK B~NAME1
                FROM REGUH AS A INNER JOIN LFA1 AS B
                ON   A~LIFNR = B~LIFNR
                INTO CORRESPONDING FIELDS OF TABLE I_BSAK_INIT
                WHERE A~LAUFD BETWEEN FR_LAUFDT AND TO_LAUFDT AND
                      A~XVORL <> 'X' AND
                      A~ZBUKR = C_BUKRS  AND
                      A~LIFNR IN S_LIFNR AND
                      A~RZAWE = 'X' AND
                      A~RWBTR LE P_RWBTR AND
                      B~KTOKK IN S_KTOKK.
      IF SY-SUBRC <> 0.
        MESSAGE 'Records Not Found' TYPE 'I'.
        LEAVE LIST-PROCESSING.
      ENDIF.
    *---------------------PERFORMANCE ISSUE--------------------------
    delete adjacent duplicates from i_bsak_init.
      IF NOT I_BSAK_INIT[] IS INITIAL.
       SELECT LIFNR AUGDT AUGBL GJAHR BELNR CPUDT BLDAT XBLNR
               BLART SHKZG DMBTR AUGGJ
                  FROM BSAK
                  INTO CORRESPONDING FIELDS OF TABLE I_BSAK
                  FOR ALL ENTRIES IN I_BSAK_INIT
                  WHERE BUKRS = C_BUKRS  AND
                  AUGBL = I_BSAK_INIT-VBLNR AND
                  XZAHL <> 'X'.
      ENDIF.
    ***  Selecting all line item records from BSEG table.
      IF I_BSAK[] IS NOT INITIAL.
        SELECT BELNR GJAHR BUZEI HKONT SHKZG DMBTR PRCTR
               FROM BSEG
               INTO CORRESPONDING FIELDS OF TABLE I_BSEG
               FOR ALL ENTRIES IN I_BSAK
               WHERE BUKRS = C_BUKRS      AND
                     BELNR = I_BSAK-BELNR AND
                     GJAHR = I_BSAK-GJAHR AND
                     BELNR <> I_BSAK-AUGBL AND
                     KOART <> 'K'.
      ENDIF.
    ***  Selecting gl account name from SKAT table.
      IF I_BSEG[] IS NOT INITIAL.
        SELECT SAKNR TXT50
               FROM SKAT
               INTO CORRESPONDING FIELDS OF TABLE I_SKAT
               FOR ALL ENTRIES IN I_BSEG
               WHERE SPRAS = 'E'     AND
                     KTOPL = C_BUKRS AND
                     SAKNR = I_BSEG-HKONT.
      ENDIF.
      SORT I_BSAK BY BELNR.
      SORT I_BSAK_INIT BY VBLNR.
      SORT I_BSEG BY BELNR GJAHR.
    *** Selecting Credit Card No. into I_XBLNR table.
      LOOP AT I_BSAK.
        I_BSAK-XBLNR1 = I_BSAK-XBLNR.
        CLEAR: V_XBLNR.
        SELECT SINGLE XBLNR FROM BKPF INTO V_XBLNR
                              WHERE BUKRS = C_BUKRS  AND
                              BELNR = I_BSAK-AUGBL.
        IF SY-SUBRC EQ 0.
          I_BSAK-XBLNR = V_XBLNR.
        ENDIF.
        READ TABLE I_BSEG WITH KEY BELNR = I_BSAK-BELNR
                                   GJAHR = I_BSAK-GJAHR
                                   BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          I_BSAK-PRCTR = I_BSEG-PRCTR.
        ENDIF.
        READ TABLE I_BSAK_INIT WITH KEY VBLNR = I_BSAK-AUGBL BINARY SEARCH.
        IF SY-SUBRC EQ 0.
          I_BSAK-NAME1 = I_BSAK_INIT-NAME1.
          I_BSAK-LAUFD = I_BSAK_INIT-LAUFD.
          I_BSAK-KTOKK = I_BSAK_INIT-KTOKK.
        ENDIF.
        MODIFY I_BSAK TRANSPORTING XBLNR XBLNR1 PRCTR NAME1 LAUFD KTOKK.
      ENDLOOP.
    ENDFORM.                    " GET_DATA
    *&      Form  MODIFY_ITAB
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM MODIFY_ITAB .
    ***  Process on internal table
      LOOP AT I_BSAK.
        AUTHORITY-CHECK OBJECT 'F_LFA1_GRP'
                             ID 'KTOKK'
                          FIELD I_BSAK-KTOKK.
        IF SY-SUBRC NE 0.
          DELETE I_BSAK WHERE KTOKK EQ I_BSAK-KTOKK.
          AUTH_RESTRICT = 'X'.
          CONTINUE.
        ENDIF.
      ENDLOOP.
      IF AUTH_RESTRICT EQ 'X'.
        MESSAGE S005(ZMSG).
      ENDIF.
      LOOP AT I_BSAK.
        IF I_BSAK-SHKZG = 'S'.
          I_BSAK-DMBTR = I_BSAK-DMBTR * -1.
          MODIFY I_BSAK .
        ENDIF.
      ENDLOOP.
      LOOP AT I_BSEG.
        IF I_BSEG-SHKZG = 'H'.
          I_BSEG-DMBTR = I_BSEG-DMBTR * -1.
          MODIFY I_BSEG .
        ENDIF.
      ENDLOOP.
    ***  Default Sorting on internal table .
      SORT I_BSAK BY XBLNR LIFNR BELNR.
      SORT I_BSEG BY BELNR HKONT.
      SORT I_SKAT BY SAKNR.
    ENDFORM.                    " MODIFY_ITAB
    *&      Form  DISPLAY_OUTPUT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY_OUTPUT .
    ***  Coding for detail output starts
      CLEAR SY-LSIND.
      REFRESH I_INACT.
      IF G_DETAIL EQ 'X'.
        APPEND 'EXPA' TO I_INACT.
      ELSE.
        APPEND 'COLL' TO I_INACT.
      ENDIF.
      IF G_SORTV EQ 'X'.
        APPEND 'SORTV' TO I_INACT.
        SORT I_BSAK BY LIFNR.
        SORT I_BSAK_LIFNR BY LIFNR.
      ELSEIF G_SORTP EQ 'X'.
        APPEND 'SORTP' TO I_INACT.
        SORT I_BSAK BY PRCTR.
        SORT I_BSAK_PRCTR BY PRCTR.
      ELSE.
        APPEND 'SORTC' TO I_INACT.
        SORT I_BSAK BY XBLNR.
      ENDIF.
      SET PF-STATUS 'STAT' EXCLUDING I_INACT.
      IF V_UCOMM = 'SORTC'.
        PERFORM WRITE_DATA.
      ELSEIF V_UCOMM = 'SORTV' .     "Subroutine for card sub total.
        PERFORM WRITE_DATA_VENDOR.   "Subroutine for vendor sub total.
      ELSEIF V_UCOMM = 'SORTP'.      "Subroutine for profit center sub total.
    *    PERFORM WRITE_DATA_PROFIT.
        PERFORM WRITE_DATA_PROFIT_NEW.  " New subroutine for profit center.
      ELSE.
        PERFORM WRITE_DATA.
      ENDIF.
    ENDFORM.                    " DISPLAY_OUTPUT
    *&      Form  F_COLOR
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM F_COLOR .
      IF COL = 'X'.
        FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
        CLEAR COL.
      ELSE.
        FORMAT COLOR COL_NORMAL INTENSIFIED ON.
        COL = 'X'.
      ENDIF.
    ENDFORM.                    " F_COLOR
    *&      Form  TOP_OF_PAGE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM TOP_OF_PAGE .
    ***  Top-of-page is Common for summary and detail report.
    ***  To display top of page only on first page.
      IF SY-PAGNO = 1 .
        CALL FUNCTION 'Z_NPL_HEADING'
          EXPORTING
            LINE_SIZE = SY-LINSZ
            HEADING1  = HEADING
            HEADING2  = HEADING2.
        FORMAT COLOR COL_HEADING INTENSIFIED ON.
    ****  To get output columns text descprition
        ULINE.
        WRITE:/ SY-VLINE NO-GAP, (10) 'Vendor' NO-GAP,
                SY-VLINE NO-GAP, (35) 'Name of Payee' NO-GAP,
                SY-VLINE NO-GAP, (10) 'G/L Num' NO-GAP,
                SY-VLINE NO-GAP, (42) 'G/L Name' NO-GAP,
                SY-VLINE NO-GAP, (07) 'Profit Center' NO-GAP,
                SY-VLINE NO-GAP, (16) 'Credit Card NO.' NO-GAP,
                SY-VLINE NO-GAP, (10) 'Pmnt Date' NO-GAP,
                SY-VLINE NO-GAP, (08) 'Doc.Type' NO-GAP,
                SY-VLINE NO-GAP, (10) 'Inv.Date' NO-GAP,
                SY-VLINE NO-GAP, (16) 'Invoice' NO-GAP,
                SY-VLINE NO-GAP, (14) 'Amount Paid' NO-GAP,
                SY-VLINE.
        ULINE.
      ENDIF.
    ENDFORM.                    " TOP_OF_PAGE
    *&      Form  WRITE_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_DATA .
      LOOP AT I_BSAK.
        CLEAR WA.
        MOVE-CORRESPONDING I_BSAK TO WA.
        PERFORM WRITE.
        AT END OF XBLNR.                             "Card sub total
          IF G_SORTC EQ 'X'.
            SUM.
            IF G_DETAIL EQ 'X'. ULINE. ENDIF.
            FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
            WRITE:/ SY-VLINE NO-GAP, (25) 'Credit Card Total:', I_BSAK-XBLNR ,
                    (35) I_BSAK-NAME1 NO-GAP.
            WRITE: 110 SY-VLINE NO-GAP,(79) I_BSAK-DMBTR NO-GAP
                                             CURRENCY 'USD',SY-VLINE.
            ULINE.
          ENDIF.
        ENDAT.                                     "End of Credit card Detail
    ****  Grand total
        AT LAST.                                   "Grand total
          SUM.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
          WRITE:/ SY-VLINE NO-GAP,(107) 'Grand Total:',
                  SY-VLINE NO-GAP,(79) I_BSAK-DMBTR NO-GAP
                                         CURRENCY 'USD', SY-VLINE.
          ULINE.
        ENDAT.
      ENDLOOP.                                     "End for I_BSAK loop
    ENDFORM.                    " WRITE_DATA
    *&      Form  WRITE_DATA_VENDOR
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_DATA_VENDOR .
      LOOP AT I_BSAK_LIFNR.
        CLEAR WA.
        MOVE-CORRESPONDING I_BSAK_LIFNR TO WA.
        PERFORM WRITE.
        AT END OF LIFNR.                           "Vendor sub Total
          IF G_SORTV EQ 'X'.
            SUM.
            IF G_DETAIL EQ 'X'. ULINE. ENDIF.
            FORMAT COLOR COL_TOTAL INTENSIFIED ON.
            WRITE:/ SY-VLINE NO-GAP,(15) 'Vendor Total:', I_BSAK_LIFNR-LIFNR.
            WRITE: 110 SY-VLINE NO-GAP,(79) I_BSAK_LIFNR-DMBTR NO-GAP
                                             CURRENCY 'USD',SY-VLINE.
            ULINE.
          ENDIF.
        ENDAT.                                     "End of Vendor Total
    ****  Grand total
        AT LAST.                                   "Grand total
          SUM.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
          WRITE:/ SY-VLINE NO-GAP,(107) 'Grand Total:',
                  SY-VLINE NO-GAP,(79) I_BSAK_LIFNR-DMBTR NO-GAP
                                         CURRENCY 'USD', SY-VLINE.
          ULINE.
        ENDAT.
      ENDLOOP.                                     "End for I_BSAK_LIFNR loop
    ENDFORM.                    " WRITE_DATA_VENDOR
    *&      Form  WRITE_DATA_PROFIT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_DATA_PROFIT .
    *** Changed By Samir On 18 Sep 08 (DEVK914685) ***
      LOOP AT I_BSAK_PRCTR.
        READ TABLE I_BSAK WITH KEY BELNR = I_BSAK_PRCTR-BELNR
                                   GJAHR = I_BSAK_PRCTR-GJAHR.
        IF SY-SUBRC = 0.
          I_BSAK_PRCTR-LIFNR  = I_BSAK-LIFNR.
          I_BSAK_PRCTR-NAME1  = I_BSAK-NAME1.
          I_BSAK_PRCTR-XBLNR  = I_BSAK-XBLNR.
          I_BSAK_PRCTR-LAUFD  = I_BSAK-LAUFD.
          I_BSAK_PRCTR-BLART  = I_BSAK-BLART.
          I_BSAK_PRCTR-BLDAT  = I_BSAK-BLDAT.
          I_BSAK_PRCTR-XBLNR1 = I_BSAK-XBLNR1.
          MODIFY I_BSAK_PRCTR TRANSPORTING LIFNR NAME1 XBLNR LAUFD BLART BLDAT XBLNR1.
        ENDIF.
      ENDLOOP.
    *** End Of Changes By Samir On 18 Sep 08 ***
      SORT I_BSAK_PRCTR BY PRCTR.
      LOOP AT I_BSAK_PRCTR.
        PERFORM F_COLOR.
        IF G_DETAIL = 'X'.
    *** Changed By Samir On 18 Sep 08 (DEVK914685) ***
          READ TABLE I_SKAT WITH KEY SAKNR = I_BSAK_PRCTR-HKONT BINARY SEARCH.
          WRITE:/ SY-VLINE NO-GAP, (10) I_BSAK_PRCTR-LIFNR NO-GAP,
                  SY-VLINE NO-GAP, (35) I_BSAK_PRCTR-NAME1 NO-GAP,
                  SY-VLINE NO-GAP, (10) I_BSAK_PRCTR-HKONT NO-GAP,
                  SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
                  SY-VLINE NO-GAP, (07) I_BSAK_PRCTR-PRCTR NO-GAP,
                  SY-VLINE NO-GAP, (16) I_BSAK_PRCTR-XBLNR NO-GAP,     " CREDIT CARD NO.
                  SY-VLINE NO-GAP, (10) I_BSAK_PRCTR-LAUFD NO-GAP,
                  SY-VLINE NO-GAP, (08) I_BSAK_PRCTR-BLART NO-GAP,
                  SY-VLINE NO-GAP, (10) I_BSAK_PRCTR-BLDAT NO-GAP,
                  SY-VLINE NO-GAP, (16) I_BSAK_PRCTR-XBLNR1 NO-GAP.
          WRITE:  SY-VLINE NO-GAP, (14) I_BSAK_PRCTR-DMBTR NO-GAP.
          WRITE:  SY-VLINE.
        ENDIF.
    *** End Of Changes By Samir On 18 Sep 08 ***
        AT END OF PRCTR.                           "Profit Center sub Total
          IF G_SORTP EQ 'X'.
            SUM.
            IF G_DETAIL EQ 'X'. ULINE. ENDIF.
            FORMAT COLOR COL_TOTAL INTENSIFIED ON.
            WRITE:/ SY-VLINE NO-GAP,(07) 'Profit Center Total:', I_BSAK_PRCTR-PRCTR.
            WRITE: 110 SY-VLINE NO-GAP,(79) I_BSAK_PRCTR-DMBTR NO-GAP
                                             CURRENCY 'USD',SY-VLINE.
            ULINE.
          ENDIF.
        ENDAT.                                    "End of Profit Center Total
    ****  Grand total
        AT LAST.                                  "Grand total
          SUM.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
          WRITE:/ SY-VLINE NO-GAP,(107) 'Grand Total:',
                  SY-VLINE NO-GAP,(79) I_BSAK_PRCTR-DMBTR NO-GAP
                                         CURRENCY 'USD', SY-VLINE.
          ULINE.
        ENDAT.
      ENDLOOP.                                     "End for I_BSAK_PRCTR loop
    ENDFORM.                    " WRITE_DATA_PROFIT
    *&      Form  WRITE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE .
      IF G_DETAIL = 'X'.
        IF WA-KTOKK = 'Z001'.                   " For HR Vendors
          PERFORM F_COLOR.
          READ TABLE I_BSEG WITH KEY BELNR = WA-BELNR GJAHR = WA-GJAHR BINARY SEARCH .
          READ TABLE I_SKAT WITH KEY SAKNR = I_BSEG-HKONT BINARY SEARCH.
          WRITE:/ SY-VLINE NO-GAP, (10) WA-LIFNR NO-GAP,
                  SY-VLINE NO-GAP, (35) WA-NAME1 NO-GAP,
                  SY-VLINE NO-GAP, (10) I_BSEG-HKONT NO-GAP,
                  SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
    *** Changed By Samir On 18 Sep 08 (DEVK914685) ***
    *             SY-VLINE NO-GAP, (07) WA-PRCTR NO-GAP,
                  SY-VLINE NO-GAP, (07) I_BSEG-PRCTR NO-GAP,
    *** End Of Changes By Samir On 18 Sep 08 ***
                  SY-VLINE NO-GAP, (16) WA-XBLNR NO-GAP,        " CREDIT CARD NO.
                  SY-VLINE NO-GAP, (10) WA-LAUFD NO-GAP,
                  SY-VLINE NO-GAP, (08) WA-BLART NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-BLDAT NO-GAP,
                  SY-VLINE NO-GAP, (16) WA-XBLNR1 NO-GAP.
          WRITE: SY-VLINE NO-GAP, (14) WA-DMBTR NO-GAP.
          WRITE: SY-VLINE.
        ELSE.
          LOOP AT I_BSEG WHERE BELNR = WA-BELNR AND GJAHR = WA-GJAHR .
            PERFORM F_COLOR.
            READ TABLE I_SKAT WITH KEY SAKNR = I_BSEG-HKONT BINARY SEARCH.
            WRITE:/ SY-VLINE NO-GAP, (10) WA-LIFNR NO-GAP,
                    SY-VLINE NO-GAP, (35) WA-NAME1 NO-GAP,
                    SY-VLINE NO-GAP, (10) I_BSEG-HKONT NO-GAP,
                    SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
    *** Changed By Samir On 17 Sep 08 (DEVK914671) ***
    *               SY-VLINE NO-GAP, (07) WA-PRCTR NO-GAP,
                    SY-VLINE NO-GAP, (07) I_BSEG-PRCTR NO-GAP,
    *** End Of Changes By Samir On 17 Sep 08 ***
                    SY-VLINE NO-GAP, (16) WA-XBLNR NO-GAP,     " CREDIT CARD NO.
                    SY-VLINE NO-GAP, (10) WA-LAUFD NO-GAP,
                    SY-VLINE NO-GAP, (08) WA-BLART NO-GAP,
                    SY-VLINE NO-GAP, (10) WA-BLDAT NO-GAP,
                    SY-VLINE NO-GAP, (16) WA-XBLNR1 NO-GAP.
            WRITE: SY-VLINE NO-GAP, (14)  I_BSEG-DMBTR NO-GAP.
            WRITE: SY-VLINE.
          ENDLOOP.                                 "End   for I_BSEG loop
        ENDIF.                                     "Endif for I_PAYR-KTOKK = 'Z001'
      ENDIF.                                       "Endif for g_detail = 'X'.
    ENDFORM.                    " WRITE
    *&      Form  WRITE_DATA_PROFIT_NEW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_DATA_PROFIT_NEW .
      REFRESH I_BSEG_COPY.
      CLEAR I_BSEG_COPY.
    *  DATA I_BSEG_COPY LIKE I_BSEG OCCURS 0 WITH HEADER LINE.
    *  I_BSEG_COPY[] = I_BSEG[].
      LOOP AT I_BSEG.
        MOVE-CORRESPONDING I_BSEG TO I_BSEG_COPY.
        APPEND I_BSEG_COPY.
        CLEAR I_BSEG_COPY.
      ENDLOOP.
      LOOP AT I_BSEG_COPY.
        READ TABLE I_BSAK_PRCTR WITH KEY BELNR = I_BSEG_COPY-BELNR GJAHR = I_BSEG_COPY-GJAHR ."HKONT = I_BSEG_COPY-HKONT.
        IF SY-SUBRC = 0.
          I_BSEG_COPY-LIFNR = I_BSAK_PRCTR-LIFNR.
          I_BSEG_COPY-XBLNR = I_BSAK_PRCTR-XBLNR.
          I_BSEG_COPY-NAME1 = I_BSAK_PRCTR-NAME1.
          I_BSEG_COPY-AUGDT = I_BSAK_PRCTR-AUGDT.
          I_BSEG_COPY-AUGBL = I_BSAK_PRCTR-AUGBL.
          I_BSEG_COPY-XBLNR1 = I_BSAK_PRCTR-XBLNR1.
          I_BSEG_COPY-BLDAT = I_BSAK_PRCTR-BLDAT.
          I_BSEG_COPY-BLART = I_BSAK_PRCTR-BLART.
          MODIFY I_BSEG_COPY TRANSPORTING LIFNR XBLNR NAME1 AUGDT AUGBL XBLNR1 BLDAT BLART.
        ENDIF.
      ENDLOOP.
      SORT I_BSAK_PRCTR BY PRCTR BELNR.
      SORT I_BSEG BY BELNR.
      SORT I_BSEG_COPY BY PRCTR.
      DATA COUNT TYPE I.
      DATA G_BELNR LIKE BSAK-BELNR.
      LOOP AT I_BSEG_COPY.
        CLEAR G_BELNR.
        G_BELNR = I_BSEG_COPY-BELNR.
        COUNT = COUNT + 1.
        READ TABLE I_BSAK WITH KEY BELNR = I_BSEG_COPY-BELNR.
        IF SY-SUBRC <> 0.
          DELETE I_BSEG_COPY WHERE BELNR = G_BELNR."INDEX count.
        ENDIF.
      ENDLOOP.
    *  LOOP AT I_BSAK_PRCTR.
      LOOP AT I_BSEG_COPY.
        CLEAR WA.
        MOVE-CORRESPONDING I_BSEG_COPY TO WA.
        PERFORM WRITE_PRCTR.
        AT END OF PRCTR.                           "Profit center sub Total
          IF G_SORTP EQ 'X'.
            SUM.
            IF G_DETAIL EQ 'X'. ULINE. ENDIF.
            FORMAT COLOR COL_TOTAL INTENSIFIED ON.
            WRITE:/ SY-VLINE NO-GAP,(20) 'Profit Center Total:', I_BSEG_COPY-PRCTR.
            WRITE: 110 SY-VLINE NO-GAP,(79) I_BSEG_COPY-DMBTR NO-GAP
                                             CURRENCY 'USD',SY-VLINE.
            ULINE.
          ENDIF.
        ENDAT.                                     "End of Vendor Total
    ****  Grand total
        AT LAST.                                   "Grand total
          SUM.
          FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
          WRITE:/ SY-VLINE NO-GAP,(107) 'Grand Total:',
                  SY-VLINE NO-GAP,(79) I_BSEG_COPY-DMBTR NO-GAP
                                         CURRENCY 'USD', SY-VLINE.
          ULINE.
        ENDAT.
      ENDLOOP.                                     "End for I_BSAK_LIFNR loop
    *ENDFORM.                    " WRITE_DATA_VENDOR
    ENDFORM.                    " WRITE_DATA_PROFIT_NEW
    *&      Form  WRITE_PRCTR
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM WRITE_PRCTR .
      IF G_DETAIL = 'X'.
        IF WA-KTOKK = 'Z001'.                   " For HR Vendors
          PERFORM F_COLOR.
    *      READ TABLE I_BSEG WITH KEY BELNR = WA-BELNR GJAHR = WA-GJAHR PRCTR = WA-PRCTR BINARY SEARCH .
          READ TABLE I_SKAT WITH KEY SAKNR = WA-HKONT BINARY SEARCH.
          WRITE:/ SY-VLINE NO-GAP, (10) WA-LIFNR NO-GAP,
                  SY-VLINE NO-GAP, (35) WA-NAME1 NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-HKONT NO-GAP,
                  SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
    *** Changed By Samir On 18 Sep 08 (DEVK914685) ***
                  SY-VLINE NO-GAP, (07) WA-PRCTR NO-GAP,
    *             SY-VLINE NO-GAP, (07) I_BSEG-PRCTR NO-GAP,
    *** End Of Changes By Samir On 18 Sep 08 ***
                  SY-VLINE NO-GAP, (16) WA-XBLNR NO-GAP,        " CREDIT CARD NO.
                  SY-VLINE NO-GAP, (10) WA-LAUFD NO-GAP,
                  SY-VLINE NO-GAP, (08) WA-BLART NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-BLDAT NO-GAP,
                  SY-VLINE NO-GAP, (16) WA-XBLNR1 NO-GAP.
          WRITE: SY-VLINE NO-GAP, (14) WA-DMBTR NO-GAP.
          WRITE: SY-VLINE.
        ELSE.
    *      LOOP AT I_BSEG WHERE BELNR = WA-BELNR AND GJAHR = WA-GJAHR AND PRCTR = WA-PRCTR .
          PERFORM F_COLOR.
          READ TABLE I_SKAT WITH KEY SAKNR = WA-HKONT BINARY SEARCH.
          WRITE:/ SY-VLINE NO-GAP, (10) WA-LIFNR NO-GAP,
                  SY-VLINE NO-GAP, (35) WA-NAME1 NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-HKONT NO-GAP,
                  SY-VLINE NO-GAP, (42) I_SKAT-TXT50 NO-GAP,
    *** Changed By Samir On 17 Sep 08 (DEVK914671) ***
                 SY-VLINE NO-GAP, (07) WA-PRCTR NO-GAP,
    *              SY-VLINE NO-GAP, (07) I_BSEG-PRCTR NO-GAP,
    *** End Of Changes By Samir On 17 Sep 08 ***
                  SY-VLINE NO-GAP, (16) WA-XBLNR NO-GAP,     " CREDIT CARD NO.
                  SY-VLINE NO-GAP, (10) WA-LAUFD NO-GAP,
                  SY-VLINE NO-GAP, (08) WA-BLART NO-GAP,
                  SY-VLINE NO-GAP, (10) WA-BLDAT NO-GAP,
                  SY-VLINE NO-GAP, (16) WA-XBLNR1 NO-GAP.
          WRITE: SY-VLINE NO-GAP, (14)  WA-DMBTR NO-GAP.
          WRITE: SY-VLINE.
    *      ENDLOOP.                                 "End   for I_BSEG loop
        ENDIF.                                     "Endif for I_PAYR-KTOKK = 'Z001'
      ENDIF.                                       "Endif for g_detail = 'X'.
    ENDFORM.                    " WRITE_PRCTR
    Thanks in advance
    Raj.

    Ralph,
    Thanks for the reply.
    I have marked the sql statement in the code that is taking long time to run but Its my mistake not explaining the same in the description.
    When I was debugging the code the below sql statement was taking long time.
      IF NOT I_BSAK_INIT[] IS INITIAL.
       SELECT LIFNR AUGDT AUGBL GJAHR BELNR CPUDT BLDAT XBLNR
               BLART SHKZG DMBTR AUGGJ
                  FROM BSAK
                  INTO CORRESPONDING FIELDS OF TABLE I_BSAK
                  FOR ALL ENTRIES IN I_BSAK_INIT
                  WHERE BUKRS = C_BUKRS  AND
                  AUGBL = I_BSAK_INIT-VBLNR AND
                  XZAHL <> 'X'.
      ENDIF.
    Any suggestions on the code?
    Regards,
    Raj.

  • Auto message  restart job take long time to run

    Dear all,
    I have configre the auto message restart job in sdoe_bg_job_monitor
    but it take long time to run.
    i have execute the report i have find out that it is faching records from smmw_msg_hdr .
    in the table present 67 laks records are there.
    actually it is taking a lot of time while getting data from the table
    is there any report or tcode for clearing data in the table.
    I need ur valiuble help to resolve the issue.
    Regards
    lakshman balanagu

    HI,
    If you are using oracle database you may need to run table statistics report (RSOANARA) to update the index. The system admin should be able to this.
    Regards,
    Vikas
    Edited by: Vikas Lamba on Aug 3, 2010 1:20 PM

  • Inventory aged reports are taking a very long time to run

    We are using Standard delievered extractors for Inventory.  We have build an Aged report and it is taking a very long time to run as more an more data is added.  We put the inventory in buckets 0-30, 31-60, .... >365 days.  We are aging based on a batch date the user enters.  the problem is it has to go through every record to recalculate because they are non cumulative.
    any ideas/suggestions on how to make this more efficient?  New design?

    Hi MM,
    We can use snapshot of monthly data from Query and store it in DSO at month level.
    We had used APD on Query and then Stored them in DSO1(WO)->DSO2(STD)->Cube->report based on Snap Shot.
    From the New Query , calculate the Age.
    Rgds
    SVU

  • Simple query taking so long time to run

    Below are the queries which are taking very long time to run. It pulls 4 million records approx on first query.
    How can it run fast?
    Thank you.
    SELECTPerson_DEID[CP1] ,
    Admit_DT,
    Discharge_DT, DRG_CD,
    cast (LineAllowedAmount
    AS money)
    as FacAA
    into
    FOET
    FROMdbo.mh_fac_claims_final[CP2] 
    group
    by Person_DEID,
    Admit_DT,
    Discharge_DT, DRG_CD,
    LineAllowedAmount;
    go
    select
    Person_DEID,
    Admit_DT, Discharge_DT,
    DRG_CD, sum(facAA)
    as FacAA_SUM[CP3] 
    from
    dbo.FOET
    group
    by Person_DEID,
    Admit_DT,
    Discharge_DT, DRG_CD,
    facAA;

    Below are the queries which are taking very long time to run. It pulls 4 million records approx on first query.
    How can it run fast?
    Thank you.
    SELECTPerson_DEID[CP1] ,
    Admit_DT,
    Discharge_DT, DRG_CD,
    cast (LineAllowedAmount
    AS money)
    as FacAA
    into
    FOET
    FROMdbo.mh_fac_claims_final[CP2] 
    group
    by Person_DEID,
    Admit_DT,
    Discharge_DT, DRG_CD,
    LineAllowedAmount;
    go
    select
    Person_DEID,
    Admit_DT, Discharge_DT,
    DRG_CD, sum(facAA)
    as FacAA_SUM[CP3] 
    from
    dbo.FOET
    group
    by Person_DEID,
    Admit_DT,
    Discharge_DT, DRG_CD,
    facAA;
    select    Person_DEID,Admit_DT,Discharge_DT,DRG_CD, convert(money,sum(LineAllowedAmount)) as FacAA_SUM[CP3] 
    into FOET
    FROM dbo.mh_fac_claims_final[CP2] 
    group by Person_DEID, Admit_DT, Discharge_DT, DRG_CD
    There is no grouping, u are calculating 4m records in second query. Maybe try above instead (already suggested)? Can u check how long above query takes to run?

  • We are running a report ? it is  taking long time for  execution. what step

    we are running a report ? it is  taking long time for  execution. what steps will we do to reduce the execution time?

    Hi ,
    the performance can be improved thru many ways..
    First try to select based on the key fields if it is a very large table.
    if not then create a Secondary index for selection.
    dont perform selects inside a loop , instead do FOR ALL ENTRIES IN
    try to perform may operations in one loop rather than calling different loops on the same internal table..
    All these above and many more steps can be implemented to improve the performance.
    Need to look into your code, how it can be improved in your case...
    Regards,
    Vivek Shah

  • You are running a report. It is taking long time for

    You are running a report. It is taking long time for
    execution. What steps will you do to reduce the
    execution time.
        plx explain clearly

    Avoid loops inside loops.
    Avoid select inside loops.
    Select only the data that is required instead of using select *
    Select the field in the sequence as they are present in the database, and also specify the fields in the where clause in the same sequence.
    When ur using for all entries in the select statement, check whether the internal table to which ur refering is not initial.
    Remove select... endselect instead use into table
    Avoid Select Single inside the loop, instead select all the data before the loop and read that internal table inside the loop using binary search.
    Sort the Internal tables where ever necessary.

  • Update ztable is taking long time

    Hi All,
    i have run the 5 jobs with the same program at a time but when we check the db trace
    zs01 is taking long time as shown below.here zs01 is having small amount of data.
    in the below dbtrace for updating zs01 is taking 2,315,485 seconds .how to reduce this?
    HH:MM:SS.MS Duration     Program   ObjectName  Op.   Curs   Array   Rec     RC     Conn     
    2:36:15 AM     2,315,485     SAPLZS01  ZS01       FETCH  294     1     1     0     R/3     
    The code as shown below
    you can check the code in the program SAPLZS01 include LZS01F01.
    FORM UPDATE_ZS01.
    IF ZS02-STATUS = '3'.
        IF Z_ZS02_STATUS = '3'.            "previous status is ERROR
          EXIT.
        ELSE.
          SELECT SINGLE FOR UPDATE * FROM  ZS01
                 WHERE  PROC_NUM    = ZS02-PROC_NUM.
          CHECK SY-SUBRC = 0.
          ADD ZS02-MF_AMT TO ZS01-ERR_AMT.
          ADD 1           TO ZS01-ERR_INVOI.
          UPDATE ZS01.
        ENDIF.
      ENDIF.
    my question is when updating the ztable why it is taking such long time,
    how to reduce the time or how to make faster to update the ztable .
    Thanks in advance,
    regards
    Suni

    Try the code like this..
    data: wa_zs01 type zs01.
    FORM UPDATE_ZS01.
    IF ZS02-STATUS = '3'.
        IF Z_ZS02_STATUS = '3'.            "previous status is ERROR
          EXIT.
        ELSE.
          SELECT SINGLE FOR UPDATE * FROM  ZS01
                 WHERE  PROC_NUM    = ZS02-PROC_NUM.
    -- change
      CHECK SY-SUBRC = 0.
          ADD ZS02-MF_AMT TO wa_ZS01-ERR_AMT.
          ADD 1           TO wa_ZS01-ERR_INVOI.
          UPDATE ZS01 from wa_zs01.
        ENDIF.
      ENDIF.
    And i think this Select query for ZS01 is inside the ZS02 SELECT statement,
    This might also make slow process.
    If you want to make database access always use Workarea/Internal table to fetch the data
    and work with that.
    Accessing database like this or with Select.... endselect is an inefficient programming.

Maybe you are looking for

  • Changes in itunes not being changed on my iphone4s

    Changes made on the iphone control feature in itunes, say add a song to a playlist or add an artist, are not being changed on the phone. Any ideas? thanks.

  • Error (-50) with iTunes Download

    I am trying to download a tv show and this keeps popping up. I went to the help page about the message. It said to delete the cache. I went to where my downloads go could not find it. In iTunes download window it is only 1.2k in size. Any help is app

  • SOAP to JMS synch scenario issue

    Dear Experts, I am working on SOAP to JMS (Websphere MQ) synch scenario.In the ESR i created 2 synch service interfaces(1 Inbound & 1 outbound). I created my 1 SOAP communication channel with QOS as "Best Effort"  2 JMS comm channel( 1 Receiver & 1 S

  • Thumbnails in Web DMS

    hi dears, i am configuring web dms, now my problem is, i am unable to get thumbnails in web dms for jpg, mbp files.If i open the same files in sap dms i am able to get thumbnails, when i open them in web page i am not getting thumbnails. I already de

  • CS6 Photoshop saving double copies of files?

    Hello! Can someone please help me! I have two MACs, one runs cs3 photoshop and the other runs cs6 photoshop. I cannot figure out for the life of my why I can only save 614 images on my flashdrive when using cs6 and I can get almost 1900 files (from t