Dynamic selection of file in infopackage from application server

Hi,
We have a infopackage in Process chain which runs daily. In the infopackage 'EXTRACTION' tab , input file is from application server. The file we get daily is not unique.
As an example file name is not like 'UNIQUE.CSV' . It varies daily and carries a date and time stamp like UNIQUE_DATE_TIME.CSV
I think we can have a routine to handle this. can someone help me with the routine/code?
Thank you all.

Hi,
1. Create Two Floders in AL11 i.e. in Apllication Server. Eg Name it F1 and F2.
2. First dump the .csv files into Folder F1 using some Programs or Manualy (Name xyz.csv).
3. Then load the data using InfoPackage (here IN infoPackage, Extraction Tab you need to select Adapter = Load Text File from Application Server and then give the correct path from Folder F1), through PC.
4. At the end of the load, attach a simple Program to Move the xyz.csv file from Folder F1 to Folder F2.
5. So next day the file will come to Folder F1 and the it will loaded to Cube/DSO and at the end it will move to Folder F2.
Else you can use simple one or two lines of UNIX/WINDOWS (depends on your OS) script to move the file from Folder F1 to Folder F2 , once you load is over.
While moving the file from Folder F1 to Folder F2 you can append the date at the end of the file and then move to Folder F2, it is use full for future reference.
See Blogs and Article, similar logic...
https://wiki.sdn.sap.com/wiki/display/profile/Surendra+Reddy
How to transfer the Data from SAP-System to Non-SAP system without additional Cost/License
/people/surendrakumarreddy.koduru/blog/2009/03/11/how-to-transfer-the-data-from-sap-system-to-non-sap-system-without-additional-costlicense
To Check the Files/Reports in Application Server and Trigger Mail Alerts.
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/4096bf2d-bcea-2b10-4ab4-e0683830d9b2&overridelayout=true
1. Create Three Floders in AL11 i.e. in Apllication Server. Eg Name it F1, F2 and F3.
2. First dump the .csv files into F1. (Name xyz.csv).
3. Then using UNIX/WINDOWS (depends on your OS) script , first check the file is there are not in F1, if yes then rename the file with date and time or date and transfer the files from F1 to F2 i.e xyz06032010.csv.
4. Then Create a small ABAP program to check the file in F2, if it is there then Trigger the Event, and using that event you execute teh PC.
5. Then using UNIX/WINDOWS (depends on your OS) script , transfer the files from F2 to F3 i.e xyz06032010.csv.
6. Next day morning F1 and F2 are empty and F3 is having the backup files.
So use this method, I used the similar logic and it is working fine.
Timinings are importent i.e what time you need to dump the fule in F1 and what time you need to run UNIX/WINDOWS (depends on your OS) script , transfer the files from F1 to F2 and what time UNIX/WINDOWS (depends on your OS) script , transfer the files from F2 to F3.
Thanks
Reddy

Similar Messages

  • Process for Flat file delta load from Application server to transactional??

    I want to do a flat file extraction in delta loads from application server and that should be loaded into a transactional cubes scheduling a process chain.
    Can any one help with ABAP code and step by step process for this?
    Thank you
    Devi

    Hi Devi,
    As per your explaination, you want to load a list of files from application server using process chain.
    You can do this with below steps.
    1) Create a Event and call event to run Process chain multiple times.
    2) Put all filenames in a file say, source-File
    3) Write a rooting to read filename from Source-File and trigger InfoPackage
    4) At the end of the process chain create new customized program which will delete first line from Source-File so that it will take next file in next run as well as delete currently loaded file. Once this is done trigger event again to start process chain again.
    Regards,
    Ganesh

  • How to upload a file in bdc  from application server

    how to upload a file in bdc  from application server

    Hi
    Check if this is useful and reward.
    PERFORM UNIX_UPLOAD.
    FORM unix_upload.
      DATA : lv_string(600) TYPE c.
      lv_string = p_fname. "p_fname is the filename  in path
    OPEN DATASET lv_string FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc <> 0.
        MESSAGE 'File Not Found' TYPE 'I'.
        LEAVE PROGRAM.
      ENDIF.
      DO .
        READ DATASET lv_string INTO gs_gfile.
        IF sy-subrc NE 0 .
          EXIT.
        ENDIF.
        APPEND gs_gfile TO gt_gfile .
        CLEAR  gs_gfile .
      ENDDO.
      CLOSE DATASET lv_string.
      CLEAR lv_string.
      DATA: lc_split TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
      LOOP AT gt_gfile INTO gs_gfile .
        SPLIT gs_gfile AT lc_split INTO
                                       gs_ipfile-field1                           
                                       gs_ipfile-field2.
      ENDLOOP.
    ENDFORM.                    "unix_upload
    here gs_ipfile is the same structure as your input file to upload
    and
    gs_gfile is the work area of the internal table containing characters as :
    TYPES  : BEGIN OF  ygs_gfile    ,
              data(600)             ,
             END OF    ygs_gfile    .
    *Internal table declaration for input file as text
    gt_gfile   TYPE STANDARD TABLE OF ygs_gfile  INITIAL SIZE 0 ,
    *Work area declaration for input file
           gs_gfile   TYPE ygs_gfile                                   .
    Thanks and Regards
    A Swarna

  • Reading file in pattern from Application server

    Hello Experts,
    I want to search file from Application server.
    I have certain pattern for the file. eg. OEDERS_.DAT or ORDERS_OPEN..
    How can I search the file for pattern from the application server?
    Ex.
    Suppose my file name is ORDER_SENT.DAT, this file should be returned.
    Suppose my file name is ORDER+SENT.DAT, this file should be returned with error.
    Regards,
    RH

    The FM  EPS_GET_DIRECTORY_LISTING is not resulting result properly.
    I have below files on server.
    AMODPROT.PC1
    AMODPROT.PC6
    CMODACT.PC1
    CMODACT.PC6
    IMODPROT.PC1
    IMODPROT.PC6
    N070703.PC2
    SAPRUPGM.PC6
    TMS_TEST.PC1
    TMS_TEST.PC2
    TMS_TEST.PC6
    UMODPROT.PC6
    I use *.PC6 in mask parameter of FM  EPS_GET_DIRECTORY_LISTING , And it returned 0 files, where as there are 6 files.
    Did I missed anything in mask parameter?
    Regards,
    RH

  • Displaying pdf files in Portal from application server.

    Hi,
    I have a requirement where i will give a link on the portal for Provident Fund related data. When the user clicks on the link, i have to retrieve his pdf file from the folder stored on the application server and display it in portal. Could you please tell me how to do it?
    Also can we use Knowledge Management for it? If yes, how to do it?

    Hi,
    This can be done by
    1. Store the pdfs in the server like userid.pdf. Or you can add the year also the the file name.  The files can be in the same appserver. No need for KM.
    2. Create a Webdynpro application where the WD automatically reads user ids of the person logged in (IUser).
    3. In the Webdynpro code create a LinkToURL element with the user id you got in step one. This will make sure that somebody cannot see others file.
    Regards
    Srini

  • File open error from Application Server

    Hello friends,
    I am able to open a file from the foreground mode.
    However when i run the program in background am unable to open it.
        OPEN DATASET fp_asfile FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    I have alos tried to change the user with the back groung user ID. but it again failed.
    Can any one tell me why.
    Ster

    Hi,
    Ok..go to SM51 in your system...and then check how many application servers are there..
    if there are more than one..do the following..
    In the background mode...the program might be running in a different application server....than the one which you used in the your foreground session..
    check this..
    1)
    In your foreground session...go to system -> status...get the application server..
    2)
    when you define the job in SM36...there is a field in the initial screen.."Exec. Target"...which says in which application server you want to run this job...Give the application server that you got from step 1...Then release the job...now your program should work fine..
    Thanks,
    Naren

  • Validating file/folder path from application server.

    Hi All ,
    I have used the FM '/SAPDMC/LSM_F4_SERVER_FILE' to open F4 help for application server. Now I want to validate the folder or file returned by the FM.
    Can anyone help on this?
    Thanks
    Shilpa

    HI Shilpa,
    Us this  FM
    F4_DXFILENAME_TOPRECURSION
    Hope this will help you.
    Regards,
    Vijay

  • Downloading more than 1 file from Application server

    Hi Gurus,
    I have a requirement in which I have to execute my program once in every 15 minutes which will check if there are any files present in application server. Is so I have to retreive the files to SAP from Application server.
    Now I have couple of issues in doing so.
    1. How to find the number of files present in that directory?
    2. How to retreive more than 1 file at a time from the directory.
    Its bit urgent.
    Cheers,
    Naveen
    NOTE: Points will be awarded to every useful answer.

    hi,
       hope this FM can help.
    PARAMETER: p_file           type pfeflnamel DEFAULT '/usr/sap/tmp'.
    data: begin of it_filedir occurs 10.
            include structure salfldir.
    data: end of it_filedir.
    START-OF-SELECTION.
    Get Current Directory Listing for OUT Dir
    call function 'RZL_READ_DIR_LOCAL'
           exporting
                name     = p_file
           tables
                file_tbl = it_filedir.
    List of files are contained within table it_filedir
      loop at it_filedir.
        write: / it_filedir-NAME.
      endloop.
    rgds
    Umakanth

  • How to upload .CSV file from Application Server

    Hi Experts,
        How to upload .CSV file separated by ',' from Application server to an internal table.
    Invoice No,Cust No,Item Type,Invoice Date,days,Discount Amount,Gross Amount,Sales Amount,Customer Order No.,Group,Pay Terms
    546162,3233,1,9/4/2007,11,26.79,5358.75,5358.75,11264,HRS,11
    546163,2645,1,9/4/2007,11,3.07,305.25,305.25,10781,C,11
    Actually I read some already answered posts. But still I have some doubts.
    Can anybody please send me the code.
    Thanks in Advance.

    Hi Priya,
    Check this code
    Yhe logic used here is as follows,
    Get all the data into an internal table in the simple format ie: a row with one field contains an entire line
    After getting the data, we split each line of the table on every occurrence of the delimiter (comma in your case)
    Here, I have named the fields as field01, field02 etc, you could use your own names according to your requirement
    parameters: p_file(512).
      DATA : BEGIN OF ITAB OCCURS 0,
              COL1(1024) TYPE C,
             END OF ITAB,
             WA_ITAB LIKE LINE OF ITAB.
      DATA: BEGIN OF ITAB_2 OCCURS 0,
        FIELD01(256),
        FIELD02(256),
        FIELD03(256),
        FIELD04(256),
        FIELD05(256),
        FIELD06(256),
        FIELD07(256),
        FIELD08(256),
        FIELD09(256),
        FIELD10(256),
        FIELD11(256),
        FIELD12(256),
        FIELD13(256),
        FIELD14(256),
        FIELD15(256),
        FIELD16(256),
       END OF ITAB_2.
      DATA: WA_2 LIKE LINE OF ITAB_2.
        OPEN DATASET p_FILE FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.
        IF SY-SUBRC = 8.
          WRITE:/ 'File' , p_FILE , 'cannot be opened'.
          LV_LEAVEPGM = 'X'.
          EXIT.
        ENDIF.
        WHILE SY-SUBRC <> 4.
          READ DATASET p_FILE INTO WA_ITAB.
          APPEND WA_ITAB TO ITAB.
        ENDWHILE.
        CLOSE DATASET p_FILE.
      LOOP AT ITAB INTO WA_ITAB.
        SPLIT WA_ITAB-COL1 AT ','    " where comma is ur demiliter
         INTO WA_2-FIELD01 WA_2-FIELD02 WA_2-FIELD03 WA_2-FIELD04
         WA_2-FIELD05 WA_2-FIELD06 WA_2-FIELD07 WA_2-FIELD08 WA_2-FIELD09
         WA_2-FIELD10 WA_2-FIELD11 WA_2-FIELD12 WA_2-FIELD13 WA_2-FIELD14
         WA_2-FIELD15 WA_2-FIELD16.
        APPEND WA_2 TO ITAB_2.
        CLEAR WA_2.
      ENDLOOP.
    Message was edited by:
            Kris Donald

  • Sending an Email by taking excel sheet from Application Server.

    Hi.
    I Searched in SDN related 'Sending an Email by taking excel sheet from Application Server'.
    But i didnt get. I got sending mails from local pc.
    Can some bdy provide me sample code how to send mail with an attachment. the attached file should get from Application Server
    Regards,
    Renu

    Hi,
    For writing data to app server from internal table:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/prog%252bon%252bopen%252bdataset%252binput
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/prog%252bon%252bopen%252bdataset%252boutput
    Checkout this wiki for sending XL in mail attachment:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/multiple%252battachment%252bon%252be_mail
    Thanks,
    Krishna

  • Infopackage-Load Many Files from Application Server and later Archive/Move

    Hi All..
      I have a doubt,   I have a requirement of take many files to load into BI 7.0..  I used the infopackage before with option:
    Load Binary File From Application server
      I load information successfully... only with one file ...but If I can load many files (with different names) like the next list.. I think it's not a good idea modify the file name (path) on infopackage each time).. :
    *All of this files will be on one server that itu2019s map into AL11.. Like
    Infopfw
    BW_LOAD_20090120.txt
    BW_LOAD_20090125.txt
    BW_LOAD_OTHER_1.txt
    u2026.
    Etc..
    This directory it's not in BW server.. It's other server..but I can load form this location (one file by one)
    Could you help me with this questions:
    -     How can I Use an infopackage with routine that take all the files..one by oneu2026 in order of creation dateu2026and load into Target? Is it possible?.. I have some knowledge of ABAP.. but I don´t know exactly how I can say to system this logicu2026
    -     In addition is it possible move this files to other locationu2026 like into Infopfwarchive u2026 just to have an history of files loaded.
    I saw that in infopackage you have an option to create a routine.. in ABAP codeu2026 Iu2019m a little bit confused because I donu2019t  know how I can specify all the path..
    I try with:
    Infopfw
    InfopfwFile.csv
    Infopfw
    This is the abap code that automatically you see and you need to modifyu2026
    Create a routine for file name
    This routine will be called by the adapter,
    when the infopackage is executed.
              p_filename =
              p_subrc = 0.
    Thank you for your ideas or recommendations.
    Al

    Hi Reddy, thank you for your answer
    I have some doubuts.. when you explain me the option:
    All the above files are appending dates at the end of the file....
    You can load the files through infopackage by using Routines and pick the files based on date at the end of the file..***
    I need to ask you if you think that when you know the date of the file and the infopackage pick each file... thi can work for many files??... or how it's possible control this process?
    About this option, I want to ask you If when you menction Unix code... where it's programed this code?.. in the routine of BW Infopackage??
    ****Or
    Create two folders in your BW in Application server level, in AL11 (ask Basis team)
    I call it is F1 and F2 folders.
    First dump the files into F1 I assume that the file name in F1 is "BW_LOAD_20090120.txt", using Unix code you rename the file and then keep in the same foleder F1 or move to F2.
    Then create InfoPackage and fix the file name (i.e. you renamed), so you don't need to change everyday your file name at infopackage level.Because in AL11 everyday the file are overwrite.
    To I get BW_LOAD_20090120.txt file in F1, then I renamed to BW_LOAD.txt and loaded into BW, then tomorrow I get BW_LOAD_20090125.txt in F1, then I renamed to BW_LOAD.txt....
    so in this way it will work.You need to schedule the Ubix script in AL11.
    This is the way how to handle the application server...I'm using the same logic.
    Thank you soo much.
    Al

  • How to Select the Latest file from Application Server?

    Dear All,
    I am working on object, which had requirement to Pick the file from application server.
    The Application server contain the files in ‘/temp/sms/’ directory. The files are having the name Like ‘smsqry_yyyymmddhhmmss.txt’ and I have to Pick the Latest file (Base on file name for eg. 'smsqry_20060713102333’) from that all and after getting the file I have to delete the file from application server.
    So How to do this.
    Regards

    hi,
    look function group EPSF-
    esp. fm EPS_GET_DIRECTORY_LISTING
    if you're looking fo OS-date and time
    look here:Re: How do I convert MTIME to date and time?
    A.
    Message was edited by: Andreas Mann

  • File from Application server into BW

    Hi All,
    I have a urgent requirement and I do not know much of ABAP
    The requirement is
    selecting existing file from application server Dynamically in BW server. This will be done by writing an ABAP code at the InfoPackage level in the External Data Tab but I am in need some ABAP code for the same
    Also let me know which table stores AL11 files
    I know USER_DIR stores directories but I required the table for the files within the directories.
    Any help is appreciated

    Hi DPN,
    If we have a condition like depending on System Date we have to get a file some thing like that then we can do that by using the ABAP Routine. But in your Scenario there are no specific conditions to select a file.
    If we have some variable which stores the value which we give and gets the specified file... That Would be Great.
    But in Routine we can not use Variables..(As Far As I Know)
    So better Select manually every time...
    Hope This Helps.
    Regards,
    rik.

  • Uploading and reading file from application server

    Hi
    My problem is when am uploading a file to application server it is getting stored in
    usr/sap/transyp1/prod/in   directory
    after that i want to read that file from application server to update database
    when  using below code it is showing some other directory in f4 help
    DATA: lv_hostname TYPE msxxlist-name.
    DATA: lv_server TYPE bank_dte_jc_servername.
    PARAMETERS: p_file TYPE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION 'BANK_API_SYS_GET_CURR_SERVER'
    IMPORTING
    e_server = lv_server.
    lv_hostname = lv_server.
    CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
    EXPORTING
    dynpfield_filename = 'P_FILE'
    dyname = sy-cprog
    dynumb = '1000'
    filetype = 'P'
    location = 'A'
    server = lv_hostname.
    experts could you please help me out
    Thanks & Regards
    Nagesh.Paruchuri

    User Transaction file. You will get all logical file path names.
    used following fucntion module to read file name and use command open dataset to read the file.
    CALL FUNCTION 'FILE_GET_NAME'
           EXPORTING
                CLIENT           = SY-MANDT
                LOGICAL_FILENAME = C_LOGICAL_FILENAME
                OPERATING_SYSTEM = SY-OPSYS
                PARAMETER_1      = P_IN_FILENAME
           IMPORTING
                FILE_NAME        = P_OUT_FILENAME
           EXCEPTIONS
                FILE_NOT_FOUND   = 1
                OTHERS           = 2.
    OPEN DATASET P_OPEN_FILE ENCODING UTF-8 IN TEXT MODE FOR OUTPUT.
      IF SY-SUBRC <> 0.
        MESSAGE E000(38) WITH 'Error in Opening file: ' V_PHY_FILENAME.
      ENDIF.

  • File download from application server to presentation server

    Hi,
         We have requirment to upload a file to application server in .dbf format and then download it to presentation server.  while downloading the file to presentation server some of the fields  getting junk values.  we are downloading file to excel sheet.  some of the fields values are Russian texts.  Those fields only getting junk values, all other fields are getting correct values.
    Please advice.
    Regards,
    chandra.

    hi
    sample code below should help you......
    <u>Download to presentation server</u>
    This program can be used to download files from Application server to presentaion server.
    1)Maximum length of each field is considered to be 40 characters.
    2)Maximum length of the field can be changed by specifying the length in selection screen parameter
    3)First line of the Application server file should contain the description of each field.
    4)Each field should be delimited by #.
    *& Report ZDOWNLOADFILE *
    REPORT ZDOWNLOADFILE
    MESSAGE-ID B1 .
    INCLUDES *
    INCLUDE ZDOWNLOADFILE_TOP.
    INCLUDE ZDOWNLOADFILE_FORM.
    EVENT-AT SELECTION-SCREEN *
    AT SELECTION-SCREEN ON pa_appl.
    PERFORM check_file_exists USING pa_appl.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_appl.
    PERFORM f4_dxfilename USING pa_appl.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_pres.
    PERFORM f4_filename USING pa_pres.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_del.
    PERFORM f4_dxfilename USING pa_del.
    EVENT INITIALIZATION *
    INITIALIZATION.
    PERFORM initialization.
    EVENT START-OF-SELECTION *
    START-OF-SELECTION.
    PERFORM determine_fields. "Determine number of columns
    PERFORM build_itab. "Create internal table based on number
    "of columns
    PERFORM build_header. "To prepare header for the file
    PERFORM download_data. "Download data to presentation server
    PERFORM delete_files. "Delete files from application server
    *& Include ZDOWNLOADFILE_TOP *
    TYPES: BEGIN OF ty_header,
    text(100) TYPE c,
    END OF ty_header.
    DATA: c_fnh_mask type dxfields-filemask value '.',
    search_dir type dxfields-longpath value '/sapglobal/users'.
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    Internal tables *
    DATA: gt_header TYPE STANDARD TABLE OF ty_header,
    gt_fieldcat TYPE lvc_t_fcat.
    Work areas *
    DATA: gs_header TYPE ty_header,
    gs_fieldcat TYPE lvc_s_fcat.
    DATA: wa_filename TYPE string.
    DATA: wa_count(2) TYPE N,
    wa_start(3) TYPE N,
    wa_end(3) TYPE N,
    wa_len(3) TYPE N.
    DATA: wa_data(12000) TYPE c,
    wa_off TYPE I,
    itab_appl TYPE REF TO DATA,
    itab_line TYPE REF TO DATA,
    col(2) TYPE c.
    DATA: wa_field(30) TYPE c.
    DATA: lv_index TYPE sy-tabix.
    DATA: gs_adrp type adrp,
    gs_usr02 type usr02,
    gs_usr21 type usr21,
    gs_char50(50).
    CONSTANTS: co_slash(1) value '/'.
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
    <wa>,
    <fs_line>,
    <wa_line>.
    SELECTION SCREEN *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-f01.
    PARAMETERS: pa_appl LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE text-f02.
    PARAMETERS: pa_pres LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B2.
    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE text-f03.
    PARAMETERS: pa_del LIKE rlgrap-filename .
    PARAMETERS: pa_deld AS CHECKBOX.
    SELECTION-SCREEN END OF BLOCK B3.
    SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE text-f04.
    PARAMETERS: pa_len(3) TYPE c.
    SELECTION-SCREEN END OF BLOCK B4.
    *& Include ZDOWNLOADFILE_FORM *
    *& Form f4_dxfilename
    text
    -->P_pa_appl text
    form f4_dxfilename using p_file.
    DATA: wa_file LIKE dxfields-longpath.
    CLEAR: wa_file.
    call function 'F4_DXFILENAME_TOPRECURSION'
    exporting
    i_location_flag = 'A'
    i_server = ' '
    i_path = search_dir
    filemask = c_fnh_mask
    fileoperation = 'R'
    importing
    o_path = wa_file
    exceptions
    rfc_error = 1
    error_with_gui = 2
    others = 3
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    else.
    p_file = wa_file.
    endif.
    endform. " f4_dxfilename
    *& Form f4_filename
    text
    -->P_pa_pres text
    form f4_filename using p_data.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    PROGRAM_NAME = SYST-CPROG
    DYNPRO_NUMBER = SYST-DYNNR
    IMPORTING
    FILE_NAME = p_data
    endform. " f4_filename
    *& Form check_file_exists
    text
    -->P_pa_appl text
    form check_file_exists using p_file.
    DATA: wa_file LIKE rlgrap-filename.
    wa_file = p_file.
    OPEN DATASET wa_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc = 8.
    MESSAGE E714
    WITH text-m01 p_file text-m02.
    ELSE.
    CLOSE DATASET p_file.
    ENDIF.
    endform. " check_file_exists
    *& Form build_header
    text
    --> p1 text
    <-- p2 text
    form build_header .
    *Select user details
    clear gs_usr21-persnumber.
    select single persnumber
    into (gs_usr21-persnumber)
    from usr21
    where bname = sy-uname.
    concatenate sy-uname
    co_slash
    gs_adrp-name_text(36)
    co_slash
    into gs_char50.
    condense gs_char50.
    clear gs_usr02-class.
    select single class
    into (gs_usr02-class)
    from usr02
    where bname = sy-uname.
    concatenate gs_char50
    gs_usr02-class
    into gs_char50.
    condense gs_char50.
    Write report technical name
    write 'Name: ' TO gs_header+0(10).
    gs_header+11(*) = sy-repid.
    APPEND gs_header TO gt_header.
    CLEAR: gs_header.
    Write user data
    write 'User: ' TO gs_header+0(10).
    gs_header+11(*) = gs_char50.
    CONCATENATE gs_header gs_char50 INTO
    gs_header SEPARATED BY SPACE.
    APPEND gs_header TO gt_header.
    CLEAR: gs_header.
    Write System data
    write 'System: ' TO gs_header+0(10).
    write: sy-sysid to gs_header+11(3).
    write: co_slash to gs_header+14(1).
    write: sy-mandt to gs_header+15(3).
    APPEND gs_header TO gt_header.
    CLEAR: gs_header.
    Write System date and time
    write 'System: ' TO gs_header+0(10).
    write sy-datum to gs_header+11(10).
    write sy-uzeit to gs_header+22(8).
    APPEND gs_header TO gt_header.
    CLEAR: gs_header.
    Write Local date and time
    write 'Local: ' TO gs_header+0(10).
    write sy-datlo to gs_header+11(10).
    write sy-timlo to gs_header+22(8).
    APPEND gs_header TO gt_header.
    CLEAR: gs_header.
    APPEND gs_header TO gt_header.
    endform. " build_header
    *& Form determine_fields
    text
    --> p1 text
    <-- p2 text
    form determine_fields .
    DATA: wa_data(600) TYPE c.
    CLEAR: wa_count,wa_start,wa_end,wa_data.
    wa_start = 0.
    wa_end = 1.
    OPEN DATASET pa_appl FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    READ DATASET pa_appl INTO wa_data.
    wa_len = STRLEN( wa_data ).
    DO wa_len TIMES.
    IF wa_data+wa_start(wa_end) EQ
    cl_abap_char_utilities=>horizontal_tab.
    wa_count = wa_count + 1.
    ENDIF.
    wa_start = wa_start + 1.
    ENDDO.
    CLOSE DATASET pa_appl.
    wa_count = wa_count + 1.
    endform. " determine_fields
    *& Form build_itab
    text
    --> p1 text
    <-- p2 text
    form build_itab .
    DATA: wa_len(4) TYPE c.
    CLEAR: wa_len.
    IF pa_len IS INITIAL.
    wa_len = 40.
    ELSE.
    wa_len = pa_len.
    ENDIF.
    col = 1.
    DO wa_count TIMES.
    CONCATENATE 'FIELD' col INTO wa_field.
    gs_fieldcat-fieldname = wa_field.
    gs_fieldcat-outputlen = wa_len.
    gs_fieldcat-datatype = 'CHAR'.
    gs_fieldcat-col_pos = col.
    col = col + 1.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR: wa_field.
    ENDDO.
    *Create the internal table dynamically based on the file structure,
    *this table will be used to download data through GUI_DOWNLOAD fm
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = gt_fieldcat
    IMPORTING
    EP_TABLE = itab_appl
    *Assign the pointer to the field symbol
    ASSIGN itab_appl->* TO <itab>.
    CREATE DATA itab_line LIKE LINE OF <itab>.
    *Create a work area for the dynamic internal table
    ASSIGN itab_line->* TO <wa_line>.
    col = 1.
    OPEN DATASET pa_appl FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    DO.
    READ DATASET pa_appl INTO wa_data.
    IF sy-subrc <> 0.
    CLOSE DATASET pa_appl.
    RETURN.
    ELSE.
    wa_start = 0.
    lv_index = 1.
    DO wa_count TIMES.
    ASSIGN COMPONENT lv_index OF STRUCTURE <wa_line> TO <fs_line>.
    FIND cl_abap_char_utilities=>horizontal_tab
    IN wa_data+wa_start(*) MATCH OFFSET wa_off.
    IF sy-subrc = 0.
    IF wa_off NE 0.
    <fs_line> = wa_data+wa_start(wa_off).
    ENDIF.
    wa_start = wa_start + wa_off + 1.
    lv_index = lv_index + 1.
    ELSE.
    <fs_line> = wa_data+wa_start(*).
    ENDIF.
    ENDDO.
    APPEND <wa_line> TO <itab>.
    CLEAR: <wa_line>,<fs_line>.
    ENDIF.
    ENDDO.
    endform. " build_itab
    *& Form download_data
    text
    --> p1 text
    <-- p2 text
    form download_data .
    clear: wa_filename.
    wa_filename = pa_pres.
    call function 'GUI_DOWNLOAD'
    exporting
    filename = wa_filename
    filetype = 'DAT'
    tables
    data_tab = gt_header
    exceptions
    access_denied = 15
    call function 'GUI_DOWNLOAD'
    exporting
    filename = wa_filename
    filetype = 'DAT'
    append = 'X'
    tables
    data_tab = <itab>
    exceptions
    access_denied = 15
    endform. " download_data
    *& Form initialization
    text
    --> p1 text
    <-- p2 text
    form initialization .
    REFRESH: gt_header,gt_fieldcat,gt_header.
    endform. " initialization
    *& Form delete_files
    text
    --> p1 text
    <-- p2 text
    form delete_files .
    IF pa_deld EQ 'X'.
    DELETE DATASET pa_appl.
    ENDIF.
    IF pa_del IS NOT INITIAL.
    DELETE DATASET pa_del.
    ENDIF.
    endform. " delete_files
    <b>reward points if helpful.</b>
    thanks
    vijay

Maybe you are looking for

  • HT3986 I bought Windows 7 for my Mac and I want to add it to a partitioned MacBook.  Do I have to buy another Windows 7?

    I bought Windows 7 for my Mac and I want to add it to my MacBook.  Do I have to buy another Windows 7?

  • Load and syc Palm Z22 with Windows Vista 64

    I have an HP, Windows Vista 64 desktop. I have a Palm z22 PDA.  When I load the installation disk I get the following error - "Error 0x80040702, Failed to Load, DLL HSAPI, set up will terminate."  I can't load the disk so I can't even get to the inst

  • URGENT!! updating issue

    Hi, I'm trying to update my original iPhone from 2.0 to 3.0.1 and its hanging on "updating iPhone software" What should I do?? It's been like it for an hour. Cheers for any help Latest OS and all apps including iTunes up to date

  • Sales order not displaying in IC

    Hi, Sales order is not displaying in the Interaction center when we are searching the Customer. Please help me in this regard. Regards, Jay.

  • Slow Login Sometimes

    I'm using open directory and network accounts in my office. There are about 6 clients. Whenever I set up a client to go to the server for network accounts it works great for a period of time. But it seems like eventually they become incredible slow,