Deletion and Creation of Excel sheet

Hi,
I have to remove the monthly spread sheet every time and create a new spread sheet while executing the code. The problem is when I run the code the records inserted into same spread sheet along with the previous records. So I need to delete the excel file and create new one. I am using POI to create the spread sheet. ICan anyone help me on this? I am posting the code below.
import org.apache.poi.hssf.usermodel.*;
public class MonthlyVolume {
     public static void execute(String[] args) {
          try {
               Properties props = new Properties();
               props.load(new FileInputStream("MonthlyVolume.properties"));
               String rpt_name = props.getProperty("rpt_loc");
               if (! rpt_name.endsWith("/")) {
                    rpt_name += "/";
               rpt_name += "Monthly Volume - " + strlast_monthyear + ".xls";
               generateExcel(rs, rpt_name, region_code, location_code, country_description, company_id, principal_debit_account, account_name, bt_count, total_bt_usd, ct_count, total_ct_usd, dr_count, total_dr_usd, avg_daily_trans, avg_daily_usd, tot_count, tot_usd, fx_count, fx_usd_amt, import_count);
          } catch (Exception e) {
               e.printStackTrace();
     public static void generateExcel(ResultSet rs, String rpt_name, String region_code, String location_code, String country_description, String company_id, String principal_debit_account, String account_name, int bt_count, double total_bt_usd, int ct_count, double total_ct_usd, int dr_count, double total_dr_usd, int avg_daily_trans, double avg_daily_usd, int tot_count, double tot_usd, int fx_count, double fx_usd_amt, int import_count) {
          try {
               HSSFWorkbook wb = null;
               HSSFSheet sh = null;
               short row_num = 1;
               while (rs.next()){
                    try {
                         System.out.println(" I am inside try block");
                         wb = new HSSFWorkbook(new FileInputStream(rpt_name));
                         sh = wb.getSheet("Totals");
                         for (row_num = 0; true; row_num++) {                              
                              if (sh.getRow(row_num) == null) {
                                   break;
                    } catch (FileNotFoundException e) {
                         System.out.println(" I am inside catch block");
                         wb = new HSSFWorkbook();
                         sh = wb.createSheet("Totals");
                         HSSFRow row = sh.createRow((short)0);
                         HSSFCell cell0 = row.createCell((short)0);
                         HSSFCell cell1 = row.createCell((short)1);
                         HSSFCell cell2 = row.createCell((short)2);
                         HSSFCell cell3 = row.createCell((short)3);
                         HSSFCell cell4 = row.createCell((short)4);
                         HSSFCell cell5 = row.createCell((short)5);
                         HSSFCell cell6 = row.createCell((short)6);
                         HSSFCell cell7 = row.createCell((short)7);
                         HSSFCell cell8 = row.createCell((short)8);
                         HSSFCell cell9 = row.createCell((short)9);
                         HSSFCell cell10 = row.createCell((short)10);
                         HSSFCell cell11 = row.createCell((short)11);
                         HSSFCell cell12 = row.createCell((short)12);
                         HSSFCell cell13 = row.createCell((short)13);
                         HSSFCell cell14 = row.createCell((short)14);
                         HSSFCell cell15 = row.createCell((short)15);
                         HSSFCell cell16 = row.createCell((short)16);
                         HSSFCell cell17 = row.createCell((short)17);
                         HSSFCell cell18 = row.createCell((short)18);
                         cell0.setCellValue("Region");
                         cell1.setCellValue("Country");
                         cell2.setCellValue("Country Name");
                         cell3.setCellValue("Company ID");
                         cell4.setCellValue("Account Number");
                         cell5.setCellValue("Account Name");
                         cell6.setCellValue("Total Trans");
                         cell7.setCellValue("Total Amount");
                         cell8.setCellValue("FX Count");
                         cell9.setCellValue("FX USD Equivalent");
                         cell10.setCellValue("Avg Daily Trans");
                         cell11.setCellValue("Avg Daily Amount");
                         cell12.setCellValue("Import Count");
                         cell13.setCellValue("Cust Trans");
                         cell14.setCellValue("Amount");
                         cell15.setCellValue("Bk Trans");
                         cell16.setCellValue("Amount");
                         cell17.setCellValue("Drafts");
                         cell18.setCellValue("Amount");
                         HSSFCellStyle cs = wb.createCellStyle();
                         HSSFFont f = wb.createFont();
                         f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                         cs.setFont(f);
                         cell0.setCellStyle(cs);
                         cell1.setCellStyle(cs);
                         cell2.setCellStyle(cs);
                         cell3.setCellStyle(cs);
                         cell4.setCellStyle(cs);
                         cell5.setCellStyle(cs);
                         cell6.setCellStyle(cs);
                         cell7.setCellStyle(cs);
                         cell8.setCellStyle(cs);
                         cell9.setCellStyle(cs);
                         cell10.setCellStyle(cs);
                         cell11.setCellStyle(cs);
                         cell12.setCellStyle(cs);
                         cell13.setCellStyle(cs);
                         cell14.setCellStyle(cs);
                         cell15.setCellStyle(cs);
                         cell16.setCellStyle(cs);
                         cell17.setCellStyle(cs);
                         cell18.setCellStyle(cs);
                    sh.setColumnWidth((short)0, (short)3000);
                    sh.setColumnWidth((short)1, (short)4000);
                    sh.setColumnWidth((short)2, (short)6000);
                    sh.setColumnWidth((short)3, (short)4000);
                    sh.setColumnWidth((short)4, (short)4200);
                    sh.setColumnWidth((short)5, (short)12000);
                    sh.setColumnWidth((short)6, (short)4000);
                    sh.setColumnWidth((short)7, (short)5000);
                    sh.setColumnWidth((short)8, (short)4000);
                    sh.setColumnWidth((short)9, (short)5000);
                    sh.setColumnWidth((short)10, (short)4000);
                    sh.setColumnWidth((short)11, (short)5000);
                    sh.setColumnWidth((short)12, (short)4000);
                    sh.setColumnWidth((short)13, (short)5000);
                    sh.setColumnWidth((short)14, (short)4000);
                    sh.setColumnWidth((short)15, (short)5000);
                    sh.setColumnWidth((short)16, (short)5000);
                    sh.setColumnWidth((short)17, (short)5000);
                    sh.setColumnWidth((short)18, (short)5000);
                    HSSFRow row = sh.createRow(row_num);
                    HSSFCell cell0 = row.createCell((short)0);
                    HSSFCell cell1 = row.createCell((short)1);
                    HSSFCell cell2 = row.createCell((short)2);
                    HSSFCell cell3 = row.createCell((short)3);
                    HSSFCell cell4 = row.createCell((short)4);
                    HSSFCell cell5 = row.createCell((short)5);
                    HSSFCell cell6 = row.createCell((short)6);
                    HSSFCell cell7 = row.createCell((short)7);
                    HSSFCell cell8 = row.createCell((short)8);
                    HSSFCell cell9 = row.createCell((short)9);
                    HSSFCell cell10 = row.createCell((short)10);
                    HSSFCell cell11 = row.createCell((short)11);
                    HSSFCell cell12 = row.createCell((short)12);
                    HSSFCell cell13 = row.createCell((short)13);
                    HSSFCell cell14 = row.createCell((short)14);
                    HSSFCell cell15 = row.createCell((short)15);
                    HSSFCell cell16 = row.createCell((short)16);
                    HSSFCell cell17 = row.createCell((short)17);
                    HSSFCell cell18 = row.createCell((short)18);
                    region_code = rs.getString("region_code");
                    location_code = rs.getString("location_code");
                    country_description = rs.getString("country_description");
                    company_id = rs.getString("company_id");
                    principal_debit_account = rs.getString("principal_debit_account");
                    account_name = rs.getString("account_name");
                    bt_count = rs.getInt("bt_count");
                    total_bt_usd = rs.getDouble("total_bt_usd");
                    ct_count = rs.getInt("ct_count");
                    total_ct_usd = rs.getDouble("total_ct_usd");
                    dr_count = rs.getInt("dr_count");
                    total_dr_usd = rs.getDouble("total_dr_usd");
                    avg_daily_trans = rs.getInt("avg_daily_trans");
                    avg_daily_usd = rs.getDouble("avg_daily_usd");
                    tot_count = rs.getInt("tot_count");
                    tot_usd = rs.getDouble("tot_usd");
                    fx_count = rs.getInt("fx_count");
                    fx_usd_amt = rs.getDouble("fx_usd_amt");
                    import_count = rs.getInt("import_count");
                    cell0.setCellValue(region_code);
                    cell1.setCellValue(location_code);
                    cell2.setCellValue(country_description);
                    cell3.setCellValue(company_id);
                    cell4.setCellValue(principal_debit_account);
                    cell5.setCellValue(account_name);
                    cell6.setCellValue(tot_count);
                    cell7.setCellValue(tot_usd);
                    cell8.setCellValue(fx_count);
                    cell9.setCellValue(fx_usd_amt);
                    cell10.setCellValue(avg_daily_trans);
                    cell11.setCellValue(avg_daily_usd);
                    cell12.setCellValue(import_count);
                    cell13.setCellValue(ct_count);
                    cell14.setCellValue(total_ct_usd);
                    cell15.setCellValue(bt_count);
                    cell16.setCellValue(total_bt_usd);
                    cell17.setCellValue(dr_count);
                    cell18.setCellValue(total_dr_usd);
                    HSSFCellStyle csNumber = wb.createCellStyle();
                    HSSFCellStyle csCurrency = wb.createCellStyle();
                    HSSFCellStyle csString = wb.createCellStyle();
                    csNumber.setDataFormat((short)3);
                    csCurrency.setDataFormat((short)7);
                    csString.setDataFormat((short)7);
                    cell0.setCellStyle(csString);
                    cell1.setCellStyle(csString);
                    cell2.setCellStyle(csString);
                    cell3.setCellStyle(csString);
                    cell4.setCellStyle(csString);
                    cell5.setCellStyle(csString);
                    cell6.setCellStyle(csNumber);
                    cell7.setCellStyle(csCurrency);
                    cell8.setCellStyle(csNumber);
                    cell9.setCellStyle(csCurrency);
                    cell10.setCellStyle(csNumber);
                    cell11.setCellStyle(csCurrency);
                    cell12.setCellStyle(csNumber);
                    cell13.setCellStyle(csNumber);
                    cell14.setCellStyle(csCurrency);
                    cell15.setCellStyle(csNumber);
                    cell16.setCellStyle(csCurrency);
                    cell17.setCellStyle(csNumber);
                    cell18.setCellStyle(csCurrency);
                    wb.write(new FileOutputStream(rpt_name));
          } catch (Exception e) {
               e.printStackTrace();
     public static void main(String[] args) {
     MonthlyVolume.execute(args);
}

I have to remove the monthly spread sheet every time
and create a new spread sheet while executing the
code. The problem is when I run the code the records
inserted into same spread sheet along with the
previous records. So I need to delete the excel file
and create new one. I am using POI to create the
spread sheet. ICan anyone help me on this? I am
posting the code below.I don't think I want to read all that code. If you want to replace the data, you can remove the sheet and create a new one with the same name. HSSFWorkBook has methods removeSheetAt() and createSheet().

Similar Messages

  • Comparing and Combining 2 Excel Sheets

    Hi there,
    I have Microsoft Office 2008 (also Office 2007 on Windows - Using Parallel). Is there a software out there for Mac or PC where I can compare and combine two excel sheets? Each excel sheet has at least 12,000 rows. One column on each spreadsheet has a unique header.
    Anything that would be compatible with Leopard or XP that anyone would recommend.
    Thanks!
    Gilbert

    Apple Discussions doesn't have support for third-party products. Excel is a Microsoft product. You would be better off posting this question in the Excel for Mac forums at Microsoft. You can find them via Mactopia.

  • Deletion and creation of Configuration Objects using JAVA Transports

    Hi Guys
    I hope you guys can help me make some sense out this situation.
    We have 2 systems in the QA Landscape which shares the Integration Server, Lets call it SYS.A1 and SYS.A2. In the SLD both SYS.A1 and SYS.A2 have the transport track pointing to SYS.PROD as the Production Environment. In QA env. we have 2 receiver determination for these 2 systems. This means in the PROD Environment we will have One object(Receiver Determination) which represents connections from these 2 systems in the QA Environment. (In prod we have one system which represents both the system in QA).
    Recently there was a transport that came in from the QA env to PROD which contained a deletion of the receiver determination for SYS.A1 and modification of receiver determination for SYS.A2. So by the end of the transport we expected to see a modified receiver determination for the PROD environment, but what we found was the object that was there in PROD was deleted and nothing was modified.
    So Can you please tell me what the transport sequence is? is there a priority given to deletion over creation? Or is there some kind of versioning applied for Directory Object transport?
    I read from the forum that there is some sort of versioning applied on repository transport.. is it the same case here??? Any help in explaining this would be much appreciated.
    Thanks & Regards
    Prav

    I have to remove the monthly spread sheet every time
    and create a new spread sheet while executing the
    code. The problem is when I run the code the records
    inserted into same spread sheet along with the
    previous records. So I need to delete the excel file
    and create new one. I am using POI to create the
    spread sheet. ICan anyone help me on this? I am
    posting the code below.I don't think I want to read all that code. If you want to replace the data, you can remove the sheet and create a new one with the same name. HSSFWorkBook has methods removeSheetAt() and createSheet().

  • Header and footer in excel sheet (ole object)

    How can we generate footer and header in an excel sheet with ole object ?
    Thanks

    hi brian,
    Excel Upload Alternative - KCD_EXCEL_OLE_TO_INT_CONVERT
    *Title : Excel Uploading
    TYPES:   BEGIN OF t_datatab,
             col1(25)  TYPE c,
             col2(30)  TYPE c,
             col3(30)  TYPE c,
             col4(30)  TYPE c,
             col5(30)  TYPE c,
             col6(30)  TYPE c,
             col7(30) TYPE c,
             col8(30)  TYPE c,
             col9(30)  TYPE c,
             col10(30)  TYPE c,
             col11(30)    TYPE c,
           END OF t_datatab.
    DATA: it_datatab TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0,
          wa_datatab TYPE t_datatab.
    Data : p_table type t_datatab occurs 0 with header line.
    DATA : gd_scol   TYPE i VALUE '1',
           gd_srow   TYPE i VALUE '1',
           gd_ecol   TYPE i VALUE '256',
           gd_erow   TYPE i VALUE '65536'.
    DATA: it_tab TYPE filetable,
          gd_subrc TYPE i.
    field-symbols : <fs>.
    *Selection screen definition
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:  p_file LIKE rlgrap-filename
                   DEFAULT 'c:\test.xls' OBLIGATORY.   " File Name
    SELECTION-SCREEN END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      REFRESH: it_tab.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title     = 'Select File'
          default_filename = '*.xls'
          multiselection   = ' '
        CHANGING
          file_table       = it_tab
          rc               = gd_subrc.
      LOOP AT it_tab INTO p_file.
       so_fpath-sign = 'I'.
       so_fpath-option = 'EQ'.
       append so_fpath.
      ENDLOOP.
    START-OF-SELECTION.
      PERFORM upload_excel_file TABLES   it_datatab
                                 USING   p_file
                                         gd_scol
                                         gd_srow
                                         gd_ecol
                                         gd_erow.
    END-OF-SELECTION.
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3,
                wa_datatab-col4,
                wa_datatab-col5,
                wa_datatab-col6,
                wa_datatab-col7,
                wa_datatab-col8,
                wa_datatab-col9,
                wa_datatab-col10,
                wa_datatab-col11.
      ENDLOOP.
    *&      Form  UPLOAD_EXCEL_FILE
          upload excel spreadsheet into internal table
         -->P_TABLE    Table to return excel data into
         -->P_FILE     file name and path
         -->P_SCOL     start column
         -->P_SROW     start row
         -->P_ECOL     end column
         -->P_EROW     end row
    FORM upload_excel_file TABLES   p_table
                           USING    p_file
                                    p_scol
                                    p_srow
                                    p_ecol
                                    p_erow.
      DATA : lt_intern TYPE  kcde_cells OCCURS 0 WITH HEADER LINE.
    Has the following format:
                Row number   | Colum Number   |   Value
         i.e.     1                 1             Name1
                  2                 1             Joe
      DATA : ld_index TYPE i.
    Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
        EXPORTING
          filename                = p_file
          i_begin_col             = p_scol
          i_begin_row             = p_srow
          i_end_col               = p_ecol
          i_end_row               = p_erow
        TABLES
          intern                  = LT_INTERN
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'Error Uploading file'.
        EXIT.
      ENDIF.
      IF lt_intern[] IS INITIAL.
        FORMAT COLOR COL_BACKGROUND INTENSIFIED.
        WRITE:/ 'No Data Uploaded'.
        EXIT.
      ELSE.
        SORT lt_intern BY row col.
        LOOP AT lt_intern.
         MOVE lt_intern-col TO ld_index.
         assign component ld_index of structure
         p_table to <fs>.
    move : lt_intern-value to <fs>.
        MOVE lt_intern-value TO p_table.
          AT END OF row.
            APPEND p_table.
            CLEAR p_table.
          ENDAT.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "UPLOAD_EXCEL_FILE
    thanks
    abdul

  • [webdynpro] How to get the data from database and store in Excel sheet

    Hi All-
    I am developing an application in Webdynpro and I need to provide a URL ( link ) which if clicked , need to collect the data from Database ( SQL Server ) and puts in an Excel Sheet corresponding fields and opens the sheet.....
    Please look into this issue and help me out......
    Regards,
    Cris

    Hi Cris,
    Add-on to wat santosh has pointed to:
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    (Or) If you have implemented your logic to get Database records below Blog should guide you in opening an excel with ur records.
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    Regards,
    N.

  • Read and Display an Excel Sheet

    Hello LabVIEW community.  I am going through a bumnch of ActiveX subVIs trying to figure out how to do something very simple.  All I want to do is read an entire Excel Sheet and display it in an array.  Single Page.  Any help would be hot.
    Remember, code does exactly what you tell it.
    Solved!
    Go to Solution.

    camerond wrote:
    DailyDose wrote:
    Is it possible to program this example to simply read all the columns and rows until it comes across like maybe 3 repetitive empty cells instead of having to specify which which row/column to end at?
    Sure. Give it a shot and let us know how you solved it.
    Cameron
    You're right!  It was possible.  Use For loops and check to see when empty cells begin to repeat.  I named it GetXL_CellValues_2D_String_All.vi
    I made mine though very dependent on my excel sheet.  It's easy to make it excel sheet independent.
    Remember, code does exactly what you tell it.
    Attachments:
    read_excel_values.llb ‏267 KB

  • Delete a column in excel sheet through POI?

    hi
    Can anyone help me out on physically deleting a column in Excel using POI framework?
    Though I am able to remove indidual cells,the cells remain blank. I want them be completly removed from the sheet.
    pls help

    Soph wrote:
    hi
    Can anyone help me out on physically deleting a column in Excel using POI framework?
    Though I am able to remove indidual cells,the cells remain blank. I want them be completly removed from the sheet.
    pls helpCan you do it in the Excel in your PC? I bet not
    Then you are able to help me how to generate a chart in Excel using POI :D :D
    But first, where to download POI library, Thanks
    {EDIT} found it never mind
    Edited by: mycoffee on Jul 1, 2010 12:15 PM

  • Leading zeros deleted while downloading to excel sheet

    Hi ,
    i am downloading data to excel sheet  from internal table, iam using gui_download but its deletin leading zeros can any one tell me as to how i go about this
    for ex i ahve a mterial no : 00123
    i see 123 i want it to be 00123
    Thanks
    kajol

    Hi,
      try to explain to excel, that this field is character field (I think that it will be done by adding single quote as first character of string).
    Pointing to my previous answer try:
    Constants: c_single_quote(1) type c value ''''.   " I _hope_ it works
    loop at itab.
    concatenate c_single_quote itab-matnr to texttab-c_matnr.
    endloop.

  • Showing the Data and exporting to Excel Sheet!!!

    I've one jsp page displaying the data from the database using jdbc connection. Now, i want to export all these data to the Excel Sheet. Could anyone tell me that , how to achieve this in JSP.
    in advance thanks....

    please go through the following links
    1)http://jakarta.apache.org/poi/
    2)http://www.rgagnon.com/javadetails/java-0516.html

  • How to download logo and heading in excel sheet.

    Hi ,
    can any one tell me how i will download the logo in the excel sheet by using program.
    Regards,
    Priti shrivastava

    Hope you are comfortable with inserting header in to excel sheet.
    Regarding Logo see the below code snippet:-
    TABLES:
      sflight.
    * header data................................
    DATA :
      header1 LIKE gxxlt_p-text VALUE 'Suresh',
      header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.
    * Internal table for holding the SFLIGHT data
    DATA BEGIN OF t_sflight OCCURS 0.
            INCLUDE STRUCTURE sflight.
    DATA END   OF t_sflight.
    * Internal table for holding the horizontal key.
    DATA BEGIN OF  t_hkey OCCURS 0.
            INCLUDE STRUCTURE gxxlt_h.
    DATA END   OF t_hkey .
    * Internal table for holding the vertical key.
    DATA BEGIN OF t_vkey OCCURS 0.
            INCLUDE STRUCTURE gxxlt_v.
    DATA END   OF t_vkey .
    * Internal table for holding the online text....
    DATA BEGIN OF t_online OCCURS 0.
            INCLUDE STRUCTURE gxxlt_o.
    DATA END   OF t_online.
    * Internal table to hold print text.............
    DATA BEGIN OF t_print OCCURS 0.
            INCLUDE STRUCTURE gxxlt_p.
    DATA END   OF t_print.
    * Internal table to hold SEMA data..............
    DATA BEGIN OF t_sema OCCURS 0.
            INCLUDE STRUCTURE gxxlt_s.
    DATA END   OF t_sema.
    * Retreiving data from sflight.
    SELECT * FROM sflight
             INTO TABLE t_sflight.
    * Text which will be displayed online is declared here....
    t_online-line_no    = '1'.
    t_online-info_name  = 'Created by'.
    t_online-info_value = 'SURESH KUMAR PARVATHANENI'.
    APPEND t_online.
    * Text which will be printed out..........................
    t_print-hf     = 'H'.
    t_print-lcr    = 'L'.
    t_print-line_no = '1'.
    t_print-text   = 'This is the header'.
    APPEND t_print.
    t_print-hf     = 'F'.
    t_print-lcr    = 'C'.
    t_print-line_no = '1'.
    t_print-text   = 'This is the footer'.
    APPEND t_print.
    * Defining the vertical key columns.......
    t_vkey-col_no   = '1'.
    t_vkey-col_name = 'MANDT'.
    APPEND t_vkey.
    t_vkey-col_no   = '2'.
    t_vkey-col_name = 'CARRID'.
    APPEND t_vkey.
    t_vkey-col_no   = '3'.
    t_vkey-col_name = 'CONNID'.
    APPEND t_vkey.
    t_vkey-col_no   = '4'.
    t_vkey-col_name = 'FLDATE'.
    APPEND t_vkey.
    * Header text for the data columns................
    t_hkey-row_no = '1'.
    t_hkey-col_no = 1.
    t_hkey-col_name = 'PRICE'.
    APPEND t_hkey.
    t_hkey-col_no = 2.
    t_hkey-col_name = 'CURRENCY'.
    APPEND t_hkey.
    t_hkey-col_no = 3.
    t_hkey-col_name = 'PLANETYPE'.
    APPEND t_hkey.
    t_hkey-col_no = 4.
    t_hkey-col_name = 'SEATSMAX'.
    APPEND t_hkey.
    t_hkey-col_no = 5.
    t_hkey-col_name = 'SEATSOCC'.
    APPEND t_hkey.
    t_hkey-col_no = 6.
    t_hkey-col_name = 'PAYMENTSUM'.
    APPEND t_hkey.
    * populating the SEMA data..........................
    t_sema-col_no  = 1.
    t_sema-col_typ = 'STR'.
    t_sema-col_ops = 'DFT'.
    APPEND t_sema.
    t_sema-col_no = 2.
    APPEND t_sema.
    t_sema-col_no = 3.
    APPEND t_sema.
    t_sema-col_no = 4.
    APPEND t_sema.
    t_sema-col_no = 5.
    APPEND t_sema.
    t_sema-col_no = 6.
    APPEND t_sema.
    t_sema-col_no = 7.
    APPEND t_sema.
    t_sema-col_no = 8.
    APPEND t_sema.
    t_sema-col_no = 9.
    APPEND t_sema.
    t_sema-col_no = 10.
    t_sema-col_typ = 'NUM'.
    t_sema-col_ops = 'ADD'.
    APPEND t_sema.
    CALL FUNCTION 'XXL_FULL_API'
      EXPORTING
    *   DATA_ENDING_AT          = 54
    *   DATA_STARTING_AT        = 5
       filename                = 'TESTFILE'
       header_1                = header1
       header_2                = header2
       no_dialog               = 'X'
       no_start                = ' '
        n_att_cols              = 6
        n_hrz_keys              = 1
        n_vrt_keys              = 4
       sema_type               = 'X'
    *   SO_TITLE                = ' '
      TABLES
        data                    = t_sflight
        hkey                    = t_hkey
        online_text             = t_online
        print_text              = t_print
        sema                    = t_sema
        vkey                    = t_vkey
    EXCEPTIONS
       cancelled_by_user       = 1
       data_too_big            = 2
       dim_mismatch_data       = 3
       dim_mismatch_sema       = 4
       dim_mismatch_vkey       = 5
       error_in_hkey           = 6
       error_in_sema           = 7
       file_open_error         = 8
       file_write_error        = 9
       inv_data_range          = 10
       inv_winsys              = 11
       inv_xxl                 = 12
       OTHERS                  = 13
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

  • Deletion and creation of Schedule line for Line Item

    Hi BW Experts,
    In P.S.A. when i have checked for first schedule line 001 reqdelqty is 50 , after deleting 001 and after creation of second schedule line in R/3 there are two records transferred from R/3 for schedule line 002 first with reversal indicator 'X' and delivery quantity -50 and next record with Reversal Indicator blank with value 50. which in turn results Reqdelqty zero.
    Reason of wrong data in BW: -
    Schedule line category for an item is being deleted forcefully. R3 doesn’t allow deletion of a schedule line category if delivery is already created. Here user is creating one same schedule line and then he deletes the order quantity from earlier one. This forces system to pick up schedule line 2 in the document flow
    · User shouldn’t delete schedule line.

    Hello Ganesh,
    Schedule line number sequence will not be in control of the user.
    once delivery for a schedule line is completed, no way you can delete the schedule line (except renumbering case). This is general SAP logic relates to schedule lines.
    Let me know how they are deleting the schedule lines even though delivery is completed.
    Now coming to Data load problem in BI.
    When you delete schedule line 001, the generated record should be with schedule line 001 with Reversal Indicator as R and delivery quantity -50.
    And for new schedule line 002, reversal indicator as blank and delivery quantity 50
    Regards,
    Nandakumar.A

  • Deletion and creation of SNP Planned order

    Hi,
    I need to delete the SNP Planned order i.e ATP category of type 'EE' and I have to create the orders of ATP category EE  through programetically. Please let me know if any BAPI's or Function modules are existed for the same.
    Appriciate your help.
    Regards,
    Ratna

    Hi Ratna.
    To delete orders in SNP use transaction:
    /SAPAPO/RLCDEL
    BAPI to create planned orders:
    BAPI_MOSRVAPS_SAVEMULTI3
    There is also a BAPI to delete planned orders if this is more suitable.
    BAPI_MOSRVAPS_DELEMULTI
    Hope this helps, M

  • Deletion and Creation of storage location.

    Dear Experts,
    Plz advise how can we un-assign any storage location from any material & how can we create the new storage location.
    Regards
    Sumit Kalyan

    Hi Sumit,
    System will  allow the stock posting to storage location for which u have set Deletion until it has been achieved.
    You can block the storage location of a material without affecting the rest of the location using the same material.
        1.Create a Physical Inventory document for the storage location with transaction MI01  by  Selecting  the Posting Block checkbox.
        This would prevent transactions from occuring until you either post or delete the physical inventory document.
    or
    2. U can create &  delete the stoarge loaction at OX09.  This will affect the all the material which has assigned to same storage lacation. Normally MM will do this,
    Regards
    Pradeep

  • Modify excel sheet from BDN/GOS and add to sales order

    Hello,
    Iu2019ve import a excel-template in OAOR (BDN) and now i want to modify the excel-sheet with my own data.
    After then I want to put it to a Sales Order (BUS2032).
    The excel sheet must indicated in the attachment list of VA02 (GOS).
    Which method I must use to copy a existing excel sheet from BDN?
    How can i modify my excel sheet from BDS and add to a existing sales order?
    Can I set the document write protected?
    Can anyone help me or have any examplesu2026
    Thanks in advance
    Edited by: Thomas Druetschel on Dec 2, 2008 3:20 PM

    Hello,
    now i can get a template from BDN and modify the excel sheet. But i want to modify the excel spreadsheet in BACKGROUND ==> have anybody a idea?
    And i need the correct method to save the modified document to BDS...
    Thanks
    i use the following code:
    TYPE-POOLS: sbdst.
    DATA go_control TYPE REF TO i_oi_container_control.
    DATA go_docking_container TYPE REF TO cl_gui_docking_container.
    DATA go_document_proxy TYPE REF TO i_oi_document_proxy.
    DATA go_excel_iface TYPE REF TO i_oi_spreadsheet.
    DATA go_error TYPE REF TO i_oi_error.
    DATA gc_exceltype TYPE soi_document_type VALUE soi_doctype_excel_sheet.
    DATA gv_retcode TYPE soi_ret_string.
    DATA gv_sheetname TYPE soi_string.
    DATA gv_inplace TYPE c.
    DATA: gv_value TYPE string.
    START-OF-SELECTION.
      PERFORM open_excel_doc_from_bds
                  USING
                      'BUS2032'
                      'BO'
                      '0010163117'
      PERFORM fill_cell
                  USING
                      'TEST123'
                      '1'
                      '2'.
    ==>> Now i want to SAVE the modified Excel Spreadshet to another Sales Order...
    *&      Form  init_excel_proxy
          text
         -->UV_INPLACE text
    FORM init_excel_proxy USING uv_inplace TYPE c.
      DATA lv_repid TYPE sy-repid.
      DATA lv_dynnr TYPE sy-dynnr.
      DATA lv_str   TYPE soi_string.
      lv_repid = sy-repid.
      lv_dynnr = sy-dynnr.
      CALL METHOD c_oi_container_control_creator=>get_container_control
        IMPORTING
          control = go_control
          error   = go_error.
      CREATE OBJECT go_docking_container
        EXPORTING
          repid     = lv_repid
          dynnr     = lv_dynnr
          side      = cl_gui_docking_container=>dock_at_bottom
          extension = 0.
    I don´t want to modify the document in the front*
      CALL METHOD go_control->init_control
        EXPORTING
          r3_application_name = ' '
          inplace_enabled     = uv_inplace
          parent              = go_docking_container
        IMPORTING
          error               = go_error.
      CALL METHOD go_control->get_document_proxy
        EXPORTING
          document_type  = gc_exceltype
        IMPORTING
          document_proxy = go_document_proxy.
    ENDFORM.                    " init_excel_iface
    *&      Form  open_excel_doc_from_bds
          text
         -->UV_CLASSNAME  text
         -->UV_CLASSTYPE  text
         -->UV_OBJECTKEY  text
         -->UV_INPLACE    text
    FORM open_excel_doc_from_bds USING uv_classname TYPE sbdst_classname
                                       uv_classtype TYPE sbdst_classtype
                                       uv_objectkey TYPE sbdst_object_key
                                       uv_inplace TYPE c.
      DATA lt_doc_uris TYPE sbdst_uri.
      DATA ls_doc_uri LIKE LINE OF lt_doc_uris.
      DATA lt_doc_signature TYPE sbdst_signature.
      DATA lv_doc_url TYPE bapiuri-uri.
      DATA lv_repid TYPE sy-repid.
      DATA lv_dynnr TYPE sy-dynnr.
      IF go_document_proxy IS INITIAL.
        PERFORM init_excel_proxy USING uv_inplace.
      ENDIF.
      CHECK NOT go_document_proxy IS INITIAL.
      CALL METHOD cl_bds_document_set=>get_with_url
        EXPORTING
          classname       = uv_classname
          classtype       = uv_classtype
          object_key      = uv_objectkey
        CHANGING
          uris            = lt_doc_uris[]
          signature       = lt_doc_signature[]
        EXCEPTIONS
          nothing_found   = 1
          error_kpro      = 2
          internal_error  = 3
          parameter_error = 4
          not_authorized  = 5
          not_allowed     = 6.
      IF sy-subrc NE 0 .
        MESSAGE 'cl_bds_document_set=>get_with_url error' TYPE 'I'.
        EXIT.
      ENDIF.
      READ TABLE lt_doc_uris INTO ls_doc_uri INDEX 1.
      lv_doc_url = ls_doc_uri-uri.
      CALL METHOD go_document_proxy->open_document
        EXPORTING
          document_url  = lv_doc_url
          open_inplace  = uv_inplace
          open_readonly = ''
        IMPORTING
          error         = go_error.
      IF NOT go_excel_iface IS INITIAL.
        FREE go_excel_iface.
      ENDIF.
      CALL METHOD go_document_proxy->get_spreadsheet_interface
        EXPORTING
          no_flush        = 'X'
        IMPORTING
          sheet_interface = go_excel_iface
          error           = go_error.
    ENDFORM.                    "open_excel_doc_from_bds
    *&      Form  fill_cell
          text
         -->UV_VALUE   text
         -->UV_COLUMN  text
         -->UV_ROW     text
    FORM fill_cell USING uv_value TYPE string
                         uv_column TYPE i
                         uv_row TYPE i.
      CHECK NOT go_document_proxy IS INITIAL.
      CHECK NOT go_excel_iface IS INITIAL.
      DATA: lt_ranges TYPE soi_range_list,
            lt_contents TYPE soi_generic_table,
            ls_contents LIKE LINE OF lt_contents[],
            lt_rangesdef TYPE soi_dimension_table,
            ls_rangesdef LIKE LINE OF lt_rangesdef.
      ls_rangesdef-row = uv_row.
      ls_rangesdef-column = uv_column.
      ls_rangesdef-rows = 1.
      ls_rangesdef-columns = 1.
      APPEND ls_rangesdef TO lt_rangesdef.
      ls_contents-row = 1.
      ls_contents-column = 1.
      ls_contents-value = uv_value.
      APPEND ls_contents TO lt_contents.
      CALL METHOD go_excel_iface->set_ranges_data
        EXPORTING
          ranges    = lt_ranges[]
          contents  = lt_contents[]
          rangesdef = lt_rangesdef[]
          no_flush  = 'X'
        IMPORTING
          error     = go_error.
    ENDFORM.                    "fill_cell
    *&      Form  get_cell
          text
         -->UV_COLUMN  text
         -->UV_ROW     text
         -->CV_VALUE   text
    FORM get_cell USING  uv_column TYPE i
                         uv_row TYPE i
                  CHANGING cv_value.
      DATA: lt_ranges TYPE soi_range_list,
          lt_contents TYPE soi_generic_table,
          ls_contents LIKE LINE OF lt_contents[],
          lt_rangesdef TYPE soi_dimension_table,
          ls_rangesdef LIKE LINE OF lt_rangesdef.
      ls_rangesdef-row = uv_row.
      ls_rangesdef-column = uv_column .
      ls_rangesdef-rows = 1.
      ls_rangesdef-columns = 1.
      APPEND ls_rangesdef TO lt_rangesdef.
      CALL METHOD go_excel_iface->get_ranges_data
        EXPORTING
          rangesdef = lt_rangesdef[]
        IMPORTING
          contents  = lt_contents[]
          error     = go_error
        CHANGING
          ranges    = lt_ranges[].
      cv_value = space.
      READ TABLE lt_contents INTO ls_contents INDEX 1.
      IF sy-subrc = 0.
        cv_value = ls_contents-value.
      ENDIF.
    ENDFORM.                    "get_cell
    *&      Form  insert_table
          text
         -->COLUMN     text
         -->ROW        text
         -->CT_DATA    text
         -->ANY        text
    FORM insert_table USING column TYPE i
                            row TYPE i
                      CHANGING ct_data TYPE table any.
      CHECK NOT go_document_proxy IS INITIAL.
      CHECK NOT go_excel_iface IS INITIAL.
      CALL METHOD go_excel_iface->insert_range_dim
        EXPORTING
          name     = 'Table'
          top      = row
          left     = column
          rows     = 1
          columns  = 1
          no_flush = 'X'
        IMPORTING
          error    = go_error.
      DATA: lt_fields_table TYPE soi_fields_table.
      CALL FUNCTION 'DP_GET_FIELDS_FROM_TABLE'
        TABLES
          data   = ct_data[]
          fields = lt_fields_table.
      go_excel_iface->insert_one_table(
        EXPORTING
          data_table   = ct_data[]
          fields_table = lt_fields_table[]
          rangename    = 'Table'
          no_flush     = 'X'
          wholetable   = 'X'
        IMPORTING
          error        = go_error
    ENDFORM.                    "insert_table=

  • V - Lookup in Excel sheet?

    Hi ,
    How to do V-Lookup in Excel sheet.
    My requirement is: I have Partner data in one excel tab in EXCELSHEET with lagacyCustomernumber, and in same excel sheet, i have one more tab i.e Sales data with SAP custemore numbers. So now I would like to do the V-LOOKUP in partner data tab for reference of SAP customernumber in partener data.
    please help me.
    Thanks,
    Coti

    Hi,
    In excel go to 'Insert' Option and select 'Function" > Lookup & Reference> VLOOKUP
    Then you will have a pop-up asking for below mention values.
    Lookup_value  The value to search in the first column of the table array (array: Used to build single formulas that produce multiple results or that operate on a group of arguments that are arranged in rows and columns. An array range shares a common formula; an array constant is a group of constants used as an argument.). Lookup_value can be a value or a reference. If lookup_value is smaller than the smallest value in the first column of table_array, VLOOKUP returns the #N/A error value.
    Table_array  Two or more columns of data. Use a reference to a range or a range name. The values in the first column of table_array are the values searched by lookup_value. These values can be text, numbers, or logical values. Uppercase and lowercase text are equivalent.
    Col_index_num  The column number in table_array from which the matching value must be returned. A col_index_num of 1 returns the value in the first column in table_array; a col_index_num of 2 returns the value in the second column in table_array, and so on. If col_index_num is:
    Less than 1, VLOOKUP returns the #VALUE! error value.
    Greater than the number of columns in table_array, VLOOKUP returns the #REF! error value.
    Range_lookup  A logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match:
    If TRUE or omitted, an exact or approximate match is returned. If an exact match is not found, the next largest value that is less than lookup_value is returned.
    The values in the first column of table_array must be placed in ascending sort order; otherwise, VLOOKUP may not give the correct value. You can put the values in ascending order by choosing the Sort command from the Data menu and selecting Ascending. For more information, see Default sort orders.
    If FALSE, VLOOKUP will only find an exact match. In this case, the values in the first column of table_array do not need to be sorted. If there are two or more values in the first column of table_array that match the lookup_value, the first value found is used. If an exact match is not found, the error value #N/A is returned.
    Let me know if you have any problem.
    Cheers,
    Rc

Maybe you are looking for

  • How to close the browser from webdynpro application

    Hi All, I need  to implement the closing the browser where the webdynpro  application running by click on some button in that application. Can any body tell me how to implement that. Regards Vijay

  • Exchange Sync Not Working After Addition of New DC

    We have several Iphones in my business that all sync Mail/Contacts/Calanders over the air. Everything had been working fine, until I installed a new Domain Controller to the domain (details below). I am sure it is just a small issue that is being ove

  • The dropdown "Do you want Firefox to save password" used to hide and now doesn't. Why?

    The dropdown "Do you want Firefox to save password" used to hide and now doesn't. Why? == This happened == Every time Firefox opened == A few weeks ago

  • Multiple libraries/computers

    I have one library at work that is my "master". Every couple of weeks, in order to keep my home library up to date, I would copy the "itunes library" file to my work external hard drive and replace all music at my home external from that hard drive a

  • DHCP Scope vs IP Helper

    Hi @all, SCCM 2012 R2 on W2K8R2 Server with SQL 2012 SP1 included all CU's and Hotfixes. It's only for a LAB so i have installed all on one Server. Problem is now, that when i install W8.1 i need other bootfile than when i install W7 cause of EFI. Ho