SSIS- Reading Of File Name

Need to perform below steps while loading data into target table from access database file
Check if file exists in Folder (particular folder say c:\bin\file...)  
If file does not exist ... exit
If file exists  read CSV File for Y/N ( CSV file has value y or n only one column one row)
If CSV value = Y
Read the file name, up till "."
Load access data where entry type = AAA and populate an additional column of source type as the FileName before "."
If CSV value = N
Read the file name,up till "."
Load access data where entry type <> AAA and populate an additional column of source type
as the FileName before "."
I can understand how to check the value of csv file for y or n
How can we check the presence of file, read the name uptill '.' store it in variable and populate it as a column value
Any help or idea on the above
aak

Hi aakcse,
To check whether accdb file exists in the spepcified directory with wildcard in the file name, you can use the following code:
public void Main()
// TODO: Add your code here
string[] files = System.IO.Directory.GetFiles(Dts.Variables["User::vStrFilePath"].Value.ToString(), "*.csv");
if (files.Length > 0)
Dts.Variables["User::vBolFileExist"].Value = true;
foreach (string file in files)
Dts.Variables["User::vFileName"].Value = Path.GetFileNameWithoutExtension(file);
else
Dts.Variables["User::vBolFileExist"].Value = false;
MessageBox.Show(Dts.Variables["User::vFileName"].Value.ToString());
Dts.TaskResult = (int)ScriptResults.Success;
Note: Assuming there is only one .accdb file in the folder, the script above assigns the file name of the .accdb file without extension to the String type SSIS variable User::vFileName.
Regards,
Mike Yin
If you have any feedback on our support, please click
here
Mike Yin
TechNet Community Support

Similar Messages

  • How to read dynamic file names in RSEINB00?

    Hi, ABAP Gurus,
    actually I'm a PI Consultant. Now I have a scenario to use the report RSEINB00.
    In the Applicaton Server i put ASCII IDocs with the following name convension: <static name>+<time stemple>:
    SAPIDOC20111127-224128-952.txt
    SAPIDOC20111127-224129-115.txt
    I created a new port in WE21 and the Outbound file and Inbound fiel tabs haben the same configration:
    physical directory: /ABC/DEV100/inbound/
    Function module: EDI_PATH_CREATE_DATE_TIME
    Inbound file: SAPIDOC.txt
    To execute the report RSEINB00 I must give the complete file name and port. It is not convenient.
    My target is, with a job to run RSEINB00 once daily to read all files with name "SAPIDOC + <time stemple>" full automatically.
    Is it possible? how to figure it out?
    thanks a lot in advance! <removed by moderator>.
    Regards
    Rene
    Edited by: Thomas Zloch on Nov 29, 2011 5:23 PM

    with the extension of the standard report RSEINB00 i solved this problem. here is some code:
    DATA:
      dir_name  LIKE  epsf-epsdirnam,
      file_mask LIKE  epsf-epsfilnam,
      g_message_fields LIKE edimessage.
    DATA:
      filename LIKE  edi_path-pthnam,
      filename2 LIKE edi_path-pthnam,
      myport TYPE EDIPO-PORT.
    DATA: h_EDIDC     LIKE EDIDC.
    DATA:
      wa TYPE file_table.
    DATA:
      t_dir_list TYPE STANDARD TABLE OF epsfili WITH HEADER LINE,
      itab TYPE table of file_table WITH HEADER LINE.
    *The directoy, where the Markant ASCII IDocs are droped by XI.
    dir_name = '<.../inbound>'.
    *File mask of ASCII IDocs.
    file_mask = 'XYIDOC.'.
    *File port.
    myport = '<Portname>'.
    CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
      EXPORTING
        dir_name               = dir_name
        file_mask              = file_mask
      TABLES
        dir_list               = t_dir_list
      EXCEPTIONS
        invalid_eps_subdir     = 1
        sapgparam_failed       = 2
        build_directory_failed = 3
        no_authorization       = 4
        read_directory_failed  = 5
        too_many_read_errors   = 6
        empty_directory_list   = 7
        OTHERS                 = 8.
    IF sy-subrc <> 0.
      MESSAGE e600(fr) WITH 'No ASCII IDoc exits'.
    ENDIF.
    "BREAK-POINT.
    *The old ASCII IDocs are stored in a dataset and copied with new file name sent_<original name>
    LOOP AT t_dir_list.
      CONCATENATE dir_name '/' t_dir_list-name INTO filename.
      CONCATENATE dir_name '/sent_' t_dir_list-name INTO filename2.
    open dataset filename for input in text mode.
    open dataset filename2 for output in text mode.
    if sy-subrc = 0.
      do.
        read dataset filename into wa.
          if sy-subrc <> 0.
           exit.
          endif.
      transfer wa to filename2.
         append wa to itab.
           enddo.
    endif.
    close dataset filename.
    *loop at itab into wa.
    transfer wa to filename2.
    *endloop.
    close dataset filename2.
      PERFORM inbound_processing USING filename.
    ENDLOOP.
    *&      Form  inbound_processing
    FORM inbound_processing USING filename TYPE edi_path-pthnam.
    do inbound processing from file
      CALL FUNCTION 'IDOC_INBOUND_FROM_FILE'
        EXPORTING
          file_name            = filename
          port                 = myport
        EXCEPTIONS
          file_open_failed     = 1
          marker_to_be_deleted = 2
          read_file_failed     = 3
          idoc_not_stored      = 4
          file_delete_failed   = 5
          marker_modify_failed = 6
          event_create_failed  = 7
          first_record_invalid = 8
          invalid_record       = 9
          OTHERS               = 10.
      IF sy-subrc <> 0.
    fill message fields for exception handling from system fields
        MOVE-CORRESPONDING sy TO g_message_fields.
    error handling using the 3.0 business workflow
        CALL FUNCTION 'IDOC_ERROR_WORKFLOW_START'
          EXPORTING
            docnum                  = 0
            eventcode               = 'EDIM'
            mess                    = g_message_fields
          EXCEPTIONS
            no_entry_in_tede5       = 0
            error_in_start_workflow = 0
            OTHERS                  = 0.
    do not care for exceptions here
        COMMIT WORK.
    append message for RFC
        MESSAGE ID     g_message_fields-msgid
                TYPE   'A'
                NUMBER g_message_fields-msgno
                WITH   g_message_fields-msgv1 g_message_fields-msgv2
                       g_message_fields-msgv3 g_message_fields-msgv4.
      ENDIF.
    ENDFORM.                    "inbound_processing

  • UDF to read a file name and use some of its contents to map fields in target.

    I have a scenario where I need to take the month and year from the file name and map it to suitable fields in the target. Ex - filename_apr2014 from this i should be able to read the month and year and map it. How to do this? I tried the udf -
    public String getFileName(Container container){
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return ourSourceFileName;
    got this error while testing the mapping -
    Runtime exception when processing target-field mapping /ns0:MT_<<>>_Output/I<<>>; root message: Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.get(com.sap.aii.mapping.api.DynamicConfigurationKey) of a null object loaded from a local variable at slot 2] in class <<>> method getSourceFileName[com.sap.aii.mappingtool.tf7.rt.Context@5b04fc0f]
    See error logs for details  

    Hi Satish - You declared "conf" twice.
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    UDF -
    String filename    = "";
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
    filename = conf.get(key);
    return filename;
    And did you define the variable slot 2 in any of your UDF's?
    The above UDF return the filename and you should handle the sub string later..

  • How to read variable file name into ODI

    Hello everyone,
    I apologize in advance if this has already been answered - I've done searches both on Google and this OTN area and have not found an answer to my query.
    I would like to do the following via ODI:
    1) rename a file in a specific directory
    2) process the file
    2) move the file to a backup directory
    3) rename the file again
    The file name is going to change everytime this process runs, as date is appended to it. I could create a variable with a system date in it and concatenate that into the filename before processing it, but I am not sure when they will run the ODI routine. Therefore, I would prefer to play it safe by doing something like a wildcard search in DOS.
    Example:
    Filename = TestFile12072010.csv
    I would like to:
    1) rename TestFile12072010.csv to TestFile.csv
    2) process the file
    3) move the file to another directory
    4) rename the file to TestFile<processdate>.csv
    I was hoping to do the first step using a DOS command that reads in TestFile*.csv. Note: I would expect there to be only 1 file with this naming convention and file extension in the directory.
    I have tried creating a stored procedure that uses the Operating System type, but it runs without stopping. I have also tried ODIFileCopy and OS Command. Obviously, I am doing something wrong since I am getting errors.
    Any guidance would be much appreciated! :)
    Thanks!
    -OS

    Issue was due to a syntax error. Case closed.
    Thanks!
    -OS

  • How to read the file name....

    Hello all,
    I have a doubt on reading file name.
    I have 10 pdf files in the dir '/d01/tem/'
    I need to get/load those 10 file names using PL/SQL. Meaning I need to get the file names only not the file contents...
    Please help me to achieve this....
    Thanks and Regards,
    Muthu

    There is no public synonym for DBMS_BACKUP_RESTORE, so you need to prefix it with SYS and make sure your user has execute privilege on the package. This will fix call to DBMS_BACKUP_RESTORE, but you have another issue. - fixed tables. Only SYS can read them. You'd have to login as SYSDBA, create a view around x$krbmsft and grant select on it to your user.
    SQL> connect sys as sysdba
    Enter password:
    Connected.
    SQL> grant execute on DBMS_BACKUP_RESTORE to scott;
    Grant succeeded.
    SQL> create view v$krbmsft as select * from x$krbmsft;
    View created.
    SQL> grant select on v$krbmsft to scott;
    Grant succeeded.
    SQL> connect scott
    Enter password:
    Connected.
    SQL> set serveroutput on
    SQL> DECLARE
      2      p_directory VARCHAR2(1024) := 'C:\TEMP';
      3      p_null VARCHAR2(1024);
      4      i number := 1;
      5  BEGIN
      6      SYS.DBMS_BACKUP_RESTORE.searchFiles(p_directory, p_null);
      7      FOR x IN (select fname_krbmsft fname from sys.v$krbmsft) LOOP
      8        DBMS_OUTPUT.PUT_LINE(x.fname);
      9        EXIT WHEN i = 3;
    10        i := i + 1;
    11      END LOOP;
    12  END;
    13  /
    C:\TEMP\acbrd-0050.csv
    C:\TEMP\afiedt.buf
    C:\TEMP\A_3136_4000.log
    PL/SQL procedure successfully completed.
    SQL>SY.

  • How to get the read input file name in bpel process using File Adapter.

    Hi,
    I am reading a .txt file from configured directory using File Adapter.
    I had configured file adapter to read file with naming pattern “SalesOrder.*\.txt”.
    Now I had requirement to access the actual file name in bpel process eg: “SalesOrder123.txt”
    How can I get the file name in bpel process.
    Any help is appreciated.
    Vidya.

    1) create a variable of message type. Click on Browse Message type. Here you select Message Type-->Project WSDL Files -->fileAdapterInboundHeader-->Message Types-->Inboundheader_msg. Then click OK
    2)Next dbl Click on teh receive Activity which is receing your File from teh File Adapter. Go to the Adapter Tab. Click on Browse variable and select the variable that you had just created above.
    This would get the File name in the variable declared

  • Read in file name + path using command line arguments

    Hi guys,
    I am trying to use command line arguments to read in the name of two files. The code below works as long as the files are on the class path.
    public class cmdLineArguments {
         public static void main(String[] args) {
              String xmlFile1 = args[0];
                    String xmlFile2 = args[1];
              System.out.println ("\nXmlFile1: " + args[0] + "\nXmlFile2: " + args[1]);
    }I would like to be able to read files that are not on the class path as well by entering their full path along with their names.
    In other words, It works if I type:
    C:\Documents and Settings\user\workspace\CmdLineArgs\src>java cmdLineArgs file1.xml file2.xmlbut not if I type:
    C:\Documents and Settings\user\workspace\CmdLineArgs\src>java cmdLineArgs c:\Documents and Settings\user\desktop\file1.xml c:\Documents and Settings\user\desktop\file2.xmlWould anyone please explain how I can edit the code to make it work? I guess I could take them both as a String, modify them manually (add a \ to it etc) but is there an easier way to do it? Even a reference to a tutorial, article etc about this would be very much appreciated.
    Also, any idea why a code would compile and run fine in Eclipse but would create an error from command line?
    Thanks a lot.

    You need to learn about cmd.exe which is used to process the command line. The arguments passed to any program is the command line split at white space so your command line arguments of
    c:\Documents and Settings\user\desktop\file1.xml c:\Documents and Settings\user\desktop\file2.xmlis turned into an array of
    "c:\Documents", "and", "Settings\user\desktop\file1.xml", "c:\Documents", "and", "Settings\user\desktop\file2.xml"In other words instead of 2 arguments you actually have 6.
    To get round this the file names need to be quoted
    java cmdLineArgs "c:\Documents and Settings\user\desktop\file1.xml" "c:\Documents and Settings\user\desktop\file2.xml"

  • How to read a file name and send it a particular reciever

    Hi,
    I have a scenario, where i am receiving a a file and based on the file name i have to decide who is the receiver and send it to that particular receiver.I do not have to do any mapping.
    can someone suggest me how can I achieve this.
    Thanks in advance.

    HI This may help you.Let me know if not.
    Step by Step Guide: XML File 2 XML File Scenario: Part I
    Step by Step Guide: XML File 2 XML File Scenario: Part II
    Converting XML to PDF using XI
    Introduction to simple(File-XI-File)scenario and complete walk through for starters(Part1)
    Introduction to simple (File-XI-File)scenario and complete walk through for starters(Part2)
    "JAVA MAPPING", an alternate way of reading a CSV file
    Dynamic File Name using XI 3.0 SP12 Part - I
    Dynamic file name(XSLT Mapping with Java Enhancement) using XI 3.0 SP12 Part -II
    Push Data to MVC Architectured application using XI
    How to send any data (even binary) through XI, without using the Integration Repository
    XI in the role of a FTP
    The specified item was not found.
    The specified item was not found.
    The specified item was not found.
    The specified item was not found.

  • LSMW Read/Converted File Name

    Hi,
    Normally when you specify file, a name will be generated for the read and converted file with different extention. Now, is it possible to have a more dynamic way of naming this file?  My requirement would be to have the read/converted named differently on each load (without changing the name in LSMW config on each run), for eg. lsmw_read_20022009.read and lsmw_read20022009.conv. In this example, the date is the variable and should change base on system date, so the next load on a different will have a different date. I got some ideas from logical/physical file, but I am not sure how and if its applicable. Any ideas?
    Thanks!
    cady

    regarding the LSMW we have lot of tables , if you chnage the file names in table level based on dates it will fick the files form tables
    goto se11 and give the /SAPDMC* then press the F4 you will get 48 tables, if its possible to chnage the file names your probelm is solved....

  • Read dynamic file name

    Dear Experts,
    I need to read a file from the application server with the file name "static""timestamp".txt, where static is the static file name and timestamp would be added at the end of the file name. Please suggest me a way to read all such files one by one.
    thanks

    Hi
    You need to scan the path in order to get all files stored and then to read it;
    You can use the fm EPS_GET_DIRECTORY_LISTING in order to scan the directory:
    DATA: dir_name  LIKE  epsf-epsdirnam,
          file_mask LIKE  epsf-epsfilnam.
    DATA: filename  TYPE string.
    DATA: t_dir_list TYPE STANDARD TABLE OF epsfili WITH HEADER LINE.
    dir_name  = '<application path name>'.
    file_mask = '<static>*.*'.
    CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
      EXPORTING
        dir_name               = dir_name
        file_mask              = file_mask
      TABLES
        dir_list               = t_dir_list
      EXCEPTIONS
        invalid_eps_subdir     = 1
        sapgparam_failed       = 2
        build_directory_failed = 3
        no_authorization       = 4
        read_directory_failed  = 5
        too_many_read_errors   = 6
        empty_directory_list   = 7
        OTHERS                 = 8.
    IF sy-subrc <> 0.
    ENDIF.
    LOOP AT t_dir_list.
      CONCATENATE dir_name '/' t_dir_list-name INTO filename.
      OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      CLOSE DATASET filename.
    ENDLOOP.
    Max

  • LSMW file read & convert file name

    Guys
    This is pretty hot - any ideas to automate will be helpful.
    Is there a way to programmatically change the default name for the LSMW file read and file convert names?
    For example if read & conv file is
    Plant_Master_Material.lsmw.read & Plant_Master_Material.lsmw.conv,
    I want to programmatically append userid and make the file name look like
    Plant_Master_Material_myid.lsmw.read & Plant_Master_Material_myid.lsmw.conv.
    It can be done manually via step specify file in LSMW, but I want to automate that step.

    Hi Iqbal,
    Its not possible to make it automatically,
    name for the LSMW file read and file convert will as such like this
    PROJECT_SUBPROJECT_OBJECT.lsmw.read & lsmw.conv.
    This can not be changed...if u need it u can have u r userid under u r object name...
    Reward if useful..

  • How to read all files' name in a directory and store in a string array?

    as title

    One possibility is to use the listFiles() method, using recursion if you want the files in the sub-directory also. Check API documentation for java.io.File.

  • How to get file name using File adapter Sync read

    Hi All,
    I am using SOA 10.1.3.3 and JDEV 10.1.3.3.
    I have an async bpel process.
    I have to read file name in this process... so i have used file adapter sync read operation.
    How can we get the file name with out payload using sync read.
    For normal read (Inbound Spec)we have UseHeaders="true" property.
    Is there any property for sync read to read the file name.
    Please help me
    Regards
    PavanKumar.M
    Edited by: [email protected] on Oct 27, 2009 11:23 PM

    Hi Eric,
    The info in the link provided by you is for a normal read.
    I need to read he file name using Sync read operation.
    Regards
    PavanKumar.M

  • If I use an app to remove duplicate pix does the app  read content  or only  the file name such as IMG

    If I use an app to remove duplicate pix does the app  read content  or only  the file name such as IMG. I have some 2500 pix  and the thought of trawling thru  them  toremove duplicates is mind numbing.
    If the apps  read the content then I am ok about that  but if they  only read the  file name ... they maybe  deleting stuff that  isnt really a duplicate

    You have to contact with the developer of the application. We do not know which app you are referring to and we do not know how that application works, but all apps of that type are supposed to delete duplicate files with the same format (like IMG, JPG...)

  • File to RFC scenario want to read file name

    Hi All,
    I am having file to RFC scenario in which i am having file name in format  text_yyyymmdd.txt.
    i want to read this file name and by separating the date in file name i have to pass this to one of the RFC date parameter.
    please help me to sort out this.
    Thanks
    Swapnil

    Hi,
    By writing simple UDF in your mapping you can Acheive this
    Try this Once
    DynamicConfiguration dynamicconfiguration = (DynamicConfiguration)param.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "FileName");
    String MyFileName = dynamicconfiguration.get(key);
    String str[] = MyFileName.split("_");
    return str1[1];
    Map this to the date parameter(RFC) in the mapping .
    Thank & Regards,
    Deepthi
    Edited by: Deepthi Muppasani on Sep 23, 2011 8:17 AM

Maybe you are looking for

  • Problem in Mapping RefCursors(in/out parameter) and Collections(in/out)

    Hi, Can anyone help to solve the proble listed below as it is affecting the business process The API for A is listed below. It takes Oracle Object types as input/output. PROCEDURE A( p_serviceOrder IN ServiceOrder, p_serviceID IN OUT p_sm_type.Servic

  • "apple-+" does not increase font size in preview pane in mail.app 4.2

    i have letterbox http://harnly.net/2009/software/letterbox/letterbox-beta-4-for-snow-leopard/ installed on my machine. before the SL upgrade, i could hit cmd-+ and increase the font size of the message i am viewing. that was super convenient! i can't

  • What are the screws on the side of the HDD

    There are 4 screws on the side of my HDD in my macbook pro 2011. Are they t6 or t8 Torx screws? I need to buy a screwdriver but I don't know which kind. Thanks.

  • Getting message "iTunes was not properly installed..."

    "...If you wish to import or burn CDs, you need to reinstall iTunes." I recently bought an external DVD burner that came with Nero 7 Essentials. After I installed Nero and tried to open iTunes, I got the above message. If I click "OK" to the message,

  • Hot spot in ALV Report

    Dear Experts, I have a doubt in classical report.  I developed a classcial report and displayed a hotspot in top of page, so that the hotspot text will take me to the alv form of the classcial report.  it works fine.  But when i try to include that h