【问题标题】:Biztalk Debatch flat file with header, 2 repeating records and trailer with tag identifiersBiztalk Debatch 平面文件,带有标题、2 个重复记录和带有标签标识符的尾部
【发布时间】:2021-09-19 10:53:04
【问题描述】:

我有一个带有标头和尾标的平面文件,标签标识符分别为 APTHDR 和 APTDTL。

然而,当前的文件让我很恼火,因为它有一个重复的记录问题。 文件结构:

    20data for the summary information 
        
     HE Header of record
        
     DE Detail of record
        
     HE Header of record
        
     DE Detail of record

     DE Detail of record
        
     20 trailler data

记录 20 = 1 个摘要实例,1 个预告片实例 记录。

记录 HE:一个 HE 有多个 DE。一个文件有多个HE。

这是数据示例:

20201117125512HH  001APPOINTMENT DATA                                    85372
 HE0350100000001 1 2CROS04202020-11-25012020-11-25 15:30:00.000000        PIC077120                   128027  2020-11-17 12:50:52.000265 N  N   0000004390000000000186000000                              00000                              PIC077120           023095412
 DE035010000000C116780360635000000439PIC077120           023095412
 HE0350100000001 1 2CACG05002020-11-25012020-11-25 14:00:00.000000        3501382191/,                183699  2020-11-17 12:51:02.000864 N  Y NS0000013210083300043754000000                              00000                              3501382191/, 1621476023035082
 DE035010000000C3100203821910000010013501382191/, 1621476023035082
 DE035010000000C3100202566840000001003501382191/, 1621476023035082
 DE035010000000C3100203826550000001073501382191/, 1621476023035082
 DE035010000000C3100203852630000000203501382191/, 1621476023035082
 DE035010000000C3100203746790000000183501382191/, 1621476023035082
 DE035010000000C3100202903510000000753501382191/, 1621476023035082
 20201117125512TT  001000000000000000000110000000000

如果我使用一个集合,我会在正确的位置得到结果,但是一旦我尝试创建一个多记录文件,它就会被淹没。 我只是不知道如何解决它。

谢谢!

【问题讨论】:

  • 您希望将它们作为一个 XML 文件,还是希望将 HE 和 DE 集合分批成单独的消息?

标签: xsd schema biztalk


【解决方案1】:

首先,您需要创建 3 个模式,一个 Header、一个 Body 和一个 Trailer。 将您拥有的文件拆分为这些组件,以便您可以针对该部分测试每个架构,因为主体只有一个 HE 和多个 DE。

然后你需要创建一个带有平面文件反汇编组件的管道,并在属性中设置所有三个架构。

部署这些,创建使用管道的接收端口和位置,并订阅消息。

示例架构

标题架构

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO68310662" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO68310662" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo standard="Flat File" root_reference="Header" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" />
      <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Header">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name="HeaderRecord">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo sequence_number="1" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="DateTime">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_length="14" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:simpleType>
                  <xs:restriction base="xs:string" />
                </xs:simpleType>
              </xs:element>
              <xs:element name="Field" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_length="64" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

主体架构

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO68310662" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO68310662" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo standard="Flat File" root_reference="Body" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" />
      <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Body">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name="HeaderRecord">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo sequence_number="1" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name=" HE" />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="Field1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_length="263" sequence_number="1" pos_offset="3" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element maxOccurs="unbounded" name="DetailRecord">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo sequence_number="2" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" tag_name=" DE" />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="Field1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" sequence_number="1" pos_length="63" pos_offset="3" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

预告片架构

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO68310662" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Scratch.SO68310662" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo standard="Flat File" root_reference="Header" default_pad_char=" " pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" />
      <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Header">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" sequence_number="1" child_order="postfix" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" />
      </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo>
            <b:groupInfo sequence_number="0" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name="TrailerRecord">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo sequence_number="1" structure="positional" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" />
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:annotation>
                <xs:appinfo>
                  <b:groupInfo sequence_number="0" />
                </xs:appinfo>
              </xs:annotation>
              <xs:element name="DateTime">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_length="14" sequence_number="1" pos_offset="1" />
                  </xs:appinfo>
                </xs:annotation>
                <xs:simpleType>
                  <xs:restriction base="xs:string" />
                </xs:simpleType>
              </xs:element>
              <xs:element name="Field" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" pos_length="37" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

输出消息 1

<Body xmlns="http://Scratch.SO68310662">
    <HeaderRecord xmlns="">
        <Field1>0350100000001 1 2CACG05002020-11-25012020-11-25 14:00:00.000000        3501382191/,                183699  2020-11-17 12:51:02.000864 N  Y NS0000013210083300043754000000                              00000                              3501382191/, 1621476023035082</Field1>
    </HeaderRecord>
    <DetailRecord xmlns="">
        <Field1>035010000000C3100203821910000010013501382191/, 1621476023035082</Field1>
    </DetailRecord>
    <DetailRecord xmlns="">
        <Field1>035010000000C3100202566840000001003501382191/, 1621476023035082</Field1>
    </DetailRecord>
    <DetailRecord xmlns="">
        <Field1>035010000000C3100203826550000001073501382191/, 1621476023035082</Field1>
    </DetailRecord>
    <DetailRecord xmlns="">
        <Field1>035010000000C3100203852630000000203501382191/, 1621476023035082</Field1>
    </DetailRecord>
    <DetailRecord xmlns="">
        <Field1>035010000000C3100203746790000000183501382191/, 1621476023035082</Field1>
    </DetailRecord>
    <DetailRecord xmlns="">
        <Field1>035010000000C3100202903510000000753501382191/, 1621476023035082</Field1>
    </DetailRecord>
</Body>

输出消息 2

<Body xmlns="http://Scratch.SO68310662">
    <HeaderRecord xmlns="">
        <Field1>0350100000001 1 2CROS04202020-11-25012020-11-25 15:30:00.000000        PIC077120                   128027  2020-11-17 12:50:52.000265 N  N   0000004390000000000186000000                              00000                              PIC077120           023095412</Field1>
    </HeaderRecord>
    <DetailRecord xmlns="">
        <Field1>035010000000C116780360635000000439PIC077120           023095412</Field1>
    </DetailRecord>
</Body>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 2013-06-18
    相关资源
    最近更新 更多