Von Excel zu SAP

Getting started ... Alles für einen gelungenen Start.
10 Beiträge • Seite 1 von 1
10 Beiträge Seite 1 von 1

Von Excel zu SAP

Beitrag von chyth (ForumUser / 7 / 0 / 0 ) »
Hallo!
Folgendes Problem liegt vor mir: Ich möchte gern Datensätze von Excel in SAP importieren/uploaden.

Dabei gibt es natürlich zwei Wege:
1) Durch ein Excel-Makro.
2) Durch ein SAP Report.

Habt ihr zu einem der beiden Wege irgendwelche Ideen? Ich weiß leider nicht genau über welches Interface und auf welche Art das möglich ist.

Liebe Grüße.

gesponsert
Stellenangebote auf ABAPforum.com schalten
kostenfrei für Ausbildungsberufe und Werksstudenten


Beitrag von TWP (Specialist / 445 / 0 / 1 ) »
Der einfachste Weg ist die EXCEL Datei als CSV oder "Tabgetrennte Textdatei" zu speichern und diese in SAP per UPLOAD oder per OPEN DATASET zu lesen.

MfG
Thomas

Beitrag von khb (Specialist / 184 / 7 / 1 ) »
Bei mir hat das Einlesen einer Excel-Datei gut mit dem FuBa 'ALSM_EXCEL_TO_INTERNAL_TABLE' geklappt

LG khb

Beitrag von chyth (ForumUser / 7 / 0 / 0 ) »
Hallo nochmal,
bei der Methode OPEN DATASET ist es ja leider so, dass Sie sich auf Files bezieht, die auf dem Application Server liegen. Ich möchte jedoch Daten aus einer .txt, oder .xls, lesen, die auf meinem Rechner liegt.

Gibt es dafür auch Funktionen?

Beitrag von khb (Specialist / 184 / 7 / 1 ) »

Code: Alles auswählen.

 Verfasst am: Fr Jul 13, 2007 08:09    Titel:  

--------------------------------------------------------------------------------
 
Bei mir hat das Einlesen einer Excel-Datei gut mit dem FuBa 'ALSM_EXCEL_TO_INTERNAL_TABLE' geklappt 

LG khb 
 
8)

Beitrag von chyth (ForumUser / 7 / 0 / 0 ) »
Hast du dazu einen Beispielcode? Wäre mir eine große Hilfe!

Beitrag von chyth (ForumUser / 7 / 0 / 0 ) »

Code: Alles auswählen.

REPORT  ZIMPORT no standard page heading.

*Data Declaration
*----------------
data: itab like alsmex_tabline occurs 0 with header line.

TYPES: Begin of t_record,
    name1 like itab-value,
    name2 like itab-value,
    age   like itab-value,
    End of t_record.
DATA: it_record type standard table of t_record initial size 0,
      wa_record type t_record.
DATA: gd_currentrow type i.

*Selection Screen Declaration
*----------------------------
PARAMETER p_infile like rlgrap-filename.


************************************************************************
*START OF SELECTION
 call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
       exporting
            filename                = p_infile
            i_begin_col             = '1'
            i_begin_row             = '1'  "Do not require headings
            i_end_col               = '14'
            i_end_row               = '31'
       tables
            intern                  = itab
       exceptions
            inconsistent_parameters = 1
            upload_ole              = 2
            others                  = 3.
  if sy-subrc <> 0.
    message e010(zz) with text-001. "Problem uploading Excel Spreadsheet
  endif.

* Sort table by rows and colums
  sort itab by row col.

* Get first row retrieved
  read table itab index 1.

* Set first row retrieved to current row
  gd_currentrow = itab-row.

  loop at itab.
*   Reset values for next row
    if itab-row ne gd_currentrow.
      append wa_record to it_record.
      clear wa_record.
      gd_currentrow = itab-row.
    endif.

    case itab-col.
      when '0001'.                              "First name
        wa_record-name1 = itab-value.
      when '0002'.                              "Surname
        wa_record-name2 = itab-value.
      when '0003'.                              "Age
        wa_record-age   = itab-value.
    endcase.
  endloop.
  append wa_record to it_record.
*!! Excel data is now contained within the internal table IT_RECORD

* Display report data for illustration purposes
  loop at it_record into wa_record.
    write:/     sy-vline,
           (10) wa_record-name1, sy-vline,
           (10) wa_record-name2, sy-vline,
           (10) wa_record-age, sy-vline.
  endloop.
Wäre ja ein brauchbarer Code - jedoch weiß ich noch nicht warum es nicht läuft, wenn ich den Pfad zum meiner .cvs Datei angebe.

Beitrag von chyth (ForumUser / 7 / 0 / 0 ) »
Für alle die, die irgendwann nach einer Lösung für ein solches Problem suchen:

Code: Alles auswählen.

*&---------------------------------------------------------------------*
*& Report  ZIMPORT
*&
*&---------------------------------------------------------------------*
*& PROGRAMM ZUM IMPORTIEREN VON TEXTFILES
*&
*&---------------------------------------------------------------------*

REPORT  ZIMPORT no standard page heading.

*Data Declaration
*----------------
data: itab like alsmex_tabline occurs 0 with header line.

TYPES: Begin of t_record,
    name1 like itab-value,
    name2 like itab-value,
    age   like itab-value,
    End of t_record.
DATA: it_record type standard table of t_record initial size 0,
      wa_record type t_record.
DATA: gd_currentrow type i.

*Selection Screen Declaration
*----------------------------
PARAMETER source like rlgrap-filename.


************************************************************************
*START OF SELECTION
 call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
       exporting
            filename                = source
            i_begin_col             = '1'
            i_begin_row             = '1'  "Do not require headings
            i_end_col               = '14'
            i_end_row               = '31'
       tables
            intern                  = itab
       exceptions
            inconsistent_parameters = 1
            upload_ole              = 2
            others                  = 3.
  if sy-subrc <> 0.
    message e010(zz) with text-001. "Problem uploading Excel Spreadsheet
  endif.

* Sort table by rows and colums
  sort itab by row col.

* Get first row retrieved
  read table itab index 1.

* Set first row retrieved to current row
  gd_currentrow = itab-row.

  loop at itab.
    if itab-row ne gd_currentrow.
      append wa_record to it_record.
      clear wa_record.
      gd_currentrow = itab-row.
    endif.

    case itab-col.
      when '0001'.                              "Vorname
        wa_record-name1 = itab-value.
      when '0002'.                              "Nachname
        wa_record-name2 = itab-value.
      when '0003'.                              "Alter
        wa_record-age   = itab-value.
    endcase.
  endloop.
  append wa_record to it_record.

  write:/     sy-vline,
         (10) 'Name', sy-vline,
         (10) 'Vorname', sy-vline,
         (10) 'Alter', sy-vline.

* Display
  loop at it_record into wa_record.
    write:/     sy-vline,
           (10) wa_record-name1, sy-vline,
           (10) wa_record-name2, sy-vline,
           (10) wa_record-age, sy-vline.
  endloop.
Eingegeben bei Param. wird der Pfad C:\xxx\file.txt

Die File muss in Excel als txt mit tab delimited gespeichert sein.

Beitrag von TWP (Specialist / 445 / 0 / 1 ) »
Wenn ihr die dateio als CSV oder Tab getrennte Datei ablegt, sol lest diese doch mit Upload wieder ein (Klasse CL_GUI_FRONTEND_SERVICES).
Beim einlesen einer EXCEL-Datei mit dem Funktionsbaustein hatte ich auch schon den Effekt, das bei abweichenden lokalen EXCEL - Verisionen das verhalten anders ist.

Thomas

Beitrag von littleJohn (ForumUser / 70 / 13 / 0 ) »
... hab auch schon den FuBA AA_FILE_UPLOAD_EXCEL verwendet. Von einem Excel-File direkt in eine interne Tabelle geladen und dann mit der Funktion SPLIT und dem Trennzeichen ',' aufgeteilt. Hat problemlos funktioniert.

Seite 1 von 1

Vergleichbare Themen

0
Antw.
2467
Views
Excel Upload ohne Excel aber OpenOffice
von MarkusW » 23.01.2008 17:07 • Verfasst in ABAP® Core
2
Antw.
4795
Views
EXCEL Export aus SAP mit Excel 2003 / 2007
von hfahrian » 03.02.2014 11:34 • Verfasst in ABAP Objects®
3
Antw.
1484
Views
SAP --> Excel
von supermario73 » 12.08.2008 15:33 • Verfasst in ABAP® Core
0
Antw.
994
Views
Excel
von Nadine_2706 » 25.09.2012 09:40 • Verfasst in ABAP® für Anfänger
8
Antw.
6791
Views
Excel und SAP
von Possy » 11.07.2007 11:24 • Verfasst in Material Management & Produktionsplanung

Über diesen Beitrag


Unterstütze die Community und teile den Beitrag für mehr Leser und Austausch

Newsletter Anmeldung

Keine Beiträge verpassen! Wöchentlich versenden wir lesenwerte Beiträge aus unserer Community.
Die letzte Ausgabe findest du hier.
Details zum Versandverfahren und zu Ihren Widerrufsmöglichkeiten findest du in unserer Datenschutzerklärung.