How to print the report directly without previewing (report viewer) using c# windows application

Hi,
Currently, we are using crystal report to all of our reporting applications, but since I/users have encountered some issues about CR's speed to load only a simple report, maybe it is now time for us to adopt a new reporting environment in which I think SSRS
can fill this problem.
To start with, I have here a sample code, that uses the crystal report to print the report directly without previewing:
csCashInvoiceCal csCashCal; --Crystal report name .rpt
dsCsReceipt dsCs; --created dataset
DataTable u;
DataRow s;
private System.Drawing.Printing.PrintDocument printDocument1;
private System.Windows.Forms.PrintDialog printDialog1;
ParameterValues paramValue;
ParameterDiscreteValue discreteValue;
ParameterFieldDefinition fieldDefinition;
private void btnPrint_Click(object sender, EventArgs e)
this.Cursor = Cursors.WaitCursor;
loadReceipt2();
print2();
csCashCal.Close();
this.Cursor = Cursors.Default;
private void loadReceipt2()
dsCs = new dsCsReceipt(); --created dataset
u = dsCs.Tables.Add("DtCsReceipt");
u.Columns.Add("Qty", Type.GetType("System.String"));
u.Columns.Add("UOM", Type.GetType("System.String"));
u.Columns.Add("Description", Type.GetType("System.String"));
u.Columns.Add("UnitPrice", Type.GetType("System.String"));
u.Columns.Add("Discount", Type.GetType("System.String"));
u.Columns.Add("Amount", Type.GetType("System.String"));
try
for (int i = 0; i < dgvDesc.Rows.Count - 1; i++)
s = u.NewRow(); double.TryParse(dgvDesc.Rows[i].Cells[Discount2.Name].Value.ToString(), out discount);
s["Qty"] = double.Parse(dgvDesc.Rows[i].Cells[Qty.Name].Value.ToString());
s["UOM"] = dgvDesc.Rows[i].Cells[Uom2.Name].Value.ToString();
s["Description"] = invcode + dgvDesc.Rows[i].Cells[Description.Name].Value.ToString();
s["UnitPrice"] = dgvDesc.Rows[i].Cells[UnitPrice.Name].Value.ToString();
if (discount != 0)
s["Discount"] = "(" + string.Format("{0:0.##}", discount) + "%)";
else
s["Discount"] = "";
s["Amount"] = dgvDesc.Rows[i].Cells[Amount2.Name].Value.ToString();
u.Rows.Add(s);
catch (Exception) { }
csCashCal = new csCashInvoiceCal();
csCashCal.SetDataSource(dsCs.Tables[1]);
//csCashCal.Refresh();
loadParameter2();
private void loadParameter2()
ParameterFieldDefinitions paramFieldDefinitions;
paramValue = new ParameterValues();
discreteValue = new ParameterDiscreteValue();
paramFieldDefinitions = csCashCal.DataDefinition.ParameterFields;
discreteValue.Value = date;
fieldDefinition = paramFieldDefinitions["Date"];
commonParam();
discreteValue.Value = txtcsno.Text;
fieldDefinition = paramFieldDefinitions["InvoiceNo"];
commonParam();
discreteValue.Value = txtNameTo.Text;
fieldDefinition = paramFieldDefinitions["CustomerName"];
commonParam();
discreteValue.Value = txtAdd.Text;
fieldDefinition = paramFieldDefinitions["CustomerAddress"];
commonParam();
------other parameters----
private void commonParam()
paramValue.Clear();
paramValue.Add(discreteValue);
fieldDefinition.ApplyCurrentValues(paramValue);
private void print2()
using (printDocument1 = new System.Drawing.Printing.PrintDocument())
using (this.printDialog1 = new PrintDialog())
//this.printDialog1.UseEXDialog = true;
this.printDialog1.Document = this.printDocument1;
DialogResult dr = this.printDialog1.ShowDialog();
if (dr == DialogResult.OK)
int nCopy = this.printDocument1.PrinterSettings.Copies;
int sPage = this.printDocument1.PrinterSettings.FromPage;
int ePage = this.printDocument1.PrinterSettings.ToPage;
string PrinterName = this.printDocument1.PrinterSettings.PrinterName;
try
csCashCal.PrintOptions.PrinterName = PrinterName;
csCashCal.PrintToPrinter(nCopy, false, sPage, ePage);
printcount++;
//saveCountPrint();
catch (Exception err)
MessageBox.Show(err.ToString());
This is only a simple sales receipt application that uses dgv and textboxes to push its data to dataset to the crystal report, a simple one but there are instances that it is very slow.
But I'm having trouble implementing this using SSRS, since I'm only new to this one, wherein I created the report using report wizard, with two button options inside the form for print preview or direct print selection. Actually, it is very easy to implement
with print preview because it uses reportviewer. My problem is that how can I print the report directly without using a reportviewer?
So here is my code so far which I don't know what's next:
private void button2_Click(object sender, EventArgs e)
this.Cursor = Cursors.WaitCursor;
loadReceipt3();
//print3();
this.Cursor = Cursors.Default;
ReportParameter[] parameter = new ReportParameter[11];
private void loadParameter3()
parameter[0] = new ReportParameter("InvoiceNo", txtcsno.Text);
parameter[1] = new ReportParameter("Date", date);
parameter[2] = new ReportParameter("CustomerTin", txtTin.Text);
parameter[3] = new ReportParameter("CustomerName", txtNameTo.Text);
parameter[4] = new ReportParameter("CustomerAddress", txtAdd.Text);
parameter[5] = new ReportParameter("Agent", agent);
parameter[6] = new ReportParameter("Discount", "Discount: ");
parameter[7] = new ReportParameter("TotalDiscount", lblDiscount.Text + "%");
parameter[8] = new ReportParameter("TotalSales", rdtotal);
parameter[9] = new ReportParameter("Tax", rdtax);
parameter[10] = new ReportParameter("TotalAmount", rdnet);
private void loadReceipt3()
DataSet dsrs = new DataSet();
DataTable dtrs = new DataTable();
DataRow drs;
dtrs.Columns.Add("Qty", Type.GetType("System.String"));
dtrs.Columns.Add("UOM", Type.GetType("System.String"));
dtrs.Columns.Add("Description", Type.GetType("System.String"));
dtrs.Columns.Add("UnitPrice", Type.GetType("System.String"));
dtrs.Columns.Add("Discount", Type.GetType("System.String"));
dtrs.Columns.Add("Amount", Type.GetType("System.String"));
try
for (int i = 0; i < dgvDesc.Rows.Count - 1; i++)
drs = dtrs.NewRow();
drs["Qty"] = double.Parse(dgvDesc.Rows[i].Cells[Qty.Name].Value.ToString());
drs["UOM"] = dgvDesc.Rows[i].Cells[Uom2.Name].Value.ToString();
drs["Description"] = invcode + dgvDesc.Rows[i].Cells[Description.Name].Value.ToString();
drs["UnitPrice"] = dgvDesc.Rows[i].Cells[UnitPrice.Name].Value.ToString();
if (discount != 0)
drs["Discount"] = "(" + string.Format("{0:0.##}", discount) + "%)";
else
drs["Discount"] = "";
drs["Amount"] = dgvDesc.Rows[i].Cells[Amount2.Name].Value.ToString();
dtrs.Rows.Add(s);
catch (Exception) { }
int addtlRow = 7;
if (addtlRow > (count - 1))
addtlRow = addtlRow - (count - 1);
for (int i = 0; i < addtlRow; i++)
dtrs.Rows.Add();
loadParameter3();
LocalReport localreport = new LocalReport();
localreport.SetParameters(parameter);
localreport.DataSources.Clear();
localreport.DataSources.Add(new ReportDataSource("dsSalesReceiptSsrs", dtrs));
localreport.Refresh();
//what's next....
So what's next after local..refresh()? Actually, I have googled a lot but I didn't found the exact solution that I'm looking for which confuses me a lot.
Anyway I'm using VS 2010 with sql server 2012 express.
You're help will be greatly appreciated.
Thank you,
Hardz

After some further studies with ReportViewer controls and with the use of this tutorial @ : http://msdn.microsoft.com/en-us/library/ms252091.aspx, which helps me a lot on how to print a report without using a report viewer, I found out what is missing
with my code above and helps solve my question.
Here's the continuation of the code above:
private void loadReceipt3()
loadParameter3();
LocalReport localreport = new LocalReport();
localreport.ReportPath = @"..\..\SsrsCashReceipt.rdlc";
localreport.SetParameters(parameter);
localreport.DataSources.Clear();
localreport.DataSources.Add(new ReportDataSource("dsSalesReceiptSsrs", dtrs));
Export(localreport);
print4();
private IList<Stream> m_streams;
private int m_currentPageIndex;
private void Export(LocalReport report)
string deviceInfo =
@"<DeviceInfo>
<OutputFormat>EMF</OutputFormat>
<PageWidth>8.5in</PageWidth>
<PageHeight>11in</PageHeight>
<MarginTop>0.25in</MarginTop>
<MarginLeft>0.25in</MarginLeft>
<MarginRight>0.25in</MarginRight>
<MarginBottom>0.25in</MarginBottom>
</DeviceInfo>";
Warning[] warnings;
m_streams = new List<Stream>();
report.Render("Image", deviceInfo, CreateStream,
out warnings);
foreach (Stream stream in m_streams)
stream.Position = 0;
private void print4()
if (m_streams == null || m_streams.Count == 0)
throw new Exception("Error: no stream to print.");
PrintDocument printDoc = new PrintDocument();
PrintDialog printDlg = new PrintDialog();
printDlg.Document = printDoc;
DialogResult dr = printDlg.ShowDialog();
if (dr == DialogResult.OK)
if (!printDoc.PrinterSettings.IsValid)
throw new Exception("Error: cannot find the default printer.");
else
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
m_currentPageIndex = 0;
printDoc.Print();
Dispose();
public void Dispose()
if (m_streams != null)
foreach (Stream stream in m_streams)
stream.Close();
m_streams = null;
private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
Stream stream = new FileStream(name + "." + fileNameExtension,
FileMode.Create);
m_streams.Add(stream);
return stream;
private void PrintPage(object sender, PrintPageEventArgs ev)
Metafile pageImage = new
Metafile(m_streams[m_currentPageIndex]);
// Adjust rectangular area with printer margins.
Rectangle adjustedRect = new Rectangle(
ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
ev.PageBounds.Width,
ev.PageBounds.Height);
// Draw a white background for the report
ev.Graphics.FillRectangle(Brushes.White, adjustedRect);
// Draw the report content
ev.Graphics.DrawImage(pageImage, adjustedRect);
// Prepare for the next page. Make sure we haven't hit the end.
m_currentPageIndex++;
ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
Thank you very much for this wonderful tutorial. :)

Similar Messages

  • HOW TO PRINT THE SCRIPT DIRECTLY

    hi ,
    i want to print the script directly by skiping the prini preview screen can any one help me..
    regards,
    siva

    Hi Siva,
    In the function module "<b>OPEN_FORM</b>" pass "<b>SPACE</b>" to the parameter <b>DIALOG</b>.
    This would allow you to SKIP the print preview screen.
    <b>Reward points for helpful answers.</b>
    Best Regards,
    Ram.

  • How to print the Grid title in ALV Report?

    Hi All,
    I write ALV Report.When i am going to print this report it is not printing the Grid Header(ie.Title ).even in Print Preview Also i m not getting the title.It shows the Gird with Values.How Can i print the title Also...
    Regards,Ravi

    Hi,
      u will declare the data as below like this
    DATA: LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
            TOP_OF_PAGE  TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
      DATA : ST_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
             IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
             ST_EVENT TYPE SLIS_ALV_EVENT,
             IT_EVENT TYPE SLIS_T_EVENT.
      DATA : ST_LIST  TYPE SLIS_LISTHEADER,
             IT_LIST  TYPE SLIS_T_LISTHEADER,
             IT_LIST1 TYPE SLIS_T_LISTHEADER,
             IT_LIST2 TYPE SLIS_T_LISTHEADER.
    START-OF-SELECTION.
      IF G_FLAG = SPACE.
      W_REPID = SY-REPID.
      G_TOP_PAGE = 'TOP-PAGE'.
          ST_LIST-INFO = '  Title Name '.
          APPEND ST_LIST TO IT_LIST.
          ST_LIST-INFO = '  second Name'.
          APPEND ST_LIST TO IT_LIST.
        ELSE.
      ENDIF.
    FORM TOP-PAGE .
      DATA: V_LOGO(15).
        V_LOGO = 'LOGO'.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY = IT_LIST
          I_LOGO             = V_LOGO.
        I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP-PAGE

  • How to print adobe form immediately without preview?

    Hi, Experts.
    I made a WD4A using Interactive Form control
    and the app is working fine and displays Adobe Form.
    But I meet a new client needs on how to print immediately without display the form.
    My client says that "I don't wanna see the form and just print form immediately when I click the print button".
    I think there are some option parameters for solving those problem...
    Plz. Help.
    Regards Junha.

    Hello Junha,
    you need to send the pdf to spool. There's a function module for it as far as I know. Can't remember the
    name at the moment and having no access to a SAP system. A good way to find it would be searching
    for SPOOL and PDF in the name.
    Best regards,
    Thomas

  • How to print the BARCODEs in Oracle 6i Reports

    Hi,
    I want to print the barcodes in the report outputs. I am using Oracle Reports 6i and Oracle Applications 11.5.10.2 with 11g database.
    Please help me with the requirements.
    Thanks,
    Pavan

    Go to Search and type in "barcode".

  • How to check the size of flash memory that are used by each applications ?

    I'm using yxplayer as secondary media player.
    2 weeks ago, this program always fails to start up.
    So, I have uninstalled this program and reinstalled newer version.
    After reinstallation, it works well. But all the video clips that I have
    Copied to this application have gone away... And It seems the
    Flash memory that was used by older version did not returned
    To free space.
    Is there any tool to check the usage of internal flash of ipad in detail ?

    Hi,
    Is there any tool to check the usage of internal flash of ipad in detail ?
    Not memory, but storage space.
    Connect your iPad to your computer. Launch iTunes. Select the Summary tab. Storage space available at the bottom of the iTunes page.
    iOS devices do not support Flash.
    Carolyn

  • Is it possible to login into the Java instance without password's input, using only my Windows workstation authorization?

    Dear Sirs,
    I try to do an authorization to my NW 7.3 Java instance through my Windows domain authorization.
    I done:
    1) Create connection to LDAP-server and tested it.
    2) Add windows domain certificate to TrustedCAs
    3) Configure SPnego
    Now, I can to login in my NW7.3 Java instance with my windows password, but however I must to input password when I open NW7.3 Java homepage.
    Is it possible to login into the Java instance without password's input, using my windows workstation login/password?
    What I have to do for that?
    I use Windows XP on my workstation and IE 8.0.6 & Chrome 38.0.2125.
    Best regards,
    Alexey Lugovskoy

    Please check
    Using Kerberos Authentication on SAP NetWeaver AS Java - User Authentication and Single Sign-On - SAP Library (NW7.3)
    Using Kerberos Authentication for Single Sign-On - User Authentication and Single Sign-On - SAP Library (NW7.0)

  • URGENT: How to print the report to a file

    Hi
    Environment Windows NT/2000 Forms 2.5
    I want to print the output of a particular report to a file.
    When I direct the output to the printer and click on 'print to file' option, it prints to a file but the file is not in a recognizable format.
    I want the report to be opened in excel because it is a tabular report with no graphics.
    How to achieve that. I'm absolutely new to Reports.
    Regards
    Naveen

    Hi ,
    Its quite obvious that you are new to the report, what you are trying to do NOW is that you are trying to output a GUI report to a file , which you cannot , for that what you have to do is change the report layout to characther mode (of course you will not be able to get some gui features, ) but if your intention is to get a output to file , then this is the only way, plus you have to realign your report once you change the format to characther mode
    regards
    rajesh
    Hi
    Environment Windows NT/2000 Forms 2.5
    I want to print the output of a particular report to a file.
    When I direct the output to the printer and click on 'print to file' option, it prints to a file but the file is not in a recognizable format.
    I want the report to be opened in excel because it is a tabular report with no graphics.
    How to achieve that. I'm absolutely new to Reports.
    Regards
    Naveen

  • Print Report RDLC without preview ... very important for me.

    Hello, I want to ask you about print Report RDLC without preview .
    I saw this article here :
    http://msdn.microsoft.com/en-us/library/ms252091.aspx
    but I did not understand because the code is long and I think difficult.
    could you put simple code please?
    Thanks a lot.

    Would that fix this mod_jk problem? Do you mean to say that I have those permissions when I actually edit those files?
    I think the wiki is also mistaken assuming that JAVA_HOME is in the /opt directory.

  • How to print the display 2D Barcode details in Oracle Reports

    Hi Experts,
    Can you pleas share the approach to print the 2d Bar code in reports
    we have requirement from our Customer to
    display 2D Barcode details in Oracle Reports (In the Invoice print or in
    Annexure).
    Following are details we have carried out so far :-
    1. We have got JAR file from the Vendor.
    2. We have loaded the JAR File in the FND_TOP.
    3. Then we tried to call the same in the report.
    But we got struck here, didn't know how to proceed further because the
    JAVA Class is not loaded in Oracle Database.
    Kindly help us as to how to achieve the same.

    What jar is it? What is fnd_top? To load java in the database there are several methods. Please use google to find them, or oracle documentation.
    Version of reports?
    Edited by: Lars Sjöström on Nov 25, 2012 11:37 PM

  • How i can print the smartform directly

    hi,
    my requirement is i have to print the smartform directly by skiping the dialog window.
    i am using the following code but in that i have press the Print push button again .
    DATA: output_options TYPE ssfcompop.
      output_options-tdimmed = 'X'.
      output_options-tddest = 'LOCL'.

    Trty something like
    *   Print parameters
        ssfcompop-tddest = tddest.
        ssfcompop-tdimmed = 'X'.
        ssfcompop-tdnewid = 'X'.
        ssfcompop-tddelete = 'X'.
    *   Control parameters
        ssfctrlop-device = 'PRINTER'.
        ssfctrlop-no_dialog = 'X'.
    * Call driver
        CALL FUNCTION fm_name
             EXPORTING
                  control_parameters = ssfctrlop
                  output_options     = ssfcompop
    Regards

  • Report Generation without previewing

    Hi,
    i am generating report by clicking menu. Code under menu is...
    run_product(reports,'daily',synchronous,runtime,filesystem,'',null);
    Suppose i am viewing the detail of customers. i want to print the report of customer detail whose detail iam viewing. i want to generate report by clicking button without previewing report. what would be the code of it?
    Thanks

    place a button on ur report and in action trigger use srw.run_report for calling 2nd report.
    srw.run_report('report path & name destype=.......');
    pass value for DESTYPE what u want eg printer, screen, file. U can also pass other paramters.

  • How to print the error records and success records in bdc

    how to print the number of error records and success records in bdc

    hai,
    plz refer this program,
    Z_130399130271_A
    REPORT Z_130399130271_A
           NO STANDARD PAGE HEADING LINE-SIZE 325.
    *INCLUDE YVALIDATE.
    *include bdcrecx1.
    INCLUDE YINCLUDE399.
    DATA ITAB LIKE TABLE OF FILE_TABLE WITH HEADER LINE.
    PARAMETERS: DATASET(132) LOWER CASE.
    DATA : RC TYPE I,
    ERR(40) TYPE C,
    SUCCESSCNT TYPE I VALUE 0,
    FAILCOUNT TYPE I VALUE 0.
       DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
      If it is nessesary to change the data section use the rules:
      1.) Each definition of a field exists of two lines
      2.) The first line shows exactly the comment
          '* data element: ' followed with the data element
          which describes the field.
          If you don't have a data element use the
          comment without a data element name
      3.) The second line shows the fieldname of the
          structure, the fieldname must consist of
          a fieldname and optional the character '_' and
          three numbers and the field length in brackets
      4.) Each field must be type C.
    Generated data section with specific formatting - DO NOT CHANGE  ***
    DATA: BEGIN OF RECORD OCCURS 0,
    data element: LIF16
            LIFNR_001(016),
    data element: KTOKK
            KTOKK_002(004),
    data element: ANRED
            ANRED_003(015),
    data element: NAME1_GP
            NAME1_004(035),
    data element: SORTL
            SORTL_005(010),
    data element: STRAS_GP
            STRAS_006(035),
    data element: PFACH
            PFACH_007(010),
    data element: ORT01_GP
            ORT01_008(035),
    data element: ORT02_GP
            ORT02_009(035),
    data element: LAND1_GP
            LAND1_010(003),
    data element: REGIO
            REGIO_011(003),
    data element: SPRAS
            SPRAS_012(002),
    data element: TELF1
            TELF1_013(016),
    data element: TELF2
            TELF2_014(016),
    data element: BANKS
            BANKS_01_015(003),
    data element: BANKK
            BANKL_01_016(015),
    data element: BANKN
            BANKN_01_017(018),
          END OF RECORD.
    DATA:   BEGIN OF ERRORITAB OCCURS 0,
            LIFNR_001 LIKE LFA1-LIFNR,
            KTOKK_002 LIKE LFA1-KTOKK,
            ANRED_003 LIKE LFA1-ANRED,
            NAME1_004 LIKE LFA1-NAME1,
            SORTL_005 LIKE LFA1-SORTL,
            STRAS_006 LIKE LFA1-STRAS,
            PFACH_007 LIKE LFA1-PFACH,
            ORT01_008 LIKE LFA1-ORT01,
            ORT02_009 LIKE LFA1-ORT02,
            LAND1_010 LIKE LFA1-LAND1,
            REGIO_011 LIKE LFA1-REGIO,
            SPRAS_012 LIKE LFA1-SPRAS,
            TELF1_013 LIKE LFA1-TELF1,
            TELF2_014 LIKE LFA1-TELF2,
            BANKS_01_015 LIKE LFBK-BANKS,
            BANKL_01_016 LIKE LFBK-BANKL,
            BANKN_01_017 LIKE LFBK-BANKN,
            ERRORMSG(60) TYPE C,
            SERIAL TYPE I VALUE '1',
        END OF ERRORITAB.
    End generated data section ***
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR DATASET.
      CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
    EXPORTING
        WINDOW_TITLE            = 'select a file '
        DEFAULT_EXTENSION       = 'TXT'
        DEFAULT_FILENAME        = 'ASSIGN5.TXT'
      FILE_FILTER             =
      INIT_DIRECTORY          =
      MULTISELECTION          =
    IMPORTING
      RC                      =
        TABLES
          FILE_TABLE              = ITAB
    EXCEPTIONS
       CNTL_ERROR              = 1
       OTHERS                  = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE ITAB INDEX 1.
      DATASET = ITAB-FILENAME.
      WRITE DATASET.
    START-OF-SELECTION.
    *perform open_dataset using dataset.
    *perform open_group.
      DATA T TYPE STRING.
      T = DATASET.
      IF T EQ ' '.
        MESSAGE E110(ZX).
      ENDIF.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                      = T
      FILETYPE                      = 'ASC'
          HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
        TABLES
          DATA_TAB                      = RECORD
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      LOOP AT RECORD.
        CLEAR RC.
        CLEAR ERR.
    *read dataset dataset into record.
        IF SY-SUBRC <> 0. EXIT. ENDIF.
        RECORD-KTOKK_002 = '0001'.
        PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0100'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'RF02K-KTOKK'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM BDC_FIELD       USING 'RF02K-LIFNR'
                                      RECORD-LIFNR_001.
        PERFORM BDC_FIELD       USING 'RF02K-KTOKK'
                                      RECORD-KTOKK_002.
        PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0110'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'LFA1-TELX1'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '/00'.
        PERFORM BDC_FIELD       USING 'LFA1-ANRED'
                                      RECORD-ANRED_003.
        PERFORM BDC_FIELD       USING 'LFA1-NAME1'
                                      RECORD-NAME1_004.
        PERFORM BDC_FIELD       USING 'LFA1-SORTL'
                                      RECORD-SORTL_005.
        PERFORM BDC_FIELD       USING 'LFA1-STRAS'
                                      RECORD-STRAS_006.
        PERFORM BDC_FIELD       USING 'LFA1-PFACH'
                                      RECORD-PFACH_007.
        PERFORM BDC_FIELD       USING 'LFA1-ORT01'
                                      RECORD-ORT01_008.
        PERFORM BDC_FIELD       USING 'LFA1-ORT02'
                                      RECORD-ORT02_009.
        PERFORM BDC_FIELD       USING 'LFA1-LAND1'
                                      RECORD-LAND1_010.
        PERFORM BDC_FIELD       USING 'LFA1-REGIO'
                                      RECORD-REGIO_011.
        PERFORM BDC_FIELD       USING 'LFA1-SPRAS'
                                      RECORD-SPRAS_012.
        PERFORM BDC_FIELD       USING 'LFA1-TELF1'
                                      RECORD-TELF1_013.
        PERFORM BDC_FIELD       USING 'LFA1-TELF2'
                                      RECORD-TELF2_014.
        PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0120'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'LFA1-KUNNR'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=VW'.
        PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0130'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'LFBK-BANKN(01)'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=ENTR'.
        PERFORM BDC_FIELD       USING 'LFBK-BANKS(01)'
                                      RECORD-BANKS_01_015.
        PERFORM BDC_FIELD       USING 'LFBK-BANKL(01)'
                                      RECORD-BANKL_01_016.
        PERFORM BDC_FIELD       USING 'LFBK-BANKN(01)'
                                      RECORD-BANKN_01_017.
        PERFORM BDC_DYNPRO      USING 'SAPMF02K' '0130'.
        PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                      'LFBK-BANKS(01)'.
        PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                      '=UPDA'.
        PERFORM BDC_TRANSACTION USING 'XK01' CHANGING ERR RC.
        DATA: SERIAL TYPE I VALUE 1.
        IF RC <> 0.
          FAILCOUNT = FAILCOUNT + 1.
          CLEAR ERRORITAB.
          ERRORITAB-SERIAL = SERIAL.
          ERRORITAB-LIFNR_001 = RECORD-LIFNR_001.
          ERRORITAB-KTOKK_002 = RECORD-KTOKK_002.
          ERRORITAB-ANRED_003 = RECORD-ANRED_003.
          ERRORITAB-NAME1_004 = RECORD-NAME1_004.
          ERRORITAB-SORTL_005 = RECORD-SORTL_005.
          ERRORITAB-STRAS_006 = RECORD-STRAS_006.
          ERRORITAB-PFACH_007 = RECORD-PFACH_007.
          ERRORITAB-ORT01_008 = RECORD-ORT01_008.
          ERRORITAB-ORT02_009 = RECORD-ORT02_009.
          ERRORITAB-LAND1_010 = RECORD-LAND1_010.
          ERRORITAB-REGIO_011 = RECORD-REGIO_011.
          ERRORITAB-SPRAS_012 = RECORD-SPRAS_012.
          ERRORITAB-TELF1_013 = RECORD-TELF1_013.
          ERRORITAB-TELF2_014 = RECORD-TELF2_014.
          ERRORITAB-BANKS_01_015 = RECORD-BANKS_01_015.
          ERRORITAB-BANKL_01_016 = RECORD-BANKL_01_016.
          ERRORITAB-BANKN_01_017 = RECORD-BANKN_01_017.
          ERRORITAB-ERRORMSG = ERR.
          SERIAL = SERIAL + 1.
          APPEND ERRORITAB.
          MODIFY RECORD TRANSPORTING KTOKK_002.
          DELETE RECORD WHERE KTOKK_002 = '0001'.
        ELSE.
          SUCCESSCNT = SUCCESSCNT + 1.
        ENDIF.
      ENDLOOP.
    display output********************************************************
      SKIP.
      FORMAT COLOR 5 INTENSIFIED OFF.
      WRITE:/ 'No. of records successfully uploaded: '.
      FORMAT COLOR 4 INTENSIFIED OFF.
      WRITE: SUCCESSCNT.
    Displaying the success table******************************************
      IF SUCCESSCNT <> 0.
        SKIP.
        FORMAT COLOR 4 INTENSIFIED OFF.
        WRITE:/ 'Successful Records'.
        FORMAT COLOR 7 INTENSIFIED ON.
        WRITE:/(261) SY-ULINE,
              / SY-VLINE,
                'S.NO',                               007 SY-VLINE,
                'VENDOR ACC.NUM',                     023 SY-VLINE,
                'VENDOR ACC GROUP',                   041 SY-VLINE,
                'TITLE',                              048 SY-VLINE,
                'VENDOR NAME',                        064 SY-VLINE,
                'SORT FIELD',                         076 SY-VLINE,
                'HOUSE NO.& STREET',                  101 SY-VLINE,
                'PO.BOX NO',                          116 SY-VLINE,
                'CITY',                               129 SY-VLINE,
                'DISTRICT',                           141 SY-VLINE,
                'COUNTRY KEY',                        156 SY-VLINE,
                'REGION',                             166 SY-VLINE,
                'LANGUAGE KEY',                       180 SY-VLINE,
                'TELEPHONE NO 1',                     196 SY-VLINE,
                'TELEPHONE NO 2',                     213 SY-VLINE,
                'BANK COUNTRY KEY',                   231 SY-VLINE,
                'BANK KEY',                           241 SY-VLINE,
                'BANK ACC.NO',                        261 SY-VLINE,
                /1(261) SY-ULINE.
        FORMAT COLOR 4 INTENSIFIED ON.
        SERIAL = 1.
       SORT RECORD BY LIFNR_001.
        LOOP AT RECORD.
          WRITE:/ SY-VLINE,
          SERIAL LEFT-JUSTIFIED,          007 SY-VLINE,
          RECORD-LIFNR_001(016),          023 SY-VLINE,
          RECORD-KTOKK_002(004),          041 SY-VLINE,
          RECORD-ANRED_003(015),          048 SY-VLINE,
          RECORD-NAME1_004(035),          064 SY-VLINE,
          RECORD-SORTL_005(010),          076 SY-VLINE,
          RECORD-STRAS_006(035),          101 SY-VLINE,
          RECORD-PFACH_007(010),          116 SY-VLINE,
          RECORD-ORT01_008(035),          129 SY-VLINE,
          RECORD-ORT02_009(035),          141 SY-VLINE,
          RECORD-LAND1_010(003),          156 SY-VLINE,
          RECORD-REGIO_011(003),          166 SY-VLINE,
          RECORD-SPRAS_012(002),          180 SY-VLINE,
          RECORD-TELF1_013(016),          196 SY-VLINE,
          RECORD-TELF2_014(016),          213 SY-VLINE,
          RECORD-BANKS_01_015(003),       231 SY-VLINE,
          RECORD-BANKL_01_016(015),       241 SY-VLINE,
          RECORD-BANKN_01_017(018),       261 SY-VLINE.
          WRITE:/(261) SY-ULINE.
          SERIAL = SERIAL + 1.
        ENDLOOP.
        WRITE:/1(261) SY-ULINE.
      ENDIF.
      SKIP.
      FORMAT COLOR 5 INTENSIFIED OFF.
      WRITE:/ 'No. of records not uploaded: '.
      FORMAT COLOR 4 INTENSIFIED OFF.
      WRITE: FAILCOUNT.
    *Displaying the error table
      IF FAILCOUNT <> 0.
        SKIP.
        FORMAT COLOR 4 INTENSIFIED OFF.
        WRITE:/(320) SY-ULINE,
                'Error Records'.
        FORMAT COLOR 7 INTENSIFIED ON.
        WRITE:/ SY-ULINE, SY-VLINE,
                'S.NO',                               007 SY-VLINE,
                'VENDOR ACC.NUM',                     023 SY-VLINE,
                'VENDOR ACC GROUP',                   041 SY-VLINE,
                'TITLE',                              048 SY-VLINE,
                'VENDOR NAME',                        064 SY-VLINE,
                'SORT FIELD',                         076 SY-VLINE,
                'HOUSE NO.& STREET',                  101 SY-VLINE,
                'PO.BOX NO',                          116 SY-VLINE,
                'CITY',                               129 SY-VLINE,
                'DISTRICT',                           141 SY-VLINE,
                'COUNTRY KEY',                        156 SY-VLINE,
                'REGION',                             166 SY-VLINE,
                'LANGUAGE KEY',                       180 SY-VLINE,
                'TELEPHONE NO 1',                     196 SY-VLINE,
                'TELEPHONE NO 2',                     213 SY-VLINE,
                'BANK COUNTRY KEY',                   231 SY-VLINE,
                'BANK KEY',                           241 SY-VLINE,
                'BANK ACC.NO',                        261 SY-VLINE,
                'ERROR MESSAGE',                      320 SY-VLINE.
        WRITE:/(320) SY-ULINE.
        FORMAT COLOR 4 INTENSIFIED ON.
       SORT ERRORITAB BY LIFNR_001.
        LOOP AT ERRORITAB.
          WRITE:/ SY-VLINE,
                ERRORITAB-SERIAL LEFT-JUSTIFIED,          007 SY-VLINE,
                ERRORITAB-LIFNR_001 ,       023 SY-VLINE,
                ERRORITAB-KTOKK_002,       041 SY-VLINE,
                ERRORITAB-ANRED_003,       048 SY-VLINE,
                ERRORITAB-NAME1_004,       064 SY-VLINE,
                ERRORITAB-SORTL_005,       076 SY-VLINE,
                ERRORITAB-STRAS_006,       101 SY-VLINE,
                ERRORITAB-PFACH_007,       116 SY-VLINE,
                ERRORITAB-ORT01_008,       129 SY-VLINE,
                ERRORITAB-ORT02_009,       141 SY-VLINE,
                ERRORITAB-LAND1_010,       156 SY-VLINE,
                ERRORITAB-REGIO_011,       166 SY-VLINE,
                ERRORITAB-SPRAS_012,       180 SY-VLINE,
                ERRORITAB-TELF1_013,       196 SY-VLINE,
                ERRORITAB-TELF2_014,       213 SY-VLINE,
                ERRORITAB-BANKS_01_015,    231 SY-VLINE,
                ERRORITAB-BANKL_01_016,    241 SY-VLINE,
                ERRORITAB-BANKN_01_017,    261 SY-VLINE,
                ERRORITAB-ERRORMSG,        320 SY-VLINE.
          WRITE:/(320) SY-ULINE.
        ENDLOOP.
        WRITE:/ SY-ULINE.
      ENDIF.
    hope this ll help you..
    regards,
    prema.A

  • How to get  the actual data in ALV report

    I am doing some upgradation work   in that i am using Submit  & And return and  also i am using some function modules like LIST FROM MEMORY , LIST TO TXT wnd WRITE LIST , it gives output in normal list format , But i need to print in ALV report .
    With the use of set table for 1st display i got the  ALV report   but not with actual data, (some junk value is showing) , So can any 1 suggest me how to get  the  actual data in ALV report, With the use of  Any Function Module or with Coding,
    with regards,

    Hi Saravana
    I am sure you must be getting the values in tables of table parameters from every FM.
    consolidate the values from tables of all FMs in one table and built ALV for that table only.
    I hope this way you can show the actual data in ALV.
    thanks
    Lalit

  • Delivery document how to print the BOM Parent and Child items

    Hi,
    I have a production BOM. In Delivery document how to print the Parent and Child items Item Code and Qty.At the time
    of add a delivery document Inventory stock redused only in Parent Item not child item because child item stock already reduced in issue for production.

    If you need to print both the BOM Parent and Child items, you have to create your own report. BOM is only for production if it is not Sales type.
    Thanks,
    Gordon

Maybe you are looking for