cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger an Alert if Flat file doesn't have records

manikandan_shanmugam3
Active Participant
0 Kudos

Hi All,

We are getting flat file(CSV) from third party system, First row will be a field names and other row are values.

Third party system may send flat file with no values but with field names in the first row, in such case we need to trigger an alert to concern parties.

Is there any way that I can fail sender channel and trigger an Alert for above case.

Regards,

Mani

Accepted Solutions (0)

Answers (2)

Answers (2)

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Manikandan,

Did you try the option validation by adapter option in the sender agreement/inbound processing.

manikandan_shanmugam3
Active Participant
0 Kudos

Hi Vishnu,

We need to maintain XSD at application server level for schema validation in-case any changes at fields, and need to connect to SFTP adapter but doing POC using FTP adapter now as SFTP server is not yet avaliable.

Regards,

mani

pvishnuvardan_reddy
Active Contributor
0 Kudos

Hi Manikandan,

I assume you will create DT for the structure in ESR.

So, can you try making the root node as 1 to unbounded and enabling the validation by adapter feature in sender agreeement and check the outcome.

former_member186851
Active Contributor
0 Kudos

Hello Manikandan,

You can make the fields name mandatory and fail it in the mapping if no value is coming and trigger an alert.

manikandan_shanmugam3
Active Participant
0 Kudos

Hi Raghuraman,

File will have field names always but I wanted it to fail at Sender adapter itself, any Idea on the same?

Regards,

Mani

vinaymittal
Contributor
0 Kudos

which version of SAP you are using what is the protocol NFS or FTP

vinaymittal
Contributor
0 Kudos

you can add a custom adapter module in the sender adapter

and have this code there for RFC lookup

for calling the ALERT function module as you can see in this link

Imports java.io.;com.sap.aii.mapping.lookup.;

//sample code for RFC loopup

java.util.Map map;

try {

String msgid;

map = container.getTransformationParameters();

msgid = (String) map.get(StreamTransformationConstants.MESSAGE_ID);

Channel channel = LookupService.getChannel("DE1CLNTXXX","CC_RFC_R_PI");

RfcAccessor accessor = LookupService.getRfcAccessor(channel);

String rfcXML= "<ns0:SALERT_CREATE xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\">"+

      "<IP_ALIAS/>"+

      "<IP_APPLICATION_GUID/>"+

      "<IP_CAT>ALERT_TEST_UDF</IP_CAT>"+

      "<IP_XML_CONTAINER/>"+

      "<IT_CONTAINER>"+

         "<item>"+

            "<ELEMENT>ZCUSTOMER</ELEMENT>"+

            "<TAB_INDEX>0</TAB_INDEX>"+

            "<ELEMLENGTH>20</ELEMLENGTH>"+

            "<TYPE>C</TYPE>"+

            "<VALUE>"+pnum+"</VALUE>"+

         "</item>"+

           "<item>"+

            "<ELEMENT>ZMSGID</ELEMENT>"+

            "<TAB_INDEX>1</TAB_INDEX>"+

            "<ELEMLENGTH>70</ELEMLENGTH>"+

            "<TYPE>C</TYPE>"+

            "<VALUE>"+msgid+"</VALUE>"+

         "</item>"+

      "</IT_CONTAINER>"+

    "</ns0:SALERT_CREATE>";

InputStream inputStream =new ByteArrayInputStream(rfcXML.getBytes());

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload rfcOutPayload = accessor.call(payload);

throw new  StreamTransformationException ( " Message Mapping Failed because of invalid Customer number");

}

catch(Exception e)

{

  throw new RuntimeException("Exception while checking for Distribution channel : "+e);

}

//*************************************************

creating custom adapter modules

Custom Adapter Module Development - SAP PI 7.1 - Netweaver Technology - SCN Wiki

in this link you can see how to raise exception to prevent the sender adapter from processing the message any further and how to create the function module and read the file

manikandan_shanmugam3
Active Participant
0 Kudos

Hi Vinay,

We need to connect with SFTP server but doing POC with file adapter as SFTP server is not avaliable.

Regards,

mani