Esempio n. 1
0
        private static void processSingleIdoc(IRfcStructure tControl, IRfcTable datarows)
        {
            Idoc idoc = new Idoc
            {
                TABNAM = tControl["TABNAM"].GetValue().ToString().Trim(),
                MANDT = tControl["MANDT"].GetValue().ToString().Trim(),
                DOCNUM = tControl["DOCNUM"].GetValue().ToString().Trim(),
                DOCREL = tControl["DOCREL"].GetValue().ToString().Trim(),
                STATUS = tControl["STATUS"].GetValue().ToString().Trim(),
                DIRECT = tControl["DIRECT"].GetValue().ToString().Trim(),
                OUTMOD = tControl["OUTMOD"].GetValue().ToString().Trim(),
                EXPRSS = tControl["EXPRSS"].ToString().Trim(),
                IDOCTYP = tControl["IDOCTYP"].GetValue().ToString().Trim(),
                CIMTYP = tControl["CIMTYP"].GetValue().ToString().Trim(),
                MESTYP = tControl["MESTYP"].GetValue().ToString().Trim(),
                MESCOD = tControl["MESCOD"].GetValue().ToString().Trim(),
                MESFCT = tControl["MESFCT"].GetValue().ToString().Trim(),
                STD = tControl["STD"].GetValue().ToString().Trim(),
                STDVRS = tControl["STDVRS"].GetValue().ToString().Trim(),
                STDMES = tControl["STDMES"].GetValue().ToString().Trim(),
                SNDPOR = tControl["SNDPOR"].GetValue().ToString().Trim(),
                SNDPRT = tControl["SNDPRT"].GetValue().ToString().Trim(),
                SNDPFC = tControl["SNDPFC"].GetValue().ToString().Trim(),
                SNDPRN = tControl["SNDPRN"].GetValue().ToString().Trim(),
                SNDSAD = tControl["SNDSAD"].GetValue().ToString().Trim(),
                SNDLAD = tControl["SNDLAD"].GetValue().ToString().Trim(),
                RCVPOR = tControl["RCVPOR"].GetValue().ToString().Trim(),
                RCVPRT = tControl["RCVPRT"].GetValue().ToString().Trim(),
                RCVPFC = tControl["RCVPFC"].GetValue().ToString().Trim(),
                RCVPRN = tControl["RCVPRN"].GetValue().ToString().Trim(),
                RCVSAD = tControl["RCVSAD"].GetValue().ToString().Trim(),
                RCVLAD = tControl["RCVLAD"].GetValue().ToString().Trim(),
                CREDAT = tControl["CREDAT"].GetValue().ToString().Trim(),
                CRETIM = tControl["CRETIM"].GetValue().ToString().Trim(),
                REFINT = tControl["REFINT"].GetValue().ToString().Trim(),
                REFGRP = tControl["REFGRP"].GetValue().ToString().Trim(),
                REFMES = tControl["REFMES"].GetValue().ToString().Trim(),
                ARCKEY = tControl["ARCKEY"].GetValue().ToString().Trim(),
                SERIAL = tControl["SERIAL"].GetValue().ToString().Trim()
            };

            Hashtable hashtable = new Hashtable();
            for (int i = 0; i < datarows.RowCount; i++)
            {
                IRfcStructure structure = datarows[i];
                if (structure["DOCNUM"].GetValue().ToString().Trim().Equals(tControl["DOCNUM"].GetValue().ToString().Trim()))
                {
                    IdocSegment newSegment = new IdocSegment();
                    if (structure["PSGNUM"].GetValue().ToString() == "000000")
                    {
                        idoc.Segments.Add(newSegment);
                    }
                    else
                    {
                        IdocSegment segment2 = (IdocSegment)hashtable[structure["PSGNUM"].GetValue().ToString()];
                        if (segment2 != null)
                        {
                            segment2.ChildSegments.Add(newSegment);
                        }
                        else
                        {
                            idoc.Segments.Add(newSegment);
                        }
                    }
                    newSegment.SegmentName = structure["SEGNAM"].GetValue().ToString();
                    string content = structure["SDATA"].GetValue().ToString();
                    newSegment.WriteDataBuffer(content, 0, 0x3e8);
                    if (!hashtable.ContainsKey(structure["SEGNUM"].GetValue().ToString()))
                    {
                        hashtable.Add(structure["SEGNUM"].GetValue().ToString(), newSegment);
                    }
                }
            }

               // IdocMeta idocMeta = new IdocMeta(ConfigFileTool.SAPGlobalSettings.GetDefaultSapCient(), idoc);
               // idocMeta.getIdocTypeDefinition();
               // idocMeta.deCompileIdoc();

            idoc.SavePlainData(@"d:/test.txt");

            //idocsegment e1maram = idoc.segments["E2MARAM006", 0];

            //// loop through segments and find the right ones
            //for (int i = 0; i < e1maram.childsegments.count; i++)
            //    if (e1maram.childsegments[i].segmentname == "e2maktm001")
            //        console.writeline("materialtext found: " +
            //            e1maram.childsegments[i].readdatabuffer(4, 40));
        }
Esempio n. 2
0
 private IdocSegment GetSegmentFromNode(XmlNode node)
 {
     IdocSegment segment;
     string segmentName = Converts.XmlNameToOriginalName(node.Name);
     try
     {
         segment = this.CreateSegment(segmentName);
     }
     catch
     {
         segment = new IdocSegment
         {
             SegmentName = segmentName
         };
     }
     for (int i = 0; i < node.ChildNodes.Count; i++)
     {
         XmlNode node2 = node.ChildNodes[i];
         if (node2.Name.Equals("BUFFER"))
         {
             segment.WriteDataBuffer(node2.InnerText, 0, 0x3e8);
             segment.Fields.Clear();
             this.RegenerateSegment(segment);
         }
         else if ((node2.ChildNodes.Count > 0) && node2.ChildNodes[0].Name.Equals("BUFFER"))
         {
             segment.ChildSegments.Add(this.GetSegmentFromNode(node2));
         }
         else
         {
             string str2 = Converts.XmlNameToOriginalName(node2.Name);
             if (this.IsSegmentValid(str2))
             {
                 segment.ChildSegments.Add(this.GetSegmentFromNode(node2));
             }
             else
             {
                 try
                 {
                     segment.Fields[str2].FieldValue = node2.InnerText;
                 }
                 catch
                 {
                     segment.WriteDataBuffer(node2.InnerText.PadRight(0x3e8), 0, 0x3e8);
                 }
             }
         }
     }
     return segment;
 }