Application Development 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: 

Uploading Excel file in SRM

Former Member
0 Kudos

Hello,

I need to upload excel file in SRM system.

FM ALSM_EXCEL_TO_INTERNAL_TABLE & TEXT_CONVERT_XLS_TO_SAP are not available in this system.

i am able to upload text file (.txt) using following code

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          = 'P_FILE'
 STATIC              = 'X'
MASK                = '.excel , *.xls '
  CHANGING
file_name           = p_file
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.

ld_file = p_file.

  CALL METHOD cl_gui_frontend_services=>gui_upload
  EXPORTING
    filename = ld_file
*    filetype = 'ASC'
*    filetype = 'BIN'
    filetype = 'DAT'
    HAS_FIELD_SEPARATOR           = 'X'
  CHANGING
    data_tab = itab[]
  EXCEPTIONS
    OTHERS   = 1.

tried with filetype = ASC , BIN & DAT - All r allowing .txt file only.

Please tell me which parameters do i need to provide in order to upload excel file

thanks & regrads,

7 REPLIES 7

Former Member
0 Kudos

Hello,

This is a simple example program to get data from an excel file and store it in an internal table.

Try it in this way.


REPORT  zexcel_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.

0 Kudos

Hello DNR_varma

Thanks for ur inputs but

I am in SRM system.

'F4_FILENAME' , 'TEXT_CONVERT_XLS_TO_SAP' - these FMs are not avaialable in this system .

Former Member
0 Kudos

Convert the Excel file to tab delimitted (or something similar) and then use FM GUI_UPLOAD, which does exist in SRM.

Rob

0 Kudos

Hello Rob,

Currently I am doing the same thing as u suggested. But this include manual process to convert .xls file to tab delimitted file. I want to automate this process. (Just like get the file, run a program & get the file uploaded in SAP system). Can you please help on this.

Thanks & Regards,

0 Kudos

Hello,

Desktop files can not be uploaded in background....!! CG3Z and CG3Y could be used to interface the files into application server. Files from AL11 can be automised....

Best Regards,

Senthilraj S

Edited by: Senthilraj Selvaraj on Aug 8, 2011 4:29 PM

Edited by: Senthilraj Selvaraj on Aug 8, 2011 4:33 PM

0 Kudos

Not all problems have neat solutions.

Rob

0 Kudos

Hello ALL

We can copy FM ALSM_EXCEL_TO_INTERNAL_TABLE into SRM system.