*:*****************************************************************************
*: Procedure file: CREA_XML
*:
*: Autor: Milan Barlok
*: Popis: Generovanie xml suboru na prenos do uctovnictva SAP pre NBS Bystrina
*: Datum: 11.12.2006   	Verzia:v1.0
*:
*:*****************************************************************************
PROCEDURE crea_xml
PARAMETERS kontroluj,rokuct,mesuct
PRIVATE old_Century,menoexp,rokuct,mesuct,oldsetdate,oldsetdele, riadkov, sumacelk,dokluzod,dokluzdo,prijemky, vydajky, ok, m.hladajmesiac, m.hladajrok
m.prijemky=.f.
m.vydajky=.f.
DO CASE 
	CASE LOWER(m.gcuct_typ)="sap" AND LOWER(m.gcuct_spec)="nbs"
		m.old_century=SET("century")
		m.oldsetdate=SET("date")
		m.oldsetdele=SET("dele")
		SET DATE TO german
		SET DELETED ON 
		m.gcuexp_path=ALLTRIM(IIF(EMPTY(m.gcuexp_path),m.gcucto_path,m.gcuexp_path))
		IF ! DIRECTORY(m.gcuexp_path)
			MKDIR (m.gcuexp_path)
		ENDIF
		IF ! DIRECTORY(m.gcuexp_path)
			=MESSAGEBOX(jaz("form_nedostupny_adresar")+": "+m.gcuexp_path,16,jaz("form_export_dat"))
			RETURN 
		ENDIF 
		
		SET CENTURY ON
		SELECT datum, id_man, SUM(castka) AS castka, MD,dal,md2,dal2,hs_md, hs_dal,pz,partner,STR(doklad,10,0) as doklad,datum_dokl,poznamka,.f. as storno,.f. as vymaz FROM u_ex_obraty GROUP BY id_man,pz,datum,doklad,datum_dokl,MD,dal INTO TABLE m.gcucto_path+"u_doklady" WHERE INLIST(LEFT(pz,1),"P","V") .and. LOWER(ALLTRIM(md))<>"export"
		DELETE FOR EMPTY(datum)
		SELECT u_doklady
*!*			TRY 
*!*				COPY all to (m.gcuexp_path+"u_doklady.dbf")
*!*				ERASE (m.gcuexp_path+"u_doklady.dbf")
*!*			CATCH
*!*				=MESSAGEBOX("Cesta k SAPu nie je dostupná. Export nemôže pokračovať.",16, "FoodMan")
*!*				USE IN u_doklady
*!*				RETURN
*!*			ENDTRY 
		m.hladajmesiac=m.mesuct
		m.hladajrok=m.rokuct
		SELECT 0
		IF m.issql
			USE (m.sqlprefix+"ruexarchobraty_mesiacrok") ALIAS uexarch IN 0
			=CURSORSETPROP("Buffering", 5, "uexarch")
		ELSE 
			IF FILE(m.gcdat_path+"uexarch.dbf")
				USE (m.gcdat_path+"uexarch.dbf")
			ELSE
				SELECT u_doklady
				COPY STRUCTURE TO (m.gcdat_path+"uexarch.dbf")
				SELECT 0
				USE (m.gcdat_path+"uexarch.dbf")
			ENDIF 
		ENDIF 
		IF m.kontroluj
			SELECT DISTINCT datum FROM u_doklady INTO CURSOR datumy
			SCAN ALL 
				m.oprava=.f.
				SELECT u_doklady
				SCAN FOR datum=datumy.datum
					SELECT uexarch
					LOCATE FOR ALLTRIM(datum)=ALLTRIM(u_doklady.datum) .and. id_man=u_doklady.id_man .and. castka=ROUND(u_doklady.castka,2) .and. ALLTRIM(md)=ALLTRIM(u_doklady.md) .and. ALLTRIM(dal)=ALLTRIM(u_doklady.dal) .and. ALLTRIM(md2)=ALLTRIM(u_doklady.md2) .and. ALLTRIM(dal2)=ALLTRIM(u_doklady.dal2) ;
					.and. ALLTRIM(hs_md)=ALLTRIM(u_doklady.hs_md) .and. ALLTRIM(hs_dal)=ALLTRIM(u_doklady.hs_dal) .and. doklad=VAL(u_doklady.doklad) .and. datum_dokl=u_doklady.datum_dokl &&.and. poznamka=u_doklady.poznamka .and. ALLTRIM(partner)=LEFT(u_doklady.partner, LEN(ALLTRIM(uexarch.partner))) .and. ALLTRIM(pz)=LEFT(u_doklady.pz,LEN(ALLTRIM(uexarch.pz)))
					IF !FOUND()
						m.oprava=.t.
					ENDIF 
					SELECT u_doklady
				ENDSCAN 
				IF m.oprava
					SELECT uexarch
					SCAN FOR datum=datumy.datum
						INSERT INTO u_doklady (datum,id_man,castka,md,dal,md2,dal2,hs_md,hs_dal,pz,partner,doklad,datum_dokl,poznamka,storno);
							VALUES (uexarch.datum,uexarch.id_man,-uexarch.castka,uexarch.md,uexarch.dal,uexarch.md2,uexarch.dal2,uexarch.hs_md,uexarch.hs_dal,uexarch.pz,uexarch.partner,STR(uexarch.doklad),uexarch.datum_dokl,uexarch.poznamka,.t.)
						DELETE 
					ENDSCAN 
				ELSE
					SELECT u_doklady
					DELETE FOR datum=datumy.datum
				ENDIF 
				SELECT datumy
			ENDSCAN 
			IF USED("stred01")
				IF m.issql
					USE (m.sqlprefix+"ruzaverka") AGAIN IN 0 ALIAS expuzav
					SELECT expuzav
					INDEX on rok+mesiac TAG kedy
				ELSE
					USE (m.gcdat_path+"uzaverka") AGAIN IN 0 ALIAS expuzav ORDER kedy
				ENDIF 
				SELECT stred01
				SCAN FOR label
					m.dokluzod=0
					m.dokluzdo=0
					SELECT expuzav
					SET FILTER TO c_stredisk=stred01.c_stredisk
					SCAN FOR (expuzav.rok+expuzav.mesiac)<=(m.rokuct+m.mesuct)
						DO CASE 
							CASE (expuzav.rok+expuzav.mesiac)<(m.rokuct+m.mesuct)
								m.dokluzod=expuzav.c_dokldo
							CASE (expuzav.rok+expuzav.mesiac)=(m.rokuct+m.mesuct)
								m.dokluzdo=expuzav.c_dokldo
						ENDCASE
					ENDSCAN 
					SELECT DISTINCT datum FROM uexarch WHERE id_man=stred01.id .and. VAL(datum)>m.dokluzod .and. VAL(datum)<=m.dokluzdo .and. !(datum in (SELECT DISTINCT datum FROM datumy));
						INTO CURSOR datumy2
					SCAN ALL 
						SELECT uexarch
						SCAN FOR datum=datumy2.datum
							INSERT INTO u_doklady (datum,id_man,castka,md,dal,md2,dal2,hs_md,hs_dal,pz,partner,doklad,datum_dokl,poznamka,storno,vymaz);
								VALUES (uexarch.datum,uexarch.id_man,-uexarch.castka,uexarch.md,uexarch.dal,uexarch.md2,uexarch.dal2,uexarch.hs_md,uexarch.hs_dal,uexarch.pz,uexarch.partner,STR(uexarch.doklad),uexarch.datum_dokl,uexarch.poznamka,.f.,.t.)
							DELETE 								
						ENDSCAN 
						SELECT datumy2
					ENDSCAN 
					USE IN datumy2
					SELECT expuzav
					SET FILTER TO 
					SELECT stred01
				ENDSCAN 
				USE IN expuzav
			ENDIF 
			USE IN datumy
		ELSE
			SELECT 0
			IF m.issql
				USE (m.sqlprefix+"ruzaverka") AGAIN IN 0 ALIAS expuzav
				SELECT expuzav
				INDEX on rok+mesiac TAG kedy
			ELSE
				USE (m.gcdat_path+"uzaverka") AGAIN IN 0 ALIAS expuzav ORDER kedy
			ENDIF 
			SET FILTER TO c_stredisk=m.gic_stredisk
			GO BOTTOM 
			m.rokuct=expuzav.rok
			m.mesuct=expuzav.mesiac
			IF EMPTY(m.rokuct) .or. EMPTY(m.mesuct)
				m.rokuct=STR(YEAR(DATE()),4,0)
				m.mesuct=STRTRAN(STR(MONTH(DATE()),2,0)," ","0")
			ELSE 
				m.mesuct=STRTRAN(STR(VAL(m.mesuct)+1,2,0)," ","0")
				IF m.mesuct="13"
					m.mesuct="01"
					m.rokuct=STR(VAL(m.rokuct)+1,4,0)
				ENDIF 
			ENDIF 
			USE IN expuzav
		ENDIF 
		SELECT u_doklady
		DELETE FOR castka=0
		LOCATE FOR LEFT(pz,1)="P"
		IF FOUND()
			m.prijemky=.t.
		ENDIF 
		GO TOP 
		LOCATE FOR LEFT(pz,1)="V"
		IF FOUND()
			m.vydajky=.t.
		ENDIF 
		DO pozavirej WITH "doklady"
		IF m.issql
			USE (m.sqlprefix+"rdokladyuctexp") IN 0 ALIAS doklady
			SELECT doklady
			=RECCOUNT()
			INDEX on c_dokl TAG c_dokl
			=CURSORSETPROP("Buffering",5,"doklady")
		ELSE 
			USE (m.fn_doklady) ALIAS doklady AGAIN IN 0 ORDER c_dokl
		ENDIF 
		IF m.prijemky
			IF m.issql
				m.menoexp=dajsapcdcislo("",m.rokuct, m.mesuct,"","")
			ELSE
				IF FILE(m.gcdat_path+"sap_cd.dbf")
					SELECT 0
					USE (m.gcdat_path+"sap_cd.dbf")
					IF sap_cd.meno=DTOS(DATE())
						m.menoexp="food_"+ALLTRIM(sap_cd.meno)+"_"+ALLTRIM(STR(sap_cd.pc,10,0))+".xml"
						REPLACE sap_cd.pc WITH sap_cd.pc+1
					ELSE
						m.menoexp="food_"+DTOS(DATE())+".xml"
						REPLACE sap_cd.pc WITH 0, sap_cd.meno WITH DTOS(DATE())
					ENDIF 
				ELSE
					CREATE TABLE (m.gcdat_path+"sap_cd") FREE (meno c(8), pc I, rok c(4), mesiac c(2))
					INSERT INTO sap_cd (meno,pc,rok,mesiac) VALUES (DTOS(DATE()),1,STR(YEAR(DATE()),4,0),STRTRAN(STR(MONTH(DATE()),2,0)," ","0"))
					m.menoexp="food_"+DTOS(DATE())+".xml"
				ENDIF 
				USE IN sap_cd
			ENDIF 			
			SELECT u_doklady
			SET RELATION TO VAL(ALLTRIM(datum)) INTO doklady
			xmlfile = FCREATE(m.gcuexp_path+m.menoexp)	
			IF xmlfile<0
				=MESSAGEBOX(jaz("msg_uct_nevytvor_subor_prenos"),16,"FoodMan")
			ELSE
				=FPUTS(xmlfile, '<?xml version="1.0" encoding="UTF-8"?>')
				=FPUTS(xmlfile, '	<INTERFACE>')
				=FPUTS(xmlfile, '		<HEADER>')
				=FPUTS(xmlfile, '			<APS_ZDROJ_ID>FOOD</APS_ZDROJ_ID>')
				=FPUTS(xmlfile, '			<APS_CIEL_ID>HRO</APS_CIEL_ID>')
			  	=FPUTS(xmlfile, '			<TYP_DOKLADU>prijemka</TYP_DOKLADU>')
				=FPUTS(xmlfile, '			<PERIOD>'+m.mesuct+RIGHT(m.rokuct,2)+'</PERIOD>')
			  	=FPUTS(xmlfile, '			<DATUM_VYST>'+TTOC(doklady.kdy,1)+'</DATUM_VYST>')
				=FPUTS(xmlfile, '		</HEADER>')
				m.riadkov=0
				m.sumacelk=0
				SCAN FOR LOWER(ALLTRIM(md))<>"export" .and. LEFT(pz,1)="P"
					m.riadkov=m.riadkov+2
					m.sumacelk=m.sumacelk+ABS(u_doklady.castka)
					=FPUTS(xmlfile, '		<DOCS>')
					=FPUTS(xmlfile, '			<BUKRS>NBS1</BUKRS>')
					=FPUTS(xmlfile, '			<BELNR>'+ALLTRIM(u_doklady.datum)+'</BELNR>')
					=FPUTS(xmlfile, '			<GJAHR>'+m.rokuct+'</GJAHR>')
					IF m.rokuct>'2021'
						IF LEFT(pz,1)="P"
							=FPUTS(xmlfile, '			<BLART>WD</BLART>')
						ELSE
							=FPUTS(xmlfile, '			<BLART>WB</BLART>')
						ENDIF 
					ELSE
						=FPUTS(xmlfile, '			<BLART>IN</BLART>')
					ENDIF 
					=FPUTS(xmlfile, '			<BLDAT>'+DTOS(u_doklady.datum_dokl)+'</BLDAT>')
					=FPUTS(xmlfile, '			<BUDAT>'+DTOS(u_doklady.datum_dokl)+'</BUDAT>')
					=FPUTS(xmlfile, '			<BKTXT></BKTXT>')
					=FPUTS(xmlfile, '			<WAERS>EUR</WAERS>')
					=FPUTS(xmlfile, '			<ITEMS>')
					=FPUTS(xmlfile, '				<HKONT>'+ALLTRIM(u_doklady.md)+'</HKONT>')
					=FPUTS(xmlfile, '				<WRBTR>'+STRTRAN(ALLTRIM(STR(ABS(u_doklady.castka),17,2)),",",".")+'</WRBTR>')
					=FPUTS(xmlfile, '				<DMBTR>'+STRTRAN(ALLTRIM(STR(ABS(u_doklady.castka),17,2)),",",".")+'</DMBTR>')
					IF u_doklady.castka>=0
						=FPUTS(xmlfile, '				<BSCHL>'+ALLTRIM(u_doklady.md2)+'</BSCHL>')
					ELSE
						=FPUTS(xmlfile, '				<BSCHL>'+ALLTRIM(u_doklady.dal2)+'</BSCHL>')
					ENDIF 
					=FPUTS(xmlfile, '				<KOSTL>'+ALLTRIM(u_doklady.hs_md)+'</KOSTL>')
					=FPUTS(xmlfile, '			</ITEMS>')
					=FPUTS(xmlfile, '			<ITEMS>')
					=FPUTS(xmlfile, '				<HKONT>'+ALLTRIM(u_doklady.dal)+'</HKONT>')
					=FPUTS(xmlfile, '				<WRBTR>'+STRTRAN(ALLTRIM(STR(ABS(u_doklady.castka),17,2)),",",".")+'</WRBTR>')
					=FPUTS(xmlfile, '				<DMBTR>'+STRTRAN(ALLTRIM(STR(ABS(u_doklady.castka),17,2)),",",".")+'</DMBTR>')
					IF u_doklady.castka>=0
						=FPUTS(xmlfile, '				<BSCHL>'+ALLTRIM(u_doklady.dal2)+'</BSCHL>')
					ELSE 
						=FPUTS(xmlfile, '				<BSCHL>'+ALLTRIM(u_doklady.md2)+'</BSCHL>')
					ENDIF 
					=FPUTS(xmlfile, '				<KOSTL>'+ALLTRIM(u_doklady.hs_dal)+'</KOSTL>')
					=FPUTS(xmlfile, '			</ITEMS>')
					=FPUTS(xmlfile, '		</DOCS>')
					REPLACE doklady.uctexport WITH .t.
				ENDSCAN 
				=FPUTS(xmlfile, '		<CHECK>')
				=FPUTS(xmlfile, '			<LINES>'+ALLTRIM(STR(m.riadkov,15,0))+'</LINES>')
				=FPUTS(xmlfile, '			<SUMA>'+STRTRAN(ALLTRIM(STR(m.sumacelk,17,2)),",",".")+'</SUMA>')
				=FPUTS(xmlfile, '		</CHECK>')
				SCAN FOR LOWER(ALLTRIM(md))<>"export" .and. LEFT(pz,1)="P" .and. !storno
					SELECT uexarch
					DELETE FOR datum=u_doklady.datum
					SELECT u_doklady
				ENDSCAN
				SELECT uexarch
				APPEND FROM (m.gcucto_path + "u_doklady") FOR !storno .and. !vymaz .and. LEFT(pz,1)="P"
				IF m.issql
					REPLACE ALL mesiac WITH PADL(ALLTRIM(STR(MONTH(datum_dokl),2,0)),2,"0"), rok WITH STR(YEAR(datum_dokl),4,0)
				ENDIF 
				=FPUTS(xmlfile, '	</INTERFACE>')
				=FCLOSE(xmlfile)
			ENDIF 
		ENDIF 
		IF m.vydajky
			IF m.issql
				m.menoexp=dajsapcdcislo("",m.rokuct, m.mesuct,"","")
			ELSE 
				IF FILE(m.gcdat_path+"sap_cd.dbf")
					SELECT 0
					USE (m.gcdat_path+"sap_cd.dbf")
					IF sap_cd.meno=DTOS(DATE())
						m.menoexp="food_"+ALLTRIM(sap_cd.meno)+"_"+ALLTRIM(STR(sap_cd.pc,10,0))+".xml"
						REPLACE sap_cd.pc WITH sap_cd.pc+1
					ELSE
						m.menoexp="food_"+DTOS(DATE())+".xml"
						REPLACE sap_cd.pc WITH 0, sap_cd.meno WITH DTOS(DATE())
					ENDIF 
				ELSE
					CREATE TABLE (m.gcdat_path+"sap_cd") FREE (meno c(8), pc I, rok c(4), mesiac c(2))
					INSERT INTO sap_cd (meno,pc,rok,mesiac) VALUES (DTOS(DATE()),1,STR(YEAR(DATE()),4,0),STRTRAN(STR(MONTH(DATE()),2,0)," ","0"))
					m.menoexp="food_"+DTOS(DATE())+".xml"
				ENDIF 
				USE IN sap_cd
			ENDIF 			
			SELECT u_doklady
			SET RELATION TO VAL(ALLTRIM(datum)) INTO doklady
			xmlfile = FCREATE(m.gcuexp_path+m.menoexp)	
			IF xmlfile<0
				=MESSAGEBOX(jaz("msg_uct_nevytvor_subor_prenos"),16,"FoodMan")
			ELSE
				=FPUTS(xmlfile, '<?xml version="1.0" encoding="UTF-8"?>')
				=FPUTS(xmlfile, '	<INTERFACE>')
				=FPUTS(xmlfile, '		<HEADER>')
				=FPUTS(xmlfile, '			<APS_ZDROJ_ID>FOOD</APS_ZDROJ_ID>')
				=FPUTS(xmlfile, '			<APS_CIEL_ID>HRO</APS_CIEL_ID>')
			  	=FPUTS(xmlfile, '			<TYP_DOKLADU>vydajka</TYP_DOKLADU>')
				=FPUTS(xmlfile, '			<PERIOD>'+m.mesuct+RIGHT(m.rokuct,2)+'</PERIOD>')
			  	=FPUTS(xmlfile, '			<DATUM_VYST>'+TTOC(doklady.kdy,1)+'</DATUM_VYST>')
				=FPUTS(xmlfile, '		</HEADER>')
				m.riadkov=0
				m.sumacelk=0
				SCAN FOR LOWER(ALLTRIM(md))<>"export" .and. LEFT(pz,1)="V"
					m.riadkov=m.riadkov+2
					m.sumacelk=m.sumacelk+ABS(u_doklady.castka)
					=FPUTS(xmlfile, '		<DOCS>')
					=FPUTS(xmlfile, '			<BUKRS>NBS1</BUKRS>')
					=FPUTS(xmlfile, '			<BELNR>'+ALLTRIM(u_doklady.datum)+'</BELNR>')
					=FPUTS(xmlfile, '			<GJAHR>'+m.rokuct+'</GJAHR>')
					IF m.rokuct>'2021'
						IF LEFT(pz,1)="P"
							=FPUTS(xmlfile, '			<BLART>WD</BLART>')
						ELSE
							=FPUTS(xmlfile, '			<BLART>WB</BLART>')
						ENDIF 
					ELSE
						=FPUTS(xmlfile, '			<BLART>IN</BLART>')
					ENDIF 
					=FPUTS(xmlfile, '			<BLDAT>'+DTOS(u_doklady.datum_dokl)+'</BLDAT>')
					=FPUTS(xmlfile, '			<BUDAT>'+DTOS(u_doklady.datum_dokl)+'</BUDAT>')
					=FPUTS(xmlfile, '			<BKTXT></BKTXT>')
					=FPUTS(xmlfile, '			<WAERS>EUR</WAERS>')
					=FPUTS(xmlfile, '			<ITEMS>')
					=FPUTS(xmlfile, '				<HKONT>'+ALLTRIM(u_doklady.md)+'</HKONT>')
					=FPUTS(xmlfile, '				<WRBTR>'+STRTRAN(ALLTRIM(STR(ABS(u_doklady.castka),17,2)),",",".")+'</WRBTR>')
					=FPUTS(xmlfile, '				<DMBTR>'+STRTRAN(ALLTRIM(STR(ABS(u_doklady.castka),17,2)),",",".")+'</DMBTR>')
					IF u_doklady.castka<=0
						=FPUTS(xmlfile, '				<BSCHL>'+ALLTRIM(u_doklady.md2)+'</BSCHL>')
					ELSE
						=FPUTS(xmlfile, '				<BSCHL>'+ALLTRIM(u_doklady.dal2)+'</BSCHL>')
					ENDIF 
					=FPUTS(xmlfile, '				<KOSTL>'+ALLTRIM(u_doklady.hs_md)+'</KOSTL>')
					=FPUTS(xmlfile, '			</ITEMS>')
					=FPUTS(xmlfile, '			<ITEMS>')
					=FPUTS(xmlfile, '				<HKONT>'+ALLTRIM(u_doklady.dal)+'</HKONT>')
					=FPUTS(xmlfile, '				<WRBTR>'+STRTRAN(ALLTRIM(STR(ABS(u_doklady.castka),17,2)),",",".")+'</WRBTR>')
					=FPUTS(xmlfile, '				<DMBTR>'+STRTRAN(ALLTRIM(STR(ABS(u_doklady.castka),17,2)),",",".")+'</DMBTR>')
					IF u_doklady.castka<=0
						=FPUTS(xmlfile, '				<BSCHL>'+ALLTRIM(u_doklady.dal2)+'</BSCHL>')
					ELSE
						=FPUTS(xmlfile, '				<BSCHL>'+ALLTRIM(u_doklady.md2)+'</BSCHL>')
					ENDIF 
					=FPUTS(xmlfile, '				<KOSTL>'+ALLTRIM(u_doklady.hs_dal)+'</KOSTL>')
					=FPUTS(xmlfile, '			</ITEMS>')
					=FPUTS(xmlfile, '		</DOCS>')
					REPLACE doklady.uctexport WITH .t.
				ENDSCAN 
				=FPUTS(xmlfile, '		<CHECK>')
				=FPUTS(xmlfile, '			<LINES>'+ALLTRIM(STR(m.riadkov,15,0))+'</LINES>')
				=FPUTS(xmlfile, '			<SUMA>'+STRTRAN(ALLTRIM(STR(m.sumacelk,17,2)),",",".")+'</SUMA>')
				=FPUTS(xmlfile, '		</CHECK>')
				SCAN FOR LOWER(ALLTRIM(md))<>"export" .and. LEFT(pz,1)="V" .and. !storno
					SELECT uexarch
					DELETE FOR datum=u_doklady.datum
					SELECT u_doklady
				ENDSCAN
				SELECT uexarch
				APPEND FROM (m.gcucto_path + "u_doklady") FOR !storno .and. !vymaz .and. LEFT(pz,1)="V"
				IF m.issql
					REPLACE ALL mesiac WITH PADL(ALLTRIM(STR(MONTH(datum_dokl),2,0)),2,"0"), rok WITH STR(YEAR(datum_dokl),4,0)
				ENDIF 
				=FPUTS(xmlfile, '	</INTERFACE>')
				=FCLOSE(xmlfile)
			ENDIF 
		ENDIF 
		SET CENTURY &old_century
		SET DATE &oldsetdate
		SET DELETED &oldsetdele
		IF m.issql
			=tux(.t.,.t.,"doklady")
			=tux(.t.,.t.,"uexarch")
		ENDIF 
		DO pozavirej WITH "u_doklady, u_ex_obraty, uexarch, doklady"
		
		IF !m.issql AND f_acc_ex(m.gcdat_path+"uexarch")
			SELECT uexarch
			PACK
			USE
		ENDIF 
ENDCASE 
