BI Publisher条件字段屏蔽

时间:2019-01-29 16:18:01

标签: peoplesoft bi-publisher

我在Peoplesoft BI Publisher RTF模板的字段上具有以下代码,该代码掩盖了银行帐号的后4位。

<?xdofx:lpad('',length(Bank_Account__)-4,'*')?> 
<?xdoxslt:rtrim(xdoxslt:right(Bank_Account__,4))?>

问题在于有时银行帐户的总长度小于4位,并且这种情况发生时,会导致lpad函数出现负数组错误。

我可以在其中包裹某种条件IF语句吗,它会检查银行帐号的长度,并且如果它大于5位数字而不是最后4位数字的掩码,否则(对于小于5位数字的银行帐号) )只需掩盖后两位数字。会是什么样?

谢谢!

编辑:

我应该补充,上面的现有代码已经包装在以下IF语句中:

<?if@inlines:Bank_Account__!=''?>

所以整个语句是:

<?if@inlines:Bank_Account__!=''?>
    <?xdofx:lpad('',length(Bank_Account__)-4,'*')?> 
    <?xdoxslt:rtrim(xdoxslt:right(Bank_Account__,4))?>
<?end if?>

我只想添加条件逻辑来检查银行帐户长度,然后执行上述任一屏蔽操作。

编辑2: 这是我的设置,其中包含您建议的更改,但是我认为我的逻辑嵌套不正确,语法也可能是个问题。

enter image description here

修改3:

这是修改后的代码,以及产生的错误消息:

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:2)

if语句可以嵌套,但是由于BIP没有else子句,因此第二个if条件必须检查否定情况。

也许这可能有效:

<?if@inlines:Bank_Account__!=''?>
    <?if@inlines:string-length(Bank_Account__)>4?>
        <?xdofx:lpad('',length(Bank_Account__)-4,'*')?><?xdoxslt:rtrim(xdoxslt:right(Bank_Account__,4))?>
    <?end if?>
    <?if@inlines:string-length(Bank_Account__)<=4?>
        <?xdofx:lpad('','2','*')?><?xdoxslt:rtrim(xdoxslt:right(Bank_Account__,string-length(Bank_Account__)-2))?>
    <?end if?>
<?end if?>

更新:这是我得到的屏幕截图:

enter image description here

这是我使用的xml代码段。

<?xml version="1.0"?>
<root>
  <record>
    <Bank_Account__>123456</Bank_Account__>
  </record>
    <record>
    <Bank_Account__>12345</Bank_Account__>
  </record>
    <record>
    <Bank_Account__>1234</Bank_Account__>
  </record>
    <record>
    <Bank_Account__>123</Bank_Account__>
  </record>
    <record>
    <Bank_Account__>12</Bank_Account__>
  </record>
</root>

here下载工作文件

有些more functions可用于实现此要求的其他方式。

相关问题