Sie sind auf Seite 1von 12

************************************************************************ * * * Includebaustein RFFORI14 zum Zahlungstrgerprogramm RFFOEDI0 mit * * Unterprogrammen fr das Erstellen von IDocs und Begleitzettel * * Include

RFFORI04, used in the payment medium program RFFOEDI0 * * with subroutines for creation of IDocs and the accomp. sheet * * * * subroutine called by report / in subroutine * * ------------------------------------------------------------------- * * EDI RFFOEDI0 * * FORMULAR_AUSGEBEN FORM EDI * * PRUEFUNG_EDI_VERBINDUNG GET REGUH * ************************************************************************

*----------------------------------------------------------------------* * Lokale Tabellen und Felder * *----------------------------------------------------------------------* DATA: BEGIN OF EDI_PARTNER OCCURS 10, "merken, ob eine EDI-PartnerverBUKRS LIKE T012D-BUKRS, "einbarung getroffen wurde HBKID LIKE T012D-HBKID, EDIPN LIKE T012D-EDIPN, OK(1) TYPE C, END OF EDI_PARTNER, BEGIN OF EDI_TAB_ZETTEL OCCURS 3, "sammelt die Whrungsinformation WAERS LIKE REGUH-WAERS,"fr den EDI-Begleitzettel ISOWR LIKE REGUD-WAERS, SUMME(7) TYPE P, UBKNT LIKE REGUH-UBKNT, UWAER LIKE T012K-WAERS, END OF EDI_TAB_ZETTEL, EDI_HLP_AUSFD EDI_XAVIS_REQ LIKE REGUH-AUSFD,"erster Ausfhrungstermin LIKE DTAMDET-XAVIS_REQ.

*----------------------------------------------------------------------* * FORM EDI * *----------------------------------------------------------------------* * gerufen von END-OF-SELECTION (RFFOEDI0) * * called by END-OF-SELECTION (RFFOEDI0) * *----------------------------------------------------------------------* * keine USING-Parameter * * no USING-parameters * *----------------------------------------------------------------------* FORM EDI. *----------------------------------------------------------------------* * Vorbereitung zum Datentrgeraustausch * * preparations for DME * *----------------------------------------------------------------------* * Sortieren des Datenbestandes * sort of extract SORT BY

REGUH-ZBUKR REGUH-UBNKS REGUH-UBNKY REGUD-XEINZ T012D-EDIPN REGUH-UBNKL REGUH-UBKNT REGUH-ZBNKS REGUH-ZBNKY REGUH-ZBNKL REGUH-ZBNKN REGUH-LIFNR REGUH-KUNNR REGUH-EMPFG REGUH-VBLNR HLP_SORTP1 HLP_SORTP2 HLP_SORTP3 REGUP-BELNR. * Dateiformat / file format HLP_DTFOR = 'SAP IDOC'.

"paying company code "country of house bank "bank key (for sort) "incoming/outgoing "EDI partner identification "bank number of house bank "account number at house bank "country of payee's bank "bank key (for sort) "bank number of payee's bank "account number of payee "creditor number "debitor number "payee is CPD / alternative payee "payment document number "sort field for single items "sort field for single items "sort field for single items "invoice document number

*----------------------------------------------------------------------* * Abarbeiten der extrahierten Daten * * loop at extracted data * *----------------------------------------------------------------------* LOOP. *-- Neuer zahlender Buchungskreis -------------------------------------*-- new paying company code -------------------------------------------AT NEW REGUH-ZBUKR. PERFORM BUCHUNGSKREIS_DATEN_LESEN. * * * * berschrift modifizieren modify title of payment method T042Z-TEXT1 = TEXT-004. Spoolparameter zur Ausgabe von Listen (z.B. Meldeliste) specify spool parameters for print of lists (e.g. reporting) ITCPO-TDDEST = PAR_PRIB. ITCPO-TDSUFFIX2 = PAR_VARI. ITCPO-TDIMMED = PAR_SOFB. EXPORT ITCPO TO MEMORY ID 'EDI ITCPO'. Spoolparameter zur Ausgabe von Begleitzettel und Formularabschlu specify spool parameters for print of sheet and summary ITCPO-TDPAGESLCT = SPACE. "all pages ITCPO-TDNEWID = 'X'. "create new spool dataset ITCPO-TDCOPIES = 1. "one copy ITCPO-TDDEST = PAR_PRIW. "name of printer ITCPO-TDPREVIEW = SPACE. "no preview ITCPO-TDCOVER = SPACE. "Kein Titelblatt ITCPO-TDDATASET = 'LIST7S'. "dataset name IF ZW_XVORL EQ SPACE. ITCPO-TDSUFFIX1 = PAR_PRIW. "name of printer ELSE.

* *

ITCPO-TDSUFFIX1 ENDIF. ITCPO-TDSUFFIX2 ITCPO-TDIMMED ITCPO-TDDELETE ITCPO-TDTITLE ITCPO-TDCOVTITLE

= 'TEST'. = = = = = PAR_VARI. PAR_SOFW. SPACE. T042Z-TEXT1. T042Z-TEXT1.

"test run "name of report variant "immediately? "do not delete after print "short description "Cover

IF PAR_PRIW EQ SPACE OR PAR_XDTA EQ SPACE. FLG_DIALOG = 'X'. ELSE. FLG_DIALOG = SPACE. ENDIF. IF PAR_WFOR EQ SPACE. IF T042B-EFORN EQ SPACE. IF SY-BATCH EQ SPACE. MESSAGE A356 WITH REGUH-ZBUKR. ELSE. MESSAGE S356 WITH REGUH-ZBUKR. MESSAGE S094. STOP. ENDIF. ELSE. PAR_WFOR = T042B-EFORN. ENDIF. ENDIF. ENDAT. *-- Neue Hausbank -----------------------------------------------------*-- new house bank ----------------------------------------------------AT NEW REGUH-UBNKL. PERFORM HAUSBANK_DATEN_LESEN. PERFORM ZAHLWEG_DATEN_LESEN. HLP_RZAWE = REGUH-RZAWE. ENDAT. *-- Neuer EDI-Partner -------------------------------------------------*-- New EDI partner ---------------------------------------------------AT NEW T012D-EDIPN. * * Tabelle der Zahlungsbelege rcksetzen reset table for payment doc. data CLEAR TAB_BELEGE30A. REFRESH TAB_BELEGE30A. Felder fr Formularabschlu initialisieren initialize fields for summary CLEAR: CNT_FORMULARE, CNT_HINWEISE, SUM_ABSCHLUSS, HLP_DTA_ZWELS, EDI_HLP_AUSFD. Tabelle fr Begleitzettel rcksetzen

* *

reset table for accompanying sheet CLEAR EDI_TAB_ZETTEL. REFRESH EDI_TAB_ZETTEL. Neues IDoc starten start new IDoc IF PAR_XDTA NE SPACE. PERFORM ZUSATZFELD_FUELLEN USING *REGUT-DTKEY '*'. PERFORM NAECHSTER_INDEX USING HLP_RENUM. PERFORM FUELLEN_REGUT USING *REGUT-DTKEY. EDI fr die Hausbank starten Start EDI for this house bank CALL FUNCTION 'FI_EDI_PAYEXT_PEXR2001_NEW' EXPORTING REGUH_IN = REGUH XEINZ_IN = REGUD-XEINZ EXCEPTIONS NOT_POSSIBLE = 1 OTHERS = 2. ENDIF. ENDAT.

* *

* *

*-- Neue Kontonummer bei der Hausbank ---------------------------------*-- new account number with house bank --------------------------------AT NEW REGUH-UBKNT. * * Kontonummer ohne Aufbereitungszeichen speichern store numerical account number for code line REGUD-OBKNT = REGUH-UBKNT. ENDAT. *-- Neue Empfngerbank ------------------------------------------------*-- new bank of payee -------------------------------------------------AT NEW REGUH-ZBNKL. PERFORM EMPFBANK_DATEN_LESEN. ENDAT. *-- Neue Kontonummer bei der Empfngerbank ----------------------------*-- new bank account number of payee ----------------------------------AT NEW REGUH-ZBNKN. * * Kontonummer ohne Aufbereitungszeichen speichern store numerical bank account number HLP_ZBNKN = REGUH-ZBNKN. ENDAT. *-- Neue Zahlungsbelegnummer ------------------------------------------*-- new payment document number ---------------------------------------AT NEW REGUH-VBLNR.

* *

Zahlweg-Daten nachlesen, falls notwendig re-read payment method data if necessary IF REGUH-RZAWE NE HLP_RZAWE. PERFORM ZAHLWEG_DATEN_LESEN. HLP_RZAWE = REGUH-RZAWE. T042Z-TEXT1 = TEXT-004. ENDIF. PERFORM ZAHLUNGS_DATEN_LESEN. PERFORM SUMMENFELDER_INITIALISIEREN. ENDAT.

*-- Verarbeitung der Einzelposten-Informationen -----------------------*-- single item information -------------------------------------------AT DATEN. PERFORM EINZELPOSTENFELDER_FUELLEN. PERFORM SUMMENFELDER_FUELLEN. ENDAT. *-- Ende der Zahlungsbelegnummer --------------------------------------*-- end of payment document number ------------------------------------AT END OF REGUH-VBLNR. CLEAR SY-SUBRC. IF PAR_XDTA NE SPACE. IF REGUH-RPOST GT PAR_ERWE AND "too many items PAR_ERWE NE 9999. EDI_XAVIS_REQ = 'X'. ELSE. CLEAR EDI_XAVIS_REQ. ENDIF. CLEAR REGUD-CHECT. CALL FUNCTION 'GET_CHECK_NUMBER' EXPORTING I_REGUH = REGUH IMPORTING E_CHECK = REGUD-CHECT TABLES T_REGUP = TAB_REGUP EXCEPTIONS NOT_FOUND = 0 OTHERS = 4. IF sy-subrc NE 0. FIMSG-MSGID = SY-MSGID. FIMSG-MSGV1 = SY-MSGV1. FIMSG-MSGV2 = SY-MSGV2. FIMSG-MSGV3 = SY-MSGV3. FIMSG-MSGV4 = SY-MSGV4. PERFORM MESSAGE USING SY-MSGNO. REGUH-EDIBN = 'E'. UPDATE REGUH SET EDIBN = REGUH-EDIBN WHERE LAUFD EQ REGUH-LAUFD AND LAUFI EQ REGUH-LAUFI AND XVORL EQ REGUH-XVORL AND ZBUKR EQ REGUH-ZBUKR

AND AND AND AND

LIFNR KUNNR EMPFG VBLNR

EQ EQ EQ EQ

REGUH-LIFNR REGUH-KUNNR REGUH-EMPFG REGUH-VBLNR.

SY-SUBRC = 4. ELSE. IF NOT REGUD-CHECT IS INITIAL. TAB_SCHECKS-ZBUKR = REGUH-ZBUKR. TAB_SCHECKS-VBLNR = REGUH-VBLNR. TAB_SCHECKS-CHECT = REGUD-CHECT. APPEND TAB_SCHECKS. ENDIF. CALL FUNCTION 'FI_EDI_PAYEXT_PEXR2001_OUT' EXPORTING REGUH_IN = REGUH REGUD_IN = REGUD XEINZ_IN = REGUD-XEINZ TABLES TAB_REGUP = TAB_REGUP CHANGING XAVIS_IO = EDI_XAVIS_REQ EXCEPTIONS OTHERS = 4. ENDIF. IF SY-SUBRC NE 0. REGUH-EDIBN = 'E'. MOVE-CORRESPONDING REGUH TO: TAB_KEIN_AVIS, ERR_EDI. APPEND: TAB_KEIN_AVIS, ERR_EDI. ENDIF. ENDIF. IF SY-SUBRC EQ 0. IF PAR_XDTA NE SPACE. IF EDI_XAVIS_REQ IS INITIAL. "kein Avis gefordert MOVE-CORRESPONDING REGUH TO TAB_KEIN_AVIS. APPEND TAB_KEIN_AVIS. ENDIF. PERFORM BELEGDATEN_SCHREIBEN. PERFORM ZAHLWEG_EINFUEGEN USING REGUH-RZAWE HLP_DTA_ZWELS. ENDIF. * * Frhestes Ausfhrungsdatum merken Store earliest execution date IF REGUH-AUSFD LE EDI_HLP_AUSFD OR EDI_HLP_AUSFD EQ 0. EDI_HLP_AUSFD = REGUH-AUSFD. ENDIF. Tabelle fr den Begleitzettel bei DTA fllen fill table for accompanying sheet PERFORM HAUSBANK_KONTO_LESEN. CLEAR EDI_TAB_ZETTEL. PERFORM ISOCODE_UMSETZEN USING REGUH-WAERS EDI_TAB_ZETTEL-ISOWR. PERFORM ISOCODE_UMSETZEN USING T012K-WAERS EDI_TAB_ZETTEL-UWAER. EDI_TAB_ZETTEL-WAERS = REGUH-WAERS. EDI_TAB_ZETTEL-UBKNT = REGUH-UBKNT. EDI_TAB_ZETTEL-SUMME = REGUH-RWBTR. COLLECT EDI_TAB_ZETTEL. Summenfelder hochzhlen und aufbereiten

* *

add up total amount ADD 1 TO ADD REGUH-RBETR TO WRITE: CNT_HINWEISE TO CNT_FORMULARE TO SUM_ABSCHLUSS TO TRANSLATE: REGUD-AVISH USING REGUD-ZAHLT USING REGUD-SUMME USING ENDIF. SET LANGUAGE SY-LANGU. ENDAT.

fields CNT_FORMULARE. SUM_ABSCHLUSS. REGUD-AVISH, REGUD-ZAHLT, REGUD-SUMME CURRENCY T001-WAERS. ' *', ' *', ' *'.

"auf Anmeldesprache zurckstellen "back to user language

*-- Ende des EDI-Partners ---------------------------------------------*-- end of EDI partner ------------------------------------------------AT END OF T012D-EDIPN. IF PAR_XDTA NE SPACE. IF HLP_DTA_ZWELS NE SPACE. * * IDoc schlieen close IDoc CALL FUNCTION 'FI_EDI_PAYEXT_PEXR2001_END' EXPORTING REGUH_IN = REGUH XEINZ_IN = REGUD-XEINZ IMPORTING USREX_OUT = *REGUT-USREX EXCEPTIONS NOT_POSSIBLE = 1 OTHERS = 2. Klammer-IDoc schlieen close collecting IDoc CALL FUNCTION 'FI_EDI_EUPEXR_IDCREF01_OUT' EXPORTING REGUH_IN = REGUH IMPORTING RENUM_OUT = HLP_RESULTAT DOCNUM_OUT = *REGUT-EDINUM EXCEPTIONS NOT_POSSIBLE = 1 OTHERS = 2. IF SY-SUBRC NE 0. MOVE-CORRESPONDING SYST TO FIMSG. PERFORM MESSAGE USING FIMSG-MSGNO. ENDIF. HLP_DTA_ID-REFNR = HLP_RESULTAT. SUM_REGUT = SUM_ABSCHLUSS. PERFORM ABSCHLUSS_REGUT. CLEAR TAB_AUSGABE. TAB_AUSGABE-NAME = TEXT-005.

* *

TAB_AUSGABE-FILENAME = *REGUT-EDINUM. TAB_AUSGABE-RENUM = *REGUT-RENUM. REPLACE '&' WITH T012D-EDIPN INTO TAB_AUSGABE-NAME. COLLECT TAB_AUSGABE. * * Begleitliste, Formularabschlu, sonstige Listen accompanying sheet, summary, other lists PERFORM FORMULAR_AUSGEBEN. IMPORT ITCPP FROM MEMORY ID 'EDI ITCPP'. IF SY-SUBRC EQ 0. CLEAR TAB_AUSGABE. TAB_AUSGABE-NAME = ITCPP-TDTITLE. TAB_AUSGABE-DATASET = ITCPP-TDDATASET. TAB_AUSGABE-SPOOLNR = ITCPP-TDSPOOLID. REPLACE '&' WITH REGUH-HBKID INTO TAB_AUSGABE-NAME. COLLECT TAB_AUSGABE. ENDIF. Gesammelte Zahlungsbelegdaten in Datenbank RFDT sichern Store payment documents (not for proposal run or HR !) IF REGUH-XVORL IS INITIAL AND "Kein Vorschlagslauf und HLP_LAUFK CA ' *R'. "nur FI-AP/AR und FI-BL PERFORM TAB_BELEGE_SCHREIBEN. ENDIF. ELSE. DELETE *REGUT. ENDIF. ELSE. PERFORM FORMULAR_AUSGEBEN. ENDIF. ENDAT. ENDLOOP. ENDFORM. "EDI

* *

*----------------------------------------------------------------------* * FORM FORMULAR_AUSGEBEN * *----------------------------------------------------------------------* * Schreiben eines Begleitzettels mit Formularabschlu * * write accompanying sheet and summary form * *----------------------------------------------------------------------* FORM FORMULAR_AUSGEBEN. * IDoc lesen und Prfsummen berechnen * read IDoc and calculate check sums DATA EDIDD LIKE EDIDD OCCURS 100 WITH HEADER LINE. TABLES E1IDRS1. CALL FUNCTION 'FI_EDI_SEGMENTS_GET_ALL' EXPORTING DOCUMENT_NR_IN = *REGUT-EDINUM TABLES IDOC_CONTAINERS = EDIDD EXCEPTIONS OTHERS = 4. IF SY-SUBRC EQ 0.

CALL FUNCTION 'FI_EDI_IDCREF01_CHECKSUM' IMPORTING E1IDRS1_OUT = E1IDRS1 TABLES IDOC_CONTAINERS = EDIDD EXCEPTIONS OTHERS = 4. ENDIF. IF SY-SUBRC NE 0. MOVE-CORRESPONDING SYST TO FIMSG. PERFORM MESSAGE USING FIMSG-MSGNO. ENDIF. * Formular ffnen * open form SET COUNTRY SPACE. REGUH-AUSFD = EDI_HLP_AUSFD. REGUD-LABEL = *REGUT-RENUM. CALL FUNCTION 'OPEN_FORM' EXPORTING FORM = PAR_WFOR DEVICE = 'PRINTER' LANGUAGE = T001-SPRAS OPTIONS = ITCPO DIALOG = FLG_DIALOG EXCEPTIONS CANCELED = 4 FORM = 8. CASE SY-SUBRC. WHEN 4. MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. STOP. WHEN 8. "abend: IF SY-BATCH EQ SPACE. "form is not active MESSAGE A069 WITH PAR_WFOR. ELSE. MESSAGE S069 WITH PAR_WFOR. MESSAGE S094. STOP. ENDIF. ENDCASE. DO PAR_ANZB TIMES. CALL FUNCTION 'START_FORM' EXPORTING STARTPAGE = 'FIRST'. * * Ausgabe des Begleitzettels write sheet CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = '530' EXCEPTIONS WINDOW = 1 ELEMENT = 2. IF SY-SUBRC EQ 2. ERR_ELEMENT-FNAME ERR_ELEMENT-FENST ERR_ELEMENT-ELEMT ERR_ELEMENT-TEXT = = = = PAR_WFOR. 'MAIN'. '530'. TEXT-530.

COLLECT ERR_ELEMENT. ENDIF. LOOP AT EDI_TAB_ZETTEL. CALL FUNCTION 'SPELL_AMOUNT' EXPORTING LANGUAGE = SPACE CURRENCY = EDI_TAB_ZETTEL-WAERS AMOUNT = EDI_TAB_ZETTEL-SUMME FILLER = SPACE IMPORTING IN_WORDS = SPELL. SHIFT SPELL-NUMBER LEFT DELETING LEADING '0'. REGUD-SWNET = EDI_TAB_ZETTEL-SUMME. REGUH-WAERS = EDI_TAB_ZETTEL-WAERS. REGUD-WAERS = EDI_TAB_ZETTEL-ISOWR. REGUH-UBKNT = EDI_TAB_ZETTEL-UBKNT. REGUD-HWAER = EDI_TAB_ZETTEL-UWAER. CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = '531' FUNCTION = 'APPEND' EXCEPTIONS WINDOW = 1 ELEMENT = 2. IF SY-SUBRC EQ 2. ERR_ELEMENT-FNAME = PAR_WFOR. ERR_ELEMENT-FENST = 'MAIN'. ERR_ELEMENT-ELEMT = '531'. ERR_ELEMENT-TEXT = TEXT-531. COLLECT ERR_ELEMENT. ENDIF. ENDLOOP. * * Hauswhrung zurcksetzen reset local currency REGUD-HWAER = T001-WAERS. CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = '532' FUNCTION = 'APPEND' EXCEPTIONS WINDOW = 1 ELEMENT = 2. IF SY-SUBRC EQ 2. ERR_ELEMENT-FNAME = PAR_WFOR. ERR_ELEMENT-FENST = 'MAIN'. ERR_ELEMENT-ELEMT = '532'. ERR_ELEMENT-TEXT = TEXT-532. COLLECT ERR_ELEMENT. ENDIF. CALL FUNCTION 'END_FORM'.

ENDDO. IF PAR_XDTA NE SPACE. CALL FUNCTION 'START_FORM' EXPORTING STARTPAGE = 'LAST' LANGUAGE = T001-SPRAS. * * Ausgabe des Formularabschlusses fr EDI write summary for EDI CONDENSE HLP_DTA_ZWELS. REGUD-ZWELS = HLP_DTA_ZWELS. CALL FUNCTION 'WRITE_FORM' EXPORTING WINDOW = 'SUMMARY' ELEMENT = '520' EXCEPTIONS WINDOW = 1 ELEMENT = 2. IF SY-SUBRC EQ 2. ERR_ELEMENT-FNAME = PAR_WFOR. ERR_ELEMENT-FENST = 'SUMMARY'. ERR_ELEMENT-ELEMT = '520'. ERR_ELEMENT-TEXT = TEXT-520. COLLECT ERR_ELEMENT. ENDIF. CALL FUNCTION 'END_FORM'. ENDIF. CALL FUNCTION 'CLOSE_FORM' IMPORTING RESULT = ITCPP. IF PAR_XDTA NE SPACE. CLEAR TAB_AUSGABE. TAB_AUSGABE-NAME = ITCPP-TDTITLE. TAB_AUSGABE-DATASET = ITCPP-TDDATASET. TAB_AUSGABE-SPOOLNR = ITCPP-TDSPOOLID. COLLECT TAB_AUSGABE. ELSE. MESSAGE S588(FS). ENDIF. ENDFORM. "Formular ausgeben

*----------------------------------------------------------------------* * FORM PRUEFUNG_EDI_VERBINDUNG * *----------------------------------------------------------------------* * gerufen von GET REGUH (RFFOEDI0) * * called by GET REGUH (RFFOEDI0) * *----------------------------------------------------------------------* * keine USING-Parameter * * no USING-parameters * *----------------------------------------------------------------------*

FORM PRUEFUNG_EDI. READ TABLE EDI_PARTNER WITH KEY BUKRS = REGUH-ZBUKR HBKID = REGUH-HBKID. IF SY-SUBRC NE 0. EDI_PARTNER-BUKRS = REGUH-ZBUKR. EDI_PARTNER-HBKID = REGUH-HBKID. EDI_PARTNER-EDIPN = SPACE. EDI_PARTNER-OK = SPACE. SELECT SINGLE * FROM T012D WHERE BUKRS = REGUH-ZBUKR AND HBKID = REGUH-HBKID. IF SY-SUBRC EQ 0 AND T012D-EDIPN NE SPACE. SELECT SINGLE * FROM EDPP1 WHERE PARNUM = T012D-EDIPN AND PARTYP = 'B'. IF SY-SUBRC EQ 0. EDI_PARTNER-EDIPN = T012D-EDIPN. EDI_PARTNER-OK = 'X'. ENDIF. ENDIF. IF EDI_PARTNER-OK EQ SPACE. FIMSG-MSGID = 'F4'. FIMSG-MSGV1 = REGUH-ZBUKR. FIMSG-MSGV2 = REGUH-HBKID. PERFORM MESSAGE USING '262'. ENDIF. APPEND EDI_PARTNER. ENDIF. IF EDI_PARTNER-OK EQ SPACE. REGUH-EDIBN = 'E'. MOVE-CORRESPONDING REGUH TO ERR_EDI. APPEND ERR_EDI. REJECT. ELSE. T012D-EDIPN = EDI_PARTNER-EDIPN. ENDIF. ENDFORM.