cancel
Showing results for 
Search instead for 
Did you mean: 

Sender file adapter - check files before transmission to PI

christian_pichler
Participant
0 Kudos

Hello!

Our partner puts 2 files on a ftp server:

123.txt

123.pdf

Our goal is only to transmit the files if both files (same filename with extensions .txt and .pdf) are available. Sometimes the printed version (.pdf) is available later and then the .txt file should not be pulled as long as the .pdf is not available.

Does anyone know how to solve this problem?

Thanks in advance for your help!

Best regards

Christian

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Christian

The general idea provided by the rest above to use "Additional files" feature is the right direction.

However, if you need the .txt files to be picked up ONLY when the .pdf is present, I would suggest the configuration below:-

i) Set *.pdf as the filename mask for files to pick up

ii) Set .txt as the additional file to pick up optional = NO

This is because the PDF comes later, so it should be the "trigger" file that initiates the pick up of both files.

Additionally, for this approach, if you want to just transmit the .txt file to the end location (you did not mentioned where it's going - file, proxy, idoc, etc), you will need to use PayloadSwapBean to swap the .txt file into the main payload.

There are some screenshots for such configuration in my article below. The article is for a different requirement, but the screenshots relevant to your case is in Scenario 2 section.

Rgds

Eng Swee

christian_pichler
Participant
0 Kudos

Hi Eng Swee,

I think that this option is only available for NFS. We have to access a ftp server.

Regards

Christian

engswee
Active Contributor
0 Kudos

Yes, you are right, it's only for NFS on the File adapter.

It is also available on the SFTP adapter. Maybe you can check with the FTP admin if their server also supports SFTP access as it is quite common to support both FTP and SFTP on the same server.

christian_pichler
Participant
0 Kudos

SFTP is also not supported in our version I think PI 7.11 SP11 is needed for SFTP, we are running on 7.10. SP14

engswee
Active Contributor
0 Kudos

Hi Christian

Another alternative approach for you to consider since you won't be able to use SFTP.

Have a two step scenario:

Scenario 1 - pick up ALL files from FTP and deposit them into a temporary NFS location

Scenario 2 - use sender File adapter with NFS protocol to pick up the pdf and addition txt file.

This way you can use the additional files functionality in the sender NFS channel.

You still have not mentioned what is the intended target. Note that File (FTP/NFS) receiver adapters do not support attachments in case you need to deliver both files to the final destination.

Rgds

Eng Swee

christian_pichler
Participant
0 Kudos

Hi Eng Swee,

that's exactly the scenario I created yesterday!

Now I have to find a way that the 2 files are processed properly. One is a PDF which should only be forwarded to another server without any conversion, the second file (.txt) is a EDIFACT message which has to be converted to an IDoc. In worst case I will add a scenario 3 with 2 sender channels, one for each file.

I am also searching for a way to get rid of the error messages if the second file is missing. This situation can last for days and it would be very annoying to receive error messages all 15 minutes.

Best regards

Christian

engswee
Active Contributor
0 Kudos

Hi Christian

For the forwarding part to different destinations, you can try the following approach:

i) Sender NFS channel picks up PDF file and have additional files setting for TXT file. PayloadSwapBean is set in sender module chain to swap TXT file to the main payload

ii) Have 2 unconditional receivers in receiver determination - one for PDF target server, another for IDoc backend receiver. It will cause a message split with both messages having 1 main payload and 1 attachment.

iii) For PDF receiver, no mapping necessary and just send to the receiver file/FTP channel. At the receiver channel, use PayloadSwapBean to swap back the PDF file to the main payload.

iv) For the EDIFACT/TXT file, map as normal to IDoc target.

The second part of your query regarding the error messages will depend on the sequence of the files. Will the files always come in a particular sequence (irrespective of the delay between their arrival), i.e. TXT file first, followed by PDF file? If yes, then setting the file mask to pick the one that arrives later will work, i.e. the TXT file will just sit there without causing any errors until the PDF finally arrives.

If there is no guaranteed sequence, then it is more challenging - might need to think a bit more on that.

Rgds

Eng Swee

christian_pichler
Participant
0 Kudos

Hi Eng Swee,

thanks for your help!

Regards

Christian

christian_pichler
Participant
0 Kudos

Hi Eng Swee,

do you have an idea how to keep the original filename

1. of the EDIFACT message until it is mapped (the filename is used in the mapping) and

2. of the PDF file until it is written to the destination server (the PDF must keep/get its original name)

Thank you!

Regards

Christian

engswee
Active Contributor
0 Kudos

Hi Christian

For the first scenario (pick up all files and store in NFS), set ASMA for FileName at both sender FTP and receiver NFS channel.

For the second scenario, set ASMA for FileName as sender NFS channel.

1) Since the PDF is the main file being picked, the FileName will contain the PDF filename, in your EDIFACT mapping, just change the extension from .pdf to .txt

2) No changes here, just set ASMA for FileName at receiver channel.

Let me know if you need further information.

Rgds

Eng Swee

christian_pichler
Participant
0 Kudos

Hi Eng Swee,

thanks a lot for your help!

I have a problem with the PayloadSwapBean. If I configure the CC like you mentioned the payload isn't swapped and the system tries to convert the PDF file with the EDIFACT-/IDoc conversion:

"Additonal file" is the EDIFACT file. So I set it swap.keyValue:

If I check it in SXMB_MONI I can see that the MainDocument is the PDF file and the Additonal File is the E2X converted EDIFACT file:

Do I use a wrong setting in the PayloadSwapBean?

Thank you!

Best regards,

Christian

former_member182412
Active Contributor
0 Kudos

Hi Christian,

Please use below values.

swap.keyName = payload-name

swap.keyValue = .txt

Regards,

Praveen.

christian_pichler
Participant
0 Kudos

Hi Praveen,

If I am using these settings the system still tries to convert the PDF file.

Regards,

Christian

former_member182412
Active Contributor
0 Kudos

Hi Christian,

Did you enable ASMA attributes and selected the file name attribute?? in your screen shot i see the payload names are MainDocument and AdditionalFile, so try below values and let me know.

swap.keyName = payload-name

swap.keyValue = AdditionalFile

Regards,

Praveen.

christian_pichler
Participant
0 Kudos

Hi Praveen,

thanks for your reply.

At the moment I am using the following configuration:

Regards

Christian

engswee
Active Contributor
0 Kudos

Hi Christian

From the logs, looks like the swap and subsequent BIC conversion is successful. Hope this settles all your issues for this requirement.

Rgds

Eng Swee

christian_pichler
Participant
0 Kudos

Hi Eng Swee,

now everything is working properly!!! The EDIFACT file is converted and the PDF file is transfered 1:1 to the destination with the original filename.

THANKS A LOT for your kind help!!!

Have a nice day,

Christian

engswee
Active Contributor
0 Kudos

Brilliant! Really glad to hear that all is working well!

Answers (2)

Answers (2)

engswee
Active Contributor
0 Kudos

Hi Christian

It's getting a bit hard to see the replies as they are being squeezed so I'm replying under the main question instead.

Try following the setup in my blog instead.

Instead of CSV in the screenshot below use TXT, and in the SwapBean, swap by Payload-Name with value of TXT.

Rgds

Eng Swee

engswee
Active Contributor
0 Kudos

Christian

If your tried my approach above and still does not work, can you provide screenshot of the audit log when the swap module is being executed?

If it is executed correctly, you should see the audit log as shown in the screenshot on my answer to the thread below.

Rgds

Eng Swee

Former Member
0 Kudos

Thanks Eng Swee,

Just want to know if you have any suggestion when the txt and pdf files don't come in a particular sequence?

engswee
Active Contributor
0 Kudos

Hi Hailong

Unfortunately, just with that information, I don't have any suggestion as the above approach would not work.

If you have more information on the actual scenario, I suggest that you open a new thread and provide as much information as possible. Then maybe the forum members will be able to come up with some suggestion specific to your scenario.

Rgds

Eng Swee

christian_pichler
Participant
0 Kudos

Hi Hailong,

the scenario would also work. The only problem is that you will receive an error message every time the system tries to poll the message. E.g. if in my scenario the PDF file would be available before the .txt file the system generates an error message because the mandatory "first" file is missing.

If you find a way to get rid of the error message my/Eng Swees solution should meet your expectations too.

Regards

Christian

engswee
Active Contributor
0 Kudos

I haven't gotten around to try it but I think if the channel goes into error because of the missing file, it might end up blocking other files from being picked up until the error is resolved.

Former Member
0 Kudos

You are right Eng Swee, the missing file will block other files to be processed until the error is resolved.

Former Member
0 Kudos

Hi Christian,

Assuming you're sending the .pdf files just as attachment, you can use 'Additional File' feature available for Sender File Adapter. Here's the help document for the same.

You can set <Additional FileN>.optional as 'NO' to trigger errors, if files are not present.

Hope this helps.

PS. Don't forget to give points.

Regards

Bibek

christian_pichler
Participant
0 Kudos

Hi Bibek,

thanks for your reply!

What do you mean with ".pdf files just as attachment"? We have 2 files on the server with the same filename (the filename is unknown) and a different extension (.txt and .pdf).

Could you please verfiy the link you sent in your posting? The target isn't accessible.

Thank you!

Regards

Christian

giridhar_vegi
Participant
0 Kudos

Hi christian,

                    it can be achieved by specifying  the property of waiting time in communication channel in advanced tab.

Thanks

Giridhar

former_member182412
Active Contributor
0 Kudos

Hi Christian,

Check Q4 in below WIKI.

Sender File Adapter Frequently Asked Questions - Process Integration - SCN Wiki

Regards,

Praveen.

Former Member
0 Kudos

Hi Christian,

I mean you're only processing(i.e. xml conversion and mapping) the .txt file and the .pdf file is to be sent as it is without any conversion or so.

The link is working fine for me. Anyways you can check here : https://help.sap.com/saphelp_nw73/helpdata/en/44/692ab8a4b633eae10000000a1553f6/content.htm

Regards

Bibek

christian_pichler
Participant
0 Kudos

Hi Giridhar,

thanks for your reply!

In our case the sender file adapter should check all 15 minutes if there are files available. If both files are available they should be transferred. If only one one the files is available nothing should be transfered.

As we do not know when the second file is available (could also be days later) we can't set a value for the waiting time.

Regards

Christian

christian_pichler
Participant
0 Kudos

Hi Praveen,

thanks for your reply.

I do not have the option which is needed for Q4:

Regards

Christian

christian_pichler
Participant
0 Kudos

Hi Bibek,

I think that this option is only available for NFS. We have to access a ftp server.

Regards

Christian

former_member182412
Active Contributor
0 Kudos

Hi Christian,

You can configure the channel like below then if both files available then PI will pick up otherwise PI wont pick up it will raise an error saying that the second file is not available.

The first file will be main payload and second will be the attachment to the main payload, what is the receiver adapter in your case?

Sender Channel :

Receiver Channel:

By using store attachments i have written main payload and attachment in the target directory. I used SFTP adapter.

Regards,

Praveen.

christian_pichler
Participant
0 Kudos

Hi Praveen,

thank you for the screenshots!

I think that this option is only available for NFS. We have to access a ftp server.

Regards

Christian