0
<tXML>
  <Header>
    <Source>J1_RETAIL</Source>
    <Action_Type>Update</Action_Type>
    <Sequence_Number>0</Sequence_Number>
    <Batch_ID>4383352</Batch_ID>
    <Reference_ID>04381645</Reference_ID>
    <User_ID>SAP</User_ID>
    <Password>password</Password>
    <Message_Type>SAP_DO</Message_Type>
    <Company_ID>J1</Company_ID>
    <Msg_Locale>English (United States)</Msg_Locale>
    <Msg_Time_Zone>Eastern Standard Time</Msg_Time_Zone>
    <Version></Version>
    <Internal_Reference_ID></Internal_Reference_ID>
    <Internal_Date_Time_Stamp></Internal_Date_Time_Stamp>
    <External_Reference_ID></External_Reference_ID>
    <External_Date_Time_Stamp></External_Date_Time_Stamp>
  </Header>
  <Message>
    <DistributionOrder>
        <ProcessInfo>
            <RefTextField1></RefTextField1>
            <RefTextField2></RefTextField2>
            <RefTextField3>S082</RefTextField3>
            <RefTextField4></RefTextField4>
            <RefTextField5></RefTextField5>
            <RefTextField6></RefTextField6>
            <RefTextField7>J1</RefTextField7>
            <RefTextField8>[0001333006_SAPTOMIF]</RefTextField8>
            <RefTextField9></RefTextField9>
            <RefTextField10>[ _20191223]</RefTextField10>
            <RefNumberField1>20191220</RefNumberField1>
            <RefNumberField2>34621</RefNumberField2>
            <RefNumberField3></RefNumberField3>
            <RefNumberField4>53</RefNumberField4>
            <RefNumberField5>13</RefNumberField5>
        </ProcessInfo>
        <Comment>
            <NoteType>MB</NoteType>
            <NoteCode>05</NoteCode>
            <CommentText>[00000_8769_741_82_093_965_987_456]</CommentText>
            <Visibility>0</Visibility>
          </Comment>
          <CustomFieldList>
            <CustomField>
              <Name>SiteID</Name>
              <Value></Value>
            </CustomField>
        <LineItem>
            <DoLineNbr>1</DoLineNbr>
            <ItemName>135465</ItemName>
            <Description>A</Description>
            <UpdateActionType></UpdateActionType>
            <PackageType></PackageType>
            <DoLineStatus>Released</DoLineStatus>
            <InventoryAttributes>
              <InventoryType>F</InventoryType>
              <ProductStatus></ProductStatus>
              <BatchNbr></BatchNbr>
              <CountryOfOrigin></CountryOfOrigin>
              <ItemAttribute1>R</ItemAttribute1>
              <ItemAttribute2></ItemAttribute2>
              <ItemAttribute3></ItemAttribute3>
              <ItemAttribute4></ItemAttribute4>
              <ItemAttribute5></ItemAttribute5>
            </InventoryAttributes>
        </LineItem>
    </DistributionOrder>
  </Message>
</tXML>

我的代码看起来像这样

output application/csv header = false , separator = "|" , quoteValues = false
---
payload.tXML.Message.*DistributionOrder map ((DistributionOrder , indexofDistributionOrder) ->  {
    column_1: "000000001",
    column_2: "0",
    column_3: "0",
    column_4: (LineItem.LineProcessInfo.LineRefTextField2 splitBy "_")[0] replace "[" with "" default "",
    column_5: (LineItem.LineProcessInfo.LineRefTextField2 splitBy "_")[1] replace "[" with "" default "",
    column_6: ????
    column_7: "",
    column_8: "",
    column_9: "",
    column_10: "",
})

forcolumn_6条件是 ifNoteType = MBNoteCode =05I 必须遍历每个注释文本和下面DistributionOrder [00000_8769_741_82_093_965_987_456],并且有 8[0 到 7] 个值用下划线分隔。我需要检查从 1 到 7 的值是否即将到来,然后如果值不为空,则将增量 01 分配给 07。如果其中一个值是空的,则跳过该数字分配下一个数字(例如,如果第 5 个值是空的然后跳过 05 并分配 06)。

4

1 回答 1

0

您的请求似乎是根据字符串增加计数器。似乎有点混乱。我会将其重新定义为计算非空值,该值由 CommentText 元素中的“_”字符分隔,该元素是一个字符串。

然后我将第 6 列表示为:

column_6: sizeOf( (DistributionOrder.Comment.CommentText splitBy  ('_')) filter (not isBlank($) ))

对于输入:

<CommentText>[00000_8769_741_82_ _ _987_456]</CommentText>

输出为 6。

于 2020-01-18T13:22:49.240 回答