cancel
Showing results for 
Search instead for 
Did you mean: 

How to ignore the header record in every line item using FTP receiver with apend option

former_member441596
Participant
0 Kudos

Hi Team,

I have requirement number IDOCs processed to single flat file using receiver FTP ....

In this case have configure the scenario and using FTP receiver communication channel wrote content conversion with "apend" option using dyanamic file name....

I am getting output every idoc is mergered and processed single flat file...

Using content conversion as below:

Getting output:


Below circle recorder are header information....each header under having data record...

Business requirement :Required output:



Request you please suggest how to how to ignore every header record from output generated file..

Thanks & Regards,

Naidu

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member190293
Active Contributor
0 Kudos

Hi Varri!

Another option is to use "Run Operation System command before message processing" setting. You can use OS script to create new file with header line if it does not exist in target folder. And not to send header line in your message at all.

Regards, Evgeniy.

former_member441596
Participant
0 Kudos

Hi,

What command i have to maintained "Run Operation System.."

Please suggest me...

nitindeshpande
Active Contributor
0 Kudos

Hi,

What is the OS of your SAP PI system? Unix or Windows? If unix you need to write the shell script and for Windows you need to write a batch script.

And this script must be called from your File sender channel.

Please follow the below Wiki and help.sap for writing these scripts.

https://help.sap.com/saphelp_nw74/helpdata/en/44/556cb799c93677e10000000a114a6b/content.htm

SAP XI File Adapter OS Command Line Feature - Process Integration - SCN Wiki

Regards,

Nitin

former_member190293
Active Contributor
0 Kudos

Hi Varri!

I think that the better way in your case is using java UDF in your message mapping that checks if file exists on FTP server and adds header line in your message when result is negative.

You can use Apache Commons Net library for that:

void connect(String hostname, int port, String username, String password) throws SocketException, IOException {

ftpClient = new FTPClient();

        ftpClient.connect(hostname, port);

        returnCode = ftpClient.getReplyCode();

        if (!FTPReply.isPositiveCompletion(returnCode)) {

            throw new IOException("Could not connect");

        }

        boolean loggedIn = ftpClient.login(username, password);

        if (!loggedIn) {

            throw new IOException("Could not login");

        }

        System.out.println("Connected and logged in.");

    }

boolean checkFileExists(String filePath) throws IOException {

        InputStream inputStream = ftpClient.retrieveFileStream(filePath);

        returnCode = ftpClient.getReplyCode();

        if (inputStream == null || returnCode == 550) {

            return false;

        }

        return true;

    }

Regards, Evgeniy.

Ryan-Crosby
Active Contributor
0 Kudos

Hi Naidu,

Probably the easiest thing to do is to package the IDocs so that you send one message instead of many individual messages.  If you package so the sender is one larger message then you will get only one header.

However, if you must continue to send separately then you handle it with two ICOs... the first one to merge the data into one file and the second to take the file and add the header to the final destination.  The drawback to such and approach is that you would have to double dip on the FCC for the receiver and also add FCC for the second sender.

Regards,

Ryan Crosby

former_member441596
Participant
0 Kudos

Hi Ryan,

I am using dual stack PI 7.4 and already implemented package IDOC in SAP ECC but in our PI side i has received one one IDOC..

So finally i am near to requirement but header is repeated for every one...i populate first IDOC header  and remaining IDOC data should be populated.

Thanks & Regards,

Naidu

Ryan-Crosby
Active Contributor
0 Kudos

Hi Naidu,

I'm not following based on your description - for example, if you have 50 IDocs that need to go out how many messages are you seeing in your monitoring?  If you are getting 50 messages which is what I would expect based on what you have described then you are not getting packaging such that the IDocs are grouped as one message.

Regards,

Ryan Crosby