cancel
Showing results for 
Search instead for 
Did you mean: 

Suppressing an optional node using Message Mapping

Former Member
0 Kudos

Hi mates,

I've an optional node (occurrence 0..1) in my target structure under which there are mandatory elements (occurrence 1..1). I've a UDF which returns ResultList.SUPPRESS or "" (empty string) based on a condition mapped to this optional target node. UDF is behaving similar to std function 'createIf' but based on a condition..

when i look at the queue in data flow editor...I see the value 'SUPPRESS' for the target node queue...mapping for this is successful..but when I execute the whole mapping in the 'test' tab...mapping terminates with the error <i>'Cannot produce target element /ns0:Messages/ns0:Message1/ns1:MT_SFE_DATA. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd'</i>

I'm puzzled as why the runtime is complaining abt not producing an option field? Am I missing or doing something wrong here? When I disable the this target optional node in the mapping...the rest of the mapping is successful in the test tab...I appreciate ur help in resolving this...

thx

praveen

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi mates,

I've found a work around for my problem...

My problem in brief..I get an error if I try to suppress an optional node/element using stad node function createIf or any simple UDF which returns ResultList.SUPPRESS

Work-around...I've an adv UDF which produces result queue. In case I need produce a node/element I add empty string ("") to the result queue. In case I need to suppress a node/element, I do nothing, instead of adding ResultList.SUPPRESS

Henrique...thanks & points for your hint...to use an adv UDF..

praveen

Former Member
0 Kudos

Hi;

Instead of making MT_SFE_DATA node as optional try to make the insert node optional and place the condition on that.

Mudit

Former Member
0 Kudos

Mudit,

I tried suppressing the optional elements other than root node...still the same error...infact I tried the std node function 'createIf' in a simple 1-1 message mappign and it fails...I'm on SP17..I wonder if anyone is able to execute mappings with creatIf on SP17 successfully.

thanks for your inputs..

praveen

Former Member
0 Kudos

Hi Praveen

As this node is optional, if there is no source data coming then it will not generate this target node. Is this UDF really required ?

Regards.

Former Member
0 Kudos

Mugdha,

Generating/suppressing the target node is based on a condition...not just 1-1 mapping from source node...hence the UDF..read my scenario above..

anyways..thanks for your time..

praveen

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Praveen,

Can you tell how you did the mapping..

Did you do the mapping with node level or field level where the UDF is used?

Regards,

sridhar

Former Member
0 Kudos

Sridhar,

I used the UDF for the node MT_SFE_DATA. Look at the message structures above...

praveen

ravi_raman2
Active Contributor
0 Kudos

Alright this seems to be an xml:xsd issue, can you please validate the xml using the xsd and see if schema validation passes..?

Regards

Ravi

Former Member
0 Kudos

Ravi,

For some inputs I'm able to execute the mapping successfully...the error occurer in case the "optional node" is suppressed...

if the XML is not valid for given XSD...it errors in test tab even before we click on execute button..

praveen

henrique_pinto
Active Contributor
0 Kudos

Hey Praveen,

how come your root tag is optional?

That logic you implemented would work for normal optional fields inside the xml message, but not for the root tag.

Regards,

Henrique.

Former Member
0 Kudos

Henrique,

My scenario is this...for the field 'Business_unit' in source message I do a value lookup from another DB and get the look up vlaue 'MSA No'. For some reason, if I cant get MSA No for a Business_unit I need to mark it as error otherwise I need to update the entry into target system database.

In the best case, I'll find MSA No for all Business units in the source...then the message type for errors (MTSFE_ERRS) should not be created...to avoid creating a blank error report..

In the worst case, I'll not find MSA No for not even a single Business_unit, in that case message type for data (MT_SFE_DATA) should not be created.. to avoid attempt insert blank records..

I'm using this mapping in enhanced ID which dynamically produces the corresponding messages..

I guess the scenario is clear now...

Using the createIf for other elements than the root, its the same fate..it errors out..infact I tried the standard node function 'createIf' for an optional element..still it fails...I'm on SP17..I'm not sure if the problem is related to SP level...anyone able to execute mapping with 'createIf' on SP17 successfully?

thx for your time

praveen

henrique_pinto
Active Contributor
0 Kudos

The createIf function works alright.

Is your UDF of queue type?

Could you post the code, so that we can analyze it?

Also, this should be a multi mapping and the target node should be able to assume 0...unbounded occurrence.

Regards,

Henrique.

Former Member
0 Kudos

In the process of analyzing the error, I tried using the standard createIf function and it gives the same error in 'test' tab and 'SUPPRESS' in the data flow editor queue.

why should all multi mappings be 0...unbounded occurrence? anyways...I tried with that as well...same error...it doesnt help

praveen

henrique_pinto
Active Contributor
0 Kudos

If your udf is not queue, the supress entry may be badly interpreted.

Hows ur udf?

Regards,

Henrique.

Former Member
0 Kudos

Henrique,

I'm not using UDF in the mapping. I'm using the std 'createIf' function. I'm getting errors in this case as well....if you are SP17...can you check if std node function createIf is working?

thanks

praveen

justin_santhanam
Active Contributor
0 Kudos

Praveen,

If its possible can you paste the source & target messages, it could be easier to analyze.

Best Regards,

raj.

Former Member
0 Kudos

Raj,

Here is my source msg structure

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

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
   <ns0:Message1>
      <ns1:MT_PSHR_DATA xmlns:ns1="http://xyz.com/pshr">
         <row>
            <EMPLID/>
            <FIRST_NAME/>
            <LAST_NAME/>
            <MIDDLE_NAME/>
            <BUSINESS_UNIT/>
            <JOBCODE/>
            <TITLE/>
            <EMPL_STATUS/>
            <JOB_ENTRY_DT/>
            <ADDRESS1_2/>
            <ADDRESS2_2/>
            <CITY2/>
            <STATE2/>
            <POSTAL2/>
         </row>
      </ns1:MT_PSHR_DATA>
   </ns0:Message1>
</ns0:Messages>

Target structure

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
	<ns0:Message1>
       		<ns1:MT_SFE_DATA xmlns:ns1="http://xyz.com/pshr">
             		<Insert>
                  			<SE_REPS action="INSERT">
					<table/>
					<access>
						<REP_NO/>
						<REP_NM/>
						<ADDRESS_1/>
						<ADDRESS_2/>
						<CITY_NM/>
						<STATE_CD/>
						<POSTAL_CD/>
					</access>
				</SE_REPS>
				<SE_REP_JOBS action="INSERT">
					<table/>
					<access>
						<REP_NO/>
						<FAC_IDU/>
						<JOB_CD/>
						<JOB_TITLE/>
						<EMPL_STATUS/>
						<EFFECTIVE_DT/>
					</access>
				</SE_REP_JOBS>
			</Insert>
		</ns1:MT_SFE_DATA>
	</ns0:Message1>
	<ns0:Message2>
		<ns1:MT_SFE_ERRS xmlns:ns1="http://xyz.com/pshr">
			<header>
				<title/>
				<row_count/>
			</header>
			<row>
				<rep_no/>
				<fac_idu/>
				<error/>
			</row>
		</ns1:MT_SFE_ERRS>
	</ns0:Message2>
</ns0:Messages>

This mapping is to be used in enhanced ID where it dynamically produces Msg types MT_SFE_DATA & MT_SFE_ERRS.

Mappign runtime errors out though the node MT_SFE_DATA is optional.

thanks

praveen