STATIC void Raj_XMLCreation()
{
XmlDocument xmlDoc;
XmlElement xmlRoot;
XmlElement xmlField;
XmlElement xmlRecord,xmlRecord1,xmlRecord2;
XMLWriter xmlWriter;
CustPackingSlipTrans custPackingSlipTrans;
SalesLine salesLine_1;
CustPackingSlipJour custPackingSlipJour;
DictTable dictTable_1 = new DictTable(tablenum(SalesLine));
DictTable dictTable_2 = new DictTable(tablenum(CustPackingSlipJour));
DictTable dictTable_3 = new DictTable(tablenum(CustPackingSlipTrans));
DictField dField;
int i, fieldId,fieldid_1;
str value;
FileIoPermission _perm;
PackingSlipId _packingSlipId;
;
xmlDoc = XmlDocument::newBlank();
xmlRoot = xmlDoc.createElement("CustPackingSlip");
_packingSlipId = "SPK-000001";
select custPackingSlipJour where custPackingSlipJour.PackingSlipId == _packingSlipId;
while select salesline_1 where salesLine_1.SalesId == custPackingSlipJour.SalesId
{
select CustPackingSlipTrans
where CustPackingSlipTrans.PackingSlipId == custPackingSlipJour.PackingSlipId && CustPackingSlipTrans.SalesId == salesLine_1.SalesId && CustPackingSlipTrans.InventTransId == salesLine_1.InventTransId;
xmlRecord1 = xmlDoc.createElement("SalesLine");
for (i=1; i<=5; i++)
{
switch(i)
{
case 1:
fieldId = fieldname2id(salesLine_1.TableId,"LineNum");
break;
case 2:
fieldId = fieldname2id(salesLine_1.TableId,"ItemId");
break;
case 3:
fieldId = fieldname2id(salesLine_1.TableId,"SalesQty");
break;
case 4:
fieldId = fieldname2id(salesLine_1.TableId,"SalesUnit");
break;
case 5:
fieldId = fieldname2id(salesLine_1.TableId,"RemainSalesPhysical");
break;
}
dField = dictTable_1.fieldObject(fieldId);
xmlField = xmlDoc.createElement(dField.name());
value = salesLine_1.(fieldId);
xmlField.innerText(value);
xmlRecord1.appendChild(xmlField);
}
xmlRecord2 = xmlDoc.createElement("CustPackingSlipJour");
xmlRecord = xmlDoc.createElement("CustPackingSlipTrans");
for (i=1; i<=3; i++)
{
switch(i)
{
case 1:
fieldId = fieldname2id(CustPackingSlipTrans.TableId,"PackingSlipId");
break;
case 2:
fieldId = fieldname2id(CustPackingSlipTrans.TableId,"Remain");
break;
case 3:
fieldId = fieldname2id(CustPackingSlipTrans.TableId,"Qty");
break;
}
dField = dictTable_3.fieldObject(fieldId);
xmlField = xmlDoc.createElement(dField.name());
switch (dField.baseType())
{
case Types::Int64 :
value = int642str(CustPackingSlipTrans.(fieldId));
break;
case Types::Integer :
value = int2str(CustPackingSlipTrans.(fieldId));
break;
default :
value = CustPackingSlipTrans.(fieldId);
break;
}
xmlField.innerText(value);
xmlRecord.appendChild(xmlField);
if(value != "" && fieldId == fieldname2id(CustPackingSlipTrans.TableId,"PackingSlipId"))
{
fieldId_1 = fieldname2id(custPackingSlipJour.TableId,"Qty");
dField = dictTable_2.fieldObject(fieldId_1);
xmlField = xmlDoc.createElement(dField.name());
value = custPackingSlipJour.(fieldId_1);
xmlField.innerText(value);
xmlRecord2.appendChild(xmlField);
}
else if((value == "" && fieldId == fieldname2id(CustPackingSlipTrans.TableId,"PackingSlipId")))
{
fieldId_1 = fieldname2id(custPackingSlipJour.TableId,"Qty");
dField = dictTable_2.fieldObject(fieldId_1);
xmlField = xmlDoc.createElement(dField.name());
value = custPackingSlipJour.(fieldId_1);
xmlRecord2.appendChild(xmlField);
}
}
xmlrecord2.appendChild(xmlRecord);
xmlrecord1.appendChild(xmlRecord2);
xmlRoot.appendChild(xmlRecord1);
}
xmlDoc.appendChild(xmlRoot);
info(xmlDoc.toString());
xmlWriter = XMLWriter::newFile(@"C:\Users\rajendra.c\Desktop\"+custPackingSlipJour.PackingSlipId+".xml");
xmlDoc.writeTo(xmlWriter);
}
{
XmlDocument xmlDoc;
XmlElement xmlRoot;
XmlElement xmlField;
XmlElement xmlRecord,xmlRecord1,xmlRecord2;
XMLWriter xmlWriter;
CustPackingSlipTrans custPackingSlipTrans;
SalesLine salesLine_1;
CustPackingSlipJour custPackingSlipJour;
DictTable dictTable_1 = new DictTable(tablenum(SalesLine));
DictTable dictTable_2 = new DictTable(tablenum(CustPackingSlipJour));
DictTable dictTable_3 = new DictTable(tablenum(CustPackingSlipTrans));
DictField dField;
int i, fieldId,fieldid_1;
str value;
FileIoPermission _perm;
PackingSlipId _packingSlipId;
;
xmlDoc = XmlDocument::newBlank();
xmlRoot = xmlDoc.createElement("CustPackingSlip");
_packingSlipId = "SPK-000001";
select custPackingSlipJour where custPackingSlipJour.PackingSlipId == _packingSlipId;
while select salesline_1 where salesLine_1.SalesId == custPackingSlipJour.SalesId
{
select CustPackingSlipTrans
where CustPackingSlipTrans.PackingSlipId == custPackingSlipJour.PackingSlipId && CustPackingSlipTrans.SalesId == salesLine_1.SalesId && CustPackingSlipTrans.InventTransId == salesLine_1.InventTransId;
xmlRecord1 = xmlDoc.createElement("SalesLine");
for (i=1; i<=5; i++)
{
switch(i)
{
case 1:
fieldId = fieldname2id(salesLine_1.TableId,"LineNum");
break;
case 2:
fieldId = fieldname2id(salesLine_1.TableId,"ItemId");
break;
case 3:
fieldId = fieldname2id(salesLine_1.TableId,"SalesQty");
break;
case 4:
fieldId = fieldname2id(salesLine_1.TableId,"SalesUnit");
break;
case 5:
fieldId = fieldname2id(salesLine_1.TableId,"RemainSalesPhysical");
break;
}
dField = dictTable_1.fieldObject(fieldId);
xmlField = xmlDoc.createElement(dField.name());
value = salesLine_1.(fieldId);
xmlField.innerText(value);
xmlRecord1.appendChild(xmlField);
}
xmlRecord2 = xmlDoc.createElement("CustPackingSlipJour");
xmlRecord = xmlDoc.createElement("CustPackingSlipTrans");
for (i=1; i<=3; i++)
{
switch(i)
{
case 1:
fieldId = fieldname2id(CustPackingSlipTrans.TableId,"PackingSlipId");
break;
case 2:
fieldId = fieldname2id(CustPackingSlipTrans.TableId,"Remain");
break;
case 3:
fieldId = fieldname2id(CustPackingSlipTrans.TableId,"Qty");
break;
}
dField = dictTable_3.fieldObject(fieldId);
xmlField = xmlDoc.createElement(dField.name());
switch (dField.baseType())
{
case Types::Int64 :
value = int642str(CustPackingSlipTrans.(fieldId));
break;
case Types::Integer :
value = int2str(CustPackingSlipTrans.(fieldId));
break;
default :
value = CustPackingSlipTrans.(fieldId);
break;
}
xmlField.innerText(value);
xmlRecord.appendChild(xmlField);
if(value != "" && fieldId == fieldname2id(CustPackingSlipTrans.TableId,"PackingSlipId"))
{
fieldId_1 = fieldname2id(custPackingSlipJour.TableId,"Qty");
dField = dictTable_2.fieldObject(fieldId_1);
xmlField = xmlDoc.createElement(dField.name());
value = custPackingSlipJour.(fieldId_1);
xmlField.innerText(value);
xmlRecord2.appendChild(xmlField);
}
else if((value == "" && fieldId == fieldname2id(CustPackingSlipTrans.TableId,"PackingSlipId")))
{
fieldId_1 = fieldname2id(custPackingSlipJour.TableId,"Qty");
dField = dictTable_2.fieldObject(fieldId_1);
xmlField = xmlDoc.createElement(dField.name());
value = custPackingSlipJour.(fieldId_1);
xmlRecord2.appendChild(xmlField);
}
}
xmlrecord2.appendChild(xmlRecord);
xmlrecord1.appendChild(xmlRecord2);
xmlRoot.appendChild(xmlRecord1);
}
xmlDoc.appendChild(xmlRoot);
info(xmlDoc.toString());
xmlWriter = XMLWriter::newFile(@"C:\Users\rajendra.c\Desktop\"+custPackingSlipJour.PackingSlipId+".xml");
xmlDoc.writeTo(xmlWriter);
}
No comments:
Post a Comment