用于从json到xml映射逻辑的groovy脚本。

2020-09-01 04:03发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


专家们,

在SAP CPI中,我遇到了来自源有效负载的混合xml和json格式的问题,而且我还必须将多个联系人详细信息发送到目标IDoc(Json格式)。

建议我1)如何在特定的映射逻辑中将json转换为xml和

2)如何将多个联系人详细信息从源发送到目标。

请找到以下收入有效载荷。

<?xml version =" 1.0" encoding =" UTF-8"?> jk6ABmagsb8NCkamj 20795738 < ACC_ZZ_PNUMBER__c/> [{" ContactPerson":{" CON_MOB_NUMBER__c":" 8888888888"," CON_NAME1__c":" Raja"," CON_TEL_NUMBER__c":" 2222222222"," CON_NAMEV__c":" Raghu"," CON_Funtion__ CRM-2536528"," CON_INDICATOR__c":" 009"}},{" ContactPerson":{" CON_MOB_NUMBER__c":" 9999999999"," CON_NAME1__c":" Ramu"," CON_TEL_NUMBER__c":" 5555555555"," CON_NAMEV__c":" Dileep"," CON_Funtion__c":" CRM-2536530"," CON_INDICATOR__c":" 009"}}]

请帮帮我。

(43.3 kB)

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


专家们,

在SAP CPI中,我遇到了来自源有效负载的混合xml和json格式的问题,而且我还必须将多个联系人详细信息发送到目标IDoc(Json格式)。

建议我1)如何在特定的映射逻辑中将json转换为xml和

2)如何将多个联系人详细信息从源发送到目标。

请找到以下收入有效载荷。

<?xml version =" 1.0" encoding =" UTF-8"?> jk6ABmagsb8NCkamj 20795738 < ACC_ZZ_PNUMBER__c/> [{" ContactPerson":{" CON_MOB_NUMBER__c":" 8888888888"," CON_NAME1__c":" Raja"," CON_TEL_NUMBER__c":" 2222222222"," CON_NAMEV__c":" Raghu"," CON_Funtion__ CRM-2536528"," CON_INDICATOR__c":" 009"}},{" ContactPerson":{" CON_MOB_NUMBER__c":" 9999999999"," CON_NAME1__c":" Ramu"," CON_TEL_NUMBER__c":" 5555555555"," CON_NAMEV__c":" Dileep"," CON_Funtion__c":" CRM-2536530"," CON_INDICATOR__c":" 009"}}]

请帮帮我。

(43.3 kB)
付费偷看设置
发送
2条回答
樱桃小丸子0093
1楼 · 2020-09-01 04:38.采纳回答

Hello Satya,

请在下面的两个xslt映射中使用以获得所需的输出(您可以在第二个XSLT之后进一步优化输出)。

XSLT 1:

 <?xml version =" 1.0" encoding =" UTF-8"?>
 
 
 
 
 
 
 
 
 
 
 
 

XSLT 2:

 
     

     
       
         
       
     

     
         
             
         
     
 
 

输出:

 <?xml版本=" 1.0"编码=" UTF-8"?>
 <通知>
 <数据>
  jk6ABmagsb8NCkamj 
 <有效载荷>
  20795738 
 
 
 
 <地图>
 
  8888888888 
  Raja 
  2222222222 
 拉古
  CRM-2536528 
  009 
 
 
 <地图>
 
  9999999999 
 拉姆
  5555555555 
  Dileep 
  CRM-2536530 
  009 
 
 
 
 
 
 
 

问候,

Sriprasad Shivaram Bhat

huskylover
2楼-- · 2020-09-01 04:38

嗨,Sirprasad,

感谢您的帮助。

我们可以在同一个XSLT映射中添加另外两个字段(例如Contacts__c ..),因为,有时在缺少的源有效负载中,我们将得到,而如果没有此信息,我们将得到。 因此,现在我已经将包含Json结构的有效负载中存在的所有这些字段转换为XML。

下面是两个有效载荷示例,

<?xml版本=" 1.0"编码=" UTF-8"?> jk6ABmagsb8NCfdjbn 20795777 < ACC_ZZ_PNUMBER__c/> [] [] [{" CreditControlArea":{" CREDIT_CTLPC_c":null," CREDIT_DBEKR_c":null," CREDIT_DBPAY_c" CREDIT_KKBER_c":" 1000"," CREDIT_KLIMK_c":500," CREDIT_CRBLB_c":false}}]

--------------------------------------------------- -------------------------------------------------- -------------------------------------------------- --------------

<?xml版本=" 1.0"编码=" UTF-8"?> jk6ABmagsb8NCdfcgjm 20795888 < ACC_ZZ_PNUMBER__c/> <联系人__c> [] <联系人__c/> [] [{" BankDetails":{" BANK_BANKS_c":" SE"," BANK_IBAN_c":null," BANK_BANKL_c": a0s4E000000Fdv5QAC"," BANK_BVTYP_c":null," BANK_BANKN_c":" 11224455"}}]

请执行Needfull。

一周热门 更多>