*& Report ZFI_MILTA_FIDELYO_AKTARIM . *
*& msirli Doğan Holding Sap *
*&---------------------------------------------------------------------*
REPORT zfi_milta_fidelyo_aktarim NO STANDARD PAGE HEADING.
INCLUDE zzinc0002.
INCLUDE
INCLUDE zms_global_function.
INCLUDE rvdirekt.
TABLES : ZFI_T_PROTEL02, ZFI_T_PROTEL03, ZFI_T_PROTEL06, ZFI_T_PROTEL07, ZFI_T_PROTEL08,
zsmile_kdv_oran, ZFI_T_PROTEL09, ZFI_T_PROTEL10, ZFI_T_PROTEL11, ZFI_T_PROTEL12,
ZFI_T_PROTEL13.
TYPES: BEGIN OF type_report,
chk TYPE C,
* color TYPE kkblo_t_specialcol,
statampel TYPE char4,
hata TYPE char200,
toplam_hesapla TYPE char1,
* INTID LIKE ZFI_T_PROTEL02-INTID,
INVOICEID LIKE ZFI_T_PROTEL02-INVOICEID,
SYSTEMREFERENCE LIKE ZFI_T_PROTEL02-SYSTEMREFERENCE,
CUSTOMERID LIKE ZFI_T_PROTEL02-CUSTOMERID,
EXTRA1 LIKE ZFI_T_PROTEL02-EXTRA1,
CUSTOMERNAME LIKE ZFI_T_PROTEL02-CUSTOMERNAME,
TAXRATE LIKE ZFI_T_PROTEL03-TAXRATE,
taxrate_value LIKE bseg-wrbtr,
INVOICEDATE LIKE ZFI_T_PROTEL02-INVOICEDATE,
AMOUNT LIKE ZFI_T_PROTEL03-AMOUNT,
TAXAMOUNT LIKE ZFI_T_PROTEL03-TAXAMOUNT,
UNITPRICE LIKE ZFI_T_PROTEL03-UNITPRICE,
PESIN_TUTAR LIKE ZFI_T_PROTEL03-AMOUNT,
CARI_HESAP_TUTAR LIKE ZFI_T_PROTEL03-AMOUNT,
KREDI_KART_TUTAR LIKE ZFI_T_PROTEL03-AMOUNT,
CURRENCYCODE LIKE ZFI_T_PROTEL03-CURRENCYCODE,
BUKRS LIKE T001-BUKRS,
GJAHR LIKE BKPF-GJAHR,
BELNR_PESIN LIKE BKPF-BELNR,
BELNR_CARI LIKE BKPF-BELNR,
BELNR_KART LIKE BKPF-BELNR,
CUSTOMERTAXOFFICE LIKE ZFI_T_PROTEL02-CUSTOMERTAXOFFICE,
CUSTOMERTAXNO LIKE ZFI_T_PROTEL02-CUSTOMERTAXNO,
CUSTOMERSTREETNAME LIKE ZFI_T_PROTEL02-CUSTOMERSTREETNAME,
CUSTOMERCITYNAME LIKE ZFI_T_PROTEL02-CUSTOMERCITYNAME,
CUSTOMERNO LIKE ZFI_T_PROTEL02-CUSTOMERNO,
HKONT_ANAHESAP LIKE BSEG-HKONT,
HKONT_KDVHESAP LIKE BSEG-HKONT,
MWSKZ LIKE BSEG-MWSKZ,
TERS TYPE char20,
SGTXT LIKE ZFI_T_PROTEL10-SGTXT,
EFAT TYPE CHAR1,
STCD2 LIKE KNA1-STCD2,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
KTOSL LIKE BSEG-KTOSL,
DVZ_AMOUNT LIKE ZFI_T_PROTEL03-AMOUNT,
DVZ_TAXAMOUNT LIKE ZFI_T_PROTEL03-TAXAMOUNT,
DVZ_UNITPRICE LIKE ZFI_T_PROTEL03-UNITPRICE,
DVZ_PESIN_TUTAR LIKE ZFI_T_PROTEL03-AMOUNT,
DVZ_CARI_HESAP_TUTAR LIKE ZFI_T_PROTEL03-AMOUNT,
DVZ_KREDI_KART_TUTAR LIKE ZFI_T_PROTEL03-AMOUNT,
WAERS LIKE ZFI_T_PROTEL09-WAERS,
EXTRA3 LIKE ZFI_T_PROTEL02-EXTRA3,
EXTRA4 LIKE ZFI_T_PROTEL02-EXTRA4,
EXTRA5 LIKE ZFI_T_PROTEL02-EXTRA5,
EXTRA6 LIKE ZFI_T_PROTEL02-EXTRA6,
MATBU LIKE BKPF-XBLNR,
KURRF LIKE BKPF-kursf,
* MANUALINVOICENO like ZFI_T_PROTEL02-MANUALINVOICENO,
END OF type_report.
DATA : itab_type_report TYPE type_report OCCURS 0 WITH HEADER LINE.
DATA : itab_header TYPE type_report OCCURS 0 WITH HEADER LINE.
DATA : EXP_T02 LIKE ZFI_T_PROTEL02 OCCURS 0 WITH HEADER LINE,
EXP_T02L LIKE ZFI_T_PROTEL02L OCCURS 0 WITH HEADER LINE,
EXP_T03 LIKE ZFI_T_PROTEL03 OCCURS 0 WITH HEADER LINE,
EXP_T03L LIKE ZFI_T_PROTEL03L OCCURS 0 WITH HEADER LINE,
EXP_T05 LIKE ZFI_T_PROTEL05 OCCURS 0 WITH HEADER LINE,
EXP_T05L LIKE ZFI_T_PROTEL04L OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF itab_tax OCCURS 0,
TAXRATE LIKE ZFI_T_PROTEL03-TAXRATE,
END OF itab_tax.
DATA : BEGIN OF itab_INVOICEID OCCURS 0,
INVOICEID LIKE ZFI_T_PROTEL02-INVOICEID,
END OF itab_INVOICEID.
DATA: default_recname TYPE slis_tabname VALUE 'ITAB_TYPE_REPORT',
default_report_name LIKE disvariant-REPORT VALUE 'ZFI_MILTA_FIDELYO_AKTARIM'.
DATA : EXCH_RATE LIKE BAPI1093_0,
RETURNXX LIKE BAPIRET1,
RATE_TYPE LIKE BAPI1093_1-RATE_TYPE,
FROM_CURR LIKE BAPI1093_1-FROM_CURR,
TO_CURRNCY LIKE BAPI1093_1-TO_CURRNCY,
DATE LIKE BAPI1093_2-TRANS_DATE.
DATA : v_gsber LIKE bseg-gsber VALUE '3040'.
PARAMETERS : pvari LIKE disvariant-variant DEFAULT '/VARYANT_SEC'.
SELECTION-SCREEN BEGIN OF BLOCK scr1 WITH FRAME TITLE TEXT-sc1.
PARAMETERS : p_bukrs LIKE t001-bukrs OBLIGATORY DEFAULT '3004',
p_budat1 LIKE bkpf-budat OBLIGATORY.
* p_budat2 like bkpf-budat OBLIGATORY.
SELECTION-SCREEN END OF BLOCK scr1.
SELECTION-SCREEN : PUSHBUTTON 2(30) TEXT-008 USER-COMMAND cli1.
INITIALIZATION.
gs_variant-REPORT = default_report_name.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pvari.
PERFORM lt_f4_for_variants USING pvari.
AT SELECTION-SCREEN.
IF sscrfields-ucomm = 'CLI1'.
PERFORM aciklama_duzenle.
ENDIF.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
DESCRIBE TABLE itab_type_report.
* IF sy-tfill GT 0.
PERFORM comment_build USING gt_list_top_of_page[].
PERFORM set_report_fcat.
PERFORM show_report_fcat TABLES itab_type_report
USING pvari
gs_variant
default_report_name
default_recname.
* ELSE.
* MESSAGE s000(e4) WITH 'Seçim kriterlerine ilişkin veri bulunamadı!'.
* ENDIF.
*---------------------------------------------------------------------*
* FORM get_data *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM get_data.
DATA : v_tarih1 TYPE budat,
v_tarih2 TYPE budat.
DATA : BEGIN OF itab_header OCCURS 0,
INTID LIKE ZFI_T_PROTEL02-INTID,
INVOICEID LIKE ZFI_T_PROTEL02-INVOICEID,
INVOICENO LIKE ZFI_T_PROTEL02-INVOICENO,
END OF itab_header.
DATA : lv_paper_printout(1).
DATA : I_TAX_NUMBER TYPE /FITE/INV_1_DE017.
DATA : I_INV_DATE TYPE SYDATUM.
DATA : I_INV_MODULE TYPE /FITE/INV_1_DE152,
I_INVOICE_NUMBER TYPE /FITE/INV_1_DE246,
E_EINV_PARTN_IND TYPE CHAR1,
P_GJAHR LIKE BKPF-GJAHR.
SELECT SINGLE *
FROM t001
WHERE bukrs = p_bukrs.
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'BUKRS' FIELD t001-bukrs
ID 'ACTVT' FIELD '02'.
IF sy-subrc <> 0.
MESSAGE e899(s1) WITH t001-bukrs ' şirket kodu için yetkiniz yok!'.
ELSE.
ENDIF.
* SELECT SINGLE *
* FROM ZFI_T_PROTEL02
* WHERE INVOICEDATE = p_budat1.
* if sy-subrc <> 0.
v_tarih1 = p_budat1 + 1. "fidelyodan 1 gün önceki veriler gelecek.
**önce eski datalar silinecek.
*
* SELECT *
* INTO CORRESPONDING FIELDS OF TABLE itab_header
* FROM ZFI_T_PROTEL02
* WHERE INVOICEDATE = p_budat1.
*
*
* LOOP AT itab_header.
*
* DELETE FROM ZFI_T_PROTEL03 WHERE INTID = itab_header-INTID
* and INVOICEID = itab_header-INVOICEID.
* ENDLOOP.
*
* delete FROM ZFI_T_PROTEL02
* WHERE INVOICEDATE = p_budat1.
*
* COMMIT WORK.
CALL FUNCTION 'ZFI_FM_PROTEL02'
EXPORTING
imp_start_date = v_tarih1
imp_end_date = v_tarih1
imp_iseinvoice = 'X'
TABLES
exp_t02 = exp_t02
exp_t02l = exp_t02l
exp_t03 = exp_t03
exp_t03l = exp_t03l
exp_t05 = exp_t05
exp_t05l = exp_t05l.
* ELSE.
*
* SELECT *
* into CORRESPONDING FIELDS OF TABLE exp_t02
* from ZFI_T_PROTEL02
* where INVOICEDATE = p_budat1.
*
*
* SELECT *
* into CORRESPONDING FIELDS OF TABLE exp_t03
* from ZFI_T_PROTEL03
* FOR ALL ENTRIES IN exp_t02
* WHERE invoiceid = exp_t02-invoiceid.
*
* ENDIF.
DATA : V_KALEM LIKE ZFI_T_PROTEL03-INVOICELINEID,
v_fark TYPE wrbtr,
v_fark_abs TYPE wrbtr,
v_TAXAMOUNT TYPE wrbtr.
*Sipariş toplam tutarları ve vergi toplam tutarları düzenleniyor...
LOOP AT exp_t02.
MOVE-CORRESPONDING exp_t02 TO itab_type_report.
itab_type_report-invoicedate = p_budat1. "23.04.2015 fideilo dan bazen fatura tarihi boş geliyordu. Otel çıkış tarihi mutlaka fatura tarihi imiş...
itab_type_report-matbu = exp_t02-MANUALINVOICENO.
REFRESH : itab_tax.
LOOP AT exp_t03 WHERE invoiceid = exp_t02-invoiceid
AND TRANSACTIONTYPE = 'Sale'.
MOVE-CORRESPONDING exp_t03 TO itab_type_report.
*Begin ; Portal plus KDV leri birden çok satırlı faturada toplatarak getiriyor.
*Hatalı getirilen kdvler tespit edilip doğrusu manuel hesaplatılıyor.
v_taxamount = ( itab_type_report-UNITPRICE * itab_type_report-taxrate ) / 100.
v_fark = itab_type_report-TAXAMOUNT - v_taxamount.
v_fark_abs = ABS( v_fark ).
IF v_fark > '0.1'.
itab_type_report-TAXAMOUNT = v_taxamount.
ENDIF.
*End ; Portal plus KDV leri birden çok satırlı faturada toplatarak getiriyor.
itab_type_report-AMOUNT = itab_type_report-TAXAMOUNT + itab_type_report-UNITPRICE.
COLLECT itab_type_report.
MOVE-CORRESPONDING itab_type_report TO itab_tax.
COLLECT itab_tax.
ENDLOOP.
DESCRIBE TABLE itab_tax.
IF sy-tfill > 1.
*Birden fazla vergi olan faturalarda ödemelerin yazılacağı satır belirleniyor.
LOOP AT itab_type_report WHERE invoiceid = exp_t02-invoiceid
AND TAXRATE <> ''.
CLEAR : itab_type_report-TAXRATE.
itab_type_report-toplam_hesapla = 'X'.
COLLECT itab_type_report.
ENDLOOP.
ELSE.
*Bir adet vergi olan faturlarda ödeme
LOOP AT itab_type_report WHERE invoiceid = exp_t02-invoiceid
AND toplam_hesapla = ''.
itab_type_report-toplam_hesapla = 'X'.
MODIFY itab_type_report.
ENDLOOP.
ENDIF.
ENDLOOP.
REFRESH itab_INVOICEID.
*Fatura no ve vergi oranına göre sıralanıyor.
LOOP AT itab_type_report.
itab_type_report-taxrate_value = itab_type_report-taxrate.
MODIFY itab_type_report.
IF itab_type_report-taxrate = ''.
itab_INVOICEID-INVOICEID = itab_type_report-invoiceid.
COLLECT itab_INVOICEID.
ENDIF.
ENDLOOP.
*Ödemelerin bir tek satıra yazılması için buna gerek duyuldu.
LOOP AT itab_INVOICEID.
LOOP AT itab_type_report WHERE invoiceid = itab_INVOICEID-invoiceid
AND taxrate <> ''.
itab_type_report-toplam_Hesapla = ''.
MODIFY itab_type_report.
ENDLOOP.
ENDLOOP.
*Faturalara ilişkin ödeme bilgileri yazılıyor.
LOOP AT itab_type_report WHERE toplam_hesapla = 'X'.
CLEAR : itab_type_report-CARI_HESAP_TUTAR,
itab_type_report-KREDI_KART_TUTAR,
itab_type_report-PESIN_TUTAR.
LOOP AT exp_t03 WHERE invoiceid = itab_type_report-invoiceid
AND TRANSACTIONTYPE = 'Payment'.
IF exp_t03-NAME = 'City Ledger'. "Cari Hesap
itab_type_report-CARI_HESAP_TUTAR = itab_type_report-CARI_HESAP_TUTAR + exp_t03-AMOUNT.
ELSEIF exp_t03-NAME = 'Visa' OR exp_t03-NAME = 'Master Card' OR exp_t03-NAME = 'Amex'. "Kredi kartı
itab_type_report-KREDI_KART_TUTAR = itab_type_report-KREDI_KART_TUTAR + exp_t03-AMOUNT.
ELSEIF exp_t03-NAME = 'Cash'. "Peşin
itab_type_report-PESIN_TUTAR = itab_type_report-PESIN_TUTAR + exp_t03-AMOUNT.
ENDIF.
MODIFY itab_type_report.
ENDLOOP.
ENDLOOP.
*KDV satırlarında kullanılacak vergi hespaları ve müşteri karşı bacağında kullanılacak hesap kodları yazılıyor...
LOOP AT itab_type_report WHERE taxrate <> ''
AND invoiceid <> 'Z'.
itab_type_report-ktosl = 'MWS'.
IF itab_type_report-taxrate = '8'.
itab_type_report-HKONT_ANAHESAP = '1819099401'.
itab_type_report-HKONT_KDVHESAP = '3910001008'.
itab_type_report-MWSKZ = 'AC'.
ELSEIF itab_type_report-taxrate = '18'.
itab_type_report-HKONT_ANAHESAP = '1819099402'.
itab_type_report-HKONT_KDVHESAP = '3910001018'.
itab_type_report-MWSKZ = 'A2'.
ENDIF.
MODIFY itab_type_report.
ENDLOOP.
DATA: lt_exp_parts TYPE zfi_protel_pars OCCURS 0 WITH HEADER LINE.
DATA: lv_imp_date TYPE zfi_start_date.
DATA: lv_imp_invoiceid TYPE zfi_invoiceintid.
DATA: lv_text TYPE string.
LOOP AT itab_type_report.
CLEAR : zfi_t_protel07.
*SAP de ilgili faturalara atılan kayıtlar bulunuyor..
SELECT SINGLE *
FROM zfi_t_protel07
WHERE INVOICEID = itab_type_report-invoiceid.
IF sy-subrc = 0.
itab_type_report-BUKRS = zfi_t_protel07-BUKRS.
itab_type_report-GJAHR = zfi_t_protel07-GJAHR.
itab_type_report-belnr_cari = zfi_t_protel07-belnr_cari.
itab_type_report-belnr_kart = zfi_t_protel07-belnr_kart.
itab_type_report-belnr_pesin = zfi_t_protel07-belnr_pesin.
itab_type_report-ters = 'Ters kayıt'.
ENDIF.
CLEAR zfi_t_protel13.
SELECT SINGLE *
FROM zfi_t_protel13
WHERE INVOICEID = itab_type_report-invoiceid.
IF sy-subrc = 0.
itab_type_report-customerno = zfi_t_protel13-KUNNR.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = itab_type_report-customerno
IMPORTING
OUTPUT = itab_type_report-kunnr.
CLEAR : itab_type_report-STCD2.
SELECT SINGLE stcd2 name1
INTO (itab_type_report-STCD2, itab_type_report-name1)
FROM kna1
WHERE kunnr = itab_type_report-kunnr.
*E fatura mükellefleri bulunuyor...
I_INV_DATE = p_budat1. "itab_type_report-INVOICEDATE.23.04.2015 msirli otelden çıkılan tarih mutlaka fatura tarihidir.
I_INV_MODULE = 'FI'.
P_GJAHR = I_INV_DATE+0(4).
I_INVOICE_NUMBER = itab_type_report-BELNR_CARI.
I_TAX_NUMBER = itab_type_report-STCD2.
CALL FUNCTION '/FITE/INV_1_F023'
EXPORTING
i_tax_number = I_TAX_NUMBER
i_inv_date = I_INV_DATE
I_BUKRS = P_bukrs
I_INVOICE_NUMBER = I_INVOICE_NUMBER
I_GJAHR = P_gjahr
I_INV_MODULE = I_INV_MODULE
IMPORTING
E_PAPER_PRINTOUT = lv_paper_printout
E_EINV_PARTN_IND = E_EINV_PARTN_IND.
IF E_EINV_PARTN_IND = 'X'.
itab_type_report-EFAT = 'X'.
ENDIF.
"24.04.2015 msirli açıklamaların yukarıdaki şekilde gelmesi istendi...
"Döviz tutarlar bulunuyor.
CLEAR: lv_text.
REFRESH lt_exp_parts.
lv_imp_date = itab_type_report-invoicedate.
lv_imp_invoiceid = itab_type_report-invoiceid.
CALL FUNCTION 'ZFI_FM_PROTEL03'
EXPORTING
imp_date = lv_imp_date
imp_invoiceid = lv_imp_invoiceid
IMPORTING
exp_error_text = lv_text
TABLES
exp_parts = lt_exp_parts[].
IF lv_text EQ 'İşlem başarılı.'.
LOOP AT lt_exp_parts WHERE FIELD = 'USDTOTAL' AND VALUE > 0
OR FIELD = 'EURTOTAL' AND VALUE > 0
OR FIELD = 'GBPTOTAL' AND VALUE > 0.
itab_type_report-DVZ_AMOUNT = lt_exp_parts-VALUE.
itab_type_report-WAERS = lt_exp_parts-FIELD+0(3).
ENDLOOP.
ENDIF.
"24.04.2015 msirli açıklamaların aşağıdaki şekilde gelmesi istendi...
"e fatura ise VCH KODU - KONAKLAMA BEDELİ
"kağıt fatura ise MATBU NO ftr. ÖDEME TİPİ(KK, PŞ yada CH) TUTAR PARA BİRİMİ (Dövizli ise) CARİ ADI
IF itab_type_report-EFAT = 'X'.
CONCATENATE itab_type_report-extra6 ' ' 'KONAKLAMA BEDELI' INTO itab_type_report-SGTXT.
ELSE.
DATA : v_tutar TYPE char20,
v_odmtip TYPE char2.
IF itab_type_report-DVZ_AMOUNT > 0.
WRITE itab_type_report-DVZ_AMOUNT TO v_tutar CURRENCY itab_type_report-WAERS.
ELSE.
WRITE itab_type_report-AMOUNT TO v_tutar CURRENCY itab_type_report-CURRENCYCODE.
ENDIF.
CONDENSE v_tutar NO-GAPS.
* IF itab_type_report-CARI_HESAP_TUTAR > 0.
* v_odmtip = 'CH'.
* ELSEIF itab_type_report-KREDI_KART_TUTAR > 0.
* v_odmtip = 'KK'.
* ELSEIF itab_type_report-PESIN_TUTAR > 0.
* v_odmtip = 'PŞ'.
* ENDIF.
IF itab_type_report-DVZ_AMOUNT > 0.
CONCATENATE itab_type_report-MATBU 'nl.ftr.' itab_type_report-extra6 v_tutar itab_type_report-WAERS itab_type_report-CUSTOMERNAME
INTO itab_type_report-sgtxt SEPARATED BY space.
ELSE.
CONCATENATE itab_type_report-MATBU 'nl.ftr.' itab_type_report-extra6 itab_type_report-CUSTOMERNAME
INTO itab_type_report-sgtxt SEPARATED BY space.
ENDIF.
ENDIF.
*Manuel girilen fatura matbu numaraları bulunuyor...
CLEAR zfi_t_protel08.
SELECT SINGLE *
FROM zfi_t_protel08
WHERE INVOICEID = itab_type_report-invoiceid.
IF sy-subrc = 0.
itab_type_report-SGTXT = zfi_t_protel08-SGTXT.
itab_type_report-DVZ_AMOUNT = zfi_t_protel08-DVZ_AMOUNT.
itab_type_report-WAERS = zfi_t_protel08-WAERS.
itab_type_report-MATBU = zfi_t_protel08-MATBU.
PERFORM doviz_tutar_hesapla.
ENDIF.
itab_type_report-EXTRA3 = itab_type_report-EXTRA3+0(10).
itab_type_report-EXTRA4 = itab_type_report-EXTRA4+0(10).
*Müşterinin giriş tarihindeki kur değeri yazılıyor.
CONCATENATE itab_type_report-EXTRA3+6(4) itab_type_report-EXTRA3+4(2) itab_type_report-EXTRA3+0(2) INTO DATE.
CLEAR : EXCH_RATE.
RATE_TYPE = 'M'.
FROM_CURR = itab_type_report-waers.
TO_CURRNCY = 'TRY'.
CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL'
EXPORTING
rate_type = RATE_TYPE
from_curr = FROM_CURR
to_currncy = TO_CURRNCY
DATE = DATE
IMPORTING
EXCH_RATE = EXCH_RATE
RETURN = RETURNXX.
itab_type_report-KURRF = EXCH_RATE-EXCH_RATE.
*Bazen cari hesap olan müşteriler kredi kartı ile ödeme yapabiliyor bakiyelerde kredi kartına atılıyor.
*Bu durumda tutarın cari hesaba gitmesi istendi.
*10.07.2014
IF itab_type_report-SYSTEMREFERENCE <> ''.
SELECT SINGLE *
FROM ZFI_T_PROTEL06
WHERE KUNNR = itab_type_report-KUNNR.
IF sy-subrc <> 0 AND itab_type_report-KUNNR <> ''.
IF itab_type_report-KREDI_KART_TUTAR > 0.
itab_type_report-CARI_HESAP_TUTAR = itab_type_report-KREDI_KART_TUTAR.
itab_type_report-DVZ_CARI_HESAP_TUTAR = itab_type_report-DVZ_KREDI_KART_TUTAR.
CLEAR : itab_type_report-KREDI_KART_TUTAR,
itab_type_report-DVZ_KREDI_KART_TUTAR.
ELSEIF itab_type_report-PESIN_TUTAR > 0.
itab_type_report-CARI_HESAP_TUTAR = itab_type_report-PESIN_TUTAR.
itab_type_report-DVZ_CARI_HESAP_TUTAR = itab_type_report-DVZ_PESIN_TUTAR.
CLEAR : itab_type_report-PESIN_TUTAR,
itab_type_report-DVZ_PESIN_TUTAR.
ENDIF.
ENDIF.
ENDIF.
MODIFY itab_type_report.
ENDLOOP.
LOOP AT itab_type_report WHERE toplam_hesapla = 'X'.
CLEAR : itab_type_report-toplam_hesapla,
itab_type_report-INVOICEID,
itab_type_report-SYSTEMREFERENCE,
itab_type_report-CUSTOMERID,
itab_type_report-EXTRA1,
itab_type_report-CUSTOMERNAME,
itab_type_report-TAXRATE,
itab_type_report-taxrate_value,
itab_type_report-BELNR_PESIN,
itab_type_report-BELNR_CARI,
itab_type_report-BELNR_KART,
itab_type_report-CUSTOMERTAXOFFICE,
itab_type_report-CUSTOMERTAXNO,
itab_type_report-CUSTOMERSTREETNAME,
itab_type_report-CUSTOMERCITYNAME,
itab_type_report-CUSTOMERNO,
itab_type_report-HKONT_ANAHESAP,
itab_type_report-HKONT_KDVHESAP,
itab_type_report-MWSKZ,
itab_type_report-sgtxt,
itab_type_report-EFAT,
itab_type_report-STCD2,
itab_type_report-KUNNR,
itab_type_report-name1,
itab_type_report-KTOSL,
itab_type_report-DVZ_AMOUNT,
itab_type_report-DVZ_TAXAMOUNT,
itab_type_report-DVZ_UNITPRICE,
itab_type_report-DVZ_PESIN_TUTAR,
itab_type_report-DVZ_CARI_HESAP_TUTAR,
itab_type_report-DVZ_KREDI_KART_TUTAR,
itab_type_report-WAERS,
itab_type_report-EXTRA3,
itab_type_report-EXTRA4,
itab_type_report-EXTRA5,
itab_type_report-EXTRA6,
itab_type_report-matbu,
itab_type_report-KURRF,
itab_type_report-invoicedate.
itab_type_report-INVOICEID = 'Z'.
itab_type_report-SYSTEMREFERENCE = ''.
itab_type_report-CUSTOMERID = ''.
itab_type_report-CUSTOMERNAME = 'GÜNLÜK TOPLAM :'.
itab_type_report-EXTRA1 = ''.
COLLECT itab_type_report.
ENDLOOP.
**--> MURATY 15.04.2015 13:14:06
* DATA: lt_exp_parts TYPE zfi_protel_pars OCCURS 0 WITH HEADER LINE.
* DATA: lv_imp_date TYPE zfi_start_date.
* DATA: lv_imp_invoiceid TYPE zfi_invoiceintid.
* DATA: lv_text TYPE string.
*
* LOOP AT itab_type_report WHERE invoiceid NE 'Z'.
* CLEAR: lv_text.
* REFRESH lt_exp_parts.
*
* lv_imp_date = itab_type_report-invoicedate.
* lv_imp_invoiceid = itab_type_report-invoiceid.
*
* CALL FUNCTION 'ZFI_FM_PROTEL03'
* EXPORTING
* imp_date = lv_imp_date
* imp_invoiceid = lv_imp_invoiceid
* IMPORTING
* exp_error_text = lv_text
* TABLES
* exp_parts = lt_exp_parts[].
*
* IF lv_text EQ 'İşlem başarılı.'.
*
* LOOP AT lt_exp_parts WHERE FIELD = 'USDTOTAL' AND VALUE > 0
* OR FIELD = 'EURTOTAL' AND VALUE > 0
* OR FIELD = 'GBPTOTAL' AND VALUE > 0.
*
* itab_type_report-DVZ_AMOUNT = lt_exp_parts-VALUE.
*
* itab_type_report-WAERS = lt_exp_parts-FIELD+0(3).
*
* ENDLOOP.
*
* PERFORM doviz_tutar_hesapla.
*
*
*
*
*
*
*
*
* MODIFY itab_type_report.
* ENDIF.
*
* ENDLOOP.
*<-- 13:14:06="" 15.04.2015="" muraty="" p="">
SORT itab_type_report BY invoiceid taxrate_value ASCENDING.
ENDFORM. "get_data
*&---------------------------------------------------------------------*
*& Form set_fcat_user_exit
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITNAME text
* -->P_SGRP text
*----------------------------------------------------------------------*
FORM set_fcat_user_exit USING p_itname
p_sgrp.
DATA : it_fcat_wa TYPE slis_fieldcat_alv.
LOOP AT lt_t_fieldcatalog INTO it_fcat_wa.
it_fcat_wa-seltext_s = it_fcat_wa-reptext_ddic.
it_fcat_wa-seltext_m = it_fcat_wa-reptext_ddic.
it_fcat_wa-seltext_l = it_fcat_wa-reptext_ddic.
***Your field catalog fields selections...
IF it_fcat_wa-tabname EQ 'ITAB_TYPE_REPORT'.
IF it_fcat_wa-fieldname EQ 'AMOUNT' OR
it_fcat_wa-fieldname EQ 'TAXAMOUNT' OR
it_fcat_wa-fieldname EQ 'UNITPRICE' OR
it_fcat_wa-fieldname EQ 'PESIN_TUTAR' OR
it_fcat_wa-fieldname EQ 'CARI_HESAP_TUTAR' OR
it_fcat_wa-fieldname EQ 'KREDI_KART_TUTAR' OR
it_fcat_wa-fieldname EQ 'DVZ_AMOUNT' OR
it_fcat_wa-fieldname EQ 'DVZ_TAXAMOUNT' OR
it_fcat_wa-fieldname EQ 'DVZ_UNITPRICE' OR
it_fcat_wa-fieldname EQ 'DVZ_PESIN_TUTAR' OR
it_fcat_wa-fieldname EQ 'DVZ_CARI_HESAP_TUTAR' OR
it_fcat_wa-fieldname EQ 'DVZ_KREDI_KART_TUTAR'.
it_fcat_wa-NO_ZERO = 'X'.
it_fcat_wa-no_sum = 'X'.
CLEAR it_fcat_wa-do_sum.
ELSEIF it_fcat_wa-fieldname EQ 'BELNR_PESIN' OR
it_fcat_wa-fieldname EQ 'BELNR_CARI' OR
it_fcat_wa-fieldname EQ 'BELNR_KART' OR
it_fcat_wa-fieldname EQ 'TERS'.
it_fcat_wa-HOTSPOT = 'X'.
ELSEIF it_fcat_wa-fieldname EQ 'EFAT'.
it_fcat_wa-CHECKBOX = 'X'.
* clear it_fcat_wa-do_sum.
* elseif it_fcat_wa-fieldname eq ' '.
* it_fcat_wa-hotspot = 'X'.
* elseif it_fcat_wa-fieldname eq ' '.
* it_fcat_wa-hotspot = 'X'.
* elseif it_fcat_wa-fieldname eq ' '.
* it_fcat_wa-hotspot = 'X'.
ENDIF.
IF it_fcat_wa-fieldname EQ 'SGTXT' OR
it_fcat_wa-fieldname EQ 'WAERS' OR
it_fcat_wa-fieldname EQ 'DVZ_AMOUNT' or
it_fcat_wa-fieldname EQ 'MATBU' OR
it_fcat_wa-fieldname EQ 'KUNNR'.
it_fcat_wa-EDIT = 'X'.
ENDIF.
ENDIF.
MODIFY lt_t_fieldcatalog FROM it_fcat_wa.
ENDLOOP.
ENDFORM. " set_fcat_user_exit
*&---------------------------------------------------------------------*
*& Form set_layout_user_exit
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PVARI text
* -->P_DRNAME text
*----------------------------------------------------------------------*
FORM set_layout_user_exit USING p_pvari
p_drname.
gs_layout-get_selinfos = 'X'.
* gs_layout-coltab_fieldname = 'COLOR'.
gs_layout-box_fieldname = 'CHK'.
gs_layout-box_tabname = 'ITAB_TYPE_REPORT'.
gs_layout-no_subtotals = 'X'.
* gs_layout-zebra = 'X'.
gs_layout-colwidth_optimize = 'X'.
ENDFORM. " set_layout_user_exit
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM set_top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = gt_list_top_of_page.
ENDFORM. "set_top_of_page
*---------------------------------------------------------------------*
* FORM COMMENT_BUILD *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> LT_TOP_OF_PAGE *
*---------------------------------------------------------------------*
FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
DATA: tarh(10) TYPE C,
saat(8) TYPE C,
trh1(10),
trh2(10),
sdatum TYPE sy-datum,
suzeit TYPE sy-uzeit.
sdatum = p_budat1.
suzeit = sy-uzeit.
WRITE : sdatum TO tarh DD/MM/YYYY.
WRITE : suzeit TO saat USING EDIT MASK '__:__:__'.
* LIST HEADING LINE: TYPE H
CLEAR ls_line.
ls_line-typ = 'H'.
* LS_LINE-KEY: NOT USED FOR THIS TYPE
ls_line-info = sy-TITLE.
APPEND ls_line TO lt_top_of_page.
* STATUS LINE: TYPE S
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-KEY = 'Şirket :' .
SELECT SINGLE *
FROM t001
WHERE bukrs = p_bukrs.
CONCATENATE p_bukrs '-' t001-butxt INTO ls_line-info SEPARATED BY space.
APPEND ls_line TO lt_top_of_page.
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-KEY = 'Seçilen tarih :'.
ls_line-info = tarh.
APPEND ls_line TO lt_top_of_page.
* ACTION LINE: TYPE A
* clear ls_line.
* ls_line-typ = 'A'.
* LS_LINE-KEY: NOT USED FOR THIS TYPE
* ls_line-info = text-105.
* append ls_line to lt_top_of_page.
ENDFORM. "comment_build
*---------------------------------------------------------------------*
* FORM f01_user_command
*---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM set_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
gs_selfield = rs_selfield.
IF NOT gs_selfield-fieldname IS INITIAL.
CLEAR itab_type_report.
READ TABLE itab_type_report INDEX gs_selfield-tabindex.
ENDIF.
CASE r_ucomm.
WHEN '&IC1'. PERFORM GET_BELNR.
WHEN '&DATA_SAVE'. PERFORM DATA_SAVE.
WHEN '&BLG'. PERFORM BELGE_YARAT.
WHEN '&EFAT'. PERFORM efatura.
WHEN '&ONY'. PERFORM ONAY.
WHEN '&DATA_MSIL'. PERFORM MUSTERI_KODU_SIL.
WHEN '&DATA_ASIL'. PERFORM TUTAR_ACIKLAMA_SIL.
ENDCASE.
gs_selfield-REFRESH = 'X'.
gs_selfield-row_stable = 'X'.
gs_selfield-col_stable = 'X'.
rs_selfield = gs_selfield.
ENDFORM. "f01_user_command
*---------------------------------------------------------------------*
* FORM f01_set_status
*---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM set_pf_status_set USING rt_extab TYPE slis_t_extab.
PERFORM set_excluding_tab TABLES rt_extab.
SET PF-STATUS 'STANDARD' EXCLUDING rt_extab[].
ENDFORM. "f01_set_status
*&---------------------------------------------------------------------*
*& Form excluding_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM excluding_events.
PERFORM exclude_events TABLES ex_events USING 'CALLER_EXIT'.
* perform exclude_events tables ex_events using 'USER_COMMAND'.
* perform exclude_events tables ex_events using 'TOP_OF_PAGE'.
PERFORM exclude_events TABLES ex_events USING 'TOP_OF_COVERPAGE'.
PERFORM exclude_events TABLES ex_events USING 'END_OF_COVERPAGE'.
PERFORM exclude_events TABLES ex_events USING 'FOREIGN_TOP_OF_PAGE'.
PERFORM exclude_events TABLES ex_events USING 'FOREIGN_END_OF_PAGE'.
* perform exclude_events tables ex_events using 'PF_STATUS_SET'.
PERFORM exclude_events TABLES ex_events USING 'LIST_MODIFY'.
PERFORM exclude_events TABLES ex_events USING 'TOP_OF_LIST'.
PERFORM exclude_events TABLES ex_events USING 'END_OF_PAGE'.
PERFORM exclude_events TABLES ex_events USING 'END_OF_LIST'.
PERFORM exclude_events TABLES ex_events USING 'AFTER_LINE_OUTPUT'.
PERFORM exclude_events TABLES ex_events USING 'BEFORE_LINE_OUTPUT'.
PERFORM exclude_events TABLES ex_events USING 'REPREP_SEL_MODIFY'.
PERFORM exclude_events TABLES ex_events USING 'SUBTOTAL_TEXT'.
PERFORM exclude_events TABLES ex_events USING 'GROUPLEVEL_CHANGE'.
ENDFORM. " excluding_events
*&---------------------------------------------------------------------*
*& Form set_excluding_tab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_RT_EXTAB text
*----------------------------------------------------------------------*
FORM set_excluding_tab TABLES extab.
REFRESH extab.
extab = '&CRB'. APPEND extab.
extab = '&CRL'. APPEND extab.
extab = '&CRR'. APPEND extab.
extab = '&CRE'. APPEND extab.
extab = '&BS-'. APPEND extab.
extab = '&BS+'. APPEND extab.
extab = '&ABC'. APPEND extab.
extab = '&OMP'. APPEND extab.
extab = '&XPA'. APPEND extab.
extab = '&EB3'. APPEND extab.
extab = '&EB9'. APPEND extab.
extab = '&GRAPH'. APPEND extab.
extab = '&INFO'. APPEND extab.
extab = '&SIMU'. APPEND extab.
extab = '&LFO'. APPEND extab.
extab = '&NFO'. APPEND extab.
*STANDARD GUİ DE OLANLAR * LA KAPATILIR.
* extab = '&UMC'. append extab.
* extab = '%SL' . append extab.
* extab = '&SUM'. append extab.
* extab = '&OL0'. append extab.
* extab = '&OAD'. append extab.
* extab = '&DATA_SAVE'. APPEND extab.
* extab = '&ILT'. append extab.
* extab = '&ETA'. append extab.
* extab = '%PC' . append extab.
* extab = '&ALL'. append extab.
* extab = '&SAL'. append extab.
* extab = '&REFRESH'. append extab.
* extab = '&OUP'. append extab.
* extab = '&ODN'. append extab.
* extab = '&RNT_PREV'. append extab.
* extab = '&VEXCEL'. append extab.
* extab = '&AOW'. append extab.
* extab = '&ILD'. APPEND extab.
* extab = '&XXL'. APPEND extab.
* extab = '&AQW'. APPEND extab.
* extab = '&AVE'. APPEND extab.
*Kullanıcı onay statüsünde yok ise Onay butonunu kaldır.
SELECT SINGLE *
FROM ZFI_T_PROTEL12
WHERE UNAME = SY-UNAME
AND statu = '1'.
IF sy-subrc <> 0.
extab = '&ONY'. APPEND extab.
ENDIF.
*Kullanıcı kayıt atma statüsünde yok ise "kaydet" ve "belge yarat" butonunu kaldır.
SELECT SINGLE *
FROM ZFI_T_PROTEL12
WHERE UNAME = SY-UNAME
AND statu = '0'.
IF sy-subrc <> 0.
* extab = '&DATA_SAVE'. APPEND extab.
extab = '&EFAT'. APPEND extab.
extab = '&BLG'. APPEND extab.
ENDIF.
ENDFORM. " set_excluding_tab
*&---------------------------------------------------------------------*
*& Form set_report_fcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
* tb : table adı
* fn : field adı
* rt : referans table adı
* rf : referans field adı
* in : Alanın IT_REPORT taki adı
* ik : Key alan göstergesi X olabilir
* tm : Medium text
* ps : Position. Fcat te ki sırası
FORM set_report_fcat.
REFRESH it_fcatfies.
PERFORM ato_fcat USING :
'' '' '' '' 'STATAMPEL' '' 'Status' 1,
'ZFI_T_PROTEL02' 'SYSTEMREFERENCE' '' '' 'SYSTEMREFERENCE' '' 'Sys.Ref' 1,
'' '' '' '' 'EFAT' '' 'E-Ftr' 1,
'ZFI_T_PROTEL10' 'SGTXT' '' '' 'SGTXT' '' 'E fatura Açıklama' 1,
'' '' '' '' 'MATBU' '' 'Kağıt Matbu no' 1,
'ZFI_T_PROTEL03' 'AMOUNT' 'ITAB_TYPE_REPORT' 'WAERS' 'DVZ_AMOUNT' '' 'Döviz tutar' 1,
'ZFI_T_PROTEL09' 'WAERS' '' '' 'WAERS' '' 'Döviz PB' 1,
'ZFI_T_PROTEL02' 'EXTRA1' '' '' 'EXTRA1' '' 'Oda no' 1,
'ZFI_T_PROTEL02' 'CUSTOMERNAME' '' '' 'CUSTOMERNAME' '' '' 1,
'ZFI_T_PROTEL03' 'TAXRATE' '' '' 'TAXRATE' '' '' 1,
'ZFI_T_PROTEL03' 'AMOUNT' 'ITAB_TYPE_REPORT' 'CURRENCYCODE' 'AMOUNT' '' '' 1,
'ZFI_T_PROTEL03' 'TAXAMOUNT' 'ITAB_TYPE_REPORT' 'CURRENCYCODE' 'TAXAMOUNT' '' '' 1,
'ZFI_T_PROTEL03' 'UNITPRICE' 'ITAB_TYPE_REPORT' 'CURRENCYCODE' 'UNITPRICE' '' '' 1,
'ZFI_T_PROTEL03' 'AMOUNT' 'ITAB_TYPE_REPORT' 'CURRENCYCODE' 'PESIN_TUTAR' '' 'Peşin' 1,
'ZFI_T_PROTEL03' 'AMOUNT' 'ITAB_TYPE_REPORT' 'CURRENCYCODE' 'CARI_HESAP_TUTAR' '' 'Cari hesap' 1,
'ZFI_T_PROTEL03' 'AMOUNT' 'ITAB_TYPE_REPORT' 'CURRENCYCODE' 'KREDI_KART_TUTAR' '' 'Kredi kartı' 1,
'ZFI_T_PROTEL03' 'CURRENCYCODE' '' '' 'CURRENCYCODE' '' 'UPB' 1,
'BSEG' 'WRBTR' 'ITAB_TYPE_REPORT' 'WAERS' 'DVZ_TAXAMOUNT' '' 'Döviz vergi' 1,
'BSEG' 'WRBTR' 'ITAB_TYPE_REPORT' 'WAERS' 'DVZ_UNITPRICE' '' 'Döviz matrah' 1,
'BSEG' 'WRBTR' 'ITAB_TYPE_REPORT' 'WAERS' 'DVZ_PESIN_TUTAR' '' 'Döviz Peşin' 1,
'BSEG' 'WRBTR' 'ITAB_TYPE_REPORT' 'WAERS' 'DVZ_CARI_HESAP_TUTAR' '' 'Döviz cari hesap' 1,
'BSEG' 'WRBTR' 'ITAB_TYPE_REPORT' 'WAERS' 'DVZ_KREDI_KART_TUTAR' '' 'Döviz kredi kartı' 1,
'KNA1' 'KUNNR' '' '' 'KUNNR' '' 'SAP MştKod' 1,
'KNA1' 'NAME1' '' '' 'NAME1' '' 'SAP MüşAd' 1,
'KNA1' 'CTCD2' '' '' 'STCD2' '' 'MüşVKN' 1,
'BKPF' 'BUKRS' '' '' 'BUKRS' '' '' 1,
'BKPF' 'GJAHR' '' '' 'GJAHR' '' '' 1,
'BKPF' 'BELNR' '' '' 'BELNR_PESIN' '' 'Belge Peşin' 1,
'BKPF' 'BELNR' '' '' 'BELNR_CARI' '' 'Belge Cari' 1,
'BKPF' 'BELNR' '' '' 'BELNR_KART' '' 'Belge K.Kart' 1,
'' '' '' '' 'TERS' '' 'Ters kayıt' 1,
'ZFI_T_PROTEL02' 'EXTRA3' '' '' 'EXTRA3' '' 'Otele giriş trh' 1,
'ZFI_T_PROTEL02' 'EXTRA4' '' '' 'EXTRA4' '' 'Otelden çıkış trh' 1,
'ZFI_T_PROTEL02' 'EXTRA5' '' '' 'EXTRA5' '' 'Rezervasyon kodu' 1,
'ZFI_T_PROTEL02' 'EXTRA6' '' '' 'EXTRA6' '' 'VCH kodu' 1,
'' '' '' '' 'KURRF' '' 'Giriş trh Dvz.Kur' 1.
* 'ZFI_T_PROTEL02' 'MANUALINVOICENO' '' '' 'MANUALINVOICENO' '' 'Matbu no' 1.
ENDFORM. " set_report_fcat
*&---------------------------------------------------------------------*
*& Form set_line_color
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM set_line_color TABLES t_color TYPE kkblo_t_specialcol
USING VALUE(p_color).
REFRESH t_color.
PERFORM set_color USING '' p_color '0' '0' ' '.
APPEND LINES OF COLOR TO t_color.
ENDFORM. " set_line_color
*&---------------------------------------------------------------------*
*& Form set_cell_color
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM set_cell_color TABLES t_color TYPE kkblo_t_specialcol
USING p_field_name
VALUE(p_color).
* REFRESH t_color.
PERFORM set_color USING p_field_name p_color '0' '0' ' '.
APPEND LINES OF COLOR TO t_color.
ENDFORM. " set_line_color
*&---------------------------------------------------------------------*
*& Form exit_caused_by_user_back
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM exit_caused_by_user_back .
ENDFORM. " exit_caused_by_user_back
*&---------------------------------------------------------------------*
*& Form exit_caused_by_user_exit
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM exit_caused_by_user_exit .
ENDFORM. " exit_caused_by_user_exit
*&---------------------------------------------------------------------*
*& Form exit_caused_by_user_cancel
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM exit_caused_by_user_cancel .
ENDFORM. " exit_caused_by_user_cancel
*&---------------------------------------------------------------------*
*& Form set_report_sort
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM set_report_sort .
REFRESH : gt_sort.
DATA : wa_sort TYPE slis_sortinfo_alv.
wa_sort-fieldname = ' '.
wa_sort-tabname = 'ITAB_TYPE_REPORT'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO gt_sort.
ENDFORM. " set_report_sort
*&---------------------------------------------------------------------*
*& Form BELGE_YARAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM belge_yarat .
*Girişler onaylanmış mı kontrol edilir.
SELECT SINGLE *
FROM ZFI_T_PROTEL11
WHERE invoicedate = p_budat1.
IF sy-subrc <> 0.
MESSAGE e119(zfi) WITH p_budat1.
EXIT.
ENDIF.
SELECT SINGLE *
FROM zfi_t_protel12
WHERE uname = sy-uname
AND statu = '0'.
IF sy-subrc <> 0.
MESSAGE 'Belge yaratma işlemi için yetkiniz yok!' TYPE 'E'.
ENDIF.
DATA : v_answer TYPE C,
v_posnr LIKE vbap-posnr.
PERFORM popup_to_confirm USING TEXT-001
CHANGING v_answer.
IF v_answer <> '1'.
EXIT.
ENDIF.
PERFORM bal_log_init.
SELECT SINGLE *
FROM t001
WHERE bukrs = p_bukrs.
REFRESH itab_header.
LOOP AT itab_type_report WHERE toplam_hesapla = 'X'
AND invoiceid <> 'Z'.
MOVE-CORRESPONDING itab_type_report TO itab_header.
APPEND itab_header.
ENDLOOP.
*Genel kontroller yapılıyor...
* LOOP AT itab_header.
*
* IF itab_header-efat = 'X'.
*
* if itab_header-SGTXT = ''.
* MESSAGE 'E faturalarda E FATURA AÇIKLAMA alanı doldurulmalıdır' type 'E'.
* ENDIF.
*
* ELSE.
*
* IF itab_header-MATBU = ''.
* MESSAGE 'Kağıt faturalarda KAĞIT MATBU NO alanı doldurulmalıdır' TYPE 'E'.
* ENDIF.
*
* ENDIF.
*
* ENDLOOP.
LOOP AT itab_header.
IF itab_header-PESIN_TUTAR > 0 AND itab_header-CARI_HESAP_TUTAR = 0 AND itab_header-KREDI_KART_TUTAR = 0 AND itab_header-BELNR_PESIN IS INITIAL.
PERFORM Call_bapi_pesin.
ENDIF.
IF itab_header-KREDI_KART_TUTAR > 0 AND itab_header-CARI_HESAP_TUTAR = 0 AND itab_header-BELNR_KART IS INITIAL.
PERFORM Call_bapi_kredi.
ENDIF.
IF itab_header-CARI_HESAP_TUTAR > 0 AND itab_header-BELNR_CARI IS INITIAL.
PERFORM Call_bapi_cari.
ENDIF.
LOOP AT itab_type_report WHERE invoiceid = itab_header-invoiceid.
itab_type_report-statampel = itab_header-statampel.
itab_type_report-hata = itab_header-hata.
itab_type_report-belnr_cari = itab_header-belnr_cari.
itab_type_report-belnr_kart = itab_header-belnr_kart.
itab_type_report-belnr_pesin = itab_header-belnr_pesin.
itab_type_report-gjahr = itab_header-gjahr.
itab_type_report-bukrs = itab_header-bukrs.
itab_type_report-ters = itab_header-ters.
MODIFY itab_type_report.
ENDLOOP.
ENDLOOP.
PERFORM show_bal_log.
ENDFORM. " belge_yarat.
*&---------------------------------------------------------------------*
*& Form CALL_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_1425 text
*----------------------------------------------------------------------*
FORM call_bapi_cari.
DATA : gv_itemno_acc TYPE posnr_acc.
DATA : v_kunnr LIKE kna1-kunnr.
CLEAR gv_itemno_acc.
PERFORM fill_documentheader.
CLEAR : v_kunnr.
v_kunnr = itab_header-kunnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = v_kunnr
IMPORTING
OUTPUT = v_kunnr.
itab_header-KUNNR = v_kunnr.
SELECT SINGLE *
FROM zfi_t_protel06
WHERE tip = 'ARIZI'
AND KUNNR = itab_header-KUNNR.
IF sy-subrc = 0.
customercpd-name = itab_header-customername.
customercpd-NAME_2 = '.'.
customercpd-NAME_3 = '.' .
customercpd-NAME_4 = '.' .
customercpd-STREET = itab_header-CUSTOMERSTREETNAME.
customercpd-city = itab_header-CUSTOMERCITYNAME.
customercpd-TAX_NO_1 = itab_header-CUSTOMERTAXOFFICE.
customercpd-TAX_NO_2 = itab_header-CUSTOMERTAXNO.
customercpd-COUNTRY = 'TR'.
ENDIF.
*Müşteri satırı tek olacak bu yüzden toplatıyoruz.
gv_itemno_acc = 1.
LOOP AT itab_type_report WHERE invoiceid = itab_header-invoiceid
AND taxrate <> ''.
CLEAR : accountreceivable.
* müşteri
accountreceivable-itemno_acc = gv_itemno_acc.
accountreceivable-CUSTOMER = itab_header-kunnr.
* if itab_header-efat = ''.
* CONCATENATE itab_header-matbu '/' itab_header-customername INTO accountreceivable-item_text SEPARATED BY space.
* ELSE.
CONCATENATE itab_header-SGTXT '' INTO accountreceivable-item_text SEPARATED BY space.
* endif.
accountreceivable-bus_area = v_gsber.
accountreceivable-alloc_nmbr = documentheader-REF_DOC_NO.
accountreceivable-BLINE_DATE = itab_header-invoicedate.
accountreceivable-REF_KEY_1 = itab_header-EXTRA3.
accountreceivable-REF_KEY_2 = itab_header-EXTRA4.
accountreceivable-REF_KEY_3 = itab_header-EXTRA5.
accountreceivable-PAYMT_REF = itab_header-EXTRA5.
COLLECT accountreceivable.
CLEAR accountreceivable.
PERFORM musteri_tutar_doldur USING gv_itemno_acc.
ENDLOOP.
LOOP AT itab_type_report WHERE invoiceid = itab_header-invoiceid
AND taxrate <> ''.
CLEAR : accounttax.
* "kdv hesabı yaz
ADD 1 TO gv_itemno_acc.
PERFORM kdv_tutar_doldur USING gv_itemno_acc.
CLEAR accountgl.
"ana hesabı yaz
ADD 1 TO gv_itemno_acc.
accountgl-itemno_acc = gv_itemno_acc.
accountgl-gl_account = itab_type_report-HKONT_ANAHESAP.
* IF itab_header-efat = ''.
* CONCATENATE itab_header-matbu '/' itab_header-customername INTO accountgl-item_text SEPARATED BY space.
* ELSE.
CONCATENATE itab_header-SGTXT '' INTO accountgl-item_text SEPARATED BY space.
* ENDIF.
accountgl-TAX_CODE = itab_type_report-MWSKZ.
accountgl-bus_area = v_gsber.
accountgl-value_date = documentheader-doc_date.
accountgl-alloc_nmbr = documentheader-REF_DOC_NO.
APPEND accountgl.
CLEAR accountgl.
PERFORM hesap_tutar_doldur USING gv_itemno_acc.
ENDLOOP.
PERFORM BAPI_ACC_DOCUMENT_POST USING 'C' CHANGING itab_header-BELNR_CARI.
ENDFORM. " CALL_BAPI_CARI
*&---------------------------------------------------------------------*
*& Form CALL_BAPI_KREDI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM call_bapi_kredi .
DATA gv_itemno_acc TYPE posnr_acc.
DATA : v_kunnr LIKE kna1-kunnr.
CLEAR gv_itemno_acc.
PERFORM fill_documentheader.
CLEAR : v_kunnr.
SELECT SINGLE *
FROM ZFI_T_PROTEL06
WHERE tip = 'KREDI'.
IF sy-subrc = 0.
v_kunnr = ZFI_T_PROTEL06-KUNNR.
ELSE.
MESSAGE 'ZFI_T_PROTEL06 tablosunda KREDI tipi için cari kodu tanımlanmamış' TYPE 'E'.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = v_kunnr
IMPORTING
OUTPUT = v_kunnr.
gv_itemno_acc = 1.
LOOP AT itab_type_report WHERE invoiceid = itab_header-invoiceid
AND taxrate <> ''.
CLEAR : accountreceivable.
* müşteri
accountreceivable-itemno_acc = gv_itemno_acc.
IF itab_type_report-efat = 'X'.
accountreceivable-CUSTOMER = itab_type_report-kunnr.
ELSE.
accountreceivable-CUSTOMER = v_kunnr.
ENDIF.
* IF itab_header-efat = ''.
* CONCATENATE itab_header-matbu '/' itab_header-customername INTO accountreceivable-item_text SEPARATED BY space.
* ELSE.
CONCATENATE itab_header-SGTXT '' INTO accountreceivable-item_text.
* ENDIF.
accountreceivable-bus_area = v_gsber.
accountreceivable-alloc_nmbr = documentheader-REF_DOC_NO.
accountreceivable-BLINE_DATE = itab_header-invoicedate.
accountreceivable-REF_KEY_1 = itab_header-EXTRA3.
accountreceivable-REF_KEY_2 = itab_header-EXTRA4.
accountreceivable-REF_KEY_3 = itab_header-EXTRA5.
accountreceivable-PAYMT_REF = itab_header-EXTRA5.
COLLECT accountreceivable.
CLEAR accountreceivable.
PERFORM musteri_tutar_doldur USING gv_itemno_acc.
ENDLOOP.
LOOP AT itab_type_report WHERE invoiceid = itab_header-invoiceid
AND taxrate <> ''.
"kdv hesabı yaz
CLEAR : accounttax.
ADD 1 TO gv_itemno_acc.
PERFORM kdv_tutar_doldur USING gv_itemno_acc.
CLEAR accountgl.
"ana hesabı yaz
ADD 1 TO gv_itemno_acc.
accountgl-itemno_acc = gv_itemno_acc.
accountgl-gl_account = itab_type_report-HKONT_ANAHESAP.
* IF itab_header-efat = ''.
* CONCATENATE itab_header-matbu '/' itab_header-customername INTO accountgl-item_text SEPARATED BY space.
* ELSE.
CONCATENATE itab_header-SGTXT '' INTO accountgl-item_text.
* ENDIF.
accountgl-TAX_CODE = itab_type_report-MWSKZ.
accountgl-bus_area = v_gsber.
accountgl-value_date = documentheader-doc_date.
accountgl-alloc_nmbr = documentheader-REF_DOC_NO.
APPEND accountgl.
CLEAR accountgl.
PERFORM hesap_tutar_doldur USING gv_itemno_acc.
ENDLOOP.
PERFORM BAPI_ACC_DOCUMENT_POST USING 'K' CHANGING itab_header-BELNR_KART.
ENDFORM. " CALL_BAPI_KREDI
*&---------------------------------------------------------------------*
*& Form CALL_BAPI_PESIN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM call_bapi_pesin.
DATA gv_itemno_acc TYPE posnr_acc.
DATA : v_kunnr LIKE kna1-kunnr.
CLEAR gv_itemno_acc.
PERFORM fill_documentheader.
CLEAR : v_kunnr.
SELECT SINGLE *
FROM ZFI_T_PROTEL06
WHERE tip = 'PESIN'.
IF sy-subrc = 0.
v_kunnr = ZFI_T_PROTEL06-KUNNR.
ELSE.
MESSAGE 'ZFI_T_PROTEL06 tablosunda PESIN tipi için cari kodu tanımlanmamış' TYPE 'E'.
ENDIF.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = v_kunnr
IMPORTING
OUTPUT = v_kunnr.
gv_itemno_acc = 1.
LOOP AT itab_type_report WHERE invoiceid = itab_header-invoiceid
AND taxrate <> ''.
CLEAR : accountreceivable.
* müşteri
accountreceivable-itemno_acc = gv_itemno_acc.
accountreceivable-CUSTOMER = v_kunnr.
* IF itab_header-efat = ''.
* CONCATENATE itab_header-matbu '/' itab_header-customername INTO accountreceivable-item_text SEPARATED BY space.
* ELSE.
CONCATENATE itab_header-SGTXT '' INTO accountreceivable-item_text.
* ENDIF.
accountreceivable-bus_area = v_gsber.
accountreceivable-alloc_nmbr = documentheader-REF_DOC_NO.
accountreceivable-BLINE_DATE = itab_header-invoicedate.
accountreceivable-REF_KEY_1 = itab_header-EXTRA3.
accountreceivable-REF_KEY_2 = itab_header-EXTRA4.
accountreceivable-REF_KEY_3 = itab_header-EXTRA5.
accountreceivable-PAYMT_REF = itab_header-EXTRA5.
COLLECT accountreceivable.
CLEAR accountreceivable.
PERFORM musteri_tutar_doldur USING gv_itemno_acc.
ENDLOOP.
LOOP AT itab_type_report WHERE invoiceid = itab_header-invoiceid
AND taxrate <> ''.
"kdv hesabı yaz
CLEAR : accounttax.
ADD 1 TO gv_itemno_acc.
PERFORM kdv_tutar_doldur USING gv_itemno_acc.
CLEAR accountgl.
"ana hesabı yaz
ADD 1 TO gv_itemno_acc.
accountgl-itemno_acc = gv_itemno_acc.
accountgl-gl_account = itab_type_report-HKONT_ANAHESAP.
* IF itab_header-efat = ''.
* CONCATENATE itab_header-matbu '/' itab_header-customername INTO accountgl-item_text SEPARATED BY space.
* ELSE.
CONCATENATE itab_header-SGTXT '' INTO accountgl-item_text.
* ENDIF.
accountgl-TAX_CODE = itab_type_report-MWSKZ.
accountgl-bus_area = v_gsber.
accountgl-value_date = documentheader-doc_date.
accountgl-alloc_nmbr = documentheader-REF_DOC_NO.
APPEND accountgl.
CLEAR accountgl.
PERFORM hesap_tutar_doldur USING gv_itemno_acc.
ENDLOOP.
PERFORM BAPI_ACC_DOCUMENT_POST USING 'P' CHANGING itab_header-BELNR_PESIN.
ENDFORM. " CALL_BAPI_PESIN
*&---------------------------------------------------------------------*
*& Form GET_BELNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM get_belnr .
CASE gs_selfield-fieldname.
WHEN 'BELNR_PESIN'.
PERFORM call_transaction_fb03 USING itab_type_report-BELNR_PESIN
itab_type_report-bukrs
itab_type_report-GJAHR.
WHEN 'BELNR_CARI'.
PERFORM call_transaction_fb03 USING itab_type_report-BELNR_CARI
itab_type_report-bukrs
itab_type_report-GJAHR.
WHEN 'BELNR_KART'.
PERFORM call_transaction_fb03 USING itab_type_report-BELNR_KART
itab_type_report-bukrs
itab_type_report-GJAHR.
WHEN 'TERS'.
PERFORM call_transaction_fb09 USING itab_type_report-bukrs
itab_type_report-GJAHR.
ENDCASE.
ENDFORM. " GET_BELNR
FORM call_transaction_fb03 USING p_vbeln p_bukrs p_gjahr.
IF NOT p_vbeln IS INITIAL.
SET PARAMETER ID: 'BLN' FIELD p_vbeln.
SET PARAMETER ID: 'BUK' FIELD p_bukrs.
SET PARAMETER ID: 'GJR' FIELD p_gjahr.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDIF.
ENDFORM. " CALL_TRANSACTION_FB03
*&---------------------------------------------------------------------*
*& Form EFATURA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM efatura .
RANGES : s_belnr FOR bkpf-belnr.
REFRESH : s_belnr.
LOOP AT itab_type_report WHERE EFAT = 'X'.
s_belnr-option = 'EQ'.
s_belnr-SIGN = 'I'.
IF itab_type_report-belnr_cari IS NOT INITIAL.
s_belnr-low = itab_type_report-belnr_cari.
COLLECT s_belnr.
ENDIF.
IF itab_type_report-belnr_kart IS NOT INITIAL.
s_belnr-low = itab_type_report-belnr_kart.
COLLECT s_belnr.
ENDIF.
IF itab_type_report-belnr_pesin IS NOT INITIAL.
s_belnr-low = itab_type_report-belnr_pesin.
COLLECT s_belnr.
ENDIF.
ENDLOOP.
IF s_belnr[] IS NOT INITIAL.
SUBMIT zfi_fi_fatura_ciktilari
WITH p_bukrs = p_bukrs
WITH p_gjahr = p_budat1+0(4)
WITH s_belnr IN s_belnr
AND RETURN.
ENDIF.
ENDFORM. " EFATURA
*&---------------------------------------------------------------------*
*& Form CALL_TRANSACTION_FB09
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITAB_TYPE_REPORT_BUKRS text
* -->P_ITAB_TYPE_REPORT_GJAHR text
*----------------------------------------------------------------------*
FORM call_transaction_fb09 USING p_bukrs
p_gjahr.
DATA : v_answer TYPE C,
v_posnr LIKE vbap-posnr.
PERFORM popup_to_confirm USING TEXT-002
CHANGING v_answer.
IF v_answer <> '1'.
EXIT.
ENDIF.
IF itab_type_report-belnr_cari IS NOT INITIAL.
CALL FUNCTION 'TB_FI_DOCUMENT_REVERSE'
EXPORTING
COMPANYCODE = itab_type_report-bukrs
DOCUMENT = itab_type_report-belnr_cari
YEAR = itab_type_report-gjahr
reason_for_reversal = '01'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
IF sy-subrc = 0.
UPDATE ZFI_T_PROTEL07
SET BELNR_CARI = ''
WHERE invoiceid = itab_type_report-invoiceid.
DATA : V_vbeln LIKE bkpf-belnr.
V_vbeln = itab_type_report-belnr_cari.
LOOP AT itab_type_report WHERE belnr_cari = V_vbeln.
CLEAR : itab_type_report-belnr_cari.
MODIFY itab_type_report.
ENDLOOP.
ENDIF.
ENDIF.
IF itab_type_report-belnr_kart IS NOT INITIAL.
CALL FUNCTION 'TB_FI_DOCUMENT_REVERSE'
EXPORTING
COMPANYCODE = itab_type_report-bukrs
DOCUMENT = itab_type_report-belnr_kart
YEAR = itab_type_report-gjahr
reason_for_reversal = '01'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
IF sy-subrc = 0.
UPDATE ZFI_T_PROTEL07
SET BELNR_kart = ''
WHERE invoiceid = itab_type_report-invoiceid.
v_vbeln = itab_type_report-belnr_kart.
LOOP AT itab_type_report WHERE belnr_kart = V_vbeln.
CLEAR : itab_type_report-belnr_kart.
MODIFY itab_type_report.
ENDLOOP.
ENDIF.
ENDIF.
IF itab_type_report-belnr_pesin IS NOT INITIAL.
CALL FUNCTION 'TB_FI_DOCUMENT_REVERSE'
EXPORTING
COMPANYCODE = itab_type_report-bukrs
DOCUMENT = itab_type_report-belnr_pesin
YEAR = itab_type_report-gjahr
reason_for_reversal = '01'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
IF sy-subrc = 0.
UPDATE ZFI_T_PROTEL07
SET BELNR_PESIN = ''
WHERE invoiceid = itab_type_report-invoiceid.
v_vbeln = itab_type_report-belnr_pesin.
LOOP AT itab_type_report WHERE belnr_pesin = V_vbeln.
CLEAR : itab_type_report-belnr_pesin.
MODIFY itab_type_report.
ENDLOOP.
ENDIF.
ENDIF.
SELECT SINGLE *
FROM ZFI_T_PROTEL07
WHERE invoiceid = itab_type_report-invoiceid
AND BELNR_PESIN = ''
AND BELNR_kart = ''
AND BELNR_CARI = ''.
IF sy-subrc = 0.
DELETE FROM ZFI_T_PROTEL07
WHERE invoiceid = itab_type_report-invoiceid.
DATA : v_invoiceid LIKE ZFI_T_PROTEL07-invoiceid.
v_invoiceid = itab_type_report-invoiceid.
LOOP AT itab_type_report WHERE invoiceid = v_invoiceid.
itab_type_report-TERS = ''.
MODIFY itab_type_report.
ENDLOOP.
ENDIF.
ENDFORM. " CALL_TRANSACTION_FB09
*&---------------------------------------------------------------------*
*& Form BAPI_ACC_DOCUMENT_POST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM bapi_acc_document_post USING P_TIP CHANGING p_belnr.
CLEAR : RETURN, RETURN[].
CLEAR : obj_type,
obj_key,
obj_sys.
IF currencyamount[] IS INITIAL.
EXIT.
ENDIF.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
customercpd = customercpd
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountgl = accountgl
accountreceivable = accountreceivable
accounttax = accounttax
currencyamount = currencyamount
extension1 = extension "se37 -> 'Z_FI_BTE_RWBAPI01'
RETURN = RETURN.
LOOP AT RETURN.
i_s_msg-msgid = RETURN-ID.
i_s_msg-msgno = RETURN-NUMBER.
i_s_msg-msgv1 = RETURN-message_v1.
i_s_msg-msgv2 = RETURN-message_v2.
i_s_msg-msgv3 = RETURN-message_v3.
i_s_msg-msgv4 = RETURN-message_v4.
IF RETURN-TYPE = 'E'.
i_s_msg-probclass = '1'.
ELSE.
i_s_msg-probclass = '4'.
ENDIF.
i_s_msg-msgty = RETURN-TYPE.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_s_msg = i_s_msg
EXCEPTIONS
log_not_found = 0
OTHERS = 1.
ENDLOOP.
LOOP AT RETURN WHERE TYPE = 'E'
OR TYPE = 'A'.
ENDLOOP.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
COMMIT WORK.
p_belnr = obj_key+0(10).
itab_header-bukrs = p_bukrs.
itab_header-gjahr = documentheader-fisc_year.
itab_header-statampel = icon_green_light.
itab_header-ters = 'Ters kayıt'.
SELECT SINGLE *
FROM ZFI_T_PROTEL07
WHERE INVOICEID = itab_header-INVOICEID.
MOVE-CORRESPONDING itab_header TO ZFI_T_PROTEL07.
ZFI_T_PROTEL07-INVOICEID = itab_header-INVOICEID.
ZFI_T_PROTEL07-BUKRS = itab_header-BUKRS.
ZFI_T_PROTEL07-GJAHR = itab_header-GJAHR.
IF p_tip = 'K'.
ZFI_T_PROTEL07-BELNR_KART = p_belnr.
ELSEIF p_tip = 'C'.
ZFI_T_PROTEL07-BELNR_CARI = p_belnr.
ELSEIF P_TIP = 'P'.
ZFI_T_PROTEL07-BELNR_PESIN = p_belnr.
ENDIF.
MODIFY ZFI_T_PROTEL07.
COMMIT WORK.
ELSE.
itab_header-statampel = icon_red_light.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
MODIFY itab_header.
ENDFORM. " BAPI_ACC_DOCUMENT_POST
*&---------------------------------------------------------------------*
*& Form FILL_DOCUMENTHEADER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM fill_documentheader .
REFRESH: accountgl,
accountreceivable,
accounttax,
currencyamount,
extension, "se37 -> 'Z_FI_BTE_RWBAPI01'
RETURN.
CLEAR: documentheader,
accountgl,
accountreceivable,
accounttax,
currencyamount,
extension,
RETURN,
customercpd.
documentheader-bus_act = 'RFBU'.
documentheader-username = sy-uname.
documentheader-comp_code = p_bukrs.
documentheader-doc_type = 'DR'.
"Aktarım tarihi başlıkta yazılacak
documentheader-doc_date = itab_header-invoicedate.
documentheader-pstng_date = documentheader-doc_date.
documentheader-fisc_year = documentheader-pstng_date+0(4).
documentheader-fis_period = documentheader-pstng_date+4(2).
* documentheader-REF_DOC_NO = itab_header-SYSTEMREFERENCE.
documentheader-REF_DOC_NO = itab_header-MATBU.
CONCATENATE itab_header-SYSTEMREFERENCE '-' itab_header-customername INTO documentheader-HEADER_TXT.
ENDFORM. " FILL_DOCUMENTHEADER
*&---------------------------------------------------------------------*
*& Form DATA_SAVE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM data_save .
*Girişler Onaylanmış ise değişiklik yapılamaz
SELECT SINGLE *
FROM zfi_t_protel11
WHERE invoicedate = p_budat1.
IF sy-subrc = 0.
MESSAGE e120(zfi) WITH p_budat1.
EXIT.
ENDIF.
*Kaydetmeye yetkisi var mı? kontrol edilir.
SELECT SINGLE *
FROM zfi_t_protel12
WHERE uname = sy-uname
AND statu = '0'.
IF sy-subrc <> 0.
MESSAGE 'Kaydetme işlemi için yetkiniz yok!' TYPE 'E'.
ENDIF.
LOOP AT itab_type_report.
* Manuel girilen veriler tabloya yazılıyor.
CLEAR ZFI_T_PROTEL08.
CONDENSE ZFI_T_PROTEL08-MATBU NO-GAPS.
FIND itab_type_report-MATBU IN itab_type_report-sgtxt.
IF sy-subrc <> 0.
CONCATENATE itab_type_report-MATBU itab_type_report-sgtxt INTO itab_type_report-sgtxt SEPARATED BY space.
ENDIF.
ZFI_T_PROTEL08-INVOICEID = itab_type_report-invoiceid.
ZFI_T_PROTEL08-SGTXT = itab_type_report-sgtxt.
ZFI_T_PROTEL08-DVZ_AMOUNT = itab_type_report-DVZ_AMOUNT.
ZFI_T_PROTEL08-WAERS = itab_type_report-WAERS.
ZFI_T_PROTEL08-MATBU = itab_type_report-MATBU.
MODIFY ZFI_T_PROTEL08.
COMMIT WORK AND WAIT.
ZFI_T_PROTEL13-INVOICEID = itab_type_report-invoiceid.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = itab_type_report-KUNNR
IMPORTING
OUTPUT = itab_type_report-KUNNR.
ZFI_T_PROTEL13-KUNNR = itab_type_report-KUNNR.
MODIFY ZFI_T_PROTEL13.
COMMIT WORK AND WAIT.
PERFORM doviz_tutar_hesapla.
SELECT SINGLE NAME1
INTO itab_type_report-name1
FROM kna1
WHERE kunnr = itab_type_report-kunnr.
MODIFY ITAB_TYPE_REPORT.
ENDLOOP.
MESSAGE 'Girişler kaydedildi.' TYPE 'S'.
ENDFORM. " DATA_SAVE
*&---------------------------------------------------------------------*
*& Form DOVIZ_TUTAR_HESAPLA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM doviz_tutar_hesapla .
IF itab_type_report-DVZ_AMOUNT = 0.
EXIT.
ENDIF.
DATA : v_temp TYPE wrbtr.
* itab_type_report-DVZ_UNITPRICE = ( ( 100 - itab_type_report-taxrate_value ) / 100 ) * itab_type_report-DVZ_AMOUNT.
*
* itab_type_report-DVZ_TAXAMOUNT = itab_type_report-DVZ_AMOUNT - itab_type_report-DVZ_UNITPRICE.
v_temp = ( itab_type_report-taxrate_value / 100 ) + 1.
itab_type_report-DVZ_UNITPRICE = itab_type_report-DVZ_AMOUNT / v_temp.
itab_type_report-DVZ_TAXAMOUNT = itab_type_report-DVZ_AMOUNT - itab_type_report-DVZ_UNITPRICE.
*ödeme tiplerindeki tutarlar oranlarak gerekli yerlere gerektiği kadar döviz tutarı yazılacak.
IF itab_type_report-PESIN_TUTAR <> 0.
itab_type_report-DVZ_PESIN_TUTAR = ( itab_type_report-PESIN_TUTAR / itab_type_report-AMOUNT ) * itab_type_report-DVZ_AMOUNT.
ENDIF.
IF itab_type_report-CARI_HESAP_TUTAR <> 0.
itab_type_report-DVZ_CARI_HESAP_TUTAR = ( itab_type_report-CARI_HESAP_TUTAR / itab_type_report-AMOUNT ) * itab_type_report-DVZ_AMOUNT.
ENDIF.
IF itab_type_report-KREDI_KART_TUTAR <> 0.
itab_type_report-DVZ_KREDI_KART_TUTAR = ( itab_type_report-KREDI_KART_TUTAR / itab_type_report-AMOUNT ) * itab_type_report-DVZ_AMOUNT.
ENDIF.
ENDFORM. " DOVIZ_TUTAR_HESAPLA
*&---------------------------------------------------------------------*
*& Form MUSTERI_TUTAR_DOLDUR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM musteri_tutar_doldur USING p_item .
IF itab_type_report-waers = ''."Döviz girilmemiş ise...
CLEAR : currencyamount.
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '00'.
currencyamount-CURRENCY = itab_header-currencycode.
currencyamount-amt_doccur = itab_type_report-amount.
COLLECT currencyamount.
CLEAR currencyamount.
ELSE. "Döviz girilmiş ise...
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '00'.
currencyamount-CURRENCY = itab_type_report-waers.
currencyamount-amt_doccur = itab_type_report-dvz_amount.
currencyamount-amt_doccur = currencyamount-amt_doccur.
COLLECT currencyamount.
CLEAR currencyamount.
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '10'.
currencyamount-CURRENCY = itab_type_report-currencycode.
currencyamount-amt_doccur = itab_type_report-amount.
currencyamount-amt_doccur = currencyamount-amt_doccur.
COLLECT currencyamount.
CLEAR currencyamount.
ENDIF.
CLEAR : extension.
extension-field1 = 'ZFI_MILTA_FIDELYO_AKTARIM'.
extension-field2 = p_item.
extension-field3 = 'BSCHL'.
extension-field4 = '01'.
COLLECT extension.
ENDFORM. " MUSTERI_TUTAR_DOLDUR
*&---------------------------------------------------------------------*
*& Form KDV_TUTAR_DOLDUR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_ITEM text
* -->P_CLEAR text
* -->P_ACCOUNTGL text
*----------------------------------------------------------------------*
FORM kdv_tutar_doldur USING p_item.
accounttax-itemno_acc = p_item.
accounttax-acct_key = itab_type_report-ktosl.
accounttax-tax_code = itab_type_report-MWSKZ.
accounttax-gl_account = itab_type_report-HKONT_KDVHESAP.
APPEND accounttax.
IF itab_type_report-waers = ''."Döviz girilmemiş ise...
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '00'.
currencyamount-CURRENCY = itab_type_report-currencycode.
currencyamount-amt_doccur = itab_type_report-TAXAMOUNT.
currencyamount-amt_doccur = currencyamount-amt_doccur * -1.
currencyamount-amt_base = itab_type_report-unitprice * -1.
APPEND currencyamount.
CLEAR currencyamount.
ELSE. "Döviz girilmiş ise...
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '00'.
currencyamount-CURRENCY = itab_type_report-waers.
currencyamount-amt_doccur = itab_type_report-DVZ_TAXAMOUNT.
currencyamount-amt_doccur = currencyamount-amt_doccur * -1.
currencyamount-amt_base = itab_type_report-dvz_unitprice * -1.
APPEND currencyamount.
CLEAR currencyamount.
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '10'.
currencyamount-CURRENCY = itab_type_report-currencycode.
currencyamount-amt_doccur = itab_type_report-TAXAMOUNT.
currencyamount-amt_doccur = currencyamount-amt_doccur * -1.
currencyamount-amt_base = itab_type_report-unitprice * -1.
COLLECT currencyamount.
CLEAR currencyamount.
ENDIF.
extension-field1 = 'ZFI_MILTA_FIDELYO_AKTARIM'.
extension-field2 = p_item.
extension-field3 = 'BSCHL'.
extension-field4 = '50'.
APPEND extension.
CLEAR extension.
extension-field1 = 'ZFI_MILTA_FIDELYO_AKTARIM'.
extension-field2 = p_item.
extension-field3 = 'GSBER'.
extension-field4 = V_GSBER.
APPEND extension.
CLEAR extension.
extension-field1 = 'ZFI_MILTA_FIDELYO_AKTARIM'.
extension-field2 = p_item.
extension-field3 = 'SGTXT'.
* IF itab_header-efat = ''.
* CONCATENATE itab_header-matbu '/' itab_header-customername INTO extension-field4 SEPARATED BY space.
* ELSE.
CONCATENATE itab_header-SGTXT '' INTO extension-field4.
* ENDIF.
APPEND extension.
CLEAR extension.
ENDFORM. " KDV_TUTAR_DOLDUR
*&---------------------------------------------------------------------*
*& Form HESAP_TUTAR_DOLDUR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITEM text
*----------------------------------------------------------------------*
FORM hesap_tutar_doldur USING p_item.
IF itab_type_report-waers = ''."Döviz girilmemiş ise...
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '00'.
currencyamount-CURRENCY = itab_type_report-currencycode.
currencyamount-amt_doccur = itab_type_report-unitprice * -1.
APPEND currencyamount.
CLEAR currencyamount.
ELSE. "Döviz girilmiş ise...
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '00'.
currencyamount-CURRENCY = itab_type_report-waers.
currencyamount-amt_doccur = itab_type_report-dvz_unitprice * -1.
APPEND currencyamount.
CLEAR currencyamount.
currencyamount-itemno_acc = p_item.
currencyamount-curr_type = '10'.
currencyamount-CURRENCY = itab_type_report-currencycode.
currencyamount-amt_doccur = itab_type_report-unitprice * -1.
APPEND currencyamount.
CLEAR currencyamount.
ENDIF.
extension-field1 = 'ZFI_MILTA_FIDELYO_AKTARIM'.
extension-field2 = p_item.
extension-field3 = 'BSCHL'.
extension-field4 = '50'.
APPEND extension.
CLEAR extension.
ENDFORM. " HESAP_TUTAR_DOLDUR
*&---------------------------------------------------------------------*
*& Form ACIKLAMA_DUZENLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM aciklama_duzenle .
DATA: BEGIN OF rangetab OCCURS 1.
INCLUDE STRUCTURE vimsellist.
DATA: END OF rangetab.
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
EXPORTING
action = 'U'
view_name = 'ZFI_T_PROTEL10'
TABLES
dba_sellist = rangetab
EXCEPTIONS
client_reference = 1
foreign_lock = 2
invalid_action = 3
no_clientindependent_auth = 4
no_database_function = 5
no_editor_function = 6
no_show_auth = 7
no_tvdir_entry = 8
no_upd_auth = 9
only_show_allowed = 10
system_failure = 11
unknown_field_in_dba_sellist = 12
view_not_found = 13
maintenance_prohibited = 14
OTHERS = 15
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " ACIKLAMA_DUZENLE
*&---------------------------------------------------------------------*
*& Form ONAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM onay .
*Kullanıcı onay işlemlerine yetkili mi bakılır.
SELECT SINGLE *
FROM ZFI_T_PROTEL12
WHERE UNAME = sy-uname
AND STATU = '1'.
IF sy-subrc <> 0.
MESSAGE 'Programda onay yetkiniz yok!' TYPE 'E'.
EXIT.
ENDIF.
*önceden onay yapılmış ise onayı iptal etmek istiyor olabilir.
SELECT SINGLE *
FROM ZFI_T_PROTEL11
WHERE invoicedate = p_budat1.
IF sy-subrc = 0.
DATA : v_answer TYPE C.
PERFORM popup_to_confirm USING TEXT-003
CHANGING v_answer.
IF v_answer = '1'.
DELETE FROM ZFI_T_PROTEL11
WHERE invoicedate = p_budat1.
COMMIT WORK.
MESSAGE 'Onay iptal Edildi...' TYPE 'S'.
EXIT.
ENDIF.
ELSE.
*Onay yapılmamış ise onaylamak istiyor...
PERFORM popup_to_confirm USING TEXT-004
CHANGING v_answer.
IF v_answer = '1'.
ZFI_T_PROTEL11-invoicedate = p_budat1.
MODIFY ZFI_T_PROTEL11.
COMMIT WORK.
MESSAGE 'Girişler onaylandı!' TYPE 'S'.
EXIT.
ENDIF.
ENDIF.
ENDFORM. " ONAY
*&---------------------------------------------------------------------*
*& Form MUSTERI_KODU_SIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM musteri_kodu_sil .
*Girişler Onaylanmış ise değişiklik yapılamaz
SELECT SINGLE *
FROM zfi_t_protel11
WHERE invoicedate = p_budat1.
IF sy-subrc = 0.
MESSAGE e120(zfi) WITH p_budat1.
EXIT.
ENDIF.
*Kaydetmeye yetkisi var mı? kontrol edilir.
SELECT SINGLE *
FROM zfi_t_protel12
WHERE uname = sy-uname
AND statu = '0'.
IF sy-subrc <> 0.
MESSAGE 'Değişiklik işlemi için yetkiniz yok!' TYPE 'E'.
ENDIF.
LOOP AT itab_type_report.
DELETE FROM ZFI_T_PROTEL13
WHERE INVOICEID = itab_type_report-invoiceid.
CLEAR : itab_type_report-kunnr,
itab_type_report-name1.
MODIFY ITAB_TYPE_REPORT.
ENDLOOP.
COMMIT WORK.
MESSAGE 'Müşteri kodları silindi. Fideliodan almak için Programdan çıkıp tekrar çalıştırınız' TYPE 'S'.
ENDFORM. " MUSTERI_KODU_SIL
*&---------------------------------------------------------------------*
*& Form TUTAR_ACIKLAMA_SIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- nbsp="" p2="" p="" text="">*----------------------------------------------------------------------*
FORM tutar_aciklama_sil .
*Girişler Onaylanmış ise değişiklik yapılamaz
SELECT SINGLE *
FROM zfi_t_protel11
WHERE invoicedate = p_budat1.
IF sy-subrc = 0.
MESSAGE e120(zfi) WITH p_budat1.
EXIT.
ENDIF.
*Kaydetmeye yetkisi var mı? kontrol edilir.
SELECT SINGLE *
FROM zfi_t_protel12
WHERE uname = sy-uname
AND statu = '0'.
IF sy-subrc <> 0.
MESSAGE 'Değişiklik işlemi için yetkiniz yok!' TYPE 'E'.
ENDIF.
LOOP AT itab_type_report.
DELETE FROM ZFI_T_PROTEL08
WHERE INVOICEID = itab_type_report-invoiceid.
CLEAR : itab_type_report-SGTXT,
itab_type_report-MATBU,
itab_type_report-DVZ_AMOUNT,
itab_type_report-WAERS,
itab_type_report-DVZ_AMOUNT,
itab_type_report-DVZ_TAXAMOUNT,
itab_type_report-DVZ_UNITPRICE,
itab_type_report-DVZ_PESIN_TUTAR,
itab_type_report-DVZ_CARI_HESAP_TUTAR,
itab_type_report-DVZ_KREDI_KART_TUTAR.
MODIFY ITAB_TYPE_REPORT.
ENDLOOP.
COMMIT WORK.
MESSAGE 'Açıklama ve Tutar bilgileri silindi. Fideliodan almak için Programdan çıkıp tekrar çalıştırınız' TYPE 'S'.
ENDFORM. " TUTAR_ACIKLAMA_SIL-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->-->
Hiç yorum yok:
Yorum Gönder