简体   繁体   English

在映射中写入缺失值的 Java 代码 Informatica PowerCenter

[英]Java code to write a missing value in a mapping Informatica PowerCenter

I have a task to take a look in a database (SAP iDoc) that has specific values in it derived by segments.我有一项任务要查看一个数据库 (SAP iDoc),该数据库具有由段派生的特定值。 I have to export an xml at the end of the mapping that has a subcomponent that can have more than one row.我必须在映射结束时导出一个 xml,该 xml 具有一个可以有多行的子组件。 My problem is that we have a component that has two values that are separated by a qualifier.我的问题是我们有一个组件,它有两个由限定符分隔的值。

Every transaction looks like so:每笔交易看起来像这样:

+----------+-----------+--------+
| QUALF_1  | BETRG_dc  | DOCNUM |
+----------+-----------+--------+
|     001  |        20 | xxxxxx |
|     001  |        22 | xxxxxx |
+----------+-----------+--------+

+---------+-----------+-----------+
| QUALF_2 |  BETRG_pr |  DOCNUM   |
+---------+-----------+-----------+
|    013  |        30 |    xxxxxx |
|    013  |        40 |    xxxxxx |
+---------+-----------+-----------+

My problem is that when joined with the built in transformations we have a geometrical progression like so我的问题是,当与内置变换结合时,我们有一个像这样的几何级数

+---------+-----------+-----------+
| DOCNUM  |  BETRG_dc |  BETRG_pr |
+---------+-----------+-----------+
| xxxxxx  |        20 |        30 |
| xxxxxx  |        20 |        40 |
| xxxxxx  |        22 |        30 |
| xxxxxx  |        22 |        40 |
+---------+-----------+-----------+

As you can see only the first and last rows are correct.如您所见,只有第一行和最后一行是正确的。

The problem comes from the fact that if BETRG_dc is 0 the whole segment is not being sent so a filter transformation fails.问题来自以下事实:如果 BETRG_dc 为 0,则整个段没有被发送,因此过滤器转换失败。

What i found out is the the segment number of QUALF_1 and QUALF_2 are sequencial.我发现 QUALF_1 和 QUALF_2 的段号是顺序的。 So QUALF_1 is for example 48 and QUALF_2 is 49.所以 QUALF_1 是例如 48 而 QUALF_2 是 49。

Can you help me create a JAVA transformation that adds a row for a missing QUALF_1.你能帮我创建一个 JAVA 转换,为缺少的 QUALF_1 添加一行吗?

Here is a table of requirements:以下是要求表:

+-------+-------+---------------+
| QUALF | BETRG | SegmentNumber |
+-------+-------+---------------+
|   013 |    20 |            48 |
|   001 |   150 |            49 |
|   013 |    15 |            57 |
|   001 |   600 |            58 |
+-------+-------+---------------+

I want the transformation to take a look and if we have a source like this:我想看看转换,如果我们有这样的来源:

+-------+-------+---------------+
| QUALF | BETRG | SegmentNumber |
+-------+-------+---------------+
|   001 |   150 |            49 |
|   013 |    15 |            57 |
|   001 |   600 |            58 |
+-------+-------+---------------+

To go ahead and insert a row with the segment id 48 and a value for BETRG of "0".继续插入段 ID 为 48 且 BETRG 值为“0”的行。

I have tried every transformation i can.我已经尝试了所有可能的转变。

The expected output should be like this:预期的输出应该是这样的:

+-------+-------+---------------+
| QUALF | BETRG | SegmentNumber |
+-------+-------+---------------+
|   013 |     0 |            48 |
|   001 |   150 |            49 |
|   013 |    15 |            57 |
|   001 |   600 |            58 |
+-------+-------+---------------+

You should join both of the table in a joiner transformation.您应该在连接器转换中连接两个表。 use Left(master) outer join and then take it into a target.使用 Left(master) 外连接,然后将其带入目标。 then map the BETRG column from the right table to the target and the rest of the columns from the left table.然后将右表中的 BETRG 列映射到目标以及左表中的其余列。 what happens is when ever there is no match BETRG will be empty.发生的情况是,当没有匹配项时,BETRG 将为空。 take it into a expression and see if the value is null or empty and change it to 0 or what value you wish.将其放入表达式中并查看该值是 null 还是空并将其更改为 0 或您希望的值。

Here is what i have created but unfortunately for now it works on a row level only and not on the whole data.这是我创建的内容,但不幸的是,目前它仅适用于行级别,而不适用于整个数据。 I am working on making the code run properly:我正在努力使代码正常运行:

QUALF_out = QUALF;
BETRG_out= BETRG;
SegmentNumber_out= SegmentNumber;

  if(QUALF.equals("001"))
{
  segment_new=(SegmentNumber - 1);
}

int colCount=1;
myList.add(SegmentNumber);


System.out.println("SegmentNumber_out: " + segment_new);

if(Arrays.asList(myList).contains(segment_new)){
    QUALF_out = QUALF;
    BETRG_out= BETRG;
    SegmentNumber_out= SegmentNumber;    
    QUALF_out="013";
    BETRG_out="0";
    SegmentNumber_out=segment_new;
    generateRow();
    } else {
  QUALF_out = QUALF;
  BETRG_out= BETRG;
  SegmentNumber_out= SegmentNumber;    
  generateRow();
}

Here is what works:这是有效的:

import java.util.*;

private ArrayList<String> myList2 = new ArrayList<String>();

QUALF_out = QUALF;
BETRG_out = BETRG;
SegmentNumber_out = SegmentNumber;
DOCNUM = DOCNUM;

array_for_search = QUALF + ParentSegmentNumber + DOCNUM ;
myList2.add(array_for_search);

System.out.println("myList: " + myList2);
System.out.println("Array: " + myList2.contains("910" + ParentSegmentNumber + DOCNUM));

if(!myList2.contains("910" + ParentSegmentNumber + DOCNUM)){
        QUALF_out="910";
        BETRG_out="0";
}
    generateRow(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM