Hi,

I replaced all QUIT with Return and add conditional check based on third parameter at the begening of the ClassMethod as you suggest.

When I tried to run, the output is excatly the same as with QUIT. Function still running even value has been found.

This is output from terminal where I added $G(mainArticle),"-",$G(article) from suggestion above.

9430954-9428572 BEGENING OF LOOP FOR: H2652.S
9430954-9428572 START RECURSIVE
9408921-9428572 BEGENING OF LOOP FOR: MQ0605.B
9408921-9428572 END OF LOOP
9430954-9428572 BEGENING OF LOOP FOR: H2641.B
9430954-9428572 BEGENING OF LOOP FOR: M1910.15.40
9430954-9428572 BEGENING OF LOOP FOR: GK6202
9430954-9428572 BEGENING OF LOOP FOR: GK6201.B
9430954-9428572 BEGENING OF LOOP FOR: IX08.0925
9430954-9428572 START RECURSIVE
9408925-9428572 END OF LOOP
9430954-9428572 BEGENING OF LOOP FOR: XQA1.AI12.1425.1020.C
9430954-9428572 START RECURSIVE
9413847-9428572 BEGENING OF LOOP FOR: XAL446.1250.1.AI12.L.A
9413847-9428572 START RECURSIVE
9408591-9428572 BEGENING OF LOOP FOR: AL446.1255
9408591-9428572 END OF LOOP
9413847-9428572 BEGENING OF LOOP FOR: XAL446.1250.1.AI12.R.A
9413847-9428572 START RECURSIVE
9408593-9428572 BEGENING OF LOOP FOR: AL446.1255
9408593-9428572 END OF LOOP
9413847-9428572 BEGENING OF LOOP FOR: AL448.1024
9413847-9428572 BEGENING OF LOOP FOR: XAL447.0970.A
9413847-9428572 START RECURSIVE
9408603-9428572 BEGENING OF LOOP FOR: AL447.0975
9408603-9428572 END OF LOOP
9413847-9428572 BEGENING OF LOOP FOR: H2640.A
9413847-9428572 BEGENING OF LOOP FOR: H2641.C
9413847-9428572 BEGENING OF LOOP FOR: H2650.A
9413847-9428572 BEGENING OF LOOP FOR: H2701.1020
9413847-9428572 BEGENING OF LOOP FOR: XAL465.1110.A0
9413847-9428572 START RECURSIVE
9421986-9428572 Has Value
9413847-9428572 BEGENING OF LOOP FOR: XAL465.1110.A1
9413847-9428572 START RECURSIVE
9421987-9428572 BEGENING OF LOOP FOR: XAL465.1110.A0
9421987-9428572 START RECURSIVE
9421986-9428572 Has Value
9421987-9428572 END OF LOOP
9413847-9428572 BEGENING OF LOOP FOR: XAL465.1110.A2
9413847-9428572 START RECURSIVE
9421990-9428572 BEGENING OF LOOP FOR: XAL465.1110.A0
9421990-9428572 START RECURSIVE
9421986-9428572 Has Value
9421990-9428572 END OF LOOP
9413847-9428572 BEGENING OF LOOP FOR: H2707.R.S
9413847-9428572 START RECURSIVE
9432315-9428572 BEGENING OF LOOP FOR: H2707
9432315-9428572 BEGENING OF LOOP FOR: H2698
9432315-9428572 BEGENING OF LOOP FOR: H2697
9432315-9428572 END OF LOOP
9413847-9428572 BEGENING OF LOOP FOR: H2707.L.S
9413847-9428572 START RECURSIVE
9432316-9428572 BEGENING OF LOOP FOR: H2707
9432316-9428572 BEGENING OF LOOP FOR: H2698
9432316-9428572 BEGENING OF LOOP FOR: H2697
9432316-9428572 END OF LOOP
9413847-9428572 END OF LOOP
9430954-9428572 END OF LOOP

// EDIT

I was able to QUIT only when I used global variable

ClassMethod workpieceUnit(mainArticle As %String, article As %String) As %String
{
	&SQL(SELECT unit->unitCode INTO :unitCode FROM production_article.composition WHERE mainArticle = :mainArticle AND article = :article)
	
	IF (SQLCODE = 0)
	{
		W !, $G(mainArticle),"-",$G(article)," Has Value"
		SET ^pasp("unitCode") = unitCode
		RETURN unitCode
	}
	ELSE
	{
		SET sql = "SELECT article, unit->unitCode,  production_article.composition_sqlArticleCode(article, type) AS articleCode FROM production_article.composition WHERE mainArticle = "_mainArticle_" AND type = 1",
		 	 rs = ##class(%SQL.Statement).%ExecDirect(,sql)
		 
		WHILE rs.%Next()
		{
			RETURN:$GET(^pasp("unitCode"))'="" ^pasp("unitCode")
			
			W !, $G(mainArticle),"-",$G(article)," BEGENING OF LOOP FOR: "_rs.articleCode
			
			IF (rs.article = article)
			{
				RETURN rs.unitCode	
			}
			
			// CHECK IF WORKPIECE HAS COMPOSITION
			&SQL(SELECT COUNT(*) INTO :composition FROM production_article.composition WHERE mainArticle = :rs.article)
			
			IF (composition > 0)
			{
				W !, $G(mainArticle),"-",$G(article)," START RECURSIVE"
				DO ..workpieceUnit(rs.article, article)
			}
		}
			
		W !, $G(mainArticle),"-",$G(article)," END OF LOOP"
		RETURN $GET(^pasp("unitCode"),"")
		KILL ^pasp("unitCode")
	}
	
	RETURN ""
}

Was not compiled even I have clicked to compile. Anyway still getting erro. Is it possible to turn off datatype validation?

Datatype validation failed for tag, PartoNo (ending at line 51 character 20), with value: 5625.1800.L

I have tried replace %xsd.short for %String,  %GlobalCharacterStream   but does not help at all

 Property PartoNo As %xsd.short(XMLNAME = "PartoNo") [ Required ];

I have generated classes now by using XML Schema, but still not working 

 Class TruLaser.ProductionPackage Extends (%Persistent, %XML.Adaptor) [ ProcedureBlock ]
{ 
Parameter XMLNAME = "ProductionPackage"; 
Parameter XMLSEQUENCE = 1; 
Property Barcode As %xsd.int(XMLNAME = "Barcode") [ Required ]; 
Property DueDate As %String(MAXLEN = "", XMLNAME = "DueDate") [ Required ]; 
Property BasicMaterial As %xsd.float(XMLNAME = "BasicMaterial") [ Required ]; 
Property RawMaterial As %String(MAXLEN = "", XMLNAME = "RawMaterial") [ Required ]; 
Property RawMaterialThicknessUnit As %String(MAXLEN = "", XMLNAME = "RawMaterialThicknessUnit") [ Required ]; 
Property JobNote As %String(MAXLEN = "", XMLNAME = "JobNote") [ Required ]; 
Property CreatedBy As %String(MAXLEN = "", XMLNAME = "CreatedBy") [ Required ]; 
Property ChangedBy As %String(MAXLEN = "", XMLNAME = "ChangedBy") [ Required ]; 
Property Workplace As TruLaser.Workplace(XMLNAME = "Workplace") [ Required ]; 
Property ManufacturingOrders As TruLaser.TcBoManufacturingOrder(XMLNAME = "ManufacturingOrders", XMLPROJECTION = "WRAPPED") [ Required ]; Relationship ProductionOrders As TruLaser.ProductionOrder(XMLITEMNAME = "ProductionOrder", XMLNAME = "ProductionOrders", XMLPROJECTION = "COLLECTION") [ Cardinality = many, Inverse = ProductionPackage ]; 
Relationship Parts As TruLaser.Part(XMLITEMNAME = "Part", XMLNAME = "Parts", XMLPROJECTION = "COLLECTION") [ Cardinality = many, Inverse = ProductionPackage1 ]; 
Property NcPrograms As TruLaser.NcProgram(XMLNAME = "NcPrograms", XMLPROJECTION = "WRAPPED") [ Required ]; 
Property RequiredSheets As TruLaser.Sheet(XMLNAME = "RequiredSheets", XMLPROJECTION = "WRAPPED") [ Required ]; 
Property LaserTechnoTables As TruLaser.LaserTechnoTable(XMLNAME = "LaserTechnoTables", XMLPROJECTION = "WRAPPED") [ Required ]; 
Relationship UsedLaserTechnoTables As TruLaser.UsedLaserTechnoTable(XMLITEMNAME = "UsedLaserTechnoTable", XMLNAME = "UsedLaserTechnoTables", XMLPROJECTION = "COLLECTION") [ Cardinality = many, Inverse = ProductionPackage2 ]; 
Property TotalRuntime As %xsd.float(XMLNAME = "TotalRuntime") [ Required ]; 
Property RawMaterialThickness As %xsd.float(XMLNAME = "RawMaterialThickness") [ Required ]; 
Property TotalPartCount As %xsd.byte(XMLNAME = "TotalPartCount") [ Required ]; 
Property TotalSheetCount As %xsd.byte(XMLNAME = "TotalSheetCount") [ Required ]; Property Waste As %xsd.float(XMLNAME = "Waste") [ Required ]; Property JobName As %String(MAXLEN = "", XMLNAME = "JobName", XMLPROJECTION = "ATTRIBUTE");
Class TruLaser.TcBoManufacturingOrder Extends (%Persistent, %XML.Adaptor) [ ProcedureBlock ]
{
Parameter XMLNAME = "TcBoManufacturingOrder"; 
Parameter XMLSEQUENCE = 1; 
Property Barcode As %xsd.int(XMLNAME = "Barcode") [ Required ]; 
Property ProgramNo As %String(MAXLEN = "", XMLNAME = "ProgramNo") [ Required ]; 
Property NoOfRuns As %xsd.byte(XMLNAME = "NoOfRuns") [ Required ]; Relationship ProductionOrders As TruLaser.Order(XMLITEMNAME = "Order", XMLNAME = "ProductionOrders", XMLPROJECTION = "COLLECTION") [ Cardinality = many, Inverse = TcBoManufacturingOrder ]; 
Property ProcessingTimeTotal As %xsd.float(XMLNAME = "ProcessingTimeTotal") [ Required ]; 
Property ManufacturingOrderNo As %String(MAXLEN = "", XMLNAME = "ManufacturingOrderNo", XMLPROJECTION = "ATTRIBUTE");
}
ERROR #5002: Cache error: <CLASS DOES NOT EXIST>XMLImportElements+96^TruLaser.TcBoManufacturingOrder.1 *TruLaser.Order for element ProductionOrders (ending at line 28 character 25)

Also im still not able access all values for example :  object.LaserTechnoTables.MaxLaserPower