How to set dynamic file path in LSMW

I am working on LSMW  object to upload say excel file from my desktop.. if someone runs my lsmw application on their system obviously it fails.. is there way where I can dynamically set the path..I mean whomsoever runs the application it picks the file from their location and execute the program.

hi,,,
change your code accordingly
here i am  inserting data into ztable from excel .
*& Report  ZBI_UPLOAD_DATA_MAST                                             *
REPORT  zbi_upload_data_mast                        .
DATA : it_tab TYPE filetable,
       gd_subrc TYPE i.
TYPES : BEGIN OF wa_wrkctr,
        fictr TYPE zbi_fictr_mast-fictr,
        prctr TYPE zbi_fictr_mast-prctr,
        type TYPE zbi_fictr_mast-type,
        END OF wa_wrkctr.
DATA : wa_save TYPE zbi_fictr_mast.
DATA : gd_scol   TYPE i VALUE '1',
       gd_srow   TYPE i VALUE '1',
       gd_ecol   TYPE i VALUE '256',
       gd_erow   TYPE i VALUE '65536'.
DATA : it_datatab TYPE STANDARD TABLE OF wa_wrkctr WITH HEADER LINE INITIAL SIZE 0.
      it_phy_data TYPE STANDARD TABLE OF wa_energy WITH HEADER LINE INITIAL SIZE 0.
*data : w_current_inv_no(5) TYPE n,
      w_pop_up_text LIKE  wfcsr_ui_popup_text.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS:  p_file LIKE rlgrap-filename OBLIGATORY
             DEFAULT 'C:\Physical Stock.xls'  .
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = 'Select File Name'
      default_extension       = '*.xls'
      default_filename        = '*.xls'
      file_filter             = '*.xls'
      initial_directory       = 'c:\'
   MULTISELECTION          =
   WITH_ENCODING           =
    CHANGING
      file_table              = it_tab
      rc                      = gd_subrc.
   USER_ACTION             =
   FILE_ENCODING           =
EXCEPTIONS
   FILE_OPEN_DIALOG_FAILED = 1
   CNTL_ERROR              = 2
   ERROR_NO_GUI            = 3
   NOT_SUPPORTED_BY_GUI    = 4
   others                  = 5
  IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
    READ TABLE it_tab INTO p_file INDEX 1.
  ENDIF.
START-OF-SELECTION.
START-OF-SELECTION.
  PERFORM upload_excel_file TABLES   it_datatab
                             USING   p_file
                                     gd_scol
                                     gd_srow
                                     gd_ecol
                                     gd_erow.
PERFORM eventtab_build CHANGING lt_eventtab.
PERFORM display_data.
*&      Form  UPLOAD_EXCEL_FILE
      text
     -->P_IT_DATATAB  text
     -->P_P_FILE  text
     -->P_GD_SCOL  text
     -->P_GD_SROW  text
     -->P_GD_ECOL  text
     -->P_GD_EROW  text
FORM upload_excel_file  TABLES   p_it_datatab
                        USING    p_file
                                 p_scol
                                 p_srow
                                 p_ecol
                                 p_erow.
  DATA : lt_intern TYPE  kcde_cells OCCURS 0 WITH HEADER LINE.
Has the following format:
            Row number   | Colum Number   |   Value
     i.e.     1                 1             Name1
              2                 1             Joe
  DATA : ld_index TYPE i.
  FIELD-SYMBOLS : <fs>.
Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
    EXPORTING
      filename                = p_file
      i_begin_col             = p_scol
      i_begin_row             = p_srow
      i_end_col               = p_ecol
      i_end_row               = p_erow
    TABLES
      intern                  = lt_intern
    EXCEPTIONS
      inconsistent_parameters = 1
      upload_ole              = 2
      OTHERS                  = 3.
  IF sy-subrc <> 0.
    FORMAT COLOR COL_BACKGROUND INTENSIFIED.
    WRITE:/ 'Error Uploading file'.
    EXIT.
  ENDIF.
  IF lt_intern[] IS INITIAL.
    FORMAT COLOR COL_BACKGROUND INTENSIFIED.
    WRITE:/ 'No Data Uploaded'.
    EXIT.
  ELSE.
    SORT lt_intern BY row col.
    LOOP AT lt_intern.
      MOVE lt_intern-col TO ld_index.
      ASSIGN COMPONENT ld_index OF STRUCTURE it_datatab TO <fs>.
      MOVE lt_intern-value TO <fs>.
      AT END OF row.
        APPEND it_datatab.
        CLEAR it_datatab.
      ENDAT.
    ENDLOOP.
  ENDIF.
  IF it_datatab[] IS NOT INITIAL.
    DELETE FROM zbi_fictr_mast.
    COMMIT WORK.
    LOOP AT it_datatab.
      wa_save-fictr = it_datatab-fictr.
      wa_save-prctr = it_datatab-prctr.
      wa_save-type  = it_datatab-type.
      INSERT INTO zbi_fictr_mast VALUES wa_save.
      IF sy-subrc = 0.
        COMMIT WORK.
        MESSAGE 'Data upload complete' TYPE 'S'.
      ENDIF.
      CLEAR wa_save.
      CLEAR it_datatab.
    ENDLOOP.
  ENDIF.
ENDFORM.                    " UPLOAD_EXCEL_FILE
i hope this will help .
Regards
Deepak

Similar Messages

  • How to set the file path dynamically based on sytem, username, and date

    Hi All,
    My requirement is upload the data into one  structure like xyz that is related to t.code MCSZ.
    file will be in  UNIx SERVER .
    PATH IS: /sapif
    file name is xy789 load .txt
    I have  to write code in one user-exit
    how can i set the file path for this.
    shall i put hard code file path?
    because i have to writecode in user-exit.
    plz tell me how to set the file path based ons syetem, username, date
    Thanks in advance
    Ram.A

    Concatenate the field SY-SYSID, SY-UNAME and SY-DATUM for the file path

  • How to set default file path while downloading alv output

    Hi,
    Can anyone tell me that how to set default file path while downloading the ALV output to system using Local file button on tool bar.
    Please look below screenshots:
    Kindly help me resolve it.
    Thanks in advance.
    Regards,
    Ashutosh Katara

    This information initial value is (maybe) stored in Windows Register (register.exe) at Software\SAP\SAPGUI Front\SAP Frontend Server\Filetransfer -> PathDownload, you can read it thru class CL_GUI_FRONTEND_SERVICES method GET_UPLOAD_DOWNLOAD_PATH and update it thru method REGISTRY_SET_VALUE. (Else there may be some parameter ID to force data, but I'm no longer sure)
    Regards,
    Raymond

  • How to give dynamic file path in the selection  screen

    Hi All,
    How to give dynamic file path f4 functionality to user on the selection so that he can browse for the path in the presentation serve? I believe there is one fun module is there for this purpose I am not getting that
    Please help me in this regard.
    Thanks&Regards
    Mahesh

    HI,
    check this program.
    <b>report ZWA_TEST2.
    PARAMETERS: a(100) default 'PRESS F4'.
    data: filet type table of FILE_TABLE.
    data: wa type file_table.
    data: count type i.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR a.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
      CHANGING
        FILE_TABLE              = filet
        RC                      = count .
    loop at filet into wa.
      a = wa-FILENAME.
    endloop.</b>
    Regards,
    HRA

  • How to set the File Path to run a javascript using Plugin Code?

    Hi All,
    Im new to Indesign Plugin Development.Can any one help me out with my problem.
    What i want to do is to run a javascript using Plugin Code.When i went through this forum i was able to find out that i should use the IscriptRunner Class to automate this.I could also figure out that the Member Function to use is "CanHandleFile" &"RunFile".
    The first parameter in CanHandleFile & RunFile Member Function is to specify the path of the JavaScript File i suppose!I could also find out that IDFile has to used to set the file path Information.
    But im clueless how to set the Javascript FilePath using IDFile.Can any one help me how to do this?Any Code Snippets Please?
    Waiting for reply.
    Thanks
    myRiaz

    Hi,  Andreas<br /><br />  Can you explain this in detail? I found it in your post before.<br /><br />  The content of elements are returned through the Characters callback function:<br /><br />From ISaxContentHandler.h:<br /><br />/**<br />        Receives character data<br /><br />The parser will call this method to report each chunk of<br />        character data. SAX parsers may return all contiguous<br />        character data in a single chunk, or they may split it into<br />        several chunks. But all characters in any single<br />        event must come from the same external entity so the<br />        Locator provides useful information.<br /><br />Note some parsers will report whitespace using the<br />        IgnorableWhitespace() method rather than this one (validating<br />        parsers must do so).<br /><br />@param Chars The characters from the XML document.<br />        */<br />virtual void Characters(const PMString& chars) = 0; <br /><br />  What i have done is implement my own SAXContentHandlerServiceBoss, and in my file XXXSAXContentHandler.cpp, I override the fonctions StartElement, EndElement, and Characters() like below: I add the PMString xmlData to collect the file content:<br /><br />class XXXSAXContentHandler : public CSAXContentHandler<br />{<br />void XXXSAXContentHandler::Characters(const WideString& chars)<br />{<br />xmlData.Append(chars);<br />}<br /><br />void XXXSAXContentHandler::StartElement(const WideString& uri, const WideString& localname, const WideString& qname, ISAXAttributes* attrs)<br />{<br />xmlData.Append("<"); xmlData.Append(localname); xmlData.Append(">");<br />}<br />void XXXSAXContentHandler::EndElement(const WideString& uri, const WideString& localname, const WideString& qname)<br />{<br />xmlData.Append("</"); xmlData.Append(localname); xmlData.Append(">");<br />}<br /><br />}<br /><br />and in my program, I use the code below to call the fonction I overrided, but I dont know how I can get the String xmlData I defined in the XXXSAXContentHandler.cpp<br /><br />InterfacePtr<IK2ServiceRegistry> serviceRegistry(gSession, UseDefaultIID());<br /><br />InterfacePtr<IK2ServiceProvider> xmlProvider(serviceRegistry->QueryServiceProviderByClassID(kXMLParserService, kXMLParserServiceBoss));<br /><br />InterfacePtr<ISAXServices> saxServices(xmlProvider, UseDefaultIID());<br />InterfacePtr<ISAXContentHandler> saxHandler(::CreateObject2<ISAXContentHandler>(kXXXSAXContentHandlerServiceBoss));<br />saxHandler->Register(saxServices);<br />bool16 parseFailed = saxServices->ParseStream(readStream, saxHandler);<br /><br />Can you give me any help?<br /><br />Thanks and regards!

  • How to set default file path for save

    Hello all,
    I'm currently blocked on the below issue and is hoping to gain your help and insights.
    We have recently upgraded to InDesign CS6. Now when an INDD file created in an older version of INDD is opened in CS6, all the save dialogs would not default to the location of the original INDD file. Though if the same file is opened in the version of InDesign that created it, the save dialog goes to the proper location by default.
    Debugged using our custom plugin as a gate way, and found out that after InDesign CS6 performed the document upgrade/convert, the database for the converted document loses file information. i.e.  IDataBase::GetSysFile() returns nil. I think we can figure out some way to get the original file path. For example, we can intercept "kAfterOpenDocSignalResponderService", and get the original file path of the opened file from IDocumentSignalData. Though I haven't yet able to figure out a safe way to set this file path to the document, so that the save dialogs would by default point at this path.
    Utils<Facade::IWorkgroupFacade>()->InitDocumentAssetManagement(docRef, filePath) seems to do the right thing, but it seems to be quite intruding, and I'm afraid that it is overkilling and will cause bad side effect for the use case I'm looking for.
    So I'm wondering if anyone has any suggestions to achieve this without implementing/overriding the file save dialog.
    Thanks.
    -Jeff

    You should be able to avoid writing your own open-doc trap by using kDocBoss's IOpenedFileInfo to obtain the original file's path. It seems fairly reliable; the only time I've seen it come up empty is for an opened QuarkXPress document.
    I'm afraid I don't know of a sanctioned way to change IDataBase::GetSysFile() without going through the database's SaveAs machinery. Overriding this behavior might only be possible by replacing the regular Save dialog with your own.
    But if InitDocumentAssetManagement() is helping, maybe the workgroup/asset management approach is worth pursuing. Have you tried spying on that call in the debug app? You might be able to isolate and use one of the commands that it's invoking (IAMSPManager::BindAsset() / kSetAssetAttributesCmdBoss?) without all of the side-effects of the higher-level call.

  • New to workshop: how to set source file path

    Hello,
    I am new to workshop. I used to use Jdeveloper where I can set project settings to specify java source root and html source root. that way, my source code does not need to be under the standard directory app/project/src/....
    I am wondering if workshop can do the same thing?
    I tried to use import function, but it only copy the files over to its standard directory.

    Hello,
    I am new to workshop. I used to use Jdeveloper where I can set project settings to specify java source root and html source root. that way, my source code does not need to be under the standard directory app/project/src/....
    I am wondering if workshop can do the same thing?
    I tried to use import function, but it only copy the files over to its standard directory.

  • How to set dynamic name of the mail attachment according to source file ?

    Hi,gurus:
    Our scenario is like below:
    Sending files from an FTP server to another FTP server without using the integraiton repositary,and the file name is not changed .Now, we want to also send the file to some with by mail adapter.The scenario  now works by using two business services in receiver determination.But the name of the attachment is "untitled.xml".We know how to set the file name staticly,but how to set the name dynamicly according to the source file name ?
    I have checked miachel's blog "XI: Dynamic name in the mail attachment - pseudo "variable substitution"(/people/michal.krawczyk2/blog/2006/02/23/xi-dynamic-name-in-the-mail-attachment--pseudo-variable-substitution),but how can I get the source file name?
    And another question:Must we restart the adapter or j2ee engine to make the user defined module work?

    Hi,
    >>>but how can I get the source file name?
    form dynamicconfiguration (ASMA)
    >>>And another question:Must we restart the adapter or j2ee engine to make the user defined module work?
    no need for a restart
    Regards,
    Michal Krawczyk

  • How to set a file in uploadrequest ??

    hello
    I want to upload a file. In the request I have the path of the file
    // my.jsp
      String filepath = request.getParameter(filepath);
      <html:form action=/Upload  method="post"  enctype="multipart/form-data">
       <html:hidden property="filepath" value='<%=filepath%>'/>
    </html:form>
      // in the MyUploadAction class
       boolean isMultipart = FileUpload.isMultipartContent(request);  // true
       DiskFileUpload upload = new DiskFileUpload();
       List items = upload.parseRequest(request);
       Iterator iter = items.iterator();
        while (iter.hasNext()) {
                System.out.println("print somthing");
      problem:
         -   iter is empty  // iter.hasNext()    ----->   false
             how to set the file in the request ????
           / /note:  I want not to use  uploadAction from struts because of designingthanks

    The following blog post provides a way to create a document set using ECMA:
    http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
    The following blog post provides a way to upload files into a document set using CSOM:
    http://www.c-sharpcorner.com/Blogs/12139/how-to-create-document-set-using-csom-in-sharepoint-2013.aspx
    See if you can follow the logic in the CSOM example to apply it to ECMA. Let me know if you have specific problems with it.
    Dimitri Ayrapetov (MCSE: SharePoint)

  • How to set dynamic parameter in list of values in parameter property

    Hi,
    I am using cr4e-all-in-one-win_2.0.1version.I have created .rpt file in that how to set dynamic parameters(from database) in list of values parameter property
    Regards,
    amol

    Hi,
    I am using cr4e-all-in-one-win_2.0.1version.I have created .rpt file in that how to set dynamic parameters(from database) in list of values parameter property
    Regards,
    amol

  • File browse : How to keep the file path in the file browse field?

    Hello,
    I have
    1) file browse field called P2_FILE_PATH.
    2) a select list with submit : P2_REGION
    If i upload some file d:\abc.gif , then select some region in the P2_REGION,
    P2_FILE_PATH will become empty. But in the session, i can find the blob value. but not the "d:\abc.gif "
    Using the following script I could capture the value of P2_FILE_PATH in a field
    P2_TEST.
    onload="javascript:document.getElementById(P2_FILE_PATH').value = document.getElementById('P2_TEST').value;"
    P2_TEST contains d:\abc.gif .
    How to retain the file path, though some other field is selected and submitted?
    Thanks in advance.
    Regards,
    Archana

    Hello Archana,
    You can't do what you want because of some HTML security restrictions – nothing to do with APEX. As you found out, You can capture the value of this item. You can't set it. After submitting the page, the browser is the one to clear the item.
    The only workaround is to work with AJAX and not submit the page until the end of the user input phase.
    Regards,
    Arie.

  • How to set the report path in a model plugin

    I am trying to figure out how to set the report path in a process model plug-in. I can seem to figure out how to get access to it. It seems like this would be a reasonable thing to do since the plug-ins are for results processing. Does anyone know how to do this? We typically use the Sequential process model but I am trying to keep my plug-in as independent of that as possible. 
    Thanks.
    Solved!
    Go to Solution.

    If I understand, you want your plug-in, when enabled, to alter the settings of any other instances of the NI report plug-in such that their reports share the same directory as your plug-in is configured to use.
    If so, your plug-in can access and modify the settings of all other plug-in instances. All instances are passed to all plug-in entries point in the plugins array sub-property of the ModelConfiguration parameter. You can iterate through this array. Any element of the array with a Base.SequenceFilename equal to "NI_ReportGenerator.seq" is an instance of the NI report plug-in. Its report options are stored in the element under PluginSpecific.Options.
    You can change the report options to what ever you want. Note that the ReportOptions model callback is called from the Initialize model-plugin entry point, so you might want to ensure that your changes are applied after that, so they aren't overwritten. To do that, you could make your changes in the the Initialize entry point of your plug-in, and ensure that your plugin runs last. To make it run last, you could set the FileGlobals.ModelPluginComponentDescription.Default.Base.RunOrder in your plug-in file to a value greater than 0, such as 1.0 (see TestStand Help>>Fundamentals>>Process Model Architecture>>Process Model Plug-in Architecture>>Structure of Plug-in Sequence Files>>Model Plug-in Entry Points>>Order of Entry Point Execution at Run Time).

  • Setting dynamic file name in Receiver file adapter - not from payload

    Guys I just remember reading a weblog but can't find it now that I need it, on how to set the file name in message mapping dynamically but not using any payload field.
    Please let me know if you remember this.
    Thanks a lot,
    Viktor Varga

    also u can check in
    <a href="/people/jayakrishnan.nair/blog/2005/06/28/dynamic-file-namexslt-mapping-with-java-enhancement-using-xi-30-sp12-part-ii file name(XSLT Mapping with Java Enhancement) using XI 3.0 SP12 Part -II</a>
    <a href="/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14: The same filename from a sender to a receiver file adapter - SP14</a>

  • Sun ONE Studio 4 aka Forte: How to set the output path for classes ?

    Help !
    Beginner's question:
    Sun ONE Studio 4 aka Forte:
    How to set the output path for classes ?
    As default, the class files are created in the same directory as the
    sources.
    In opposite, both JBuilder and Together support that there is a tree
    with the sources and another tree with the classes.
    The first answer I got was "not possible with Forte, but just if you write your own "ANT Build script" !
    a) Please point me to a ready-to-use ANT script for this purpose, if such is available
    b) Is using ANT instead of the MAKE as comfortable ? Besides the separation of sourcecode and classes, I would like to keep everything else to be the same, i.e. I don�t want to edit the ANT file if I enlarge the project by directories or files.
    Tia
    Sincerely
    Rolf

    You can set S1S's options to place newly created .class files in a specific location.
    Identify the compiler that is being used - Open the S1S's Tools/Options window, expand Editing and select Java Sources. Note the Default Compiler value. (If it's one if the Ant options, you use Ant to specify this option, not S1S.)
    Open the S1S's Tools/Options window, expand Building/Compiler Types and select the appropriate compiler.
    The Properties tab of the compiler has the property Target, which sets the filesystem where the compiler output is directed. If you choose <not set>, the .class files are written to their source directory.
    When you set the Target, your change affects all classes that use this compiler.
    Very few options can't be set in S1S; the challenge is finding out where they're set!

  • How to get the file path in adf application

    hii all,
    i have a txt file that i am using in my adf application,
    i am passing this txt file through a File Reader, for which i have to mention the file path.
    The file is in web-content and when i am hard coding the complete file path i.e C:/JDeveloper/myApp/ViewController/public_html/log.txt
    the application is working fine when run on integrated weblogic server.
    My requirement is to access this file without giving the static file path, as in case i have to use this application on any other machine..
    for that how to mention the file path-
    i tried using FacesContext to get the context path :-
    FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
    which gives me
    \myApp-ViewController-context-root
    after appending public_html\log.txt
    I am using the following path to access the file :-
    \myApp-ViewController-context-root\public_html\log.txt
    again i am getting the java.io.FileNotFoundException
    Does anyone know how to use file from inside the web-content without giving the complete path..???
    Thanks

    Hi,
    If you put your file under public_html folder, you can use this code to access the file:
    For example file is : log.txt
    FacesContext.getCurrentInstance().getExternalContext().getRealPath('/log.txt').toString().trim();
    Thanks.
    - LSR

Maybe you are looking for

  • How to use non default port 1521 while 11.2.0.1 grid upgrade to 11.2.0.2

    Hi Team , We are planning 11.2.0.1 Grid infra rolling upgrade to 11.2.0.2 with out any downtime. But while up gradation due to default scan port 1521 , 11.2.0.1 databases are not able to connect (remote connections) We are using 1900 port for existin

  • South Park Go God Go XII makes my PC freeze!

    What is this BS? My computer freezes for a minute and then the cursor moves 1/2 inch and then freezes again. I have to reboot to get rid of the problem? You giving us viruses with this crap, itunes?

  • Locking Objects in Page Layout Doc

    Just asking, applying objects to a section master or placing an object in the background is only available in a Word Processing document?  I need the flexibility of a Page Layout doc, but would like to have some objects on each page locked.  Why can'

  • CPO-Web Service Queries

    Hi All, I am trying to start a process using web service. I want to know, 1. How to get Task waiting for inputs of a user by web service. 2. How to get instance id of a process . 3. What is process start point ID or Name.( which is one of the paramet

  • Apple Wired keyboard problem

    hello i have mac pro purchased  in 2012..after cleaning up with thinner and dry it under the light for 5  to 10 minutes..its stopped working.. how ever in windows 7 it is getting detected in device and scanner option.but none keys are working....prev