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: 

Not uploading more than 150 rows from Excel file to Internal table.

former_member587421
Participant
0 Kudos

Hi All,

We have a Z program to upload initial stock from excel file to SAP using BAPI. The problem is we have defined row to '65536'. But it is not uploading more than 150 rows at a time. The piece of code is given below.


DATA : it_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA: xcel TYPE TABLE OF alsmex_tabline WITH HEADER LINE.
DATA : gd_scol   TYPE i VALUE '1',
       gd_srow   TYPE i VALUE '3',
       gd_ecol   TYPE i VALUE '256',
       gd_erow   TYPE i VALUE '65536'.

PERFORM upload_excel_file TABLES   gt_out
                              USING   p_file
                                      gd_scol
                                      gd_srow
                                      gd_ecol
                                      gd_erow.
FORM upload_excel_file  TABLES   gt_out
                                   "Insert correct name for <...>
                        USING    p_p_file
                                 p_gd_scol
                                 p_gd_srow
                                 p_gd_ecol
                                 p_gd_erow.
  DATA : lt_intern TYPE  kcde_cells OCCURS 0 WITH HEADER LINE.
  DATA : ld_index TYPE i.
  FIELD-SYMBOLS: <fs> TYPE ANY.
  CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
    EXPORTING
      filename    = p_p_file
      i_begin_col = p_gd_scol
      i_begin_row = p_gd_srow
      i_end_col   = p_gd_ecol
      i_end_row   = p_gd_erow
    TABLES
      intern      = lt_intern[].
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  IF lt_intern[] IS INITIAL.
    FORMAT COLOR COL_BACKGROUND INTENSIFIED.
    WRITE:/ 'No Data Uploaded'.
    EXIT.
  ELSE.
    SORT lt_intern BY row col.
    LOOP AT lt_intern.
      MOVE lt_intern-col TO ld_index.
      ASSIGN COMPONENT ld_index OF STRUCTURE gt_out TO <fs>.
      MOVE lt_intern-value TO <fs>.
      AT END OF row.
        APPEND gt_out.
        CLEAR gt_out.
      ENDAT.
    ENDLOOP.
  ENDIF.

ENDFORM.            

Plz tell me, what is the problem here. I want to upload all the rows at a time.

Thanks,

With regards,

Rosaline.

8 REPLIES 8

Former Member
0 Kudos

Hi,

Try this FM


*   Convert XLS to internal table
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
        i_tab_raw_data       = lv_tab_raw_data " Dummy field
        i_filename           = p_file " Your file name
      TABLES
        i_tab_converted_data = gt_out " Final internal table
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.

Former Member
0 Kudos

Hi,

Try the FM ALSM_EXCEL_TO_INTERNAL_TABLE or else do like below.

*--Uploading xls sheet
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = p_locin          "file name with location
      has_field_separator     = 'X'
    TABLES
      data_tab                = li_text_data.

  IF sy-subrc <> 0.
  ENDIF.

  lv_file  = p_locin.
*--Converting the xls to readable format
  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      i_field_seperator    = 'X'
      i_tab_raw_data       = li_text_data
      i_filename           = lv_file
    TABLES
      i_tab_converted_data = li_locfile.

The itab li_locfile will contain the data.

Sandra_Rossi
Active Contributor
0 Kudos

We have a Z program to upload initial stock from excel file to SAP using BAPI \[...\] KCD_EXCEL_OLE_TO_INT_CONVERT

Just a little comment: KCD_EXCEL_OLE_TO_INT_CONVERT is absolutely not a BAPI, and it's not released (released means "can be used by the customer"). A BAPI name starts with BAPI, is usually released. Always be prudent when using non-released SAP objects. Note that TEXT_CONVERT_XLS_TO_SAP is not released too, but it uses DOI which is a supported technology, and I think you don't risk much to use it (as many many clients do use it).

0 Kudos

... (released means "can be used by the customer")

A minor nit to pick - I think released only means that a FM is guaranteed to be upward compatible.

We all use unreleased FMs, but at upgrade time we understand that testing our custom program interfaces to SAP FMs is a major chore.

On the other hand, if you call an unreleased FM in your custom code, you will have a tough time to get support from SAP if it doesn't work as you expect. SAP will support their BAPIs (not sure about released FMs that are not BAPIs).

Rob

0 Kudos

Hi Rob, I confirm, you're nitpicking! 😄 For information, I've noted a few SAP comments about releasing and released objects, for people who like reading: [SAP Library - Documenting and Releasing a Function Module|http://help.sap.com/saphelp_nw70/helpdata/en/d1/801f50454211d189710000e8322d00/frameset.htm], [Note 109533 - Use of SAP function modules|https://service.sap.com/sap/support/notes/109533], [Note 415983 - Modification/customer developments of SAP function modules|https://service.sap.com/sap/support/notes/415983]; Example of an unreleased BAPI -> [Note 577453 - Using BAPI BAPI_DELIVERYPROCESSING_EXEC|https://service.sap.com/sap/support/notes/577453]

Sandra

Former Member
0 Kudos

Hi,

Though I am not sure what is the exact reason.

In my requirement I have successfully uploaded excel file with more than 150 rows in the application server using FM 'ALSM_EXCEL_TO_INTERNAL_TABLE'.

you can try this.

Thanks.....

former_member587421
Participant
0 Kudos

Solved by myself.

0 Kudos

How did you solve y yourself?