cancel
Showing results for 
Search instead for 
Did you mean: 

Need to pick .TXT file only if .CTL file is available

sridharreddy_kondam
Active Contributor
0 Kudos

Hi All

I need some inputs and thoughts from you all,

I will explain you the scenario, The scenario is like this FTP (File1.txt, File2.ctl)--> PI -->SAP(Idoc)

--> Two files one File1.txt and another File2.ctl should be picked from PI and send to SAP (IDOC) which

{ --> .txt contains all the data (TXTVYYYYMMDDHHMMSS.txt)

And

--> .ctl is an empty file (CTLYYYYMMDDHHMMSS.ctl)

}

-->File2.ctl* file will be created only after the File1.txt file has been created in FTP serveru2026

-->.ctl file concept is that PI should start processing .txt file only after if .ctl file is created/available then only it has permission to read the .txt file other wise the .txt file should not be processed

Please help me in achieving this.

Thanks and Regards,

Sridhar Reddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey

Since we can't have dynamic names in sender file adapter,it will be really complicated to implement this in XI.

We has the same requirement but we asked the sender application system to write the file in a temporary format like .dat and then once the file is completely written,rename it to .txt format.

The sender file adapter will pick only *.txt files.

Thanx

Aamir

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Aamir,

Thanks for your reply...

Can we achieve this using shell script using "Operating System Command". in the sender file adapter ...?

Or should there is any other Logic to handle that before i question my client and ask about the logic you have mentioned...

Regards,

Sridhar Reddy

Former Member
0 Kudos

Hey

well we looked at lots of options like scripts and controlling adapters externally but the problem we faced was that since the file name in sender adapter can't be dynamic we were unable to handle it in XI.

The best solution which came from SAP was to tweak the sender application system itself.

If you come up with a better solution,please update us:)

Thanx

Aamir

Former Member
0 Kudos

Please have a look at the below thread

It discuss same issue as yours but the solution is to use Java proxy.

Thanx

Aamir

Answers (10)

Answers (10)

sridharreddy_kondam
Active Contributor
0 Kudos

Handled Shell scripts at the FTP server and scheduled

Former Member
0 Kudos

Hi,

You can try using enhancement module in sender file adapter, so the file adapter only monitoring .ctl file and the enhancement module will get the original data (.txt) base on the .ctl filename and replace the main content of the message.

you will get the .txt content for further processing. just need little bit java programming to build enhancement module.

Best Regards

Fernand

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Fernand,

Thanx for the reply,

Can you please let me know which one is better in implementing

1.

Should i use the Operating System Command and write shell script as suggested

like this if exist c:\src\abc.ctl copy c:\src\abc.txt c:\dest

2.

Or should i go the way you suggested...

Thanks and Regards,

Sridhar Reddy

Former Member
0 Kudos

Hi Sridhar,

Now I got same requirement. Could you please let me know how you approached on this requirement. Either used Shell Script or followed any other way.

Advance Thanks & Regards,

Nageswari.P

Former Member
0 Kudos

Is your problem solved...

If yes then let your solution to known to everybody so that in future someone may get help from this..

Thanks,

JAY

Edited by: JGD on Sep 15, 2008 7:00 AM

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Jay,

I am just checking whether the shell script as suggested works fine or not...

Once done then i will close and give the solution which helped me...

Regards,

Sridhar

former_member181985
Active Contributor
0 Kudos

Hi Sridhar,

Hmm......looks complicated.

What I understood is this;

In FTP direcoty, there will control file(.ctl) & its corresponding data file for IDOC (.txt). They are unique and can be identified by DateTimeStamp format for the logic which should be implemented.

The control file will be only triggering point for your scenario i.e., it has nothing to do with application for posting data to IDOC.

First let me know if my understanding is correct for your requirement.

Thanks,

Gujjeti.

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Praveen,

-


In FTP direcoty, there will control file(.ctl) & its corresponding data file for IDOC (.txt). They are unique and can be identified by DateTimeStamp format for the logic which should be implemented.

-


Yes Praveen the control file(.ctl) and data file (.txt) file will have the file name like this

ADMYYYYMMHHSS.txt

ADMYYYYMMHHSS.ctl

.txt file has to be picked up only if .ctl file is found/available on the FTP server and then only ADMYYYYMMHHSS.txt file has to be sent to SAP(IDOC)

Regards,

Sridhar Reddy

former_member181985
Active Contributor
0 Kudos

Hi Sridhar,

May be it is one of the possible solutions.

Use File Adapter with correct FTP parameters to pool the *.ctl files and then in mapping (Java Mapping) using dynamic configuration code read the CTL filename just pooled.

Do some manipulation within javacode to get the first part of the filename i.e., filename without extension and store it to some temporary string variable by adding ".txt" suffix.

Now within java mapping code use FTP JAVA API to connect to the FTP directory & check if the corresponding .txt file exists, then read the entire file stream and store it into another file within PI system directory. Once complete stream is read from FTP directory either delete or archive the file within FTP directory according to your requirement.

Configure a second scenario which will pool for the PI System directory for the copied .txt files. Once the file gets picked map it to IDOC structure (preferably graphical mapping) and then the IDOC adapter will take care of the things as per your configuration.

So your scenario is split into two scenarios

1. FTP(*.CTL) using FileAdapter ---> PI (JavaMapping) ---> PI Local Directory using FileAdapter

2. PI Local Directory using FileAdapter ---> PI ---> IDOC

For the first part, as said above use java mapping to read the corresponding .txt stream and dump it to PI Local Directory which is triggering point for your second scenario.

I hope this works.

Thanks,

Gujjeti

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Praveen,

Thanks for your inputs,

The way you suggested has to be tried... But can we dont get a better solution... Mean cant we go with Shell scripts as Jay and Veera suggested...

Please update...

Regards,

Sridhar

former_member181985
Active Contributor
0 Kudos

Hi Sridhar,

Yes their solutions are also possible.

Only a proper POC with the suggested cases can give a better optimized solution.

Thanks,

Gujjeti.

sridharreddy_kondam
Active Contributor
0 Kudos

Hi All,

Can any one give me Exact information on how to hanlde this...

Regards,

Sridhar Reddy

Former Member
0 Kudos

hi sreedahr,

i posted this in one of the forums and i got this reply....hope it gives u a clear picture.

you can achive this by writing script at communication channel configuaration.

check this link: i posted your requirement only in that forum

http://www.computing.net/answers/programming/shell-script-code-for-file-transfer/16959.html

regards.

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Chaitanya,

Can you let me know when the operating system command starts working for the Sender File adapter...

Mean does the operating system command works before the file adapter starts processing the message?

can you geive more details...

Regards,

Sridhar

Former Member
0 Kudos

yes....it has to run before message processing...

Former Member
0 Kudos

Sirdhar,

Yes you have to use the same location otherwise ,, the command line argument will not be active.

Thanks,

JAY

Edited by: JGD on Sep 12, 2008 8:46 AM

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Jay,

Can you please elaborate more with shell script e.g...

As i dont know any i appreciate your help .. here PI has been installed on Linux OS..

Regards,

Sridhar Reddy

Former Member
0 Kudos

hi,

[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/10377] [original link is broken] [original link is broken] [original link is broken];

this blog might be resembly ur needs.

Regards .

Siddhesh Naik

Former Member
0 Kudos

Hi,

There are two option you can follow to achive this, if i am wrong then update me.

1. Write a script, use the script in the configuration communication channel.

The script will check the date of creation of the file and then it will check if there is any *.CTL file is present . If the file is present with the current date then it will pick the *.CTL file and the it will pick the *.TXT file.

Conern: If there are multiple file that need to be processed at a sigle point of time then the option of using the command line argument in the CC will behave in a different way.. sometimes it will fetch and sometimes it will fail to process anything.

2. The second option is to write a functional module and call it in mapping. The functional module will the required job of processing the files in the sequiential order: once the correct order is maintained then the process will run sucessfully.

Thanks,

JAY.

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Jay,

Can we check the .ctl file in the folder /server and from the same folder can XI pick the .txt file if we write the shell scripts...

Regards,

Sridhar Reddy

Former Member
0 Kudos

Hi,

If u are using linux script to copy data from Temporary folder to XI than u can check for

if ls *.CTL

then

cd $DEST_DIR

lcd $SOURCE_DIR7

mget $FILE\*

Former Member
0 Kudos

Hello Sridhar,

The files are placing on ftp server, so we can write the ftp script to validate the said condition.The source sytem will place the files on some temp folder.The ftp script which is scheduled as per u r requirement, it will read the files from temp folder it will check the file with extension .ctl is there or not. If it is there script will replace the .txt file from temp folder to another folder. From this folder file sender channel can process the file.

Hope ftp script idea will helps to you.

Cheers

Veera

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Veera,

Can you please let me know how and where to write scripts .

and is that the only solution which we can handle... any how let me check with my client ... then will get back to you....

Regards,

Sridhar

sridharreddy_kondam
Active Contributor
0 Kudos

Hi Veera,

Cant we check the .ctl file and pick the .txt file from the same folder instead of moving into another folder?

Regards,

sridhar

Former Member
0 Kudos

hi,

never faced this situation but...just thinking on these lines if it is possible:

say u will place the files in a temporary folder and write a script to read the extension .ctl and match the same with .txt file once this is fine then script will transfer the .txt file to another folder and file adapter will pick from there.

just thinking not sure if it is 100% solution.

please let us know if u solved this one with other options.

regards.