[ERR U01] Missing mandatory integer field. Field: TemplateID

49 views
Skip to first unread message

rollen

unread,
Mar 10, 2011, 10:37:38 AM3/10/11
to quickfast_users
Hi,

I receive the error U01.

the template file is like this:

...
<template name="FAST RelatedSym" id="5" dictionary="FAST
RelatedSym">
<string name="LSEG FAST SecurityID" id="48" presence="optional">
</string>
<string name="LSEG FAST SecurityIDSource" id="22"
presence="optional">
</string>
<string name="FAST ProductComplex" id="1227" presence="optional">
</string>
</template>
<template name="FAST MDEntryType" id="6" dictionary="FAST
MDEntryType">
<string name="FAST MDEntryType" id="269" presence="optional">
</string>
<string name="FAST MDEntryTime" id="273" presence="optional">
</string>
<string name="LSEG FAST QuoteCondition" id="276"
presence="optional">
</string>
</template>
<template name="FAST Market Data Request" id="7" dictionary="FAST
Market Data Request">
<string name="FAST MsgType" id="35" presence="mandatory">
</string>
<string name="FAST SendingTime" id="52" presence="mandatory">
</string>
<string name="FAST MDReqID" id="262" presence="mandatory">
</string>
<uInt32 name="FAST SubscriptionRequestType" id="263"
presence="mandatory">
</uInt32>
<uInt32 name="FAST NumberMDEntryTypes" id="267"
presence="optional">
</uInt32>
<sequence name="FAST MDEntryTypes" id="" presence="optional">
<length name="FAST NoMDEntryTypes" id="267">
</length>
<uInt32 name="TemplateID" id="9999">
<copy dictionary="global" value="6" />
</uInt32>
<templateRef name="FAST MDEntryType" />
</sequence>
<uInt32 name="FAST NumberRelatedSym" id="146" presence="optional">
</uInt32>
<sequence name="FAST RelatedSyms" presence="optional">
<length name="FAST NoRelatedSyms" id="146">
</length>
<uInt32 name="TemplateID" id="9999">
<copy dictionary="global" value="5"/>
</uInt32>
<templateRef name="FAST RelatedSym" />
</sequence>
</template>
...

and the QuickFAST code that come on error is this:

FastMessage marketDataRequest(const
QuickFAST::Codecs::TemplateRegistryPtr templateRegistry, const string&
segment, const uint32_t instrumentId) {
string message;
try {
QuickFAST::Messages::Message msg(templateRegistry-
>maxFieldCount());
QuickFAST::Messages::FieldIdentityCPtr field_MsgType = new
QuickFAST::Messages::FieldIdentity("FAST MsgType");
QuickFAST::Messages::FieldIdentityCPtr field_SendingTime = new
QuickFAST::Messages::FieldIdentity("FAST SendingTime");
QuickFAST::Messages::FieldIdentityCPtr field_MDReqID = new
QuickFAST::Messages::FieldIdentity("FAST MDReqID");
QuickFAST::Messages::FieldIdentityCPtr
field_SubscriptionRequestType = new
QuickFAST::Messages::FieldIdentity("FAST SubscriptionRequestType");
QuickFAST::Messages::FieldIdentityCPtr field_NumberMDEntryTypes =
new QuickFAST::Messages::FieldIdentity("FAST NumberMDEntryTypes");
QuickFAST::Messages::FieldIdentityCPtr field_MDEntryTypes = new
QuickFAST::Messages::FieldIdentity("FAST MDEntryTypes");
QuickFAST::Messages::FieldIdentityCPtr field_NoMDEntryTypes = new
QuickFAST::Messages::FieldIdentity("FAST NoMDEntryTypes");
QuickFAST::Messages::FieldIdentityCPtr field_MDEntryType = new
QuickFAST::Messages::FieldIdentity("FAST MDEntryType");
QuickFAST::Messages::FieldIdentityCPtr field_MDEntryTime = new
QuickFAST::Messages::FieldIdentity("FAST MDEntryTime");
QuickFAST::Messages::FieldIdentityCPtr field_QuoteCondition = new
QuickFAST::Messages::FieldIdentity("FAST QuoteCondition");
QuickFAST::Messages::FieldIdentityCPtr field_NumberRelatedSym =
new QuickFAST::Messages::FieldIdentity("FAST NumberRelatedSym");
QuickFAST::Messages::FieldIdentityCPtr field_RelatedSyms = new
QuickFAST::Messages::FieldIdentity("FAST RelatedSyms");
QuickFAST::Messages::FieldIdentityCPtr field_NoRelatedSyms = new
QuickFAST::Messages::FieldIdentity("FAST NoRelatedSyms");
QuickFAST::Messages::FieldIdentityCPtr field_RelatedSym = new
QuickFAST::Messages::FieldIdentity("FAST RelatedSym");
QuickFAST::Messages::FieldIdentityCPtr field_SecurityID = new
QuickFAST::Messages::FieldIdentity("LSEG FAST SecurityID");
QuickFAST::Messages::FieldIdentityCPtr field_SecurityIDSource =
new QuickFAST::Messages::FieldIdentity("LSEG FAST SecurityIDSource");
QuickFAST::Messages::FieldIdentityCPtr field_ProductComplex = new
QuickFAST::Messages::FieldIdentity("FAST ProductComplex");
QuickFAST::Messages::FieldIdentityCPtr field_TemplateID = new
QuickFAST::Messages::FieldIdentity("FAST TemplateID");
QuickFAST::Messages::FieldSetPtr set_MDEntryTypes(new
QuickFAST::Messages::FieldSet(2));
set_MDEntryTypes->addField(field_TemplateID,
QuickFAST::Messages::FieldUInt32::create(6));
set_MDEntryTypes->addField(field_MDEntryTypes,
QuickFAST::Messages::FieldString::create("0"));
//sequence_MDEntryTypes->addField(field_MDEntryTime,
QuickFAST::Messages::FieldString::create(""));
//sequence_MDEntryTypes->addField(field_QuoteCondition,
QuickFAST::Messages::FieldString::create(""));
//QuickFAST::Messages::SequencePtr sequence_MDEntryTypes(new
QuickFAST::Messages::Sequence(field_NoMDEntryTypes, 1));
QuickFAST::Messages::FieldIdentityPtr id_NoMDEntryTypes = new
QuickFAST::Messages::FieldIdentity("FAST NoMDEntryTypes");
QuickFAST::Messages::FieldIdentityCPtr
cid_NoMDEntryTypes(id_NoMDEntryTypes);
id_NoMDEntryTypes->setId("267");
QuickFAST::Messages::SequencePtr sequence_MDEntryTypes(new
QuickFAST::Messages::Sequence(cid_NoMDEntryTypes, 1));
sequence_MDEntryTypes-
>addEntry(QuickFAST::Messages::FieldSetCPtr(set_MDEntryTypes));
QuickFAST::Messages::FieldSetPtr set_RelatedSyms(new
QuickFAST::Messages::FieldSet(2));
set_RelatedSyms->addField(field_TemplateID,
QuickFAST::Messages::FieldUInt32::create(5));
set_RelatedSyms->addField(field_SecurityID,
QuickFAST::Messages::FieldString::create(format("%d",
instrumentId).c_str()));
//sequence_RelatedSyms->addField(field_SecurityIDSource,
QuickFAST::Messages::FieldString::create(""));
//sequence_RelatedSyms->addField(field_ProductComplex,
QuickFAST::Messages::FieldString::create(""));
//QuickFAST::Messages::SequencePtr sequence_RelatedSyms(new
QuickFAST::Messages::Sequence(field_NoRelatedSyms, 1));
QuickFAST::Messages::FieldIdentityPtr id_NoRelatedSyms = new
QuickFAST::Messages::FieldIdentity("FAST NoRelatedSyms");
QuickFAST::Messages::FieldIdentityCPtr
cid_NoRelatedSyms(id_NoRelatedSyms);
id_NoRelatedSyms->setId("146");
QuickFAST::Messages::SequencePtr sequence_RelatedSyms(new
QuickFAST::Messages::Sequence(cid_NoRelatedSyms, 1));
sequence_RelatedSyms-
>addEntry(QuickFAST::Messages::FieldSetCPtr(set_RelatedSyms));
msg.addField(field_MsgType,
QuickFAST::Messages::FieldString::create("V"));
timeb now; ::ftime(&now);
struct tm gmtime = *::gmtime_r(&now.time, &gmtime);
char buffer[22];
strftime(buffer, sizeof(buffer), "%Y%m%d-%H:%M:%S", &gmtime);
snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer),
".%03d", now.millitm);
msg.addField(field_SendingTime,
QuickFAST::Messages::FieldString::create(buffer));
msg.addField(field_MDReqID,
QuickFAST::Messages::FieldString::create(format("%d",
instrumentId).c_str()));
msg.addField(field_SubscriptionRequestType,
QuickFAST::Messages::FieldUInt32::create(0));
//msg.addField(field_NumberMDEntryTypes,
QuickFAST::Messages::FieldUInt32::create(1));
//msg.addField(field_TemplateID,
QuickFAST::Messages::FieldUInt32::create(6));
msg.addField(field_MDEntryTypes,
QuickFAST::Messages::FieldSequence::create(sequence_MDEntryTypes));
//msg.addField(field_NumberRelatedSym,
QuickFAST::Messages::FieldUInt32::create(1));
//msg.addField(field_TemplateID,
QuickFAST::Messages::FieldUInt32::create(5));
msg.addField(field_RelatedSyms,
QuickFAST::Messages::FieldSequence::create(sequence_RelatedSyms));
QuickFAST::Codecs::Encoder encoder(templateRegistry);
QuickFAST::Codecs::DataDestination destination;
template_id_t templId = 7; // FAST Market Data Request
encoder.encodeMessage(destination, templId, msg);
destination.toString(message);
//QuickFAST::Messages::FieldCPtr blockSize =
QuickFAST::Messages::FieldUInt64::create(message.size());
//message = string(reinterpret_cast<const char*>(blockSize-
>displayString().data()), blockSize->displayString().size()) +
message;
message = string(1, static_cast<char>(message.size() | 0x80)) +
message;
}
catch (std::exception& e) {
LOGGER_ERROR("std::exception = " << e.what());
}
return FastMessage(message.data(), message.size());
}

Thank for your help.

Mario

Dale Wilson

unread,
Mar 10, 2011, 2:49:42 PM3/10/11
to quickfa...@googlegroups.com
Hi Mario,

The error you are getting is not related to the template id for a
template, but rather is related to the field you have named TemplateID
using this field instruction:

<uInt32 name="TemplateID" id="9999">
<copy dictionary="global" value="6" />
</uInt32>

If you truly mean this to be a template ID, you should be aware that
there is no need to declare it explicitly, the <template> element
defines the template id field automatically.

That being said, it appears that you are attempting to assign a value
for this field using this code:

QuickFAST::Messages::FieldIdentityCPtr field_TemplateID = new
QuickFAST::Messages::FieldIdentity("FAST TemplateID");

set_MDEntryTypes->addField(field_TemplateID,
QuickFAST::Messages::FieldUInt32::create(6));

This is unnecessary, of course, but if it were necessary it would work
better if the name in FieldIdentity ("FAST TemplateID") matched the name
in the XML ("TemplateID")


HTH,

Dale


--
Dale Wilson
Principal Software Engineer
Object Computing, Inc.

rollen

unread,
Mar 11, 2011, 7:23:27 AM3/11/11
to quickfast_users
Thank for help.

I can not modify the template file (this come from market), so I must
write the field TemplateID. Now I write right (TemplateID) and all
work.

I probe to decode the encoded message

2011/03/11 13:18:22.807 | DEBUG | 8 | ### [/SG/SPARCVII/marior/WS/
FASTFIX/src/lsefeed/listener.cc 246] FAST MsgType[]=V FAST
SendingTime[]=20110311-12:18:22.807 FAST MDReqID[]=116006 FAST
SubscriptionRequestType[]=0 FAST NumberMDEntryTypes[]=11
FAST MDEntryTypes[]=Sequence: FAST NoMDEntryTypes[] = 11 {
[0]: TemplateID[]=6 FAST MDEntryType[]=0
[1]: TemplateID[]=6 FAST MDEntryType[]=1
[2]: TemplateID[]=6 FAST MDEntryType[]=2
[3]: TemplateID[]=6 FAST MDEntryType[]=4
[4]: TemplateID[]=6 FAST MDEntryType[]=5
[5]: TemplateID[]=6 FAST MDEntryType[]=7
[6]: TemplateID[]=6 FAST MDEntryType[]=9
[7]: TemplateID[]=6 FAST MDEntryType[]=B
[8]: TemplateID[]=6 FAST MDEntryType[]=d
[9]: TemplateID[]=6 FAST MDEntryType[]=e
[10]: TemplateID[]=6 FAST MDEntryType[]=f
}
FAST NumberRelatedSym[]=1
FAST RelatedSyms[]=Sequence: FAST NoRelatedSyms[] = 1 {
[0]: TemplateID[]=5 LSEG FAST SecurityID[]=116006
}

but I receive another error:

2011/03/11 13:18:22.807 | ERROR | 8 | [/SG/SPARCVII/marior/WS/FASTFIX/
src/lsefeed/listener.cc 269] std::exception = ascii cannot be
converted to Group

I have modified the template name (template name="FAST MDEntryType")
and his reference in (template name="T FAST MDEntryType") because
there is a string with the same name. It's this right ?

Thank. Mario
> ...
>
> leggi tutto

Dale Wilson

unread,
Mar 11, 2011, 10:36:47 AM3/11/11
to quickfa...@googlegroups.com
The error message indicates that the XML template declared that there
was a group with a particular name, but when the encoder attempted to
retrieve that group by name from the record being encoded it got an
ASCII string field instead.

If the template declares group and a field with the same name in the
same scope that could certainly cause this problem. This is an invalid
template definition. However this error is not currently detected by
the template parser.

If, however, the string and the group are NOT in the same scope in the
XML file, then you need to be sure the fields are in the proper parent
segments in the message being decoded.

Dale

Reply all
Reply to author
Forward
0 new messages