SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Material comparison between two plants



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
vga
Мастер
Мастер


Age: 48
Joined: 04 Oct 2007
Posts: 1218
Location: Питер

PostPosted: Sat Nov 29, 2008 4:36 pm    Post subject: Material comparison between two plants Reply with quote

Code:
 *------------------------------------------------- --------------------*
  Report ZMMATVER * *
  *------------------------------------------------- --------------------*
  * Created 12.06.2003 Thorsten Neubüser, www.4ap.de
  *
  * Developed under 3.1I
  * Also tested at 4.6C, 4.7
  * Under 4.7 must be highly comma be defined differently if Unicode system
  * Then goes but also a different dynamic table generation ;-))
  *
  * Based on a sample material, the differences on the
  * Hereafter to be selected materials angelistet
  * Which fields are compared in the form of routines (eg
  * Mara_felder_ausblenden) defines
  * Branching into the MM02 in line select
  * Download the data to Excel for manual sorting / Care
  *
  * This download can then manually editing in another
  * ABAP on the remaining MATERIAL_MAINTAIN_DARK not wanted
  * Differences
  *
  * The report uses an own-status pf 'Z_PICK'.  A copy
  * Of the 'PICK' from SAPMSSY0 supplemented by pushbutton for Excel download
  * Function code PF5 = = EXCL Excel Download
  *
  * It is the message class ZP with the error (000) needed.
  * It is defined as' & 1 & 2 & 3 & 4 '
  *
  * The tables J_ are only included in the cable_solution
  * You can be deleted.
  *
  *------------------------------------------------- --------------------*
REPORT  ZMMATVER LINE-SIZE 240 LINE-COUNT 65.

* DATENDEKLARATIONEN
TABLES:
  MARAV,          " Materialstamm Konzern, der View enthält maktx!
  MARC,           " Materialstamm Werk
  MVKE,           " Materialstamm: Verkaufsdaten
  MBEW,           " Materialbewertung
  EINA,           " Einkaufsinfosatz - allgemeine Daten
  EINE,           " Einkaufsinfosatz - Einkaufsorganisationsdaten
  J_1NE,          " CS: Materialien auf VKORG-Ebene mit NE-Schlüsseln
  J_1NEMM.        " CS: Materialien auf Werks-Ebene mit NE-Schlüsseln


* Materialliste für zu vergleichende Materialien
DATA:
  BEGIN OF MAT_LISTE OCCURS 0,
    MATNR LIKE MARAV-MATNR,
    WERKS LIKE MARC-WERKS,
    MAKTX LIKE MARAV-MAKTX,
  END OF MAT_LISTE.

* Felder für Vergleich
  TABLES: DD03L,                      " Tabellenfelder
          DD04T.                      " R/3-DD: Texte der Datenelemente
  DATA:
    BEGIN OF ITAB_FELDER OCCURS 0,
      TABNAME   LIKE DD03L-TABNAME,
      FIELDNAME LIKE DD03L-FIELDNAME,
      ROLLNAME  LIKE DD03L-ROLLNAME,
      SCRTEXT_L LIKE DD04T-SCRTEXT_M, " C20mittellang. Schlüsselwort
    END   OF ITAB_FELDER,
    MARA_FELDER     LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE,
    MARC_FELDER     LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE,
    MVKE_FELDER     LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE,
    MBEW_FELDER     LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE,
    EINE_FELDER     LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE,
    J_1NE_FELDER    LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE,
    J_1NEMM_FELDER  LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE,
    EK_TXT_FELDER   LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE,
* Struktur für Excel-Download
    XLS_STRUC LIKE ITAB_FELDER OCCURS 0 WITH HEADER LINE.

* Einzelvergleich für bestimmte Felder
FIELD-SYMBOLS: <TABNAME>, <FIELDNAME>, <SCRTEXT_L>,
               <MAT_A_FIELD>, <MAT_B_FIELD>,
               <TABNAME_FIELDNAME>, <TABELLE_FELD>,
               <FELDWERT>.
DATA: FELDNAME(20).           " 'marc' + 10 Char

* Strukturen für Vergleich
DATA:
  WA_MARA_M LIKE MARAV,   " Workarea MARA Muster
  WA_MARA_V LIKE MARAV,   " Workarea MARA Vergleich
  WA_MARC_M LIKE MARC,
  WA_MARC_V LIKE MARC,
  WA_MVKE_M LIKE MVKE,
  WA_MVKE_V LIKE MVKE,
  WA_MBEW_M LIKE MBEW,
  WA_MBEW_V LIKE MBEW,
  BEGIN OF WA_EINE_M,
    LFDNR TYPE I,
    LIFNR LIKE EINA-LIFNR,
    MATNR LIKE EINA-MATNR.
    INCLUDE STRUCTURE EINE.
DATA:
  END OF WA_EINE_M,
*  wa_eine_m like eine,
  WA_EINE_V LIKE WA_EINE_M,
  WA_J_1NE_M LIKE J_1NE,
  WA_J_1NE_V LIKE J_1NE,
  WA_J_1NEMM_M LIKE J_1NEMM,
  WA_J_1NEMM_V LIKE J_1NEMM.

* Hilfsfelder, Textpositionen der Ausgabe
DATA:
  LINES_EK_M LIKE SY-TFILL,
  LINES_EK_V LIKE SY-TFILL,
*  sy_tabix like sy-tabix,
  TP(3) VALUE '005', " Textposition
  PM(3) VALUE '055', " Position Muster
  PV(3) VALUE '100'. " Position Vergleichswert

* dynamische Generierung eines temporären Unterprogrammes
*  unter 3.1i ist das leider ein wenig umständlich (Subroutinepool)
  DATA: TABNAME_FIELDNAME(21), TABELLE_FELD(21).
  DATA: CODE(72) OCCURS 100 WITH HEADER LINE,
        CODE2(72), HOCHKOMMA TYPE X VALUE '27', " hex27 = dec39 = '
        PROG(8), MSG(120), LIN(3), WRD(10), OFF(3).

* Einkaufsbestelltexte
DATA: EK_TXT_ID LIKE THEAD-TDID,
      EK_TXT_LANGU LIKE THEAD-TDSPRAS,
      EK_TXT_NAME LIKE THEAD-TDNAME,
      EK_TXT_OBJECT LIKE THEAD-TDOBJECT,
      EK_TEXT_ZEILE LIKE SY-TABIX,
      BEGIN OF EK_TEXT_M OCCURS 0.
        INCLUDE STRUCTURE TLINE.    " tdformat  tdline
DATA: END OF EK_TEXT_M,
      BEGIN OF EK_TEXT_V OCCURS 0.
        INCLUDE STRUCTURE EK_TEXT_M.
DATA: END OF EK_TEXT_V.



* SELEKTIONSBILDSCHIRM
SELECTION-SCREEN BEGIN OF BLOCK MUSTER
    WITH FRAME TITLE TEXT-001. " 'Mustermaterial / Vorlage:'
  PARAMETERS:
    P_MATNR LIKE MARAV-MATNR OBLIGATORY,
    P_WERKS LIKE MARC-WERKS OBLIGATORY,
    P_LANGU LIKE SY-LANGU OBLIGATORY DEFAULT SY-LANGU,
    P_BWKEY LIKE MBEW-BWKEY,
    P_BWTAR LIKE MBEW-BWTAR,
    P_VKORG LIKE MVKE-VKORG OBLIGATORY,
    P_VTWEG LIKE MVKE-VTWEG OBLIGATORY,
    P_LIFNR LIKE EINA-LIFNR OBLIGATORY MATCHCODE OBJECT KRED,
    P_EKORG LIKE EINE-EKORG OBLIGATORY DEFAULT '0001',
    P_ESOKZ LIKE EINE-ESOKZ OBLIGATORY DEFAULT '0',
    P_J1NNES LIKE J_1NE-J_1NNES OBLIGATORY DEFAULT '001'.
SELECTION-SCREEN END OF BLOCK MUSTER.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN BEGIN OF BLOCK AUSWAHL WITH FRAME TITLE TEXT-002.
  "  'Auswahl / Eingrenzung der zu überprüfenden Materialien'.
  SELECT-OPTIONS:
    S_MATNR FOR MARAV-MATNR,      " Materialnummer
    S_WERKS FOR MARC-WERKS,       " Werk
    S_MAKTX FOR MARAV-MAKTX,      " Materialkurztext
    S_MATKL FOR MARAV-MATKL,      " Warengruppe
    S_MTART FOR MARAV-MTART,      " Materialart
    S_PRDHA FOR MARAV-PRDHA,      " Produkthierarchie
    S_SPART FOR MARAV-SPART.      " Sparte
SELECTION-SCREEN END OF BLOCK AUSWAHL.

PARAMETERS:
  P_LISTEN,             " Anlisten der Vergleichsfelder?
  P_ZEIGID DEFAULT '',  " zeigt völlig idente Materialien an
  P_DETAIL DEFAULT 'X', " führt Detailvergleich durch
  P_EKTEXT DEFAULT '',  " listet die Einkaufsbestelltexte an
  P_FILENM LIKE RLGRAP-FILENAME.


INITIALIZATION.
* Dateinamen für Excel-Download vorbelegen
*  concatenate 'c:\' sy-repid '_' sy-datum '_' sy-uzeit '.XLS'
  CONCATENATE 'c:\' SY-REPID '_' SY-DATUM '_' SY-UZEIT '.txt'
    INTO P_FILENM.



* ES GEHT LOS!
START-OF-SELECTION.
* 'PICK' aus SAPMSSY0 ergänzt um Drucktaste für Excel-Download
  SET PF-STATUS 'Z_PICK'.
* zu vergleichende Materialien in itab mat_liste
  PERFORM MATERIALLISTE.

* diverse Feldlisten erstellen
  PERFORM FELDER_HOLEN TABLES MARA_FELDER USING 'MARAV'.
  PERFORM FELDER_HOLEN TABLES MARC_FELDER USING 'MARC'.
  PERFORM FELDER_HOLEN TABLES MVKE_FELDER USING 'MVKE'.
  PERFORM FELDER_HOLEN TABLES MBEW_FELDER USING 'MBEW'.
  PERFORM FELDER_HOLEN TABLES EINE_FELDER USING 'EINE'.
  PERFORM FELDER_HOLEN TABLES J_1NE_FELDER USING 'J_1NE'.
  PERFORM FELDER_HOLEN TABLES J_1NEMM_FELDER USING 'J_1NEMM'.
* Einkaufstexte
  PERFORM EX_TXT_FELDER TABLES EK_TXT_FELDER.

* nicht benötigte Felder ausblenden
*  hier wird entschieden welche Felder überhaupt verglichen werden!
  PERFORM MARA_FELDER_AUSBLENDEN.
  PERFORM MARC_FELDER_AUSBLENDEN.
  PERFORM MVKE_FELDER_AUSBLENDEN.
  PERFORM MBEW_FELDER_AUSBLENDEN.
  PERFORM EINE_FELDER_AUSBLENDEN.
  PERFORM J_1NE_FELDER_AUSBLENDEN.
  PERFORM J_1NEMM_FELDER_AUSBLENDEN.
  PERFORM EX_TXT_FELDER_AUSBLENDEN.

* Struktur Excel-Tabelle anlegen
*  da das unter 3.1i noch nicht anders geht, wird ein
*  'PROGRAM SUBPOOL' verwendet. Auch beide Kopfzeilen werden geschrieben
*  im 'perform ausgabe_xls_itab' wird das Programm dann gestartet
  PERFORM CREATE_XLS_ITAB.

* zu Materialdaten des Mustermaterials holen
  PERFORM MUSTERMATERIALDATEN_HOLEN.
  IF NOT P_EKTEXT IS INITIAL.
    PERFORM MUSTER_EINKAUFSBESTELLTEXT.
  ENDIF.
  PERFORM MUSTERDATEN_XLS_ITAB.

* Vergleich aller selektierten Materialien
  LOOP AT MAT_LISTE.
    WRITE: / 'Mustermaterial / Vorlage:'(001), P_MATNR,
             'Werk:'(004), P_WERKS,
             'Materialkurztext:'(017), WA_MARA_M-MAKTX.
    FORMAT HOTSPOT ON COLOR 5 INVERSE ON.
    WRITE: / 'Vergleich mit Material  :'(003), MAT_LISTE-MATNR,
             'Werk:'(004), MAT_LISTE-WERKS,
             'Materialkurztext:'(017), MAT_LISTE-MAKTX.
    FORMAT HOTSPOT OFF COLOR OFF INVERSE OFF.

    PERFORM MARA_VERGLEICHEN.
* unter 3.1i leider nicht verfügbar: CREATE DATA dref TYPE type.
*  sonst könnte man das Ganze dynamisch aufrufen, so leider jede
*  Tabelle einzeln
    PERFORM MARC_VERGLEICHEN.
    PERFORM MVKE_VERGLEICHEN.
    PERFORM MBEW_VERGLEICHEN.
    PERFORM EINE_VERGLEICHEN.
    PERFORM J_1NE_VERGLEICHEN.
    PERFORM J_1NEMM_VERGLEICHEN.
    IF NOT P_EKTEXT IS INITIAL.
      PERFORM EINKAUFSBESTELLTEXTE.
    ENDIF. " not p_ektext is initial
    ULINE.
    IF NOT P_DETAIL IS INITIAL. " Detailvergleich durchgeführt
      APPEND 'APPEND XLS_ITAB.' TO CODE.
      APPEND '*' TO CODE.
    ENDIF. " not p_detail is initial. " Detailvergleich durchgeführt
  ENDLOOP. " at mat_liste


* Ausdrucken der Vergleichsfelder
  IF NOT P_LISTEN IS INITIAL.
    PERFORM DRUCK_FELDER.
  ENDIF. " not p_listen is initial


* FERTIG
END-OF-SELECTION.

ULINE.
WRITE : / '** Listende **'(099).


AT USER-COMMAND.
  CASE SY-UCOMM.
    WHEN 'EXCL'.
      IF P_DETAIL IS INITIAL.
        MESSAGE I000(ZP) WITH
          'Bitte Detailvergleich durchführen.'(022).
        PERFORM AUSGABE_XLS_ITAB.
      ELSE.
        PERFORM AUSGABE_XLS_ITAB.
      ENDIF.
    WHEN OTHERS.
    ENDCASE.

* auch bei Auswahl eines Hotspots
AT LINE-SELECTION.
  IF SY-LISEL(9) = 'VERGLEICH'.
    SET PARAMETER: ID 'MAT' FIELD SY-LISEL+26(18),
                   ID 'WRK' FIELD SY-LISEL+51(4),
                   ID 'BWT' FIELD P_BWTAR,
                   ID 'VKO' FIELD P_VKORG,
                   ID 'VTW' FIELD P_VTWEG.
    CALL TRANSACTION 'MM02'.
  ENDIF. "sy-lisel(9) = 'VERGLEICH'




* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*
* AB HIE NUR NOCH FORM-ROUTINEN
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*


*---------------------------------------------------------------------*
*      Form  MATERIALLISTE
*---------------------------------------------------------------------*
FORM MATERIALLISTE.
* Alle zu prüfenden Materialien besorgen
  SELECT   MARAV~MATNR
           MARC~WERKS
           MARAV~MAKTX
         FROM MARAV INNER JOIN MARC
           ON MARAV~MATNR = MARC~MATNR
         INTO   CORRESPONDING FIELDS OF TABLE MAT_LISTE
         WHERE  MARAV~MATNR IN S_MATNR
         AND    MARC~WERKS  IN S_WERKS
         AND    MARAV~MAKTX IN S_MAKTX
         AND    MARAV~SPRAS = P_LANGU
         AND    MARAV~MATKL IN S_MATKL
         AND    MARAV~MTART IN S_MTART
         AND    MARAV~PRDHA IN S_PRDHA
         AND    MARAV~SPART IN S_SPART.
ENDFORM.                    " MATERIALLISTE


*---------------------------------------------------------------------*
*      Form  FELDER_HOLEN
*---------------------------------------------------------------------*
*       liest die Felder der Datenbanktabelle aus
*----------------------------------------------------------------------*
*      -->ITAB_FELDER  interne Tabelle für Feldnamen
*      -->tabelle      Name der transparenten Tabelle
*----------------------------------------------------------------------*
FORM FELDER_HOLEN TABLES ITAB_FELDER LIKE ITAB_FELDER[]
                  USING  TABELLE.
  SELECT DD03L~TABNAME DD03L~FIELDNAME DD03L~ROLLNAME
         DD04T~SCRTEXT_L
         FROM  DD03L INNER JOIN DD04T
           ON DD04T~ROLLNAME = DD03L~ROLLNAME
           AND DD04T~DDLANGUAGE = P_LANGU
         INTO CORRESPONDING FIELDS OF TABLE ITAB_FELDER
         WHERE  DD03L~TABNAME  =  TABELLE
         AND    DD03L~ROLLNAME NE ''.
  IF SY-SUBRC NE 0.
    MESSAGE I000(ZP) WITH 'Form "felder_holen" fehlgeschlagen'(008)
                          TABELLE.
  ENDIF.
  SORT ITAB_FELDER BY FIELDNAME.
ENDFORM.                    " FELDER_HOLEN


*---------------------------------------------------------------------*
*      Form  EX_TXT_FELDER
*---------------------------------------------------------------------*
FORM EX_TXT_FELDER TABLES ITAB_FELDER LIKE ITAB_FELDER[].
*      tabname   like dd03l-tabname,
*      fieldname like dd03l-fieldname,
*      rollname  like dd03l-rollname,
*      scrtext_l like dd04t-scrtext_m, " C20mittellang. Schlüsselwort
  CLEAR ITAB_FELDER. REFRESH ITAB_FELDER.
  ITAB_FELDER-TABNAME   = 'EK_TXT'.
  ITAB_FELDER-FIELDNAME = 'TDFORMAT'.
  ITAB_FELDER-ROLLNAME  = 'TDFORMAT'.
  ITAB_FELDER-SCRTEXT_L = 'EK-TXT Format Zeile1'.
  APPEND ITAB_FELDER.
  ITAB_FELDER-TABNAME   = 'EK_TXT'.
  ITAB_FELDER-FIELDNAME = 'LINE_ANZ'.
  ITAB_FELDER-ROLLNAME  = 'LINE_ANZ'.
  ITAB_FELDER-SCRTEXT_L = 'EK-TXT Anzahl Zeilen'.
  APPEND ITAB_FELDER.
  ITAB_FELDER-TABNAME   = 'EK_TXT'.
  ITAB_FELDER-FIELDNAME = 'TDLINE'.
  ITAB_FELDER-ROLLNAME  = 'TDLINE'.
  ITAB_FELDER-SCRTEXT_L = 'EK-TXT Line Zeile 1'.
  APPEND ITAB_FELDER.
ENDFORM.                    " EX_TXT_FELDER


*---------------------------------------------------------------------*
*      Form  MARA_FELDER_AUSBLENDEN
*---------------------------------------------------------------------*
FORM MARA_FELDER_AUSBLENDEN.
* unnötige Felder entfernen
  LOOP AT MARA_FELDER WHERE
       (
          FIELDNAME NE 'MTART'    " Materialart
      AND FIELDNAME NE 'LVORM'    " Löschvormerkung
      AND FIELDNAME NE 'MATKL'    " Warengruppe
      AND FIELDNAME NE 'PRDHA'    " Produkthierarchie
      AND FIELDNAME NE 'XCHPF'    " Chargenpflicht
      AND FIELDNAME NE 'EKWSL'    " Einkaufswerteschl.
      AND FIELDNAME NE 'SPART'    " Sparte
*      and fieldname ne ''    "
                               ).
    DELETE MARA_FELDER.
  ENDLOOP. " at mara_felder where
* sonderhandlung Texte mara_felder
  LOOP AT MARA_FELDER.
    CASE MARA_FELDER-FIELDNAME.
      WHEN 'LVORM'.
        MARA_FELDER-SCRTEXT_L = 'Lösch-VM Material'.
        MODIFY MARA_FELDER.
      WHEN 'XCHPF'.
        MARA_FELDER-SCRTEXT_L = 'Chargenpflicht Material'.
        MODIFY MARA_FELDER.
    ENDCASE.
  ENDLOOP. " at mara_felder
  APPEND LINES OF MARA_FELDER TO XLS_STRUC.
ENDFORM.                    " MARA_FELDER_AUSBLENDEN


*---------------------------------------------------------------------*
*      Form  MARC_FELDER_AUSBLENDEN
*---------------------------------------------------------------------*
FORM MARC_FELDER_AUSBLENDEN.
* unnötige Felder entfernen
  LOOP AT MARC_FELDER WHERE
       (
          FIELDNAME NE 'LVORM'   " Löschvormerkung
      AND FIELDNAME NE 'LADGR'   " Ladegruppe
      AND FIELDNAME NE 'STAWN'   " Statistische Warennummer
      AND FIELDNAME NE 'HERKL'   " Herkunftsland
      AND FIELDNAME NE 'MTVER'   " Export(Importgruppe
      AND FIELDNAME NE 'EKGRP'   " Einkäufergruppe
      AND FIELDNAME NE 'MMSTA'   " MAT-/PPS-Status
      AND FIELDNAME NE 'XCHPF'   " Chargenpflicht Werksebene
      AND FIELDNAME NE 'DISMM'   " Dispomerkmal
      AND FIELDNAME NE 'DISPO'   " Disponent
      AND FIELDNAME NE 'DISLS'   " Dispolosgröße
      AND FIELDNAME NE 'BSTRF'   " Rundungswert
      AND FIELDNAME NE 'BESKZ'   " Beschaffungsart
      AND FIELDNAME NE 'SOBSL'   " Sonderbeschaffungsschlüssel
      AND FIELDNAME NE 'DZEIT'   " Eigenfertigungszeit
      AND FIELDNAME NE 'WEBAZ'   " WE-Baerb.Zeit
      AND FIELDNAME NE 'FHORI'   " Horizontschlüssel
      AND FIELDNAME NE 'PLIFZ'   " Planlieferzeit
*      and fieldname ne ''   "
                               ).
    DELETE MARC_FELDER.
  ENDLOOP. " at marc_felder where
* sonderhandlung Texte marc_felder
  LOOP AT MARC_FELDER.
    CASE MARC_FELDER-FIELDNAME.
      WHEN 'LVORM'.
        MARC_FELDER-SCRTEXT_L = 'Lösch-VM Werk'.
        MODIFY MARC_FELDER.
      WHEN 'XCHPF'.
        MARC_FELDER-SCRTEXT_L = 'Chargenpflicht Werk'.
        MODIFY MARC_FELDER.
    ENDCASE.
  ENDLOOP. " at marc_felder
  APPEND LINES OF MARC_FELDER TO XLS_STRUC.
ENDFORM.                    " MARC_FELDER_AUSBLENDEN


*---------------------------------------------------------------------*
*      Form  MVKE_FELDER_AUSBLENDEN
*---------------------------------------------------------------------*
FORM MVKE_FELDER_AUSBLENDEN.
* unnötige Felder entfernen
  LOOP AT MVKE_FELDER WHERE
       (
          FIELDNAME NE 'VKORG'    " Verkaufsorganisation
      AND FIELDNAME NE 'VTWEG'    " Vertriebsweg
      AND FIELDNAME NE 'DWERK'    " Auslieferungswerk
      AND FIELDNAME NE 'KONDM'    " Materialgruppe
      AND FIELDNAME NE 'MVGR2'    " Materialgruppe 2
*      and fieldname ne ''   "
                               ).
    DELETE MVKE_FELDER.
  ENDLOOP. " at mvke_felder where
  APPEND LINES OF MVKE_FELDER TO XLS_STRUC.
ENDFORM.                    " MVKE_FELDER_AUSBLENDEN


*---------------------------------------------------------------------*
*      Form  MBEW_FELDER_AUSBLENDEN
*---------------------------------------------------------------------*
FORM MBEW_FELDER_AUSBLENDEN.
* unnötige Felder entfernen
  LOOP AT MBEW_FELDER WHERE
       (
          FIELDNAME NE 'PEINH'    " Preiseinheit
      AND FIELDNAME NE 'STPRS'    " Standardpreis
*      and fieldname ne ''   "
                               ).
    DELETE MBEW_FELDER.
  ENDLOOP. " at mbew_felder where
  APPEND LINES OF MBEW_FELDER TO XLS_STRUC.
ENDFORM.                    " MBEW_FELDER_AUSBLENDEN


*---------------------------------------------------------------------*
*      Form  EINE_FELDER_AUSBLENDEN
*---------------------------------------------------------------------*
FORM EINE_FELDER_AUSBLENDEN.
* unnötige Felder entfernen
  LOOP AT EINE_FELDER WHERE
       (
          FIELDNAME NE 'NORBM'    " Normalmenge
      AND FIELDNAME NE 'MINBM'    " Mindestmenge
      AND FIELDNAME NE 'UNTTO'    " Toleranz Unterlieferung
      AND FIELDNAME NE 'UEBTO'    " Toleranz Überlieferung
      AND FIELDNAME NE 'MWSKZ'    " Materialkurztext
      AND FIELDNAME NE 'EKORG'    " Einkaufsorganisation
      AND FIELDNAME NE 'WERKS'    " Werk
*      and fieldname ne ''    "
                               ).
    DELETE EINE_FELDER.
  ENDLOOP. " at eine_felder where
* Sonderfelder für Einkaufsinfosatz BTCI einfügen
  EINE_FELDER-TABNAME   = 'EINE'.
  EINE_FELDER-FIELDNAME = 'MATNR'.
  EINE_FELDER-ROLLNAME  = 'MATNR'.
  EINE_FELDER-SCRTEXT_L = 'EKINFO Material'.
  INSERT EINE_FELDER INDEX 1.
  EINE_FELDER-FIELDNAME = 'LIFNR'.
  EINE_FELDER-ROLLNAME  = 'LIFNR'.
  EINE_FELDER-SCRTEXT_L = 'EKINFO Lieferant'.
  INSERT EINE_FELDER INDEX 1.
  EINE_FELDER-FIELDNAME = 'LFDNR'.
  EINE_FELDER-ROLLNAME  = 'LFDNR'.
  EINE_FELDER-SCRTEXT_L = 'EKINFO laufende Nr.'.
  INSERT EINE_FELDER INDEX 1.
* für Excel
  APPEND LINES OF EINE_FELDER TO XLS_STRUC.
ENDFORM.                    " EINE_FELDER_AUSBLENDEN


*---------------------------------------------------------------------*
*      Form  J_1NE_FELDER_AUSBLENDEN
*---------------------------------------------------------------------*
FORM J_1NE_FELDER_AUSBLENDEN.
* unnötige Felder entfernen
  LOOP AT J_1NE_FELDER WHERE
       (
          FIELDNAME NE 'J_1NVGW'    " NE Gewicht Vertrieb
*      and fieldname ne ''   "
                               ).
    DELETE J_1NE_FELDER.
  ENDLOOP. " at j_1ne_felder where
* sonderhandlung Texte j_1ne_felder
  LOOP AT J_1NE_FELDER.
    CASE J_1NE_FELDER-FIELDNAME.
      WHEN 'J_1NVGW'.
        J_1NE_FELDER-SCRTEXT_L = 'NE Gewicht Vertrieb'.
        MODIFY J_1NE_FELDER.
    ENDCASE.
  ENDLOOP. " at j_1ne_felder
  APPEND LINES OF J_1NE_FELDER TO XLS_STRUC.
ENDFORM.                    " J_1NE_FELDER_AUSBLENDEN


*---------------------------------------------------------------------*
*      Form  J_1NEMM_FELDER_AUSBLENDEN
*---------------------------------------------------------------------*
FORM J_1NEMM_FELDER_AUSBLENDEN.
* unnötige Felder entfernen
  LOOP AT J_1NEMM_FELDER WHERE
       (
          FIELDNAME NE 'J_1NVGW'    " NE Gewichte Einkauf
*      and fieldname ne ''   "
                               ).
    DELETE J_1NEMM_FELDER.
  ENDLOOP. " at j_1nemm_felder where
* sonderhandlung Texte j_1ne_felder
  LOOP AT J_1NEMM_FELDER.
    CASE J_1NEMM_FELDER-FIELDNAME.
      WHEN 'J_1NVGW'.
        J_1NEMM_FELDER-SCRTEXT_L = 'NE Gewicht Einkauf'.
        MODIFY J_1NEMM_FELDER.
    ENDCASE.
  ENDLOOP. " at j_1nemm_felder
  APPEND LINES OF J_1NEMM_FELDER TO XLS_STRUC.
ENDFORM.                    " J_1NEMM_FELDER_AUSBLENDEN


*---------------------------------------------------------------------*
*      Form  EX_TXT_FELDER_AUSBLENDEN
*---------------------------------------------------------------------*
FORM EX_TXT_FELDER_AUSBLENDEN.
* hier wird natürlich nur 'eingeblendet' :-))
  APPEND LINES OF EK_TXT_FELDER TO XLS_STRUC.
ENDFORM.                    " EX_TXT_FELDER_AUSBLENDEN


*---------------------------------------------------------------------*
*      Form  MUSTERMATERIALDATEN_HOLEN
*---------------------------------------------------------------------*
FORM MUSTERMATERIALDATEN_HOLEN.
  CLEAR: WA_MARC_M, WA_MARA_V, WA_MARC_M, WA_MARC_V,
         WA_MVKE_M, WA_MVKE_V, WA_MBEW_M, WA_MBEW_V,
         WA_EINE_M, WA_EINE_V, WA_J_1NE_M, WA_J_1NE_V,
         WA_J_1NEMM_M, WA_J_1NEMM_V.
    CLEAR MARAV.
    SELECT SINGLE *
           FROM   MARAV
           INTO   CORRESPONDING FIELDS OF WA_MARA_M
           WHERE  MATNR  = P_MATNR
           AND    SPRAS  = P_LANGU.
    IF SY-SUBRC NE 0.
      MESSAGE I000(ZP) WITH 'Musterdaten nicht gefunden!!'(019) 'MARAV'.
    ENDIF.
    CLEAR MARC.
    SELECT SINGLE *
           FROM   MARC
           INTO   CORRESPONDING FIELDS OF WA_MARC_M
           WHERE  MATNR  = P_MATNR
           AND    WERKS  = P_WERKS.
    IF SY-SUBRC NE 0.
      MESSAGE I000(ZP) WITH 'Musterdaten nicht gefunden!!'(019) 'MARC'.
    ENDIF.
    CLEAR MVKE.
    SELECT SINGLE *
           FROM   MVKE
           INTO   CORRESPONDING FIELDS OF WA_MVKE_M
           WHERE  MATNR  = P_MATNR
           AND    VKORG  = P_VKORG
           AND    VTWEG  = P_VTWEG.
    IF SY-SUBRC NE 0.
      MESSAGE I000(ZP) WITH 'Musterdaten nicht gefunden!!'(019) 'MVKE'.
*     dringend benötigte Felder in Excel-Download
      WA_MVKE_M-VKORG = P_VKORG.
      WA_MVKE_M-VTWEG = P_VTWEG.
    ENDIF.
*   wenn bwkey nicht gepflegt bwkey = werks
    IF P_BWKEY IS INITIAL.
      P_BWKEY = P_WERKS.
    ENDIF.
    CLEAR MBEW.
    SELECT SINGLE *
           FROM   MBEW
           INTO   CORRESPONDING FIELDS OF WA_MBEW_M
           WHERE  MATNR  = P_MATNR
           AND    BWKEY  = P_BWKEY
           AND    BWTAR  = P_BWTAR.
    IF SY-SUBRC NE 0.
      MESSAGE I000(ZP) WITH 'Musterdaten nicht gefunden!!'(019) 'MBEW'.
    ENDIF.
    CLEAR EINA.
    SELECT *
           FROM   EINA       CLIENT SPECIFIED
           WHERE  MATNR       = P_MATNR
           AND    LIFNR       = P_LIFNR.
*     es kann nur einen geben!  der erste Satz gilt.
      EXIT.
    ENDSELECT. " from eina
    IF SY-SUBRC NE 0.
      MESSAGE I000(ZP) WITH 'Musterdaten nicht gefunden!!'(019) 'EINA'.
    ENDIF.
    CLEAR EINE.
    SELECT SINGLE *
           FROM   EINE
           INTO   CORRESPONDING FIELDS OF WA_EINE_M
           WHERE  INFNR = EINA-INFNR
           AND    EKORG = P_EKORG
           AND    ESOKZ = P_ESOKZ
           AND    WERKS = P_WERKS.
    IF SY-SUBRC NE 0.
      MESSAGE I000(ZP) WITH 'Musterdaten nicht gefunden!!'(019) 'EINE'.
    ELSE.
      WA_EINE_M-LFDNR = 999.
      WA_EINE_M-LIFNR = P_LIFNR.
      WA_EINE_M-MATNR = P_MATNR.
    ENDIF.
    SELECT SINGLE *
           FROM   J_1NE
           INTO   CORRESPONDING FIELDS OF WA_J_1NE_M
           WHERE  KUNNR   = ''
           AND    J_1NMAT = P_MATNR
           AND    J_1NVKO = P_VKORG
           AND    J_1NNES = P_J1NNES.
    IF SY-SUBRC NE 0.
      MESSAGE I000(ZP) WITH 'Musterdaten nicht gefunden!!'(019) 'J_1NE'.
    ENDIF.
    SELECT * " single *
           FROM  J_1NEMM
           INTO   CORRESPONDING FIELDS OF WA_J_1NEMM_M
*           where  j_1nlif     = p_lifnr
           WHERE  J_1NMAT     = P_MATNR
*           and    j_1neko     = p_ekorg
           AND    J_1NWRK     = P_WERKS
           AND    J_1NNES     = P_J1NNES.
      EXIT. " Highlander-Prinzip (es kann nur einen geben)
    ENDSELECT.
    IF SY-SUBRC NE 0.
    MESSAGE I000(ZP) WITH 'Musterdaten nicht gefunden!!'(019) 'J_1NEMM'.
    ENDIF.
ENDFORM.                    " MUSTERMATERIALDATEN_HOLEN


*---------------------------------------------------------------------*
*      Form  DRUCK_FELDER
*---------------------------------------------------------------------*
FORM DRUCK_FELDER.
    SKIP 3.
    WRITE: / 'Es wurden folgende Felder verglichen:'(005).
    ULINE.
    WRITE: / 'Materialstamm Konzernebene [MARA]:'(006).
    LOOP AT MARA_FELDER.
      WRITE: / 'MARA-',
               MARA_FELDER-FIELDNAME,
*               mara_felder-rollname,
               MARA_FELDER-SCRTEXT_L.
    ENDLOOP. " at mara_felder
    SKIP.
    WRITE: / 'Materialstamm Werksebene [MARC]:'(007).
    LOOP AT MARC_FELDER.
      WRITE: / 'MARC-',
               MARC_FELDER-FIELDNAME,
*               marc_felder-rollname,
               MARC_FELDER-SCRTEXT_L.
    ENDLOOP. " at marc_felder
    SKIP.
    WRITE: / 'Materialstamm: Verkaufsdaten [MVKE]:'(009).
    LOOP AT MVKE_FELDER.
      WRITE: / 'MVKE-',
               MVKE_FELDER-FIELDNAME,
*               mvke_felder-rollname,
               MVKE_FELDER-SCRTEXT_L.
    ENDLOOP. " at mvke_felder
    SKIP.
    WRITE: / 'Materialbewertung [MBEW]:'(010).
    LOOP AT MBEW_FELDER.
      WRITE: / 'MBEW-',
               MBEW_FELDER-FIELDNAME,
*               mbew_felder-rollname,
               MBEW_FELDER-SCRTEXT_L.
    ENDLOOP. " at mbew_felder
    SKIP.
  WRITE: / 'Einkaufsinfosatz - Einkaufsorganisationsdaten [EINE]:'(011).
    LOOP AT EINE_FELDER.
      WRITE: / 'EINE-',
               EINE_FELDER-FIELDNAME,
*               eine_felder-rollname,
               EINE_FELDER-SCRTEXT_L.
    ENDLOOP. " at eine_felder
    SKIP.
    WRITE: /
      'CS: Materialien auf VKORG-Ebene mit NE-Schlüsseln [J_1NE]:'(012).
    LOOP AT J_1NE_FELDER.
      WRITE: / 'J_1NE-',
               J_1NE_FELDER-FIELDNAME,
*               j_1ne_felder-rollname,
               J_1NE_FELDER-SCRTEXT_L.
    ENDLOOP. " at j_1ne_felder
    SKIP.
    WRITE: /
    'CS: Materialien auf Werks-Ebene mit NE-Schlüsseln [J_1NEMM]:'(013).
    LOOP AT J_1NEMM_FELDER.
      WRITE: / 'J_1NEMM-',
               J_1NEMM_FELDER-FIELDNAME,
*               j_1nemm_felder-rollname,
               J_1NEMM_FELDER-SCRTEXT_L.
    ENDLOOP. " at j_1nemm_felder
ENDFORM.                    " DRUCK_FELDER


*---------------------------------------------------------------------*
*      Form  MARA_VERGLEICHEN
*---------------------------------------------------------------------*
FORM MARA_VERGLEICHEN.
*  wir befinden uns im 'loop at mat_liste'
*   Daten Vergleichmaterial beschaffen
    CLEAR: WA_MARA_V.
    SELECT SINGLE *
           FROM   MARAV
           INTO   CORRESPONDING FIELDS OF WA_MARA_V
           WHERE  MATNR = MAT_LISTE-MATNR
           AND    SPRAS = P_LANGU.
*   Werksdaten überschreiben!
    WA_MARA_V-MATNR = P_MATNR.
    IF WA_MARA_M EQ WA_MARA_V.
      IF NOT P_ZEIGID IS INITIAL.
        WRITE: / 'Material'(014), 'identisch.'(015), 'MARA',
                 '[MM02: Grunddatensicht, Einkauf; MM06]'(018).
      ENDIF. " not p_zeigid is initial
    ELSE. " wa_mara_m eq wa_mara_v
*     Werksinformation zurückschreiben
      WA_MARA_V-MATNR = MAT_LISTE-MATNR.
      WRITE: / 'Material'(014), 'ungleich.'(016), 'MARA',
      '[MM02: Grunddatensicht, Einkauf; MM06]'(018).
      IF NOT P_DETAIL IS INITIAL.

* Excel-Download
* Key-Daten schreiben.
  APPEND 'CLEAR XLS_ITAB.' TO CODE.
  CONCATENATE HOCHKOMMA WA_MARA_V-MATNR HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MATNR' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA MAT_LISTE-WERKS HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-WERKS' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA WA_MARA_V-MAKTX HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MAKTX' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.

        PERFORM MARA_DETAILVERGLEICH.
      ENDIF.
    ENDIF. " wa_mara_m eq wa_mara_v
ENDFORM.                    " MARA_VERGLEICHEN


*---------------------------------------------------------------------*
*      Form  MARA_DETAILVERGLEICH
*---------------------------------------------------------------------*
FORM MARA_DETAILVERGLEICH.
* Einzelvergleich für bestimmte Felder
  LOOP AT MARA_FELDER.
    ASSIGN MARA_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN MARA_FELDER-SCRTEXT_L TO <SCRTEXT_L>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MARA_M TO <MAT_A_FIELD>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MARA_V TO <MAT_B_FIELD>.
    IF <MAT_A_FIELD> NE <MAT_B_FIELD>.
      CONCATENATE 'mara-' <FIELDNAME> INTO FELDNAME.
      WRITE: AT /TP FELDNAME, <SCRTEXT_L>,
             AT PM <MAT_A_FIELD>.
      FORMAT COLOR 5 INVERSE ON.
        WRITE: AT PV <MAT_B_FIELD>.
      FORMAT COLOR OFF INVERSE OFF.
*     für Excel-Export
      ASSIGN MARA_FELDER-TABNAME TO <TABNAME>.
      ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MARA_V TO <FELDWERT>.
      PERFORM FELDZUWEISUNG_XLS_ITAB.
    ENDIF.
  ENDLOOP. " at mara_felder
  SKIP.
ENDFORM.                    " MARA_DETAILVERGLEICH


*---------------------------------------------------------------------*
*      Form  MARC_VERGLEICHEN
*---------------------------------------------------------------------*
FORM MARC_VERGLEICHEN.
*  wir befinden uns im 'loop at mat_liste'
*   Daten Vergleichmaterial beschaffen
    CLEAR: WA_MARC_V.
    SELECT SINGLE *
           FROM   MARC
           INTO   CORRESPONDING FIELDS OF WA_MARC_V
           WHERE  MATNR = MAT_LISTE-MATNR
           AND    WERKS = MAT_LISTE-WERKS.
*   Werksdaten überschreiben!
    WA_MARC_V-MATNR = P_MATNR.
    WA_MARC_V-WERKS = P_WERKS.
    IF WA_MARC_M EQ WA_MARC_V.
      IF NOT P_ZEIGID IS INITIAL.
        WRITE: / 'Material'(014), 'identisch.'(015), 'MARC',
'[MM02: Disposition 1 -  Einkauf - Vertrieb/allg.Werksdaten]'(023).
      ENDIF. " not p_zeigid is initial
    ELSE. " wa_marc_m eq wa_marc_v
*     Werksinformation zurückschreiben
      WA_MARC_V-MATNR = MAT_LISTE-MATNR.
      WA_MARC_V-WERKS = MAT_LISTE-WERKS.
      WRITE: / 'Material'(014), 'ungleich.'(016), 'MARC',
'[MM02: Disposition 1 -  Einkauf - Vertrieb/allg.Werksdaten]'(023).
      IF NOT P_DETAIL IS INITIAL.
        PERFORM MARC_DETAILVERGLEICH.
      ENDIF.
    ENDIF. " wa_marc_m eq wa_marc_v
ENDFORM.                    " MARC_VERGLEICHEN


*---------------------------------------------------------------------*
*      Form  MARC_DETAILVERGLEICH
*---------------------------------------------------------------------*
FORM MARC_DETAILVERGLEICH.
* Einzelvergleich für bestimmte Felder
  LOOP AT MARC_FELDER WHERE FIELDNAME NE 'WERKS'.
    ASSIGN MARC_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN MARC_FELDER-SCRTEXT_L TO <SCRTEXT_L>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MARC_M TO <MAT_A_FIELD>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MARC_V TO <MAT_B_FIELD>.
    IF <MAT_A_FIELD> NE <MAT_B_FIELD>.
      CONCATENATE 'marc-' <FIELDNAME> INTO FELDNAME.
      WRITE: AT /TP FELDNAME, <SCRTEXT_L>,
             AT PM <MAT_A_FIELD>.
      FORMAT COLOR 5 INVERSE ON.
        WRITE: AT PV <MAT_B_FIELD>.
      FORMAT COLOR OFF INVERSE OFF.
*     für Excel-Export
      ASSIGN MARC_FELDER-TABNAME   TO <TABNAME>.
      ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MARC_V TO <FELDWERT>.
      PERFORM FELDZUWEISUNG_XLS_ITAB.
    ENDIF.
  ENDLOOP. " at marc_felder
  SKIP.
ENDFORM.                    " MARC_DETAILVERGLEICH


*---------------------------------------------------------------------*
*      Form  MVKE_VERGLEICHEN
*---------------------------------------------------------------------*
FORM MVKE_VERGLEICHEN.
*  wir befinden uns im 'loop at mat_liste'
*   Daten Vergleichmaterial beschaffen
    CLEAR: WA_MVKE_V.
    SELECT SINGLE *
           FROM   MVKE
           INTO   CORRESPONDING FIELDS OF WA_MVKE_V
           WHERE  MATNR = MAT_LISTE-MATNR
           AND    VKORG = P_VKORG
           AND    VTWEG = P_VTWEG.
*   Werksdaten überschreiben!
    WA_MVKE_V-MATNR = P_MATNR.
    IF WA_MVKE_M EQ WA_MVKE_V.
      IF NOT P_ZEIGID IS INITIAL.
        WRITE: / 'Material'(014), 'identisch.'(015), 'MVKE',
                 '[MM02: Vertrieb Verkaufsorgdaten]'(024).
      ENDIF. " not p_zeigid is initial
    ELSE. " wa_mvke_m eq wa_mvke_v
*     Werksinformation zurückschreiben
      WA_MVKE_V-MATNR = MAT_LISTE-MATNR.
      WRITE: / 'Material'(014), 'ungleich.'(016), 'MVKE',
               '[MM02: Vertrieb Verkaufsorgdaten]'(024).
      IF NOT P_DETAIL IS INITIAL.
        PERFORM MVKE_DETAILVERGLEICH.
      ENDIF.
    ENDIF. " wa_mvke_m eq wa_mvke_v
ENDFORM.                    " MVKE_VERGLEICHEN


*---------------------------------------------------------------------*
*      Form  MVKE_DETAILVERGLEICH
*---------------------------------------------------------------------*
FORM MVKE_DETAILVERGLEICH.
* Einzelvergleich für bestimmte Felder
  LOOP AT MVKE_FELDER WHERE FIELDNAME NE 'WERKS'.
    ASSIGN MVKE_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN MVKE_FELDER-SCRTEXT_L TO <SCRTEXT_L>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MVKE_M TO <MAT_A_FIELD>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MVKE_V TO <MAT_B_FIELD>.
    IF ( <MAT_A_FIELD> NE <MAT_B_FIELD> )
       OR MVKE_FELDER-FIELDNAME = 'VKORG'   " immer übermitteln da
       OR MVKE_FELDER-FIELDNAME = 'VTWEG'.  " Keyfeld für ZMMATHAR
      CONCATENATE 'mvke-' <FIELDNAME> INTO FELDNAME.
      WRITE: AT /TP FELDNAME, <SCRTEXT_L>,
             AT PM <MAT_A_FIELD>.
      FORMAT COLOR 5 INVERSE ON.
        WRITE: AT PV <MAT_B_FIELD>.
      FORMAT COLOR OFF INVERSE OFF.
*     für Excel-Export
      ASSIGN MVKE_FELDER-TABNAME TO <TABNAME>.
      ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MVKE_V TO <FELDWERT>.
      PERFORM FELDZUWEISUNG_XLS_ITAB.
    ENDIF.
  ENDLOOP. " at mvke_felder
  SKIP.
ENDFORM.                    " MVKE_DETAILVERGLEICH


*---------------------------------------------------------------------*
*      Form  MBEW_VERGLEICHEN
*---------------------------------------------------------------------*
FORM MBEW_VERGLEICHEN.
*  wir befinden uns im 'loop at mat_liste'
*   Daten Vergleichmaterial beschaffen
    CLEAR: WA_MBEW_V.
    SELECT SINGLE *
           FROM   MBEW
           INTO   CORRESPONDING FIELDS OF WA_MBEW_V
           WHERE  MATNR = MAT_LISTE-MATNR
           AND    BWKEY = P_BWKEY
           AND    BWTAR = P_BWTAR.
*   Werksdaten überschreiben!
    WA_MBEW_V-MATNR = P_MATNR.
    IF WA_MBEW_M EQ WA_MBEW_V.
      IF NOT P_ZEIGID IS INITIAL.
        WRITE: / 'Material'(014), 'identisch.'(015), 'MBEW',
               '[MM02: Buchhaltung oder Kalkulation]'(025).
      ENDIF. " not p_zeigid is initial
    ELSE. " wa_mbew_m eq wa_mbew_v
*     Werksinformation zurückschreiben
      WA_MBEW_V-MATNR = MAT_LISTE-MATNR.
      WRITE: / 'Material'(014), 'ungleich.'(016), 'MBEW',
               '[MM02: Buchhaltung oder Kalkulation]'(025).
      IF NOT P_DETAIL IS INITIAL.
        PERFORM MBEW_DETAILVERGLEICH.
      ENDIF.
    ENDIF. " wa_mbew_m eq wa_mbew_v
ENDFORM.                    " MBEW_VERGLEICHEN


*---------------------------------------------------------------------*
*      Form  MBEW_DETAILVERGLEICH
*---------------------------------------------------------------------*
FORM MBEW_DETAILVERGLEICH.
* Einzelvergleich für bestimmte Felder
  LOOP AT MBEW_FELDER WHERE FIELDNAME NE 'WERKS'.
    ASSIGN MBEW_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN MBEW_FELDER-SCRTEXT_L TO <SCRTEXT_L>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MBEW_M TO <MAT_A_FIELD>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MBEW_V TO <MAT_B_FIELD>.
    IF <MAT_A_FIELD> NE <MAT_B_FIELD>.
      CONCATENATE 'mbew-' <FIELDNAME> INTO FELDNAME.
      WRITE: AT /TP FELDNAME, <SCRTEXT_L>,
             AT PM <MAT_A_FIELD>.
      FORMAT COLOR 5 INVERSE ON.
        WRITE: AT PV <MAT_B_FIELD>.
      FORMAT COLOR OFF INVERSE OFF.
*     für Excel-Export
      ASSIGN MBEW_FELDER-TABNAME   TO <TABNAME>.
      ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MBEW_V TO <FELDWERT>.
      PERFORM FELDZUWEISUNG_XLS_ITAB.
    ENDIF.
  ENDLOOP. " at mbew_felder
  SKIP.
ENDFORM.                    " MBEW_DETAILVERGLEICH


*---------------------------------------------------------------------*
*      Form  EINE_VERGLEICHEN
*---------------------------------------------------------------------*
FORM EINE_VERGLEICHEN.
*  wir befinden uns im 'loop at mat_liste'
*   Daten Vergleichmaterial beschaffen
    CLEAR: WA_EINE_V, EINA, EINE.
    SELECT *
           FROM  EINA       CLIENT SPECIFIED
           WHERE  MATNR       = MAT_LISTE-MATNR
           AND    LIFNR       = P_LIFNR.
*     es kann nur einen geben!  der erste Satz gilt.
      EXIT.
    ENDSELECT. " from eina
    IF SY-SUBRC NE 0.
      EXIT.
    ENDIF.
    SELECT SINGLE *
           FROM   EINE
           INTO   CORRESPONDING FIELDS OF WA_EINE_V
           WHERE  INFNR = EINA-INFNR
           AND    EKORG = P_EKORG
           AND    ESOKZ = P_ESOKZ
           AND    WERKS = MAT_LISTE-WERKS.
    IF SY-SUBRC NE 0.
      EXIT.
    ENDIF.
*   Werksdaten überschreiben!
    WA_EINE_V-LFDNR = WA_EINE_M-LFDNR.
    WA_EINE_V-LIFNR = P_LIFNR.
    WA_EINE_V-MATNR = P_MATNR.
    WA_EINE_V-WERKS = P_WERKS.
    IF WA_EINE_M EQ WA_EINE_V.
      IF NOT P_ZEIGID IS INITIAL.
        WRITE: / 'Material'(014), 'identisch.'(015), 'EINE',
         '[ME12: Einkaufsinfosatz ändern -> Einkaufsorgdaten]'(026).
      ENDIF. " not p_zeigid is initial
    ELSE. " wa_eine_m eq wa_eine_v
*     Werksinformation zurückschreiben
      WRITE: / 'Material'(014), 'ungleich.'(016), 'EINE',
       '[ME12: Einkaufsinfosatz ändern -> Einkaufsorgdaten]'(026).
      IF NOT P_DETAIL IS INITIAL.
*       damit Daten weggesichert werden
        CLEAR: WA_EINE_M-LIFNR, WA_EINE_M-MATNR,
               WA_EINE_M-EKORG, WA_EINE_M-WERKS.
        WA_EINE_V-MATNR = MAT_LISTE-MATNR.
        WA_EINE_V-WERKS = MAT_LISTE-WERKS.
        PERFORM EINE_DETAILVERGLEICH.
      ENDIF.
    ENDIF. " wa_marc_m eq wa_marc_v
    WA_EINE_M-LIFNR = P_LIFNR.
    WA_EINE_M-MATNR = P_MATNR.
ENDFORM.                    " EINE_VERGLEICHEN


*---------------------------------------------------------------------*
*      Form  EINE_DETAILVERGLEICH
*---------------------------------------------------------------------*
FORM EINE_DETAILVERGLEICH.
* Einzelvergleich für bestimmte Felder
  LOOP AT EINE_FELDER.
    ASSIGN EINE_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN EINE_FELDER-SCRTEXT_L TO <SCRTEXT_L>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_EINE_M TO <MAT_A_FIELD>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_EINE_V TO <MAT_B_FIELD>.
    IF <MAT_A_FIELD> NE <MAT_B_FIELD>.
      CONCATENATE 'eine-' <FIELDNAME> INTO FELDNAME.
* diese Felder werden IMMER exportiert, da in ZMMATHAR benötigt
      IF <FIELDNAME> NE 'WERKS' AND <FIELDNAME> NE 'EKORG'
         AND <FIELDNAME> NE 'MATNR' AND <FIELDNAME> NE 'LIFNR'.
        WRITE: AT /TP FELDNAME, <SCRTEXT_L>,
               AT PM <MAT_A_FIELD>.
        FORMAT COLOR 5 INVERSE ON.
          WRITE: AT PV <MAT_B_FIELD>.
        FORMAT COLOR OFF INVERSE OFF.
      ENDIF. " <fieldname> ne 'WERKS' or <fieldname> ne 'VKORG'
*     für Excel-Export
      ASSIGN EINE_FELDER-TABNAME   TO <TABNAME>.
      ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_EINE_V TO <FELDWERT>.
      PERFORM FELDZUWEISUNG_XLS_ITAB.
    ENDIF.
  ENDLOOP. " at eine_felder
  SKIP.
ENDFORM.                    " EINE_DETAILVERGLEICH


*---------------------------------------------------------------------*
*      Form  J_1NE_VERGLEICHEN
*---------------------------------------------------------------------*
FORM J_1NE_VERGLEICHEN.
*  wir befinden uns im 'loop at mat_liste'
*   Daten Vergleichmaterial beschaffen
    CLEAR: WA_J_1NE_V.
    SELECT SINGLE *
           FROM   J_1NE
           INTO   CORRESPONDING FIELDS OF WA_J_1NE_V
           WHERE  KUNNR   = ''
           AND    J_1NMAT = MAT_LISTE-MATNR
           AND    J_1NVKO = P_VKORG
           AND    J_1NNES = P_J1NNES.
*   Materialdaten überschreiben!
    WA_J_1NE_V-J_1NMAT = P_MATNR.
    IF WA_J_1NE_M EQ WA_J_1NE_V.
      IF NOT P_ZEIGID IS INITIAL.
        WRITE: / 'Material'(014), 'identisch.'(015), 'J_1NE',
         '[MM02: Zusätze -> NE Gewichte Vertrieb]'(027).
      ENDIF. " not p_zeigid is initial
    ELSE. " wa_j_1ne_m eq wa_j_1ne_v
*     Werksinformation zurückschreiben
      WA_J_1NE_V-J_1NMAT = MAT_LISTE-MATNR.
      WRITE: / 'Material'(014), 'ungleich.'(016), 'J_1NE',
         '[MM02: Zusätze -> NE Gewichte Vertrieb]'(027).
      IF NOT P_DETAIL IS INITIAL.
        PERFORM J_1NE_DETAILVERGLEICH.
      ENDIF.
    ENDIF. " wa_j_1ne_m eq wa_j_1ne_v
ENDFORM.                    " J_1NE_VERGLEICHEN


*---------------------------------------------------------------------*
*      Form  J_1NE_DETAILVERGLEICH
*---------------------------------------------------------------------*
FORM J_1NE_DETAILVERGLEICH.
* Einzelvergleich für bestimmte Felder
  LOOP AT J_1NE_FELDER WHERE FIELDNAME NE 'WERKS'.
    ASSIGN J_1NE_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN J_1NE_FELDER-SCRTEXT_L TO <SCRTEXT_L>.
  ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_J_1NE_M TO <MAT_A_FIELD>.
  ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_J_1NE_V TO <MAT_B_FIELD>.
    IF <MAT_A_FIELD> NE <MAT_B_FIELD>.
      CONCATENATE 'j_1ne-' <FIELDNAME> INTO FELDNAME.
      WRITE: AT /TP FELDNAME, <SCRTEXT_L>,
             AT PM <MAT_A_FIELD>.
      FORMAT COLOR 5 INVERSE ON.
        WRITE: AT PV <MAT_B_FIELD>.
      FORMAT COLOR OFF INVERSE OFF.
*     für Excel-Export
      ASSIGN J_1NE_FELDER-TABNAME   TO <TABNAME>.
     ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_J_1NE_V TO <FELDWERT>.
      PERFORM FELDZUWEISUNG_XLS_ITAB.
    ENDIF.
  ENDLOOP. " at j_1ne_felder
  SKIP.
ENDFORM.                    " J_1NE_DETAILVERGLEICH


*---------------------------------------------------------------------*
*      Form  J_1NEMM_VERGLEICHEN
*---------------------------------------------------------------------*
FORM J_1NEMM_VERGLEICHEN.
*  wir befinden uns im 'loop at mat_liste'
*   Daten Vergleichmaterial beschaffen
    CLEAR: WA_J_1NEMM_V.
    SELECT * " single *
           FROM   J_1NEMM
           INTO   CORRESPONDING FIELDS OF WA_J_1NEMM_V
*           where  j_1nlif     = p_lifnr
           WHERE   J_1NMAT     = MAT_LISTE-MATNR
*           and    j_1neko     = p_ekorg
           AND    J_1NWRK     = P_WERKS
           AND    J_1NNES     = P_J1NNES.
       EXIT. " erster gilt
     ENDSELECT.
*   Werksdaten überschreiben!
    WA_J_1NEMM_V-J_1NMAT = P_MATNR.
    WA_J_1NEMM_V-J_1NWRK = P_WERKS.
    IF WA_J_1NEMM_M EQ WA_J_1NEMM_V.
      IF NOT P_ZEIGID IS INITIAL.
        WRITE: / 'Material'(014), 'identisch.'(015), 'J_1NEMM',
         '[MM02: Zusätze -> NE Gewichte Einkauf]'(028).
      ENDIF. " not p_zeigid is initial
    ELSE. " wa_j_1nemm_m eq wa_j_1nemm_v
*     Werksinformation zurückschreiben
      WA_J_1NEMM_V-J_1NMAT = MAT_LISTE-MATNR.
      WA_J_1NEMM_V-J_1NWRK = MAT_LISTE-WERKS.
      WRITE: / 'Material'(014), 'ungleich. '(016), 'J_1NEMM',
         '[MM02: Zusätze -> NE Gewichte Einkauf]'(028).
      IF NOT P_DETAIL IS INITIAL.
        PERFORM J_1NEMM_DETAILVERGLEICH.
      ENDIF.
    ENDIF. " wa_j_1nemm_m eq wa_j_1nemm_v
ENDFORM.                    " J_1NEMM_VERGLEICHEN


*---------------------------------------------------------------------*
*      Form  J_1NEMM_DETAILVERGLEICH
*---------------------------------------------------------------------*
FORM J_1NEMM_DETAILVERGLEICH.
* Einzelvergleich für bestimmte Felder
  LOOP AT J_1NEMM_FELDER.
    ASSIGN J_1NEMM_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN J_1NEMM_FELDER-SCRTEXT_L TO <SCRTEXT_L>.
ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_J_1NEMM_M TO <MAT_A_FIELD>.
ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_J_1NEMM_V TO <MAT_B_FIELD>.
    IF <MAT_A_FIELD> NE <MAT_B_FIELD>.
      CONCATENATE 'j_1nemm-' <FIELDNAME> INTO FELDNAME.
      WRITE: AT /TP FELDNAME, <SCRTEXT_L>,
             AT PM <MAT_A_FIELD>.
      FORMAT COLOR 5 INVERSE ON.
        WRITE: AT PV <MAT_B_FIELD>.
      FORMAT COLOR OFF INVERSE OFF.
*     für Excel-Export
      ASSIGN J_1NEMM_FELDER-TABNAME   TO <TABNAME>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_J_1NEMM_V TO <FELDWERT>.
      PERFORM FELDZUWEISUNG_XLS_ITAB.
    ENDIF.
  ENDLOOP. " at j_1nemm_felder
  SKIP.
ENDFORM.                    " J_1NEMM_DETAILVERGLEICH


*---------------------------------------------------------------------*
*      Form  CREATE_XLS_ITAB
*---------------------------------------------------------------------*
*  Anlegen der zum Download bestimmten Excel-Tabelle
*----------------------------------------------------------------------*
FORM CREATE_XLS_ITAB.
  APPEND 'PROGRAM SUBPOOL.' TO CODE.
  APPEND 'DATA BEGIN OF XLS_ITAB OCCURS 0.' TO CODE.
*  APPEND 'DATA MATNR LIKE MARAV-MATNR. " Key_Material' TO CODE.
*  APPEND 'DATA WERKS LIKE MARC-WERKS. " Key_Werk' TO CODE.
*  APPEND 'DATA MAKTX LIKE MAKT-MAKTX. " Materialkurztext' TO CODE.
*  APPEND 'DATA Muster. " Sortierfeld'  TO CODE.
* Felder als CHAR definiert, um Spaltenüberschriften hineinschreiben zu
*  können!
  APPEND 'DATA MATNR(25). " Key_Material' TO CODE.
  APPEND 'DATA WERKS(25).  " Key_Werk' TO CODE.
  APPEND 'DATA MAKTX(40). " Materialkurztext' TO CODE.
  APPEND 'DATA Muster(25). " Sortierfeld'  TO CODE.

  LOOP AT XLS_STRUC.
    ASSIGN XLS_STRUC-TABNAME   TO <TABNAME>.
    ASSIGN XLS_STRUC-FIELDNAME TO <FIELDNAME>.
    CONCATENATE <TABNAME> '-' <FIELDNAME> INTO TABNAME_FIELDNAME.
    CONCATENATE <TABNAME> '_' <FIELDNAME> INTO TABELLE_FELD.
    ASSIGN TABNAME_FIELDNAME TO <TABNAME_FIELDNAME>.
    ASSIGN TABELLE_FELD      TO <TABELLE_FELD>.

    CONCATENATE <TABELLE_FELD> '(40)' INTO CODE.
    CONCATENATE 'data' CODE '.' INTO CODE SEPARATED BY ' '.

      TRANSLATE CODE TO UPPER CASE.
      APPEND CODE.
  ENDLOOP. " at xls_struc
  APPEND 'DATA END OF XLS_ITAB.' TO CODE.
  APPEND '*' TO CODE.

* eigentlicher Programmstart bzw. Formstart
  APPEND '*' TO CODE.
  APPEND '* LOS GEHTs' TO CODE.
  APPEND 'FORM DYN1.'  TO CODE.

* Kopfzeile 1 schreiben (Klarschrifttexte)
  APPEND '* Kopfzeile 1 schreiben (Klarschrifttexte)' TO CODE.
  APPEND 'CLEAR XLS_ITAB.' TO CODE.
  CONCATENATE HOCHKOMMA 'Material' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MATNR' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA 'Werk' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-WERKS' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA 'Materialkurztext' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MAKTX' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
* Flag für Musterzeile setzen
  CONCATENATE HOCHKOMMA 'Musterflag' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MUSTER' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  LOOP AT XLS_STRUC.
    ASSIGN XLS_STRUC-TABNAME   TO <TABNAME>.
    ASSIGN XLS_STRUC-FIELDNAME TO <FIELDNAME>.
    ASSIGN XLS_STRUC-SCRTEXT_L TO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP. " at xls_struc
  APPEND 'APPEND XLS_ITAB.' TO CODE.

* Kopfzeile 2 schreiben (Feldnamen)
  APPEND '* Kopfzeile 2 schreiben (Feldnamen)' TO CODE.
  APPEND 'CLEAR XLS_ITAB.' TO CODE.
  CONCATENATE HOCHKOMMA 'MARAV-MATNR' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MATNR' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA 'MARC-WERKS' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-WERKS' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA 'MAKT-MAKTX' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MAKTX' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
* Flag für Musterzeile setzen
  CONCATENATE HOCHKOMMA 'Musterflag' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MUSTER' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  LOOP AT XLS_STRUC.
    ASSIGN XLS_STRUC-TABNAME   TO <TABNAME>.
    ASSIGN XLS_STRUC-FIELDNAME TO <FIELDNAME>.
*    assign xls_struc-scrtext_l to <feldwert>.
    CONCATENATE <TABNAME> '-' <FIELDNAME> INTO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP. " at xls_struc
  APPEND 'APPEND XLS_ITAB.' TO CODE.
ENDFORM.                    " CREATE_XLS_ITAB


*---------------------------------------------------------------------*
*      Form  MUSTERDATEN_XLS_ITAB
*---------------------------------------------------------------------*
FORM MUSTERDATEN_XLS_ITAB.
* Key-Daten schreiben.
  APPEND 'CLEAR XLS_ITAB.' TO CODE.
  CONCATENATE HOCHKOMMA WA_MARA_M-MATNR HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MATNR' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA WA_MARC_M-WERKS HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-WERKS' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA WA_MARA_M-MAKTX HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MAKTX' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
* Flag für Musterzeile setzen
  CONCATENATE HOCHKOMMA 'X' HOCHKOMMA INTO CODE.
  CONCATENATE 'XLS_ITAB-MUSTER' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  LOOP AT MARA_FELDER.
    ASSIGN MARA_FELDER-TABNAME   TO <TABNAME>.
    ASSIGN MARA_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MARA_M TO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP." at mara_felder
  LOOP AT MARC_FELDER.
    ASSIGN MARC_FELDER-TABNAME   TO <TABNAME>.
    ASSIGN MARC_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MARC_M TO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP." at marc_felder
  LOOP AT MVKE_FELDER.
    ASSIGN MVKE_FELDER-TABNAME   TO <TABNAME>.
    ASSIGN MVKE_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MVKE_M TO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP." at mvke_felder
  LOOP AT MBEW_FELDER.
    ASSIGN MBEW_FELDER-TABNAME   TO <TABNAME>.
    ASSIGN MBEW_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_MBEW_M TO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP." at mbew_felder
  LOOP AT EINE_FELDER.
    ASSIGN EINE_FELDER-TABNAME   TO <TABNAME>.
    ASSIGN EINE_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_EINE_M TO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP." at eine_felder
  LOOP AT J_1NE_FELDER.
    ASSIGN J_1NE_FELDER-TABNAME   TO <TABNAME>.
    ASSIGN J_1NE_FELDER-FIELDNAME TO <FIELDNAME>.
    ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_J_1NE_M TO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP." at j_1ne_felder
  LOOP AT J_1NEMM_FELDER.
    ASSIGN J_1NEMM_FELDER-TABNAME   TO <TABNAME>.
    ASSIGN J_1NEMM_FELDER-FIELDNAME TO <FIELDNAME>.
   ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE WA_J_1NEMM_M TO <FELDWERT>.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP." at j_1nemm_felder
* Musterdaten Einkaufsbestelltext
* es wird nur die erste Zeile übertragen!!!
  DESCRIBE TABLE EK_TEXT_M LINES LINES_EK_M.
  READ TABLE EK_TEXT_M INDEX 1.
  LOOP AT EK_TXT_FELDER.
    ASSIGN EK_TXT_FELDER-TABNAME TO <TABNAME>.
    ASSIGN EK_TXT_FELDER-FIELDNAME TO <FIELDNAME>.
    IF <FIELDNAME> NE 'LINE_ANZ'.
    ASSIGN COMPONENT <FIELDNAME> OF STRUCTURE EK_TEXT_M TO <FELDWERT>.
    ELSE.
      MOVE LINES_EK_M TO <FELDWERT>.
    ENDIF.
    PERFORM FELDZUWEISUNG_XLS_ITAB.
  ENDLOOP." at ek_text_felder
* Zeile wegschreiben
  APPEND 'APPEND XLS_ITAB.' TO CODE.
  APPEND '*' TO CODE.
  APPEND '*' TO CODE.
  APPEND '* ab hier jetzt die Daten' TO CODE.
  APPEND '*' TO CODE.
ENDFORM.                    " MUSTERDATEN_XLS_ITAB


*---------------------------------------------------------------------*
*      Form  FELDZUWEISUNG_XLS_ITAB
*---------------------------------------------------------------------*
FORM FELDZUWEISUNG_XLS_ITAB.
    CONCATENATE <TABNAME> '_' <FIELDNAME> INTO TABELLE_FELD.
    ASSIGN TABELLE_FELD      TO <TABELLE_FELD>.
    CONCATENATE 'xls_itab-' <TABELLE_FELD> INTO CODE.
    WRITE <FELDWERT> TO CODE2.
    SHIFT CODE2 LEFT DELETING LEADING ' '.
    CONCATENATE '@' CODE2 '@' INTO CODE2.
    REPLACE '@' WITH HOCHKOMMA INTO CODE2.
    REPLACE '@' WITH HOCHKOMMA INTO CODE2.
    CONCATENATE CODE '=' CODE2 '.' INTO CODE SEPARATED BY ' '.
    TRANSLATE CODE TO UPPER CASE.
    APPEND CODE.
ENDFORM.                    " FELDZUWEISUNG_XLS_ITAB


*---------------------------------------------------------------------*
*      Form  AUSGABE_XLS_ITAB
*---------------------------------------------------------------------*
FORM AUSGABE_XLS_ITAB.
*  append 'LOOP AT XLS_ITAB.' to code.
*    append 'WRITE: / SY-TABIX, XLS_ITAB(120).' to code.
*  append 'ENDLOOP. " AT XLS_ITAB' to code.

  APPEND 'DATA FILENAME LIKE RLGRAP-FILENAME.' TO CODE.
  CONCATENATE HOCHKOMMA
*              p_filenm " 'c:\' sy-datum '_' sy-uzeit '.xls'
              P_FILENM " 'c:\' sy-datum '_' sy-uzeit '.txt'
              HOCHKOMMA INTO CODE.
  CONCATENATE 'FILENAME' '=' CODE '.' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA 'RH_START_EXCEL_WITH_DATA' HOCHKOMMA INTO CODE.
  CONCATENATE 'CALL' 'FUNCTION' CODE INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  APPEND 'EXPORTING' TO CODE.
  CONCATENATE 'DATA_NAME' '=' 'FILENAME' INTO CODE SEPARATED BY ' '.
  APPEND CODE.
  CONCATENATE HOCHKOMMA ' ' HOCHKOMMA INTO CODE.
  CONCATENATE 'DATA_PATH_FLAG' '=' CODE INTO CODE SEPARATED BY ' '.
  APPEND CODE.
*         DATA_TYPE           = 'DAT'
*BEIM DOWNLOAD KOENNEN VERSCHIEDENE KONVERTIERUNGEN DURCHGEFUEHRT WERDEN
*DAS ZIELFORMAT WIRD DURCH DEN FILETYPE BESTIMMT.
*'ASC' : ASCII-FORMAT, DIE TABELLE WIRD ZEILENGERECHT ABGELEGT
*'IBM' : ASCII-FORMAT WIE 'ASC' MIT IBM-CODEPAGE KONVERTIERUNG (DOS)
*'DAT' : ASCII-FORMAT WIE 'ASC', ZUSAETZLICH SPALTENTRENNUNG MIT TAB
*        SPALTENAUSWAHL MIT COL_SELCECT UND COL_SELECTMASK IST MÖGLICH
*'WK1' : ZEILEN- UND SPALTENGERECHTE ABLAGE IM TABELLENFORMAT WK1
*      : SPALTENBREITE FÜR C-FELDER MAX. 240 ZEICHEN
*'BIN' : BINÄRES FORMAT (ANGABE VON BIN_FILESIZE ERFORDERLICH)
*'DBF' : ABLAGE ALS DBASE-DATEI (IMME
...
Back to top
View user's profile Send private message Blog
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.