*---------------------------------------------------------------------*
*           Z _ B J H _ B A P I _ R O U T I N G _ C R E A T E         *
*                                                                     *
*                  Autor: Bernd Haase (BJH Software)                  *
*---------------------------------------------------------------------*
* Beispielprogramm für den Aufruf des BAPI_ROUTING_CREATE. Es werden  *
* Materialien und Werke vorgegeben. Das Programm sucht daraus eine    *
* Ergebnismenge, die zusätzlich noch durch den Planstatus und das     *
* Datum weiter eingegrenzt werden kann. Danach werden die Pläne 1:1   *
* kopiert. Zum Abschluß erfolgt noch eine Statistik über den gesamten *
* Lauf, welches auch in eine Datei geschrieben werden kann.           *
*---------------------------------------------------------------------*
* (T) FB Output-Datei, Read_Text, Inner Join(2), Warnstufe            *
*---------------------------------------------------------------------*
* 13.04.2004 BHaa: Programm aus Vorlage Datumkorrektur kopiert        *
* 09.05.2005 BHaa: etwas mehr Felder für die Statistik            V1.1*
* 11.05.2005 BHaa: Eieruhr für den Fortgang anzeigen              V1.2*
*---------------------------------------------------------------------*
REPORT  z_bjh_bapi_routing_create .

INCLUDE .

TABLES:
 crfh,    "CIM Production Resource and Tool Master Data
 crhd,    "Arbeitsplatz Kopf
 crvd_a,  "Verknüpfung Fertigungshilfsmittel - Dokument
 crve_a,  "Verknüpfung FHM-Daten - Equipment
 crvm_a,  "Verknüpfung Fertigungshilfsmitteldaten - Material
 crvs_a,  "Verknüpfung Fertigungshilfsmittel ohne Material
 mapl,    "Zuordnung von Plänen zu Materialien
 plas,    "Plan - Auswahl von Positionen
 plfh,    "Plan - Fertigungshilfsmittel
 plfl,    "Plan-Folgen
 plko,    "Plan - Kopf
 plmk,    "Prüfplanmerkmale
 plmz,    "Zuordnungen Stücklistenpositionen zu Arbeitsvorgängen
 plpo,    "Plan: Vorgang
 stpo,    "Stücklistenposition
 stxh.    "STXD SAPscript Text-Datei Header

DATA:
 anzahl(6) TYPE n,
 anzahl_zeilen LIKE anzahl,
 anzahl_fehler LIKE anzahl,
 anzahl_f_bapi LIKE anzahl,
* Anzahl der einzelnen Warnstufen nach BAPI-Aufruf
 anzahl_rot    LIKE anzahl,
 anzahl_gelb   LIKE anzahl,
 anzahl_gruen  LIKE anzahl,
 anzahl_plko   LIKE anzahl,              "V1.2 wieviele Pläne im Umlauf
 anzahl_bapi   LIKE anzahl,              "V1.1 BAPI-Aufrufe
 anzahl_erfolgreich LIKE anzahl,         "V1.1 davon waren erfolgreich
 anz_prozent(3) TYPE p DECIMALS 2,       "V1.2 für die Eieruhr

 fb_ftp(1) TYPE c,
 zw_text(100) TYPE c,
 wa_fehlerhaft(1) TYPE c,
 wa_test LIKE bapiflag.

*****************************
* Vorlauf, Material im Plan *
*****************************
DATA:
 BEGIN OF in_mapl,
   matnr LIKE mapl-matnr,
   werks LIKE mapl-werks,
   plnnr LIKE mapl-plnnr,
   plnal LIKE mapl-plnal,
 END OF in_mapl,
 intab_mapl LIKE TABLE OF in_mapl.

*********************
* Material zum Plan *
*********************
DATA:
 BEGIN OF ct_mapl,
   plnty LIKE mapl-plnty,
   werks LIKE mapl-werks,
   matnr LIKE mapl-matnr,
   plnnr LIKE mapl-plnnr,
   plnal LIKE mapl-plnal,
 END OF ct_mapl,
 cttab_mapl LIKE TABLE OF ct_mapl,

 wa_mapl LIKE mapl,

 itab_mapl LIKE SORTED TABLE OF wa_mapl
           WITH NON-UNIQUE KEY matnr plnty plnnr plnal.

************
* Plankopf *
************
DATA:
 BEGIN OF ct_plko,
   plnty LIKE plko-plnty,
   plnnr LIKE plko-plnnr,
   plnal LIKE plko-plnal,
   werks LIKE plko-werks,
   matnr LIKE mapl-matnr,
   vagrp LIKE plko-vagrp,
 END OF ct_plko,
 cttab_plko LIKE TABLE OF ct_plko,

 wa_plko LIKE plko,

 itab_plko LIKE HASHED TABLE OF wa_plko
           WITH UNIQUE KEY plnty plnnr plnal.

**************
* Planfolgen *
**************
DATA:
 wa_plfl LIKE plfl,

 itab_plfl LIKE TABLE OF wa_plfl
           WITH NON-UNIQUE KEY plnty plnnr.

*****************
* Plansequenzen *
*****************
DATA:
 BEGIN OF ct_plas,
   plnty LIKE plas-plnty,
   plnnr LIKE plas-plnnr,
   plnal LIKE plas-plnal,
   plnfl LIKE plas-plnfl,
 END OF ct_plas,
 cttab_plas LIKE TABLE OF ct_plas,

 wa_plas LIKE plas,

 itab_plas LIKE TABLE OF wa_plas
           WITH NON-UNIQUE KEY plnty plnnr.

******************
* Planpositionen *
******************
DATA:
 BEGIN OF ct_plpo,
   plnty LIKE plpo-plnty,
   plnnr LIKE plpo-plnnr,
   plnkn LIKE plpo-plnkn,
   arbpl LIKE crhd-arbpl,
   logrp LIKE plpo-logrp,
 END OF ct_plpo,
 cttab_plpo LIKE TABLE OF ct_plpo,

 wa_plpo LIKE plpo,

 itab_plpo LIKE TABLE OF wa_plpo
           WITH NON-UNIQUE KEY plnty plnnr.

*****************
* Arbeitsplätze *
*****************
DATA:
 BEGIN OF ct_crhd,
   objid LIKE crhd-objid,
 END OF ct_crhd,
 cttab_crhd LIKE TABLE OF ct_crhd,

 BEGIN OF wk_crhd,
   objid LIKE crhd-objid,
   arbpl LIKE crhd-arbpl,
 END OF wk_crhd,
 wktab_crhd LIKE HASHED TABLE OF wk_crhd WITH UNIQUE KEY objid.

*********************************
* Fertigungshilfsmittel im Plan *
*********************************
DATA:
 BEGIN OF ct_plfh,
   plnty LIKE plfh-plnty,
   plnnr LIKE plfh-plnnr,
 END OF ct_plfh,
 cttab_plfh LIKE TABLE OF ct_plfh,

 wa_plfh LIKE plfh,

 itab_plfh LIKE TABLE OF wa_plfh
           WITH NON-UNIQUE KEY plnty plnnr.

*************************
* Fertigungshilfsmittel *
*************************
DATA:
 BEGIN OF ct_crfh,
   objty LIKE crfh-objty,
   objid LIKE crfh-objid,
 END OF ct_crfh,
 cttab_crfh LIKE TABLE OF ct_crfh,
* Dokument
 cttab_crvd LIKE TABLE OF ct_crfh,
* Equipment / Ausstattung
 cttab_crve LIKE TABLE OF ct_crfh,
* Material
 cttab_crvm LIKE TABLE OF ct_crfh,
* sonstige
 cttab_crvs LIKE TABLE OF ct_crfh,

 BEGIN OF wk_crfh,
   objty LIKE crfh-objty,
   objid LIKE crfh-objid,
   fhmar LIKE crfh-fhmar,
* die einzelnen Felder aus den zusätlichen Tabellen
* in der doknr stecken auch die Materialnummer, Equipment und sonstige
   werks LIKE crvm_a-werks,
   dokar LIKE crvd_a-dokar,
   doknr LIKE crvd_a-doknr,
   doktl LIKE crvd_a-doktl,
   dokvr LIKE crvd_a-dokvr,
 END OF wk_crfh,
 wktab_crfh LIKE HASHED TABLE OF wk_crfh WITH UNIQUE KEY objty objid,

 wa_crvd LIKE crvd_a,
 itab_crvd LIKE TABLE OF crvd_a,

 wa_crve LIKE crve_a,
 itab_crve LIKE TABLE OF crve_a,

 wa_crvm LIKE crvm_a,
 itab_crvm LIKE TABLE OF crvm_a,

 wa_crvs LIKE crvs_a,
 itab_crvs LIKE TABLE OF crvs_a.

***************************
* Material zur Stückliste *
***************************
DATA:
 BEGIN OF ct_mast,
   stlnr LIKE mast-stlnr,
   stlal LIKE mast-stlal,
 END OF ct_mast,
 cttab_mast LIKE TABLE OF ct_mast,

 BEGIN OF wk_mast,
   matnr LIKE mast-matnr,
   werks LIKE mast-werks,
   stlnr LIKE mast-stlnr,
   stlal LIKE mast-stlal,
 END OF wk_mast,
 wktab_mast LIKE TABLE OF wk_mast.

***********************
* Stücklistenposition *
***********************
DATA:
 BEGIN OF ct_stpo,
   stlty LIKE stpo-stlty,
   stlnr LIKE stpo-stlnr,
   stlkn LIKE stpo-stlkn,
 END OF ct_stpo,
 cttab_stpo LIKE TABLE OF ct_stpo,

 BEGIN OF wk_stpo,
   stlty LIKE stpo-stlty,
   stlnr LIKE stpo-stlnr,
   stlkn LIKE stpo-stlkn,
   posnr LIKE stpo-posnr,
   datuv LIKE stpo-datuv,
 END OF wk_stpo,
 wktab_stpo LIKE TABLE OF wk_stpo.

*********************************
* Zuordnung Plan <=> Stückliste *
*********************************
DATA:
 wa_plmk LIKE plmk,

 itab_plmk LIKE TABLE OF wa_plmk
           WITH NON-UNIQUE KEY plnty plnnr.

****************
* Prüfmerkmale *
****************
DATA:
 wa_plmz LIKE plmz,

 itab_plmz LIKE TABLE OF wa_plmz
           WITH NON-UNIQUE KEY plnty plnnr.

*************
* Langtexte *
*************
DATA:
 t_thead LIKE thead OCCURS 1 WITH HEADER LINE.

DATA:
* falls der Schlüssel zusammengebaut werden muß
 wa_tdname LIKE stxh-tdname.

*---------------------------------------------------------------------*
* Zwischentabelle für den aufgeteilten Text.
* der Fließtext wird gesplittet und in die Datenelemente
* abgespeichert
*---------------------------------------------------------------------*
DATA: BEGIN OF t_lines OCCURS 0.
       INCLUDE STRUCTURE tline.
DATA: END OF t_lines,

 wa_lines LIKE t_lines.

*******************
* Datei schreiben *
*******************
DATA:
 BEGIN OF wa_out,
   plnnr_neu LIKE plko-plnnr,
   t01(1)    TYPE c,
   plnnr_alt LIKE plko-plnnr,                              "V1.1
   t02(1)    TYPE c,
   matnr     LIKE mapl-matnr,             "V1.1 erste Materialnummer
   t03(1)    TYPE c,
   type      LIKE bapiret2-type,
   t04(1)    TYPE c,
   id(10)    TYPE c,                      "LIKE bapiret2-id,
   t05(1)    TYPE c,
   number    LIKE bapiret2-number,
   t06(1)    TYPE c,
   message   LIKE bapiret2-message,
 END OF wa_out,

 BEGIN OF ds_out,
   satz LIKE wa_out,
 END OF ds_out,

 dstab_out LIKE TABLE OF ds_out.

*---------------------------------------------------------------------*
*                    B a p i - V a r i a b l e n                      *
*---------------------------------------------------------------------*
DATA:
 neue_plnnr LIKE plko-plnnr,
 neue_plnal LIKE plko-plnal.

DATA:
 BEGIN OF itab_bapi_plko OCCURS 0.
       INCLUDE STRUCTURE bapi1012_tsk_c.
DATA:
 END OF itab_bapi_plko,

 BEGIN OF itab_bapi_mapl OCCURS 0.
       INCLUDE STRUCTURE bapi1012_mtk_c.
DATA:
 END OF itab_bapi_mapl,

 BEGIN OF itab_bapi_plfl OCCURS 0.
       INCLUDE STRUCTURE bapi1012_seq_c.
DATA:
 END OF itab_bapi_plfl,

 BEGIN OF itab_bapi_plpo OCCURS 0.
       INCLUDE STRUCTURE bapi1012_opr_c.
DATA:
 END OF itab_bapi_plpo,

 BEGIN OF itab_bapi_plmz OCCURS 0.
       INCLUDE STRUCTURE bapi1012_com_c.
DATA:
 END OF itab_bapi_plmz,

 BEGIN OF itab_bapi_plfh OCCURS 0.
       INCLUDE STRUCTURE bapi1012_prt_c.
DATA:
 END OF itab_bapi_plfh,

 BEGIN OF itab_bapi_plmk OCCURS 0.
       INCLUDE STRUCTURE bapi1012_cha_c.
DATA:
 END OF itab_bapi_plmk,

 BEGIN OF itab_bapi_stxh OCCURS 0.
       INCLUDE STRUCTURE bapi1012_txt_hdr_c.
DATA:
 END OF itab_bapi_stxh,

* Positionierung der Texte in der Bapi-Struktur-Übergabe
 wa_ltxt_index LIKE bapi1012_txt_hdr_c-line_from,

 BEGIN OF itab_bapi_ltxt OCCURS 0.
       INCLUDE STRUCTURE bapi1012_txt_c.
DATA:
 END OF itab_bapi_ltxt,

 wa_bapi_return LIKE bapiret2,

 BEGIN OF itab_bapi_return OCCURS 0.
       INCLUDE STRUCTURE bapiret2.
DATA:
 END OF itab_bapi_return.

*---------------------------------------------------------------------*
*                                                                     *
*                 A u s w a h l b i l d s c h i r m                   *
*                                                                     *
*---------------------------------------------------------------------*
* Auswahl und Eingrenzung von Arbeitsplanaufträgen
SELECTION-SCREEN: BEGIN OF BLOCK a1 WITH FRAME TITLE text-901.
PARAMETERS:
* Plantyp, gilt für Aufträge wie für Vorgänge
 pm_plnty LIKE plko-plnty OBLIGATORY.
SELECT-OPTIONS:
* Parameter für den Arbeitsplan
* Materialnummer
 so_matnr FOR mapl-matnr,
* Werk
 so_werks FOR plko-werks DEFAULT '0110',
* welche Stati sollen beachtet werden
 so_statu FOR plko-statu DEFAULT 'X',
* Gültigkeitsdatum (ab wann der Plan gilt)
 so_datvk FOR plko-datuv.

SELECT-OPTIONS:
* zusätzlich noch Arbeitsplanspositionen (AVOs) selektieren
* Gültigkeitsdatum von Arbeitsvorgängen (AVOs). Hier gilt nur der
* Plantyp, alle weiteren Einstellungen zählen nicht
 so_datvp FOR plpo-datuv NO-DISPLAY.
SELECTION-SCREEN: END OF BLOCK a1.

* Aktion, Einspielmodus, Fehleranzeige sowie Dateiname des Ergebnisses
SELECTION-SCREEN: BEGIN OF BLOCK a3 WITH FRAME TITLE text-902.
PARAMETERS:
* neues Gültigkeitsdatum
 pm_datng LIKE plko-datuv OBLIGATORY DEFAULT '20050514',  "od.SY-DATUM,
* Aktion. Testlauf mit Statistik oder Echtlauf mit Änderungen
 pmx_test TYPE c RADIOBUTTON GROUP grp3 DEFAULT 'X',
 pmx_echt TYPE c RADIOBUTTON GROUP grp3,
* Warnstufenanzeige
 pmx_rot  TYPE c RADIOBUTTON GROUP grp2,
 pmx_gelb TYPE c RADIOBUTTON GROUP grp2 DEFAULT 'X',
 pmxgruen TYPE c RADIOBUTTON GROUP grp2.
SELECTION-SCREEN: END OF BLOCK a3.

* Steuerung, wohin Datei geschrieben werden soll (Plattform und Name)
* pmout = Ergebnisdatei soll wohin gespeichert werden. FTP-Block
INCLUDE zmgl_bjh_ftp_data.

INITIALIZATION.
 MOVE 'N' TO pm_plnty.

 CLEAR:   so_datvk, so_datvp, so_statu.
 REFRESH: so_datvk, so_datvp, so_statu.

 MOVE 'I'  TO: so_datvk-sign,   so_datvp-sign,   so_statu-sign.
 MOVE 'EQ' TO: so_datvk-option, so_datvp-option, so_statu-option.

 MOVE: 'BT'       TO so_datvk-option,
       'I'        TO so_datvk-sign,
       '18000101' TO so_datvk-low,
       '99991231' TO so_datvk-high.
 APPEND so_datvk.

* Vorbesetzung Status: nur freigegebene
 MOVE 'X' TO so_statu-low.
 APPEND so_statu.

* Ein-/Ausgabedefinition füt FTP-Datentransfer
 MOVE 'BJH_PUT' TO ftp_key.
 MOVE ' ' TO pm_titel.

 IF sy-batch = 'X'.
* Hintergrundprogramm, muß über FTP laufen
   MOVE ' ' TO pm_ftp.
   MOVE 'plan_werk_erg' TO pmout.
 ELSE.
* Sichtprogramm, Speichern standardmäßig auf PC
   MOVE 'X' TO pm_ftp.
   CASE sy-uname.
     WHEN 'RRENAE'.
       MOVE 'd:\haase\sap\daten\plan_werk_erg.txt' TO pmout.
     WHEN OTHERS.
       MOVE 'd:\plan_werk_erg.txt' TO pmout.
   ENDCASE.
 ENDIF.

***********************************************************************
*                                                                     *
*                     P R O G R A M M S T A R T                       *
*                                                                     *
***********************************************************************
START-OF-SELECTION.

* bereitstellen der Pläne
 PERFORM upro-vorlauf.

 IF NOT cttab_plko IS INITIAL.
* Pläne gefunden, alle weiteren Tabellen aufbauen
   PERFORM upro-vorlauf_tabellen.

   IF NOT itab_plko IS INITIAL.
* Pläne kopieren
     PERFORM upro-bapi_schleife.
   ENDIF.

 ENDIF.

 SKIP 1.

* zu guter letzt noch ein wenig Statistik am Bildschirm
 PERFORM upro-statistik.

* Ergebnis auch in Datei schreiben, auch wenn es nur ein Testlauf war
 IF  NOT pmout(1)  IS INITIAL
 AND NOT dstab_out IS INITIAL.
   PERFORM upro-ftp_datei_out
           TABLES dstab_out
           USING  ds_out
                  ftp_key
                  pmout.
 ENDIF.

END-OF-SELECTION.
 EXIT.

*---------------------------------------------------------------------*
*                          V O R L A U F                              *
*---------------------------------------------------------------------*
* Daten (Pläne) bereitstellen. Ursprung oder Quelle gemäß Auswahl, ob *
* Daten über datei beschafft werden oder aus den SAP-Tabellen gemäß   *
* den Eingabeparametern.                                              *
*---------------------------------------------------------------------*
FORM upro-vorlauf.

 CLEAR:   cttab_plko, cttab_mapl,
          dstab_out,  anzahl_bapi, anzahl_erfolgreich.
 REFRESH: cttab_plko, cttab_mapl, dstab_out.

* aus den Auswahlparametern die Pläne bestimmen
* nur aktive Pläne heranziehen, auch keine löschvorgemerkten
 SELECT
   ij_mapl~matnr
   ij_mapl~werks
   ij_mapl~plnnr
   ij_mapl~plnal
 FROM       mapl AS ij_mapl
 INNER JOIN plko AS ij_plko
 ON    ij_mapl~plnty = ij_plko~plnty
   AND ij_mapl~plnnr = ij_plko~plnnr
   AND ij_mapl~plnal = ij_plko~plnal
 INTO TABLE intab_mapl
 WHERE ij_mapl~plnty = pm_plnty
 AND   ij_mapl~matnr IN so_matnr
 AND   ij_mapl~werks IN so_werks
 AND   ij_mapl~loekz <> 'X'
 AND   ij_plko~datuv IN so_datvk
 AND   ij_plko~statu IN so_statu
 AND   ij_plko~loekz <> 'X'                 "Plan ist NICHT gelöscht
 AND   ij_plko~delkz <> 'X'.  "Plan ist NICHT zum Löschen vorgemerkt

 LOOP AT intab_mapl INTO in_mapl.
   MOVE pm_plnty      TO: ct_plko-plnty, ct_mapl-plnty.
   MOVE in_mapl-plnnr TO: ct_plko-plnnr, ct_mapl-plnnr.
   MOVE in_mapl-plnal TO: ct_plko-plnal, ct_mapl-plnal.
   MOVE in_mapl-matnr TO  ct_mapl-matnr.
   MOVE in_mapl-werks TO  ct_mapl-werks.
   COLLECT ct_plko INTO cttab_plko.
   COLLECT ct_mapl INTO cttab_mapl.
 ENDLOOP.

ENDFORM.

*---------------------------------------------------------------------*
*                   V O R L A U F _ T A B E L L E N                   *
*---------------------------------------------------------------------*
* zu den ermittelten Plänen im Vorlauf nun alle untergliederten Ta-   *
* bellen ebenfalls auswerten und deren Werte merken. Komplette Struk- *
* turen einspielen, wenn Kopie über BAPI läuft, wird dieses benötigt  *
*---------------------------------------------------------------------*
FORM upro-vorlauf_tabellen.

 CLEAR: itab_mapl,  itab_plko,
        itab_plas,  cttab_plas,
        itab_plpo,  cttab_plpo,
        itab_plfh,  cttab_plfh, cttab_mast, wktab_mast,
        itab_plmk,  itab_plmz,  cttab_stpo, wktab_stpo,
        cttab_crfh, cttab_crvd, cttab_crve, cttab_crvm, cttab_crvs,
        wktab_crfh, itab_crvd,  itab_crve,  itab_crvm,  itab_crvs,
        wktab_crhd, cttab_crhd.

 REFRESH: itab_mapl,  itab_plko,
          itab_plas,  cttab_plas,
          itab_plpo,  cttab_plpo,
          itab_plfh,  cttab_plfh,
          itab_plmk,  itab_plmz,  cttab_stpo, wktab_stpo,
          cttab_crfh, cttab_crvd, cttab_crve, cttab_crvm, cttab_crvs,
          wktab_crfh, itab_crvd,  itab_crve,  itab_crvm,  itab_crvs,
          wktab_crhd, cttab_crhd.

* Arbeitspläne. Abprüfen auf Status bereits im Vorlauf. Bei Einlesen
* über Datei oder Vorgängen keine weiteren Prüfungen
 IF NOT cttab_plko IS INITIAL.
* Materialien zum Plan
   SELECT * FROM mapl
   INTO TABLE itab_mapl
   FOR ALL ENTRIES IN cttab_mapl
   WHERE plnty =  cttab_mapl-plnty
   AND   plnnr =  cttab_mapl-plnnr
   AND   plnal =  cttab_mapl-plnal
   AND   matnr =  cttab_mapl-matnr
   AND   werks =  cttab_mapl-werks
   AND   loekz <> 'X'.

* Pläne
   SELECT * FROM plko
   INTO TABLE itab_plko
   FOR ALL ENTRIES IN cttab_plko
   WHERE plnty =  cttab_plko-plnty
   AND   plnnr =  cttab_plko-plnnr
   AND   plnal =  cttab_plko-plnal
   AND   aennr =  '            '
   AND   loekz <> 'X'
   AND   delkz <> 'X'.

* Planfolgen
   SELECT * FROM plfl
   INTO TABLE itab_plfl
   FOR ALL ENTRIES IN cttab_plko
   WHERE plnnr =  cttab_plko-plnnr
   AND   plnal =  cttab_plko-plnal
   AND   loekz <> 'X'.
 ENDIF.

 LOOP AT itab_plfl INTO wa_plfl.
   MOVE wa_plfl-plnty TO: ct_plas-plnty, ct_plfh-plnty.
   MOVE wa_plfl-plnnr TO: ct_plas-plnnr, ct_plfh-plnnr.
   MOVE wa_plfl-plnal TO  ct_plas-plnal.
   MOVE wa_plfl-plnfl TO  ct_plas-plnfl.
   COLLECT ct_plas INTO cttab_plas.
   COLLECT ct_plfh INTO cttab_plfh.
 ENDLOOP.

* Auswahl der Positionen
 IF NOT cttab_plas IS INITIAL.
   SELECT * FROM plas
   INTO TABLE itab_plas
   FOR ALL ENTRIES IN cttab_plas
   WHERE plnty =  cttab_plas-plnty
   AND   plnnr =  cttab_plas-plnnr
   AND   plnal =  cttab_plas-plnal
   AND   plnfl =  cttab_plas-plnfl
   AND   loekz <> 'X'.

   LOOP AT itab_plas INTO wa_plas.
     MOVE wa_plas-plnty TO ct_plpo-plnty.
     MOVE wa_plas-plnnr TO ct_plpo-plnnr.
     MOVE wa_plas-plnkn TO ct_plpo-plnkn.
     COLLECT ct_plpo INTO cttab_plpo.
   ENDLOOP.

* AVOs (Arbeitsvorgänge)
   IF NOT cttab_plpo IS INITIAL.
     SELECT * FROM plpo
     INTO TABLE itab_plpo
     FOR ALL ENTRIES IN cttab_plpo
     WHERE plnty =  cttab_plpo-plnty
     AND   plnnr =  cttab_plpo-plnnr
     AND   plnkn =  cttab_plpo-plnkn
*     AND   aennr =  '            '  "gemäß Konzept nur in PLKO
     AND   loekz <> 'X'.

* sammeln der Arbeitsplätze in den Vorgängen
     LOOP AT itab_plpo INTO wa_plpo.
       MOVE wa_plpo-arbid TO ct_crhd-objid.
       COLLECT ct_crhd INTO cttab_crhd.
     ENDLOOP.

     IF NOT cttab_crhd IS INITIAL.
* alle gefundenen Arbeitsplätze zur Verfügung stellen
       SELECT * FROM crhd
       INTO CORRESPONDING FIELDS OF TABLE wktab_crhd
       FOR ALL ENTRIES IN cttab_crhd
       WHERE objty = 'A'
       AND   objid = cttab_crhd-objid.
     ENDIF.

* Prüfplanmerkmale
     SELECT * FROM plmk
     INTO TABLE itab_plmk
     FOR ALL ENTRIES IN cttab_plpo
     WHERE plnty =  cttab_plpo-plnty
     AND   plnnr =  cttab_plpo-plnnr
     AND   plnkn =  cttab_plpo-plnkn
     AND   loekz <> 'X'.

* Zuordnungen Stücklistenpositionen zu Arbeitsvorgängen
     SELECT * FROM plmz
     INTO TABLE itab_plmz
     FOR ALL ENTRIES IN cttab_plpo
     WHERE plnty =  cttab_plpo-plnty
     AND   plnnr =  cttab_plpo-plnnr
     AND   plnkn =  cttab_plpo-plnkn
     AND   loekz <> 'X'.

* bei den Stücklisten werden noch die Vorgangsnummern benötigt, diese
* stehen jedoch nur in den Stücklistentabellen selber. Im Stücklis-
* tenkopf ist das Material von Interesse, das Werk ergibt sich um die
* Umsetztabelle
     LOOP AT itab_plmz INTO wa_plmz.
       MOVE wa_plmz-stlty TO  ct_stpo-stlty.
       MOVE wa_plmz-stlnr TO: ct_stpo-stlnr, ct_mast-stlnr.
       MOVE wa_plmz-stlkn TO  ct_stpo-stlkn.
       MOVE wa_plmz-stlal TO  ct_mast-stlal.
       COLLECT ct_stpo INTO cttab_stpo.
       COLLECT ct_mast INTO cttab_mast.
     ENDLOOP.

     IF NOT cttab_mast IS INITIAL.
       SELECT * FROM mast
       INTO CORRESPONDING FIELDS OF TABLE wktab_mast
       FOR ALL ENTRIES IN cttab_mast
       WHERE stlnr =  cttab_mast-stlnr
       AND   stlal =  cttab_mast-stlal.
     ENDIF.
     IF NOT cttab_stpo IS INITIAL.
       SELECT * FROM stpo
       INTO CORRESPONDING FIELDS OF TABLE wktab_stpo
       FOR ALL ENTRIES IN cttab_stpo
       WHERE stlty =  cttab_stpo-stlty
       AND   stlnr =  cttab_stpo-stlnr
       AND   stlkn =  cttab_stpo-stlkn
       AND   lkenz <> 'X'.
     ENDIF.
   ENDIF.
 ENDIF.

* Fertigungshilfsmittel im Plan
 IF NOT cttab_plfh IS INITIAL.
   SELECT * FROM plfh
   INTO TABLE itab_plfh
   FOR ALL ENTRIES IN cttab_plfh
   WHERE plnty =  cttab_plfh-plnty
   AND   plnnr =  cttab_plfh-plnnr
   AND   loekz <> 'X'.

   LOOP AT itab_plfh INTO wa_plfh
   WHERE objty = 'FH'.
     MOVE wa_plfh-objty TO ct_crfh-objty.
     MOVE wa_plfh-objid TO ct_crfh-objid.
     COLLECT ct_crfh INTO cttab_crfh.
   ENDLOOP.
 ENDIF.

* Fertigungshilfsmittel, gültig zum neuen Gültigkeitstag
 IF NOT cttab_crfh IS INITIAL.
   SELECT * FROM crfh
   INTO CORRESPONDING FIELDS OF TABLE wktab_crfh
   FOR ALL ENTRIES IN cttab_crfh
   WHERE objty =  cttab_crfh-objty
   AND   objid =  cttab_crfh-objid
   AND   loekz <> 'X'
   AND   datuv <= pm_datng
   AND   datub => pm_datng.

* Fertigungshilfsmittel ist wo zugeordnet
   LOOP AT wktab_crfh INTO wk_crfh.
     MOVE wk_crfh-objty TO ct_crfh-objty.
     MOVE wk_crfh-objid TO ct_crfh-objid.
     CASE wk_crfh-fhmar.
       WHEN 'D'.
         COLLECT ct_crfh INTO cttab_crvd.
       WHEN 'E'.
         COLLECT ct_crfh INTO cttab_crve.
       WHEN 'M'.
         COLLECT ct_crfh INTO cttab_crvm.
       WHEN 'S'.
         COLLECT ct_crfh INTO cttab_crvs.
     ENDCASE.
   ENDLOOP.
 ENDIF.

* Fertigungshilfsmittel - Dokumente
 IF NOT cttab_crvd IS INITIAL.
   SELECT * FROM crvd_a
   INTO TABLE itab_crvd
   FOR ALL ENTRIES IN cttab_crvd
   WHERE objty =  cttab_crvd-objty
   AND   objid =  cttab_crvd-objid.

   LOOP AT itab_crvd INTO wa_crvd.
     READ TABLE wktab_crfh INTO wk_crfh
     WITH TABLE KEY objty = wa_crvd-objty
                    objid = wa_crvd-objid.
     IF sy-subrc = 0.
       MOVE wa_crvd-dokar TO wk_crfh-dokar.
       MOVE wa_crvd-doknr TO wk_crfh-doknr.
       MOVE wa_crvd-doktl TO wk_crfh-doktl.
       MOVE wa_crvd-dokvr TO wk_crfh-dokvr.
       MODIFY TABLE wktab_crfh FROM wk_crfh
              TRANSPORTING dokar doknr doktl dokvr.
     ENDIF.
   ENDLOOP.
 ENDIF.

* Fertigungshilfsmittel - Equipment
 IF NOT cttab_crve IS INITIAL.
   SELECT * FROM crve_a
   INTO TABLE itab_crve
   FOR ALL ENTRIES IN cttab_crve
   WHERE objty =  cttab_crve-objty
   AND   objid =  cttab_crve-objid.

   LOOP AT itab_crve INTO wa_crve.
     READ TABLE wktab_crfh INTO wk_crfh
     WITH TABLE KEY objty = wa_crve-objty
                    objid = wa_crve-objid.
     IF sy-subrc = 0.
       MOVE wa_crve-equnr TO wk_crfh-doknr.
       MODIFY TABLE wktab_crfh FROM wk_crfh
              TRANSPORTING doknr.
     ENDIF.
   ENDLOOP.
 ENDIF.

* Fertigungshilfsmittel - Material
 IF NOT cttab_crvm IS INITIAL.
   SELECT * FROM crvm_a
   INTO TABLE itab_crvm
   FOR ALL ENTRIES IN cttab_crvm
   WHERE objty =  cttab_crvm-objty
   AND   objid =  cttab_crvm-objid.

   LOOP AT itab_crvm INTO wa_crvm.
     READ TABLE wktab_crfh INTO wk_crfh
     WITH TABLE KEY objty = wa_crvm-objty
                    objid = wa_crvm-objid.
     IF sy-subrc = 0.
       MOVE wa_crvm-werks TO wk_crfh-werks.
       MOVE wa_crvm-matnr TO wk_crfh-doknr.
       MODIFY TABLE wktab_crfh FROM wk_crfh
              TRANSPORTING werks doknr.
     ENDIF.
   ENDLOOP.
 ENDIF.

* Fertigungshilfsmittel - sonstige
 IF NOT cttab_crvs IS INITIAL.
   SELECT * FROM crvs_a
   INTO TABLE itab_crvs
   FOR ALL ENTRIES IN cttab_crvs
   WHERE objty =  cttab_crvs-objty
   AND   objid =  cttab_crvs-objid.

   LOOP AT itab_crvs INTO wa_crvs.
     READ TABLE wktab_crfh INTO wk_crfh
     WITH TABLE KEY objty = wa_crvs-objty
                    objid = wa_crvs-objid.
     IF sy-subrc = 0.
       MOVE wa_crvs-sfhnr TO wk_crfh-doknr.
       MODIFY TABLE wktab_crfh FROM wk_crfh
              TRANSPORTING doknr.
     ENDIF.
   ENDLOOP.
 ENDIF.

ENDFORM.

*---------------------------------------------------------------------*
*                      B A P I _ S C H L E I F E                      *
*---------------------------------------------------------------------*
* Alle Pläne durchgehen. Die Vorgehensweise ist die, daß komplett ein *
* Plan aufgebaut wird und dieser dann auch durch den BAPI geschickt   *
* wird. Auch wenn der BAPI das gleichzeitige Anlegen mehrerer Pläne   *
* zuläßt, ist dieses hier nicht umgesetzt worden, wegen der Zuordnung *
* der Plannummer, diese wird vom System automatisch vergeben.         *
*---------------------------------------------------------------------*
FORM upro-bapi_schleife.

* Fehlerprotokolltabellen initialisieren. Diese gelten über alle Pläne
 CLEAR:   itab_bapi_return, wa_bapi_return.
 REFRESH: itab_bapi_return.

 DESCRIBE TABLE itab_plko LINES anzahl_plko.
 LOOP AT itab_plko INTO wa_plko.
   CLEAR wa_fehlerhaft.
* die einzelnen Tabellen für die Pläne und deren Daten initialisieren
   CLEAR:   itab_bapi_plko, itab_bapi_mapl, itab_bapi_plfl,
            itab_bapi_plpo, itab_bapi_plmz, itab_bapi_plfh,
            itab_bapi_plmk, itab_bapi_stxh, itab_bapi_ltxt,
            anzahl_f_bapi.
   REFRESH: itab_bapi_plko, itab_bapi_mapl, itab_bapi_plfl,
            itab_bapi_plpo, itab_bapi_plmz, itab_bapi_plfh,
            itab_bapi_plmk, itab_bapi_stxh, itab_bapi_ltxt.

* Zeiger für Langtexte auf 1 setzen. Der Zeiger zeigt immer auf den
* Anfang eines neuen Textes in der Texttabelle.
   MOVE 1 TO wa_ltxt_index.
* Echtlauf oder Testlauf. Durch Fehler kann der Echtlauf für den Plan
* noch zu einem Testlauf umgebogen werden
   MOVE pmx_test TO wa_test.

* Materialien und Werke
   LOOP AT itab_mapl INTO wa_mapl
   WHERE plnty = wa_plko-plnty
   AND   plnnr = wa_plko-plnnr.
     PERFORM upro-bapi_mapl.
   ENDLOOP.

* Kopfdaten für die Bapi-Struktur füllen, erst jetzt hier auffüllen, da
* auch im Plan das Werk abgefragt wird, dieses kann aber nur in Kombina-
* tion mit dem Material geschehen
   PERFORM upro-bapi_plko.

* und die dazu gehörenden Langtexte
   PERFORM upro-bapi_ltxt_header.

   LOOP AT itab_plfl INTO wa_plfl
   WHERE plnty = wa_plko-plnty
   AND   plnnr = wa_plko-plnnr.
* Planfolgen
     PERFORM upro-bapi_plfl.
   ENDLOOP.

   LOOP AT itab_plpo INTO wa_plpo
   WHERE plnty = wa_plko-plnty
   AND   plnnr = wa_plko-plnnr.
* Positionen
     PERFORM upro-bapi_plpo.

* und die dazu gehörenden Langtexte
     PERFORM upro-bapi_ltxt.
   ENDLOOP.

* Fertigungshilfsmittel
   LOOP AT itab_plfh INTO wa_plfh
   WHERE plnty = wa_plko-plnty
   AND   plnnr = wa_plko-plnnr.
     PERFORM upro-bapi_plfh.
   ENDLOOP.

* Prüfmerkmale
   LOOP AT itab_plmk INTO wa_plmk
   WHERE plnty = wa_plko-plnty
   AND   plnnr = wa_plko-plnnr.
     PERFORM upro-bapi_plmk.
   ENDLOOP.

* Zuordnungen Stücklistenpositionen zu Planknoten
   LOOP AT itab_plmz INTO wa_plmz
   WHERE plnty = wa_plko-plnty
   AND   plnnr = wa_plko-plnnr.
     PERFORM upro-bapi_plmz.
   ENDLOOP.

* alle Tabellen sind aufgebaut, BAPI-Verarbeitung starten
   PERFORM upro-bapi_aufruf.

 ENDLOOP.

* Statistik und Fehlerprotokoll
 PERFORM upro-statistik_bapi.

ENDFORM.

*---------------------------------------------------------------------*
*                     F T P _ D A T E I _ O U T                       *
*---------------------------------------------------------------------*
* Datei ausgeben. Unabhängig, welche Datei ausgegeben oder wegge-     *
* schrieben werden soll, diese wird über Übergabeparameter genau      *
* spezifiziert                                                        *
*---------------------------------------------------------------------*
* =>] dstab_out: interne Tabelle, Basis für die Datei, jedoch bereits *
*     ausgabefertig aufbereitet                                       *
* =>] ds_out   : Struktur, Zeile der internen Tabelle                 *
* =>] p_ftp_key: welchen FTP-Schlüssel verwenden                      *
* =>] p_dateiname: Name der Datei, die gespeichert werden soll.       *
*---------------------------------------------------------------------*
FORM upro-ftp_datei_out
    TABLES dstab_out
    USING  ds_out
           p_ftp_key
           p_dateiname.

* gedrehte Logik für das Schreiben auf FTP. Schreiben auf Unix nicht
* über Oberflächensteuerung möglich
 IF pm_ftp = 'X'.
   MOVE ' ' TO fb_ftp.
 ELSE.
   MOVE 'X' TO fb_ftp.
 ENDIF.

 CALL FUNCTION 'Z_F_DATEI_OUT'
      EXPORTING
           ds_out          = ds_out
*           UEB_OUT         =
           p_ftp_transfer  = fb_ftp
           p_ftp_key       = p_ftp_key
           p_datawarehouse = ' '
           p_dateiname     = p_dateiname
           p_datei_ext     = pmdattyp
*           p_datei_ersetz  = ' '
           p_titel         = pm_titel
           p_meld          = pmmeld
           p_al11_del      = i_ad_del
      IMPORTING
           p_anzahl        = anzahl
           p_anzahl_fehler = anzahl_fehler
      TABLES
           dstab_out       = dstab_out.

ENDFORM.

*---------------------------------------------------------------------*
*                        B A P I _ P L K O                            *
*---------------------------------------------------------------------*
* Kopfdaten des Planes.                                               *
*---------------------------------------------------------------------*
FORM upro-bapi_plko.

* MOVE WA_PLKO-MANDT TO.
* MOVE WA_PLKO-PLNTY TO.
* Plannummer soll das System vorgeben
* MOVE wa_plko-plnnr TO itab_bapi_plko-task_list_group.
* soll automatisch die nächste freie Alternative des Plannes sein
* MOVE wa_plko-plnal TO itab_bapi_plko-group_counter.
* MOVE WA_PLKO-ZAEHL TO.
* MOVE WA_PLKO-TECHV TO.
 MOVE wa_plko-datuv TO itab_bapi_plko-valid_from.
 MOVE wa_plko-loekz TO itab_bapi_plko-del_ind.
 MOVE wa_plko-aennr TO itab_bapi_plko-change_no.
* MOVE WA_PLKO-PARKZ TO.
* MOVE WA_PLKO-ANDAT TO.
* MOVE WA_PLKO-ANNAM TO.
* MOVE WA_PLKO-AEDAT TO.
* MOVE WA_PLKO-AENAM TO.
 MOVE wa_plko-verwe TO itab_bapi_plko-task_list_usage.
 MOVE wa_plko-werks TO itab_bapi_plko-plant.
 MOVE wa_plko-statu TO itab_bapi_plko-task_list_status.
 MOVE wa_plko-plnme TO itab_bapi_plko-task_measure_unit.
 MOVE wa_plko-losvn TO itab_bapi_plko-lot_size_from.
 MOVE wa_plko-losbs TO itab_bapi_plko-lot_size_to.
 MOVE wa_plko-vagrp TO itab_bapi_plko-resp_planner_group.
* MOVE WA_PLKO-AESZN TO.
 MOVE wa_plko-ktext TO itab_bapi_plko-description.
* MOVE WA_PLKO-TXTSP TO.
* MOVE WA_PLKO-ABDAT TO.
* MOVE WA_PLKO-ABANZ TO.
* MOVE WA_PLKO-PROFIDNETZ TO.
* MOVE WA_PLKO-KOKRS      TO.
* MOVE WA_PLKO-QVEWERKS   TO.
* MOVE WA_PLKO-QVEMENGE   TO.
* MOVE WA_PLKO-QVEVERSION TO.
* MOVE WA_PLKO-QVEDATUM   TO.
* MOVE WA_PLKO-QVEGRUPPE  TO.
* MOVE WA_PLKO-QVECODE    TO.
 MOVE wa_plko-qdynregel  TO itab_bapi_plko-dyn_modif_rule.
 MOVE wa_plko-qdynhead   TO itab_bapi_plko-dyn_modif_level.
 MOVE wa_plko-qprziehver TO itab_bapi_plko-sample_drawing_procedure.
* MOVE WA_PLKO-QVERSNPRZV TO.
* MOVE WA_PLKO-QKZRASTER  TO.
* MOVE WA_PLKO-QDYNSTRING TO.
* MOVE WA_PLKO-STRAT TO.
* MOVE WA_PLKO-PPOOL TO.
* MOVE WA_PLKO-ISTRU TO.
* MOVE WA_PLKO-IWERK TO.
* MOVE WA_PLKO-ANLZU TO.
* MOVE WA_PLKO-ARBID TO.
 MOVE wa_plko-extnum TO itab_bapi_plko-ind_units_ext_numbering.
* MOVE WA_PLKO-DELKZ TO.
* MOVE WA_PLKO-ARBTY TO.
* MOVE WA_PLKO-STUPR TO.
* MOVE WA_PLKO-CLNDR TO.
* MOVE WA_PLKO-PRTYP TO.
* MOVE WA_PLKO-REODAT TO.
* MOVE WA_PLKO-NETID TO.
* MOVE WA_PLKO-FLG_CHK TO.
* MOVE WA_PLKO-PSPNR TO.
* MOVE WA_PLKO-TTRAS TO.
* MOVE WA_PLKO-KZKFG TO.
 MOVE wa_plko-plnnr_alt TO itab_bapi_plko-old_number_of_task_list.
 MOVE wa_plko-flg_capo  TO itab_bapi_plko-recalc_std_values.
* MOVE WA_PLKO-STLTY TO.
* MOVE WA_PLKO-STLNR TO.
* MOVE WA_PLKO-STLAL TO.
 MOVE wa_plko-slwbez   TO itab_bapi_plko-ident_key.
 MOVE wa_plko-ppkztlzu TO itab_bapi_plko-insppoint_partiallot_assgnmt.
 MOVE wa_plko-chrule   TO itab_bapi_plko-change_rule.
 MOVE wa_plko-ccoaa    TO itab_bapi_plko-object_change_type.
* MOVE WA_PLKO-ST_ARBID TO.
* MOVE WA_PLKO-MEINH TO.
* MOVE WA_PLKO-UMREZ TO.
* MOVE WA_PLKO-UMREN TO.
* MOVE WA_PLKO-BMSCH TO.

* MOVE WA_ ??? TOBAPI1012_TSK_C-CHANGE_NO_TO.
* MOVE WA_ ??? TOBAPI1012_TSK_C-VALID_TO_DATE.
* MOVE WA_ ??? TOBAPI1012_TSK_C-TASK_MEASURE_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_TSK_C-DYN_MODIF_BY_VENDOR.
* MOVE WA_ ??? TOBAPI1012_TSK_C-DYN_MODIF_BY_MANUFACT.
* MOVE WA_ ??? TOBAPI1012_TSK_C-DYN_MODIF_BY_CUSTOMR.
* MOVE WA_ ??? TOBAPI1012_TSK_C-PLANNING_WORK_CENTER.

 APPEND itab_bapi_plko.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM upro-bapi_mapl                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM upro-bapi_mapl.

 CLEAR: itab_bapi_mapl.

* MOVE WA_MAPL-MANDT TO.
 MOVE wa_mapl-matnr TO itab_bapi_mapl-material.
 MOVE wa_mapl-werks TO itab_bapi_mapl-plant.
* MOVE WA_MAPL-PLNTY TO.
* Plannummer soll das System generieren
* MOVE WA_MAPL-PLNNR TO ITAB_BAPI_MAPL-TASK_LIST_GROUP.
* automatische Vergabe
* MOVE wa_mapl-plnal TO itab_bapi_mapl-group_counter.
* MOVE WA_MAPL-ZKRIZ TO.
* MOVE WA_MAPL-ZAEHL TO.
* MOVE WA_MAPL-TECHV TO.

 MOVE wa_mapl-datuv TO itab_bapi_mapl-valid_from.
 MOVE wa_mapl-aennr TO itab_bapi_mapl-change_no.
 MOVE wa_mapl-loekz TO itab_bapi_mapl-del_ind.
* MOVE WA_ ??? TOBAPI1012_MTK_C-CHANGE_NO_TO.
* MOVE WA_ ??? TOBAPI1012_MTK_C-VALID_TO_DATE.

* MOVE WA_MAPL-PARKZ TO.
* MOVE WA_MAPL-ANDAT TO.
* MOVE WA_MAPL-ANNAM TO.
* MOVE WA_MAPL-AEDAT TO.
* MOVE WA_MAPL-AENAM TO.
* MOVE WA_MAPL-LIFNR TO.
* MOVE WA_MAPL-KUNR TO.
* MOVE WA_MAPL-SUCHFELD TO.
 MOVE wa_mapl-vbeln TO itab_bapi_mapl-doc_number.
 MOVE wa_mapl-posnr TO itab_bapi_mapl-itm_number.
 MOVE wa_mapl-pspnr TO itab_bapi_mapl-work_breakdown_struct_element.

 APPEND itab_bapi_mapl.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM upro-bapi_plfl                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM upro-bapi_plfl.

* MOVE WA_PLFL-MANDT TO.
* MOVE WA_PLFL-PLNTY TO.
* MOVE wa_plfl-plnnr TO itab_bapi_plfl-task_list_group.
* MOVE WA_PLFL-PLNAL TO ITAB_BAPI_PLFL-GROUP_COUNTER.
 MOVE wa_plfl-plnfl TO itab_bapi_plfl-sequence_no.
* MOVE WA_PLFL-ZAEHL TO.
* MOVE WA_PLFL-TECHV TO.

 MOVE wa_plfl-datuv TO itab_bapi_plfl-valid_from.
 MOVE wa_plfl-aennr TO itab_bapi_plfl-change_no.
 MOVE wa_plfl-loekz TO itab_bapi_plfl-del_ind.
* MOVE WA_ ??? TOBAPI1012_SEQ_C-CHANGE_NO_TO.
* MOVE WA_ ??? TOBAPI1012_SEQ_C-VALID_TO_DATE.

* MOVE WA_PLFL-PARKZ TO.
* MOVE WA_PLFL-ANDAT TO.
* MOVE WA_PLFL-ANNAM TO.
* MOVE WA_PLFL-AEDAT TO.
* MOVE WA_PLFL-AENAM TO.
 MOVE wa_plfl-flgat TO itab_bapi_plfl-sequence_category.
 MOVE wa_plfl-bezfl TO itab_bapi_plfl-reference_sequence.
* MOVE WA_PLFL-BKNT1 TO.
* MOVE WA_PLFL-BKNT2 TO.
 MOVE wa_plfl-ltxa1 TO itab_bapi_plfl-description.
* MOVE WA_PLFL-TXTSP TO.
 MOVE wa_plfl-losvn TO itab_bapi_plfl-lot_sz_min.
 MOVE wa_plfl-losbs TO itab_bapi_plfl-lot_sz_max.
* MOVE WA_PLFL-BSCHL1 TO.
* MOVE WA_PLFL-BSCHL2 TO.
 MOVE wa_plfl-auschl TO itab_bapi_plfl-alignment_key_for_scheduling.
* MOVE WA_PLFL-KNOBJ TO.

* MOVE WA_ ??? TOBAPI1012_SEQ_C-TASK_MEASURE_UNIT.
* MOVE WA_ ??? TOBAPI1012_SEQ_C-TASK_MEASURE_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_SEQ_C-BRANCH_OPERATION.
* MOVE WA_ ??? TOBAPI1012_SEQ_C-RETURN_OPERATION.
* MOVE WA_ ??? TOBAPI1012_SEQ_C-BRANCH_OPERATION_IDENT.
* MOVE WA_ ??? TOBAPI1012_SEQ_C-RETURN_OPERATION_IDENT.

 APPEND itab_bapi_plfl.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM upro-bapi_plpo                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM upro-bapi_plpo.

* Arbeitsplatz einlesen. Für den BAPI muß der richtige Arbeitsplatz
* genannt werden, die Umwandlung zu einer Objektnummer geschieht dann
* intern
 READ TABLE wktab_crhd INTO wk_crhd
 WITH TABLE KEY objid = wa_plpo-arbid.
 IF sy-subrc <> 0.
   CLEAR: wk_crhd.
 ENDIF.

* MOVE WA_PLPO-MANDT TO.
* MOVE WA_PLPO-PLNTY TO.
* MOVE wa_plpo-plnnr TO itab_bapi_plpo-task_list_group.
 MOVE wa_plpo-plnkn TO itab_bapi_plpo-operation_id.
* MOVE WA_PLPO-ZAEHL TO.
* MOVE WA_PLPO-TECHV TO.

* falls mit Löschvermerk gearbeitet wird. Dann muß eine Änderungsnummer
* vorliegen und das von und bis-Datum müssen gesetzt sein
*  IF pmx_edel = 'X'.
*    MOVE 'X' TO itab_bapi_plpo-del_ind.
*    MOVE wa_aenr-aennr TO itab_bapi_plpo-change_no_to.
*    MOVE wa_aenr-datuv TO itab_bapi_plpo-valid_from.
*    MOVE wa_aenr-datuv TO itab_bapi_plpo-valid_to_date.
*  ELSE.
 MOVE wa_plpo-datuv TO itab_bapi_plpo-valid_from.
 MOVE wa_plpo-aennr TO itab_bapi_plpo-change_no.
 MOVE wa_plpo-loekz TO itab_bapi_plpo-del_ind.
* MOVE WA_ ??? TOBAPI1012_OPR_C-CHANGE_NO_TO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-VALID_TO_DATE.
*  ENDIF.

* MOVE WA_PLPO-PARKZ TO.
* MOVE WA_PLPO-ANDAT TO.
* MOVE WA_PLPO-ANNAM TO.
* MOVE WA_PLPO-AEDAT TO.
* MOVE WA_PLPO-AENAM TO.
* MOVE WA_PLPO-SUMNR TO.
 MOVE wa_plpo-vornr TO itab_bapi_plpo-activity.
 MOVE wa_plpo-steus TO itab_bapi_plpo-control_key.
 MOVE wk_crhd-arbpl TO itab_bapi_plpo-work_cntr.
 MOVE wa_plpo-objty TO itab_bapi_plpo-object_type_cim_resource.
 MOVE wa_plpo-werks TO itab_bapi_plpo-plant.
 MOVE wa_plpo-ktsch TO itab_bapi_plpo-standard_text_key.
 MOVE wa_plpo-ltxa1 TO itab_bapi_plpo-description.
* MOVE WA_PLPO-LTXA2 TO.
* MOVE WA_PLPO-TXTSP TO.
* MOVE WA_PLPO-VPLTY TO.
* MOVE WA_PLPO-VPLNR TO.
* MOVE WA_PLPO-VPLAL TO.
* MOVE WA_PLPO-VPLFL TO.
* MOVE WA_PLPO-VINTV TO.
 MOVE wa_plpo-meinh TO itab_bapi_plpo-operation_measure_unit.
 MOVE wa_plpo-umren TO itab_bapi_plpo-denominator.
 MOVE wa_plpo-umrez TO itab_bapi_plpo-nominator.
 MOVE wa_plpo-bmsch TO itab_bapi_plpo-base_quantity.
 MOVE wa_plpo-zmerh TO itab_bapi_plpo-break_time.
 MOVE wa_plpo-zeier TO itab_bapi_plpo-break_unit.
 MOVE wa_plpo-lar01 TO itab_bapi_plpo-acttype_01.
 MOVE wa_plpo-vge01 TO itab_bapi_plpo-std_unit_01.
 MOVE wa_plpo-vgw01 TO itab_bapi_plpo-std_value_01.
 MOVE wa_plpo-lar02 TO itab_bapi_plpo-acttype_02.
 MOVE wa_plpo-vge02 TO itab_bapi_plpo-std_unit_02.
 MOVE wa_plpo-vgw02 TO itab_bapi_plpo-std_value_02.
 MOVE wa_plpo-lar03 TO itab_bapi_plpo-acttype_03.
 MOVE wa_plpo-vge03 TO itab_bapi_plpo-std_unit_03.
 MOVE wa_plpo-vgw03 TO itab_bapi_plpo-std_value_03.
 MOVE wa_plpo-lar04 TO itab_bapi_plpo-acttype_04.
 MOVE wa_plpo-vge04 TO itab_bapi_plpo-std_unit_04.
 MOVE wa_plpo-vgw04 TO itab_bapi_plpo-std_value_04.
 MOVE wa_plpo-lar05 TO itab_bapi_plpo-acttype_05.
 MOVE wa_plpo-vge05 TO itab_bapi_plpo-std_unit_05.
 MOVE wa_plpo-vgw05 TO itab_bapi_plpo-std_value_05.
 MOVE wa_plpo-lar06 TO itab_bapi_plpo-acttype_06.
 MOVE wa_plpo-vge06 TO itab_bapi_plpo-std_unit_06.
 MOVE wa_plpo-vgw06 TO itab_bapi_plpo-std_value_06.
 MOVE wa_plpo-zerma TO itab_bapi_plpo-std_value_calculation_type.
 MOVE wa_plpo-zgdat TO itab_bapi_plpo-std_value_year_of_calculation.
 MOVE wa_plpo-zcode TO itab_bapi_plpo-std_value_code_reference_no.
 MOVE wa_plpo-zulnr TO itab_bapi_plpo-std_value_calculation_basis.
 MOVE wa_plpo-rsanz TO itab_bapi_plpo-no_of_confirmation_slips.
* MOVE WA_PLPO-PDEST TO.
 MOVE wa_plpo-loanz TO itab_bapi_plpo-no_of_time_tickets.
 MOVE wa_plpo-loart TO itab_bapi_plpo-wagetype.
 MOVE wa_plpo-qualf TO itab_bapi_plpo-suitability.
 MOVE wa_plpo-anzma TO itab_bapi_plpo-no_of_employee.
* MOVE WA_PLPO-RFGRP TO.
 MOVE wa_plpo-rfsch TO itab_bapi_plpo-setup_group_category.
 MOVE wa_plpo-rasch TO itab_bapi_plpo-setup_type_key.
 MOVE wa_plpo-aufak TO itab_bapi_plpo-scrap_factor.
 MOVE wa_plpo-logrp TO itab_bapi_plpo-wagegroup.
 MOVE wa_plpo-uemus TO itab_bapi_plpo-required_overlapping.
 MOVE wa_plpo-uekan TO itab_bapi_plpo-optional_overlapping.
 MOVE wa_plpo-flies TO itab_bapi_plpo-ind_cont_flow_production.
 MOVE wa_plpo-zeimu TO itab_bapi_plpo-min_overlap_time_unit.
 MOVE wa_plpo-zminu TO itab_bapi_plpo-min_overlap_time.
 MOVE wa_plpo-minwe TO itab_bapi_plpo-min_send_ahead_qty.
 MOVE wa_plpo-spmus TO itab_bapi_plpo-ind_splitting_reqrd.
 MOVE wa_plpo-splim TO itab_bapi_plpo-max_no_of_splits.
 MOVE wa_plpo-zeimb TO itab_bapi_plpo-min_processing_time_unit.
 MOVE wa_plpo-zminb TO itab_bapi_plpo-min_processing_time.
 MOVE wa_plpo-zeilm TO itab_bapi_plpo-max_wait_time_unit.
 MOVE wa_plpo-zlmax TO itab_bapi_plpo-max_wait_time.
 MOVE wa_plpo-zeilp TO itab_bapi_plpo-required_wait_time_unit.
 MOVE wa_plpo-zlpro TO itab_bapi_plpo-required_wait_time.
 MOVE wa_plpo-zeiwn TO itab_bapi_plpo-standard_queue_time_unit.
 MOVE wa_plpo-zwnor TO itab_bapi_plpo-standard_queue_time.
 MOVE wa_plpo-zeiwm TO itab_bapi_plpo-min_queue_time_unit.
 MOVE wa_plpo-zwmin TO itab_bapi_plpo-min_queue_time.
 MOVE wa_plpo-zeitn TO itab_bapi_plpo-standard_move_time_unit.
 MOVE wa_plpo-ztnor TO itab_bapi_plpo-standard_move_time.
 MOVE wa_plpo-zeitm TO itab_bapi_plpo-min_move_time_unit.
 MOVE wa_plpo-ztmin TO itab_bapi_plpo-min_move_time.
 MOVE wa_plpo-ablipkz TO itab_bapi_plpo-teardown_and_wait_ind.
 MOVE wa_plpo-rstra TO itab_bapi_plpo-reduction_strategy.
* MOVE WA_PLPO-BZOFFB TO.
* MOVE WA_PLPO-OFFSTB TO.
* MOVE WA_PLPO-EHOFFB TO.
* MOVE WA_PLPO-BZOFFE TO.
* MOVE WA_PLPO-OFFSTE TO.
* MOVE WA_PLPO-EHOFFE TO.
 MOVE wa_plpo-sortl TO itab_bapi_plpo-sorted_by.
 MOVE wa_plpo-lifnr TO itab_bapi_plpo-vendor_no.
 MOVE wa_plpo-plifz TO itab_bapi_plpo-plnd_delry.
* MOVE WA_PLPO-PREIS TO.
* MOVE WA_PLPO-PEINH TO.
 MOVE wa_plpo-sakto TO itab_bapi_plpo-cost_elem.
 MOVE wa_plpo-waers TO itab_bapi_plpo-currency.
 MOVE wa_plpo-infnr TO itab_bapi_plpo-info_rec.
* MOVE WA_PLPO-ESOKZ TO.
 MOVE wa_plpo-ekorg TO itab_bapi_plpo-purch_org.
 MOVE wa_plpo-ekgrp TO itab_bapi_plpo-purch_group.
 MOVE wa_plpo-kzlgf TO itab_bapi_plpo-fixed_lot_ext_process_ind.
 MOVE wa_plpo-matkl TO itab_bapi_plpo-matl_group.
* MOVE WA_PLPO-DAUNO TO.
* MOVE WA_PLPO-DAUNE TO.
* MOVE WA_PLPO-DAUMI TO.
* MOVE WA_PLPO-DAUME TO.
* MOVE WA_PLPO-DDEHN TO.
* MOVE WA_PLPO-EINSA TO.
* MOVE WA_PLPO-EINSE TO.
* MOVE WA_PLPO-ARBEI TO.
* MOVE WA_PLPO-ARBEH TO.
* MOVE WA_PLPO-ANZZL TO.
* MOVE WA_PLPO-PRZNT TO.
* MOVE WA_PLPO-VERTL TO.
* MOVE WA_PLPO-MLSTN TO.
* MOVE WA_PLPO-PPRIO TO.
* MOVE WA_PLPO-BUKRS TO.
 MOVE wa_plpo-slwid TO itab_bapi_plpo-userfields_keyword_id.
 MOVE wa_plpo-usr00 TO itab_bapi_plpo-userfield_ch20_00.
 MOVE wa_plpo-usr01 TO itab_bapi_plpo-userfield_ch20_01.
 MOVE wa_plpo-usr02 TO itab_bapi_plpo-userfield_ch10_02.
 MOVE wa_plpo-usr03 TO itab_bapi_plpo-userfield_ch10_03.
 MOVE wa_plpo-usr04 TO itab_bapi_plpo-userfield_quan_04.
 MOVE wa_plpo-use04 TO itab_bapi_plpo-userfield_unit_04.
 MOVE wa_plpo-usr05 TO itab_bapi_plpo-userfield_quan_05.
 MOVE wa_plpo-use05 TO itab_bapi_plpo-userfield_unit_05.
 MOVE wa_plpo-usr06 TO itab_bapi_plpo-userfield_curr_06.
 MOVE wa_plpo-use06 TO itab_bapi_plpo-userfield_currency_06.
 MOVE wa_plpo-usr07 TO itab_bapi_plpo-userfield_curr_07.
 MOVE wa_plpo-use07 TO itab_bapi_plpo-userfield_currency_07.
 MOVE wa_plpo-usr08 TO itab_bapi_plpo-userfield_date_08.
 MOVE wa_plpo-usr09 TO itab_bapi_plpo-userfield_date_09.
 MOVE wa_plpo-usr10 TO itab_bapi_plpo-userfield_flag_10.
 MOVE wa_plpo-usr11 TO itab_bapi_plpo-userfield_flag_11.
* MOVE WA_PLPO-ANFKO TO.
* MOVE WA_PLPO-ANFKOKRS TO.
* MOVE WA_PLPO-KAPAR TO.
* MOVE WA_PLPO-INDET TO.
* MOVE wa_plpo-larnt TO itab_bapi_plpo-acttype_01.
* MOVE WA_PLPO-PRKST TO.
* MOVE WA_PLPO-QRASTERMNG TO.
 MOVE wa_plpo-qrastereh TO itab_bapi_plpo-quant_unit.
* MOVE WA_PLPO-ANLZU TO.
* MOVE WA_PLPO-ISTRU TO.
* MOVE WA_PLPO-ISTTY TO.
* MOVE WA_PLPO-ISTNR TO.
* MOVE WA_PLPO-ISTKN TO.
* MOVE WA_PLPO-ISTPO TO.
* MOVE WA_PLPO-IUPOZ TO.
* MOVE WA_PLPO-EBORT TO.
* MOVE WA_PLPO-KALID TO.
* MOVE WA_PLPO-FRSP TO.
* MOVE WA_PLPO-VERTN TO.
* MOVE WA_PLPO-ZGR01 TO.
* MOVE WA_PLPO-ZGR02 TO.
* MOVE WA_PLPO-ZGR03 TO.
* MOVE WA_PLPO-ZGR04 TO.
* MOVE WA_PLPO-ZGR05 TO.
* MOVE WA_PLPO-ZGR06 TO.
* MOVE WA_PLPO-MDLID TO.
* MOVE WA_PLPO-RUZUS TO.
* MOVE WA_PLPO-BMEIH TO.
* MOVE WA_PLPO-BMVRG TO.
 MOVE wa_plpo-ckselkz TO itab_bapi_plpo-cost_relevant.
* MOVE WA_PLPO-KALKZ TO.
* MOVE WA_PLPO-NPRIO TO.
* MOVE WA_PLPO-PVZKN TO.
* MOVE WA_PLPO-PHFLG TO.
* MOVE WA_PLPO-PHSEQ TO.
* MOVE WA_PLPO-KNOBJ TO.
 MOVE wa_plpo-erfsicht TO itab_bapi_plpo-recording_view.
* MOVE WA_PLPO-PSPNR TO.
* MOVE WA_PLPO-QLOTYPE TO.
* MOVE wa_plpo-qlobjektid TO itab_bapi_plpo-obj_id.
* MOVE WA_PLPO-QLKAPAR TO.
 MOVE wa_plpo-qkzprzeit TO itab_bapi_plpo-time_grid.
 MOVE wa_plpo-qkzztmg1 TO itab_bapi_plpo-quantonce.
 MOVE wa_plpo-qkzprmeng TO itab_bapi_plpo-quant_grid.
 MOVE wa_plpo-qkzprfrei TO itab_bapi_plpo-free_grid.
 MOVE wa_plpo-qrastzeht TO itab_bapi_plpo-time_unit.
 MOVE wa_plpo-qrastzfak TO itab_bapi_plpo-time_factor.
 MOVE wa_plpo-qrastmeng TO itab_bapi_plpo-qty_btw_two_inspections.
 MOVE wa_plpo-qppktabs  TO
      itab_bapi_plpo-insp_point_complt_flow_variant.
* MOVE WA_PLPO-KRIT1 TO.
* MOVE WA_PLPO-CLASSID TO.
* MOVE WA_PLPO-PACKNO TO.
 MOVE wa_plpo-ebeln TO itab_bapi_plpo-po_number.
 MOVE wa_plpo-ebelp TO itab_bapi_plpo-po_item.
* MOVE WA_PLPO-CAPOC TO.
* MOVE WA_PLPO-FLG_CAPTXT TO.
* MOVE WA_PLPO-CN_WEIGHT TO.
 MOVE wa_plpo-qkztlsbest
      TO itab_bapi_plpo-stock_related_partial_lot_assg.
* MOVE WA_PLPO-AUFKT TO.
* MOVE WA_PLPO-DAFKT TO.
* MOVE WA_PLPO-RWFAK TO.
* MOVE WA_PLPO-AAUFG TO.
 MOVE wa_plpo-verdart TO itab_bapi_plpo-cumulation_type.
 MOVE wa_plpo-uavo_aufl TO itab_bapi_plpo-sub_act_not_in_order_ind.
 MOVE wa_plpo-frdlb TO itab_bapi_plpo-ext_proc_with_subcontract_ind.
 MOVE wa_plpo-qpart TO itab_bapi_plpo-insptype.
 MOVE wa_plpo-prz01 TO itab_bapi_plpo-co_busproc.
* MOVE WA_PLPO-TAKT TO.
* MOVE WA_PLPO-OPRID TO.
* MOVE WA_PLPO-NVADD TO.
* MOVE WA_PLPO-EVGEW TO.
* MOVE WA_PLPO-RFPNT TO.
 MOVE wa_plpo-flg_tsk_group TO itab_bapi_plpo-group_operation.

* MOVE wa_plpo-arbid TO itab_bapi_plpo-obj_id.
* MOVE WA_ ??? TOBAPI1012_OPR_C-GROUP_COUNTER.
* MOVE WA_ ??? TOBAPI1012_OPR_C-SEQUENCE_NO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-OPERATION_MEASURE_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-BREAK_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-STD_UNIT_01_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-STD_UNIT_02_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-STD_UNIT_03_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-STD_UNIT_04_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-STD_UNIT_05_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-STD_UNIT_06_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-SETUP_GROUP_KEY.
* MOVE WA_ ??? TOBAPI1012_OPR_C-MIN_OVERLAP_TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-MIN_PROCESSING_TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-MAX_WAIT_TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-REQUIRED_WAIT_TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-STANDARD_QUEUE_TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-MIN_QUEUE_TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-STANDARD_MOVE_TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-MIN_MOVE_TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-INFO_REC_NET_PRICE.
* MOVE WA_ ??? TOBAPI1012_OPR_C-PRICE_UNIT.
* MOVE WA_ ??? TOBAPI1012_OPR_C-CURRENCY_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-USERFIELD_UNIT_04_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-USERFIELD_UNIT_05_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-USERFIELD_CURRENCY_06_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-USERFIELD_CURRENCY_07_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-TIME_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_OPR_C-QUANT_UNIT_ISO.

 APPEND itab_bapi_plpo.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM upro-bapi_plfh                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM upro-bapi_plfh.

 CLEAR: itab_bapi_plfh, wa_out.

 MOVE wa_mapl-plnnr TO wa_out-plnnr_neu.
 MOVE wa_mapl-plnal TO wa_out-plnnr_alt.

* MOVE WA_PLFH-MANDT TO.
* MOVE WA_PLFH-PLNTY TO.
* MOVE WA_PLFH-PLNNR TO ITAB_BAPI_PLFH-TASK_LIST_GROUP.
 MOVE wa_plfh-pzlfh TO itab_bapi_plfh-prt_item_count.
* MOVE WA_PLFH-ZAEHL TO.
* MOVE WA_PLFH-TECHV TO.
* MOVE WA_PLFH-PARKZ TO.

 MOVE wa_plfh-datuv TO itab_bapi_plfh-valid_from.
 MOVE wa_plfh-loekz TO itab_bapi_plfh-del_ind.
 MOVE wa_plfh-aennr TO itab_bapi_plfh-change_no.
* MOVE WA_ ??? TOBAPI1012_PRT_C-CHANGE_NO_TO.
* MOVE WA_ ??? TOBAPI1012_PRT_C-VALID_TO_DATE.

* MOVE WA_PLFH-DATUI TO.
* MOVE WA_PLFH-USERI TO.
* MOVE WA_PLFH-DATUC TO.
* MOVE WA_PLFH-USERC TO.
 MOVE wa_plfh-objty  TO itab_bapi_plfh-object_type_cim_resource.
 MOVE wa_plfh-objid  TO itab_bapi_plfh-object_id_cim_resource.
 MOVE wa_plfh-objct  TO itab_bapi_plfh-object_of_task_list.
* MOVE wa_plfh-plnal  TO itab_bapi_plfh-group_counter.
 MOVE wa_plfh-plnfl  TO itab_bapi_plfh-sequence_no.
 MOVE wa_plfh-plnkn  TO itab_bapi_plfh-operation_id.
 MOVE wa_plfh-psnfh  TO itab_bapi_plfh-item_no_of_production_resource.
 MOVE wa_plfh-steuf  TO itab_bapi_plfh-ctrl_key.
 MOVE wa_plfh-kzkbl  TO itab_bapi_plfh-create_load_recs.
 MOVE wa_plfh-bzoffb TO itab_bapi_plfh-start_ref_date.
 MOVE wa_plfh-offstb TO itab_bapi_plfh-start_offset.
 MOVE wa_plfh-ehoffb TO itab_bapi_plfh-start_offset_unit.
 MOVE wa_plfh-bzoffe TO itab_bapi_plfh-end_ref_date.
 MOVE wa_plfh-offste TO itab_bapi_plfh-end_offset.
 MOVE wa_plfh-ehoffe TO itab_bapi_plfh-end_offset_unit.
 MOVE wa_plfh-mgeinh TO itab_bapi_plfh-prt_measure_unit.
 MOVE wa_plfh-mgvgw  TO itab_bapi_plfh-std_value_for_prt_qty.
 MOVE wa_plfh-mgform TO itab_bapi_plfh-formula_tot_qty.
 MOVE wa_plfh-eweinh TO itab_bapi_plfh-prt_usage_value_unit.
 MOVE wa_plfh-ewvgw  TO itab_bapi_plfh-std_usage_value_for_prt.
 MOVE wa_plfh-ewform TO itab_bapi_plfh-formula_tot_usage.
* MOVE WA_PLFH-TXTSP TO.
 MOVE wa_plfh-ktsch  TO itab_bapi_plfh-std_text_key.
 MOVE wa_plfh-txtz1  TO itab_bapi_plfh-description.
* MOVE WA_PLFH-KNOBJ TO.
* MOVE WA_PLFH-GP_KRIT1 TO.

* Basisdaten zu den Fertigungshilfsmittel aus den Stammtabellen dazu-
* mischen. Die Werte zu den Hilfsmitteln wurden bereits im Vorlauf beim
* Einlesen der Tabellen komplett bereitgestellt, somit entfällt hier
* der Doppelzugriff
 IF wa_plfh-objty = 'FH'.
   READ TABLE wktab_crfh INTO wk_crfh
   WITH TABLE KEY objty = wa_plfh-objty
                  objid = wa_plfh-objid.
   IF sy-subrc <> 0.
     MOVE 'X'    TO wa_test.
     MOVE 'CRFH' TO wa_out-id.
     ADD  1      TO anzahl_f_bapi.

     CONCATENATE 'Keine Zuordnung FHM zum Objekt'
                 wa_plfh-objid
                 INTO wa_out-message SEPARATED BY ' '.
     MOVE wa_out TO ds_out-satz.
     APPEND ds_out TO dstab_out.
   ELSE.
* die Dokumentennummer ist in allen Fällen gefüllt, auch wenn die
* Bedeutung unterschiedlich ist
     IF wk_crfh-doknr IS INITIAL.
       MOVE 'X'    TO wa_test.
       MOVE 'CRFH' TO wa_out-id.
       ADD  1      TO anzahl_f_bapi.

       CONCATENATE 'Zum FHM-Typ' wk_crfh-fhmar
                   'Objekt' wa_plfh-objid
                   'sind keine Daten vorhanden'
                   INTO wa_out-message SEPARATED BY ' '.
       MOVE wa_out TO ds_out-satz.
       APPEND ds_out TO dstab_out.
     ELSE.
       MOVE wk_crfh-fhmar TO itab_bapi_plfh-prt_category.

       CASE wk_crfh-fhmar.
         WHEN 'D'.
           MOVE wk_crfh-dokar TO itab_bapi_plfh-document_type.
           MOVE wk_crfh-doknr TO itab_bapi_plfh-document_number.
           MOVE wk_crfh-doktl TO itab_bapi_plfh-document_part.
           MOVE wk_crfh-dokvr TO itab_bapi_plfh-document_version.
         WHEN 'E'.
           MOVE wk_crfh-doknr TO itab_bapi_plfh-equipment.
         WHEN 'M'.
           MOVE wk_crfh-werks TO itab_bapi_plfh-prt_plant.
           MOVE wk_crfh-doknr TO itab_bapi_plfh-material.
         WHEN 'S'.
           MOVE wk_crfh-doknr TO itab_bapi_plfh-miscellaneous.
         WHEN OTHERS.
           MOVE 'X'    TO wa_test.
           MOVE 'CRFH' TO wa_out-id.
           ADD  1      TO anzahl_f_bapi.

           CONCATENATE 'Ungültiger FHM-Typ' wk_crfh-fhmar
                       'zum Object'         wa_plfh-objid
                       INTO wa_out-message SEPARATED BY ' '.
           MOVE wa_out TO ds_out-satz.
           APPEND ds_out TO dstab_out.
       ENDCASE.
     ENDIF.
   ENDIF.
 ENDIF.

* Bapi-Struktur arbeitet nicht mit der Knoten-Struktur, sondern mit der
* AVO-Nummer. Diese lesen und hier einspielen. Nur wenn eine gefunden
* worden ist, ist die Fertigungshilfsmittelposition gültig
 READ TABLE itab_plpo INTO wa_plpo
 WITH KEY plnty = wa_plfh-plnty
          plnnr = wa_plfh-plnnr
          plnkn = wa_plfh-plnkn.
 IF sy-subrc = 0.
   MOVE wa_plpo-vornr TO itab_bapi_plfh-activity.

   APPEND itab_bapi_plfh.
 ENDIF.

* MOVE WA_ ??? TOBAPI1012_PRT_C-PRT_NUMBER.
* MOVE WA_ ??? TOBAPI1012_PRT_C-START_OFFSET_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_PRT_C-END_OFFSET_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_PRT_C-PRT_MEASURE_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_PRT_C-PRT_USAGE_VALUE_UNIT_ISO.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM upro-bapi_plmk                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM upro-bapi_plmk.

* MOVE WA_PLMK-MANDT       TO.
* MOVE WA_PLMK-PLNTY       TO.
* MOVE WA_PLMK-PLNNR       TO ITAB_BAPI_PLMK-TASK_LIST_GROUP.
 MOVE wa_plmk-plnkn       TO itab_bapi_plmk-operation_id.
* MOVE WA_PLMK-KZEINSTELL  TO.
 MOVE wa_plmk-merknr      TO itab_bapi_plmk-inspchar.
* MOVE WA_PLMK-ZAEHL       TO.
 MOVE wa_plmk-gueltigab   TO itab_bapi_plmk-valid_from.
* MOVE WA_PLMK-SERNV       TO.
 MOVE wa_plmk-loekz       TO itab_bapi_plmk-del_ind.
* MOVE WA_PLMK-PARKZ       TO.
 MOVE wa_plmk-aendergnr   TO itab_bapi_plmk-change_no.
* MOVE WA_PLMK-ERSTELLER   TO.
* MOVE WA_PLMK-ERSTELLDAT  TO.
* MOVE WA_PLMK-AENDERER    TO.
* MOVE WA_PLMK-AENDERDAT   TO.
* MOVE WA_PLMK-STEUERKZ    TO.
 MOVE wa_plmk-qmtb_werks  TO itab_bapi_plmk-pmethod.
 MOVE wa_plmk-pmethode    TO itab_bapi_plmk-method.
* MOVE WA_PLMK-PMTVERSION  TO.
* MOVE WA_PLMK-QPMK_REF    TO.
* MOVE WA_PLMK-QPMK_ZAEHL  TO.
 MOVE wa_plmk-verwmerkm   TO itab_bapi_plmk-mstr_char.
* MOVE WA_PLMK-MKVERSION   TO.
* MOVE WA_PLMK-MKVERSDAT   TO.
 MOVE wa_plmk-merkgew     TO itab_bapi_plmk-ch_wgt_cod.
 MOVE wa_plmk-probenr     TO itab_bapi_plmk-phys_smpl.
 MOVE wa_plmk-pruefquali  TO itab_bapi_plmk-inspector_qualif.
 MOVE wa_plmk-toleranzsl  TO itab_bapi_plmk-tolerance_key.
 MOVE wa_plmk-kurztext    TO itab_bapi_plmk-char_descr.
* MOVE WA_PLMK-LTEXTKZ     TO.
* MOVE WA_PLMK-LTEXTSPR    TO.
* MOVE WA_PLMK-LTEXTEKZ    TO.
* MOVE WA_PLMK-LTXTENTSPR  TO.
 MOVE wa_plmk-stellen     TO itab_bapi_plmk-dec_places.
* MOVE WA_PLMK-MASSEINHSW  TO.
* MOVE WA_PLMK-SOLLWERT    TO.
* MOVE WA_PLMK-SOLLWNI     TO.
* MOVE WA_PLMK-TOLERANZOB  TO.
* MOVE WA_PLMK-TOLOBNI     TO.
* MOVE WA_PLMK-TOLERANZUN  TO.
* MOVE WA_PLMK-TOLUNNI     TO.
 MOVE wa_plmk-klasanzahl  TO itab_bapi_plmk-no_of_value_classes.
* MOVE WA_PLMK-KLASBREITE  TO.
* MOVE WA_PLMK-KLASBRNI    TO.
* MOVE WA_PLMK-KLASMITTE   TO.
* MOVE WA_PLMK-KLASMINI    TO.
* MOVE WA_PLMK-GRENZEOB1   TO.
* MOVE WA_PLMK-GRENZOB1NI  TO.
* MOVE WA_PLMK-GRENZEUN1   TO.
* MOVE WA_PLMK-GRENZUN1NI  TO.
* MOVE WA_PLMK-GRENZEOB2   TO.
* MOVE WA_PLMK-GRENZOB2NI  TO.
* MOVE WA_PLMK-GRENZEUN2   TO.
* MOVE WA_PLMK-GRENZUN2NI  TO.
* MOVE WA_PLMK-PLAUSIOBEN  TO.
* MOVE WA_PLMK-PLAUSIOBNI  TO.
* MOVE WA_PLMK-PLAUSIUNTE  TO.
* MOVE WA_PLMK-PLAUSIUNNI  TO.
* MOVE WA_PLMK-TOLERWEIOB  TO.
* MOVE WA_PLMK-TOLWOBNI    TO.
* MOVE WA_PLMK-TOLERWEIUN  TO.
* MOVE WA_PLMK-TOLWUNNI    TO.
* MOVE WA_PLMK-TOLERWAB    TO.
* MOVE WA_PLMK-TOLERWBIS   TO.
 MOVE wa_plmk-stichprver  TO itab_bapi_plmk-smpl_procedure.
* MOVE WA_PLMK-FAKPLANME   TO.
* MOVE WA_PLMK-FAKPROBME   TO.
 MOVE wa_plmk-probemgeh   TO itab_bapi_plmk-smpl_unit.
 MOVE wa_plmk-pruefeinh   TO itab_bapi_plmk-smpl_quant.
* MOVE WA_PLMK-DYNKRIT     TO.
 MOVE wa_plmk-formelsl    TO itab_bapi_plmk-formula_check_by_sap.
 MOVE wa_plmk-formel1     TO itab_bapi_plmk-formula_field_1.
 MOVE wa_plmk-formel2     TO itab_bapi_plmk-formula_field_2.
 MOVE wa_plmk-codegr9u    TO itab_bapi_plmk-lw_def_code_grp.
 MOVE wa_plmk-code9u      TO itab_bapi_plmk-lw_def_code.
* MOVE WA_PLMK-CODEVR9U    TO.
 MOVE wa_plmk-codegr9o    TO itab_bapi_plmk-up_def_code_grp.
 MOVE wa_plmk-code9o      TO itab_bapi_plmk-up_def_code.
* MOVE WA_PLMK-CODEVR9O    TO.
* MOVE WA_PLMK-KATAB1      TO.
* MOVE wa_plmk-katalgart1  TO itab_bapi_plmk-cat_type1.
 MOVE wa_plmk-auswmenge1  TO itab_bapi_plmk-sel_set1.
 MOVE wa_plmk-auswmgwrk1  TO itab_bapi_plmk-psel_set1.
* MOVE WA_PLMK-AUSWVERS1   TO.
* MOVE WA_PLMK-AUSWDAT1    TO.
* MOVE WA_PLMK-KATAB2      TO.
 MOVE wa_plmk-katalgart2  TO itab_bapi_plmk-cat_type2.
* MOVE wa_plmk-auswmenge2  TO itab_bapi_plmk-sel_set2.
* MOVE wa_plmk-auswmgwrk2  TO itab_bapi_plmk-psel_set2.
* MOVE WA_PLMK-AUSWVERS2   TO.
* MOVE WA_PLMK-AUSWDAT2    TO.
* MOVE WA_PLMK-KATAB3      TO.
 MOVE wa_plmk-katalgart3  TO itab_bapi_plmk-cat_type3.
* MOVE wa_plmk-auswmenge3  TO itab_bapi_plmk-sel_set3.
* MOVE wa_plmk-auswmgwrk3  TO itab_bapi_plmk-psel_set3.
* MOVE WA_PLMK-AUSWVERS3   TO.
* MOVE WA_PLMK-AUSWDAT3    TO.
* MOVE WA_PLMK-KATAB4      TO.
 MOVE wa_plmk-katalgart4  TO itab_bapi_plmk-cat_type4.
* MOVE wa_plmk-auswmenge4  TO itab_bapi_plmk-sel_set4.
* MOVE wa_plmk-auswmgwrk4  TO itab_bapi_plmk-psel_set4.
* MOVE WA_PLMK-AUSWVERS4   TO.
* MOVE WA_PLMK-AUSWDAT4    TO.
* MOVE WA_PLMK-KATAB5      TO.
 MOVE wa_plmk-katalgart5  TO itab_bapi_plmk-cat_type5.
* MOVE wa_plmk-auswmenge5  TO itab_bapi_plmk-sel_set5.
* MOVE wa_plmk-auswmgwrk5  TO itab_bapi_plmk-psel_set5.
* MOVE WA_PLMK-AUSWVERS5   TO.
* MOVE WA_PLMK-AUSWDAT5    TO.
 MOVE wa_plmk-dummy10     TO itab_bapi_plmk-infofield1.
 MOVE wa_plmk-dummy20     TO itab_bapi_plmk-infofield2.
 MOVE wa_plmk-dummy40     TO itab_bapi_plmk-infofield3.
 MOVE wa_plmk-charact_id1 TO itab_bapi_plmk-characteristic_name.
 MOVE wa_plmk-qergdath    TO itab_bapi_plmk-res_org.
 MOVE wa_plmk-eeantverf   TO itab_bapi_plmk-share_calc.
 MOVE wa_plmk-qdynregel   TO itab_bapi_plmk-dyn_modif_rule.
 MOVE wa_plmk-dynmerkref  TO itab_bapi_plmk-dyn_modif_ref_cha.
* MOVE WA_PLMK-PZLFH       TO.
 MOVE wa_plmk-codegrqual  TO itab_bapi_plmk-def_code_grp_general.
 MOVE wa_plmk-codequal    TO itab_bapi_plmk-def_code_general.
 MOVE wa_plmk-spckrit     TO itab_bapi_plmk-spc_criterion_key.

 READ TABLE itab_plpo INTO wa_plpo
 WITH KEY plnty = wa_plfh-plnty
          plnnr = wa_plfh-plnnr
          plnkn = wa_plfh-plnkn.
 IF sy-subrc = 0.
   MOVE wa_plpo-vornr TO itab_bapi_plmk-activity.

   APPEND itab_bapi_plmk.
 ENDIF.

* MOVE WA_ ??? TOBAPI1012_CHA_C-GROUP_COUNTER.
* MOVE WA_ ??? TOBAPI1012_CHA_C-SEQUENCE_NO.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CHANGE_NO_TO.
* MOVE WA_ ??? TOBAPI1012_CHA_C-VALID_TO_DATE.
* MOVE WA_ ??? TOBAPI1012_CHA_C-QUANTITATIVE_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-PRESET_CTRL_INDS_KEY.
* MOVE WA_ ??? TOBAPI1012_CHA_C-PMSTR_CHAR.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CHA_MASTER_IMPORT_MODUS.
* MOVE WA_ ??? TOBAPI1012_CHA_C-MEAS_VALUE_CONFIRM_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-ATTRIBUTE_REQUIRED_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-UP_TOL_LMT_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-LW_TOL_LMT_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-TARGET_VAL_CHECK_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-SCOPE_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-LONG_TERM_INSP_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-RESULT_RECORDING_TYPE.
* MOVE WA_ ??? TOBAPI1012_CHA_C-DOCU_REQU.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CONFIRMATION_CATEGORY.
* MOVE WA_ ??? TOBAPI1012_CHA_C-ADD_SAMPLE_QUANTITY.
* MOVE WA_ ??? TOBAPI1012_CHA_C-DESTRUCTIVE_INSP_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-FORMULA_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-SAMPLING_PROCEDURE_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-QSCORE_AND_SHARE_RELEVANT.
* MOVE WA_ ??? TOBAPI1012_CHA_C-DEFECT_NO_CONFIRMATION.
* MOVE WA_ ??? TOBAPI1012_CHA_C-INSP_TOOL_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-AUTO_DEFCT_RECORDING.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CHANGE_DOCUMENTS_REQ.
* MOVE WA_ ??? TOBAPI1012_CHA_C-SPC_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-PRINT_IND.
* MOVE WA_ ??? TOBAPI1012_CHA_C-ITEM_NO_OF_PRODUCTION_RESOURCE.
* MOVE WA_ ??? TOBAPI1012_CHA_C-MEAS_UNIT.
* MOVE WA_ ??? TOBAPI1012_CHA_C-MEAS_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_CHA_C-TARGET_VAL.
* MOVE WA_ ??? TOBAPI1012_CHA_C-UP_TOL_LMT.
* MOVE WA_ ??? TOBAPI1012_CHA_C-LW_TOL_LMT.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CLASS_WIDTH.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CLASS_MIDPOINT.
* MOVE WA_ ??? TOBAPI1012_CHA_C-UP_LMT_1.
* MOVE WA_ ??? TOBAPI1012_CHA_C-LW_LMT_1.
* MOVE WA_ ??? TOBAPI1012_CHA_C-UP_LMT_2.
* MOVE WA_ ??? TOBAPI1012_CHA_C-LW_LMT_2.
* MOVE WA_ ??? TOBAPI1012_CHA_C-UP_PLS_LMT.
* MOVE WA_ ??? TOBAPI1012_CHA_C-LW_PLS_LMT.
* MOVE WA_ ??? TOBAPI1012_CHA_C-FORMULA_FIELD_2.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CODE_GROUP2.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CAT_TYPE3.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CODE_GROUP3.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CAT_TYPE4.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CODE_GROUP4.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CAT_TYPE5.
* MOVE WA_ ??? TOBAPI1012_CHA_C-CODE_GROUP5.
* MOVE WA_ ??? TOBAPI1012_CHA_C-SMPL_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_CHA_C-DYN_MODIF_BY_VENDOR.
* MOVE WA_ ??? TOBAPI1012_CHA_C-DYN_MODIF_BY_MANUFAC.
* MOVE WA_ ??? TOBAPI1012_CHA_C-DYN_MODIF_BY_CUSTOMR.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM upro-bapi_plmz                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM upro-bapi_plmz.

 CLEAR: itab_bapi_plmz.

* MOVE WA_PLMZ-MANDT TO.
* MOVE WA_PLMZ-PLNTY TO.
* MOVE WA_PLMZ-PLNNR TO ITAB_BAPI_PLMZ-TASK_LIST_GROUP.
* MOVE WA_PLMZ-ZUONR TO.
* MOVE WA_PLMZ-ZAEHL TO.
* MOVE WA_PLMZ-TECHV TO.

 MOVE wa_plmz-datuv TO itab_bapi_plmz-valid_from.
 MOVE wa_plmz-aennr TO itab_bapi_plmz-change_no.
 MOVE wa_plmz-loekz TO itab_bapi_plmz-del_ind.
* MOVE WA_ ??? TOBAPI1012_COM_C-CHANGE_NO_TO.
* MOVE WA_ ??? TOBAPI1012_COM_C-VALID_TO_DATE.

* MOVE WA_PLMZ-PARKZ TO.
* MOVE wa_plmz-plnal TO itab_bapi_plmz-group_counter.
 MOVE wa_plmz-plnfl TO itab_bapi_plmz-sequence_no.
 MOVE wa_plmz-plnkn TO itab_bapi_plmz-operation_id.
 MOVE wa_plmz-stlty TO itab_bapi_plmz-bom_type.
 MOVE wa_plmz-stlnr TO itab_bapi_plmz-bom_no.
 MOVE wa_plmz-stlal TO itab_bapi_plmz-alternative_bom.
 MOVE wa_plmz-stlkn TO itab_bapi_plmz-item_id.
 MOVE wa_plmz-werk_stl TO itab_bapi_plmz-plant.
 MOVE wa_plmz-zudiv TO itab_bapi_plmz-cutting_measure_divisor.
 MOVE wa_plmz-zums1 TO itab_bapi_plmz-cutting_measure_1.
 MOVE wa_plmz-zums2 TO itab_bapi_plmz-cutting_measure_2.
 MOVE wa_plmz-zums3 TO itab_bapi_plmz-cutting_measure_3.
 MOVE wa_plmz-zumei TO itab_bapi_plmz-cutting_measure_unit.
 MOVE wa_plmz-imeng TO itab_bapi_plmz-comp_qty.
 MOVE wa_plmz-imein TO itab_bapi_plmz-comp_unit.
* MOVE WA_PLMZ-ANDAT TO.
* MOVE WA_PLMZ-ANNAM TO.
* MOVE WA_PLMZ-AEDAT TO.
* MOVE WA_PLMZ-AENAM TO.
 MOVE wa_plmz-rgekz TO itab_bapi_plmz-backflush.
 MOVE wa_plmz-stlst TO itab_bapi_plmz-order_lvl.
 MOVE wa_plmz-stlwg TO itab_bapi_plmz-order_path.
* MOVE WA_PLMZ-REFKN TO.
* MOVE WA_PLMZ-GP_UVORN TO.
* MOVE WA_PLMZ-GP_KRIT1 TO.
* MOVE WA_PLMZ-GP_FREET TO.
* MOVE WA_PLMZ-AOBAR TO.
* MOVE WA_PLMZ-ZEINH TO.
* MOVE WA_PLMZ-DAUER TO.
* MOVE WA_PLMZ-DMENG TO.
* MOVE WA_PLMZ-KNTTP TO.
* MOVE WA_PLMZ-FLGEX TO.
* MOVE WA_PLMZ-VORAB TO.
* MOVE WA_PLMZ-STRECKE TO.
 MOVE wa_plmz-stlty_w TO itab_bapi_plmz-bom_type_root.
 MOVE wa_plmz-stlnr_w TO itab_bapi_plmz-bom_no_root.
 MOVE wa_plmz-stlal_w TO itab_bapi_plmz-alternative_bom_root.
 MOVE wa_plmz-kante   TO itab_bapi_plmz-path.
* MOVE WA_PLMZ-LGORT TO.
* MOVE WA_PLMZ-DISP TO.
* MOVE WA_PLMZ-PRODFLOWID TO.

* MOVE WA_ ??? TOBAPI1012_COM_C-CUTTING_MEASURE_UNIT_ISO.
* MOVE WA_ ??? TOBAPI1012_COM_C-COMP_UNIT_ISO.

 MOVE wa_plko-werks TO itab_bapi_plmz-plant.

* das Material zur Stückliste finden
 LOOP AT wktab_mast INTO wk_mast
 WHERE stlnr = wa_plmz-stlnr
 AND   stlal = wa_plmz-stlal
 AND   werks = wa_plko-werks.
   MOVE wk_mast-matnr TO itab_bapi_plmz-material.
 ENDLOOP.

* Positionsnummer der Stückliste finden
 LOOP AT wktab_stpo INTO wk_stpo
 WHERE stlty = wa_plmz-stlty
 AND   stlnr = wa_plmz-stlnr
 AND   stlkn = wa_plmz-stlkn.
   MOVE wk_stpo-posnr TO itab_bapi_plmz-item_no.
 ENDLOOP.

* da ist wohl was mit dem Datum schiefgelaufen, das Stücklistenanlage-
* datum ist jüngeren Datums als die Zuordnung. Stücklistendatum gewinnt.
 IF wk_stpo-datuv > itab_bapi_plmz-valid_from.
   MOVE wk_stpo-datuv TO itab_bapi_plmz-valid_from.
 ENDIF.

* und auch benötigt das System die echte Arbeitsvorgangsnummer und
* nicht den SAP vergebenen Planknoten
 READ TABLE itab_plpo INTO wa_plpo
 WITH KEY plnty = wa_plmz-plnty
          plnnr = wa_plmz-plnnr
          plnkn = wa_plmz-plnkn.
 IF sy-subrc = 0.
   MOVE wa_plpo-vornr TO itab_bapi_plmz-activity.

   APPEND itab_bapi_plmz.
 ENDIF.

*MOVE BAPI1012_COM_C-PLANT
*  TO COM_CLASS_DATA_INTERFACE-WERKS                               .
*
*MOVE BAPI1012_COM_C-MATERIAL
*  TO COM_CLASS_DATA_INTERFACE-BOMAT                               .
*
ENDFORM.

*---------------------------------------------------------------------*
*                   B A P I _ L T X T _ H E A D E R                   *
*---------------------------------------------------------------------*
* Texte zu den Plankopfdaten einlesen. Es werden nur die Informationen*
* eingelesen, welche Texte vorhanden sind, da eigentliche Textzeilen- *
* übertragen übernimmt ein Nachfolge-Unterprogramm                    *
*---------------------------------------------------------------------*
FORM upro-bapi_ltxt_header.

 CONCATENATE sy-mandt
             wa_plko-plnty
             wa_plko-plnnr
             wa_plko-plnal
             wa_plko-zaehl
             INTO wa_tdname.

* Langtexte zum Arbeitsvorgang lesen, in allen Sprachen
 SELECT tdobject tdname tdid tdspras FROM stxh
 INTO CORRESPONDING FIELDS OF TABLE t_thead
 WHERE tdobject = 'ROUTING'
 AND   tdname   = wa_tdname
 AND   tdid     = 'PLKO'.

 PERFORM upro-textzeile USING '10' wa_plko-datuv '0000'.

ENDFORM.

*---------------------------------------------------------------------*
*                         B A P I _ L T X T                           *
*---------------------------------------------------------------------*
* Texte zu den AVOs, den Positionen einlesen. Es werden nur die Infor-*
* mationen eingelesen, welche Texte vorhanden sind, da eigentliche    *
* Textzeilenübertragen übernimmt ein Nachfolge-Unterprogramm          *
*---------------------------------------------------------------------*
FORM upro-bapi_ltxt.

 CONCATENATE sy-mandt
             wa_plpo-plnty
             wa_plpo-plnnr
             wa_plpo-plnkn
             wa_plpo-zaehl
             INTO wa_tdname.

* Langtexte zum Arbeitsvorgang lesen, in allen Sprachen
 SELECT tdobject tdname tdid tdspras FROM stxh
 INTO CORRESPONDING FIELDS OF TABLE t_thead
 WHERE tdobject = 'ROUTING'
 AND   tdname   = wa_tdname
 AND   tdid     = 'PLPO'.

 PERFORM upro-textzeile USING '13'
                              wa_plpo-datuv
                              wa_plpo-vornr.

ENDFORM.

*---------------------------------------------------------------------*
*                        T E X T Z E I L E                            *
*---------------------------------------------------------------------*
* Anlage von Langtexten. Umschiften der internen Texttabellen auf die *
* Tabellen, welche der BAPI braucht. Der arbeitet zusätzlich noch mit *
* Zeigern, diese werden hier aber berechnet und hochgezählt. Als Über-*
* gabe gilt die Identifikation des Textes, welchem Plan oder Position *
* er zugeordnet ist.                                                  *
*---------------------------------------------------------------------*
* =>] p_objekt: Interne Identifizierung, siehe Domäne Record_type     *
* =>] p_datuv: ab wann soll der Text gültig sein                      *
* =>] p_vornr: AVO, Arbeitsplanvorgangsnummer                         *
* die Plannummer vergibt das System. Diese ist hier noch unbekannt    *
*---------------------------------------------------------------------*
FORM upro-textzeile
    USING p_objekt
          p_datuv
          p_vornr.

 LOOP AT t_thead.
* alle Langtexte zum Arbeitsvorgang in der Sprache holen
   CALL FUNCTION 'READ_TEXT'
        EXPORTING
             id       = t_thead-tdid
             language = t_thead-tdspras
             name     = t_thead-tdname
             object   = t_thead-tdobject
        TABLES
             lines    = t_lines.

   DESCRIBE TABLE t_lines LINES anzahl.
   IF anzahl > 0.
* ein Text ist vorhanden, zuerst den Kopf füllen, Kennung '13'
* siehe Wertebereich zur Domäne record_type in der SE11
     itab_bapi_stxh-object_type = p_objekt.
     itab_bapi_stxh-valid_from  = p_datuv.
     itab_bapi_stxh-activity    = p_vornr.
     itab_bapi_stxh-langu       = t_thead-tdspras.
     itab_bapi_stxh-line_from   = wa_ltxt_index.

* jede Zeile in die Struktur vom BAPI überstellen
     LOOP AT t_lines INTO wa_lines.
       MOVE wa_lines-tdformat TO itab_bapi_ltxt-format_col.
       MOVE wa_lines-tdline   TO itab_bapi_ltxt-text_line.
       APPEND itab_bapi_ltxt.
* Positionierung anpassen
       ADD 1 TO wa_ltxt_index.
     ENDLOOP.
   ENDIF.

* Kopfdaten zum Text vervollständigen, der Textzeiger ist bereits einen
* über das Ziel hinausgeschossen, der Zähler entspricht immer dem
* Aufsetzpunkt eines neuen Textes.
   COMPUTE itab_bapi_stxh-line_to = wa_ltxt_index - 1.
   APPEND itab_bapi_stxh.
 ENDLOOP.

ENDFORM.

*---------------------------------------------------------------------*
*                        B A P I _ A U F R U F                        *
*---------------------------------------------------------------------*
* Alle internen Tabellen, welche im BAPI auch angesprochen werden,    *
* sind gefüllt. Zum krönenden Abschluß nun den BAPI starten. Dabei    *
* kann zwischen einem Testlauf (nur mal schauen, ob es klappen würde) *
* und einem Echtlauf gewählt werden (Echtlauf verbucht und der Plan   *
* ist physikalisch angelegt). Im Anschluß nach dem BAPI wird noch an  *
* die Protokolltabelle angehangen, wie der BAPI gestartet wurde (Test *
* oder echt) und welche neue Plannummer das System vergeben hat.      *
*---------------------------------------------------------------------*
FORM upro-bapi_aufruf.

 ADD 1 TO anzahl_bapi.

* V1.2 Prozente für die Eieruhr berechnen
 COMPUTE anz_prozent = anzahl_bapi * 100 / anzahl_plko.
 CONCATENATE 'aktuell wird Plan'
             wa_plko-plnnr
             'kopiert'
             INTO zw_text SEPARATED BY ' '.

* allerdings wird die Anzeige durch Eieruhren im Bapi überschrieben
 CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
      EXPORTING
           percentage = anz_prozent
           text       = zw_text.

 CALL FUNCTION 'BAPI_ROUTING_CREATE'
      EXPORTING
           testrun                = wa_test
*           PROFILE                =
           bomusage               = '3'
           application            = 'PP01'
      IMPORTING
           group                  = neue_plnnr
           groupcounter           = neue_plnal
      TABLES
           task                   = itab_bapi_plko
           materialtaskallocation = itab_bapi_mapl
           sequence               = itab_bapi_plfl
           operation              = itab_bapi_plpo
*           SUBOPERATION           =
*           REFERENCEOPERATION     =
*           WORKCENTERREFERENCE    =
           componentallocation    = itab_bapi_plmz
           productionresource     = itab_bapi_plfh
           inspcharacteristic     = itab_bapi_plmk
           textallocation         = itab_bapi_stxh
           text                   = itab_bapi_ltxt
           return                 = itab_bapi_return.

* Gesamtstatus des Durchlaufes setzen
 CLEAR: wa_bapi_return.
 MOVE 'ZM' TO wa_bapi_return-id.
 MOVE '000' TO wa_bapi_return-number.

 IF wa_test = 'X'.
   MOVE 0 TO sy-subrc.
   MOVE 'W' TO wa_bapi_return-type.
   CONCATENATE 'Testlauf' ''
               INTO wa_bapi_return-message SEPARATED BY ' '.

   APPEND wa_bapi_return TO itab_bapi_return.
 ELSE.
   IF wa_fehlerhaft = 'J'.
* irgendwas verlief nicht nach Plan. Fehleranzeige (rote Ampel)
     MOVE 'E' TO wa_bapi_return-type.
     CONCATENATE 'Fehler bei dem Aufbau' ''
                 INTO wa_bapi_return-message SEPARATED BY ' '.
     APPEND wa_bapi_return TO itab_bapi_return.
   ELSE.
* muß sein, damit der Arbeitsplan aktiv ist
     COMMIT WORK.

     IF sy-subrc = 0.
       ADD 1 TO anzahl_erfolgreich.

* Sonderzeichen, damit diese Zeile garantiert am Bildschirm erscheint
       MOVE '+' TO wa_bapi_return-type.
       CONCATENATE 'Plan' neue_plnnr 'Alternative' neue_plnal
                   'wurde erfolgreich angelegt.'
                   INTO wa_bapi_return-message SEPARATED BY ' '.
       MOVE 'angelegt wurde Plan' TO wa_bapi_return-message_v1.
       MOVE neue_plnnr    TO wa_bapi_return-message_v2.
       MOVE 'Alternative' TO wa_bapi_return-message_v3.
       MOVE neue_plnal    TO wa_bapi_return-message_v4.

       APPEND wa_bapi_return TO itab_bapi_return.
     ELSE.
       MOVE 'E' TO wa_bapi_return-type.
* Bapi durchgelaufen, aber Commit nicht erfolgreich (rote Ampel).
* Arbeitsplan existiert nicht. Der Commit ist ein Muß am Ende !
       CONCATENATE 'Commit' 'fehlerhaft'
                   INTO wa_bapi_return-message SEPARATED BY ' '.

       APPEND wa_bapi_return TO itab_bapi_return.
     ENDIF.
   ENDIF.
 ENDIF.

ENDFORM.

*---------------------------------------------------------------------*
*                    S T A T I S T I K _ B A P I                      *
*---------------------------------------------------------------------*
* BAPI-Lauf auswerten. Alle Meldungen für das Speichern auf Datei     *
* vorbereiten und wenn gewünscht am Bildschirm anzeigen. Dabei beach- *
* ten, welche Warnstufen angezeigt werden sollen.                     *
*---------------------------------------------------------------------*
FORM upro-statistik_bapi.

 CLEAR: anzahl_rot, anzahl_gelb, anzahl_gruen.

 LOOP AT itab_bapi_return INTO wa_bapi_return.
* interne Tabelle für Dateischreiben vorbereiten
   IF neue_plnnr IS INITIAL.
     MOVE wa_plko-plnnr TO wa_out-plnnr_neu.
     CLEAR wa_out-plnnr_alt.                               "V1.1
   ELSE.
     MOVE neue_plnnr    TO wa_out-plnnr_neu.
     MOVE wa_plko-plnnr TO wa_out-plnnr_alt.               "V1.1
   ENDIF.
   MOVE wa_mapl-matnr                  TO wa_out-matnr.    "V1.1
   MOVE wa_bapi_return-type            TO wa_out-type.
   MOVE wa_bapi_return-id              TO wa_out-id.
   MOVE wa_bapi_return-number          TO wa_out-number.
   MOVE wa_bapi_return-message         TO wa_out-message.
   MOVE wa_out                         TO ds_out-satz.
   APPEND ds_out TO dstab_out.

   IF pmmeld    =  'X'
   AND sy-batch <> 'X'.
* Meldungen am Bildschirm anzeigen, gemäß Stufe Ampel am Bildschirm
* bringen, jedoch Warnstufe beachten, welche gewünscht wurde beim
* Einstieg
     CONCATENATE wa_out-plnnr_neu
                 wa_bapi_return-parameter
                 wa_bapi_return-message
                 INTO zw_text SEPARATED BY ' '.

     CASE wa_bapi_return-type.
       WHEN 'A'.
         ADD 1 TO anzahl_rot.
         WRITE AT: /1 icon_defect AS ICON,
                    7 zw_text.
       WHEN 'E'.
         ADD 1 TO anzahl_rot.
         WRITE AT: /1 icon_red_light AS ICON,
                    7 zw_text.
       WHEN 'W'.
         ADD 1 TO anzahl_gelb.
         IF pmx_gelb = 'X'
         OR pmxgruen = 'X'.
           WRITE AT: /1 icon_yellow_light AS ICON,
                      7 zw_text.
         ENDIF.
       WHEN 'S'.
         ADD 1 TO anzahl_gruen.
         IF pmxgruen = 'X'.
           WRITE AT: /1 icon_green_light AS ICON,
                      7 zw_text.
         ENDIF.
       WHEN '+'.
         ADD 1 TO anzahl_gruen.
         WRITE AT: /1 icon_checked AS ICON,
                    7 zw_text.
     ENDCASE.
   ENDIF.
 ENDLOOP.

* Gesamtanzahl der Meldungen anzeigen, welche niedriger sind als die
* gewünschte Warnstufe
 IF pmmeld    =  'X'
 AND sy-batch <> 'X'.
   IF  pmx_gelb = ' '
   AND pmxgruen = ' '
   AND anzahl_gelb > 0.
     IF anzahl_gelb = 1.
       WRITE AT: /1 icon_yellow_light AS ICON,
                  7 'eine Meldung mit Warnung.'.
     ELSE.
       WRITE AT: /1 icon_yellow_light AS ICON,
                  7 anzahl_gelb,
                 14 'Meldungen mit Warnung.'.
     ENDIF.
   ENDIF.
   IF pmxgruen = ' '
   AND anzahl_gruen > 0.
     WRITE AT: /1 icon_green_light AS ICON,
                7 anzahl_gruen,
               14 'Meldungen ohne Beanstandungen'.
   ENDIF.

   SKIP 1.

 ENDIF.

ENDFORM.

*---------------------------------------------------------------------*
*                           S T A T I T I K                           *
*---------------------------------------------------------------------*
* zu guter letzt noch die Gesamtstatistik aufbereiten für die Ergeb-  *
* nisdatei und die Anzeige am Bildschirm. Es werden die Anzahl Sätze  *
* zu den internen Tabellen ermittelt und ausgegeben                   *
*---------------------------------------------------------------------*
FORM upro-statistik.

 DATA:
   idx_beginn LIKE sy-tabix,
   idx_ende   LIKE sy-tabix.

 CLEAR: wa_out, ds_out, idx_beginn, idx_ende.
 APPEND ds_out TO dstab_out.

 MOVE 'Ergebnis' TO wa_out-plnnr_neu.

* da die allgemeinen Meldungen an die interne Tabelle auch für die
* Bapi-Fehlermeldungen gehangen werden, muß der Bereich für die Anzeige
* eingegrenzt werden. Dieses geschieht über die Zeiger idx_beginn und
* idx_ende
 MOVE sy-tabix TO idx_beginn.

 DESCRIBE TABLE intab_mapl LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Arbeitspläne zu bearbeiten' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'zu bearbeitende Arbeitspläne'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 IF anzahl_f_bapi = 0.
   MOVE 'S' TO wa_out-type.
   MOVE 'Keine Zuordnungsfehler' TO wa_out-message.
 ELSE.
   MOVE 'E' TO wa_out-type.
   CONCATENATE anzahl_f_bapi
               'Zuordnungsfehler'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE itab_mapl LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Pläne zu Materialien' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Pläne zu Materialien'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE itab_plko LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Arbeitspläne' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Arbeitspläne'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE itab_plfl LINES anzahl.
 IF anzahl = 0.
   MOVE 'W' TO wa_out-type.
   MOVE 'Keine Folgen zu den Arbeitsplänen' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Folgen zu Arbeitsplänen'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE itab_plas LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Positionen zu den Plänen' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Positionen zu den Plänen'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE itab_plpo LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Arbeitsvorgänge' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Arbeitsvorgänge'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE itab_plfh LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Fertigungshilfsmittel in Plänen' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Fertigungshilfsmittel in Plänen'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE wktab_crfh LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Fertigungshilfsmittel - Stammsätze' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Fertigungshilfsmittel - Stammsätze'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE itab_plmk LINES anzahl.
 IF anzahl = 0.
   MOVE 'W' TO wa_out-type.
   MOVE 'Keine Prüfplanmerkmale' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Prüfplanmerkmale'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE itab_plmz LINES anzahl.
 IF anzahl = 0.
   MOVE 'W' TO wa_out-type.
   MOVE 'Keine Zuordnungen zur Stückliste' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Zuordnungen zur Stückliste'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE wktab_mast LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Materialien als Stücklistenkopf' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Materialien als Stücklistenkopf'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 DESCRIBE TABLE wktab_stpo LINES anzahl.
 IF anzahl = 0.
   MOVE 'E' TO wa_out-type.
   MOVE 'Keine Stücklistenpositionen' TO wa_out-message.
 ELSE.
   MOVE 'S' TO wa_out-type.
   CONCATENATE anzahl
               'Stücklistenpositionen'
               INTO wa_out-message SEPARATED BY ' '.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

* V1.1 Statistik, wie die BAPI-Aufrufe verlaufen sind
 IF wa_test = 'X'.
   MOVE 'Testlauf' TO wa_out-plnnr_neu.
   MOVE 'W' TO wa_out-type.
   CONCATENATE anzahl_bapi
               'BAPI Aufrufe'
               INTO wa_out-message SEPARATED BY ' '.

 ELSE.
   IF anzahl_bapi = anzahl_erfolgreich.
     MOVE 'S' TO wa_out-type.
     CONCATENATE 'Alle'
                 anzahl_bapi
                 'BAPI Aufrufe erfolgreich durchlaufen'
                 INTO wa_out-message SEPARATED BY ' '.
   ELSE.
     MOVE 'E' TO wa_out-type.
     CONCATENATE anzahl_bapi
                 'BAPI Aufrufe, wovon'
                 anzahl_erfolgreich
                 'erfogreich waren'
                 INTO wa_out-message SEPARATED BY ' '.
   ENDIF.
 ENDIF.
 MOVE wa_out TO ds_out-satz.
 APPEND ds_out TO dstab_out.

 MOVE sy-tabix TO idx_ende.

* V1.1 Ergebnis nun auch am Bildschirm anzeigen, wenn dieses gewünscht
* ist (Eingabeparameter und kein Hintergrundprozeß)
 IF  pmmeld = 'X'
 AND sy-batch <> 'X'
 AND idx_beginn > 0
 AND idx_ende   > idx_beginn..
   LOOP AT dstab_out INTO ds_out FROM idx_beginn TO idx_ende.
     MOVE ds_out-satz TO wa_out.
     CASE wa_out-type.
       WHEN 'E'.
         WRITE: / icon_red_light    AS ICON.
       WHEN 'W'.
         WRITE: / icon_yellow_light AS ICON.
       WHEN 'S'.
         WRITE: / icon_green_light  AS ICON.
       WHEN ' '.
* Leerzeile.
         SKIP 1.
       WHEN OTHERS.
         WRITE: / icon_light_out    AS ICON.
     ENDCASE.
     WRITE: wa_out-message(70).
   ENDLOOP.
 ENDIF.

ENDFORM.

***** Ende *****
* Copyright BJH Software, Datei überarbeitet am: 26.5.2005