Materialvergleich
www.4AP.de - ABAP Syntaxbeispiel: Materialvergleich zwischen zwei Werken
Beispielcoding: Materialvergleich zwischen zwei Werken (kopieren erlaubt aber auf eigene Gefahr
*&---------------------------------------------------------------------*
*& Report ZMMATVER *
*&---------------------------------------------------------------------*
* erstellt 12.06.2003 Thorsten Neubüser www.4AP.de
*
* entwickelt unter 3.1i // UNICODEPRÜFUNG muss deaktiviert sein!!!!!
* auch getestet unter 4.6c, 4.7
* unter 4.7 muss hochkomma anders definiert werden, wenn Unicode-System
* dann geht aber auch eine andere dynamische Tabellenerzeugung ;-))
*
* ausgehend von einem Mustermaterial werden die Unterschiede zu den
* nachfolgend zu selektierenden Materialien angelistet
* Welche Felder verglichen werden ist in den Formroutinen (z.B.
* mara_felder_ausblenden) definiert
* Verzweigung in die MM02 bei line-select
* Download der Daten nach Excel für manuelle Sortierung / Pflege
*
* Dieser Download kann dann nach manueller Bearbeitung in einem anderen
* ABAP über MATERIAL_MAINTAIN_DARK die verbliebenen nicht gewollten
* Unterschiede ausgleichen
*
* Der Report benutzt einen eigenen pf-status 'Z_PICK'. Eine Kopie
* des 'PICK' aus SAPMSSY0 ergänzt um Drucktaste für Excel-Download
* Funktionscode PF5 = EXCL = Excel Download
*
* Es wird die Nachrichtenklasse ZP mit dem Fehler (000) benötigt.
* er ist definiert als '&1 &2 &3 &4'
*
*&---------------------------------------------------------------------*
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 (IMMER MIT DOS-CODEPAGE)
* concatenate hochkomma 'DAT' hochkomma into code.
* concatenate hochkomma 'ASC' hochkomma into code.
* concatenate 'DATA_TYPE' '=' code into code separated by ' '.
APPEND 'TABLES' TO code.
CONCATENATE 'DATA_TAB' '=' 'XLS_ITAB' INTO code SEPARATED BY ' '.
APPEND code.
APPEND 'EXCEPTIONS' TO code.
CONCATENATE 'NO_BATCH' '=' '1' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'DOWNLOAD_ERROR' '=' '2' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'INVALID_TYPE' '=' '3' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'INTERNAL_ERROR' '=' '4' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'NO_OLE_SUPPORT' '=' '5' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'OLE_FILE_ERROR' '=' '6' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'OLE_ERROR' '=' '7' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'NO_DATA' '=' '8' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'COORDINATE_ERROR' '=' '9' INTO code SEPARATED BY ' '.
APPEND code.
CONCATENATE 'OTHERS' '=' '10' '.' INTO code SEPARATED BY ' '.
APPEND code.
APPEND 'ENDFORM. " DYN1' TO code.
* Generierung der Subroutine
GENERATE SUBROUTINE POOL code NAME prog
MESSAGE msg
LINE lin
WORD wrd
OFFSET off.
IF sy-subrc <> 0.
WRITE: / 'Error during generation in line', lin,
/ msg,
/ 'Word:', wrd, 'at offset', off.
ELSE.
* write: / 'The name of the subroutine pool is', prog.
* skip.
PERFORM dyn1 IN PROGRAM (prog).
* write: / 'ENDE dyn1 in program (prog)'.
ENDIF.
** nur für Testzwecke
* WRITE / '~~~~~~~~~~~~~~~~~~~~~~~~~~~'.
* LOOP AT CODE.
* WRITE: / SY-TABIX, CODE.
* ENDLOOP.
* WRITE / '~~~~~~~~~~~~~~~~~~~~~~~~~~~'.
ENDFORM. " AUSGABE_XLS_ITAB
*&---------------------------------------------------------------------*
*& Form MUSTER_EINKAUFSBESTELLTEXT
*&---------------------------------------------------------------------*
FORM muster_einkaufsbestelltext.
* Text des Mustermaterials lesen
CLEAR ek_text_m. REFRESH ek_text_m.
MOVE: 'BEST' TO ek_txt_id,
p_langu TO ek_txt_langu,
wa_mara_m-matnr TO ek_txt_name,
'MATERIAL' TO ek_txt_object.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = ek_txt_id
language = ek_txt_langu
name = ek_txt_name
object = ek_txt_object
* ARCHIVE_HANDLE = 0
* IMPORTING
* HEADER =
TABLES
lines = ek_text_m
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc NE 0.
* message i000(zp) with 'CALL FUNCTION READ_TEXT'
* sy-subrc EK_TXT_ID EK_TXT_NAME.
ENDIF. " sy-subrc ne 0
ENDFORM. " MUSTER_EINKAUFSBESTELLTEXT
*&---------------------------------------------------------------------*
*& Form EINKAUFSBESTELLTEXTE
*&---------------------------------------------------------------------*
FORM einkaufsbestelltexte.
* wir befinden uns im 'loop at mat_liste'
CLEAR ek_txt_name.
CLEAR ek_text_v. REFRESH ek_text_v.
MOVE wa_mara_v-matnr TO ek_txt_name.
* Text des Mustermaterials lesen
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = ek_txt_id
language = ek_txt_langu
name = ek_txt_name
object = ek_txt_object
* ARCHIVE_HANDLE = 0
* IMPORTING
* HEADER =
TABLES
lines = ek_text_v
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc NE 0.
* message i000(zp) with 'CALL FUNCTION READ_TEXT'
* sy-subrc EK_TXT_ID EK_TXT_NAME.
ENDIF. " sy-subrc ne 0
IF ek_text_m[] EQ ek_text_v[].
IF NOT p_zeigid IS INITIAL.
WRITE: / 'Material'(014), 'identisch.'(015),
'Einkaufsbestelltext'(020).
ENDIF. " not p_zeigid is initial
ELSE. " ek_text_m[] eq ek_text_v[]
WRITE: / 'Material'(014), 'ungleich.'(016),
'Einkaufsbestelltext'(020).
IF NOT p_detail IS INITIAL.
PERFORM ek_bestelltext_detailvergleich.
ENDIF.
ENDIF. " ek_text_m[] eq ek_text_v[]
ENDFORM. " EINKAUFSBESTELLTEXTE
*&---------------------------------------------------------------------*
*& Form EK_BESTELLTEXT_DETAILVERGLEICH
*&---------------------------------------------------------------------*
FORM ek_bestelltext_detailvergleich.
* Anzahl Zeilen bestimmen
CLEAR: lines_ek_m, lines_ek_v, ek_text_m, ek_text_v.
DESCRIBE TABLE ek_text_m LINES lines_ek_m.
DESCRIBE TABLE ek_text_v LINES lines_ek_v.
IF lines_ek_m GE lines_ek_v.
* Musterwerte als 'Loop-Größe'
LOOP AT ek_text_m.
CLEAR ek_text_v.
ek_text_zeile = sy-tabix.
READ TABLE ek_text_v INDEX sy-tabix.
PERFORM ek_text_zeilenvergleich USING ek_text_zeile.
ENDLOOP. " at ek_text_m
ELSE. " lines_ek_m ge lines_ek_v
* Vergleichswerte als 'Loop-Größe'
LOOP AT ek_text_v.
CLEAR ek_text_m.
ek_text_zeile = sy-tabix.
READ TABLE ek_text_m INDEX sy-tabix.
PERFORM ek_text_zeilenvergleich USING ek_text_zeile.
ENDLOOP. " at ek_text_m
ENDIF. " lines_ek_m ge lines_ek_v
ENDFORM. " EK_BESTELLTEXT_DETAILVERGLEICH
*&---------------------------------------------------------------------*
*& Form EK_TEXT_ZEILENVERGLEICH
*&---------------------------------------------------------------------*
FORM ek_text_zeilenvergleich USING zeile.
IF ek_text_m-tdformat NE ek_text_v-tdformat
OR ek_text_m-tdline NE ek_text_v-tdline.
WRITE: AT /tp 'EK-Bestelltext'(021), zeile,
AT pm ek_text_m-tdformat, ek_text_m-tdline.
FORMAT COLOR 5 INVERSE ON.
WRITE: AT pv ek_text_v-tdformat, ek_text_v-tdline.
FORMAT COLOR OFF INVERSE OFF.
* für Excel-Export
CHECK zeile = 1.
LOOP AT ek_txt_felder.
ASSIGN ek_txt_felder-tabname TO <tabname>.
ASSIGN ek_txt_felder-fieldname TO <fieldname>.
ASSIGN ek_txt_felder-scrtext_l TO <scrtext_l>.
* es dürfen maximal ca. 40 Char übertragen werden (keine Langtexte!)
ek_text_v-tdline = ek_text_v-tdline(38).
IF <fieldname> NE 'LINE_ANZ'.
ASSIGN COMPONENT <fieldname> OF STRUCTURE ek_text_v TO <feldwert>.
ELSE.
MOVE lines_ek_v TO <feldwert>.
ENDIF.
PERFORM feldzuweisung_xls_itab.
ENDLOOP." at ek_text_felder
ENDIF. " Vergleich auf Abweichung tdformat tdline
ENDFORM. " EK_TEXT_ZEILENVERGLEICH
***************
* *
* T T *
* N *
* *
* `---´ *
* *
***************