[50960] in SAPr3-news

home help back first fref pref prev next nref lref last post

Abgleich der Formeln zwischen SAP BW Queries / ABAP Toolprogramme

daemon@ATHENA.MIT.EDU (volker Korrmann)
Fri Aug 6 05:18:02 2004

To: sapr3-news@mit.edu
Date: 6 Aug 2004 02:17:50 -0700
From: volker_korrmann@web.de (volker Korrmann)
Message-ID: <cdd58c09.0408060117.1dc35bdb@posting.google.com>

Hallo Leute,

anbei mal wieder ein neues Programm aus meiner Sammelkiste.
Die Beschreibung bitte auch immer mit in die Dokumentation des Reports
packen!!

Rückfragen? --> volker_korrmann@yahoo.de


Ansonsten viel Spaß damit


Volker





SELEKTIONSTEXTE:
P_AUFL	   Formeln auflösen
P_COMPID   Query
P_FEHLT	   Komplett fehlende Formeln
P_NEU	   Komplett neue Formeln
P_OK1	   Korrekte Formeln
P_OK2	   Korrekte Felder in Formeln
P_ORIG	   Original
P_ORIG2	   Originalformeln ohne Abw.
P_SELF	   Quellcube mit auswerten
S_COMPID   Query
S_CUBES2   InfoCube
S_TEXT	   Formelname


---------------------------------------------------------------------------

DOKUMENTATION:
Kurztext
Auswertung über Query Formeln

Verwendung
Dieses Programm vergleicht die Formeln zwischen verschiedenen SAP
BW-Queries auf Basis der Feldbezeichnungen.

WARNUNG: Bei der Verwendung von Klammern und Funktionen in der Formel
ist die Anzeige der Formeln fehlerhaft! Bei Formeln ohne Klammern und
Funktionen sollte die Anzeige jedoch korrekt sein. Trotz allem liefert
der Report auch bei einer "fehlerhaften Formeldarstellung" wichtige
Hinweise auf Abweichungen zwischen zwei Queries in den Formeln.

Sollte eine Kennzahl trotz gleicher Namensgebung anders definiert
sein, so kann dieser Sachverhalt mit dieser Auswertung nicht entdeckt
werden.

Da Formeln wiederum als Felder in anderen Formeln Verwendung finden,
können diese Formeln mit Hilfe dieses Reports auch aufgelöst werden,
so daß man die wirklich in eine Formel eingehenden Kennzahlen
ermitteln kann.

WICHTIG: Diese Option (Formeln auflösen) sollte bei den Prüfungen auch
Verwendung finden,  da somit ermittelt werden kann, ob nicht
vielleicht schon im Original in einer Gesamtsumme, sich über die
verschiedenen Summenstufen hinweg, eine Kennzahl doppelt
eingeschlichen hat.




Selektion
Query (Vorlage)
Hier muß eine Query als Vorlage ausgewählt werden. Das geht entweder
über die F4 Hilfe, oder  den Button "Auswahl einer Query (Vorlage)" .
Der Button zeigt alle Queries zu allen Infocubes an. Die Anzeige kann
jedoch über eine Eingabe im Feld InfoCube auf der Selektionsmaske
eingeschränkt werden.

Formelname
Hier können die auszuwertenden Formeln über die Formelbezeichnung
eingegrenzt werden.

Formeln auflösen
Mit Hilfe dieser Option werden die Formelfelder in Formeln aufgelöst,
so daß in einer Formel alle wirklich enthaltenen Kennzahlen angezeigt
werden

Quellcube mit auswerten
Mit Hilfe dieser Option wird die ausgewählte Query gegen alle anderen
Queries dieses Cubes verglichen.

InfoCube
Mit den Selektionsbedingungen InfoCube und Query können weitere
Queries für den Vergleich selektiert werden. Sind beide Felder leer,
werden keine weitern Queries ausgewählt. Möchten Sie jedoch gegen alle
Queries aller Cubes vergleichen, so geben sie hier als Selektion bitte
den Wildcard " * " ein!!!

Wurde zum Vergleichen nur InfoCube´s ausgewählt, so wird immer gegen
alle Queries dieses Infocubes verglichen.

Query
Selektion der Queries, die mit der Vorlage Query verglichen werden
sollen. Einzelne Queries können über die F4 Hilfe oder über den Button
"Auswahl mehrerer Queries (Kopien)" hinzugefügt werden. Der Button
zeigt alle Queries zu allen Infocubes an. Die Anzeige kann jedoch über
eine Eingabe im Feld InfoCube auf der Selektionsmaske eingeschränkt
werden.

Die Benutzung des Buttons "Auswahl mehrerer Queries (Kopien)" weicht
von der des anderen Button leicht ab. Bei der Auswahl mehrerer Queries
kann man mehrere Queries durch einen Doppelklick auswählen, ohne die
Listanzeige zu verlassen. Nach Auswahl aller Queries ist die
Listanzeige mit F3 zu beenden. Die ausgewählten Queries sind als
Einzelwerte in der Selektionsauswahl dann bereits eingetragen.



Auszublendende Informationen in der Anzeige 
Die nachfolgenden Optionen blenden gewisse Informationen in der Liste
aus. Dadurch erhält man einen wesentlich besseren Überblick über die
gefundenen Abweichungen

Original
Die Formeln der Querievorlage sollen nicht angezeigt werden

Originalformeln ohne Abw.
Die Formeln der Querievorlage sollen nur dann angezeigt werden, wenn
es zu diesem Formelfeld in einer der Kopien zu einer Abweichung
gekommen ist. Diese Option ist per Default ausgewählt.

Korrekte Formeln
Korrekte Kopien einer Formel  in anderen Queries werden nicht mit
ausgegeben. Diese Option ist per Default ausgewählt.

Korrekte Felder in Formeln
Wenn ein Formelfeld einen Fehler aufweist, so sollen nur die
fehlerhaften Felder in dieser Formel ausgegeben werden.

Komplett fehlende Formeln
Wenn eine Formel in einer Kopie überhaupt nicht vorhanden ist, so soll
hierzu kein Fehler ausgegeben werden. Wenn die Formel zwar existiert
aber einzelne Formelbestandteile fehlen, erfolgt die Ausgabe natürlich
weiterhin!!!

Komplett neue Formeln
Wenn eine neue Formel in einer Kopie existiert, die im Original nicht
vorkommt, so wird mit Hilfe dieser Option die Ausgabe dieses
Formelfeldes unterdrückt. Einzelne neue Felder innerhalb einer Formel,
die auch im Original bekannt ist, werden natürlich weiterhin
ausgegeben.



Ausgabe
Die nachfolgenden Informationen werden vom Report zur Auswertung zur
Verfügung gestellt. Diese müssen Teilweise über die Funktionen des ALV
(Allgemeiner List Viewer) bei Bedarf eingeblendet werden (Strg+F8
Layout ändern) .

InfoCube Bei der Vorlage wird dem Infocubenamen ein Unterstrich
vorangestellt. Damit wird erreicht, daß

Querybezeichnung 

Formelname 

Status  (siehe unten)

Operator 

Operand 

Technischer Name der Query 

Verantw. 

Änderer 

Änd.datum 

Änd.zeit


Beschreibung der STATUS Informationen
Das Feld Status kann die nachfolgenden Ausprägungen annehmen:

Original
Bei diesen Feldern handelt es sich um die Vorlage.

OK
Dieses Feld existiert in dieser Formel ebenfalls in der Vorlage.

Feld fehlt
Dieses Feld steht nur in der Vorlage, ist jedoch in der Formel
innerhalb der Kopie nicht vorhanden. Fehlen alle Felder einer Formel,
so ist die gesamte Formel in der Kopie nicht bekannt. Solche Fälle
lassen sich mit Hilfe der Anzeigeoptionen ausfiltern.

doppeltes Feld
Das Feld ist unabhängig ob Vorlage oder Kopie, mehr als einmal
innerhalb der Formel vorhanden.

Feld zuviel
Dieses Feld wird nur in der Kopie innerhalb dieser Formel verwendet.
Sind alle Felder einer Formel als "zuviel" deklariert, so handelt es
sich um eine neue Formel innerhalb der Kopie. Solche Fälle lassen sich
mit Hilfe der Anzeigeoptionen ausfiltern.


------------------------------------------------------------------------

REPORT:


*&---------------------------------------------------------------------*
*& Report  Z_VK_QUERIEAUSWERTUNG                                      
*
*&                                                                    
*
*&---------------------------------------------------------------------*
*&                                                                    
*
*&                                                                    
*
*&---------------------------------------------------------------------*

REPORT  Z_VK_QUERIEAUSWERTUNG2  line-size 255 message-id z1.
* (C) 2004 Volker Korrmann

TYPE-POOLS: slis.

data rc type i.

Tables: V_REP_JOIN, RSZELTDIR, RSZELTTXT, RSZELTXREF,
        RSZCALC, *RSZELTTXT.

DATA: begin of it_queries occurs 0,
       infocube   like v_rep_join-infocube,
       seltuid    like RSZELTXREF-seltuid,
       Queriename like RSZELTTXT-txtlg,
       compid     like v_rep_join-compid,
       owner      like v_rep_join-owner,
       tstpnm     like v_rep_join-tstpnm,
       tstpdat    like v_rep_join-tstpdat,
       tstptim    like v_rep_join-tstptim,
      end of it_queries.

DATA: vorlage like it_queries.


* Diese Tabelle enthält eine Liste
* Querie ID
* Felder ID´s
DATA: begin of it_refs occurs 0,
       seltuid    like RSZELTXREF-seltuid,
       teltuid    like RSZELTXREF-teltuid,
*       stufe      type i,
      end of it_refs.

DATA: begin of it_refs2 occurs 0,
       seltuid    like RSZELTXREF-seltuid,
       teltuid    like RSZELTXREF-teltuid,
      end of it_refs2.

* Die Tabelle IT_REFS_NEW enthält die Folgende Tabelle:

* Id der Query  (nicht des letzten Queriefeldes)
* ID des zugehörigen Feldes
* WICHTIG, in der Datenbank hat QueryID A ein Feld B,
* zu dem über diese Tabelle wieder mit Frage nach
* ID B weitere Felder E und F geliefert werden.
* Die Tabelle It_refs_new wird somit in zwei Aufrufen
* Verwendet.

* Inhalte erster Aufruf
* A B
* Inhalte zweiter Aufruf
* A E
* A F
...


DATA: begin of it_refs_new occurs 0,
       seltuid    like RSZELTXREF-seltuid,
       seltuid2    like RSZELTXREF-seltuid,
      end of it_refs_new.

DATA: begin of it_refs_new2 occurs 0,
       seltuid    like RSZELTXREF-seltuid,
       seltuid2    like RSZELTXREF-seltuid,
      end of it_refs_new2.


TYPES: begin of tt_Formeln,
       infocube   like v_rep_join-infocube,
       seltuid    like RSZELTXREF-seltuid,
       Queriename like RSZELTTXT-txtlg,
       compid     like v_rep_join-compid,
       teltuid    like RSZELTXREF-teltuid,
*       deftp      like RSZELTDIR-deftp,
       Formelfeld like RSZELTTXT-txtlg,
*       stufe      type i,
       stepnr     like rszcalc-stepnr,
       oper1      like rszcalc-oper1,
       oper2      like rszcalc-oper2,
       opera      like rszcalc-opera,
*       o1flg      like rszcalc-o1flg,
*       o2flg      like rszcalc-o1flg,
       oper1t     like RSZELTTXT-txtlg,
       oper2t     like RSZELTTXT-txtlg,
       end of tt_formeln.

DATA: it_form1 type standard table of tt_formeln with header line.
DATA: it_form2 type sorted table of tt_formeln with header line
      with non-unique key compid Formelfeld stepnr.


TYPES: begin of tt_Formeln3,
       infocube   like v_rep_join-infocube,
       Queriename like RSZELTTXT-txtlg,
       compid     like v_rep_join-compid,
       owner      like v_rep_join-owner,
       tstpnm     like v_rep_join-tstpnm,
       tstpdat    like v_rep_join-tstpdat,
       tstptim    like v_rep_join-tstptim,
       Formelfeld like RSZELTTXT-txtlg,
       stepnr     like rszcalc-stepnr,
       opera      like rszcalc-opera,
       oper1t     like RSZELTTXT-txtlg,
       teltuid    like RSZELTXREF-teltuid,
       oper1      like rszcalc-oper1,
       status     like RSZELTTXT-txtSH,
       end of tt_formeln3.

DATA: it_form3 type standard table of tt_formeln3 with header line.
DATA: it_formv type sorted table of tt_formeln3 with header line
      with non-unique key Formelfeld oper1t compid.

TYPES: begin of tt_Formeln4,
       teltuid    like RSZELTXREF-teltuid,
       oper1      like rszcalc-oper1,
       compid     like v_rep_join-compid,
       stepnr     like rszcalc-stepnr,
       opera      like rszcalc-opera,
       oper1t     like RSZELTTXT-txtlg,
       end of tt_formeln4.

DATA: it_form4 type sorted table of tt_formeln4 with header line
      with non-unique key compid teltuid stepnr.


*Parameters: p_cube like V_REP_JOIN-infocube.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH frame title TEXT-001.

* Diese Eine Query soll mit vielen anderen verglichen werden
Parameters: p_compid like V_REP_JOIN-compid default 'Z_ZUCSA_C35_MQ'.
select-options: s_text for RSZELTTXT-txtlg.
parameters: p_aufl as checkbox.
* Eventuell nur einzelne Felder davon.


selection-screen skip.
* Vergleich gegen Queries des eigenen Cubes

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH frame title TEXT-002.

Parameters: p_self as checkbox default ' '.
* Vergleich auch gegen die Queries anderer Cubes
Select-options: s_cubes for V_REP_JOIN-infocube no-display.
Select-options: s_cubes2 for V_REP_JOIN-infocube.
Select-options: s_compid for V_REP_JOIN-compid
default 'Z_ZUCSA_C35_TEST'.
* Einschränkung auf einzelne Queries

SELECTION-SCREEN end of block B2.

SELECTION-SCREEN BEGIN OF BLOCK B3 WITH frame title TEXT-003.
Parameters:
p_orig as checkbox,  "Original Ausblenden
p_orig2 as checkbox default 'X', "Originalformeln ohne Fehler
ausblenden
p_ok1  as checkbox default 'X',  "Alle korrekten Kopien ausblenden
p_ok2  as checkbox,  "Alle Felder mit Status OK ausblenden
p_fehlt as checkbox, "Nicht existente Formeln ignorieren
p_neu   as checkbox. "komplett neue Formeln

SELECTION-SCREEN end of block B3.


SELECTION-SCREEN end of block B1.


data: i type i.
data: gmode type i.


* Anfang: Behandlung der Buttonleiste auf dem Selektionsschirm
tables: sscrfields.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN FUNCTION KEY 2.

AT SELECTION-SCREEN.
  case SY-UCOMM.
    when 'FC01'.
      Perform Queriesuche2 using 'X'.
      gmode = 1.
      perform ALV_qlist.
    when 'FC02'.
      Perform Queriesuche2 using 'X'.
      gmode = 2.
      perform ALV_qlist.

    when others.
  endcase.


INITIALIZATION.

  SSCRFIELDS-FUNCTXT_01 = 'Auswahl einer Query (Vorlage)'.
  SSCRFIELDS-FUNCTXT_02 = 'Auswahl mehrerer Queries (Kopien)'.



start-of-selection.

  if s_compid[] is initial and
     s_cubes2[] is initial.
    clear s_cubes. refresh s_cubes.
    s_cubes-sign = 'I'.
    s_cubes-option = 'EQ'.
    s_cubes-low = '-----------'.
    append s_cubes.
  else.
    s_cubes[] = s_cubes2[].
  endif.


* Als erstes müssen die Queries ermitteln werden
  Perform Queriesuche.
  perform Feldermittlung.
  Perform Formelfelder.
  perform Formeln_laden.

*  perform Formelausgabe.

  perform Datenaufbereitung.


  Perform Vergleich.

  perform ALV_Ausgabe.




*&--------------------------------------------------------------------*
*&      Form  Datenaufbereitung
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form Datenaufbereitung.

  sort it_queries by seltuid.

  refresh it_form3.
  loop at it_form2.
    move-corresponding it_form2 to it_form3.
    clear it_queries.
    read table it_queries with key seltuid = it_form2-seltuid
         binary search.
    move-corresponding it_queries to it_form3.

    it_form3-stepnr = 1000 - it_form3-stepnr.
    if it_form2-oper1t <> '' and it_form2-oper2t <> ''.
      it_form3-oper1t = it_form2-oper2t.
      it_form3-oper1  = it_form2-oper2.
      append it_form3.
      it_form3-oper1t = it_form2-oper1t.
      it_form3-oper1  = it_form2-oper1.
      it_form3-stepnr = it_form3-stepnr - 1.
      append it_form3.
    elseif it_form2-oper1t <> ''.
      append it_form3.
    elseif it_form2-oper2t <> ''.
      it_form3-oper1t = it_form2-oper2t.
      it_form3-oper1  = it_form2-oper2.  append it_form3.
    endif.
  endloop.



  if p_aufl = 'X'.
    rc = 0.
    sort it_form3 by compid teltuid stepnr.

    refresh it_form4.
    loop at it_form3.
      move-corresponding it_form3 to it_form4.
      insert it_form4 into table it_form4.
    endloop.


    while rc = 0.
      perform Formeln_aufloesen changing rc.
    endwhile.
    refresh it_form4.

  endif.


  delete it_form3 where not formelfeld in s_text.
  refresh it_form2.
endform.                    "Datenaufbereitung


*&--------------------------------------------------------------------*
*&      Form  ALV_Ausgabe
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form ALV_Ausgabe.
  DATA:
          lt_alv_cat  TYPE  SLIS_T_FIELDCAT_ALV,
          ls_alv_cat  LIKE LINE OF lt_alv_cat.


  ls_alv_cat-fieldname     = 'INFOCUBE'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'INFOCUBE'.
  ls_alv_cat-SELTEXT_L       = 'InfoCube'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-ddictxt         = 'L'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'QUERIENAME'.
  ls_alv_cat-ref_tabname     = 'RSZELTTXT'.
  ls_alv_cat-ref_fieldname     = 'TXTLG'.
  ls_alv_cat-SELTEXT_L       = 'Querybezeichnung'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-ddictxt         = 'L'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'COMPID'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'COMPID'.
  ls_alv_cat-SELTEXT_L       = 'Technischer Name der Query'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-ddictxt         = 'L'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'OWNER'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'OWNER'.
  ls_alv_cat-SELTEXT_L       = ''.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-ddictxt         = ''.

  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'TSTPNM'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'TSTPNM'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'TSTPDAT'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'TSTPDAT'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'TSTPTIM'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'TSTPTIM'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'FORMELFELD'.
  ls_alv_cat-ref_tabname     = 'RSZELTTXT'.
  ls_alv_cat-ref_fieldname     = 'TXTLG'.
  ls_alv_cat-SELTEXT_L       = 'Formelname'.
  ls_alv_cat-ddictxt         = 'L'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'STEPNR'.
  ls_alv_cat-ref_tabname     = 'RSZCALC'.
  ls_alv_cat-ref_fieldname     = 'STEPNR'.
  ls_alv_cat-SELTEXT_L       = 'Step'.
  ls_alv_cat-ddictxt         = 'L'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'STATUS'.
  ls_alv_cat-ref_tabname     = 'RSZELTTXT'.
  ls_alv_cat-ref_fieldname     = 'TXTSH'.
  ls_alv_cat-SELTEXT_L       = 'Vergleichsstatus'.
  ls_alv_cat-ddictxt         = 'L'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  APPEND ls_alv_cat TO lt_alv_cat.


  ls_alv_cat-fieldname     = 'OPERA'.
  ls_alv_cat-ref_tabname     = 'RSZCALC'.
  ls_alv_cat-ref_fieldname     = 'OPERA'.
  ls_alv_cat-SELTEXT_L       = 'Operator'.
  ls_alv_cat-ddictxt         = 'L'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'OPER1T'.
  ls_alv_cat-ref_tabname     = 'RSZELTTXT'.
  ls_alv_cat-ref_fieldname     = 'TXTLG'.
  ls_alv_cat-SELTEXT_L       = 'Operand'.
  ls_alv_cat-ddictxt         = 'L'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  APPEND ls_alv_cat TO lt_alv_cat.


  DATA: titel TYPE	LVC_TITLE value 'Query Formelanzeige'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = sy-repid
*   I_CALLBACK_PF_STATUS_SET          = ' '
*   I_CALLBACK_USER_COMMAND           = ' '
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      = titel
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         =
      IT_FIELDCAT                       = lt_alv_cat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
      I_SAVE                            = 'A'
*   IS_VARIANT                        =
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      T_OUTTAB                          = it_form3
   EXCEPTIONS
     PROGRAM_ERROR                     = 1
     OTHERS                            = 2
            .
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


endform.                    "ALV_Ausgabe





*&--------------------------------------------------------------------*
*&      Form  formelausgabe
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form formelausgabe.


  loop at it_form2.
    write: /
    it_form2-infocube(30),
    it_form2-queriename(35),
    it_form2-formelfeld(35),
*    it_form2-stufe,
    it_form2-stepnr,
    it_form2-oper1t(35),
    it_form2-opera,
    it_form2-oper2t(35).
  endloop.

endform.                    "formelausgabe


*&--------------------------------------------------------------------*
*&      Form  formeln_laden
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form formeln_laden.
  types: begin of t_it_f,
        eltuid like rszcalc-eltuid,
        stepnr like rszcalc-stepnr,
        opera  like rszcalc-opera,
        oper1  like rszcalc-oper1,
        oper2  like rszcalc-oper2,
        o1flg  like rszcalc-o1flg,
        o2flg  like rszcalc-o2flg,
        end of t_it_f.
  DATA: it_f type sorted table of t_it_f
        with non-unique key eltuid stepnr
        with header line.

  select eltuid stepnr opera oper1 oper2 o1flg o2flg
         into table it_f
         from rszcalc
         for all entries in it_form1
         where eltuid = it_form1-teltuid and
               objvers = 'A'.

  loop at it_form1.
    it_form2 = it_form1.
    loop at it_f where eltuid = it_form1-teltuid.
      move-corresponding it_f to it_form2.

      clear RSZELTTXT.
      select single txtlg into it_form2-oper1t
                from RSZELTTXT
                where eltuid = it_form2-oper1 and
                      objvers = 'A' and
                      langu   = sy-langu.
      if sy-subrc <> 0 and it_f-o1flg = 'C'.
        it_form2-oper1t = it_form2-oper1.
      endif.


      clear RSZELTTXT.
      select single txtlg into it_form2-oper2t
                from RSZELTTXT
                where eltuid = it_form2-oper2 and
                      objvers = 'A' and
                      langu   = sy-langu.
      if sy-subrc <> 0 and it_f-o2flg = 'C'.
        it_form2-oper2t = it_form2-oper2.
      endif.

      insert it_form2 into table it_form2.

    endloop.
  endloop.
endform.                    "formeln_laden




* Es werden nur noch Formelfelder betrachtet.
form formelfelder.
*       infocube   like v_rep_join-infocube,
*       seltuid    like RSZELTXREF-seltuid,
*       Queriename like RSZELTTXT-txtlg,
*       teltuid    like RSZELTXREF-teltuid,
**       deftp      like RSZELTDIR-deftp,
*       Formelfeld like RSZELTTXT-txtlg,
*       stepnr     like rszcalc-stepnr,
*       oper1      like rszcalc-oper1,
*       oper2      like rszcalc-oper2,
*       opera      like rszcalc-opera,
*       oper1t     like RSZELTTXT-txtlg,
*       oper2t     like RSZELTTXT-txtlg,


  loop at it_refs.
    select single * from RSZELTDIR where eltuid = it_refs-teltuid and
                                         objvers = 'A' and
                                         deftp = 'FML'.
    if sy-subrc = 0.

      clear RSZELTTXT.
      select single txtlg into it_form1-formelfeld
                from RSZELTTXT
                where eltuid = it_refs-teltuid and
                      objvers = 'A' and
                      langu   = sy-langu.

      if it_form1-formelfeld in s_text or p_aufl = 'X'.

        clear it_queries.
 read table it_queries with key seltuid = it_refs-seltuid binary
search.

        it_form1-seltuid    = it_refs-seltuid.
        it_form1-infocube   = it_queries-infocube.
        it_form1-queriename = it_queries-queriename.
        it_form1-compid     = it_queries-compid.
        it_form1-teltuid    = it_refs-teltuid.
*        it_form1-stufe      = it_refs-stufe.
        append it_form1.
      endif.
    endif.
  endloop.
endform.                    "formelfelder


* Leider kommt es beim Aufruf über mehrere Queries dazu, das
* durch die gleichzeitige Benutzung von Felder mache
* Queries plötzlich ausgefiltert werden.

* Ich habe dieses Problem leider nicht lösen können, somit
* umgehe ich es jetzt hiermit, indem ich die Feldermittlung
* Querieweise (für alle Einträge zu einer Seltuid einzeln)
* aufrufe !!!
* Dazu muß ich auch die Ergebnisse temporär zwischenspeichern.
form feldermittlung.
  DATA: begin of l_it_refs occurs 0,
         seltuid    like RSZELTXREF-seltuid,
         teltuid    like RSZELTXREF-teltuid,
*       stufe      type i,
        end of l_it_refs.

  DATA: begin of l_it_refs_new occurs 0,
         seltuid    like RSZELTXREF-seltuid,
         seltuid2    like RSZELTXREF-seltuid,
        end of l_it_refs_new.

  DATA: l_seltuid like RSZELTXREF-seltuid.

  refresh: l_it_refs, l_it_refs_new.

  clear l_seltuid.

  insert lines of it_refs_new into table l_it_refs_new.
  sort l_it_refs_new by seltuid.
  refresh: it_refs_new, it_refs_new2.

  loop at l_it_refs_new.
    if l_seltuid <> l_it_refs_new-seltuid.
      if l_seltuid <> ''.
        perform feldermittlung2.
        insert lines of it_refs into table l_it_refs.
        refresh: it_refs_new, it_refs_new2, it_refs.
      endif.
      l_seltuid =  l_it_refs_new-seltuid.
    endif.
    insert l_it_refs_new into table it_refs_new.
  endloop.
  if l_seltuid <> ''.
    perform feldermittlung2.
    insert lines of it_refs into table l_it_refs.
  endif.
  refresh: it_refs_new, it_refs_new2.
  it_refs[] = l_it_refs[].
  refresh l_it_refs.
endform.                    "feldermittlung

*&--------------------------------------------------------------------*
*&      Form  feldermittlung
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form feldermittlung2.
  data: stufe type i.
  sort it_refs_new by seltuid2.

  i = 1.
  stufe = 0.
* Ermitteln aller Felder der Query
  while i > 0.
    stufe = stufe + 1.
    refresh it_refs2.
    select seltuid teltuid into table it_refs2
           from RSZELTXREF
           for all entries in it_refs_new
           where seltuid = it_refs_new-seltuid2 and
                 objvers = 'A'.

    loop at it_refs2.
      clear it_refs_new.
      read table it_refs_new with key seltuid2 = it_refs2-seltuid
                             binary search.
      it_refs-seltuid = it_refs_new-seltuid.
      it_refs-teltuid = it_refs2-teltuid.
*      it_refs-stufe   = stufe.
      append it_refs.
      it_refs_new2-seltuid = it_refs_new-seltuid.
      it_refs_new2-seltuid2 = it_refs2-teltuid.
      append it_refs_new2.
    endloop.

    it_refs_new[] = it_refs_new2[].
    sort it_refs2 by teltuid.

    sort it_refs_new by seltuid2.
    loop at it_refs.
* Verhindern von zyklischen Bezügen
      read table it_refs2 with key teltuid = it_refs-teltuid
           binary search.
      if sy-subrc <> 0.
        read table it_refs_new with key seltuid2 = it_refs-teltuid
             binary search.
        if sy-subrc = 0.
          delete it_refs_new index sy-tabix.
        endif.
      endif.
    endloop.

    describe table it_refs_new lines i.
  endwhile.
  refresh it_refs2.

  sort it_refs by teltuid.
  DELETE ADJACENT DUPLICATES from it_refs comparing teltuid.

endform.                    "feldermittlung



*&--------------------------------------------------------------------*
*&      Form  Queriesuche
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form Queriesuche2 using mode.

  DATA: l_vorlage like vorlage.

  refresh it_queries.
  clear vorlage.

  if mode = 'X'.
    select Infocube compuid compid compid owner tstpnm tstpdat tstptim
        from v_rep_join
        into table it_queries
        where
              infocube in s_cubes2  and
*              compid   in s_compid and
                objvers = 'A'.
  else.
    select Infocube compuid compid compid owner tstpnm tstpdat tstptim
        from v_rep_join
        into table it_queries
        where
                infocube in s_cubes2  and
                compid   in s_compid and
                objvers = 'A'.
  endif.
  refresh it_refs_new.

  sort it_queries by seltuid.

  loop at it_queries.
    clear RSZELTTXT.
    select single txtlg into it_queries-queriename
           from RSZELTTXT
           where eltuid = it_queries-seltuid and
                 objvers = 'A' and
                 langu   = sy-langu.
    modify it_queries.
*    write: / it_queries.

* Referenzen füllen

    it_refs_new-seltuid = it_queries-seltuid.
    it_refs_new-seltuid2 = it_queries-seltuid.
    insert it_refs_new into table it_refs_new.
  endloop.

endform.                    "Queriesuche



*&--------------------------------------------------------------------*
*&      Form  Queriesuche
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form Queriesuche.

  DATA: l_vorlage like vorlage.

  refresh it_queries.
  clear vorlage.

  select Infocube compuid compid compid owner tstpnm tstpdat tstptim
         from v_rep_join
         into vorlage up to 1 rows
         where compid = p_compid and
               objvers = 'A'.
  endselect.
  if sy-subrc <> 0. message e100. endif.

  l_vorlage = vorlage.
  if p_self <> 'X'.
    l_vorlage-infocube = '---'.
  endif.


  select Infocube compuid compid compid owner tstpnm tstpdat tstptim
      from v_rep_join
      into table it_queries
      where ( ( compuid  = vorlage-seltuid or
              infocube = l_vorlage-infocube ) or
            ( infocube in s_cubes and compid in s_compid ) ) and
              objvers = 'A'.

  refresh it_refs_new.

  sort it_queries by seltuid.

  loop at it_queries.
    clear RSZELTTXT.
    select single txtlg into it_queries-queriename
           from RSZELTTXT
           where eltuid = it_queries-seltuid and
                 objvers = 'A' and
                 langu   = sy-langu.
    modify it_queries.
*    write: / it_queries.

* Referenzen füllen

    it_refs_new-seltuid = it_queries-seltuid.
    it_refs_new-seltuid2 = it_queries-seltuid.
    insert it_refs_new into table it_refs_new.
  endloop.

endform.                    "Queriesuche





*&--------------------------------------------------------------------*
*&      Form  Formeln_aufloesen
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->RC         text
*---------------------------------------------------------------------*
form Formeln_aufloesen changing rc type i.
  data: i type i.
  data: l_id like it_form3-teltuid.

  DATA: l_it_form3 type standard table of tt_formeln3 with header
line.

  rc = 1.

* Es wird die lokale Kopie abgeloopt und dabei ein neues Original
* erstellt
  l_it_form3[] = it_form3[].
  refresh it_form3.

* Dafür wurde bereits zusätzlich eine sortierte Version mit den
Feldern
* einer Formel angelegt.  (it_form4)
  clear l_id.
  loop at l_it_form3 where formelfeld in s_text.
    if l_id <> l_it_form3-teltuid.
      i = 1.
      l_id = l_it_form3-teltuid.
    endif.

    it_form3 = l_it_form3.
    loop at it_form4 where compid = l_it_form3-compid and
                           teltuid = l_it_form3-oper1.
      rc = 0.
      it_form4-teltuid = it_form3-teltuid.
      move-corresponding it_form4 to it_form3.
      it_form3-stepnr = i. i = i + 1.
      append it_form3.
    endloop.
    if sy-subrc <> 0.
* Das Feld konnte nicht weiter aufgelöst werden->
* Das Originalfeld anhängen
      it_form3-stepnr = i. i = i + 1.
      append it_form3.
    endif.
  endloop.


endform.                    "Formeln_aufloesen



*&--------------------------------------------------------------------*
*&      Form  ALV_Qlist
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form ALV_Qlist.
  DATA:
          lt_alv_cat  TYPE  SLIS_T_FIELDCAT_ALV,
          ls_alv_cat  LIKE LINE OF lt_alv_cat.


*       infocube   like v_rep_join-infocube,
*       seltuid    like RSZELTXREF-seltuid,
*       Queriename like RSZELTTXT-txtlg,
*       compid     like v_rep_join-compid,
*       owner      like v_rep_join-owner,
*       tstpnm     like v_rep_join-tstpnm,
*       tstpdat    like v_rep_join-tstpdat,
*       tstptim    like v_rep_join-tstptim,


  ls_alv_cat-fieldname     = 'INFOCUBE'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'INFOCUBE'.
  ls_alv_cat-SELTEXT_L       = 'InfoCube'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-ddictxt         = 'L'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'QUERIENAME'.
  ls_alv_cat-ref_tabname     = 'RSZELTTXT'.
  ls_alv_cat-ref_fieldname     = 'TXTLG'.
  ls_alv_cat-SELTEXT_L       = 'Querybezeichnung'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-ddictxt         = 'L'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'COMPID'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'COMPID'.
  ls_alv_cat-SELTEXT_L       = 'Technischer Name der Query'.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-ddictxt         = 'L'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'OWNER'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'OWNER'.
  ls_alv_cat-SELTEXT_L       = ''.
  ls_alv_cat-SELTEXT_M       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-SELTEXT_S       = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-text_fieldname  = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-reptext_ddic    = ls_alv_cat-SELTEXT_L.
  ls_alv_cat-ddictxt         = ''.

  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'TSTPNM'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'TSTPNM'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'TSTPDAT'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'TSTPDAT'.
  APPEND ls_alv_cat TO lt_alv_cat.

  ls_alv_cat-fieldname     = 'TSTPTIM'.
  ls_alv_cat-ref_tabname     = 'V_REP_JOIN'.
  ls_alv_cat-ref_fieldname     = 'TSTPTIM'.
  APPEND ls_alv_cat TO lt_alv_cat.


  sort it_queries by infocube queriename.


  DATA: titel TYPE	LVC_TITLE value 'Liste der Queries'.
  data: IS_VARIANT     LIKE  DISVARIANT.
  DATA: l_user_command type  SLIS_FORMNAME.
  data: it_exits       type SLIS_T_EVENT_EXIT with header line.


  is_variant-report = sy-repid.
  is_variant-handle = '0001'.
  is_variant-username = sy-uname.
  l_user_command = 'USER_COMMAND'.
  it_exits-ucomm = '&IC1'.
  it_exits-before = ''.
  it_exits-after = 'X'.
  append it_exits.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = sy-repid
*   I_CALLBACK_PF_STATUS_SET          = ' '
    I_CALLBACK_USER_COMMAND           = l_user_command
*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      = titel
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         =
      IT_FIELDCAT                       = lt_alv_cat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
      I_SAVE                            = 'B'
      IS_VARIANT                        = is_variant
*   IT_EVENTS                         =
    IT_EVENT_EXIT                     = it_exits[]
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      T_OUTTAB                          = it_queries
   EXCEPTIONS
     PROGRAM_ERROR                     = 1
     OTHERS                            = 2
            .
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


endform.                    "ALV_Qlist


*&--------------------------------------------------------------------*
*&      Form  user_command
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->R_UCOMM    text
*      -->RS_SELFIELDtext
*---------------------------------------------------------------------*
FORM user_command  USING r_ucomm LIKE sy-ucomm
                                   rs_selfield TYPE slis_selfield.

  DATA: i type i.
  describe table it_queries lines i.

  if r_ucomm = '&IC1'.  "Doppelklick auf eine Zeile
    if rs_selfield-tabindex <> 0 and i >= rs_selfield-tabindex.

      read table it_queries index rs_selfield-tabindex.
      if gmode = 1.
        p_compid = it_queries-compid.
        r_ucomm = '&F03'.     "Abbruch des ALV´s
      endif.
      if gmode = 2.
        s_compid-sign = 'I'.
        s_compid-option = 'EQ'.
        s_compid-low = it_queries-compid.
        s_compid-high = ''.
        append s_compid.
      endif.
    endif.
  endif.

endform.                    "user_command





*&--------------------------------------------------------------------*
*&      Form  vergleich
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form vergleich.
*TYPES: begin of tt_Formeln3,
*       infocube   like v_rep_join-infocube,
*       Queriename like RSZELTTXT-txtlg,
*       compid     like v_rep_join-compid,
*       owner      like v_rep_join-owner,
*       tstpnm     like v_rep_join-tstpnm,
*       tstpdat    like v_rep_join-tstpdat,
*       tstptim    like v_rep_join-tstptim,
*       Formelfeld like RSZELTTXT-txtlg,
*       stepnr     like rszcalc-stepnr,
*       opera      like rszcalc-opera,
*       oper1t     like RSZELTTXT-txtlg,
*       teltuid    like RSZELTXREF-teltuid,
*       oper1      like rszcalc-oper1,
*       status     like RSZELTTXT-txtSH,
*       end of tt_formeln3.
*
*DATA: it_form3 type standard table of tt_formeln3 with header line.
*DATA: it_formv type sorted table of tt_formeln3 with header line
*      with non-unique key Formelfeld oper1t compid.



* Die Daten stehen in it_form3.
* Nur die Vorlage bleibt in form3 stehen, der Rest wird nach formv
* verschoben

  DATA: it_compid type standard table of tt_formeln3 with header line.

  insert lines of it_form3 into table it_formv.
  delete it_form3 where compid <> vorlage-compid.
  delete it_formv where compid = vorlage-compid.


* Ermitteln aller selektierten Queries
* Mit diesen Kopfdaten werden später die Fehlenden Einträge versorgt!
  loop at it_formv.
    on change of it_formv-compid.
      it_compid = it_formv.
      append it_compid.
    endon.
  endloop.


  sort it_compid.
  DELETE ADJACENT DUPLICATES FROM it_compid.


  loop at it_form3.
    it_form3-status = 'Original'.
    it_form3-infocube+1 = it_form3-infocube.
    it_form3-infocube(1) = '_'.
    modify it_form3.
  endloop.

  loop at it_form3.


    loop at it_formv where formelfeld = it_form3-formelfeld and
                           oper1t     = it_form3-oper1t and
                           opera      = it_form3-opera.
      it_formv-status = 'OK'.
      modify it_formv.
    endloop.


    loop at it_formv where formelfeld = it_form3-formelfeld and
                            oper1t     = it_form3-oper1t and
                            status     = ' '.
      it_formv-status = 'abw. Operand'.
      modify it_formv.
    endloop.

    loop at it_compid.
      read table it_formv with key formelfeld = it_form3-formelfeld
                                   oper1t     = it_form3-oper1t
                                   compid     = it_compid-compid.
      if sy-subrc <> 0.
        it_formv = it_form3.
        it_formv-infocube   = it_compid-infocube.
        it_formv-Queriename = it_compid-Queriename.
        it_formv-compid     = it_compid-compid.
        it_formv-owner      = it_compid-owner.
        it_formv-tstpdat    = it_compid-tstpdat.
        it_formv-tstpnm     = it_compid-tstpnm.
        it_formv-tstptim    = it_compid-tstptim.
        it_formv-Status     = 'Feld fehlt'.
        insert it_formv into table it_formv.
      endif.
    endloop.

  endloop.


  insert lines of it_formv into table it_form3.
  sort it_form3 by infocube compid formelfeld oper1t.

  data: l_form  like it_form3.
  DATA: l_rc    type i.
  DATA: i_ok1   type i,
        i_fehlt type i,
        i_neu   type i,
        i_anz   type i.

  DATA: begin of it_del occurs 0,
        infocube   like it_form3-infocube,
        compid     like it_form3-compid,
        formelfeld like it_form3-formelfeld,
        end of it_del.


  clear: l_rc, i_ok1, i_fehlt, i_neu, i_anz.


  loop at it_form3.

    if l_form-infocube   <> it_form3-infocube or
       l_form-compid     <> it_form3-compid or
       l_form-formelfeld <> it_form3-formelfeld or
       l_form-oper1t     <> it_form3-oper1t.
      clear l_rc.

      if l_form-infocube   <> it_form3-infocube or
         l_form-compid     <> it_form3-compid or
         l_form-formelfeld <> it_form3-formelfeld.

        if i_anz > 0.
          if ( i_anz   = i_ok1   and p_ok1   = 'X' ) or
             ( i_anz   = i_fehlt and p_fehlt = 'X' ) or
             ( i_anz   = i_neu   and p_neu   = 'X' ).
* Jetzt das komplette Feld ausblenden !!!

            move-corresponding l_form to it_del. append it_del.
          endif.
        endif.

        clear: i_ok1, i_fehlt, i_neu, i_anz.

      endif.
      l_form = it_form3.
    endif.

    l_rc = l_rc + 1.
    if l_rc > 1.
      it_form3-status = 'doppeltes Feld'.
      modify it_form3.
    endif.

    if it_form3-status = ''.
      it_form3-status = 'Feld zuviel'.
      modify it_form3.
    endif.

* Anzeigefilter !!!
*p_ok1  as checkbox,  "Alle komplett korrekten Formeln ausblenden 
(OK)
*p_fehlt as checkbox. "Nicht existente Formeln ignorieren (Feld fehlt)
*p_neu   as checkbox. "komplett neue Formeln (Feld zuviel)
    case it_form3-status.
      when 'OK'.           i_ok1   = i_ok1 + 1.
      when 'Feld fehlt'.   i_fehlt = i_fehlt + 1.
      when 'Feld zuviel'.  i_neu   = i_neu + 1.
      when others.
    endcase.
    i_anz = i_anz + 1.

  endloop.

  if i_anz > 0.
    if ( i_anz   = i_ok1   and p_ok1   = 'X' ) or
       ( i_anz   = i_fehlt and p_fehlt = 'X' ) or
       ( i_anz   = i_neu   and p_neu   = 'X' ).
* Jetzt das komplette Feld ausblenden !!!
* Hier noch einmal nach der loop, falls das letzte Feld auszublenden
ist
      move-corresponding l_form to it_del. append it_del.
    endif.
  endif.

  describe table it_del lines i.
  if i > 0.

    sort it_del by infocube compid formelfeld.
    l_rc = 1.
    clear l_form.
* löschen der gefundenen auszublendenden Formeln.
    loop at it_form3.

      if l_form-infocube   <> it_form3-infocube or
         l_form-compid     <> it_form3-compid or
         l_form-formelfeld <> it_form3-formelfeld.
        l_form = it_form3.
        read table it_del with key infocube   = it_form3-infocube
                                   compid     = it_form3-compid
                                   formelfeld = it_form3-formelfeld
                                   binary search.
        l_rc = sy-subrc.
      endif.

      if l_rc = 0.
        delete it_form3.
      endif.

    endloop.
  endif.


  sort it_form3 by infocube compid formelfeld stepnr.

* Anzeigefilter !!!

*p_orig as checkbox,  "Original Ausblenden
*p_ok2  as checkbox,  "Alle Felder mit Status OK ausblenden
*p_orig2 as checkbox, "Originalformeln ohne fehler ausblenden

  if p_orig = 'X'.
    delete it_form3 where status = 'Original'.
  endif.

  if p_ok2 = 'X'.
    delete it_form3 where status = 'OK'.
  endif.

  refresh it_formv.
  clear it_formv.


  if p_orig = '' and p_orig2 = 'X'.
* Jetzt alle Formelfelder im Original löschen, die in den Kopien nicht
* mehr vorkommen!!!

    loop at it_form3 where status <> 'Original' and
                           status <> 'OK'.
      it_formv-formelfeld = it_form3-formelfeld.
      insert it_formv into table it_formv.
    endloop.

    DELETE ADJACENT DUPLICATES from it_formv comparing formelfeld.

    loop at it_form3 where status = 'Original'.
      read table it_formv with key formelfeld = it_form3-formelfeld
                                   oper1t     = ''
                                   compid     = ''.
      if sy-subrc <> 0.
        delete it_form3.
      endif.
    endloop.

  endif.


endform.                    "vergleich

home help back first fref pref prev next nref lref last post