Problem in uploading excel

Hi,
I am using fm GUI_UPLOAD.
When i use a text file then the program is working fine.
But if i use an excel file for same data then the table returned by GUI_UPLOAD (T_UPLOAD)doesnt have correct entries.Instead of having the correct data, it has some symbols (ÐÏ#ࡱ#á|#################4 etc).
Please correct me where i am wrong in the approach.                                            
The code is :                               
TYPES:                                
Structure for the upload table.                            
      BEGIN OF TP_UPLOAD,                            
          STLNR  TYPE CHAR8,                                    "Bill of material                 
          MATNR  TYPE CHAR18,                                   "Material number                      
          WERKS  TYPE CHAR4,                                    "Plant
          STLTY  TYPE CHAR1,                                    "BOM category
          STLAN  TYPE CHAR1,                                    "BOM usage
          STLST  TYPE CHAR2,                                    "BOM status
          POSTP  TYPE CHAR1,                                    "Item category
          BMENG  TYPE CHAR17,                                   "Base quantity
          IDNRK  TYPE CHAR18,                                   "BOM component
          MENGE  TYPE CHAR17,                                   "Component quantity
          IDENT  TYPE CHAR8,                                    "Item ID
          DATUV  TYPE CHAR10,                                   "Valid-From Date
          LKENZ  TYPE CHAR1,                                    "Deletion indicator
      END OF TP_UPLOAD,
For uploading the file
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                = L_PATHUP                        "Long path name
      FILETYPE                = C_FILE_TYPE                     "File type ASC
      HAS_FIELD_SEPARATOR     = C_CHK
      READ_BY_LINE            = 'X'
     DAT_MODE                = 'X'
    REPLACEMENT             =
    TABLES
      DATA_TAB                = T_UPLOAD
    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.

Hi Napsterr,
try this program out might be it is usefull for you.
With Regards,
S.Saravanan (EKS).
report zsdu_flash_performance_upload
       no standard page heading line-size 255.
include bdcrecx1.
data: int type i.
data: begin of it_tab occurs 0,
      vkorg like zsd_flash_per-vkorg,
      vkbur like zsd_flash_per-vkbur,
      matnr like zsd_flash_per-matnr,
      zmonth type char6,
      zfkimg type char13,
      zkzwi1 type char13,
      matkl like zsd_flash_per-matkl,
      prodh like zsd_flash_per-prodh,
      mvgr1 like zsd_flash_per-zmvgr1,
      end of it_tab.
data: begin of it_mara occurs 0,
      matnr like mara-matnr,
      matkl like mara-matkl,
      end of it_mara.
data: begin of it_mvke occurs 0,
      matnr like mvke-matnr,
      prodh like mvke-prodh,
      mvgr1 like mvke-mvgr1,
      end of it_mvke.
data : begin of it_dummy occurs 0,
       temp(8000),
       end of it_dummy.
selection-screen : begin of block b1 with frame title text-001 .
parameters: p_flname type rlgrap-filename,
             p_down like rlgrap-filename.
selection-screen : end of block b1.
data: it_bdcdata like bdcdata occurs 0 with header line.
data: begin of t_col occurs 0,
      col like alsmex_tabline-col,
      size type i.
data: end of t_col.
data: begcol type i value 1,
      begrow type i value 1,
      endcol type i value 100,
      endrow type i value 32000.
data: zwlen type i,
      zwlines type i,
      tind(4) type n,
      zwfeld(20) type c,
      id type n,
      in type n.
data: begin of fieldnames occurs 3,
        title(60),
        table(6),
        field(10),
        kz(1),
      end of fieldnames.
BEGIN OF INSERTION OF CODE VERSION-2 SARAVANAN             DV1K908323
data: g_matnr like mara-matnr,
      g_matkl like mara-matkl,
      g_prodh like vbrp-prodh,
      g_mvgr1 like vbrp-mvgr1.
END OF INSERTION OF CODE VERSION-2 SARAVANAN               DV1K908323
types:begin of ty_file,
       value_0001(18),
       value_0002(18),
       value_0003(18),
       value_0004(18),
       value_0005(18),
       value_0006(18),
       value_0007(18),
       value_0008(18),
       value_0009(18),
end of ty_file.
data: wa_file type ty_file.
data: lcl_down type string.
data: int_table type standard table of alsmex_tabline with header line ,
      int_table1 type standard table of alsmex_tabline with header line.
field-symbols: <fs1> type any.
at selection-screen  on value-request for p_down.
  call function 'F4_FILENAME'
    importing
      file_name = p_down.
  lcl_down = p_down.
at selection-screen on value-request for p_flname.
  call function 'F4_FILENAME'
    importing
      file_name = p_flname.
  call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    exporting
      filename    = p_flname
      i_begin_col = begcol
      i_begin_row = begrow
      i_end_col   = endcol
      i_end_row   = endrow
    tables
      intern      = int_table.
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 int_table.
    int_table1 = int_table.
    clear int_table1-row.
    append int_table1.
  endloop.
  sort int_table1 by col.
  loop at int_table1.
    at new col.
      t_col-col = int_table1-col.
      append t_col.
    endat.
    zwlen = strlen( int_table1-value ).
    read table t_col with key col = int_table1-col.
    if sy-subrc eq 0.
      if zwlen > t_col-size.
        t_col-size = zwlen.
        modify t_col index sy-tabix.
      endif.
    endif.
  endloop.
  describe table t_col lines zwlines.
  sort int_table by row col.
  do zwlines times.
    write sy-index to fieldnames-title.
    append fieldnames.
  enddo.
  sort int_table by row col.
  loop at int_table.
    tind = int_table-col.
    concatenate 'wa_FILE-VALUE_' tind into zwfeld.
    assign (zwfeld) to <fs1>.
    <fs1> = int_table-value.
    at end of row.
      condense wa_file-value_0001 no-gaps.
      condense wa_file-value_0002 no-gaps.
      condense wa_file-value_0003 no-gaps.
      condense wa_file-value_0004 no-gaps.
      condense wa_file-value_0005 no-gaps.
      condense wa_file-value_0006 no-gaps.
      condense wa_file-value_0007 no-gaps.
      condense wa_file-value_0008 no-gaps.
      condense wa_file-value_0009 no-gaps.
      concatenate wa_file-value_0001
                  wa_file-value_0002
                  wa_file-value_0003
                  wa_file-value_0004
                  wa_file-value_0005
                  wa_file-value_0006
                  wa_file-value_0007
                  wa_file-value_0008
                  wa_file-value_0009
                  into it_dummy-temp separated by space.
      append it_dummy.
      clear: it_dummy, wa_file-value_0001, wa_file-value_0002, wa_file-value_0003,wa_file-value_0004,wa_file-value_0005.
    endat.
  endloop.
start-of-selection.
  loop at it_dummy.
      split it_dummy-temp at ' ' into   it_tab-vkorg
                                        it_tab-vkbur
                                        it_tab-matnr
                                        it_tab-zmonth
                                        it_tab-zfkimg
                                        it_tab-zkzwi1.
int = strlen( it_tab-matnr ).
case int.
when '5'.
concatenate '0000000000000' it_tab-matnr into it_tab-matnr.
when '6'.
concatenate '000000000000' it_tab-matnr into it_tab-matnr.
when '7'.
concatenate '00000000000' it_tab-matnr into it_tab-matnr.
when '8'.
concatenate '0000000000' it_tab-matnr into it_tab-matnr.
when '9'.
concatenate '000000000' it_tab-matnr into it_tab-matnr.
when '10'.
concatenate '00000000' it_tab-matnr into it_tab-matnr.
when '11'.
concatenate '0000000' it_tab-matnr into it_tab-matnr.
when '12'.
concatenate '000000' it_tab-matnr into it_tab-matnr.
when '13'.
concatenate '00000' it_tab-matnr into it_tab-matnr.
when '14'.
concatenate '0000' it_tab-matnr into it_tab-matnr.
when '15'.
concatenate '000' it_tab-matnr into it_tab-matnr.
when '16'.
concatenate '00' it_tab-matnr into it_tab-matnr.
when '17'.
concatenate '0' it_tab-matnr into it_tab-matnr.
endcase.
clear int.
int = strlen( it_tab-zmonth ).
case int.
when '5'.
concatenate '0' it_tab-zmonth into it_tab-zmonth.
endcase.
BEGIN OF INSERTION OF CODE VERSION-2 SARAVANAN             DV1K908323
  select single matkl from mara into g_matkl where matnr eq it_tab-matnr.
  it_tab-matkl = g_matkl.
  select single prodh mvgr1 from mvke into (g_prodh,g_mvgr1) where matnr eq it_tab-matnr.
  it_tab-prodh = g_prodh.
  it_tab-mvgr1 = g_mvgr1.
END OF INSERTION OF CODE VERSION-2 SARAVANAN               DV1K908323
      append it_tab.
      clear it_tab.
BEGIN OF INSERTION OF CODE VERSION-2 SARAVANAN             DV1K908323
  clear: g_matkl,
         g_prodh,
         g_mvgr1.
END OF INSERTION OF CODE VERSION-2 SARAVANAN               DV1K908323
  endloop.
  sort it_tab by matnr.
BEGIN OF COMMENT OF CODE VERSION-2 SARAVANAN             DV1K908323
select matnr
        matkl
        from mara into corresponding fields of table it_mara
        FOR ALL ENTRIES IN IT_TAB
        where matnr eq it_tab-matnr.
select  matnr
         prodh
         mvgr1
        from mvke into corresponding fields of table it_mvke
        for all entries in it_mara
        where matnr eq it_mara-matnr.
loop at it_tab.
read table it_mara with key matnr = it_tab-matnr.
if sy-subrc eq 0.
it_tab-matkl = it_mara-matkl.
endif.
read table it_mvke with key matnr = it_tab-matnr.
if sy-subrc eq 0.
it_tab-prodh = it_mvke-prodh.
it_tab-mvgr1 = it_mvke-mvgr1.
endif.
modify it_tab.
endloop.
END OF COMMENT OF CODE VERSION-2   SARAVANAN             DV1K908323
perform open_group.
loop at it_tab.
perform bdc_dynpro      using 'ZSDR_FLASH_MAINTAIN_TABLES' '1000'.
perform bdc_field       using 'BDC_CURSOR'
                              'TABNAME'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ONLI'.
perform bdc_field       using 'TABNAME'
                              'ZSD_FLASH_PER'.
perform bdc_dynpro      using 'SAPLZSD_FLASH_PER' '0001'.
perform bdc_field       using 'BDC_CURSOR'
                              'ZSD_FLASH_PER-VKORG(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=AEND'.
perform bdc_dynpro      using 'SAPLZSD_FLASH_PER' '0001'.
perform bdc_field       using 'BDC_CURSOR'
                              'ZSD_FLASH_PER-VKORG(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=NEWL'.
perform bdc_dynpro      using 'SAPLZSD_FLASH_PER' '0001'.
perform bdc_field       using 'BDC_CURSOR'
                              'ZSD_FLASH_PER-ZKZWI1(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=SAVE'.
perform bdc_field       using 'ZSD_FLASH_PER-VKORG(01)' it_tab-vkorg.
                             'DOM'.
perform bdc_field       using 'ZSD_FLASH_PER-VKBUR(01)' it_tab-vkbur.
                             'TN02'.
perform bdc_field       using 'ZSD_FLASH_PER-MATNR(01)' it_tab-matnr.
                             '30303'.
perform bdc_field       using 'ZSD_FLASH_PER-MATKL(01)' it_tab-matkl.
                             'NONSTICK'.
perform bdc_field       using 'ZSD_FLASH_PER-PRODH(01)' it_tab-prodh.
                             'OMSEL'.
perform bdc_field       using 'ZSD_FLASH_PER-ZMVGR1(01)' it_tab-mvgr1.
                             'FYP'.
perform bdc_field       using 'ZSD_FLASH_PER-ZMONTH(01)' it_tab-zmonth.
                             '07.2007'.
perform bdc_field       using 'ZSD_FLASH_PER-ZFKIMG(01)' it_tab-zfkimg.
                             '20.000'.
perform bdc_field       using 'ZSD_FLASH_PER-ZKZWI1(01)' it_tab-zkzwi1.
                             '2040.00'.
perform bdc_dynpro      using 'SAPLZSD_FLASH_PER' '0001'.
perform bdc_field       using 'BDC_OKCODE'
                              '/EABR'.
perform bdc_field       using 'BDC_CURSOR'
                              'ZSD_FLASH_PER-VKORG(02)'.
perform bdc_dynpro      using 'SAPLZSD_FLASH_PER' '0001'.
perform bdc_field       using 'BDC_OKCODE'
                              '/EABR'.
perform bdc_field       using 'BDC_CURSOR'
                              'ZSD_FLASH_PER-ZKZWI1(01)'.
perform bdc_dynpro      using 'ZSDR_FLASH_MAINTAIN_TABLES' '1000'.
perform bdc_field       using 'BDC_OKCODE'
                              '/EECAN'.
perform bdc_field       using 'BDC_CURSOR'
                              'TABNAME'.
perform bdc_transaction using 'ZSD014'.
endloop.
call function 'GUI_DOWNLOAD'
  exporting
  BIN_FILESIZE                    =
    filename                        = lcl_down
    filetype                        = 'ASC'
  APPEND                          = ' '
   write_field_separator           = 'X'
  HEADER                          = '00'
  TRUNC_TRAILING_BLANKS           = ' '
  WRITE_LF                        = 'X'
  COL_SELECT                      = ' '
  COL_SELECT_MASK                 = ' '
  DAT_MODE                        = ' '
  CONFIRM_OVERWRITE               = ' '
  NO_AUTH_CHECK                   = ' '
  CODEPAGE                        = ' '
  IGNORE_CERR                     = ABAP_TRUE
  REPLACEMENT                     = '#'
  WRITE_BOM                       = ' '
  TRUNC_TRAILING_BLANKS_EOL       = 'X'
  WK1_N_FORMAT                    = ' '
  WK1_N_SIZE                      = ' '
  WK1_T_FORMAT                    = ' '
  WK1_T_SIZE                      = ' '
  WRITE_EOL                       = ABAP_TRUE
IMPORTING
  FILELENGTH                      =
  tables
    data_tab                        = it_tab
  FIELDNAMES                      =
EXCEPTIONS
  FILE_WRITE_ERROR                = 1
  NO_BATCH                        = 2
  GUI_REFUSE_FILETRANSFER         = 3
  INVALID_TYPE                    = 4
  NO_AUTHORITY                    = 5
  UNKNOWN_ERROR                   = 6
  HEADER_NOT_ALLOWED              = 7
  SEPARATOR_NOT_ALLOWED           = 8
  FILESIZE_NOT_ALLOWED            = 9
  HEADER_TOO_LONG                 = 10
  DP_ERROR_CREATE                 = 11
  DP_ERROR_SEND                   = 12
  DP_ERROR_WRITE                  = 13
  UNKNOWN_DP_ERROR                = 14
  ACCESS_DENIED                   = 15
  DP_OUT_OF_MEMORY                = 16
  DISK_FULL                       = 17
  DP_TIMEOUT                      = 18
  FILE_NOT_FOUND                  = 19
  DATAPROVIDER_EXCEPTION          = 20
  CONTROL_FLUSH_ERROR             = 21
  OTHERS                          = 22
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
perform close_group.

Similar Messages

  • Problem in Uploading Excel Data ! - Urgent

    Dear Experts,
    I am uploading excel data using FM 'TEXT_CONVERT_XLS_TO_SAP' , its directly convert data and store in internal table same as in excel sheet(row , column wise).
    But the problem is , one of the column having description more then 500 characters. so while uploding excel to itab its truncating the text and only uploding 255 characters.
    Is there any other way , so that i can upload more then 500 characters long text. Also i have tried 'ALSM_EXCEL_TO_INTERNAL_TABLE' FM , it was also not working.
    Please Help me , its Urgent.
    Points will be rewared.
    Thanks & Regards,

    Hi,
    Please use FM 'GUI_UPLOAD'.
    types: begin of ttab,
           rec(1000) type c,
           end of ttab.
    types: begin of tdat,
           fld1(10) type c,
           fld2(10) type c,
           fld3(10) type c,
           end of tdat.
    data: itab type table of ttab with header line.
    data: idat type table of tdat with header line.
    data: file_str type string.
    parameters: p_file type localfile.
    at selection-screen on value-request for p_file.
      call function 'KD_GET_FILENAME_ON_F4'
           exporting
                static    = 'X'
           changing
                file_name = p_file.
    start-of-selection.
      file_str = p_file.
      call function 'GUI_UPLOAD'
           exporting
                filename                = file_str
                filetype                = 'ASC'
           tables
                data_tab                = itab
           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.
    Best regards,
    Prashant

  • Problem in Uploading excel file using WebDynpro for Java

    Hi  All
    I have followed for Uploading excel file using WebDynpro for Java added by  Tulasi Palnati
    I done all, but I'm getting 500 Exception please contact u r system admin meag  at run time also  Jxl/Workbook class not found msag  but i downloaded Jxl.jar file and  there is no error signals  in coding part. How can I solve the Problem.
    Thanks
    Polaka

    Please ask the people in the Web Dynpro Java forum for a solution.

  • Problem to upload excel into table using sqlldr

    hi ,
    i'm using following code on 10g forms (when button pressed) to upload excel to oracle table i.e.
    --V_USERID_CS:=USER||'/'||PWD||'@'||CONNSTR ;
    V_USERID_CS:='saf_integ'||'/'||'saf_integ'||'@'||'ORCLREG'; ---connection string for AS on this machine, control files and .csv files are also on that machine--
    LOG_EVENTS('BEFORE HOST CALLING'); just to trace the message
    LOG_EVENTS('SQLLDR'||' '||RTRIM(V_USERID_CS)||' '||'control='||'c:\overtime.ctl'||' '||'log='||'C:\LOG_FILE.log'||';'); just to trace the command
    HOST('SQLLDR'||' '||RTRIM(V_USERID_CS)||' '||'control='||'c:\overtime.ctl'||' '||'log='||'C:\LOG_FILE.log'||';');
    LOG_EVENTS('AFTER HOST CALLING'); just to trace the message
    COMMIT;
    LOG_EVENTS IS PROCEDURE TO TRACE THE BUG; WHICH SHOWS THE DATA AS GIVEN BELOW:
    SYSDATE_1               ERROR_TEXT                                   ID
    5/14/2010 BEFORE HOST CALLING                                        8464274
    5/14/2010      SQLLDR saf_integ/saf_integ@ORCLREG control=c:\overtime.ctl log=C:\LOG_FILE.log;          8464275
    5/14/2010      AFTER HOST CALLING                                   8464276
    i'm not getting any error but even data is not uploaded into table.
    but when i get the same command from the log table run directly on that machine it's working fine.
    please suggest me where is the gap?
    Thanks
    kam

    i'm not getting any error but even data is not uploaded into table.
    but when i get the same command from the log table run directly on that machine it's working fine.
    please suggest me where is the gap?The SQLLDR.EXE file exists where. In the APPLICATION SERVER or in the CLIENT MACHINE. If it is in the client machine. Then you need to use CLIENT_HOST instead of HOST. CLIENT_HOST exists in webutil library.
    -Ammad

  • I have problem of uploading excel file to my internal table

    Hi,
    I trying to upload data from excel file to my internal table and when i tried to debug the program and check the data in internal table and iam gettin # in all the fields and the data in not populated in internal table , as we are using 4.0b version and we are using UPLOAD FUNCTION.
            BUKRS(4) TYPE C,     
             PONO(8) TYPE C,     
             GRNNO(8) TYPE C,   
             DELNOTE(16) TYPE C,
             RECPTDT(10) TYPE C,  
             SUPPCODE(20) TYPE C, 
              RECPT(12) TYPE C,  
              GLACCT(10) TYPE C, 
             CCTR(6) TYPE C,      
      CALL FUNCTION 'UPLOAD'
        TABLES DATA_TAB = STRU.
      IF SY-SUBRC NE 0.
        WRITE: /'Data file error'.
      ENDIF.
    i am using the same sequeuence in the above structure in excel.

    Hi KODAMANCHILI,
    Refer following link :
    http://help.sap.com/saphelp_40b/helpdata/en/fc/eb3d9d358411d1829f0000e829fbfe/frameset.htm
    This will surely solve your problem.
    Regards,
    Vivek

  • Problem in uploading excel file

    HI ,
    i need to upload a excel file, I am able to get records form excel to internal table, using ws_upload FM.
    But i m getting a # in between every fields.
    I have used split at '#' into field1 field2... but it is not working. Can anybody help me onthis.. plz..
    Kumar

    Hi I have encountered this problem too. After trying different solutions, I guess that FM 'GUI_UPLOAD' is
    not supposed to upload an excel file. So please try FM 'TEXT_CONVERT_XLS_TO_SAP' as below. It works.
    *: Description                                                :
    *: This is a simple example program to get data from an excel :
    *: file and store it in an internal table.                    :
    *: Author : www.sapdev.co.uk, based on code from Jayanta      :
    *: SAP Version : 4.7                                          :
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE  rlgrap-filename.     "To retrieve the upload file name
    TYPES: BEGIN OF t_datatab,
          col1(10)    TYPE c,
          col2(10)    TYPE c,
          col3(10)    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        =  'X'
         i_line_header            =  'X'     "To ignore the header line(the first line) if it is '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.

  • Problem while uploading excel file to server

    Hello,
    I have created an excel file using OLE and saved it to local desktop. Then I use GUI_UPLOAD to upload the excel into SAP and attach it to mail. but while using Function GUI_UPLOAD I am getting dump for CNTL_ERROR.
    If I skip the process of excel creation by OLE and passes the excel file created earlier then it gives no dump and is executed successfully.
    Kindly help on this.

    Hi Suchendar,
    Try using the FM -  F4_FILENAME to get the valid file name and use TEXT_CONVERT_XLS_TO_SAP FM to upload into SAP based on the required format.
    Regards,
    Suresh

  • Uploading Excel sheet in LSMW

    I am facing problem with uploading Excel sheet in LSMW. However, when I try to upload same data through tabulated file, its working perfectly fine.
    Please suggest the required solution.

    Thanks a lot !!! Your solution really helped. However, one correction :- When we use "No Delimiter" option.. data gets populated erroneously. I tried using "Comma Separated" and it is working.
    If there is any deviation please tell.

  • Problems in uploading from excel sheet to internal table

    hi experts,
    i got one problem regarding uploading data from excel sheet to int.table. I used FM ALSM_EXCEL_TO_INTERNAL_TABLE but in that the value is char of 50. but i need a case where i have to send value more than 50 characters. please suggest me any other FM to overcome this problem.
    advanced thanks
    vijay

    Hi,
    >
    Vijay Krishna Arvapalli wrote:
    > hi tarun,
    >
    > thank you for your reply
    >
    > but when i tried to use FM TEXT_CONVERT_XLS_TO_SAP it is giving error actually that 'Error generating the test frame'.
    >
    > so can you suggest me with some other option where i can upload the field with more than 50 character length.
    >
    > thank you
    > regards
    > vijay
    Yes, when you execute the FM from SE37, then it displays a message.
    Just copy the below code and paste it in a report (SE38) and execute.
    Create a file in C:/ with name test.xls and execute it will display the records even with more than 50 characters of length.
    I have tested and its working.
    I have taken three fields in the excel file empid, name and doj.
    TYPE-POOLS : truxs.
    PARAMETERS : p_file TYPE rlgrap-filename DEFAULT 'C:\TEST.XLS'.
    DATA : BEGIN OF itab OCCURS 0,
             empid(150) TYPE c,
             name(150) TYPE c,
             doj(150) TYPE c,
           END OF itab.
    DATA: it_raw TYPE truxs_t_text_data.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM f4_file_process USING p_file.
    AT SELECTION-SCREEN.
      PERFORM validate_file_path USING p_file.
    START-OF-SELECTION.
      PERFORM upload_data.
    END-OF-SELECTION.
      PERFORM display_data.
    *&      Form  F4_FILE_PROCESS
    *       text
    *      -->P_FILE_PATH  text
    FORM f4_file_process USING p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = 'P_FILE'
        IMPORTING
          file_name     = p_file.
      IF sy-subrc NE 0.
        MESSAGE e000(zsd).
      ENDIF.
    ENDFORM.                    " F4_FILE_PROCESS
    *&      Form  VALIDATE_FILE_PATH
    *       text
    *      -->P_FILE  text
    FORM validate_file_path USING p_file.
      DATA : lv_dir TYPE string,
             lv_file TYPE string,
             lv_result(1) TYPE c.
      DATA : lv_filename TYPE string.
      lv_filename = p_file.
      CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
        EXPORTING
          full_name     = p_file
        IMPORTING
          stripped_name = lv_file
          file_path     = lv_dir
        EXCEPTIONS
          x_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.
      CALL METHOD cl_gui_frontend_services=>directory_exist
        EXPORTING
          directory            = lv_dir
        RECEIVING
          result               = lv_result
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          wrong_parameter      = 3
          not_supported_by_gui = 4
          OTHERS               = 5.
      IF lv_result IS INITIAL.
        MESSAGE 'Invalid Directory' TYPE 'E'.
      ENDIF.
      CLEAR lv_result.
      CALL METHOD cl_gui_frontend_services=>file_exist
        EXPORTING
          file                 = lv_filename
        RECEIVING
          result               = lv_result
        EXCEPTIONS
          cntl_error           = 1
          error_no_gui         = 2
          wrong_parameter      = 3
          not_supported_by_gui = 4
          OTHERS               = 5.
      IF lv_result IS INITIAL.
        MESSAGE 'Invalid File' TYPE 'E'.
      ENDIF.
    ENDFORM.                    " VALIDATE_FILE_PATH
    *&      Form  UPLOAD_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM upload_data .
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_field_seperator    = 'X'
          i_line_header        = 'X'
          i_tab_raw_data       = it_raw
          i_filename           = p_file
        TABLES
          i_tab_converted_data = itab[]
        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.
    ENDFORM.                    " UPLOAD_DATA
    *&      Form  DISPLAY_DATA
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display_data .
      LOOP AT itab.
        WRITE : / itab-empid, itab-name, itab-doj.
      ENDLOOP.
    ENDFORM.                    " DISPLAY_DATA
    Hope this helps you.
    Regards,
    Tarun

  • SharePoint 2013 Foundation error when uploading Excel files

    Hello 
    I have a specific problem. I have an xlsx file that I cannot upload in SharePoint. Normally our SharePoint can upload Excel files and other file formats normally but this one has data with nearly 5000 rows. The size of the file is less then 500 KB. The error
    message is: "The URL is invalid. Perhaps it refers to a nonexistent file or folder, or it refers to a valid file or folder in the current Web." When I am uploading this file I am getting the same error message in every library. When I save
    the file as a 97-2003 compatible xls then it works. Sometimes even Excel files with Macros won't upload. 
    Kind regards
    ivicapro1987

    Hi,
    This issue occurs when the Version column is configured as an Indexed Column. 
    To work around this issue, remove the Version column from the list of Indexed Columns for the list that has this issue. To do this, follow these steps:
    Browse to the list where the issue exists.
    In the ribbon, click the Library tab, and then click
    Library Settings.
    In the fields list, click Indexed Columns.
    In the Indexed Columns list, click Version.
    Click Delete, and then click OK.
    Upload any files that you previously experienced the issue with.
    Reference:
    https://support.microsoft.com/kb/2796640?wa=wsignin1.0
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • How to upload excel file in Webdynpro application using ABAP

    Hi Experts,
    Am developing a webdynpro application in which it will take an excel file as input and display the contents in the form of a table in output. I am able to upload tab delimited text file and populate the table using the below code but not able to do the same with .xls file. Pls let me know if I need to use a different function module for upload excel file.
    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.
      ENDLOOP.
    lo_nd_data = wd_context->get_child_node( 'DATA_TAB' ).
    lo_nd_data->bind_table( T_TABLE1 ).
    Thanks,
    Subathra

    Dear Exports
    Can anyone guide me how to uplode the .xlsx or ..xls formatted excel file using abap webdynpro without converting it to .txt file. Because my client requirement is only to upload the excel file. because to convert the .xlsx flie to .txt file it will be time taking and cost expanssive. Another requirement is suppose today i have create a application for uploading a file which has 8 columns and 10 rows. suppose tomorrow the client will make some changes in that flat file means the client will add 2 extra columns and 10 more columns in that fil. and will upload that file. Then the new file will be display on the browser or old file. but my requirement is to display the new file in browser.
    Can anyone kindly help to solve my problem. I am completely fresher in this field and I need to do it as soon as possible. Please help to solve the problem. 
    Regards
    Rashmita

  • Error message while upload excel file (with macro) to sap (iw28)

    While upload excel file to sap through iw28, i get error message (vb)
    u2022     i have to say that the excel file contain macro , with out the macro , work fine .
    u2022     The error display just in refresh command.
    the error message :
    Public Sub ALV_CUS_Exit()
    Dim objs As ChartObjects
    Dim obj As ChartObject
    Dim sheet As Worksheet
    Dim r As Range
    For Each sheet In Sheets
    Set objs = sheet.ChartObjects
    For Each obj In objs
    Set r = Sheets("RawData").UsedRange
    obj.Chart.SetSourceData Source:=r
    Next obj
    Next sheet
    End Sub

    hi,
    This is releated to the ABAP coding...There might be some ouput problem in the Abap list viewer...Pls check it with the ABAP consultant...
    Regards
    Priyanka.P

  • Upload excel file in SAP BI-7.0

    Hi ,
    i  need to  upload an excel  file in SAP BI 7.0 where the standard r/3 fm are not available.
    Currently we uploading a file in CSV format but now we want to upload using XLS also.
    ia way to upload excel  file in SAP BI 7.0
    Best Regards,
    Sharad
    Edited by: sharad narayan on Jan 7, 2011 10:58 AM
    while searching the forum i  found the fm MS_EXCEL_OLE_STANDARD_DAT .
    but while using this FM i  am getting the exception file not exist.
    Kindlu  suggest what  to  do
    i  even tried the FM TMP_GUI_GET_FILE_EXIST' to  check  the existence of the file.
    even then same problem.
    Please suggest
    Edited by: sharad narayan on Jan 10, 2011 2:51 PM

    Hi,
    Scheduled jobs are the jobs for which we have scheduled for a time, may be daily so that each day the scheduled jobs will trigger at the time given.So that every time u need not to trigger the job manully urself as the schedule time will hit the job will trigger itself.
    Released job means the job which is in between Sheduled state and active state.say For eg: 10 jobs are Scheduled in a queue Job no 1 is released from the queue that means any moment it will be in active state.So it is the state between Schedule and Active state of a job.
    Thanks
    Varun

  • Problem in uploading multiple line items while Creating sales order by BAPI

    Hi experts ,  Im able to create sales order  with one item while using this program, but the problem is  when iam having multiple  items or multiple sales order  , iam not able to createthe line items , though its creating  sales order header , Iam copy pasting my code , please add the additional code to my code to take more than 1 line items ,This is urgent requirement . Points will be rewarded for answers , Thanks in advance
    *& Report  Z_SO_CREATE_BAPI
    REPORT  Z_SO_CREATE_BAPI.
    DATA: i_header TYPE bapisdhd1 occurs 0 with header line.
    DATA: i_details TYPE bapisditm OCCURS 0 WITH HEADER LINE.
    DATA: i_partner TYPE bapiparnr OCCURS 0 WITH HEADER LINE.
    DATA: i_return1 TYPE bapiret2 OCCURS 0 WITH HEADER LINE.
    DATA: i_return2 TYPE bapiret2.
    data : ORDER_HEADER_IN like BAPISDHD1.
    data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with HEADER LINE .
    data : ORDER_ITEMS_INX Like BAPISDITMX occurs 0 with HEADER LINE .
    data : RETURN like BAPIRET2 occurs 0 with header line.
    data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
    header line.
    DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
    LiNE.
    data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
    header line.
    data : ORDER_SCHEDULES_INX like BAPISCHDLX occurs 0 with
    header line.
    data : BEGIN OF TAB OCCURS 0,
           SRNO(4),
            DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
            SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
            DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
            DIVISION like ORDER_HEADER_IN-DIVISION,
           REQ_DATE_H(10),
           PURCH_DATE(10),
           PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
           PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
           ITM_NUMBER like BAPISDITM-ITM_NUMBER,
            MATERIAL   LIKE  ORDER_ITEMS_IN-MATERIAL ,
            PLANT LIKE ORDER_ITEMS_IN-PLANT,
           TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
           ITM_NUMBERX like  ORDER_ITEMS_INX-ITM_NUMBER ,
           MATERIALX   LIKE  ORDER_ITEMS_INX-MATERIAL ,
           CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
           PLANTX LIKE ORDER_ITEMS_INX-PLANT,
           TARGET_QTYX LIKE ORDER_ITEMS_INX-TARGET_QTY,
           ITM_NUMBER LIKE ORDER_ITEMS_IN-ITM_NUMBER,
           MATERIAL   LIKE  ORDER_ITEMS_IN-MATERIAL ,
            PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
            PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
          END OF TAB.
    DATA: v_vbeln TYPE bapivbeln-vbeln.
    selection-screen begin of block b1 with frame.
    skip 3.
    parameter:p_infile like rlgrap-filename obligatory.
    skip 3.
    selection-screen end  of block b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
      PERFORM value_help.
    start-of-selection.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                     = p_infile
       FILETYPE                      = 'DAT'
      HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      tables
        data_tab                      = tab.
    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.
    **Validation for the Create SO screen
    *AT SELECTION-SCREEN ON BLOCK na_create.
    Loop at Tab.
    i_header-doc_type =  TAB-DOC_TYPE .
    i_header-sales_org = TAB-SALES_ORG.
    i_header-distr_chan = TAB-DISTR_CHAN .
    i_header-division = TAB-DIVISION .
    append i_header.
    *endloop.
    i_partner-partn_role = TAB-PARTN_ROLE .
    i_partner-partn_numb =  TAB-PARTN_NUMB.
    APPEND i_partner.
    i_details-material =  TAB-MATERIAL .
    APPEND i_details.
    endloop.
    *Bapi for Creating SO
                   CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
                     EXPORTING
                     SALESDOCUMENTIN               = v_vbeln
                       order_header_in               = i_header
                     ORDER_HEADER_INX              =
                     SENDER                        =
                     BINARY_RELATIONSHIPTYPE       =
                     INT_NUMBER_ASSIGNMENT         =
                     BEHAVE_WHEN_ERROR             =
                     LOGIC_SWITCH                  =
                     TESTRUN                       =
                     CONVERT                       = ' '
                    IMPORTING
                      SALESDOCUMENT                 = v_vbeln
                     tables
                      RETURN                        = i_return1
                      ORDER_ITEMS_IN                = i_details
                      ORDER_ITEMS_INX               = ORDER_ITEMS_INX
                       order_partners                = i_partner .
                     ORDER_SCHEDULES_IN            =
                     ORDER_SCHEDULES_INX           =
                     ORDER_CONDITIONS_IN           =
                     ORDER_CONDITIONS_INX          =
                     ORDER_CFGS_REF                =
                     ORDER_CFGS_INST               =
                     ORDER_CFGS_PART_OF            =
                     ORDER_CFGS_VALUE              =
                     ORDER_CFGS_BLOB               =
                     ORDER_CFGS_VK                 =
                     ORDER_CFGS_REFINST            =
                     ORDER_CCARD                   =
                     ORDER_TEXT                    =
                     ORDER_KEYS                    =
                     EXTENSIONIN                   =
                     PARTNERADDRESSES              =
    IF NOT v_vbeln IS INITIAL.
    *Bapi Commit Work
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT =
    IMPORTING
    return = i_return2
    ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
    IMPORTING
    RETURN =
    ENDIF.
    LOOP AT i_return1 .  "INTO wa_return1.
    WRITE:/ i_return1-message.
    ENDLOOP.
    FORM value_help .
      CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
        EXPORTING
          DEF_FILENAME     = ' '
          DEF_PATH         = ' '
          MASK             = ',.,..'
          MODE             = 'O'
          TITLE            = ' '
        IMPORTING
          FILENAME         = p_infile
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    endform.
    txt file data
    order type  salesorg   distch      divison       materialno                  parter role
    TA     PB01     01     00     000000000000000852     WE
    Partner no
    8101000000

    Hi Neerja,
    you can reffer this sample code. It may not be complet soluation for your poblem,
    but you will get some idea.
    *& Report  ZBAPI_SALESORDER_CREATE
    *& Author : Karthik
    REPORT  ZBAPI_SALESORDER_CREATE.
    data : ORDER_HEADER_IN like BAPISDHD1.
    data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with
    header line.
    data : RETURN like BAPIRET2 occurs 0 with header line.
    data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
    header line.
    DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
    LINE.
    data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
    header line.
    data : BEGIN OF TAB OCCURS 0,
            SRNO(4),
            DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
            SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
            DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
            DIVISION like ORDER_HEADER_IN-DIVISION,
           REQ_DATE_H(10),
            PURCH_DATE(10),
            PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
            PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
            ITM_NUMBER like BAPISDITM-ITM_NUMBER,
            CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
            PLANT LIKE ORDER_ITEMS_IN-PLANT,
            TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
            PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
            PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
          END OF TAB.
    data: itab1 like alsmex_tabline occurs 0 with header
    line.
    DATA: gd_currentrow type i.
    data : PURCHASEORDER like ekko-ebeln.
    Data: tot_rec type i,     "Total Records
         gd_update type i,   "Main Table Increement Counter
         gd_lines type i,    "Success Table increement Counter
         w_textout like t100-text. "VARIABLE TO GET ERRORLOG
    data : begin of it_success occurs 0,
            SALESDOCUMENT LIKE BAPIVBELN-VBELN,  "PROJECT
          end of it_success.
    data : begin of it_error occurs 0,
            srno(4),
            err_msg(73) TYPE c,    "TO RETREIVE ERROR MESSAGES
         end of it_error.
    data : srno(4).
    DATA : SALESDOCUMENT LIKE  BAPIVBELN-VBELN.
    selection-screen begin of block b1 with frame.
    skip 3.
    parameter:p_infile like rlgrap-filename obligatory.
    skip 3.
    selection-screen end  of block b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
      PERFORM value_help.
    start-of-selection.
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_infile
          i_begin_col             = '1'
          i_begin_row             = '2' "Do not require
    headings
          i_end_col               = '22'
          i_end_row               = '10000'
        TABLES
          intern                  = itab1
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          others                  = 3.
      if sy-subrc <> 0.
        message e010(zz) with text-001. "Problem uploading
    Excel Spreadsheet
      endif.
    *perform open_group.
      sort itab1 by row col.
    Get first row retrieved
      read table itab1 index 1.
    Set first row retrieved to current row
      gd_currentrow = itab1-row.
      loop at itab1.
    Reset values for next row
        if itab1-row ne gd_currentrow.
          append tab .
          clear tab.
          gd_currentrow = itab1-row.
        endif.
        SHIFT ITAB1-VALUE LEFT DELETING LEADING SPACE.
        case itab1-col.
          when '0001'.
            TAB-SRNO = itab1-value.
          when '0002'.
            TAB-DOC_TYPE = itab1-value.
          when '0003'.
            TAB-SALES_ORG = itab1-value.
          when '0004'.
            TAB-DISTR_CHAN = itab1-value.
          when '0005'.
            TAB-DIVISION = itab1-value.
         when '0006'.
           TAB-REQ_DATE_H =  itab1-value.
          when '0006'.
            TAB-PURCH_DATE = itab1-value.
          when '0007'.
            TAB-PMNTTRMS = itab1-value.
          when '0008'.
            TAB-PURCH_NO_C = itab1-value.
            when '0009'.
            TAB-ITM_NUMBER = itab1-value.
           when '0010'.
            TAB-CUST_MAT22 = itab1-value.
          when '0011'.
            TAB-PLANT  = itab1-value.
          when '0012'.
            TAB-TARGET_QTY = itab1-value.
          when '0013'.
            TAB-PARTN_ROLE = itab1-value.
          when '0014'.
            TAB-PARTN_NUMB = itab1-value.
        endcase.
      endloop.
      append tab.
      clear tab.
      sort tab by SRNO.
      LOOP AT TAB.
       concatenate tab-REQ_DATE_H+4(4)
    tab-REQ_DATE_H2(2) tab-REQ_DATE_H0(2) into
    tab-REQ_DATE_H.
        concatenate tab-PURCH_DATE+4(4)
    tab-PURCH_DATE2(2) tab-PURCH_DATE0(2) into
    tab-PURCH_DATE.
        SRNO = TAB-SRNO.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-PARTN_NUMB
          IMPORTING
            OUTPUT = tab-PARTN_NUMB.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-CUST_MAT22
          IMPORTING
            OUTPUT = tab-CUST_MAT22.
        IF TAB-SRNO = SRNO.
          ORDER_HEADER_IN-DOC_TYPE = TAB-DOC_TYPE.
          ORDER_HEADER_IN-SALES_ORG = TAB-SALES_ORG.
          ORDER_HEADER_IN-DISTR_CHAN = TAB-DISTR_CHAN.
         ORDER_HEADER_IN-REQ_DATE_H = TAB-REQ_DATE_H.
          ORDER_HEADER_IN-PURCH_DATE = TAB-PURCH_DATE.
          ORDER_HEADER_IN-PMNTTRMS = TAB-PMNTTRMS.
          ORDER_HEADER_IN-PURCH_NO_C = TAB-PURCH_NO_C.
          ORDER_HEADER_IN-DIVISION  = tab-DIVISION.
          ORDER_ITEMS_IN-ITM_NUMBER = tab-ITM_NUMBER.
          ORDER_ITEMS_IN-material = TAB-CUST_MAT22.
          ORDER_ITEMS_IN-PLANT      = TAB-PLANT.
          APPEND ORDER_ITEMS_IN.
          ORDER_PARTNERS-PARTN_ROLE = TAB-PARTN_ROLE.
          ORDER_PARTNERS-PARTN_NUMB = TAB-PARTN_NUMB.
          APPEND ORDER_PARTNERS.
          ORDER_SCHEDULES_IN-ITM_NUMBER = tab-ITM_NUMBER.
          ORDER_SCHEDULES_IN-REQ_QTY = tab-TARGET_QTY.
          append ORDER_SCHEDULES_IN.
        ENDIF.
        AT END OF SRNO.
          CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
            EXPORTING
               SALESDOCUMENTIN               =
                 ORDER_HEADER_IN               = ORDER_HEADER_IN
               ORDER_HEADER_INX              =
               SENDER                        =
               BINARY_RELATIONSHIPTYPE       =
               INT_NUMBER_ASSIGNMENT         =
               BEHAVE_WHEN_ERROR             =
               LOGIC_SWITCH                  =
               TESTRUN                       =
               CONVERT                       = ' '
           IMPORTING
             SALESDOCUMENT                 = SALESDOCUMENT
            TABLES
             RETURN                        = RETURN
                 ORDER_ITEMS_IN                = ORDER_ITEMS_IN
               ORDER_ITEMS_INX               =
                 ORDER_PARTNERS                = ORDER_PARTNERS
                 ORDER_SCHEDULES_IN            = ORDER_SCHEDULES_IN
               ORDER_SCHEDULES_INX           =
               ORDER_CONDITIONS_IN           =
               ORDER_CONDITIONS_INX          =
               ORDER_CFGS_REF                =
               ORDER_CFGS_INST               =
               ORDER_CFGS_PART_OF            =
               ORDER_CFGS_VALUE              =
               ORDER_CFGS_BLOB               =
               ORDER_CFGS_VK                 =
               ORDER_CFGS_REFINST            =
               ORDER_CCARD                   =
               ORDER_TEXT                    =
             ORDER_KEYS                    = ORDER_KEYS
               EXTENSIONIN                   =
               PARTNERADDRESSES              =
          IF SALESDOCUMENT <> SPACE.
            commit work.
            ADD 1 TO gd_update.
            it_success-SALESDOCUMENT = SALESDOCUMENT.
            append it_success.
            CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
            REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
          ELSE.
            loop at return.
              it_error-SRNO = tab-SRNO.
              it_error-err_msg = return-MESSAGE .
              Append it_error.
            ENDLOOP.
            CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
            REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
          ENDIF.
        endat.
      endloop.
      DESCRIBE TABLE it_success LINES gd_lines.
      IF gd_lines GT 0.
        Display result report column headings
        PERFORM display_column_headings.
        Display result report
        PERFORM DISPLAY_SUCESS.
      ENDIF.
    IF SUCESS FAILS Display Error Report
      DESCRIBE TABLE it_error LINES gd_lines.
      IF gd_lines GT 0.
        PERFORM errorheadings.
        PERFORM errorreport.
      ENDIF.
    *&      Form  display_column_headings
          text
    FORM display_column_headings.
      WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
      SKIP.
      WRITE:2 'The following records inserted
    successfully:'(013).
      WRITE:/ sy-uline(15).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
               (10) 'Sales order'(004), sy-vline.
      WRITE:/ sy-uline(15).
    ENDFORM.                    "display_column_headings
    *Subroutine to display SUCESS REPORT
    FORM DISPLAY_SUCESS.
      FORMAT COLOR COL_NORMAL.
      LOOP AT it_success.
        WRITE:/      sy-vline,
            (10)  it_success-SALESDOCUMENT, sy-vline.
        CLEAR it_success.
      ENDLOOP.
      WRITE:/ sy-uline(15).
      REFRESH: it_success.
      FORMAT COLOR COL_BACKGROUND.
    ENDFORM.                               "
    DISPLAY_REPORT
    *&      Form  errorreport
          text
    FORM errorreport.
      LOOP AT it_error.
        WRITE:/      sy-vline,
                (10) it_error-SRNO, sy-vline,
                 (40) it_error-err_msg, sy-vline.
      ENDLOOP.
      WRITE:/ sy-uline(104).
      REFRESH: it_error.
    endform.                    "errorreport
    *&      Form  ERRORHEADINGS
          text
    FORM ERRORHEADINGS.
      SKIP.
      WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
      SKIP.
      WRITE:2 'The following records failed during
    update:'(008).
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'ERROR.'(009), sy-vline.
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_NORMAL.
    ENDFORM.                    "ERRORHEADINGS
    **&      Form  value_help
          text
    -->  p1        text
    <--  p2        text
    FORM value_help .
      CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
        EXPORTING
          DEF_FILENAME     = ' '
          DEF_PATH         = ' '
          MASK             = ',.,..'
          MODE             = 'O'
          TITLE            = ' '
        IMPORTING
          FILENAME         = p_infile
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    endform.                    "value_help
    Regards,
    Amit.

  • Uploading Excel to Internal Table

    Hi,
      Can anyone please look into the code and suggest me the changes in uploading Excel to Internal Table. Code is as below in OnInputProcessing.
    DATA: event TYPE REF TO CL_HTMLB_EVENT.
    event =
    CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
    DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD,
           fcontent type xstring,
           fstring  type string,
                  len TYPE I.
    fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'fileUpload'
    id = 'myFileUpload1').
    len = fileUpload->file_length.
    IF event->id = 'submitButton' AND
        event->event_type = 'click'.
       fileUpload ?=
    CL_HTMLB_MANAGER=>GET_DATA( request = request
                               id = 'myFileUpload1'
                               name = 'fileUpload' ).
       IF ( fileUpload->file_name NE '' ) AND
       ( fileUpload->file_length GT 0 ).
         IF fileUpload->file_content_type
         = 'application/vnd.ms-excel'.
           DATA: content TYPE ZTABLE,
           conv TYPE REF TO CL_ABAP_CONV_IN_CE,
           viewoff TYPE REF TO CL_ABAP_VIEW_OFFLEN,
           it_off TYPE ABAPOFFLENTAB,
           wa_off TYPE ABAPOFFLEN,
           dd_fields TYPE DDFIELDS,
           wa_fields TYPE DFIES.
    data: codepage type CPCODEPAGE.
    CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
    EXPORTING
    external_name       = 'utf-16le'
      KIND                = 'H'
      IMPORTING
      SAP_CODEPAGE        = codepage.
    conv = CL_ABAP_CONV_IN_CE=>CREATE( encoding = '4103'
    endian = 'L'
    input =   fileUpload->file_content
    ignore_cerr = 'X').
           CALL FUNCTION 'TR_NAMETAB_GET'
             EXPORTING
               IV_TABNAME                 = 'ZTABLE'
               IV_GET_LENGTHS_IN_CHARMODE = 'X'
               IV_GET_TEXTS               = ' '
             IMPORTING
               ET_DFIES                   = dd_fields.
            LOOP AT dd_fields INTO wa_fields.
             MOVE wa_fields-offset TO wa_off-ioff.
             MOVE wa_fields-intlen TO wa_off-ilen.
             APPEND wa_off TO it_off.
            ENDLOOP.
           viewoff = CL_ABAP_VIEW_OFFLEN=>CREATE( tab = it_off ).
            call method conv->read( importing data = fstring ).
           fcontent = conv->get_buffer( ).
           call function 'HR_KR_XSTRING_TO_STRING'
               exporting
                   from_codepage = '4103'
                   in_xstring    = fcontent
              importing
                   out_string    = fstring.
          data: input_string type string.
          data: fields  type string_table.
          data: s_table type string_table.
    split fstring at cl_abap_char_utilities=>cr_lf into table s_table.
    field-symbols: <wa_table> like line of s_table.
    loop at s_table assigning <wa_table>.
      split <wa_table> at cl_abap_char_utilities=>HORIZONTAL_TAB into table
    fields.
    endloop.
      endif.
      endif.
      endif.
    thanks in advance,
    anjani.

    Hi anjani,
    it doesn't help much if you just post some code and request changes, if you don't state the kind of problem you are having ... in order to receice helpful replies, you have to give detailed information, what you want to do, what is not working as expected ... so please post more details.
    Meanwhile I recommend doing a search for your excel problem in the forum and also read the excel weblogs from <a href="https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/u/1918">Thomas Jung</a>.
    Regards,
    Max

Maybe you are looking for