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: 

Interfaces

Former Member
0 Kudos

Hi,

In interfaces we transfer data from a ascii file to sap tables right? But my question is from where do we get this ASCII file from? I want to know the buisness logic of all these process....

Help me pls

Thank you,

Kelly.

16 REPLIES 16

Former Member
0 Kudos

Well Kelly.. that depends, in the most cases the file i'ts proposed by the user, for example the user have in a Excel file the data all the customer of the company, then you may convert (or use the same excel file) to a .TXT file, the your program read this .txt and do all the process that have to do in order tu input the custumer data inside sap.

i hope you may find this information useful

Regards.

Carlos A. Lerzundy

0 Kudos

Hi,

Also I wanted to know is there any FM to upload data directly from EXcel sheet , without convertig it into flat file?

Thanx Kelly

0 Kudos

Kelly,

"Where" your data comes from depends on your application. What is it that you need to do. Do you need to create a sales order from data which is coming from an old legacy system? Do you have to create a sales order from data which is collected via a java iView. Every application is different.

In the case where one needs to upload sales orders from a legacy system, your data would need to come from that legacy system in the form a flat file, delimited file, or excel sheet. Then using LSMW, you would read this file in, and use it to create your sales orders via standard upload programs, recordings, idocs, or BAPIs.

If you needed to create a sales order from a web application, then you would use a BAPI in your java class. Your web frontend would get the data from the user, and in your program, you would build the interface to the BAPI(this means taking the data from the user and putting it in the import/export/tables parameters of the bapi) and call the BAPI. This would create your sales order in R/3.

You can "upload" data from an excel sheet, what we usually do is same the data as a comma delimited excel file. LSMW will be able to handle the parsing of the records.

Regards,

Rich Heilman

0 Kudos

Hi

I tried to upload data directly from exel sheet using FM wsupload.. But all i got was some special characters. nothing else.. why is this..

Kelly

0 Kudos

Please try using the following class/method. I'm sure that this will work for you.




types: begin of t_excel,
       field1(20) type c,
       field2(20) type c,
       field3(20) type c,
       field4(20) type c,
       field5(20) type c,
       field6(20) type c,
       field7(20) type c,
       field8(20) type c,
       field9(20) type c,
       field10(20) type c,
       field11(20) type c,
       field12(20) type c,
       end of t_excel.

data: i_excel type table of t_excel.

      call method cl_gui_frontend_services=>gui_upload
        exporting
          filename                = file
          has_field_separator   = 'X'
        changing
          data_tab                = i_excel
        exceptions
          others                  = 22.

Regards,

Rich Heilman

0 Kudos

Hi ,

Still the same. All I am getting is

"Di######.....####sheet####".

I did a small program with just char fields in the file.

But isn't working for me...

Kelly

0 Kudos

Strange....this code worked great for me.

Can you post your small program. Maybe I can take a look and see whats up.

Regards,

Rich Heilman

0 Kudos

Make sure that the excel file is NOT saved as UTF-8 or any other unicode format but plain tab delimted ascii file.

Christian

0 Kudos

Hi Kelly,

I think people are really trying very hard to help you You can save the file as CSV file from EXCEL and then try uploading it.

Regards,

Sanjeev

0 Kudos

hi,

Actually It will work when I save it as Csv file . But what I wanted to know is , Is there any way that I can upload data directly from Excel without changing it to anyother format? Is it possible?

Kelly

0 Kudos

Yes, using my sample code above, I uploaded an excel file with 5 fields and 5 rows into internal table with 5 fields. All data was as it was in the excel sheet.

Of course, now I can't get it to work again. I am seeing the same problem as you. Great!

Regards,

Rich Heilman

Message was edited by: Rich Heilman

0 Kudos

Ok, I see why it worked for me. I was downloading data to excel using GUI_DOWNLOAD, then uploading using the GUI_UPLOAD. Must be the way GUI_DOWNLOAD writes the data to excel. Install the sample program. You will see what I mean. Enter a file path and execute, program will write the file, now click the upload radiobutton and execute, progam will read the file back and write it to list display.



types: begin of t_excel,
        field1(20) type c,
        field2(20) type c,
        field3(20) type c,
        field4(20) type c,
        field5(20) type c,
        field6(20) type c,
        field7(20) type c,
        field8(20) type c,
        field9(20) type c,
        field10(20) type c,
        field11(20) type c,
        field12(20) type c,
        end of t_excel.

data: i_excel type table of t_excel.
data: x_excel type t_excel.
data: file type string.

parameters: p_file type localfile.
parameters: p_down radiobutton group grp1 default 'X',
            p_up   radiobutton group grp1.


at selection-screen on value-request for p_file.
  call function 'KD_GET_FILENAME_ON_F4'
       exporting
            static    = 'X'
       changing
            file_name = p_file.

start-of-selection.

  if p_down = 'X'.

    x_excel-field1 = 'A1'.
    x_excel-field2 = 'A2'.
    x_excel-field3 = 'A3'.
    x_excel-field4 = 'A4'.
    x_excel-field5 = 'A5'.
    append x_excel to i_excel.

    x_excel-field1 = 'B1'.
    x_excel-field2 = 'B2'.
    x_excel-field3 = 'B3'.
    x_excel-field4 = 'B4'.
    x_excel-field5 = 'B5'.
    append x_excel to i_excel.

    x_excel-field1 = 'C1'.
    x_excel-field2 = 'C2'.
    x_excel-field3 = 'C3'.
    x_excel-field4 = 'C4'.
    x_excel-field5 = 'C5'.
    append x_excel to i_excel.

    file = p_file.
    call method cl_gui_frontend_services=>gui_download
      exporting
        filename              = file
        write_field_separator   = 'X'
      changing
        data_tab                = i_excel
      exceptions
        others                  = 22.


  elseif p_up = 'X'.

    file = p_file.
    call method cl_gui_frontend_services=>gui_upload
      exporting
        filename              = file
        has_field_separator   = 'X'
      changing
        data_tab                = i_excel
      exceptions
        others                  = 22.

    loop at i_excel into x_excel.
      write:/ x_excel.
    endloop.

  endif.

Regards,

Rich Heilman

0 Kudos

Try FM ALSM_EXCEL_TO_INTERNAL_TABLE to read excel file.

Regards

0 Kudos

Hi Shehryar,

I tried this one . But I am getting the sy-subrc as 2 which is an exception 'UPLOAD _OLE' Why is that?

thanx

kelly

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

From external systems, in our case, we generated text files from our Legacy AS/400 system, then upload these text files into SAP using LSMW.

Regards,

Rich Heilman

0 Kudos

Hi,

Lets take the example of a BAPI for updating and creating new sales orders. How does it work? I mean when the customer places a sales order how do we get it as a flat file o excel sheet?

I hope i am clear with my question...

Thanx

Kelly