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

File upload in BDC

Former Member
0 Likes
737

Dear friends,

While uploading flat file into an internal table generally we ask users to save that file in TEXT format

and by using filetype DAT , we take it into an internal table....

Can we take that file Directly from EXCEL to an INTERNAL TABLE using GUI_UPLOAD...

and avoiding use of fun module ALSM_EXCEL_TO_INTERNAL_TABLE....

or any other way out ?

Thanks........

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
710

HI,

Try this code to upload excel data into itab...

DATA l_count TYPE sy-tabix.

   CONSTANTS: lc_begin_col TYPE i VALUE '1',

              lc_begin_row TYPE i VALUE '2',

              lc_end_col   TYPE i VALUE '2',

              lc_end_row   TYPE i VALUE '3000'.

* Begin of CALK912848 - Carlos Werberich - 16Sep08

  CLEAR p_i_excel_data. REFRESH p_i_excel_data.

* End   of CALK912848 - Carlos Werberich - 16Sep08

* Function module to read excel file and convert it into internal table

   CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

     EXPORTING

       filename                = p_p_file

       i_begin_col             = lc_begin_col

       i_begin_row             = lc_begin_row

       i_end_col               = lc_end_col

       i_end_row               = lc_end_row

     TABLES

       intern                  = i_data

     EXCEPTIONS

       inconsistent_parameters = 1

       upload_ole              = 2

       OTHERS                  = 3.

* Error in file upload

   IF sy-subrc NE 0 .

     MESSAGE text-006 TYPE 'E'.

     EXIT.

   ENDIF.

   IF i_data[] IS INITIAL .

     MESSAGE text-007 TYPE 'E'.

     EXIT.

   ELSE.

     SORT i_data BY row col .

* Loop to fill data in Internal Table

     LOOP AT i_data .

       MOVE i_data-col TO l_count .

       ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO  .

       AT END OF row .

* Append data into internal table

         APPEND p_i_excel_data.

         CLEAR p_i_excel_data.

       ENDAT .

     ENDLOOP .

   ENDIF 

Dear friends,

While uploading flat file into an internal table generally we ask users to save that file in TEXT format

and by using filetype DAT , we take it into an internal table....

Can we take that file Directly from EXCEL to an INTERNAL TABLE using GUI_UPLOAD...

and avoiding use of fun module ALSM_EXCEL_TO_INTERNAL_TABLE....

or any other way out ?

Thanks........

5 REPLIES 5
Read only

arjun_subhash
Active Participant
0 Likes
710

hi,

try using this function module with fname as excel file name.

DATA FNAME TYPE RLGRAP-FILENAME.

DATA PNAME TYPE STRING

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

  • EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

  • STATIC = ' '

  • MASK = ' '

CHANGING

FILE_NAME = fname

  • EXCEPTIONS

  • MASK_TOO_LONG = 1

  • OTHERS = 2

and gui_upload like,

PNAME = FNAME.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = PNAME

FILETYPE = 'ASC'

thanks

Arjun

Read only

former_member156446
Active Contributor
0 Likes
710

but you got to split the cell content into your internal table structure.. that's gonna be messy its better to use the ALMExcell FM...

Read only

tarangini_katta
Active Contributor
0 Likes
710

Hi,

This is not possiable with GUI_upload

It's better to go with ASLM_EXCEL_INTERNALTABLE.

Thanks,

Read only

Former Member
0 Likes
710

you try with CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

Read only

Former Member
0 Likes
711

HI,

Try this code to upload excel data into itab...

DATA l_count TYPE sy-tabix.

   CONSTANTS: lc_begin_col TYPE i VALUE '1',

              lc_begin_row TYPE i VALUE '2',

              lc_end_col   TYPE i VALUE '2',

              lc_end_row   TYPE i VALUE '3000'.

* Begin of CALK912848 - Carlos Werberich - 16Sep08

  CLEAR p_i_excel_data. REFRESH p_i_excel_data.

* End   of CALK912848 - Carlos Werberich - 16Sep08

* Function module to read excel file and convert it into internal table

   CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

     EXPORTING

       filename                = p_p_file

       i_begin_col             = lc_begin_col

       i_begin_row             = lc_begin_row

       i_end_col               = lc_end_col

       i_end_row               = lc_end_row

     TABLES

       intern                  = i_data

     EXCEPTIONS

       inconsistent_parameters = 1

       upload_ole              = 2

       OTHERS                  = 3.

* Error in file upload

   IF sy-subrc NE 0 .

     MESSAGE text-006 TYPE 'E'.

     EXIT.

   ENDIF.

   IF i_data[] IS INITIAL .

     MESSAGE text-007 TYPE 'E'.

     EXIT.

   ELSE.

     SORT i_data BY row col .

* Loop to fill data in Internal Table

     LOOP AT i_data .

       MOVE i_data-col TO l_count .

       ASSIGN COMPONENT l_count OF STRUCTURE p_i_excel_data TO  .

       AT END OF row .

* Append data into internal table

         APPEND p_i_excel_data.

         CLEAR p_i_excel_data.

       ENDAT .

     ENDLOOP .

   ENDIF