Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FM for uploading data into internal table from Excel sheet

Former Member
0 Likes
1,174

Hi,

I have a slight problem in one of the function modules that I have created. Actually it has been copied from a standard SAP function module “KCD_EXCEL_OLE_TO_INT_CONVERT”. Now my created function module is throwing me a dump suggesting “Data objects in a Unicode program are not convertible”. Can anybody help me out in removing the error .

Actually the need of copying the standard FM to a ZFM is to increase the length of the column which can be uploaded thru this FM. The standard FM has a restriction of being able to upload 32 characters whereas my requirement is to upload data having at least 150 characters. So in order to care the need I made a ZStructure ZAKHIL_CELLS taking the Value parameters as 150 characters instead of 32 characters.

Well this is all done because I wanted to upload a excel sheet into an internal table and not use a tab delimited file. Can anybody help in this regard or suggest some other function module which can upload more than 150 characters from a excel sheet .

‘m also attaching structure of my ZStructure for ur reference .

STRUCTURE ZAKHIL_CELLS1 .

ROW KCD_EX_ROW_N NUMC 4 Flexible Excel upload: row number

COL KCD_EX_COL_N NUMC 4 Column

VALUE KCD_VALUE CHAR 150 External Data Transfer: Values of Parameters or Variables

Thanks & Rgds,

Akhil

Hi,

I have a slight problem in one of the function modules that I have created. Actually it has been copied from a standard SAP function module “KCD_EXCEL_OLE_TO_INT_CONVERT”. Now my created function module is throwing me a dump suggesting “Data objects in a Unicode program are not convertible”. Can anybody help me out in removing the error .

Actually the need of copying the standard FM to a ZFM is to increase the length of the column which can be uploaded thru this FM. The standard FM has a restriction of being able to upload 32 characters whereas my requirement is to upload data having at least 150 characters. So in order to care the need I made a ZStructure ZAKHIL_CELLS taking the Value parameters as 150 characters instead of 32 characters.

Well this is all done because I wanted to upload a excel sheet into an internal table and not use a tab delimited file. Can anybody help in this regard or suggest some other function module which can upload more than 150 characters from a excel sheet .

‘m also attaching structure of my ZStructure for ur reference .

STRUCTURE ZAKHIL_CELLS1 .

ROW KCD_EX_ROW_N NUMC 4 Flexible Excel upload: row number

COL KCD_EX_COL_N NUMC 4 Column

VALUE KCD_VALUE CHAR 150 External Data Transfer: Values of Parameters or Variables

Thanks & Rgds,

Akhil

4 REPLIES 4
Read only

Former Member
0 Likes
730

Can you try with FM ALSM_EXCEL_TO_INTERNAL_TABLE?

Read only

0 Likes
730

Hi,

The FM "ALSM_EXCEL_TO_INTERNAL_TABLE" has a restriction of uplaoding till 50 characters. My xcel sheet has data till 150 characters

Thanks & Rgds,

Akhil

Read only

Former Member
0 Likes
730

Hi Akhil

We can use GUI_UPLOAD FM or method of CL_GUI_FRONTEND_SERVICES.

Below example can give you some idea:

parameters: p_fname like rlgrap-filename.

types: begin of t_data,
         fld1(300) type c,
         fld2(10) type c,
       end of t_data.
data: it_data type standard table of t_data,
      wa_data type t_data.
data: l_fname type string.


at selection-screen on value-request for p_fname.

CALL FUNCTION 'F4_FILENAME'
 IMPORTING
   FILE_NAME           = p_fname.

start-of-selection.

l_fname = p_fname.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
  EXPORTING
    FILENAME                = l_fname
*    FILETYPE                = 'ASC'
    HAS_FIELD_SEPARATOR     = 'X'
*    HEADER_LENGTH           = 0
*    DAT_MODE                = SPACE
*    CODEPAGE                = SPACE
*    IGNORE_CERR             = ABAP_TRUE
*    REPLACEMENT             = '#'
*    READ_BY_LINE            = 'X'
*  IMPORTING
*    FILELENGTH              =
*    HEADER                  =
  CHANGING
    DATA_TAB                = it_data[]
  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
    NOT_SUPPORTED_BY_GUI    = 17
    ERROR_NO_GUI            = 18
    others                  = 19.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Kind Regards

Eswar

Read only

0 Likes
730

Hi,

Thanks for ur prompt reply but this FM will work on a TAB delimited file which i dont want . I want to directly upload the data from a excel sheet .

Thanks& Rgds,

Akhil