How to pick the multiples based on file size

Hi All,
my sender file adapter needs to pick up 5 files based on file size.
for example 1file size is 500kb,2nd file size 300kb,3rd file size 400kb, 4file size 100kb and 5file size 600kb.
here my requirement is, my file adapter needs to pick in the below order like 5th file,1st file,3rd file 2nd file and 4th file.
means based on file size, i need to pick up my file adapter.
could you please ang inputs on this requirement.
Thanks & Regards,
AVR

Hi AVR,
for case 2:
1. At specific time each day  "23:58:00" hours ,count the number of files in directory say "c:\apps\acm".
2. sort the files on basis of their size.
3. place the files one by one after definite  time interval (more than polling time of the sender communication channel).
in target directory say "c:\apps\acm1" from where PI server  picks up the files for further processing. The file with smallest size is placed last.
4. In this case you need to ensure all files are present in the directory "c:\apps\acm" before "23:58:00" hours.
for case 2  java code
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class sortFilesOnSpecificTime {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
try
* In Unix/Linux OS, dir1="/usr/apps/test"  etc
int pollingInterval=10,sleepTime=1*60;
String dir1="c:\\apps\\acm";
String dir2="c:\\apps\\acm1";
File fread=new File(dir1);
File fwrite=new File(dir2);
if(fread.canRead()==false)
System.out.println("error: "+dir1+" does not have read permission. Program Terminates.");
return;
if(fwrite.canWrite()==false)
System.out.println("error: "+dir2+" does not have write permission. Program Terminates.");
return;
String fileNames[],fileNamesOut[];
long fileSize[];
int i,j;
byte b[];
int t=4;
Calendar cal;
int hour24,min,fileCopyHour=23,fileCopyMin=58;
long waitSeconds=1,currentTime=0;
while(t>0)
cal = new GregorianCalendar();
hour24 = cal.get(Calendar.HOUR_OF_DAY);     // 0..23
min = cal.get(Calendar.MINUTE);             //0..59
System.out.println("current time="+hour24+":"+min);
/*loop unless time reaches a specific predetermined value
* predetermined values are provided by values
* fileCopyHour=8,fileCopyMin=30 i.e say 08:30 hours
currentTime=(hour24*60+min)*60;
waitSeconds=(fileCopyHour*60+fileCopyMin)*60 - currentTime;
if(waitSeconds>0)
* in case you wanna to make this thread sleep for
* say sleepTime(10) minutes before it checks the files once again
* because looping continuously causes wastage of CPU cycles.   
Thread.sleep(waitSeconds*1000);
//read list of files
fileNames=fread.list();
if(fileNames.length;=0)
* time is up but there are no file
* in dir1 to copy. Then this program
* goes to sleep for some time and
* checks only at 11:55 hours. That is
* end of the day
continue;
fileSize=new long[fileNames.length];
fileNamesOut=new String[fileNames.length];
//read their sizes
for(i=0;i<fileNames.length;++i)
fileNamesOut<i>=fileNames<i>;
fileNames<i>=dir1+System.getProperty("file.separator";)+fileNames<i>;
fileSize<i>=new File(fileNames<i>).length();
System.out.println(fileNames<i>+" size="+fileSize<i>);
//sorting on basis of file size descending order
long value;
String temp;
for(i=1;i<fileSize.length;++i)
value=fileSize<i>;
temp=fileNames<i>;
for(j=i-1;j>=0 && fileSize[j]<value;--j)
fileSize[j+1]=fileSize[j];
fileNames[j+1]=fileNames[j];
fileSize[j+1]=value;
fileNames[j+1]=temp;
//now copy files to dir2
b=new byte[512];
for(i=0;i<fileNames.length;++i)
System.out.println(fileNames<i>+" size="+fileSize<i>);
for(i=0;i<fileNames.length;++i)
File f=new File(fileNames<i>);
FileInputStream in=new FileInputStream(f);
FileOutputStream out=new FileOutputStream(dir2+System.getProperty("file.separator";)+fileNamesOut<i>);
int len=0;
while(2>1)
if((len=in.read(b))<0)
break;
out.write(b,0,len);
in.close();
//delete files after copying from dir1
f.delete();
out.close();
//put each file after polling interval is over
Thread.sleep(pollingInterval*1000);
catch(Exception e)
e.printStackTrace();
The code runs in infinite loop. You need to run them in command line in DOS environment as you indicated that you OS is WIN XP.  I have a few print statements which I kept for debugging, you can safely remove them and run the codes. This code is independent of the Operating System you are using. Only change is required in values of "dir1","dir2", timings and file count, which I think you can take care easily.
Hope this solves your problem.
regards
Anupam

Similar Messages

  • How to pick the data based on customer number

    Hi All ,
    greets....
    i have a requirement to select  the data based on customer number and then do furthur processing .
    example:
    this is some 10 dcouments in customer nr:v1000
    and 20 documents in customer v2000 in a internal table how to select that,
    thank s in advance.

    thier is an internal table which is having some 1000records.
    and their is 6 customers.
    in which i should pick the data based on customer number.
    how to write a code for that?

  • How can get the library items total file size

    Hi All,
    I want to get the total file size of the library and count how many file in library.
    would I use getItemsRequest can get them?
    or have another ways to do that?
    Thank You
    Jimmy

    Sorry, I don't have any ideas.
    Just so you know, the document management support is the lowest priority.
    There are not any active enhancements planned for document management.
    We added some support in 12.0.x for WebAccess, but there is none planned
    further.
    Preston
    >>> On Tuesday, August 21, 2012 at 2:26 AM,
    jimmyng25<[email protected]> wrote:
    > Thank you, Preston.
    > I will try to find other ways.
    > Would you please telling me if you have any idea?
    > I no idea to solve that, thank you very much.
    >
    > Jimmy

  • How to pick the file which is created with current date

    Hello All,
    I have an FTP server where files are created with current date as PO_CONFIRM_20100701.txt.
    Need to pick the file based on current date. How to pick the above file format using file sender adapter. i.e what file pattern can we use so that file will be picked only on today's date
    Regards,
    Sreenivas.

    Hi Srinivas,
    It depends upon the OS you are using. If unix you can see an example script here:
    http://www.computing.net/answers/dos/batch-file-to-rename-files-by-date/5517.html
    If windows an example here:
    http://en.kioskea.net/forum/affich-87157-finding-and-using-file-date-in-batch-command
    You may need to change slightly to fit your exact requirements. But this would make you to start. Else you can also google to get the script. Here is one link:
    http://www.google.com/#hl=en&source=hp&q=scripttorenamefileshavingtodaysdate&aq=f&aqi=m1&aql=&oq=&gs_rfai=CRE9SwTMsTNjiDpzGhgTm65iFCwAAAKoEBU_QC2i-&fp=e0fa4b5da4f245a4
    Regards,
    ---Satish

  • How to load the data from excel file into temprory table in Forms 11g?

    Hi
    How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
    My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
    Kindly Suggest the Solution.
    Regards,
    Sachin

    Declare
        v_full_filename         varchar2(500);
        v_server_path           varchar2(2000);
        v_separator             VARCHAR2(1);
        v_filename              VARCHAR2(400);
        filename                VARCHAR2 (100);
        v_stop_load             varchar2 (2000);
        v_rec_error_log         varchar2(4000);
        v_error_log             varchar2(4000);
        ctr                     NUMBER (12);
        cols                    NUMBER (2);
        btn                     number;
        RES                     BOOLEAN;   
        application             ole2.obj_type;
        workbooks               ole2.obj_type;
        workbook                ole2.obj_type;
        worksheets              ole2.obj_type;
        worksheet               ole2.obj_type;
        cell                    ole2.obj_type;
        cellType                ole2.OBJ_TYPE;
        args                    ole2.obj_type;
        PROCEDURE olearg
        IS
        args   ole2.obj_type;
        BEGIN
        args := ole2.create_arglist;
        ole2.add_arg (args, ctr);                                
        ole2.add_arg (args, cols);                                   
        cell := ole2.get_obj_property (worksheet, 'Cells', args);
        ole2.destroy_arglist (args);
        END;
    BEGIN
    v_full_filename := client_get_file_name(directory_name => null
                                     ,file_name      => null
                                     ,file_filter    => 'Excel  files (*.xls)|*.xls|'  
                                                                            ||'Excel  files (*.xlsx)|*.xlsx|'                                                                 
                                     ,message        => 'Choose Excel file'
                                     ,dialog_type    => null
                                     ,select_file    => null
    If v_full_filename is not null Then
    v_separator := WEBUTIL_CLIENTINFO.Get_file_Separator ;
    v_filename := v_separator||v_full_filename ;
    :LOAD_FILE_NAME := substr(v_filename,instr(v_filename,v_separator,-1) + 1);                                
    RES := Webutil_File_Transfer.Client_To_AS(v_full_filename,"server_path"||substr(v_filename,instr(v_filename,v_separator,-1) + 1));     
    --Begin load data from EXCEL
    BEGIN
        filename := v_server_path||substr(v_filename,instr(v_filename,v_separator,-1) + 1); -- to pick the file
        application := ole2.create_obj ('Excel.Application');
        ole2.set_property (application, 'Visible', 'false');
        workbooks := ole2.get_obj_property (application, 'Workbooks');
        args := ole2.create_arglist;
        ole2.add_arg (args, filename); -- file path and name
        workbook := ole2.get_obj_property(workbooks,'Open',args);
        ole2.destroy_arglist (args);
        args := ole2.create_arglist;
        ole2.add_arg (args, 'Sheet1');
        worksheet := ole2.get_obj_property (workbook, 'Worksheets', args);
        ole2.destroy_arglist (args);
        ctr := 2;                                                     --row number
        cols := 1;                                                -- column number
        go_block('xxx');
        FIRST_RECORD;  
        LOOP       
                --Column 1 VALUE --------------------------------------------------------------------
            olearg;
            v_stop_load := ole2.get_char_property (cell, 'Text'); --cell value of the argument
            :item1 := v_stop_load;
            cols := cols + 1;                                                      
              --Column 2 VALUE --------------------------------------------------------------------
            olearg;
            :item2 := ole2.get_char_property (cell, 'Text'); --cell value of the argument
            cols := cols + 1;
            --<and so on>
        ole2.invoke (application, 'Quit');
        ole2.RELEASE_OBJ (cell);
        ole2.RELEASE_OBJ (worksheet);
        ole2.RELEASE_OBJ (worksheets);
        ole2.RELEASE_OBJ (workbook);
        ole2.RELEASE_OBJ (workbooks);
        ole2.RELEASE_OBJ (application);
    END;
    --End load data from EXCELPlease mark it as answered if you helped.

  • How to split the IDOCS based on document number change whit out BPM

    Hi all,
    Thanks,for giving the responce..
    Scenario:File to IDoc.
    Problum1 : How to Split the IDocs based on document number change in the source file with out BPM.My file contains document numbers like
    20000092
    20000092
    20000092
    50000050
    50000050
    50000065
    I want 3 IDocs in target system.i.e 1 for 20000092,20000092,20000092
                                                       2 for 50000050,50000050
                                                       3 for 5000006
    By using external definations i am getting 6 IDOCs insted of 3.
    Problum 2:Is there any chnges/modifications in Directory when we are using external definations.
    Could u plz provide me the step by step process(Repository/Directory) with using of external definations.
    Thanks in advance.
    Regards,
    KP

    HI,
    for this no need of BPM.
    You can think of Idoc bundling concept to acheive this-just you need to do the external definition to change the idoc occurence
    /people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change
    to achieve for each document no, one idoc, you can write small user defined function in the mapping with context handling you an achieve this.
    For this e.g
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6bd6f69a-0701-0010-a88b-adbb6ee89b34
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/877c0d53-0801-0010-3bb0-e38d5ecd352c
    Regards,
    Moorthy

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How to delete the specified line in file?

    How to delete the specified line in file? In case of deleting a specified line in a file, how to do?
    Line 1
    Line 2
    Line 3
    Line 4
    Line 5
    The case is a file including the above content. Now I wanna to delete the "Line 3" and how to realize the action in Java?

    An alternative solution can be :
    import java.io.LineNumberReader;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileReader;
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    public class LineDeleter {
    public static void main(String args[]){
    try {
    //suppose you want to delete line 3
         int lineToBeDeleted = 3;
         File f = new File("line.txt");
         long fileSize = f.length();
    //Wrap the FileReader with a LineNumberReader. It will help you
    //identify the lines.
    LineNumberReader lnr = new LineNumberReader( new FileReader(f));
    //Wrap the FileWriter object with BufferedWriter object. Create it with the buffersize
    //equal to the file size.
         BufferedWriter bw = new BufferedWriter(new FileWriter(new File("line1.txt")),(int)fileSize);
    //Wrap BufferedWriter object with PrintWriter so that it allows you
    //to print line by line
    PrintWriter pw = new PrintWriter(bw);
         String s=null;
         while ( (s=lnr.readLine())!=null ){
              System.out.println(s);
              int lineNumber = lnr.getLineNumber();
    //match the line number
              if(! (lineNumber==lineToBeDeleted)){
                   pw.println(s);
              pw.flush();
              lnr.close();
              pw.close();
         catch(Exception e){System.out.println(e);}
    If you want you can rename the line1.txt to the original file name.
    I hope this helps.Good luck!!!!!!

  • How to setup the security based on roles in Organization.

    Hi,
    How to setup the security based on roles in Organization.
    For example:Few users are Manager and a few user are Non Manager .Manager should have access to all work data including Non Manager and Non Manager should access based role.How to setup this? How OBI server identify the user role?
    kindly let me know.
    Regards.,
    CHR

    Hi,
    You need to have Back End support to achieve this. In Back End you need to create two groups . You need to know what joins has to be made for which group (which is more important) and also make session variable for the userrole (with SQL supporting it). In the BMM layer, we need to put the security join conditions in the 'where clause'.
    And make a common report. User loggin in with the respective userid will have userrole and joins assigned in the Back end. And they will be viewing the report according to their access.
    Hope this will solve your problem.
    Regards
    MuRam

  • In iphoto, how do i save a photo after editing, in the same or higher file size, it's saves in a lower size

    in iphoto, how do i save a photo after editing, in the same or higher file size, it's saves in a lower size

    It's rather more complicated that this.
    iPhoto is a lossless editor. You don't lose any quality on your shot in iPhoto.
    The file size you see reported is the size of your iPhoto Preview: this is what gets used if you access the data via a media browser. It's a "good-enough-for-most-uses" version of the shot. Email it, upload to websites, use it in Presentation, Word processing file etc
    If you want to set the quality yourself then Export the photo using the File -> Export command.
    You can choose to export to Jpeg, Tiff or png. Tiff is lossless but the file sizes are up to 10 times larger. Jpeg allows you to choose different qualities: High, Medium or low. The difference is the amount of compression involved. High quality means very little compression. It's not unusual for photos exported at this setting to have a larger file size than the original.
    Which setting you choose depends on the use you intend. Further editing, printing then high is important. Sending to Facebook? Well low will do just fine there as they're going to trash the file anyway.
    But the key point: the file size only becomes an issue when you export.
    Regards
    TD

  • How to Load the data from excel file(Extension is .CSV) into the temp.table

    Hi
    How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
    My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
    Kindly Suggest the Solution.
    Regards,
    Sachin

    Hello Sachin,
    You can use the following metalink note:How to Read Data from an EXCEL Spreadsheet into a Form Using Webutil Client_OLE2 (Doc ID 813535.1) and modify it a little bit.
    Instead of copy values into forms you can save them in your temporary table.
    Kind regards,
    Alex
    If someone's helpful or correct please mark it accordingly.

  • How to load the data from .csv file to oracle table???

    Hi,
    I am using oracle 10g , plsql developer. Can anyone help me in how to load the data from .csv file to oracle table. The table is already created with the required columns. The .csv file is having about 10lakh records. Is it possible to load 10lakh records. can any one please tell me how to proceed.
    Thanks in advance

    981145 wrote:
    Can you tell more about sql * loader??? how to know that utility is available for me or not??? I am using oracle 10g database and plsql developer???SQL*Loader is part of the Oracle client. If you have a developer installation you should normally have it on your client.
    the command is
    sqlldrType it and see if you have it installed.
    Have a look also at the FAQ link posted by Marwin.
    There are plenty of examples also on the web.
    Regards.
    Al

  • How  to load the data from excel  file  into table in oracle using UTL_FI

    How to load the data from excel file into table in oracle
    and from table to excel file
    using UTL_FILE package
    Please give me some example

    This is something i tried in oracle apex
    http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
    Regards,
    CKLP

  • How to read the complete path in file upload UI

    Hi,
    I want to know how to read the complete path in file upload UI in java web dynpro.
    I have created 1 file upload UI and than when i do browse and select some file say small.jpg from my local PC, desktop , its path is coming in file upload UI like E:\small.jpg,
    I want to know how to get this path in java webdynpro code.
    please let me know..

    Hi Satyam,
    In webdynpro java, first file stores in server location then it reads from server.
    Create a button with upload and write this code OnAction
    Resource is the attribute name in context of type com.sap.ide.webdynpro.uielementdefinitions.Resource, this attribute is for Resource property for Upload UI Element.
    Then in OnAction of button
    InputStream text = null;
           int temp=0;
           try{
                File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
               String path = file.getAbsolutePath();
                wdComponentAPI.getMessageManager().reportSuccess(path);
           }catch(Exception e){
                e.printStackTrace();
        //@@end
    Regards,
    Pradeep
    Edited by: pradeep_546 on May 11, 2011 12:22 PM

  • How to capture the multiple value in list box

    Hi forums,
           How to select the multiple values in list box and how to catch that values in OnInputProcessing.
    Regards,
    Ravi.

    Hi,
    A possible method is:
    Get all fields of the form
        CALL METHOD request->get_form_fields
          CHANGING
            fields = table_fields.
    loop over the fields
        LOOP AT table_fields INTO wa_fields.
    test the name of the field
          CASE wa_fields-name.
            WHEN 'test'.
    retrieve the value of the field
              test = wa_fields-value.
    endcase
    endloop.
    Eddy

Maybe you are looking for

  • Recording videos while recording sound?

    Hey everyone. Well I just got a new MacBook and I wanted to make some YouTube videos of me playing my guitar. How exactly would I record this? I have tried on iMovie, but I couldn't find a way to record audio and video at the same time. If anyone can

  • Production database sync with Reporting Server

    we have configured always-on on node1 as primary and node 2 as secondary.Now I have launched a new node 3 SQL Server for reporting purpose.I want to have the node 1 Database to be in sync with node 3 Reporting server. As I dont want any overhead on t

  • How do I change my password?

    I was changing my password but it said "The server is unavaliable. Change your password when the server does becomes avaliable." What does that even mean? How do I change my password?

  • I'm trying to upgrade from 10.5.8 to Snow Leopard

    I'm trying to upgrade from 10.5.8 to Snow Leopard but keep getting an error message, "This update requires Mac OS X version 10.6.".  Isn't Snow Leopard 10.6?....so now what?

  • How to obtain the URL to access an instance?

    Hi!! Is there any way to get or to form (a kind of format or something) the URL for an instance? What I want to do is that the user clics on a link and that it shows the workspace with the instance opened so the user doesn't have to do a search to fi