cancel
Showing results for 
Search instead for 
Did you mean: 

Suppress IDOC if input value is blank

Former Member
0 Kudos

Hi All

We have a File to IDOC scenario.

It is a fixed length file.It contains 1 Header record with multiple line items.

if in Line item First 4 characters(field dealer) are blank then no IDOC should be created at ECC.

IDOC occurrence 0 to 1.

All the line items will be included in one IDOC.

Sample file

If file is as below IDOC should be created.This is working fine now.

Header:     WXYZ2016-08-19 0000000001                                   

Line Item:  ABCDL03000000523.8000000000010000523.8000000000010000000001MZ350004  

Requirement : if file is as below IDOC should not be created.

Header:     WXYZ2016-08-19 0000000001                                   

Line Item:       L03000000523.8000000000010000523.8000000000010000000001MZ350004  

Please help me on below questions:

1.When the occurrence is 0 to 1 can we suppress IDOC through mapping?

2.In receiver determination can we put a condition for not processing this file to ECC?

Thanks in advance!!

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Anitha,

Some comments:


1.When the occurrence is 0 to 1 can we suppress IDOC through mapping?

You mean there would be an idoc but no message type? Not sure what would happen.


2.In receiver determination can we put a condition for not processing this file to ECC?

This could work via the xpath function substring, but in your case since you are using multiline, there is a chance that some lines might have a value while others may not. If that happens, the message would still get created. Your best bet would be to use enhanced receiver determination.

Regards,

Mark

Former Member
0 Kudos

Hi Mark

Thanks!!

1. I mean no IDOC at all in ECC

2.As of now we see only one line item in file when dealer is blank.

So I provided below condition in RD.

But messages failing even when they have dealer value.

(/p1:MT_Indirect_Sales/Sales/Detail[substring(DEALER,1,2,3,4)!=''] EX )
markangelo_dihiansan
Active Contributor
0 Kudos

Here you go:

Here's the actual xpath for the left operand

contains(substring(/p1:MT_Indirect_Sales/Sales/Detail/DEALER[1],1,4),"    ")

Test1 (four spaces in front of L03)

Test2

Regards,

Mark

Former Member
0 Kudos

Thank you Mark will try this and confirm you back!!

former_member182412
Active Contributor
0 Kudos

Hi Anitha,

Input:

Try this XPATH expression in the receiver determination.

In the receiver determination select Ignore if No Receiver is found.

If you process the above file you will see the log below.

Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen and Mark

I tried both the conditions provided by you people.

but I am facing below error for both the conditions.

former_member182412
Active Contributor
0 Kudos

Hi Anitha,

Give me the input XML which you are testing??

Regards,

Praveen.

Former Member
0 Kudos

Hi Praveen

I am using Java mapping to convert fixed length file to XML.

So I am giving u input XML from mapping.

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

<ns0:MT_Indirect_Sales xmlns:ns0="urn:mmal.com.au:INT_689:Indirect_Sales">

   <Sales>

      <Header>

         <DISTR_HEADER>XXXX</DISTR_HEADER>

         <SALES_DATE>19.08.2016</SALES_DATE>

         <FILLER/>

      </Header>

      <Detail>

         <DEALER/>

         <VEH_GROUP/>

         <PRT_SLS_CODE/>

         <FILLER1/>

         </Detail>

   </Sales>

</ns0:MT_Indirect_Sales>

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Anitha,

Is it not possible for you to use FCC? Because in that case, our conditions in receiver determination will not work when the file is not yet XML (without FCC).

Regards,

Mark

Former Member
0 Kudos

Hi Mark

I used Java mapping because there is no constant value in input file(for FCC we must need some constant value to use as KEY field for Header and detail records). .

Finally we have decided to work with ABAP to have a batch job for collecting failed IDOCs with blank/invalid dealer and update them to have a status of No Further processing rather than suppressing at PI .

But I am interested to know for future use...why yours and Praveens XPATH conditions are not working for me .

Regards

Anitha

former_member190293
Active Contributor
0 Kudos

Hi Anitha!

In your case you could use extended receiver determination to set receiver in java code.

And your conditions don't work since you have flat file, not XML structure.

Regards, Evgeniy.

former_member190293
Active Contributor
0 Kudos

By the way, I'm not much experienced in FCC but It seems to me that in case of your file structure (one header line and multiple details) you don't need any keys. Try to set recordset structure as: Header,1,Details,* and set parameters for both recordsets. FCC should treat first line as Header and the rest lines as Details.

Regards, Evgeniy.

former_member182412
Active Contributor
0 Kudos

Hi Anitha,

You can do below approach.

Read the file line by line, use below FCC.

You will get the xml like below after FCC. You can see second line first 3 letters are blank.


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

<ns:FileSenderData xmlns:ns="http://mycompany.org">

  <Record>

  <Line>HH20160826</Line>

  </Record>

  <Record>

  <Line>   1000XYZ</Line>

  </Record>

  <Record>

  <Line>DEF2000PQR</Line>

  </Record>

</ns:FileSenderData>

You can use below condition in Receiver Determination.

In message mapping using one UDF you can map header and detail.

Execution Type : All Values Of Queue


public void mapHeaderDetail(String[] line, ResultList headerField1Res, ResultList headerField2Res, ResultList detailRes,

  ResultList detailField1Res, ResultList detailField2Res, ResultList detailField3Res, Container container)

  throws StreamTransformationException {

  boolean isFirst = true, isDetailFirst = true;

  for (int i = 0; i < line.length; i++) {

  if (!line[i].equals(ResultList.CC)) {

  if (isFirst) {

  isFirst = false;

  headerField1Res.addValue(line[i].substring(0, 2));

  headerField2Res.addValue(line[i].substring(2, 10));

  } else {

  if (isDetailFirst)

  isDetailFirst = false;

  else {

  detailField1Res.addContextChange();

  detailField2Res.addContextChange();

  detailField3Res.addContextChange();

  }

  detailRes.addValue("");

  detailField1Res.addValue(line[i].substring(0, 3));

  detailField2Res.addValue(line[i].substring(3, 7));

  detailField3Res.addValue(line[i].substring(7, 10));

  }

  }

  }

  }

Mapping Test:

Regards,

Praveen.

Answers (4)

Answers (4)

former_member187587
Contributor
0 Kudos

What is the buisness meanning of a line item in the file without the prefix charecters?

Former Member
0 Kudos

There is table in ECC which checks for valid dealer value.

If it is blank IDOC fails saying there is no input dealer.

So customer wants to suppress in PI itself rather than creating IDOC

former_member187587
Contributor
0 Kudos

So its a case when the item's dealer is not provided by the sender system in the file?

If you have an external data source where the dealers are valid and maintained by the item then you can implement an enrichment pattern and add it to the IDoc during mapping using lookup..

You do understand that the customer wants you to handle bad business logic in the PI...

This is a good recipe for bad solution.

former_member190293
Active Contributor
0 Kudos

Hi Anitha!

If I understand your requirement right you need to create one IDOC containing all line items with non-empty dealer field. Or not to create IDOC if there are no line items with dealer field.

Is it correct?

Regards, Evgeniy.

Former Member
0 Kudos

Hi Evigeniy

You are correct !! that is my requirement.

Regards

Anitha

former_member186851
Active Contributor
0 Kudos

Then you can try the UDF logic which I shared anitha.

former_member190293
Active Contributor
0 Kudos

Hi Anitha!

I guess that you use FCC to convert your flat file to XML and send it to ECC.

In receiver mapping you could just use condition to create IDOC node if that condition is true.

Regards, Evgeniy.

former_member190293
Active Contributor
0 Kudos

Here is an example of mapping to create IDoc if any of OrderID fields inside Order row isn't empty:

Regards, Evgeniy.

Former Member
0 Kudos

Hi Evgeniy

I tried placing creatif function.

It works fine when you test in mapping and shows like no IDOC created as output.

But if we test end to end message fails in PI.

SAP:Code area="IDOC_ADAPTER">ATTRIBUTE_IDOC_RUNTIME</SAP:Code>

  <SAP:P1>MSGGUID A8FA96338F7F491C0C3BABFE7A6DE0A9: Tag found instead of tag IDOC BEGIN=</SAP:P1>

  <SAP:P2 />

  <SAP:P3 />

  <SAP:P4 />

  <SAP:AdditionalText />

  <SAP:Stack>Error: MSGGUID A8FA96338F7F491C0C3BABFE7A6DE0A9: Tag found instead of tag IDOC BEGIN=</SAP:Stack>

  <SAP:Retry>M</SAP:Retry>

  </SAP:Error>

Output payload:

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

- <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

  <ns0:Message1 />

  </ns0:Messages>

I seached SDN for this error and they requested to import meta data gain.check occurrence and all...

All I did but still same error.

former_member186851
Active Contributor
0 Kudos

Anitha,

One more way could be using Suppress in the UDF.

UDF - Insert 'suppress' in the first context | SCN

Former Member
0 Kudos

Hi raghu

Thanks !!

But our scenario is different.Output IDOC can be 1 if file has dealers and 0(Suppress) when dealer is blank.

Harish
Active Contributor
0 Kudos

Hi Anitha,

1.When the occurrence is 0 to 1 can we suppress IDOC through mapping?

->> you can modify the message mapping occurance ot 0..1 and put the condition on message node (above IDOC node). The older version of PI does not support multi mapping with IDOC adapter but it will work with version later 7.31. If you are running on older version then refer the below blog to change the ESR

2.In receiver determination can we put a condition for not processing this file to ECC?

-->> You can put the condition in receiver determination as xpath query.

refer the below wiki for xpath query

Xpath Condition in Receiver Determination - Process Integration - SCN Wiki

regards,

Harish

Former Member
0 Kudos

Hi harish

Thanks for your reply!!

I gone through the links and exported IDOC structure to XSD and modified occurrence(0 to 1) then imported as ED and created new MM and IM.

I am stuck at IM.if we use new MM with ED then target of IM should be service Interface with ED(Idoc structure).so I have to modify receiver service interface in ID from IDOC(original) to SI with ED.

Pls correct me if wrong.

Cming to Xpath I have put condition like this.but not working.

(/p1:MT_Indirect_Sales/Sales/Detail[substring(DEALER,1,2,3,4)!='    '] EX )

Regards

anitha