Upload problem with BDCRECX1

hello,
i am trying to modify a sap document with uploading a txt file.the program has BDCRECX1 as include and while serching i have had some information about BDCRECX1 but stil i dont know what to do.
what am i suppossed to do with BDCRECX1 selection screen?

here it is :
***INCLUDE BDCRECX1.
*  for programs doing a data transfer by creating a batch-input session
*  and
*  for programs doing a data transfer by CALL TRANSACTION USING
SELECTION-SCREEN BEGIN OF LINE.
   PARAMETERS SESSION RADIOBUTTON GROUP CTU.  "create session
   SELECTION-SCREEN COMMENT 3(20) TEXT-S07 FOR FIELD SESSION.
   selection-screen position 45.
   PARAMETERS CTU RADIOBUTTON GROUP  CTU.     "call transaction
   SELECTION-SCREEN COMMENT 48(20) TEXT-S08 FOR FIELD CTU.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN COMMENT 3(20) TEXT-S01 FOR FIELD GROUP.
   selection-screen position 25.
   PARAMETERS GROUP(12).                      "group name of session
   SELECTION-SCREEN COMMENT 48(20) TEXT-S05 FOR FIELD CTUMODE.
   selection-screen position 70.
   PARAMETERS CTUMODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.
                                       "A: show all dynpros
                                       "E: show dynpro on error only
                                       "N: do not display dynpro
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN COMMENT 3(20) TEXT-S02 FOR FIELD USER.
   selection-screen position 25.
   PARAMETERS: USER(12) DEFAULT SY-UNAME.     "user for session in batch
   SELECTION-SCREEN COMMENT 48(20) TEXT-S06 FOR FIELD CUPDATE.
   selection-screen position 70.
   PARAMETERS CUPDATE LIKE CTU_PARAMS-UPDMODE DEFAULT 'L'.
                                       "S: synchronously
                                       "A: asynchronously
                                       "L: local
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN COMMENT 3(20) TEXT-S03 FOR FIELD KEEP.
   selection-screen position 25.
   PARAMETERS: KEEP AS CHECKBOX.       "' ' = delete session if finished
                                       "'X' = keep   session if finished
   SELECTION-SCREEN COMMENT 48(20) TEXT-S09 FOR FIELD E_GROUP.
   selection-screen position 70.
   parameters E_GROUP(12).             "group name of error-session
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN COMMENT 3(20) TEXT-S04 FOR FIELD HOLDDATE.
   selection-screen position 25.
   PARAMETERS: HOLDDATE LIKE SY-DATUM.
   SELECTION-SCREEN COMMENT 51(17) TEXT-S02 FOR FIELD E_USER.
   selection-screen position 70.
   PARAMETERS: E_USER(12) DEFAULT SY-UNAME.    "user for error-session
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN COMMENT 51(17) TEXT-S03 FOR FIELD E_KEEP.
   selection-screen position 70.
   PARAMETERS: E_KEEP AS CHECKBOX.     "' ' = delete session if finished
                                       "'X' = keep   session if finished
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN COMMENT 51(17) TEXT-S04 FOR FIELD E_HDATE.
   selection-screen position 70.
   PARAMETERS: E_HDATE LIKE SY-DATUM.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN COMMENT 1(33) TEXT-S10 FOR FIELD NODATA.
   PARAMETERS: NODATA DEFAULT '/' LOWER CASE.          "nodata
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
   SELECTION-SCREEN COMMENT 1(33) TEXT-S11 FOR FIELD SMALLLOG.
   PARAMETERS: SMALLLOG as checkbox.  "' ' = log all transactions
                                      "'X' = no transaction logging
SELECTION-SCREEN END OF LINE.
*   data definition
*       Batchinputdata of single transaction
DATA:   BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.
*       messages of call transaction
DATA:   MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
*       error session opened (' ' or 'X')
DATA:   E_GROUP_OPENED.
*       message texts
TABLES: T100.
*   at selection screen                                                *
AT SELECTION-SCREEN.
* group and user must be filled for create session
   IF SESSION = 'X' AND
      GROUP = SPACE OR USER = SPACE.
     MESSAGE E613(MS).
   ENDIF.
*   open dataset                                                       *
FORM OPEN_DATASET USING P_DATASET.
   OPEN DATASET P_DATASET
                FOR INPUT IN TEXT MODE
                ENCODING DEFAULT.
   IF SY-SUBRC <> 0.
     WRITE: / TEXT-E00, SY-SUBRC.
     STOP.
   ENDIF.
ENDFORM.
*   close dataset                                                      *
FORM CLOSE_DATASET USING P_DATASET.
   CLOSE DATASET P_DATASET.
ENDFORM.
*   create batchinput session                                          *
*   (not for call transaction using...)                                *
FORM OPEN_GROUP.
   IF SESSION = 'X'.
     SKIP.
     WRITE: /(20) 'Create group'(I01), GROUP.
     SKIP.
*   open batchinput group
     CALL FUNCTION 'BDC_OPEN_GROUP'
          EXPORTING  CLIENT   = SY-MANDT
                     GROUP    = GROUP
                     USER     = USER
                     KEEP     = KEEP
                     HOLDDATE = HOLDDATE.
     WRITE: /(30) 'BDC_OPEN_GROUP'(I02),
             (12) 'returncode:'(I05),
                  SY-SUBRC.
   ENDIF.
ENDFORM.
*   end batchinput session                                             *
*   (call transaction using...: error session)                         *
FORM CLOSE_GROUP.
   IF SESSION = 'X'.
*   close batchinput group
     CALL FUNCTION 'BDC_CLOSE_GROUP'.
     WRITE: /(30) 'BDC_CLOSE_GROUP'(I04),
             (12) 'returncode:'(I05),
                  SY-SUBRC.
   ELSE.
     IF E_GROUP_OPENED = 'X'.
       CALL FUNCTION 'BDC_CLOSE_GROUP'.
       WRITE: /.
       WRITE: /(30) 'Fehlermappe wurde erzeugt'(I06).
       E_GROUP_OPENED = ' '.
     ENDIF.
   ENDIF.
ENDFORM.
*        Start new transaction according to parameters                 *
FORM BDC_TRANSACTION USING TCODE.
   DATA: L_MSTRING(480).
   DATA: L_SUBRC LIKE SY-SUBRC.
* batch input session
   IF SESSION = 'X'.
     CALL FUNCTION 'BDC_INSERT'
          EXPORTING TCODE     = TCODE
          TABLES    DYNPROTAB = BDCDATA.
     IF SMALLLOG <> 'X'.
       WRITE: / 'BDC_INSERT'(I03),
                TCODE,
                'returncode:'(I05),
                SY-SUBRC,
                'RECORD:',
                SY-INDEX.
     ENDIF.
* call transaction using
   ELSE.
     REFRESH MESSTAB.
     CALL TRANSACTION TCODE USING BDCDATA
                      MODE   CTUMODE
                      UPDATE CUPDATE
                      MESSAGES INTO MESSTAB.
     L_SUBRC = SY-SUBRC.
     IF SMALLLOG <> 'X'.
       WRITE: / 'CALL_TRANSACTION',
                TCODE,
                'returncode:'(I05),
                L_SUBRC,
                'RECORD:',
                SY-INDEX.
       LOOP AT MESSTAB.
         SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA
                                   AND   ARBGB = MESSTAB-MSGID
                                   AND   MSGNR = MESSTAB-MSGNR.
         IF SY-SUBRC = 0.
           L_MSTRING = T100-TEXT.
           IF L_MSTRING CS '&1'.
             REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING.
             REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING.
             REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING.
             REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING.
           ELSE.
             REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING.
             REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING.
             REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING.
             REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING.
           ENDIF.
           CONDENSE L_MSTRING.
           WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).
         ELSE.
           WRITE: / MESSTAB.
         ENDIF.
       ENDLOOP.
       SKIP.
     ENDIF.
** Erzeugen fehlermappe ************************************************
     IF L_SUBRC <> 0 AND E_GROUP <> SPACE.
       IF E_GROUP_OPENED = ' '.
         CALL FUNCTION 'BDC_OPEN_GROUP'
              EXPORTING  CLIENT   = SY-MANDT
                         GROUP    = E_GROUP
                         USER     = E_USER
                         KEEP     = E_KEEP
                         HOLDDATE = E_HDATE.
          E_GROUP_OPENED = 'X'.
       ENDIF.
       CALL FUNCTION 'BDC_INSERT'
            EXPORTING TCODE     = TCODE
            TABLES    DYNPROTAB = BDCDATA.
     ENDIF.
   ENDIF.
   REFRESH BDCDATA.
ENDFORM.
*        Start new screen                                              *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
   CLEAR BDCDATA.
   BDCDATA-PROGRAM  = PROGRAM.
   BDCDATA-DYNPRO   = DYNPRO.
   BDCDATA-DYNBEGIN = 'X'.
   APPEND BDCDATA.
ENDFORM.
*        Insert field                                                  *
FORM BDC_FIELD USING FNAM FVAL.
   IF FVAL <> NODATA.
     CLEAR BDCDATA.
     BDCDATA-FNAM = FNAM.
     BDCDATA-FVAL = FVAL.
     APPEND BDCDATA.
   ENDIF.
ENDFORM.

Similar Messages

  • Uploading problem with Ebay and Dreamweaver MX

    I am unable to sync websites with Dreamweaver MX 6.01. When I connect to the remote server, it shuts down the program. I have reinstalled the program, but it still does it. Also, when I use Safari, Opera, and Firefox to upload photos on Ebay, the upload process fails completely, and blows me directly into My Ebay, as if I was not on the selling page at all. I have to go to my PC to do the photo uploads. Seems like it may be a related issue, some kind of uploading problem with Rosetta, or something. I am using a Macbook Pro with the 2.0Ghz processor, connected with ethernet cable, and firewall is set to off. Any ideas?

    For E-Bay you might try the following:
    Type the following command in Terminal (while Safari is NOT running):
    defaults write com.apple.Safari IncludeDebugMenu 1
    Then launch Safari, and you will be able to use the new Debug menu.
    If you ever wish to disable it again, just repeat the command with a "0" instead of a "1".
    Under the Debug menu, you'll see the User Agent sub-menu; select Windows MSIE 6.0 from the list and then try connecting to your web site
    Dreamweaver you might need to update your version.
    To Dreamweaver 8.01
    http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=f56452a8

  • Upload problems with Facebook and Vimeo from Premiere Elements 10

    I have created a project in HD and am trying to upload to Vimeo.  Premiere Elements 10 does not have a preset so I followed some instructions from the Vimeo website.  Project is "blurry" when viewed.  I checked with Vimeo and they said what they converted matches what I sent so the problem must be in the export - bit rate may be incorrect.  Can anyone give me the correct presets for Vimeo from Premiere Elements 10.  I can view other people's video in HD and they look fine so I don't think it's my computer monitor.   I'm sure you will need more information about my project so please give me a list of specific things you need to know.  Thank you.
    My Facebook problem is as follows.  If I use the preset from Premiere Elements 10 to upload to Facebook it looks fine, HD quality as expected.  Problem is, I would like to upload to my business page.  Since the personal page and the business page (managed by my personal account) share a login, the preset always loads to my personal page.  Does anyone know the values of the preset so I can upload the video to my business page.  My business is event and wedding videography so I would like the posts to be as clear as possible.
    If the problem with the Vimeo uploads is solved then I suppose I can just share the Vimeo file on Facebook.  Thank you.

    VDRAVES
    I think that you are overlooking what you already have with regard to a Vimeo HD preset for export to file for upload of the saved file at the Vimeo website.
    Please see
    Share/Computer/AVCHD with Presets = Vimeo HD
    Under the Advanced Button/Video Tab, you can customize the preset further from 1280 x 720 to 1920 x 1080 and increase the bitrate, if necessary, to a level that does not give you a prohibitive file size. With Profile = Main and Level = 3.1, the bitrate range is 0.19 to 14 Mbps (megabits per second).
    I would start with the default bitrates of Target = 8 Mbps and Maximium = 9 Mbps and explore and experiment from there.
    If you customize the preset to 1920 x 1080 in the Export Settings customization area, then change the Profile to High and the Level to 5.1
    When you do that the bitrate range will be 0.19 to 300 Mbps instead of 0.19 to 14 Mbps.
    In all cases, watch for file size versus bitrate versus quality of end product.
    Please give that a look and then let us know if the above resolves your Vimeo and Facebook question.
    Please review and let us know the outcome.
    Thank you.
    ATR

  • RMDATIND uploading problem with external material numbers

    Hi,
    I'm using LSMW direct input program RMDATIND (Object:0020 Method:0000) for creating materials.
    I have a problem with uploading materials which have two types of external material numbers.
    For example one material number is 1111-333 and then we have 10000000. The problem is that direct input won't create materials with number 1111-333 though it's possible to create them manually. It works fine with material 10000000.
    Does anyone know how fix this issue?

    Sweth123 wrote:
    Hi Guys:
    >
    > Clicked check box External number assignment without Check., When I am creating a material (mm01) with only numeric characters it is giving me an eror message saying for this material type Numeric characters are not allowed.
    >
    > i should be able to create a material with external number range and it can be numeric or alpha numeric?
    >
    >
    > Thanks
    > Sweth
    Hi,
    go to the path Define Number Ranges for Each Material Type click on maintain groups & select the materila type & select the mouse on material type & click on maintain after that maintain the number ranges.
    for ex: from 300000000 to 399999999 internal no.range
                from A                to ZZZZZZ     external no.range
    from this u can able to create a material with external number range and it can be numeric or alpha numeric
    Regards
    Raj.

  • Vendor Master Upload Problem with Check Box

    Hi All,
    I have a problem with Vendor Master Upload program. In one of the screen of XK01 transaction depending upon the PO Box, Postal Code, Other City and Other Region i have to check the PO Box w/o no check Box. So in my program after i check the PO Box, Postal Code, Other City and Other Region values how to write a code that i can check the PO Box w/o no. Or other wise how can i send value to the Po Box w/o no check box. field
    Thanks in advance.

    The call to the first screen should look something like:
        perform dynpro
          tables bdcdata
          using:
         'X' 'SAPMF02K'     '0105',         "Create Vendor: Initial Screen
          ' ' 'RF02K-BUKRS'             'COCO',
          ' ' 'RF02K-KTOKK'             'YYYY',
          ' ' 'USE_ZAV'                 'X'.
    I'm using screen 105, not 100 here.
    Rob

  • Dreamweaver CS5.5 file upload problems with javascript

    Hi,
    Maybe someone can help me. I have both CS4 and CS5.5 and Lion installed.
    When I upload files to the remote server, formatting for all source code (including javascript) is lost. And then any javascript functions on the website do not work. I have the same problem when uploading files with Filezilla.
    Another problem - probably related - is that under Firefox javascript of my local website does not work (it works on a fresh start, but only for the first link), while the remote site under Firefox works fine. Safari works both remotely and local.
    Now, when I boot the Mac from the Snow Leopard partition, everything works just fine. So it must have to do with Lion.
    Does anyone know how to fix this, please?

    Hi, thank you for helping.
    Line Break is set to CR (Macintosh). I don't know what OS our host server is running. I would assume it is either  Linux or Windows.
    On the other user account Line Break was set to LF (Unix), so I switched it on my account as well.
    After that the file transferred with the code intact. Just out of curiosity I switched the setting back, and it still works, but only for new files. Also, old files can no longer be deleted.
    Firefox hasn't changed. Under the other user the local site works, under my user, the scripts still don't work.
    So, I am very confused. I will give Apple a call to see, how I can reset the user preferences and report back.

  • Fios upload problem with firefox

    just got 25Mb/25Mb Fios along with the Extreme HD tv service installed today and was having upload speed problems while running Firefox.  Had speed of 25Mb download but 4-7Mb upload.  Tested with IE8 and got download of 24-25Mb and upload of 21Mb.  Did another test with Google Chrome and got better result same 24Mb-25Mb download and 23-24Mb of upload.  What is the problem here with Firefox?   Currently running Window Vista Ultimate 64-bit version all updated to latest version, Intel i920 OC to 3.8Ghz, 6GB of Corsair Dominator DDR3 triple channel ram, Asus Deluxe P6T motherboard, ATI Raedon 4870 X2 (yea i know its a little old, but was waiting for the new videocards to get a little cheaper before upgrading to either the ATI 5870 or nVidia 470), harddrives are 300GB Velicoraptor and 1TB Seagate 7200rpm and 2TB WD Green drive.  Use this PC mainly for online gaming MMO's and FPS's games.  This PC was built around 2 years ago so parts are a little old, but was having no problem at my old home with Fios 15Mb/5Mb plan, got what i paid for there with the Firefox.  15Mb download and 5Mb upload everytime i tested the speed out for 3-5 months since it was installed. 
    Ran both Speedtest.net and Speaskeasy.net tests.  Fios guys even ran the optimizers and that didn't help at all, they said since this was an issue with Firefox and not IE or Chrome that was not really Verizon problem since i was able to get ~25Mb upload speed on the other 2 broswer.  Is anyone else having problem with their Firefox Upload Speed?
    Solved!
    Go to Solution.

    Be sure you have the latest version of Firefox/3.6.6. Some of the older versions may have had issues. I did a google search and only found the postings for upload speed issues from 2009 and back.
    My speed test with Firefox/3.6.6 Windows Vista Business 64 bit with service pack 2.
    http://www2.verizon.net/micro/speedtest/java/
    Checking for Middleboxes . . . . . . . . . . . . . . . . . . Done
    SendBufferSize set to [522720]
    running 10s outbound test (client to server) . . . . . 35.14Mb/s
    running 10s inbound test (server to client) . . . . . . 35.78Mb/s

  • Uploading problems with Safari 4.1.3 -

    Hello, I just thought this was a funny question to ask -
    On my PowerPC G5 tower, running OS 10.4.11, and my question is in regards to Safari version 4.1.3 uploading problems for facebook and youtube... I always have to use FireFox version 3.6.13... and not without trouble either.
    I get it.  I need a new computer, but I just thought it fascinating why one works 90% of the time and the other never works.

    Firefox is way more upto date than Safari in 10.4.11, but TenFourFox is the most up to date browser for our PPCs, they even have G4 & G5 optimized versions...
    http://www.floodgap.com/software/tenfourfox/
    Also I think they Require Flash &/or Java, which may be a problem in 10.4

  • Upload problem with animations?

    One slide in an Adobe Presenter 9 ppt program is not showing animations correctly upon uploading. In other words, I have 10 animations on the slide, with each coming up as I speak. The editing looks correct; the preview works correctly. When I upload it, however, this slide (and this slide only) has all the animations coming up at once and in an odd order. Suggestions?

    I was having the probleme (in case someone wants to know) ibecause "Presenter treats any object containing an equation or any 3D effect as an image.
    As a result the text box containing the equation was taken as an image and that was resulting in all the animations to go awry."  Mahesh did some magic.  Talk about service!  THANKs, publically!  Now I know how to treat equations on Presenter.

  • Facebook uploader problems with Snow leopard

    When I attempt to add photos in facebook the uploader appears but only a jpg icon shows in the frames - no pictures. before installing Snow leopard I use to get a request for facebook to use a java applet. I would say yes and the pics would load perfectly. I do not get the message with Snow Leopard. Any ideas?

    HI,
    Try this... In the Add More photos window, underneath that window look where it says: Try the Simple Uploader just under the word Cancel. It's much easier to use with Facebook on Safari.
    Carolyn

  • YouTube HD uploading problem with QT/Safari/Firefox...

    I've upgraded to Snow Leopard and now Safari and Firefox refuse to upload to YouTube- so I resorted to using Quicktime X, which worked... BUT... the movie was an HD file exported from Final Cut, and didn't upload to YouTube in HD. The only way I have been able to upload the HD version was to go via Windows under VMWare...
    Surely there must be an easier way? And why does Quicktime X downconvert as it uploads?

    For E-Bay you might try the following:
    Type the following command in Terminal (while Safari is NOT running):
    defaults write com.apple.Safari IncludeDebugMenu 1
    Then launch Safari, and you will be able to use the new Debug menu.
    If you ever wish to disable it again, just repeat the command with a "0" instead of a "1".
    Under the Debug menu, you'll see the User Agent sub-menu; select Windows MSIE 6.0 from the list and then try connecting to your web site
    Dreamweaver you might need to update your version.
    To Dreamweaver 8.01
    http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=f56452a8

  • Crazy upload problem with Ipod Video

    I have an Ipod Video 60gb that I've had no trouble with for a month. Suddenly, when I connect with Itunes to upload music, Itunes identifies the Ipod as having 190gb with 130-150gb already full. This is despite the fact that I've just restored my operating system on the Ipod and wiped it clean with Ipod Updater (6-28-06). Another interesting this is that after restoring the operating system, Itunes still knows the name of the Ipod and has a song list already attributed to it (on the Ipod view in Itunes) as if I've already got music on there. When I restored with Ipod Updater, it also thought I had 190gb. Itunes does the sync process and finishes normally, but there are no songs on the Ipod when it finishes. It's almost like there's two partitions on the Ipod and I can only see one of them. Crazy! Any thoughts?

    Go to the video settings (iPod nano) and turn off fit to screen.
    Click to download iPod nano (5th generation) - User Guide
    Message was edited by: David M Brewer

  • Does anyone have upload problems with macbook 10.6.7

    I am not able to upload any content for the past two weeks.

    What do you mean with "upload"?
    Upload a photo to Twitter?
    Upload a Video to Youtube?
    Upload a file from your Time Capsule to your Mac?
    Uploading a game from an iPhone to the Mac?

  • File Upload- problem with IE

    I am using commons file upload:
    When I do item.getName() I am getting the name of the file(When I use Mozilla Browser).
    But with IE I am getting the full path instead of name of file.
    So this creates the issues while uploading.
    Can any one help me out with this.
    Thanks
    Aniketh

    Just trim off the file path? The java.lang.String API offers useful methods for that.
    Also see http://balusc.blogspot.com/2007/11/multipartfilter.html for an example.

  • Uploading problem with my servlet..

    Hi All,
    I have spent almost several hours yesterday trying to figure this out.
    Here is the issue.
    I have written a servlet that uploads the files, not it works flawlessly with text files but when I upload binary data then there is a 2 bytes difference beetween the actual file and the file I upload. Hence corrupting the binary files.
    Can some one who might have come accross this shed some light...?
    thanks again

    Show us your code. Remember to use
    [code]...[/code] tags or the "code"
    button on the forum posting form.I have attached my core, I am just trying to make this work at this point so please forgive my lack of docs coding ...
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletInputStream;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    public class TestUpload extends HttpServlet {
        private URL contextPath;
        private String FILE_SEPARATOR;
        private static final String FILE_SEPARATOR_PROPERTY = "file.separator";
        private static final String MULTIPART_BEGIN_STRING = "Content-Disposition";
        private static final String MULTIPART_CONTENT_TYPE = "Content-Type";
        private static final String MULTIPART_BOUNDARY_FLAG = "-----------------------------";
        public void init(ServletConfig servletConfig) throws ServletException {
            super.init(servletConfig);
            try {
                contextPath = servletConfig.getServletContext().getResource("/uploads");
                FILE_SEPARATOR = System.getProperty(FILE_SEPARATOR_PROPERTY);
            } catch (MalformedURLException mfe) {
                mfe.printStackTrace();
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doWork(request, response);
        public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doWork(request, response);
        public void doWork(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            processRequest(request);
            //sendResponse(request,response);
        public synchronized void processRequest(HttpServletRequest request) throws ServletException, IOException {
            ServletInputStream servletInputStream = request.getInputStream();
            FileOutputStream fileOutputStream = null;
            int buffLen = 1024;
            int lineCtr = 0;
            String boundaryStart = "", boundaryEnd = "";
            boolean isOK = true, isData = false;
            String fileName = "";
            String previousLine = "";
            byte[] prevBytes = new byte[buffLen];
            int preRead = 0;
            int pre = 0;
            byte[] inputBytes = new byte[buffLen];
            int readLen = 0;
            while ((readLen = servletInputStream.readLine(inputBytes, 0, buffLen)) > -1) {
                String line = new String(inputBytes, 0, readLen).trim();
                //System.out.println(lineCtr+" LINE - "+line);
                if (line != null && line.indexOf(MULTIPART_BOUNDARY_FLAG) > -1 && boundaryStart.equals("")) {//parse multipart data
                    boundaryStart = line.trim();
                    boundaryEnd = boundaryStart + "--".trim();
                    System.out.println("Start Parsing:" + boundaryStart);
                } else if (line != null && line.indexOf(boundaryEnd) > -1) {//end parsing multipart data for one file
                    System.out.println("End Parsing:" + boundaryEnd/*+"\nPrevious Line was = ["+previousLine.trim()+"]"*/);
                    if (isData && prevBytes != null) {
                        String tline = getLine(previousLine.getBytes());
                        System.out.println(lineCtr + " WRITING LAST LINE - " + tline);
                        updateFile(tline.getBytes(), tline.getBytes().length, fileOutputStream);
                        //updateFile(prevBytes, preRead, fileOutputStream);
                    closeFile(fileOutputStream, fileName);
                    boundaryStart = "";
                    boundaryEnd = "";
                    fileName = "";
                    fileOutputStream = null;
                    preRead = 0;
                    isData = false;
                } else {
                    if (fileName.equals("") && line != null && line.indexOf(MULTIPART_BEGIN_STRING) > -1) {
                        fileName = getFileName(line);
                        fileOutputStream = createWriteFile(fileName);
                        System.out.println("fileName = " + fileName);
                    } else if (!fileName.equals("") && line != null && line.indexOf(MULTIPART_CONTENT_TYPE) > -1) {
                        continue;
                    } else if (isOK && line != null && line.length() == 0) {
                        continue;
                    } else {
                        if (isData) {
                            //System.out.println(lineCtr+" WRITING LINE - "+ previousLine+"\nXX prevBytes="+new String(prevBytes,0,preRead));
                            updateFile(previousLine.getBytes(), preRead, fileOutputStream);
                        isOK = false;
                        isData = true;
                        previousLine = new String(inputBytes, 0, readLen);
                        preRead = previousLine.getBytes().length;//readLen;
                        //System.out.println("prevBytes = "+new String(prevBytes,0,preRead));
                lineCtr++;
            }//end of while loop
        public String getFileName(String line) {
            String fileName = "";
            if (line != null && line.indexOf("filename") > -1) {
                if (line.indexOf("\"") > -1) {
                    line = line.replaceAll("\"", "");
                if (line.indexOf("\n") > -1) {
                    line = line.replaceAll("\n", "");
                if (line.indexOf("\r") > -1) {
                    line = line.replaceAll("\r", "");
                String[] arr = line.split(" ");
                String strA = arr[arr.length - 1];
                if (strA != null && strA.indexOf("=") > -1) {
                    String[] strB = strA.split("=");
                    if (strB != null && strB.length > 1) {
                        fileName = strB[strB.length - 1];
                        if (fileName.indexOf("\\") > -1) {
                            fileName = fileName.substring(fileName.lastIndexOf("\\") + 1);
                        if (fileName.indexOf("/") > -1) {
                            fileName = fileName.substring(fileName.lastIndexOf("/"));
            return fileName;
        public FileOutputStream createWriteFile(final String fileName) {
            FileOutputStream fos = null;
            if (fileName != null && !fileName.equals("")) {
                File file = new File(contextPath.getPath());
                file.mkdirs();
                //System.out.println("contextpath = "+contextPath+"\nfileName = "+fileName+"\nabsolute path = "+file.getAbsolutePath());
                try {
                    String strFileName = file.getAbsolutePath() + FILE_SEPARATOR + fileName.trim();
                    System.out.println("Begin: FILE Create:" + strFileName);
                    fos = new FileOutputStream(new File(strFileName));
                } catch (IOException ioe) {
                    ioe.printStackTrace();
            return fos;
        public void closeFile(FileOutputStream fileOutputStream, String fileName) {
            try {
                if (fileOutputStream != null) {
                    fileOutputStream.flush();
                    fileOutputStream.close();
                    File file = new File(contextPath.getPath());
                    String strFileName = file.getAbsolutePath() + FILE_SEPARATOR + fileName.trim();
                    System.out.println("End: FILE Close:" + strFileName);
                } else {
                    System.out.println("File objet is NULL");
            } catch (IOException ioe) {
                ioe.printStackTrace();
        public void updateFile(byte[] readData, final int readLength, FileOutputStream fileOutputStream) {
            if (fileOutputStream != null) {
                try {
                    //System.out.println("LINE:"+line);
                    fileOutputStream.write(readData, 0, readLength);
                    //System.out.println("fileOutputStream= "+((null==fileOutputStream)?"NULL":"NOT NULL"));
                } catch (IOException ioe) {
                    ioe.printStackTrace();
        private synchronized String getLine(byte[] bytes) throws IOException {
            int read = bytes.length, index;
            String line = null;
            if (read != -1) {
                line = new String(bytes, 0, read);
                if ((index = line.indexOf('\n')) >= 0) line = line.substring(0, index - 1);
                line.trim();
            return line;
    }Please I hope some one can shed some light.
    Its clear to me that there is a logical error thats because of my lack of understanding of the input/output stream the way its being transferred to servlet and then being parsed before written. But I have not been able to put my head around.
    Thanks for any one who tries to help

Maybe you are looking for

  • Windows Vista Ultimate doesn't install on Satellite M40

    Windows Vista Ultimate doesn't install on this notebook. Vista hangs after installation and doesn't boot up. Does anybody know what the problem is?

  • Mapping constant values to the target data source columns

    Hi A Target data source has only two columns(RPT_NAME, RPT_LEVEL) and both of them are constants and mapped as follows WITH TEMP1 AS (select 'AS' as A from dual union select 'IS' as A from dual union select 'ED' as A from dual select t.A as RPT_NAME,

  • Help!  I haven't had service all day!

    iPhone support is closed both with AT&T and Apple. I have had nothing but problems. No connections either through 3g or Wifi, losing my contacts and my Calendar. I have no idea what the heck is going on, but all day today, I haven't been able to make

  • Creating a data model in BW by importing an .ER1 file

    Hi, We have a Data Model from an Oracle 9 data warehouse in the form of an Erwin File ( .ER1) . We would like to replicate this data model in SAP BW 7.0. Is it possible to create the same data model in SAP BW by importing this file and automatically

  • Creating new pages

    I am writing a cookbook and have finished page 1 but I can't figure out how to get to page 2. I read the response stating to just continue writing; however, I can't just continue with the next recipe because it would cut it in half at the end of the