on 02-19-2015 10:00 AM
I'm currently creating an two interfaces where files from Shipment Interface will wait until all Shipping Confirmation files are picked up and processed.
To do this, I'm maximizing Run OS Command Before Message Processing so that the Shipment Interface will check the Shipping Confirmation folder and temporarily sleep if it sees files there. My script is:
------------------------------
#!/bin/ksh
#
# Check first if there are existing SHPCON files. If there's none, process SHPMNT files.
#
file=$1
extension=$2
while [[ -f ${file}*${extension} ]];do
sleep 10
done
------------------------------
Sample input: ksh /util/bin/pi/file_check.ksh /sapin/DEV/ExternalParty/SHPCON/snd/ESRTP2SHPCON .xml
============================
Even if I remove the "extension" variable both in the script and as an argument, the logic still fails. However, when I use an absolute file name, the logic works.
So there might be another way of checking the file. I need the wildcard since the file name has a timestamp and, obviously, the file name is not the same always.
HELP!!!!
Since this query is script related, here is the working script. But, I am still considering the other suggestions posted here in this forum.
#!/bin/ksh
#
# Check first if there are existing SHPCON files. If there's none, process SHPMNT files.
#
filepath=$1
filename=$2
while [ -n "`ls -1 $filepath | grep $filename`" ]; do
sleep 10
done
Sample input: ksh /util/bin/pi/file_check.ksh /sapin/DEV/ExternalParty/SHPCON/snd ESRTP2SHPCON
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Two questions came to my mind:
1. How do you now an empty folder "/sapin/DEV/ExternalParty/SHPCON/snd/" means all confirmation files have been picked up? Couldn't it be the case that pickup has run and another confirmation was delivered after that?
2. If you know for sure that you may process the contents of the SHMPNT directory after SHPCON is empty you could change the process of SHPCON pickup to run a OS command AFTER the processing. Check in the script if SHPCON directory is empty. If so, rename file in SHPMNT directory or move file to a subdirectory. Change target file schema / directory of SHPMNT pickup process accordingly to match the then renamed or moved SHPMNT file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1. Both SHPCON and SHPMNT files are placed in their respective folders every five minutes. Should there be any new transactions, it won't come after that five minutes. That's why in the script, I only let it sleep for 10 seconds. I just need to delay the processing of SHPMNT files up until the SHPCON folder is cleared.
2. The files come from an external party and has already agreed to a naming convention. We're already in the middle of testing and that's why we're minimizing the changes to the solution. Hence this "delay" in SHPMNT processing.
Hi Jan,
Have you tried with the option -e ?. It seems to be less restrictive Bash Shell: Check File Exists or Not
Regards.
Hi Jan,
I agree with Jens Schwendemann the solution doesn't seem to be the better. You have another options, avoiding shell script usage, its maintenance can be difficult with the time. You could do a file lookup in the confirmation scenario to take the second file, even to use the logical positive and to ask in the second scenario if the first file is deposited in archive to continue. I'm sure you can find more different solutions if you ask in this forum.
From my own PI experience, sometimes it's better to wait more time in the develop process because the consequences in the maintenance can be worst.
Regards,
Hi Jan,
I assume the next in your scenario:
1. It is File - (Proxy or RFC or IDOC, any kind of ERP destination)
2. If the shipment confirmation file is deposited the shipment file must be deposited as well.
You can do a sender file that polls for the shipment confirmation. The sender file adapter takes the file, at mapping level you pick up the shipment file with an UDF: File Lookup in UDF - Process Integration - SCN Wiki. You can do any conversion with the file taken and to generate in the UDF or a Java Mapping the outstream desired to do a second mapping to get the XML needed to be sent to the ERP destination.
If my second supposition is wrong, the scenario can be more complicated. However in your ERP you can do a job/or simple report that starts a channel to take second file: . Why a job or simple report?, if the second file is not present you can try n times to start the sender file channel to pick up the file or a job that n minutes check what confirmations are arrived and try to take the second file.
Hope this helps.
Regards.
Hi Jan,
Have you used in PI the variables %f or %F for the file or the absolute path instead of $1 and $2?.
Defining Operating System Commands Before/After Processing - Advanced Adapter Engine - SAP Library
Regards.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.