Try this code and let us know, if you face any specific error with this code.
recWhseSerialBatchHeader.RESET;
recWhseSerialBatchHeader.SETFILTER(Quantity, '>%1',0);
frmWhseSerialBatchList.SETTABLEVIEW(recWhseSerialBatchHeader);
frmWhseSerialBatchList.LOOKUPMODE(TRUE);
IF frmWhseSerialBatchList.RUNMODAL = ACTION::LookupOK THEN BEGIN
frmWhseSerialBatchList.GETRECORD(recWhseSerialBatchHeader);
recSerialNoInformation.RESET;
recSerialNoInformation.SETRANGE("Batch No.", recWhseSerialBatchHeader."No.");
recSerialNoInformation.RESET;
recSerialNoInformation3 := recSerialNoInformation;
recSerialNoInformation3.SETRANGE("Shipment No.", recSalesShipmentLine."Document No.");
recSerialNoInformation3.SETRANGE("Shipment Line No.", recSalesShipmentLine."Line No.");
intQtyBatch := recWhseSerialBatchHeader.Quantity; //This should take the Quantity from the Whse Serial Batch List
intShipmentLine := recSerialNoInformation."Shipment Line No",Quantity; //take the quantity from the Posted Sales Shipment
intQtyAssign := recSalesShipmentLine.Quantity; //take the quantity from the Serial Number Information List
recWhseSerialBatchHeader.Quantity.COUNT //This should count the quanity
recSalesShipmentLine.Qantity.COUNT //This Should count the quantity
IF recSerialNoInformation.COUNT <> recSalesShipmentLine.Quantity THEN
IF (intAssignBatch + intQtyBatch) > intShipmentLine THEN
ERROR('Error'); //produce error message
IF intQtyAssign < intShipmentLine THEN
IF CONFIRM('Are you sure?',FALSE) = FALSE THEN
EXIT;
BEGIN
IF recSerialNoInformation.FINDSET(FALSE,FALSE) THEN
REPEAT
recSerialNoInformation2 := recSerialNoInformation;
recSerialNoInformation2."Shipment No." := recSalesShipmentLine."Document No.";
recSerialNoInformation2."Shipment Line No." := recSalesShipmentLine."Line No.";
recSerialNoInformation2."Batch No." := '';
recSerialNoInformation2.MODIFY;
UNTIL recSerialNoInformation.NEXT = 0;
recWhseSerialBatchHeader.CALCFIELDS(Quantity);
IF recWhseSerialBatchHeader.Quantity = 0 THEN;
recWhseSerialBatchHeader.DELETE;
END;
END;