Getting IllegalThreadStateException, while exporting the report to PDF

Hi Friends,
I am using JRC to create report in PDF format.
But intermitently I get java.lang.IllegalThreadStateException while trying to export ReportClientDocument into PDF format using the PrintOutPutContrller.
The I am using for this is
ExportOptions exportoptions = new ExportOptions();
PDFExportFormatOptions pdfOptions = new PDFExportFormatOptions();
exportoptions.setExportFormatType(ReportExportFormat.PDF);
exportoptions.setFormatOptions(pdfOptions);
reportInputStream = reportClientDocument.getPrintOutputController().export(exportoptions);
The exception I get is:
com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: java.lang.IllegalThreadStateException---- Error code:-2147467259 Error code name:failed
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
at com.solidcore.as.report.ReportJob.createPDFReport(ReportJob.java:114)
at com.solidcore.as.report.ReportJob.execute(ReportJob.java:66)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
I am using JRC that comes with CR4E 2.0. The Report is designed using Crystal Report 2008.
Please help me in solving the issue.
Thank you,
Deepak

Hi Ted,
Thank you for the answers.
In our applications the Report will be generated in two ways.
1. A user clicks on a link on web, and the report is generated in PDF format and sent via http.
            At present we are creating a new
            ReportClientDocument for every request and using ExportControl.processHttpRequest() API
            the report in PDF format is sent user through response.
2. Quartz schuduler trigger a job, whose work is to generate Report in PDF format into a file, and the
          generated pdf file is sent to users via mail.
          Here I user ReportCLientDocument.export() API to get the InputStream and use the input stream
          to create PDF file.
It is possible that a user is requesting a report on Web Page and the same report is being generated by Scheduler at the same time. But in each case a separate ReportClientDocument is being used.Since Report containse a huge data, and it takes time to generate PDF file so, it is possible that a given RPT file is opened by two spearate ReportClientDocuemnt (one via web user and other via Scheduler) at the same time.
The have got rid of my earlier exceptions by sycncronizing the ReportClientDocuent.export() API.
But now am getting following exception intermittently.
2009-05-01 16:47:45.859 GMT+05:30 [ERROR] [ReportJob.java:137] [AnalyticsScheduler_Worker-10(34)] - [] Could not generate the Report.
java.lang.NullPointerException
     at com.crystaldecisions.sdk.occa.report.application.ds.a(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.if(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.export(Unknown Source)
     at com.solidcore.as.report.ReportJob.createPDFReport(ReportJob.java:123)
     at com.solidcore.as.report.ReportJob.execute(ReportJob.java:75)
     at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
     at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
2009-05-01 16:47:45.859 GMT+05:30 [ERROR] [JobRunShell.java:211] [AnalyticsScheduler_Worker-10] - Job reportJobGroup.reportJob threw an unhandled Exception:
java.lang.NullPointerException
     at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.if(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.case(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.ClientDocument.close(Unknown Source)
     at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.close(Unknown Source)
     at com.solidcore.as.report.ReportJob.createPDFReport(ReportJob.java:155)
     at com.solidcore.as.report.ReportJob.execute(ReportJob.java:75)
     at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
     at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Edited by: Deepak Mishra on May 4, 2009 5:47 PM

Similar Messages

  • Getting error while exporting the report

    Hi,
    I am facing error while exporting the report. Getting below error.
    "No data can be exported because there are no rows.Operation failed."
    how come this error is coming even though my report contains data.
    please do the needful.
    i am using the version discoverer 10g.
    Thanks,
    RC.

    I am having the same problem. I found this article in which the user was exporting 100,000 plus records and had the same issue exporting (Discoverer workbook exported to excel error - No dta can be exported and they were able to fix it by adjusting two memory settings in their pref.txt file. However, in my report there are only 1,100 records with eleven columns being returned. I export much larger reports on a daily basis.
    Originally, the report was returning records and when I would go to retrieve all records it would tell me that all the rows could not be returned and the data may be incomplete. After scrubbing my SQL I no longer get that message, but the report still will not export and I get the same error as you.
    I have not tried the pref.txt settings fix but may try it today to see if that is a workaround. I will then have to evaluate whether it is a good fix or just a band-aid.

  • Server Threw Exception when Exporting the report as PDF

    Hi ,
    I am developing a .Net application , In my application referring to the .rep file which is created using the Business Objects Desktop Intelligence as below
      objBO = new busobj.Application();
                        objBO.Logon(strUserName, strPassword, strServerName, strConnectionMode,false, false);
                        objBO.Visible = false;
                        objBO.Documents.OpenFromEnterprise("PfILS Document.rep", strDomain, BoEnterpriseFolderKind.boFolder);
    After passing the values to the variables of the.rep and refreshing like as below
    objBO.Application.ActiveDocument.Refresh();
    when I tried to save the generated report as .pdf ..
    objBO.Application.ActiveDocument.ExportAsPDF(@"c:\" + Report0101010 + ".pdf");
    I am getting the following issue
    The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
    and the application fails to export the report to pdf document
    Please help me , what will be root cause of this issue
    Thanks
    Babu
    Edited by: Babu Lakshmikantham on Oct 28, 2009 9:18 AM

    Hi,
    World you like to have a look at the sample [here|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60b54507-de66-2b10-95b8-a89015297027]?
    Hope that helps!
    Thanks.

  • Getting warning while running the report

    hi all am getting warning while running the report .
    the log file is given below
    +---------------------------------------------------------------------------+
    Process Manufacturing Inventory: Version : 11.5.0
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    XXVIS_OPM_STOCK_STATEMENT module: Visaka RG1 Register
    +---------------------------------------------------------------------------+
    Current system time is 11-OCT-2011 20:42:05
    +---------------------------------------------------------------------------+
    **Starts**11-OCT-2011 20:42:05
    **Ends**11-OCT-2011 20:43:25
    +---------------------------------------------------------------------------+
    Start of log messages from FND_FILE
    +---------------------------------------------------------------------------+
    +---------------------------------------------------------------------------+
    End of log messages from FND_FILE
    +---------------------------------------------------------------------------+
    +---------------------------------------------------------------------------+
    Executing request completion options...
    +------------- 1) PUBLISH -------------+
    Unable to find an Output Post Processor service to post-process request 15845789.
    Check that the Output Post Processor service is running.
    +--------------------------------------+
    +------------- 2) PRINT   -------------+
    Not printing the output of this request because post-processing failed.
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed
    Current system time is 11-OCT-2011 20:43:25
    +---------------------------------------------------------------------------+what is mean by output post processor?
    why am getting this problem?
    Please help me to fix this problem .
    Thanks for all in advance

    Hi;
    Unable to find an Output Post Processor service to post-process request 15845789.
    Check that the Output Post Processor service is running.Check OPP Cm are up and run. Please also check logs for can see why you are getting this message
    Regard
    Helios

  • Getting warninig while running the report

    hi all am getting warning while running the report .
    am getting following errors in log file .
    log file is given below
    please help me
    +---------------------------------------------------------------------------+
    Process Manufacturing Inventory: Version : 11.5.0
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    XXVIS_OPM_STOCK_STATEMENT module: Visaka RG1 Register
    +---------------------------------------------------------------------------+
    Current system time is 11-OCT-2011 20:35:56
    +---------------------------------------------------------------------------+
    **Starts**11-OCT-2011 20:35:57
    **Ends**11-OCT-2011 20:37:26
    +---------------------------------------------------------------------------+
    Start of log messages from FND_FILE
    +---------------------------------------------------------------------------+
    +---------------------------------------------------------------------------+
    End of log messages from FND_FILE
    +---------------------------------------------------------------------------+
    +---------------------------------------------------------------------------+
    Executing request completion options...
    +------------- 1) PUBLISH -------------+
    Unable to find an Output Post Processor service to post-process request 15845786.
    Check that the Output Post Processor service is running.
    +--------------------------------------+
    +------------- 2) PRINT   -------------+
    Not printing the output of this request because post-processing failed.
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed
    Current system time is 11-OCT-2011 20:37:26
    +---------------------------------------------------------------------------+
    [\code]
    thanks for all in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Ask this in the Oracle eBusiness Suite forum. This doesn't look like a Reports problem.

  • Indesign getting crash while exporting because of bad pdf inside file.

    Hi,
    My indesing is getting crash while exporting to pdf. I have link to pdf file inside the indesign file, when i export that indesign file to pdf indesign is getting crash without showing any error message. If i place another pdf file in same location then it is going fine and i can able to get the output pdf file. Please suggest me how can i check and correct that pdf file and is there any solution to this. Please help me i have thousands of indesign pages with the same issue. If you want pdf i can send it to your mail id. please i need fix for this problem.
    Thanks
    Kiran

    For all of you lurkers, Kiran sent me a copy of the PDF, and it looks like I found the problem (and learned a new technique which may help others in the same boat).
    I tried re-frying the file by creating an eps and distilling, but the result was the same, then I tried exporting from CS3, just for fun, and it worked, but I realized the PDF had been cropped, so I started trying differnt sections and isolated an area that failed, though that wasn't particularly helpful.
    Acrobat preflight didn't find anything that looked odd or problematic, and then I decided to run Examine Document. It came up with MetaData (no surprise) and also two items under a heading of Deleted and Cropped objects, with no preview or description. I unselected the MetaData from the list of found stuff, them clicked the Remove button in the Examine Document panel, and resaved (and while you have the opportunity to give it a new name, doing so doesn't remove the stuff untill you do the whole procedure again and save with the same name). Placed the new version of the PDF in a new file and exported no problem.

  • Can we give page range while exporting the report programatically

    hi
    i am using CR Server XI RAS Embedded.
    i am trying to exporting the report to a stream object. it woks fine.
    is that possible to give page range ie, From and To page nos while exporting programatically.
    Thanks  in advance
    Regards
    Padmanaban V

    Hi Padmanaban,
    Try with this i have tested with VS 2008 and CR 2008 SP0:
    ExportOptions exportOptions = new ExportOptions();
            exportOptions.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatPDF;
            PDFExportFormatOptions pdfOptions = new PDFExportFormatOptions();
            pdfOptions.StartPageNumber = 1;
            pdfOptions.EndPageNumber = 3;
            exportOptions.FormatOptions = pdfOptions;
            Response.AddHeader("Content-Disposition", "filename=" + "untiteled" + ".pdf");
            Response.ContentType = "application/pdf";
            Response.BinaryWrite((Byte[])reportClientDoc.ReportSource.Export(exportOptions, new      RequestContext()));
            Response.End();
    Regards,
    Shweta

  • Issue while exporting the report to other formats

    When the rpt file created in the BO server is used to view the report through the report viewer, there are export options available to choose from. If this export option is tried as MSExcel or Word document, the alignment, page headers and all are not coming in the same way like in the one generated through the PDF.

    Hi aparmar,
    Which version of the Crystal Report and Business Objects you are using?
    Which SDK's you are using in your application to export the report to RTF format?
    Also if you are using JRC in your application, you can follow the given link:
    Font size in exported report
    I hope the above link might be helpful.
    Please revert if you need any other information.
    Regards,
    Anchal

  • Failed to export the report to PDF

    I am currently developing multiple applications using Visual Studio 2008 and Crystal Reports. The application works fine in the development environment but when deployed to a user's machine I get the error listed below.
    I installed the redistributable package that came with Visual Studio. Then I installed my packed. I check in the users GAC that the assemblies I used in developing are installed. They are present on the users machine.
    I have not found much on this subject online. Does anyone know of a solution to this issue? Was installing the redistributable package that came with Visual Studio 2008 correct? Any help would be great.
    Not implemented.
    Failed to export the report.
    Error in File C:\DOCUME~1\USER~1\LOCALS~1\Temp\1\temp_a4f4905b-85ec-4420-ae7e-f1a57ecd3f44 {CDBECA9C-8D45-4BEE-949F-F6CF818AB575}.rpt:
    Operation not yet implemented.
       at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
       at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
       at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options)
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportFormatType formatType)
       at Condor.Threading.PortfolioAnalysisPDFThread.StitchReport(List`1 crReports)
       at Condor.Threading.PortfolioAnalysisPDFThread.CreateReport(DoWorkEventArgs e)

    Hi Ludek ,
    Thanks for reply,
    I download CR2008 Redistribale & Installed it.
    But still I am getting following  error on client PC;
    at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
       at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
       at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
       at CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
       at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToDisk(ExportFormatType formatType, String fileName)
    Please  give  solution.
    Thanks

  • Getting variation while running the report S_ALR_87012386

    Hi,
    We made a posting in AP  based in USD  (value xxx  USD;   Local Amount :  361,65 u20AC )
    Due to the nature of the TAX Transaction, it was applied the Vat Code  XX  (to aplly / deduct VAT  at 23%  - Services from Other Markets). The posting is OK;  according to the rules:
    However while executing the report :S_ALR_87012386(Advance return for tax on sales/purchases Portugal) there is abnormal situation that shows wrong VAT base amounts and 23% tax also not calculating the Base amounts.
    I have posted the same document with local currency but there is no problem with Local currency because document and Tax amount calculated correctly in both transaction and report.
    Doc with local currency:  CR    31 vendor                10000
                                              DR   40 GL account                  10000
                                              CR   50 23% tax ammount  2300
                                              DR   40 23%tax amount             2300
    Above line items are showing correctly in report also same as it is.
    Below line items are correct but in report it is showing wrongly.
    Doc with F currency:      CR    31 vendor                     $520        Local: 350.52
                                              DR   40 GL account                 $ 520   Local: 350.52
                                              CR   50 23% tax ammount  $82.62      Local:  82.62
                                              DR   40 23%tax amount           $ 80.62   Local:80.62   
    Local Base amount     showing as 269.90 & 431.14 respectively and it is not calculating the 23% tax like above line items.                             
    It seems that only occured with Foreign Currency.
    Pleas let me know if you need further inputs or anything...
    Please help me out in this...
    KMR

    Ask this in the Oracle eBusiness Suite forum. This doesn't look like a Reports problem.

  • Headers getting repeated while running the report in background

    Hi,
    I have a report which uses ALV grid display for output display.
    I have displayed a heder in the top_of_page option. while running the program in foregound the header gets displayed only once. but when executing in background the header is getting displayed for each and every page.
    can any one tell me how to get the header displayed only once in the background also.

    REPORT  ZBACKORD MESSAGE-ID VZ
                                  NO STANDARD PAGE HEADING.
    *& TABLES AND TYPE-POOLS                                               *
    Tables used
    TABLES : VBAK,    "Sales Document: Header Data
             VBAP,    "Sales Document: Item Data
             VBPA.    "Sales Document Partner
    For ALV Display
    TYPE-POOLS: SLIS.  "Globale Typen für generische Listbausteine
    *& CONSTANTS                                                           *
    Constants Used
    CONSTANTS:
               C_X         VALUE 'X',           "Order status
               C_TAPA(4)   VALUE 'TAPA',        "For Material Determination
               C_0001(4)   VALUE '0001',        "Etenr value
               C_A         VALUE 'A',           "Enable Save
               C_US(3)  VALUE 'US$',            "US DOLLAR.
               C_B         VALUE 'B',           "for Partially processed
               C_E         VALUE 'E',           "Language
               C_C         VALUE 'C',           "for completely processed
               C_BLANK     VALUE ' ',           "Blank
               C_IC1(4) VALUE '&IC1',           "for user command
               C_ZR(2)     VALUE 'ZR',          "Cs ReP No
               C_BP(2)     VALUE 'RE',          "Bill to party
               C_SH(2)     VALUE 'WE',          "Sold to party
              C_6(6)      VALUE '000000',      "For item number
               C_20(2)  TYPE N VALUE '20',      "For the length of the field
               C_S(1)   TYPE C VALUE 'S',       "STOCK
               C_H      VALUE 'H',              "Header
               C_COL(1) TYPE C VALUE ':',       " COLUMN FOR DATA AND TIME
               C_TOP    TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
                                               "For TOP_OF_PAGE
               C_USER   TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
    " For USER_COMMAND
    *& TYPE DEFINITIONS                                                    *
    *FOR Sales Document: Header Data
    TYPES: BEGIN OF TP_VBAK,
             VBELN TYPE VBELN_VF,   "Sales Document
             ERDAT TYPE ERDAT,      "Date on which the record was created
             AUART TYPE AUART,      "Sales document type
             LIFSK TYPE LIFSK,      "Delivery block
             VKORG TYPE VKORG,      "Sales organization
             VTWEG TYPE VTWEG,      "Distribution channel
           END OF TP_VBAK.
    *FOR Sales Document Business Data
    TYPES :BEGIN OF TP_VBKD,
            VBELN TYPE VBELN,      "Sales and distribution document number
            POSNR TYPE POSNR,      "Item number of the SD document
            INCO1 TYPE INCO1,      "Incoterms
            ZTERM TYPE DZTERM,     "Terms of payment key
            BSTKD TYPE BSTKD,      "Customer purchase order number
          END OF TP_VBKD.
    TYPES : BEGIN OF TP_VBFA,
              VBELV TYPE VBELN_VON,
              POSNV TYPE POSNR_VON,
            END OF TP_VBFA.
    *FOR Sales Document: Partner
    TYPES : BEGIN OF TP_VBPA,
              VBELN TYPE VBELN,    "Sales and distribution
              PARVW TYPE PARVW,    "Partner function
              KUNNR TYPE KUNNR,    "Customer Number 1
              ADRNR TYPE ADRNR,    "address
            END OF TP_VBPA.
    *FOR Addresses (Business Address Services)
    TYPES : BEGIN OF TP_ADRC,
              ADDRNUMBER TYPE AD_ADDRNUM,  "Address
              DATE_FROM TYPE AD_DATE_FR,   "Date valid from
              NATION TYPE AD_NATION,       "International address
              NAME1 TYPE AD_NAME1,         "name
            END OF TP_ADRC.
    *FOR Sales Document: Item Data
    TYPES: BEGIN OF TP_VBAP,
            VBELN TYPE VBELN_VA,   "Sales document
            POSNR TYPE POSNR_VA,   "Sales document item
            MATNR TYPE MATNR,      "Material Number
            PSTYV TYPE PSTYV,      "Sales document item category
            KDMAT TYPE MATNR_KU,   "Material number used by customer
            VRKME TYPE VRKME,      "Sales unit
            WERKS TYPE WERKS_EXT,  "Plant (Own or External)
            VSTEL TYPE VSTEL,      "Shipping point /Receiving point
            NETPR TYPE NETPR,      "Net p
            NETWR TYPE NETWR_AP,
            WAERK TYPE VBAP-WAERK,"Target outline doc currency
         END OF TP_VBAP.
    *for Sales Document: Schedule Line Data
    TYPES: BEGIN OF TP_VBEP,
            VBELN TYPE VBELN_VA,   "Sales document
            POSNR TYPE POSNR_VA,   "Sales Document Item
            ETENR TYPE ETENR,      "Schedule line
            EDATU TYPE EDATU,      "Schedule line data
            WMENG TYPE WMENG,      "Order quantity in sales unit
            BMENG TYPE BMENG,      "Confirmed quantity
            LMENG TYPE LMENG,      "Required quantity
            WADAT TYPE WADAT,      "Goods issue date
            LIFSP TYPE LIFSP_EP,   "Schedule line blocked for delivery
          END OF TP_VBEP.
    *For Sales Document: Header Status and Administrative Data
    TYPES : BEGIN OF TP_VBUK,
              VBELN TYPE VBELN,  "Sales and Distribution Document Number
              SPSTG TYPE SPSTG,  "Overall blocked status
              CMGST TYPE CMGST,
            END OF TP_VBUK.
    TYPES : BEGIN OF TP_TVLST,
              LIFSP TYPE LIFSP,  "Default delivery block
              VTEXT TYPE BEZEI_LIFSP, "Description
            END OF TP_TVLST.
    *FOR Sales Document: Item Status
    TYPES : BEGIN OF TP_VBUP,
              VBELN TYPE VBELN,      "Sales and distribution
              POSNR TYPE POSNR,      "Item number of the SD
              LFGSA TYPE LFGSA,      "Overall delivery status of item
            END OF TP_VBUP.
    For ALV Display-if  cs rep is checked
    TYPES: BEGIN OF TP_DISPC,
              VBELN TYPE VBELN,       "Sales and distribution Doc
              VKORG TYPE VKORG,       "Sales organization
              VTWEG TYPE VTWEG,       "Distribution channel
              AUART TYPE AUART,       "Sales document type
              BSTKD TYPE BSTKD,       "Customer purchase order
              KUNNR_1 TYPE KUNNR,     "Cs Rep Number
              NAME1_1 TYPE NAME1,     "Cs Rep Name
              KUNNR_2 TYPE KUNNR,     "Bill to Number
              NAME1_2 TYPE NAME1,     "Bill to Party
              KUNNR_3 TYPE KUNNR,     "Ship to Number
              NAME1_3 TYPE NAME1,     "Ship to Party
              POSNR TYPE POSNR_VA,    "Item number of the SD
              MATNR TYPE MATNR,       "Material Number
              KDMAT TYPE MATNR_KU,    "Material number used by
              VSTEL TYPE VSTEL,       "Shipping point /Receiving
              NETPR TYPE NETPR,       "Net price
              NETWR TYPE NETWR_AP,
              WAERK TYPE WAERK,       "Currency
              ZTERM TYPE DZTERM,      "Terms of payment key
              WMENG TYPE WMENG,       "Order quantity in sales unit
              LOGIC_1 TYPE WMENG,     "BackOrder Quantity
              VRKME TYPE STRING,      "Sales Unit
              WADAT TYPE EDATU,       "Goods issue date
              WADAT1 TYPE EDATU,
              EDATU TYPE EDATU,       "Schedule line data
              VRKME_1 TYPE STRING,    "Sales Unit
              INCO1 TYPE INCO1,       "Incoterms
              LFGSA TYPE STRING,      "Overall delivery status of item
              LIFSP TYPE STRING,      "Line Item Block
              LIFSK TYPE STRING,      "Header block
              SPSTG TYPE STRING,      "Overall blocked status
             END OF TP_DISPC.
    For ALV Display-if plant is checked
    TYPES: BEGIN OF TP_DISPP,
              VBELN TYPE VBELN,       "Sales and distribution Doc
              VKORG TYPE VKORG,       "Sales organization
              VTWEG TYPE VTWEG,       "Distribution channel
              AUART TYPE AUART,       "Sales document type
              BSTKD TYPE BSTKD,       "Customer purchase order
              KUNNR_2 TYPE KUNNR,     "Cs rep number
              NAME1_2 TYPE NAME1,     "Cs rep Name
              KUNNR_3 TYPE KUNNR,     "Ship to Number
              NAME1_3 TYPE NAME1,     "Ship to Party Name
              POSNR TYPE POSNR_VA,    "Item number of the SD
              MATNR TYPE MATNR,       "Material Number
              KDMAT TYPE MATNR_KU,    "Material number used by customer
              VSTEL TYPE VSTEL,       "Shipping point /Receiving point
              NETPR TYPE NETPR,       "Net price
              NETWR TYPE NETWR_AP,
    *}MOD02
              WAERK TYPE WAERK,       "Currency
              ZTERM TYPE DZTERM,      "Terms of payment key
              WMENG TYPE WMENG,       "Order quantity in sales unit
              LOGIC_1 TYPE WMENG,     "Backorder Quantity
              VRKME TYPE STRING,      "Sales unit
              WADAT TYPE EDATU,       "Goods issue date
              WADAT1 TYPE EDATU,
              EDATU TYPE EDATU,       "Schedule line data
              VRKME_1 TYPE STRING,    "Sales Unit
              INCO1 TYPE INCO1,       "Incoterms
              LFGSA TYPE STRING,      "Overall delivery status of item
              LIFSP TYPE STRING,      "Line Item Block
              LIFSK TYPE STRING,      "Header block
              SPSTG TYPE STRING,      "Overall blocked status
              WERKS TYPE WERKS_EXT,   "Plant (Own or External)
           END OF TP_DISPP.
    For ALV Display-if cs rep and palnt is checked
    TYPES: BEGIN OF TP_DISP,
              VKORG TYPE VKORG,        "Sales organization
              VTWEG TYPE VTWEG,        "Distribution channel
              AUART TYPE AUART,        "Sales document type
              VBELN TYPE VBELN,        "Sales and distribution Doc no
              BSTKD TYPE BSTKD,        "Customer purchase order number
              KUNNR_1 TYPE KUNNR,      "Cs Rep Number
              NAME1_1 TYPE NAME1,      "Cs Rep Name
              KUNNR_2 TYPE KUNNR,      "Bill to Number
              NAME1_2 TYPE NAME1,      "Bill to Name
              KUNNR_3 TYPE KUNNR,      "Ship to Number
              NAME1_3 TYPE NAME1,      "Ship to Name
              POSNR TYPE POSNR_VA,     "Item number of the SD
              MATNR TYPE MATNR,        "Material Number
              KDMAT TYPE MATNR_KU,     "Material number used
              VSTEL TYPE VSTEL,        "Shipping point /Receiving
              NETPR TYPE NETPR,        "Net price
              NETWR TYPE NETWR_AP,
              WAERK TYPE WAERK,        "Currency
              ZTERM TYPE DZTERM,       "Terms of payment key
              WMENG TYPE WMENG,        "Order quantity in sales
              LOGIC_1 TYPE WMENG,      "Backorder Quantity
              VRKME TYPE STRING,       "Sales unit
              WADAT TYPE EDATU,        "Goods issue date
              WADAT1 TYPE EDATU,
              VRKME_1 TYPE STRING,     "Sales Unit
              EDATU TYPE EDATU,        "Schedule line date
              INCO1 TYPE INCO1,        "Incoterms
              LFGSA TYPE STRING,       "Overall delivery status of
              LIFSP TYPE STRING,       "Line Item Block
              LIFSK TYPE STRING,       "Header block
              SPSTG TYPE STRING,       "Overall blocked status
              WERKS TYPE WERKS_EXT,    "Plant (Own or External)
           END OF TP_DISP.
    *& INTERNAL TABLES                                                     *
    Internal Tables used for Data Selection
    DATA: T_VBAK TYPE STANDARD TABLE OF TP_VBAK WITH HEADER LINE,
          T_VBPA TYPE STANDARD TABLE OF TP_VBPA WITH HEADER LINE,
          T_VBAP TYPE STANDARD TABLE OF TP_VBAP WITH HEADER LINE,
          T_VBKD TYPE STANDARD TABLE OF TP_VBKD WITH HEADER LINE,
          T_VBEP TYPE STANDARD TABLE OF TP_VBEP WITH HEADER LINE,
          T_VBEP1 TYPE STANDARD TABLE OF TP_VBEP WITH HEADER LINE,
          T_VBUP TYPE STANDARD TABLE OF TP_VBUP WITH HEADER LINE,
          T_ADRC TYPE STANDARD TABLE OF TP_ADRC WITH HEADER LINE,
          T_DISPC TYPE STANDARD TABLE OF TP_DISPC WITH HEADER LINE,
          T_DISPP TYPE STANDARD TABLE OF TP_DISPP WITH HEADER LINE,
          T_DISP TYPE STANDARD TABLE OF TP_DISP WITH HEADER LINE.
    {23-8-2007
    DATA: T_VBUK TYPE STANDARD TABLE OF TP_VBUK WITH HEADER LINE,
          T_TVLST TYPE STANDARD TABLE OF TP_TVLST WITH HEADER LINE,
          T_TVLST1 TYPE STANDARD TABLE OF TP_TVLST WITH HEADER LINE,
          T_VBFA TYPE STANDARD TABLE OF TP_VBFA WITH HEADER LINE.
                Variables used for ALV Display                           *
    DATA:
          W_REPID TYPE SY-REPID,               " Report name
          W_POS   TYPE I VALUE 0,              " Column position indicator
          W_LAYOUT TYPE SLIS_LAYOUT_ALV,       " Layout
          W_DATUM(10) TYPE C,                  " Run date
          W_TIME(8)   TYPE C.                  " Run time
                Tables used for ALV Display                              *
    DATA  :   T_GROUP TYPE SLIS_T_SP_GROUP_ALV WITH HEADER LINE,
                                                 "Grouping of field
              T_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,
                                                 "sorting of the field
              T_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
                                                " Field description
              T_TOP TYPE SLIS_T_LISTHEADER.      " Header for the ALV
                Work Area used for ALV Display
    DATA : WA_TOP LIKE LINE OF T_TOP.            " Work Area for Header
    *& SELECTION SCREEN                                                    *
    Selection
    SELECTION-SCREEN BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-T01.
    "Sales Organization details
    SELECT-OPTIONS: S_VKORG FOR VBAK-VKORG OBLIGATORY.
    "Sales Organization
    SELECT-OPTIONS: S_VTWEG FOR VBAK-VTWEG .
    "Distribution Channel
    SELECT-OPTIONS: S_KUNNR1 FOR VBPA-KUNNR .             "CS Rep Number
    SELECT-OPTIONS: S_WERKS FOR VBAP-WERKS.               "Plant
    SELECTION-SCREEN END OF BLOCK B01.
    SELECTION-SCREEN BEGIN OF BLOCK B02 WITH FRAME TITLE TEXT-T02.
    "Additional Selections
    SELECT-OPTIONS: S_KUNNR2 FOR VBPA-KUNNR .      "Bill to party
    SELECT-OPTIONS: S_KUNNR3 FOR VBPA-KUNNR .      "Ship to party
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN .       "Saler Order
    SELECT-OPTIONS: S_MATNR FOR VBAP-MATNR .       "Material Number
    SELECT-OPTIONS: S_KDMAT FOR VBAP-KDMAT .       "Customer Material Number
    SELECT-OPTIONS: S_AUART FOR VBAK-AUART .       "Sales Order Type
    SELECTION-SCREEN END OF BLOCK B02.
    SELECTION-SCREEN BEGIN OF BLOCK B03 WITH FRAME TITLE TEXT-T03.
    "Date Selection
    SELECT-OPTIONS: S_ERDAT FOR VBAK-ERDAT OBLIGATORY.
    "Order Creation Date
    PARAMETER: P_PLANT AS CHECKBOX.                 "Backorder Plant
    PARAMETER: P_CSREP AS CHECKBOX.                 "Backorder CSREP number
    SELECTION-SCREEN END OF BLOCK B03.
    *& AT SELECTION SCREEN                                                 *
    *Validation Sales Organisation
    AT SELECTION-SCREEN ON S_VKORG.
      IF NOT S_VKORG[] IS INITIAL.
        SELECT VKORG UP TO 1 ROWS FROM TVKO
        BYPASSING BUFFER
        INTO S_VKORG
        WHERE VKORG IN S_VKORG.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E01.
          "Enter a valid Sales Organization
        ENDIF.
      ENDIF.
    *Validation Distribution Channel
    AT SELECTION-SCREEN ON S_VTWEG.
      IF NOT S_VTWEG[] IS INITIAL.
        SELECT VTWEG UP TO 1 ROWS FROM TVTW
         BYPASSING BUFFER
      INTO S_VTWEG
       WHERE VTWEG IN S_VTWEG.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E02.
          "Enter a valid Distribution channel
        ENDIF.
      ENDIF.
    *Validation Customer service rep number
    AT SELECTION-SCREEN ON S_KUNNR1.
      IF NOT S_KUNNR1[] IS INITIAL.
        SELECT KUNNR UP TO 1 ROWS FROM KNA1
        INTO S_KUNNR1
        WHERE KUNNR IN S_KUNNR1.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E03.
          "Enter a valid Customer Service rep number
        ENDIF.
      ENDIF.
    *Validation Plant
    AT SELECTION-SCREEN ON S_WERKS.
      IF NOT S_WERKS[] IS INITIAL.
        SELECT WERKS UP TO 1 ROWS
        FROM T001W
        INTO S_WERKS
        BYPASSING BUFFER
        WHERE WERKS IN S_WERKS.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E04.  "Enter a valid Plant
        ENDIF.
      ENDIF.
    *Validation Bill to number
    AT SELECTION-SCREEN ON S_KUNNR2.
      IF NOT S_KUNNR2[] IS INITIAL.
        SELECT KUNNR UP TO 1 ROWS FROM KNA1
        INTO S_KUNNR2
        WHERE KUNNR IN S_KUNNR2.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E05.  "Enter a valid Bill to number
        ENDIF.
      ENDIF.
    *Validation Ship to Number
    AT SELECTION-SCREEN ON S_KUNNR3.
      IF NOT S_KUNNR3[] IS INITIAL.
        SELECT KUNNR UP TO 1 ROWS FROM KNA1
        INTO S_KUNNR3
        WHERE KUNNR IN S_KUNNR3.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E06.  "Enter a valid Ship to number
        ENDIF.
      ENDIF.
    *Validation Order Number
    AT SELECTION-SCREEN ON S_VBELN.
      IF NOT S_VBELN[] IS INITIAL.
        SELECT VBELN UP TO 1 ROWS FROM VBUK
        INTO S_VBELN
        WHERE VBELN IN S_VBELN.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E07.  "Enter a valid Order number
        ENDIF.
      ENDIF.
    *Validation Material Number
    AT SELECTION-SCREEN ON S_MATNR.
      IF NOT S_MATNR[] IS INITIAL.
        SELECT MATNR UP TO 1 ROWS FROM MARA
        INTO S_MATNR
        WHERE MATNR IN S_MATNR.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E08.  "Enter a valid Material number
        ENDIF.
      ENDIF.
    *Validation Customer Material Number
    AT SELECTION-SCREEN ON S_KDMAT.
      IF NOT S_KDMAT[] IS INITIAL.
        SELECT KDMAT UP TO 1 ROWS
        FROM KNMT
        INTO S_KDMAT
        WHERE VKORG IN S_VKORG AND
              VTWEG IN S_VTWEG AND
              KDMAT IN S_KDMAT.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E09.
          "Enter a valid Customer Material number
        ENDIF.
      ENDIF.
    *Validation Salea order type
    AT SELECTION-SCREEN ON S_AUART.
      IF NOT S_AUART[] IS INITIAL.
        SELECT AUART UP TO 1 ROWS FROM TVAK
        INTO S_AUART
        BYPASSING BUFFER
        WHERE AUART IN S_AUART.
        ENDSELECT.
        IF SY-SUBRC NE 0.
          MESSAGE E000 WITH TEXT-E10.
          "Enter a valid Sales Order type
        ENDIF.
      ENDIF.
    *Validation for Plant / CS rep .
    AT SELECTION-SCREEN .
      IF NOT ( ( P_PLANT = C_X ) OR ( P_CSREP = C_X ) ).
        MESSAGE E000 WITH TEXT-E12.  "Choose the Plant or CSrep
      ENDIF.
      IF  ( P_PLANT = C_X ) AND S_WERKS IS INITIAL.
        MESSAGE E000 WITH TEXT-E13.  "Enter Plant
      ENDIF.
      IF  ( P_CSREP = C_X ) AND S_KUNNR1 IS INITIAL.
        MESSAGE E000 WITH TEXT-E14. " Enter CSREP number
      ENDIF.
    *& START OF SELECTION                                                  *
    START-OF-SELECTION.
    Clear Work Areas/Variables and Clear/Refresh Internal Tables
      PERFORM CLEAR_REFRESH.
    Selection of Data as per inputs
      PERFORM DATA_SELECTION.
    Populate Internal table for display
      PERFORM DATA_FILL_FOR_DISPLAY.
    *& END OF SELECTION                                                  *
    END-OF-SELECTION.
      IF NOT T_DISP[] IS INITIAL.
    *Populating the field catalog for ALV Display if plant and csrep is
    *checked.
        PERFORM POPULATE_FIELD_CATALOG.
        PERFORM DISPLAY.
      ELSEIF T_DISPP[] IS NOT INITIAL.
    *Populating the field catalog for ALV Display if plant is checked.
        PERFORM POPULATE_FIELD_CATALOG.
        PERFORM DISPLAY.
      ELSEIF T_DISPC[] IS NOT INITIAL.
    *Populating the field catalog for ALV Display if csrep is checked.
        PERFORM POPULATE_FIELD_CATALOG.
        PERFORM DISPLAY.
      ELSE.
        MESSAGE I000 WITH TEXT-E15. "No Data found for Selection Criteria
      ENDIF.
    Clear Work Areas/Variables and Clear/Refresh Internal Tables
      PERFORM CLEAR_REFRESH.
    *&      Form  CLEAR_REFRESH
          Clear Work Areas/Variables and Clear/Refresh Internal Tables
    FORM CLEAR_REFRESH .
    Clear Variables/Work Areas/Internal Tables
      CLEAR: W_REPID,
             W_POS,
             W_LAYOUT,
             W_DATUM,
             W_TIME,
             T_VBAK,
             T_VBKD,
             T_VBPA,
             T_VBAP,
             T_VBEP,
             T_VBUP,
             T_DISPC,
             T_DISPP,
             T_DISP,
             T_VBUK,
             T_TVLST,
             T_TVLST1.
    Refresh Internal Tables
      REFRESH: T_VBAK,
               T_VBKD,
               T_VBPA,
               T_VBAP,
               T_VBEP,
               T_VBUP,
               T_DISPC,
               T_DISPP,
               T_DISP,
               T_VBUK,
               T_TVLST,
               T_TVLST1.
    ENDFORM.                    " CLEAR_REFRESH
    *&      Form  DATA_SELECTION
          Selection of Data as per inputs
    FORM DATA_SELECTION .
    *Obtain Sales and distribution document number,Date on which the record
    *was created
    *Sales document type,Delivery block,Sales organisation,
    Distribution channel based on selection criteria
      SELECT VBELN                            "Sales and distribution Doc no
             ERDAT
             "Date on which the record was created
             AUART                            "Sales document type
             LIFSK                            "Delivery block
             VKORG                            "Sales organisation
             VTWEG                            "Distribution channel
             FROM VBAK
             INTO TABLE T_VBAK
             WHERE VBELN IN S_VBELN AND
                   ERDAT IN S_ERDAT AND
                   AUART IN S_AUART AND
                   VKORG IN S_VKORG AND
                   VTWEG IN S_VTWEG.
      IF SY-SUBRC EQ 0.
        SORT T_VBAK BY VBELN .
    *Obtain Sales document ,Sales document item,Material Number,Material
    *number used by customer
    Safer point ,Plant (Own or External),Shipping point /Receiving point
    Net price based on selection criteria
        SELECT A~VBELN        "Sales document
               A~POSNR        "Sales document item
               MATNR        "Material Number
               PSTYV        "Sales document item category
               KDMAT        "Material number used by customer
               VRKME        "Sales unit
               WERKS        "Plant (Own or External)
               VSTEL        "Shipping point /Receiving point
               NETPR        "Net price
    *MOD02 {
               NETWR
    *}MOD02
               WAERK        "Target outline doc currency
               FROM  VBAP AS A JOIN VBUP AS B
               ON ( AVBELN = BVBELN
                   AND APOSNR = BPOSNR )
               INTO TABLE T_VBAP
               FOR ALL ENTRIES IN T_VBAK
               WHERE A~VBELN = T_VBAK-VBELN AND
                     A~MATNR IN S_MATNR AND
                     A~PSTYV NE C_TAPA AND
                     A~KDMAT IN S_KDMAT AND
                     A~WERKS IN S_WERKS AND
                     A~ABGRU EQ SPACE AND
                     B~LFSTA NE 'C'.
        IF SY-SUBRC EQ 0.
          SORT T_VBAP BY VBELN POSNR.
        ENDIF.
       SELECT VBELV
              POSNV
              FROM VBFA
              INTO TABLE T_VBFA
              FOR ALL ENTRIES IN T_VBAP
              WHERE VBELV = T_VBAP-VBELN
              AND POSNV = T_VBAP-POSNR
              AND VBTYP_N = 'J'.
       IF SY-SUBRC = 0.
         SORT T_VBFA BY VBELV POSNV.
         LOOP AT T_VBAP.
    *READ TABLE T_VBFA WITH KEY VBELV = T_VBAP-VBELN POSNV = T_VBAP-POSNR.
           IF SY-SUBRC = 0.
             DELETE T_VBAP.
           ENDIF.
         ENDLOOP.
       ENDIF.
    { 23-8-2007
        SELECT LIFSP
               VTEXT
               FROM TVLST
               INTO TABLE T_TVLST
               FOR ALL ENTRIES IN T_VBAK
               WHERE SPRAS EQ C_E AND
                     LIFSP = T_VBAK-LIFSK.
        IF SY-SUBRC EQ 0.
          SORT T_TVLST BY LIFSP.
        ENDIF.
    *Obtain Sales and distribution document number,Item number of the SD
    *document ,Incoterms,Terms of payment key,Customer purchase order number
    *based on selection criteria
        SELECT VBELN                 "Sales and distribution document number
               POSNR                 "Item number of the SD document
               INCO1                 "Incoterms
               ZTERM                 "Terms of payment key
               BSTKD                 "Customer purchase order number
               FROM VBKD INTO TABLE T_VBKD
               FOR ALL ENTRIES IN T_VBAK
               WHERE VBELN = T_VBAK-VBELN.
        IF SY-SUBRC EQ 0.
          SORT T_VBKD BY VBELN .
        ENDIF.
    *Obtain Sales document,Sales Document Item,Schedule line,Schedule line
    *data, Order quantity in sales unit,Confirmed quantity,Goods issue date,
    *Schedule line blocked for delivery based on selection criteria
        SELECT VBELN                    "Sales document
                POSNR                   "Sales Document Item
                ETENR                   "Schedule line
                EDATU                   "Schedule line data
                CMENG                   "Order quantity in sales unit
                BMENG                   "Confirmed quantity
                LMENG
                WADAT                   "Goods issue date
                LIFSP                   "Schedule line blocked for delivery
                FROM VBEP INTO TABLE T_VBEP
                FOR ALL ENTRIES IN T_VBAK
                WHERE VBELN = T_VBAK-VBELN AND
                      ETENR = C_0001.
        IF SY-SUBRC EQ 0.
          SORT T_VBEP BY VBELN POSNR ETENR.
    { 23-8-2007
          SELECT LIFSP
                 VTEXT
                 FROM TVLST
                 INTO TABLE T_TVLST1
                 FOR ALL ENTRIES IN T_VBEP
                 WHERE SPRAS EQ C_E AND
                       LIFSP = T_VBEP-LIFSP.
          IF SY-SUBRC EQ 0.
            SORT T_TVLST1 BY LIFSP.
          ENDIF.
        ENDIF.
        SELECT VBELN                    "Sales document
                    POSNR                   "Sales Document Item
                    ETENR                   "Schedule line
                    EDATU                   "Schedule line data
                    CMENG                   "Order quantity in sales unit
                    BMENG                   "Confirmed quantity
                    LMENG
                    WADAT                   "Goods issue date
                    LIFSP
                    "Schedule line blocked for delivery
                    FROM VBEP INTO TABLE T_VBEP1
                    FOR ALL ENTRIES IN T_VBAK
                    WHERE VBELN = T_VBAK-VBELN .
        IF SY-SUBRC EQ 0.
          SORT T_VBEP1 BY VBELN POSNR .
        ENDIF.
    { 23-8-2007
        SELECT    VBELN    "Sales and Distribution Document Number
                  SPSTG    "Overall blocked status
    *MOD02 {
                  CMGST
    *}MOD02
            FROM VBUK
            INTO TABLE T_VBUK
            FOR ALL ENTRIES IN T_VBAK
           WHERE VBELN = T_VBAK-VBELN
           AND ( CMGST = 'A' OR CMGST = 'D' ).
        IF SY-SUBRC EQ 0.
          SORT T_VBUK BY VBELN .
        ENDIF.
    *Obtain Sales and distribution Doc no,Item number of the SD document
    Overall delivery status of item
        SELECT    VBELN    "Sales and distribution Doc no
                  POSNR    "Item number of the SD document
                  LFGSA    "Overall delivery status of item
            FROM VBUP
            INTO TABLE T_VBUP
            FOR ALL ENTRIES IN T_VBAK
           WHERE VBELN = T_VBAK-VBELN.
        IF SY-SUBRC EQ 0.
          SORT T_VBUP BY VBELN POSNR.
        ENDIF.
    *Obtain Sales and distribution document number,Partner function
    Customer Number 1,address based on selection criteria
        SELECT    VBELN   "Sales and distribution Doc no
                  PARVW   " Patner function
                  KUNNR   "Customer No1
                  ADRNR   "address
                    FROM VBPA
                    INTO TABLE T_VBPA
                    FOR ALL ENTRIES IN T_VBAP
                   WHERE VBELN = T_VBAP-VBELN AND
                        ( ( KUNNR IN S_KUNNR1 ) OR
                         ( KUNNR IN S_KUNNR2 )  OR
                          ( KUNNR IN S_KUNNR3 ) ) AND
                           ( ( PARVW = C_ZR ) OR
                             ( PARVW = C_BP ) OR
                             ( PARVW = C_SH ) ).
        IF SY-SUBRC EQ 0.
          SORT T_VBPA BY VBELN PARVW.
          IF NOT T_VBPA[] IS INITIAL.
    *Obtain  Address number ,name
            SELECT  ADDRNUMBER  "Address number
                    DATE_FROM   "Date valid from
                    NATION      "International address version ID
                    NAME1        "name
              FROM ADRC
              INTO TABLE T_ADRC
              FOR ALL ENTRIES IN T_VBPA
              WHERE ADDRNUMBER = T_VBPA-ADRNR.
            IF SY-SUBRC EQ 0.
              SORT T_ADRC BY ADDRNUMBER.
            ENDIF.
          ENDIF.
        ELSE.
          MESSAGE I000 WITH TEXT-S02."No Data For the Entered CS rep number
          STOP.
        ENDIF.
      ELSE.
        MESSAGE I000 WITH TEXT-S01.
        "No data found for the selection criteria
        STOP.
      ENDIF.
    ENDFORM.                    " DATA_SELECTION
    *&      Form  DATA_FILL_FOR_DISPLAY
          Populate Internal table for display
    FORM DATA_FILL_FOR_DISPLAY .
      DATA: L_NETPR TYPE NETPR.    "For net amount
      DATA: L_DATE TYPE EDATU.     "For Date Field
      DATA: L_WMENG TYPE WMENG.    "For Confirmed Quantity
      DATA: L_BMENG TYPE BMENG.    "For Delivered Quantity
      DATA : L_LAST_DATE TYPE EDATU.
      DATA : W_FG TYPE C.
      DATA : L_TABIX TYPE SY-TABIX.
      DATA: L_CNT TYPE I,
            L_NETWR TYPE NETWR.
    *If plant and csrep are selected.
      IF ( ( P_PLANT = C_X ) AND ( P_CSREP = C_X ) ).
        LOOP AT T_VBAP.
          CLEAR W_FG.
          CLEAR L_CNT.
    *MOD02 {
          READ TABLE T_VBUK WITH KEY VBELN = T_VBAP-VBELN.
          IF SY-SUBRC = 0.
    *}MOD02
            LOOP AT T_VBEP1 WHERE VBELN = T_VBAP-VBELN AND POSNR =
            T_VBAP-POSNR.
              L_CNT = L_CNT + 1.
              IF L_LAST_DATE IS NOT INITIAL AND W_FG NE 'X'.
                IF L_LAST_DATE NE T_VBEP1-WADAT.
                  W_FG = 'X'.
                ENDIF.
              ENDIF.
              L_LAST_DATE = T_VBEP1-WADAT.
            ENDLOOP.
            IF L_CNT = 1 AND T_VBEP1-BMENG = 0.
              W_FG = 'X'.
            ENDIF.
            IF W_FG = 'X'.
              READ TABLE T_VBEP WITH KEY VBELN = T_VBAP-VBELN
                                         POSNR = T_VBAP-POSNR
                                          BINARY SEARCH.
              IF SY-SUBRC EQ 0.
    *Move Order quantity in sales unit to final internal table
                MOVE T_VBEP-WMENG TO T_DISP-WMENG.
                MOVE T_VBEP-WADAT TO T_DISP-WADAT1.
    *Move Goods issue date to final internal table
                MOVE T_VBEP-EDATU TO T_DISP-WADAT.
    { 23-8-2007
                READ TABLE T_TVLST1 WITH KEY LIFSP = T_VBEP-LIFSP
                                          BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  CONCATENATE T_VBEP-LIFSP
                                  T_TVLST1-VTEXT
                                  INTO T_DISP-LIFSP
                                  SEPARATED BY SPACE.
                ENDIF.
    *Move the Schedule line blocked for delivery
    to final internal table.
              ENDIF.
    *LOOP AT T_VBEP1 WHERE VBELN = T_VBAP-VBELN AND POSNR = T_VBAP-POSNR.
              LOOP AT T_VBEP1 WHERE VBELN = T_VBAP-VBELN AND POSNR =
              T_VBAP-POSNR.
                L_WMENG = T_VBEP1-WMENG + L_WMENG.
                L_BMENG = T_VBEP1-BMENG + L_BMENG.
           IF NOT L_DATE IS INITIAL.
             IF ( L_DATE < T_VBEP1-EDATU ).
               L_DATE = T_VBEP1-EDATU.
             ENDIF.
           ELSE.
             L_DATE = T_VBEP1-EDATU.
           ENDIF.
                AT END OF POSNR.
                  READ TABLE T_VBEP1 INDEX SY-TABIX.
                  IF SY-SUBRC = 0.
                    L_DATE = T_VBEP1-EDATU.
                  ENDIF.
                ENDAT.
              ENDLOOP.
              IF T_VBEP1-WMENG EQ T_VBEP1-BMENG.
                T_DISP-LOGIC_1 = 0.
                T_DISP-EDATU = T_VBEP1-EDATU.
              ELSEIF   L_WMENG EQ L_BMENG  .
                T_DISP-EDATU = L_DATE.
                T_DISP-LOGIC_1 = L_WMENG.
              ELSE.
                T_DISP-EDATU = C_BLANK.
                T_DISP-LOGIC_1 = L_WMENG.
              ENDIF.
    *Move the Sales document item to final internal table.
              MOVE T_VBAP-POSNR TO T_DISP-POSNR.
    *Move the Material Number to final internal table.
              MOVE T_VBAP-MATNR TO T_DISP-MATNR.
    *Move the Material number used by customer to final internal table.
              MOVE T_VBAP-KDMAT TO T_DISP-KDMAT.
    *Move the Shipping point to final internal table.
              MOVE T_VBAP-VSTEL TO T_DISP-VSTEL.
    *Move the Sales unit to final internal table.
              PERFORM UNIT1 USING T_VBAP-VRKME CHANGING T_VBAP-VRKME.
              MOVE T_VBAP-VRKME TO T_DISP-VRKME.
              MOVE T_VBAP-VRKME TO T_DISP-VRKME_1.
    *Move the Plant (Own or External) to final internal table.
              MOVE T_VBAP-WERKS TO T_DISP-WERKS.
              MOVE T_VBAP-WAERK TO T_DISP-WAERK.
    *Move the Net price to final internal table.
              IF  T_VBAP-WAERK = C_US   .
                L_NETPR = T_VBAP-NETPR.
                L_NETPR = L_NETPR / 100.
                T_DISP-NETPR = L_NETPR.
                CLEAR L_NETPR.
              ELSE.
                MOVE T_VBAP-NETPR TO T_DISP-NETPR.
              ENDIF.
              CLEAR L_NETPR.
    *MOD02{
              IF  T_VBAP-WAERK = C_US   .
                L_NETWR = T_VBAP-NETWR.
                L_NETWR = L_NETWR / 100.
                T_DISP-NETWR = L_NETWR.
                CLEAR L_NETWR.
              ELSE.
                MOVE T_VBAP-NETWR TO T_DISP-NETWR.
              ENDIF.
              CLEAR L_NETWR.
    *}MOD02
    *READ THE TABLE VBAK TO FETCH Sales Order Number,sales
    *organisation,distribution channel,Document type,Delivery block
              READ TABLE T_VBAK WITH KEY VBELN = T_VBEP-VBELN BINARY SEARCH.
              IF SY-SUBRC EQ 0.
    *Move the Sales order number to final internal table.
                MOVE T_VBAK-VBELN TO T_DISP-VBELN.
                PERFORM DELETE_LEADING_ZEROES CHANGING T_DISP-VBELN.
    *Move the Sales organisation to final internal table.
                MOVE T_VBAK-VKORG TO T_DISP-VKORG.
    *Move the Distribution channel to final internal table.
                MOVE T_VBAK-VTWEG TO T_DISP-VTWEG.
    *Move the Document type to final internal table.
                MOVE T_VBAK-AUART TO T_DISP-AUART.
    {23-8-2007
                READ TABLE T_TVLST WITH KEY LIFSP = T_VBAK-LIFSK
                                            BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  CONCATENATE T_VBAK-LIFSK
                              T_TVLST-VTEXT
                              INTO T_DISP-LIFSK
                              SEPARATED BY SPACE.
                ENDIF.
              ENDIF.
    *READ THE TABLE VBKD TO FETCH Incoterms,Terms of payment key,Customer
    *purchase order number
              READ TABLE T_VBKD WITH KEY VBELN = T_VBAP-VBELN
                BINARY SEARCH.
              IF SY-SUBRC EQ 0.
    *Move the Customer purchase order number to final internal table.
                MOVE T_VBKD-BSTKD TO T_DISP-BSTKD.
    *Move the Incoterms to final internal table.
                MOVE T_VBKD-INCO1 TO T_DISP-INCO1.
    *Move the Terms of payment to final internal table.
                MOVE T_VBKD-ZTERM TO T_DISP-ZTERM.
              ENDIF.
    { 23-8-2007
              READ TABLE T_VBUK WITH KEY VBELN = T_VBEP-VBELN
              BINARY SEARCH.
              IF SY-SUBRC EQ 0.
                IF T_VBUK-SPSTG EQ SPACE.
                  T_DISP-SPSTG = TEXT-TE1. "Not Blocked
                ELSEIF T_VBUK-SPSTG EQ C_C.
                  T_DISP-SP

  • Problem when exporting the report to PDF viwer a 45,000-page report

    I am using Visual Studio 2013 with the report vivew.
    I have a report that works correctly, however when generating a 45000 pages he is giving memory error when exporting to PDF, any tips?

    Check this SAP Note: 1089388     Incorrect value in exported PDF when Concat function is used
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/smb_searchnotes/display.htm?note_langu=E&note_numm=1089388]

  • Getting error while executing the report in WEB

    Hello Experts,
    I have did validation in my report on selection screen, if that validation is successful then only we can see the report output
    otherwise it's give the error message.
    Validations are working query designer and RSRT but when I run the report in WEB then even if the validation is successful then also I am getting the error message and not able to see the report output.
    I have written the code in user exit for validation.
    Can any one tell me why it is so?
    what needs to do?
    Thanks
    Chetan

    Hi.
    Could you plz explain your validation logic and wich way it done ?
    Could you plz provide error message ?
    Regards.

  • User getting error while opening the report

    Admin can run the report, but users cannot.
    This is XI3.1 Cluster version on Linux. User's cannot run the webi document, getting the error below
    An error occured when trying to set preferences. Please contact your Business Objects administrator. (Error: INF)
    Also when the users try to set the preferences they get this error
    An error has occurred: Sorry, you do not have the right to 'Edit objects' (ID: 6) for 'linwe' (ID: 18496663). Please contact your administrator if you require this right.
    It looks like it might be issue with the rights, but can't figure out where.
    These users are in the developer access level where they have almost all the rights.
    Please help

    inorder for the users to change their preferences, following right must be enabled
    Access Levels --> select the ACL and go to included rights
    Application --> Infoview -->Change user's preferences
    Can you check whether it is enabled or not?

  • While exporting the Report to Excel Records are showing two times

    Hello Gurus
    When im trying to export a report from NW Portal to Excel,  data is showing double times, even variable selections screen, records are  showing two tmes.
    What would be the problem, does we need any SP.
    Thanks in advance.
    Regd
    Lajwanth

    GURU'S ANY REPLIES........

Maybe you are looking for

  • My songs are missing in the music and the used memory doesn't change. Is it a bug for IOS7? How can I fix it?

    I plugged my ipod touch 5 via usb to the pc and browsed my music on itunes. And suddenly i played some music and there's a exclamation point before the song. I haven't deleted that song or moved. And the whole album was gone. And i checked the number

  • Power Mac G4 shows only screensaver image; won't read disks

    My Power Mac G4 will no longer show the finder or any of my folders. It boots beyond the grey and blue screens to show a screensaver I'd chosen earlier, but doesn't show the finder or any of my folders. It will not read any of its original install di

  • Scroll bar and episodes bouncing up and down in podcasts

    Hi all, I'm running Windows 7 Pro and iTunes 11.4. The scroll bar on the episodes side of the screen when in My Podcasts will not scroll down past the first visible subscribed podcasts without "bouncing" back to the top. If I can get it down to a pod

  • Dynamic Variant in ECC 6.0

    Hi All, Can any one tell me how to create a dynamic variant in ECC 6.0 for a exicutable program? In ECC 5.0 its easy to create but in ECC 6.0 the varinat creation screen has been changed. Thanks Manas

  • Spaces in java

    hi guys, how do i make sure there are spaces between words in my System.out.println statetments please.. this is what i have tried but doesnt work System.out.println(" The measurements of the firstbox are " + awidth + aheight + adepth); the following