FM to upload the Excel file to internal table

Hi
Is any FM available to upload the Excel file to internal table.
Thanks
Anbu

Hi
se this code
EXCEL to INTERNAL TABLE and then to APPLICATION SERVER
*& Report  ZSD_EXCEL_INT_APP
REPORT  ZSD_EXCEL_INT_APP.
parameter: file_nm type localfile.
types : begin of it_tab1,
        f1(20),
        f2(40),
        f3(20),
       end of it_tab1.
data : it_tab type table of ALSMEX_TABLINE with header line,
       file type rlgrap-filename.
data : it_tab2 type it_tab1 occurs 1,
       wa_tab2 type it_tab1,
       w_message(100)  TYPE c.
at selection-screen on value-request for file_nm.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
  PROGRAM_NAME        = SYST-REPID
  DYNPRO_NUMBER       = SYST-DYNNR
  FIELD_NAME          = ' '
   STATIC              = 'X'
  MASK                = ' '
  CHANGING
   file_name           = file_nm
EXCEPTIONS
   MASK_TOO_LONG       = 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.
start-of-selection.
refresh it_tab2[].clear wa_tab2.
file = file_nm.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    filename                      = file
    i_begin_col                   = '1'
    i_begin_row                   =  '1'
    i_end_col                     = '10'
    i_end_row                     = '35'
  tables
    intern                        = it_tab
EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3
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 it_tab.
  case it_tab-col.
   when '002'.
    wa_tab2-f1 = it_tab-value.
   when '004'.
    wa_tab2-f2 = it_tab-value.
  when '008'.
    wa_tab2-f3 = it_tab-value.
endcase.
at end of row.
  append wa_tab2 to it_tab2.
clear wa_tab2.
  endat.
endloop.
data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
*--- Display error messages if any.
  IF sy-subrc NE 0.
    MESSAGE e001(zsd_mes).
    EXIT.
  ELSE.
*---Data is downloaded to the application server file path
    LOOP AT it_tab2 INTO wa_tab2.
      TRANSFER wa_tab2 TO p_file.
    ENDLOOP.
  ENDIF.
*--Close the Application server file (Mandatory).
  CLOSE DATASET p_file.
loop at it_tab2 into wa_tab2.
  write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
endloop.

Similar Messages

  • Upload openoffice excel file into internal table

    Hi Everyone,
    I have a requirement where in we need to upload vendor master data into SAP.
    The data is available in excel format. But the excel sheet was created in openoffice s/w and client is not allowing
    us to install MS-Office so that we cut and paste the data by creating anexcel file.
    Now there is an option of saving the excel file in openoffice s/w as MS-Excel 95 format with .xls extension.
    But since we are saving this in openoffice enivoronment   the FM ALSM_EXCEL..... data is not improting this excel file into
    Did somebody faced this issue before. Pls share the approach to solve this issue.
    Regards,
    Vinay

    Hi !
    you can use the Function module TEXT_CONVERT_XLS_TO_SAP to upload xcel file to internal table
    please go through the code below.
    REPORT zupload_excel_to_itab.
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
    col1(30) TYPE c,
    col2(30) TYPE c,
    col3(30) TYPE c,
    END OF t_datatab.
    DATA: it_datatab type standard table of t_datatab,
    wa_datatab type t_datatab.
    DATA: it_raw TYPE truxs_t_text_data.
    At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    field_name = 'P_FILE'
    IMPORTING
    file_name = p_file.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    I_FIELD_SEPERATOR =
    i_line_header = 'X'
    i_tab_raw_data = it_raw " WORK TABLE
    i_filename = p_file
    TABLES
    i_tab_converted_data = it_datatab[] "ACTUAL DATA
    EXCEPTIONS
    conversion_failed = 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.
    END-OF-SELECTION.
    END-OF-SELECTION.
    LOOP AT it_datatab INTO wa_datatab.
    WRITE:/ wa_datatab-col1,
    wa_datatab-col2,
    wa_datatab-col3.
    ENDLOOP.
    hope this will help you.
    Regards,
    Kiran

  • Uploading excel file into internal table

    Hi,
    Any function module is there to upload an excel file into internal table in CRM 7.0 system?
    Thanks.

    Hi Ginger,
    If u have access to ECC R/3 make use FM 'TEXT_CONVERT_XLS_TO_SAP' source code which is existing to convert to Excel to Internal table.  It will work in CRM also.
    As of Now I don't have access to SAP S/m. Mean while u can try as above said.
    Regards,
    Lokesh B

  • FROM EXCEL FILE TO INTERNAL TABLE

    HI GURU'S,
    i'm using the following code to conver the excel file into internal table.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
         I_FIELD_SEPERATOR          = 'X'
        I_LINE_HEADER              =
          I_TAB_RAW_DATA             = IT_TAB_RAW_DATA
          I_FILENAME                 = P_FILE
        TABLES
          I_TAB_CONVERTED_DATA       = IT_MM01
       EXCEPTIONS
         CONVERSION_FAILED          = 1
         OTHERS                     = 2
    What is the exact format for the to send the Excel File.
    My requirement is the Excel file contains the several fields , that should be stored as a records in the internal table
    My problem is when i send the data in the excel file as one column, i'm getting all the data in the first column of the Internal Table.
    If i send the data in the excel file as a record it is not filling the internal table.
    what is the problem??/
    if the Excel files contain multiple records is it able to convert the data into internal table records.
    Regards,
    Adi.

    **Internal Table to hold the records in the text file
    Hello Adi,
    Put the fields in excel in the same format in which u want in ur internal table(here record)
    U can refer the following code.
    data: begin of record occurs 0,
          General Data
    data element: BUKRS
            bukrs_001(004), " Company Code
    data element: EKORG
            ekorg_002(004), " Purchase Orgn
    data element: KTOKK
            ktokk_003(004), " Account Group
        end of record.
    Internal Table
    data:it_excel like table of alsmex_tabline with header line.
    **SELECTION-SCREEN**
    selection-screen begin of  block blk.
    parameters: p_file like rlgrap-filename default 'c:\vendor_creation.xls'
    selection-screen end of block blk.
    A T   S E L E C T I O N - S C R E E N   O U T P U T
    ***************START*********************** F4 Help for field p_file
    at selection-screen on value-request for p_file.
    call function 'KD_GET_FILENAME_ON_F4'
    exporting
       program_name        = syst-repid
       dynpro_number       = syst-dynnr
      FIELD_NAME          = ' '
      STATIC              = ' '
      MASK                = ' '
      changing
        file_name           = p_file
    EXCEPTIONS
      MASK_TOO_LONG       = 1
      OTHERS              = 2
    if sy-subrc <>  0.
    message e006(zhnc).
    endif.
    S T A R T - O F - S E L E C T I O N
    start-of-selection.
    data : vf_index type i.
    data : vf_start_col type i value '1',      "start column
             vf_start_row type i value '4',    "start row
             vf_end_col   type i value '200',  "maximum column
             vf_end_row   type i value '2500', "maximum row
             p_text(20).                       "stores error messages
    */ Work Area
    data: wa_intern like it_excel.
    */ Field symbol
    field-symbols : <fs>.
    *********Fn Module to convert the excel file data into internal table
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                      =  'c:\vendor_creation.xls'
        i_begin_col                   =  vf_start_col
        i_begin_row                   =  vf_start_row
        i_end_col                     =  vf_end_col
        i_end_row                     =  vf_end_row
      tables
        intern                        = it_excel
    exceptions
       inconsistent_parameters       = 1
       upload_ole                    = 2
       others                        = 3.
    if sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
      if it_excel[] is initial.
        p_text = 'No Data Uploaded'.
      else.
      sort it_excel by row col.
          loop at it_excel.
          move : it_excel-col to vf_index.
          assign component vf_index of structure record to <fs>.
          move : it_excel-value to <fs>.
          at end of row.
            append record.
            clear record.
          endat.
          endloop.
      endif.
    In case of any problem u  can revert back.
    Aastha

  • Upload excel file to internal table in web dynpro program

    Hi friend's
    In web dynpro program how to upload excel file into  internal table and finally data will be save Y table.

    hi,
    See the properties of File Upload UI element..
    Link: [http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/732f0510d83ff6e10000000a42189c/frameset.htm]
    Goto References -> User Interface Elements -> Integration Category -> File upload..
    After creating the 'FILE UPLOAD' element in a view.. Bind a datasource(a context attribute with STRING) with the data property..
    Double click on ONACTION_UPLOAD method. Write a code as given below.
    METHOD onactionon_upload .
    TYPES :   BEGIN OF str_itab,
           name(10) TYPE c,
           age(10) TYPE c,
           END OF str_itab.  DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
             i_data TYPE STANDARD TABLE OF string,
             l_string TYPE string,
             fs_table TYPE str_itab,
             l_xstring TYPE xstring,
             fields TYPE string_table,
             lv_field TYPE string.
    DATA : t_table TYPE if_main=>elements_data_tab,
             data_table TYPE if_main=>elements_data_tab.
    * get single attribute 
    wd_context->get_attribute(  
    EXPORTING    
    name =  `DATASOURCE`  
    IMPORTING    
    value = l_xstring ).
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          in_xstring = l_xstring
        IMPORTING
          out_string = l_string. 
    SPLIT l_string  AT cl_abap_char_utilities=>newline INTO TABLE i_data.
    * Bind With table Element.
    LOOP AT i_data INTO l_string.
        SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields.
       READ TABLE fields INTO lv_field INDEX 1.
        fs_table-name = lv_field.  
    READ TABLE fields INTO lv_field INDEX 2.
        fs_table-age = lv_field.   
    APPEND fs_table TO t_table1.     "Append to  the internal  table
      ENDLOOP.
    Edited by: Rameshkumar Raamasamy on Feb 9, 2010 9:39 AM

  • Uploading excell file to internal table

    HI every body,
           Here I am uploading the excel file into the internal table but it is uploading special
      charecters  ÐÏ#ࡱ#á##    like this  , what i have to do?
    my code is
    PARAMETERS:  fn LIKE rlgrap-filename OBLIGATORY.
    DATA: FN1 TYPE STRING,
         l .
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR fn. "p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                field_name = 'FN'
           IMPORTING
                file_name  = fn.
       START-OF-SELECTION.
      FN1 = FN.
      PERFORM upload.
       FORM upload.
      CALL function 'GUI_UPLOAD'
      exporting
        filename                      = FN1
       FILETYPE                      = 'DAT'
      tables
        data_tab                      = ITAB.

    Hi Srinivasa ,
    Here is the solution with other FM . Its working fine with my application and also easy to use!
    REPORT  ztest_upload       .
    TYPE-POOLS : truxs.
    DATA : BEGIN OF i_data OCCURS 0,
              auart(4) TYPE c,
              vbeln(10) TYPE n,
              plant(4) TYPE c,
              item_no(6) TYPE c,
              qty TYPE p,
              uom_qty(3) TYPE c,
              value1 TYPE p DECIMALS 2,
              value2 TYPE p DECIMALS 2,
              text(20) TYPE c,
            END OF i_data.
    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_fname LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN: END OF BLOCK b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          program_name = sy-repid
          static       = 'X'
        CHANGING
          file_name    = p_fname.
    START-OF-SELECTION.
      PERFORM get_excel_data.
    *&      Form  get_excel_data
          text
    -->  p1        text
    <--  p2        text
    FORM get_excel_data .
    <b>
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
          EXPORTING
        I_FIELD_SEPERATOR        =
            i_line_header            =  'X'
            i_tab_raw_data           =  it_raw       " WORK TABLE
            i_filename               =  p_fname
          TABLES
            i_tab_converted_data     = i_data[]    "ACTUAL DATA
         EXCEPTIONS
            conversion_failed        = 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.</b>
    ENDFORM.                    " get_excel_data
    After That You can Use i_data internal table directly , you can loop on that and extract the data.
    It uploads the data same as in the excel format.
    Reward with points if usefull.
    Thanks & Regards,

  • Upload the excel file in oracle db through oracle forms

    Hi all,
    I want to upload the excel file in oracle db through oracle forms...I am new to oracle forms .
    I have searched a lot but not getting exact solution
    Is there anyone who will help me out with this .....
    Any help will be appriciated

    I'm trying to move data from excel into an Oracle forms field. This involves coping 2 columns of data cells in excel and pasting it into an Oracle forms field. I can get the date pasted into the Oracle forms field but there is a invisible character that separates the 2 columns of data coming from Excel. I do not know what this character is but it is causing the error 'Line 1 is invalid. Check forms'.
    Any ideas how to get pass this?
    Thank you

  • Need to upload the excel file having extension .XLSX

    Hello,
    I am not able to upload the excel file having extension .XLSX But i can upload the excel file having extension .XLS .
    Please Guide me what are the changes i need to do... for uploading the excel file".XLSX".
    Thanks.

    Hi,
    What issue you are facing? Refer this document:  Upload/Read .xlsx file in SAP Web Dynpro . You need to on Netweaver 712 to use the classes mentioned in this document.
    Regards,
    Kiran

  • Uploading the EXCEL file  in transaction QM02

    Hi SAP  Gurus,
    I am uploading the EXCEL file  in transaction QM02 >services for object >Create attachment. But after uploading it I am not able to find where it is stored
    Best Regards,
    Parag Save.

    hi
    kindly refer [HERE |http://help.sap.com/erp2005_ehp_04/helpdata/EN/be/3fe63659241157e10000009b38f889/frameset.htm] for more details
    regards
    thyagarajan

  • Excel file to internal table gui_upload

    Hi every 1,
    I want to upload excel file to internal table through GUI_UPLOAD FM,
    Will you please help me out.
    Regards,

    You might want to try the following function module.  This progam uploads an excel file to a dynamic internal table.
    report zrich_0002.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: it_fldcat type lvc_t_fcat,
          wa_it_fldcat type lvc_s_fcat.
    type-pools : abap.
    data: new_table type ref to data,
          new_line  type ref to data.
    data: xcel type table of alsmex_tabline with header line.
    selection-screen begin of block b1 with frame title text .
    parameters: p_file type  rlgrap-filename default 'c:Test.csv'.
    parameters: p_flds type i.
    selection-screen end of block b1.
    start-of-selection.
    * Add X number of fields to the dynamic itab cataelog
      do p_flds times.
        clear wa_it_fldcat.
        wa_it_fldcat-fieldname = sy-index.
        wa_it_fldcat-datatype = 'C'.
        wa_it_fldcat-inttype = 'C'.
        wa_it_fldcat-intlen = 10.
        append wa_it_fldcat to it_fldcat .
      enddo.
    * Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = it_fldcat
                   importing
                      ep_table        = new_table.
      assign new_table->* to <dyn_table>.
    * Create dynamic work area and assign to FS
      create data new_line like line of <dyn_table>.
      assign new_line->* to <dyn_wa>.
    * Upload the excel
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           exporting
                filename                = p_file
                i_begin_col             = '1'
                i_begin_row             = '1'
                i_end_col               = '200'
                i_end_row               = '5000'
           tables
                intern                  = xcel
           exceptions
                inconsistent_parameters = 1
                upload_ole              = 2
                others                  = 3.
    * Reformt to dynamic internal table
      loop at xcel.
        assign component xcel-col of structure <dyn_wa> to <dyn_field>.
        if sy-subrc = 0.
         <dyn_field> = xcel-value.
        endif.
        at end of row.
          append <dyn_wa> to <dyn_table>.
          clear <dyn_wa>.
        endat.
      endloop.
    * Write out data from table.
      loop at <dyn_table> into <dyn_wa>.
        do.
          assign component  sy-index  of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <dyn_field>.
          else.
            write: <dyn_field>.
          endif.
        enddo.
      endloop.
    Regards,
    Rich Heilman

  • Help with uploading an excel file to a table using an application

    Hello,
    Can anyone please help me out with this issue. I have apex application where in the end users upload an excel file to a table. For this I have followed the solution provided in this link
    http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
    Using the above solution, I was able to upload the excel data to a table "sample_tbl1" successfully with fields Id,acct_no,owner_name,process_dt. But the thing is I want accomdate a particular condition while uploading the file data, to check see if the acct_no already exists in another table say "sample_tbl2" or not. If acct_nos already exists in sample_tbl2 then give out an error displaying the list of account numbers that already exists in the database. Below is the code which I am using to upload file data to a table.
    DECLARE
    v_blob_data       BLOB; 
    v_blob_len        NUMBER; 
    v_position        NUMBER; 
    v_raw_chunk       RAW(10000); 
    v_char            CHAR(1); 
    c_chunk_len       number       := 1; 
    v_line            VARCHAR2 (32767)        := NULL; 
    v_data_array      wwv_flow_global.vc_arr2; 
    v_rows            number; 
    v_sr_no           number         := 1; 
    l_cnt             BINARY_INTEGER := 0;
    l_stepid          NUMBER := 10;
    BEGIN
    --Read data from wwv_flow_files</span> 
    select blob_content into v_blob_data 
    from wwv_flow_files 
    where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER) 
    and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER); 
    v_blob_len := dbms_lob.getlength(v_blob_data); 
    v_position := 1; 
    /* Evaluate and skip first line of data
    WHILE (v_position <= v_blob_len ) LOOP
    v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position);
    v_char :=  chr(hex_to_decimal(rawtohex(v_raw_chunk)));
    v_line := v_line || v_char;
    v_position := v_position + c_chunk_len;
    -- When a whole line is retrieved
    IF v_char = CHR(10) THEN
    -- Clear out 
    v_line := NULL;
    EXIT;
    END IF;
    END LOOP;
    -- Read and convert binary to char</span> 
    WHILE ( v_position <= v_blob_len ) LOOP 
    v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position); 
    v_char :=  chr(hex_to_decimal(rawtohex(v_raw_chunk))); 
    v_line := v_line || v_char; 
    v_position := v_position + c_chunk_len; 
    -- When a whole line is retrieved </span> 
    IF v_char = CHR(10) THEN
    -- Convert comma to : to use wwv_flow_utilities </span> 
    v_line := REPLACE (v_line, ',', ':'); 
    -- Convert each column separated by : into array of data </span> 
    v_data_array := wwv_flow_utilities.string_to_table (v_line); 
    -- Insert data into target table
    EXECUTE IMMEDIATE 'insert into sample_tbl1(ID,ACCT_NO,OWNER_NAME,PROCESS_DT) 
    values (:1,:2,:3,:4)'
    USING 
    v_sr_no, 
    v_data_array(1), 
    v_data_array(2),
    to_date(v_data_array(3),'MM/DD/YYYY');
    -- Clear out 
    v_line := NULL; 
    v_sr_no := v_sr_no + 1; 
    l_cnt := l_cnt + SQL%ROWCOUNT;
    END IF; 
    END LOOP;
    delete from wwv_flow_files
    where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER)
    and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER);
    l_stepid  := 20;
    IF l_cnt = 0 THEN
    apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold">Please select a file to upload.</span></p>' ;
    ELSE
    apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold;color:green">File uploaded and processed ' || l_cnt || ' record(s) successfully.</span></p>';
    END IF;
    l_stepid  := 30;
    EXCEPTION WHEN OTHERS THEN
    ROLLBACK;
    apex_application.g_print_success_message := apex_application.g_print_success_message || '<p><span style="font-size:14;font-weight:bold;color:red">Failed to upload the file. '||REGEXP_REPLACE(SQLERRM,'[('')(<)(>)(,)(;)(:)(")('')]{1,}', '') ||'</span></p>';
    END;
    {code}
    Can anyone please help me, how do i accomdate the condition within my existing code.
    thanks,
    Orton                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Orton,
    From your code it appears that the account No comes in the second column of the file = > v_data_array(1)
    So You can put a conditional block around the execute immediate code that inserts the records
    For instance
      SELECT count(1) INTO ln_account_no_exists from <"sample_tbl2> where account_no = v_data_array(1);
      IF (  ln_account_no_exists > 0 ) THEN
         --Account No: already exists
        <Do what you want to do here >
      ELSE
        EXECUTE IMMEDIATE ...
      END IF:
    {code}
    Inorder to handle the account no records which exists you can
      <li>Raise an exception
      <li> Write record to table or insert into collection and then use a report region in the page based on this table/collection to show error records
      <li> Append errored account No:s to the Success Message Variable programmatically(this variable is used by PLSQL process success/error message )
       {code}
        IF ( record exists)
          apex_application.g_print_success_message := apex_application.g_print_success_message||','|| v_data_array(1) ; -- Comma separated list of errored account no:s
        ELSE ...
       {code}
    Hope it helps                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Uploading Excel file to Internal Table

    Hi,
    I need to upload an excel file into my internal table. Can we use GUI_UPLOAD Function module for this purpose? if Yes What are all the parameters we need to pass?
    Can anybody give the related function modules list.
    egards,
    Sudheer

    hi,
    check this,
    *& Report  ZTESTPROG002
    REPORT  ZTESTPROG002.
    tables: mara.
    PARAMETERS: p_file LIKE rlgrap-filename default 'C:\Documents and Settings\venkatapp\Desktop\venkat.xls'.
    data:begin of it_mara occurs 0,
         matnr like mara-matnr,
         meins like mara-meins,
         mtart like mara-mtart,
         mbrsh like mara-mbrsh,
         end of it_mara.
    SELECT matnr
           meins
           mtart
           mbrsh
           FROM mara
           INTO corresponding fields of TABLE it_mara.
    CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
      EXPORTING
        i_filename     = p_file
      TABLES
        i_tab_sap_data = it_mara.
    regards,
    venkat.

  • Upload long text from excel file into internal table

    I need to upload service master(T-code : AC02) data alongwith long text.Now i have data in excel as: Service no(ASMD-ASNUM) and corresponding long text for it.
    I am facing problem in getting entire lontext from excel into my internal table.It only takes till 255 characters i think.Any help in this regard woulg be highly appreciable.

    hi,
    what is the maximum length of your long text.
    and you can try with more than 255 chars. in the internal table it will take , if you want check it.
    i'm in 4.7 ,5.0 version, what about you ..
    please check , you can upload even more than 255.
    try
    regards
    vijay

  • Uploading EXCEL file into Internal Table Using GUI_UPLOAD

    Can any one please give me an example use of FM "GUI_UPLOAD" which to upload a EXCEL file????? (not .txt)

    Use the forum search option [GUI_UPLOAD FOR EXCEL|https://forums.sdn.sap.com/search.jspa?threadID=&q=GUI_UPLOADFOREXCEL&objID=c42&dateRange=all&numResults=15&rankBy=10001]) or sdn wiki/code gallery ([UPLOAD EXCEL|https://wiki.sdn.sap.com/wiki/dosearchsite.action?searchQuery.queryString=upload+Excel&searchQuery.spaceKey=conf_global])  - Same question already answered many time
    GUI_UPLOAD doesnt perform such conversion (Excel, Word, PDF) and wont give you a suitable result, use one of the FM mentioned above or [office integration|http://help.sap.com/saphelp_47x200/helpdata/en/21/b53138e1ba11d2bdbe080009b4534c/frameset.htm] or OLE or convert your Excel sheet to a simpler format : txt, csv, xml.
    Regards,
    Raymond

  • Excel File to Internal Table

    Hi,
    I need to export the content of a excel file to an internal table.
    I looked for it and I found some samples. But they opened the excel file.
    My excel file comes from upload and I have it in a xstring variable.
    The functions for excel expect for a file name, but I have the xstring only.
    Are there functions (to export the content to an internal table) that expect a xstring as a parameter?
    Thanks a lot.
    Best Regards,
    Jorge Luiz

    hi,
    I am uploading excel file. Ensure that columns in your excel are exactly present in the internal table structure that you use.
    I am using a TabDelimeted file as input for the  below mention case .
    Declare context node FILE
    with Attributes:
    Filename type String
    MimeType type String
    FILE type xstring.
    Place 'Fileupload UI element' on you view , bind DATA property to Attribute u2018FILEu2019 created in the context node.
    Create a Button lets call UPLOAD. on its click action put the following code.
    method upload_file .
      data: s_cont type string,
            x_cont type xstring,
            convt type ref to cl_abap_conv_in_ce,
            item_file type xstringval.
      data: input_string type string,
            fields  type string_table,
            fields2  type string_table,
            tbl_fields  type string_table,
            s_table type string_table,
            ls_table like line of s_table,
            ls like line of fields,
            lv_num_cols type i.
      data: lt_data type table of ZMYREC, "here
            ls_data like line of lt_data,
            lv_data type string.
      field-symbols: <wa_table> like line of s_table.
      wd_this->m_elem_file->get_attribute(
        exporting
          name =  `FILE`
        importing
          value = item_file ).
      convt = cl_abap_conv_in_ce=>create( input = item_file ).
      convt->read( importing data = s_cont ).
      "Column headers
      split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.
      read table s_table into ls_table index 1.
      "Delete column header
      delete s_table index 1.
      split ls_table at cl_abap_char_utilities=>horizontal_tab into table fields.
      lv_num_cols = lines( fields ).
      refresh fields.
      loop at s_table assigning <wa_table>.
        split <wa_table> at cl_abap_char_utilities=>horizontal_tab into :
         ls_data-recordid
         ls_data-bstkd                                                                   
         ls_data-kunnr                                                                   
         ls_data-matnr                                                                   
         ls_data-candno                                                                  
         ls_data-fname                                                                   
         ls_data-inits                                                                   
         ls_data-lname                                                                   
         ls_data-gesch.                                                                   
         append ls_data to lt_data.
         clear ls_data.
      endloop.
    wd_this->m_node_data->bind_table(
       exporting
          new_items            = lt_data
          set_initial_elements = abap_true ).
    endmethod.
    I hope it helps.
    Thanx.

Maybe you are looking for

  • Exporting/ Sharing - Converting Numbers to HTML5?

    Is there a way - or a utility / app - to convert a numbers file to HTML5? I have a lot of numbers spreadsheets that contain popups, checkboxes, etc - and none of it will convert to Excel. I need to be able to exchange my files with other users, some

  • Multiple po's against one PR

    Hi all,         Is it possible to create more than po's for one Purchase requisition?If so,will it allow us to post GR against both PO's? Waiting for your reply regards, Mona

  • Terminal command to turn on/off iCloud syncing?

    I'm a musician using my MacBook Pro on gigs and lately I've been experiencing some glitching in my audio that I believe is related to sync services or other processes that Mavericks uses to communicate with iCloud.  Googling, I saw references to an i

  • Maintaining image quality in FrameMaker and RoboHelp

    Can someone tell me how I can maintain image quality in my Word documents in FrameMaker 11 while importing the documents into RoboHelp 10?  Basically, I will be importing Word (help) documents into FrameMaker 11 (hoping to maintain the image quality)

  • JMenu is not shown completely

    Hello. I've created an application with a JMenu. Now I have the problem that it is not shown completely. It's just shown the beginning until there's a JPanel and then the JPanel covers the JMenu. How can I change the program that the JMenu covers the