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

upload data from excel to screen

Former Member
0 Likes
634

Hi

I have created one Table Maintanence Generator with only one screen (Table control ). Here i have to upload data from excel to table control. How to upload data from excel to table control.

Hi

I have created one Table Maintanence Generator with only one screen (Table control ). Here i have to upload data from excel to table control. How to upload data from excel to table control.

4 REPLIES 4
Read only

andreas_mann3
Active Contributor
0 Likes
611

here's a prg. to load data (formatted for SAP!) in customer tables http://www.a-saph.de/etc/ZLOADZTABLE.txt

A.

Read only

Former Member
0 Likes
611

hi,

Let say your table control contains the internal table (ITAB) fields. In PBO upload the data From desktop to the ITAB using FM 'GUI_UPLOAD' specifying the loaction , file name and type and in tables ITAB .

Read only

Former Member
0 Likes
611

Hi,

Upload the excel data to the internal table using Function Module 'GUI_UPLOAD' and than transfer this internal table to the table control.

I hope this answer help you.

Thanks,

Khushbu.

Read only

vinod_vemuru2
Active Contributor
0 Likes
611

Hi,

Use this code to get data from excel to internal table. Later put the logic in PBO of the screen to fill the table control from internal table.


PARAMETERS: po_file TYPE rlgrap-filename DEFAULT 'E:test.xls'.
TYPES: BEGIN OF t_final,
          empno(10) TYPE c,
          name(30) TYPE c,
          state(25) TYPE c,
       END OF t_final.
PARAMETERS: po_file TYPE rlgrap-filename.
DATA: i_tab    TYPE STANDARD TABLE OF alsmex_tabline,
      i_final  TYPE STANDARD TABLE OF t_final,
      wa_tab   TYPE alsmex_tabline,
      wa_final TYPE t_final.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR po_file.
PERFORM open_folder.

START-OF-SELECTION.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
     EXPORTING
          filename                = po_file
          i_begin_col             = 1
          i_begin_row             = 1
          i_end_col               = 3
          i_end_row               = 65256
     TABLES
          intern                  = i_tab
     EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.

CHECK NOT i_tab[] IS INITIAL.

LOOP AT i_tab INTO wa_tab.
  CASE wa_tab-col.
    WHEN 1.
      wa_final-empno = wa_tab-value.
    WHEN 2.
      wa_final-name = wa_tab-value.
    WHEN 3.
      wa_final-state = wa_tab-value.
  ENDCASE.
  AT END OF row.
    APPEND wa_final TO i_final.
    CLEAR wa_final.
  ENDAT.
ENDLOOP.
*
FORM open_folder .
  DATA: li_file  TYPE TABLE OF sdokpath,
        lwa_file TYPE sdokpath.
  CLEAR: p_fname, lwa_file.
  REFRESH li_file[].
  CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
       TABLES
            file_table = li_file
       EXCEPTIONS
            cntl_error = 1
            OTHERS     = 2.
  IF sy-subrc IS INITIAL.
    READ TABLE li_file INTO lwa_file INDEX 1.
    IF sy-subrc IS INITIAL.
     p_fname = lwa_file-pathname.
    ENDIF.
  ENDIF.
ENDFORM.                    " open_folder

Thanks,

Vinod.

Edited by: Vinod Reddy Vemuru on Jul 28, 2008 4:50 PM