* Controllo di Piva e poi di codice fiscale per lieferant:

        vars tempResult
	
	//**New Code ticket 5536073 MaMo 05062023**//
	//no result or more than 1 then we try to search with FiscalCode - MaMo 05062023
	
	//Modificata query con nuovo parametro codfisc in data 06062023
	call api_log_error("No Match for PIVA= :piva found! Let's try with Fiscal Code= :codfis")
	
	DBMS ALIAS num, name
	DBMS SQL select dok_dat_feld_:idFieldNum as num, dok_dat_feld_:idFieldName as name from firmen_spezifisch \
			where kue_dokuart = :+docTypeShort and (dok_dat_feld_:ID_DOC_FIELD_CODFISC = :+codfis or dok_dat_feld_:ID_DOC_FIELD_CODFISC like '%'||:+codfis ) \
				and dok_dat_feld_:navCompanyDBField = :+companyCode \
				and case when (kue_dokuart = :+DOC_TYPE_CLIENT_FOLDER \
							or (kue_dokuart = :+DOC_TYPE_VENDOR_FOLDER and (dok_dat_feld_:ID_DOC_FIELD_BLOCKED is null or dok_dat_feld_:ID_DOC_FIELD_BLOCKED != :+CONSTANT_ALL_BLOCKED))) then 0 else 1 end = 0
	tempResult = @dmrowcount
	DBMS ALIAS
	
	if tempResult == 1
	{
			//num
		dok_dat_feld[:idFieldNum] = num[1]
		call api_log_error("MAMO 1 risultato")
	
		
		
		if(dok_dat_feld[:ID_DOC_FIELD_OUTGOING_DESC] == CONSTANT_EU_INCOMING_INVOICE)
		{
			//nicht Ita ER schreibe Lieferant in Lieferantenname2 da doppelbelegung auf Lieferatn
			dok_dat_feld[20] = name[1]
			call api_log_error("MaMo Fattura estera")
	
		}
		else 
		{
			//name
			dok_dat_feld[:idFieldName] = name[1]
			call api_log_error("MaMo fattura italiana")
	
		}
		return 0
		
		
	}
	
	else
	{
		
			call api_log_error("No Match for PIVA= :piva or FiscalCode= :codfis found!")
			return -1
		
	}
	//**End New Code ticket 5536073 MaMo 05062023**//
	
}