How to save from a JTable to .CSV file format?

i am building a client sever model in which the client will send the details to the server...
the server will take all the details and display it in a jtable..
now, after sorting it using autorowsorter(..), how can i save the data from table to a .CSV file???
Thanks in advance..

Here is one code from my own my application. It should compile straight away, but if there are any compile time bugs, you can easily fix them. Pls do read the comments at the top.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
import javax.swing.table.*;
* This class is now JDK 1.6 Dependent, with the addition of the use of the Desktop
* class instead of the default application launch procedure, and the use of the new
* FileNameExtensionFilter class introduced under javax.swing.filechooser.
* This class can be used in one line of code by passing the appropriate JTable to the
* desired constructor.
public class ExcelExporter extends Object {
    public JTable source;
    public JFileChooser chooser;
    public File csvFile;
    private boolean cancelOp = false, isDefault = true;
    private String topText = "";
    public ExcelExporter(JTable source) {
        this(source, "");
    public ExcelExporter(JTable source, String topText) {
        this(source, topText, true);
    public ExcelExporter(JTable source, String topText, boolean isDefault, File target, JProgressBar bar) {
        super();
        this.source = source;
        this.topText = topText;
        this.isDefault = isDefault;
        new ProgressDialog(source, target, bar);
    public ExcelExporter(JTable source, String topText, boolean isDefault) {
        super();
        this.source = source;
        this.topText = topText;
        this.isDefault = isDefault;
        obtainFileName();
    public void obtainFileName() {
        cancelOp = false;
        FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel Format (CSV)", "csv");
        if(chooser == null) {
            chooser = new JFileChooser();
            chooser.setDialogTitle("Saving Database");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            chooser.setSelectedFile( new File("database.csv") );
            chooser.setAcceptAllFileFilterUsed(false);                     
        int val = chooser.showSaveDialog((Component)null);
        if(val == JFileChooser.APPROVE_OPTION) {
            csvFile = chooser.getSelectedFile();
            boolean fixed = fixExtension(csvFile, "csv");
            if(!fixed && !cancelOp) {
                JOptionPane.showMessageDialog(null,"File Name Specified Not Supported",
                "File Name Error", JOptionPane.ERROR_MESSAGE);
                obtainFileName();
                return;
            if(!cancelOp) {
                //storeTableAsCSV(csvFile, source);
                new ProgressDialog(source, csvFile).setVisible(true);
    public boolean fixExtension(File file, String prefExt) {
        String fileName = file.getName();
        String dir = file.getParentFile().getAbsolutePath();
        String ext = null;
        try {
            ext = fileName.substring( fileName.lastIndexOf("."), fileName.length() );
            System.out.println("Original File Extension: " + ext);
        } catch(StringIndexOutOfBoundsException e) {
            ext = null;
        if(ext != null && !ext.equalsIgnoreCase("."+prefExt)) {
            return false;
        String csvName = null;
        if(ext == null || ext.length() == 0) {
            csvName = fileName + "." + prefExt;
        } else {
            csvName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + prefExt;
        System.out.println("Corrected File Name: " + csvName);
        File csvCert = new File(dir, csvName);
        if(csvCert.exists()) {
            int val = JOptionPane.showConfirmDialog(null, "Replace Existing File?", "File Exists",
                        JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
            if(val == JOptionPane.NO_OPTION) {
                obtainFileName();
                cancelOp = true;
                return false;
            } else if(val == JOptionPane.CANCEL_OPTION) {
                cancelOp = true;
                return false;              
        if(!file.renameTo(csvCert)) {
            file = new File(dir, csvName);
            try {
                file.createNewFile();
            } catch(IOException ioe) {}
        System.out.println("Exporting as: " + file.getAbsolutePath() );
        return true;
    public void storeTableAsCSV(File target, JTable src) {
        String csvData = topText + "\n\n";
        for(int i = 0; i < src.getModel().getRowCount(); i++) {
            for(int x = 0; x < src.getModel().getColumnCount(); x++) {
                int col = src.convertColumnIndexToView(x);
                String curVal = (String)src.getModel().getValueAt(i,col);
                if(curVal == null) {
                    curVal = "";
                csvData = csvData + removeAnyCommas(curVal) + ",";
                if(isDefault) {
                    if(x == src.getModel().getColumnCount() - 3) {
                        csvData = csvData + "\n";
                        continue;
                } else {
                    if(x == src.getModel().getColumnCount() - 1) {
                        csvData = csvData + "\n";                      
        try {
            FileWriter writer = new FileWriter(target);
                writer.write(csvData);
                writer.flush();
                writer.close();
            writer = null;
            csvData = null;
        } catch(IOException ioe) {
            JOptionPane.showMessageDialog(source, "Error Writing File.\nFile may be in use by another application."
            + "\nCheck and try re-exporting", "Export Error", JOptionPane.ERROR_MESSAGE);
    public String removeAnyCommas(String src) {
        if(src == null) {
            return "";
        for(int i = 0; i < src.length(); i++) {
            if(src.charAt(i) == ',') {
                src = src.substring(0,i) + src.substring(i+1, src.length());
        return src;
    class ProgressDialog extends JDialog {
        JProgressBar progress;
        JLabel progressLabel;
        javax.swing.Timer timer;
        int rowPoint = -1;
        StringBuffer data;
        JTable srcTable;       
        DefaultTableModel srcModel;
        File targetFile;
        public ProgressDialog(JTable src, File target) {
            super( new JDialog(), "Exporting", true);
            createUI();
            setLocationRelativeTo(null);
            srcTable = src;
            srcModel = (DefaultTableModel)src.getModel();
            targetFile = target;
            exportDataProgressively();
        public ProgressDialog(JTable src, File target, JProgressBar progress) {
            super();
            srcTable = src;
            srcModel = (DefaultTableModel)src.getModel();
            targetFile = target;
            setProgressBar(progress);
            exportDataProgressively();
        public void createUI() {
            progress = new JProgressBar(0, 100);
            progress.setIndeterminate(true);
            progress.setValue(0);
            progress.setBorder( BorderFactory.createCompoundBorder(
                                    BorderFactory.createEmptyBorder(10,10,10,10),
                                UIManager.getBorder("ProgressBar.border") ) );
            progress.setPreferredSize( new Dimension(300, 38) );
            progressLabel = new JLabel("Writing Excel Format. Please Wait...");
            progressLabel.setFont( new Font("Verdana", Font.PLAIN, 11) );
            progressLabel.setBorder( BorderFactory.createEmptyBorder(10,10,10,10) );
            JPanel progressPanel = new JPanel( new BorderLayout() );
                progressPanel.add(progressLabel, BorderLayout.NORTH );
                progressPanel.add(progress, BorderLayout.CENTER);
                progressPanel.setBorder( BorderFactory.createEmptyBorder(10,10,10,10) );
            setContentPane(progressPanel);         
            pack();
        public void exportDataProgressively() {
            //progress.setString("");
            progress.setMaximum(srcModel.getRowCount());
            progress.setIndeterminate(false);
            data = new StringBuffer("Autogenerated Excel Format"
                 + topText + "\n\n");          
            timer = new javax.swing.Timer(15, new ActionListener() {
                public void actionPerformed(ActionEvent e) {                   
                    if(rowPoint > -1 && srcModel.getValueAt(rowPoint,0) == null) {
                        timer.stop();
                    progress.setValue(rowPoint);
                    appendData();
            timer.setRepeats(false);
            timer.start();
        public void appendData() {
            timer.stop();
            for(int j = 0; j < srcModel.getColumnCount(); j++) {
                int col = srcTable.convertColumnIndexToView(j);
                if(rowPoint == -1) {
                    data.append(removeAnyCommas((String)srcModel.getColumnName(col)).toUpperCase());
                } else if(col != -1){
                    String text = (String)srcModel.getValueAt(rowPoint,col);
                    if(srcModel.getColumnName(col).equalsIgnoreCase("Phone Number(s)") && !isPrintableText(text) ) {
                        text = "\'" + getPrintableText(text);
                    } else if( srcModel.getColumnName(col).equalsIgnoreCase("Phone Number(s)") && isPrintableText(text)  ) {
                        text = "\'" + removeAnyCommas(text);
                    } else {
                        text = removeAnyCommas(text);
                    data.append(text);
                if(isDefault) {
                    if(j != srcModel.getColumnCount() - 3 ){
                        data.append(",");
                    } else {
                        data.append("\n");
                        break;
                } else {
                    if(j != srcModel.getColumnCount() - 1 ){
                        data.append(",");
                    } else {
                        data.append("\n");
            rowPoint++;
            if(rowPoint < srcModel.getRowCount()) {
                timer.start();
            } else {
                try {
                    if(!targetFile.exists())
                        targetFile.createNewFile();
                    FileWriter writer = new FileWriter(targetFile);
                        writer.write(data.toString());
                        writer.close();
                        progress.setValue(progress.getMaximum());
                        progress.setStringPainted(true);
                        progress.setString("Done");
                        openFile(targetFile);                      
                        setVisible(false);
                        data = null;
                } catch(IOException ioe) {
                    JOptionPane.showMessageDialog(source, "Error Writing File. Try Resaving",
                    "Save Error", JOptionPane.ERROR_MESSAGE);
                } catch(Exception exc) {
                    System.out.println(exc);
        public void setProgressBar(JProgressBar bar) {
            progress = bar;
        public boolean isPrintableText(String text) {
            return !text.contains("::");
        public String getPrintableText(String text) {          
            try {
                text = text.substring(2);
            } catch(StringIndexOutOfBoundsException sie) {
                System.out.println(sie);
            String generated = "";
            StringTokenizer st = new StringTokenizer(text, ",");
            try {
                for(int i = 0; st.hasMoreTokens(); i++ ) {
                    if(i > 0) {
                        generated = generated + " / ";
                    String token = st.nextToken();
                    generated = generated + token.substring( token.indexOf("-") + 2 );
            } catch(NoSuchElementException nse) {}
            return generated;
        public void openFile(File file) {
            int val = JOptionPane.showConfirmDialog(null, "Would You Like To View The File Right Now?",
            "View File", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
            try {
                if(val == JOptionPane.YES_OPTION) {
                    if(Desktop.isDesktopSupported()) {
                        Desktop.getDesktop().open(file);
                    } else {
                        new ExcelExecutor(file.getAbsolutePath());
            } catch(IOException ioe) {
                JOptionPane.showMessageDialog(null, "Failed to Open File", "Error",
                 JOptionPane.ERROR_MESSAGE);
}ICE

Similar Messages

  • How to save a bitmap to a pdf file format?

    Hello,
    We have a scanning application that can write out BMP files or TIFF files.  My boss would like to have the files in PDF format.  Is there a way to do this?  I can write code if given the specs.  Call an external routine if there is one available for free or low cost.  I initially get the info from a handle to a DIB, convert it to a Bitmap object, then save it to a TIFF.  I am using VB.NET and am looking for a solution that isn't too costly in cash or time since the benefit is small, but I do not know if there is one.  Even if someone can point me in the right direction I would appreciate it.
    Thanks

    Open in a graphics package and print to the Adobe PDF printer. TIFF files can be opened directly in Acrobat and converted (you would then use Save As to get the PDF). BMP files are not in the list of files converted by Acrobat, but you could still try -- might get an error message, but maybe it will work also.

  • How do I save a string to a CSV file using applescript?

    Hi,
    I have an applescript that returns a string in the form:
    Value1,Value2,Value3,Value4
    Value5,Value6,Value7,Value8
    Value9,Value10,Value11,Value12
    Value13,Value14,Value15,Value16   etc.
    I would like to be able to save this string as a CSV file on my desktop but I'm not sure how to do this.
    Could someone help me out with this?
    Thanks,
    Nick

    sorry, I didn't read carefully.  this is slightly better:
    set theText to "some delimited text you already have..."
    set filePath to (path to desktop as text) & "file name.csv"
    set fp to open for access filePath with write permission
    write theText to fp
    close access fp

  • How to save from .ai to .png without a gap

    I created a repeating pattern. I made the artboard the exact size of the art. I zoomed in and there are no gaps around the edge. I saved it for web and devices png8 and the top has a gap with transparency showing through. When I use it as a web page background, there is a white stripe showing. I've tried twice to resave it but get the same gap.
    I'm trying to upload the two images using the camera icon but nothing happens after I select the image and click the "insert image" button. Again, I've tried twice without a different result. Please advise.
    Thank you.
    Please help.
    Kathleen

    Having a hard time with google docs, sigh. Thank you for all your help.
    From: "Kurt Gold" <[email protected]>
    To: "kathpoole" <[email protected]>
    Sent: Tuesday, May 28, 2013 1:29:21 PM
    Subject: How to save from .ai to .png without a gap
         Re: How to save from .ai to .png without a gap
    created by Kurt Gold in Illustrator - View the full discussion
    Adobe Illustrator files are not tolerated as attachments in that Adobe Illustrator forum (great, isn't it?).
    You may take a service like Google Docs to provide them.
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5359346#5359346
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5359346#5359346
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5359346#5359346. In the Actions box on the right, click the Stop Email Notifications link .
    Start a new discussion in Illustrator by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746 .

  • BO 4.0 save as csv file format issue

    Hi All,
    We are using BO 4.0 Webi for reporting on SAP BW 7.3 system. Some of our reports have to be scheduled to bring the output in CSV file format. When I schedule the report in CSV format, the final output has data in two sets. The first set has the list of columns which I have selected in my report. Starting on the next row I get to see the second set of data with all the objects selected in the query panel including the detail objects.
    We only need the data for the columns which is selected in the report, but it is bringing the dump from all the objects in the dataprovider.
    Can anyone tell me how to get rid of the second set of data in the same csv file ?
    Thanks,
    Prasad

    Hi,
    CSV format is reserved for 'data only' dataprovider dumps. it exports the entire webi microcube (query results)
    You don't get that option when going 'save as' - which preserves the report formatting - in which case you should consider .xls
    regards,
    H

  • How do I export phone contacts into CSV file?

    I can't seem to export the contacts in my iPhone into a CSV file so I can import them into Yahoo Mail or Gmail to edit.

    Contacts are designed to be synced with a supported application on your computer. This is so common with Windows users - here anyway - not having contacts available on their computer. How does one get by without having contact info available on their computer, or having email addresses only for contacts on their computer, telephone numbers only for contacts on their cell phone, and mailing addresses who knows where? Not a good idea to depend on an iPhone or any cell phone only for contact info - along with having to manually enter all contact info on a cell phone, which can be lost or stolen.
    With Windoze, you can sync contacts with Outlook 2003 or 2007 along with syncing calendar events, or with the address book used by Outlook Express or by Windows Mail (depending on the Windoze version) called Windows Contacts for syncing contacts only. You may not have Outlook 2003 or 2007, but you have Windows Contacts available.
    If Windows Contacts is empty - no contact info, before the first sync enter one contact in Windows Contacts. Make the contact up if needed, which can be deleted later. This will provide a merge prompt with the first sync for this data, which you want to select. Syncing contacts with Windows Contacts is selected under the Info tab for your iPhone sync preferences with iTunes.
    After your contacts are available in Windows Contacts, you can export the contacts from there in a CSV file for import by Yahoo or Gmail.

  • How to save Internal table as a local file?

    Hi,
    How to save Interanl table as a local file ?
    I had some data which i had selected in Interanl table and would like to send this as an attachment by attaching internal table contents as a local file--

    Hi friend,
    See sample code for GUI_DOWNLOAD.
    *Types
    TYPES: BEGIN OF g_r_mara,
           matnr LIKE mara-matnr,
           ersda LIKE mara-ersda,
           laeda LIKE mara-laeda,
           mtart LIKE mara-mtart,
           mbrsh LIKE mara-mbrsh,
           END OF g_r_mara.
    *Data
    DATA: g_t_mara TYPE TABLE OF g_r_mara,
          filename TYPE string.
    *Tables
    TABLES: mara, sscrfields.
    *Selection Screen
    SELECT-OPTIONS: s_matnr FOR mara-matnr.
    SELECTION-SCREEN BEGIN OF LINE.
    *SELECTION-SCREEN COMMENT 10(20) text-001 FOR FIELD p1.
    SELECTION-SCREEN PUSHBUTTON 12(20) word USER-COMMAND uc.
    SELECTION-SCREEN END OF LINE.
    *Initilizing data.
    INITIALIZATION.
      word = 'word'.
      filename = 'C:\Testing.doc'.   <------- File name and location
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
        WHEN 'UC'.
    *Data retrival
          SELECT matnr ersda laeda mtart mbrsh
            INTO  CORRESPONDING FIELDS OF TABLE g_t_mara
            FROM mara
            WHERE matnr IN s_matnr.
    *Downloading data from internal table to excel
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              filename              = filename
              filetype              = 'ASC'
              write_field_separator = 'X'
            TABLES
              data_tab              = g_t_mara.
      ENDCASE.
    (Note: Downloaded file is in C:\Testing.doc)
    You can change the file format by changing the extension in filename.
    Might helpful for u.
    Thanks..

  • How to use GUI_upload for Uploading a CSV file in Microsoft Excel.

    Hi Guys,
                  can anybody tell me how to Upload the CSV format file in Microsoft excel sheet?
    Thanks,
    Gopi.

    Hi Gopi,
    u can use GUI_UPLOAD, TEXT_CONVERT_XLS_TO_SAP.
    Please check these codes.
    Uploading data from CSV file format into internal table using GUI_UPLOAD
    REPORT zupload MESSAGE-ID bd.
    DATA: w_tab TYPE ZTEST.
    DATA: i_tab TYPE STANDARD TABLE OF ZTEST.
    DATA: v_subrc(2),
    v_recswritten(6).
    PARAMETERS: p_file(80)
    DEFAULT 'C:\Temp\ZTEST.TXT'.
    DATA: filename TYPE string,
    w_ans(1) TYPE c.
    filename = p_file.
    CALL FUNCTION 'POPUP_TO_CONFIRM'
    EXPORTING
    titlebar = 'Upload Confirmation'
    * DIAGNOSE_OBJECT = ' '
    text_question = p_file
    text_button_1 = 'Yes'(001)
    * ICON_BUTTON_1 = ' '
    text_button_2 = 'No'(002)
    * ICON_BUTTON_2 = ' '
    default_button = '2'
    * DISPLAY_CANCEL_BUTTON = 'X'
    * USERDEFINED_F1_HELP = ' '
    * START_COLUMN = 25
    * START_ROW = 6
    * POPUP_TYPE =
    * IV_QUICKINFO_BUTTON_1 = ' '
    * IV_QUICKINFO_BUTTON_2 = ' '
    IMPORTING
    answer = w_ans
    * TABLES
    * PARAMETER =
    * EXCEPTIONS
    * TEXT_NOT_FOUND = 1
    * OTHERS = 2
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CHECK w_ans = 1.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = filename
    * FILETYPE = 'ASC
    has_field_separator = 'X'
    * HEADER_LENGTH = 0
    * READ_BY_LINE = 'X'
    * IMPORTING
    * FILELENGTH =
    * HEADER =
    TABLES
    data_tab = i_tab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    * SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *
    IF sy-subrc <> 0.
    v_subrc = sy-subrc.
    MESSAGE e899 WITH 'File Open Error' v_subrc.
    ENDIF.
    INSERT ZTEST FROM TABLE i_tab.
    COMMIT WORK AND WAIT.
    MESSAGE i899 WITH sy-dbcnt 'Records Written to ZTEST'.
    Uploading data from Excel file format into internal table using TEXT_CONVERT_XLS_TO_SAP
    REPORT  zupload_excel_to_itab.
    TYPE-POOLS: truxs.
    PARAMETERS: p_file TYPE  rlgrap-filename.
    TYPES: BEGIN OF t_datatab,
          col1(30)    TYPE c,
          col2(30)    TYPE c,
          col3(30)    TYPE c,
          END OF t_datatab.
    DATA: it_datatab type standard table of t_datatab,
          wa_datatab type t_datatab.
    DATA: it_raw TYPE truxs_t_text_data.
    * At selection screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'P_FILE'
        IMPORTING
          file_name  = p_file.
    *START-OF-SELECTION.
    START-OF-SELECTION.
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
    *     I_FIELD_SEPERATOR        =
          i_line_header            =  'X'
          i_tab_raw_data           =  it_raw       " WORK TABLE
          i_filename               =  p_file
        TABLES
          i_tab_converted_data     = it_datatab[]    "ACTUAL DATA
       EXCEPTIONS
          conversion_failed        = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * END-OF-SELECTION.
    END-OF-SELECTION.
      LOOP AT it_datatab INTO wa_datatab.
        WRITE:/ wa_datatab-col1,
                wa_datatab-col2,
                wa_datatab-col3.
      ENDLOOP.
    reward if helpful
    raam

  • Extract data from Oracle Database and store it into a CSV file format

    Hello.
    I'm trying to export a table from an Oracle Database into CSV file format with any Oracle adaptor and store it into a HDFS system.
    How could I do it?
    Thanks in advance!

    Xavi wrote:
    HI Charles. Could I use.. Oracle Data Integrator Application Adapter for Hadoop? For this purpose?
    Thanks in advancePerhaps. I have to confess that I am not familiar enough with ODI to know if that is within its capabilities.
    You might see if there is a forum for ODI and post your question to that.
    Charles Lamb

  • Linux server(how to save command out put to another file. )

    hi all,
    i have Q ?
    how to save command out put to another file.
    Ex: #ps -ef
    that particular cmd output i need to save another file.
    is it possible ...if possible ..please let me know
    And how to save command history in Linux.

    df -h >> /oracle/output.log
    /oracle -- mount point name
    Regards
    Asif Kabir

  • ANYBODY KNOW how to save a swatch in an ID file at a percentage?

    ANYBODY KNOW how to save a swatch in an ID file at a percentage?
    So that every time it's used, it applies that percentage automatically?

    LOL...nevermind. Took me 2 seconds to realize all I needed to do after posting this. Sad trombone.

  • How to save a photobook as pdf or jpeg format?

    how to save a photobook as pdf or jpeg format?

    Do you mean like a multi-page PDF?  As in, one photo per page? Or something else?
    You might get what you are looking for by exploring the options in iPhoto's Print (under the File menu) and then clicking the PDF button, and then Save As PDF.
    Without knowing more details about exactly what you are wanting to do, it's hard to know what else to suggest.

  • File upload - issue with European .csv file format

    All,
    when uploading the .csv file for "Due List for Planned Receipts" in the File Transfer Upload center I receive an error.  It appears that it is due to the european .csv file format that is delimited by semicolon rather than comma. The only way I could solve this issue is to change Regional and Language options to English. However, I don't think this is a great solution as I can't ask all our suppliers to change their settings.  Has anyone come across this issue and another way of solving it?
    Thank you!
    Have a good day,
    Johanna

    Igor thank you for your suggestion. 
    I found this SAP note:
    +If you download a file, and the formatting of the CSV file is faulty, it is possible that your column separator does not match the standard settings of the SAP system. In the standard SAP system, the separator is ,.
    To ensure that the formatting is correct, set your global default for column separation in your system, so that it matches that of the SAP system you are using.+
    To do that Microsoft suggests to change the "List separator" in the Regional and Language Options Customize view. Though like you suggest that does not seem to do the trick. Am I missing something?
    However, if I change the whole setting from say German to English (UK) the .csv files are comma delimited and can be easily uploaded.  Was hoping there would be another way of solving this without need for custom development.

  • To download data into csv file format

    Hi All
    I have to download data into csv file format. I use the FM
    GUI_DOWNLOAD and gave the filename text.csv. But data is stored in excel
    file in place of csv file.
    Can anyone tell me what should i do to load the data into csv file or any other function module should used?
    Regards

    see this sample code
    REPORT  YSG_MATSTK_REPT    LINE-SIZE 220
                               LINE-COUNT 50(5).
    *&                       DATA DECLARATION                              *
    TABLES: MARA,                      "GENERAL MASTER DATA
            MARC,                      "PLANT DATA FOR MATERIAL
            MARD,                      "STORAGE LOCATION DATA FOR MATERIAL
            MVKE,                      "SALES DATA FOR MATERIAL
            MAKT,                      "MATERIAL DESCRIPTION
            EKKO,                      "PURCHASING DOCUMENT HEADER
            EKPO,                      "PURCHASING DOCUMENT ITEM
            VBAK,                      "SALES DOCUMENT HEADER DATA
            VBAP.                      "SALES DOCUMENT ITEM DATA
    TYPE-POOLS : SLIS.
    DATA: VT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
          V_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          V_LAYOUT TYPE SLIS_LAYOUT_ALV,
          BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
          BEGIN OF I_MARA OCCURS 0,
             MATNR LIKE MARA-MATNR,  "MATERIAL NUMBER
             MBRSH LIKE MARA-MBRSH,  "INDUSTRY SECTOR
             MEINS LIKE MARA-MEINS,  "BASE UNIT OF MEASURE
             MATKL LIKE MARA-MATKL,  "MATERIAL GROUP
          END OF I_MARA,
          BEGIN OF I_MARC OCCURS 0,
             MATNR LIKE MARC-MATNR,  "MATERIAL NUMBER
             WERKS LIKE MARC-WERKS,  "PLANT
             LVORM LIKE MARC-LVORM,  "FLAG MATERIAL FOR DELETION AT PLANT
                                     "LEVEL
             DISPO LIKE MARC-DISPO,  "MRP CONTROLLER
          END OF I_MARC,
          BEGIN OF I_MAKT OCCURS 0,
             MATNR LIKE MAKT-MATNR,  "MATERIAL NUMBER
             MAKTX LIKE MAKT-MAKTX,  "MATERIAL DESCRIPTION
             SPRAS LIKE MAKT-SPRAS,  "LANGUAGE KEY
          END OF I_MAKT,
          BEGIN OF I_MVKE OCCURS 0,
             MATNR LIKE MVKE-MATNR,  "MATERIAL NUMBER
             VKORG LIKE MVKE-VKORG,  "SALES ORGANIZATION
             VTWEG LIKE MVKE-VTWEG,  "DISTRIBUTION CHANNEL
          END OF I_MVKE,
          BEGIN OF I_MARD OCCURS 0,
            MATNR LIKE MARD-MATNR,  "MATERIAL NUMBER
            LGORT LIKE MARD-LGORT,  "STORAGE LOCATION
            LABST LIKE MARD-LABST,  "VALUATED STOCK WITH UNRESTRICTED USE
          END OF I_MARD,
          BEGIN OF I_EKPO OCCURS 0,
            EBELN LIKE EKPO-EBELN,  "PURCHASING DOCUMENT NUMBER
            EBELP LIKE EKPO-EBELP,  "ITEM NUMBER OF PURCHASING DOCUMENT
            MATNR LIKE EKPO-MATNR,  "MATERIAL NUMBER
          END OF I_EKPO,
          BEGIN OF I_VBAP OCCURS 0,
            VBELN LIKE VBAP-VBELN,  "SALES DOCUMENT
            POSNR LIKE VBAP-POSNR,  "SALES DOCUMENT ITEM
            MATNR LIKE VBAP-MATNR,  "MATERIAL NUMBER
          END OF I_VBAP,
          BEGIN OF I_OUT OCCURS 0,
            MATNR LIKE MARC-MATNR,
            WERKS LIKE MARC-WERKS,
            LVORM LIKE MARC-LVORM,
            DISPO LIKE MARC-DISPO,
            MBRSH LIKE MARA-MBRSH,
            MEINS LIKE MARA-MEINS,
            MATKL LIKE MARA-MATKL,
            VKORG LIKE MVKE-VKORG,
            VTWEG LIKE MVKE-VTWEG,
            SPRAS LIKE MAKT-SPRAS,
            MAKTX LIKE MAKT-MAKTX,
            LGORT LIKE MARD-LGORT,
            LABST LIKE MARD-LABST,
            EBELN LIKE EKPO-EBELN,
            EBELP LIKE EKPO-EBELP,
            VBELN LIKE VBAP-VBELN,
            POSNR LIKE VBAP-POSNR,
          END OF I_OUT,
          BEGIN OF I_HEADING OCCURS 0,
            TEXT1(20),
            TEXT2(20),
            TEXT3(20),
            TEXT4(20),
            TEXT5(20),
            TEXT6(20),
            TEXT7(20),
            TEXT8(20),
            TEXT9(20),
            TEXT10(20),
            TEXT11(40),
            TEXT12(20),
            TEXT13(20),
            TEXT14(20),
            TEXT15(20),
            TEXT16(20),
            TEXT17(20),
          END OF I_HEADING.
    *&                   S E L E C T I O N - S C R E E N                   *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-100.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. "OBLIGATORY.
    PARAMETERS: P_WERKS LIKE MARC-WERKS. "OBLIGATORY.
    SELECT-OPTIONS: S_LGORT FOR MARD-LGORT,
                    S_DISPO FOR MARC-DISPO,
                    S_EBELN FOR EKPO-EBELN .
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-101.
    PARAMETERS : RB1 RADIOBUTTON GROUP G1,
                 RB2 RADIOBUTTON GROUP G1,
                 RB3 RADIOBUTTON GROUP G1.
    SELECTION-SCREEN END OF BLOCK B2.
    *&                  I N I T I A L I Z A T I O N                      *
    *INITIALIZATION.
    *&             S T A R T - O F - S E L E C T I O N                     *
    START-OF-SELECTION.
      SELECT MATNR WERKS LVORM DISPO FROM MARC
      INTO CORRESPONDING FIELDS OF TABLE I_MARC
                          WHERE MATNR IN S_MATNR
                          AND DISPO IN S_DISPO
                          AND WERKS = P_WERKS.
      IF I_MARC[] IS INITIAL.
        WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARC'.
        EXIT.
      ENDIF.
      PERFORM PURCHASEDATA_VALIDATION.
      PERFORM SALESDATA_VALIDATION.
      SELECT MATNR LGORT LABST FROM MARD INTO TABLE  I_MARD
                          FOR ALL ENTRIES IN I_MARC
                          WHERE MATNR = I_MARC-MATNR
                          AND WERKS EQ P_WERKS
                          AND LGORT IN S_LGORT.
      IF I_MARD[] IS INITIAL.
        WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARD'.
        EXIT.
      ENDIF.
      SELECT MATNR VKORG VTWEG FROM MVKE INTO TABLE I_MVKE
                          FOR ALL ENTRIES IN I_MARC
                          WHERE MATNR = I_MARC-MATNR.
      IF I_MVKE[] IS INITIAL.
        WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MVKE'.
        EXIT.
      ENDIF.
      LOOP AT I_MARC.
        MOVE-CORRESPONDING I_MARC TO I_OUT.
        CLEAR MARC.
        SELECT SINGLE MATNR MBRSH MEINS MATKL FROM MARA
                          INTO CORRESPONDING FIELDS OF MARA
                          WHERE MATNR = I_OUT-MATNR.
        IF SY-SUBRC = 0.
          MOVE: MARA-MBRSH TO I_OUT-MBRSH,
                MARA-MEINS TO I_OUT-MEINS,
                MARA-MATKL TO I_OUT-MATKL.
        ELSE.
          CONTINUE.
        ENDIF.
        SELECT SINGLE MATNR MAKTX SPRAS FROM MAKT
                        INTO  CORRESPONDING FIELDS OF MAKT
                        WHERE  MATNR = I_OUT-MATNR.
        IF SY-SUBRC = 0.
          MOVE: MAKT-MAKTX TO I_OUT-MAKTX,
                MAKT-SPRAS TO I_OUT-SPRAS.
        ELSE.
          CONTINUE.
        ENDIF.
        LOOP AT I_EKPO WHERE MATNR =  I_MARC-MATNR.
          MOVE: I_EKPO-EBELN TO I_OUT-EBELN,
                I_EKPO-EBELP TO I_OUT-EBELP.
        ENDLOOP.
        LOOP AT I_VBAP WHERE MATNR =  I_MARC-MATNR.
          MOVE: I_VBAP-VBELN TO I_OUT-VBELN,
                I_VBAP-POSNR TO I_OUT-POSNR.
        ENDLOOP.
        LOOP AT I_MARD WHERE MATNR = I_MARC-MATNR.
          MOVE: I_MARD-LABST TO I_OUT-LABST,
                I_MARD-LGORT TO I_OUT-LGORT.
        ENDLOOP.
        LOOP AT I_MVKE WHERE MATNR = I_MARC-MATNR.
          MOVE: I_MVKE-VKORG TO I_OUT-VKORG,
                I_MVKE-VTWEG TO I_OUT-VTWEG.
        ENDLOOP.
        APPEND I_OUT.
        CLEAR I_OUT.
      ENDLOOP.
      PERFORM OPTIONS.
                         FORM  OPTIONS                                *
    FORM OPTIONS.
      IF RB2 = 'X'.
        PERFORM FIELDCAT.
        PERFORM OUTPUT.
      ELSE.
        IF RB1 = 'X'.
          PERFORM HEADINGS.
          PERFORM DLOAD.
        ELSE.
          IF RB3 = 'X'.
            PERFORM HEADINGS.
            PERFORM DLOAD.
            PERFORM FIELDCAT.
            PERFORM OUTPUT.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    "OPTIONS
                         FORM  HEADINGS                               *
    FORM HEADINGS.
      I_HEADING-TEXT1 = 'MATNR'.
      I_HEADING-TEXT2 = 'WERKS'.
      I_HEADING-TEXT3 = 'LVORM'.
      I_HEADING-TEXT4 = 'DISPO'.
      I_HEADING-TEXT5 = 'MBRSH'.
      I_HEADING-TEXT6 = 'MEINS'.
      I_HEADING-TEXT7 = 'MATKL'.
      I_HEADING-TEXT8 = 'VKORG'.
      I_HEADING-TEXT9 = 'VTWEG'.
      I_HEADING-TEXT10 = 'SPRAS'.
      I_HEADING-TEXT11 = 'MAKTX'.
      I_HEADING-TEXT12 = 'LGORT'.
      I_HEADING-TEXT13 = 'LABST'.
      I_HEADING-TEXT14 = 'EBELN'.
      I_HEADING-TEXT15 = 'EBELP'.
      I_HEADING-TEXT16 = 'VBELN'.
      I_HEADING-TEXT17 = 'POSNR'.
      APPEND I_HEADING.
    ENDFORM.                    "HEADINGS
                         FORM  DLOAD                                  *
    FORM DLOAD.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME              = 'C:\MATSTK.csv'
          FILETYPE              = 'DAT'
          WRITE_FIELD_SEPARATOR = 'X'
        TABLES
          DATA_TAB              = I_HEADING
        EXCEPTIONS
          FILE_WRITE_ERROR      = 1.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME              = 'C:\MATSTK.csv'
          FILETYPE              = 'DAT'
          APPEND                = 'X'
          WRITE_FIELD_SEPARATOR = 'X'
        TABLES
          DATA_TAB              = I_OUT.
    ENDFORM.                    "DLOAD
                              FORM  FIELDCAT                          *
    FORM FIELDCAT.
      V_FIELDCAT-COL_POS = '1'.
      V_FIELDCAT-FIELDNAME     = 'MATNR'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-HOTSPOT = 'X'.
      V_FIELDCAT-REF_FIELDNAME = 'MATNR'.
      V_FIELDCAT-REF_TABNAME   = 'MARC'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '2'.
      V_FIELDCAT-FIELDNAME     = 'WERKS'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'WERKS'.
      V_FIELDCAT-REF_TABNAME   = 'MARC'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '3'.
      V_FIELDCAT-FIELDNAME     = 'LVORM'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'LVORM'.
      V_FIELDCAT-REF_TABNAME   = 'MARC'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '4'.
      V_FIELDCAT-FIELDNAME     = 'DISPO'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'DISPO'.
      V_FIELDCAT-REF_TABNAME   = 'MARC'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '5'.
      V_FIELDCAT-FIELDNAME     = 'MBRSH'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'MBRSH'.
      V_FIELDCAT-REF_TABNAME   = 'MARA'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '6'.
      V_FIELDCAT-FIELDNAME     = 'MEINS'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'MEINS'.
      V_FIELDCAT-REF_TABNAME   = 'MARA'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '7'.
      V_FIELDCAT-FIELDNAME     = 'MATKL'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'MATKL'.
      V_FIELDCAT-REF_TABNAME   = 'MARA'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '8'.
      V_FIELDCAT-FIELDNAME     = 'VKORG'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'VKORG'.
      V_FIELDCAT-REF_TABNAME   = 'MVKE'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '9'.
      V_FIELDCAT-FIELDNAME     = 'VTWEG'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'VTWEG'.
      V_FIELDCAT-REF_TABNAME   = 'MVKE'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '10'.
      V_FIELDCAT-FIELDNAME     = 'SPRAS'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'SPRAS'.
      V_FIELDCAT-REF_TABNAME   = 'MAKT'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '11'.
      V_FIELDCAT-FIELDNAME     = 'MAKTX'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'MAKTX'.
      V_FIELDCAT-REF_TABNAME   = 'MAKT'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '12'.
      V_FIELDCAT-FIELDNAME     = 'LGORT'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
    V_FIELDCAT-REF_FIELDNAME = 'LGORT'.
    V_FIELDCAT-REF_TABNAME   = 'MARD'.
      V_FIELDCAT-SELTEXT_L = 'STRG LOCT'.
      V_FIELDCAT-OUTPUTLEN = 10.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '13'.
      V_FIELDCAT-FIELDNAME     = 'LABST'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-SELTEXT_M = 'STOCK'.
      V_FIELDCAT-OUTPUTLEN = 15.
    V_FIELDCAT-REF_FIELDNAME = 'LABST'.
    V_FIELDCAT-REF_TABNAME   = 'MARD'.
      V_FIELDCAT-DO_SUM = 'X'.
      V_LAYOUT-TOTALS_TEXT = 'TOTAL STOCK:'.
      V_FIELDCAT-HOTSPOT = 'X'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '14'.
      V_FIELDCAT-FIELDNAME     = 'EBELN'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-HOTSPOT = 'X'.
      V_FIELDCAT-REF_FIELDNAME = 'EBELN'.
      V_FIELDCAT-REF_TABNAME   = 'EKPO'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '15'.
      V_FIELDCAT-FIELDNAME     = 'EBELP'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'EBELP'.
      V_FIELDCAT-REF_TABNAME   = 'EKPO'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '16'.
      V_FIELDCAT-FIELDNAME     = 'VBELN'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-HOTSPOT = 'X'.
      V_FIELDCAT-REF_FIELDNAME = 'VBELN'.
      V_FIELDCAT-REF_TABNAME   = 'VBAP'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
      V_FIELDCAT-COL_POS = '17'.
      V_FIELDCAT-FIELDNAME     = 'POSNR'.
      V_FIELDCAT-TABNAME = 'I_OUT'.
      V_FIELDCAT-REF_FIELDNAME = 'POSNR'.
      V_FIELDCAT-REF_TABNAME   = 'VBAP'.
      APPEND V_FIELDCAT TO VT_FIELDCAT1.
      CLEAR  V_FIELDCAT.
    ENDFORM.                      "FIELDCAT
                              FORM  OUTPUT                            *
    FORM OUTPUT.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM      = SY-REPID
          I_CALLBACK_TOP_OF_PAGE  = 'TOP-OF-PAGE'
          I_GRID_TITLE = 'CLICK ON MATERIAL/PURDOC/SALESDOC FOR DETAILS'
          I_CALLBACK_USER_COMMAND = 'DISPLAYDETAILS'
          IS_LAYOUT               = V_LAYOUT
          IT_FIELDCAT             = VT_FIELDCAT1
        TABLES
          T_OUTTAB                = I_OUT.
      IF SY-SUBRC <> 0.
      ENDIF.
    ENDFORM.                    "OUTPUT
                            FORM  TOP-OF-PAGE                         *
    FORM TOP-OF-PAGE.
      DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
            WA_HEADER TYPE SLIS_LISTHEADER.
      WA_HEADER-TYP = 'H'.
      WA_HEADER-INFO = 'REPORT FOR : '.
      APPEND WA_HEADER TO T_HEADER.
      CLEAR WA_HEADER.
      WA_HEADER-TYP = 'S'.
      WA_HEADER-INFO = 'MATERIAL DETAILS'.
      APPEND WA_HEADER TO T_HEADER.
      CLEAR WA_HEADER.
      WA_HEADER-TYP = 'S'.
      WA_HEADER-INFO = 'PURCHASE ORDER DETAILS'.
      APPEND WA_HEADER TO T_HEADER.
      CLEAR WA_HEADER.
      WA_HEADER-TYP = 'S'.
      WA_HEADER-INFO = 'SALES ORDER DETAILS'.
      APPEND WA_HEADER TO T_HEADER.
      CLEAR WA_HEADER.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          I_LOGO             = 'GEAR'
          IT_LIST_COMMENTARY = T_HEADER.
    ENDFORM.                    "TOP-OF-PAGE
    *&                       FORM  DISPLAYDETAILS                          *
    FORM DISPLAYDETAILS USING UCOMM LIKE SY-UCOMM
          SELFIELD TYPE SLIS_SELFIELD.
      IF SELFIELD-FIELDNAME = 'EBELN'.
        IF UCOMM = '&IC1'.
          READ TABLE I_OUT INDEX SELFIELD-TABINDEX.
          PERFORM PORECDNG.
          CLEAR BDCDATA[].
        ENDIF.
      ELSE.
        IF SELFIELD-FIELDNAME = 'MATNR'.
          IF UCOMM = '&IC1'.
            READ TABLE I_OUT INDEX SELFIELD-TABINDEX.
            PERFORM MMRECDNG.
            CLEAR BDCDATA[].
          ENDIF.
        ELSE.
          IF SELFIELD-FIELDNAME = 'VBELN'.
            IF UCOMM = '&IC1'.
              READ TABLE I_OUT INDEX SELFIELD-TABINDEX.
              PERFORM SALESRECDNG.
              CLEAR BDCDATA[].
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    "DISPLAYDETAILS
                        FORM PORECDNG                                   *
    FORM PORECDNG.
      PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0105'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'RM06E-BSTNR'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM BDC_FIELD       USING 'RM06E-BSTNR'
                                    I_OUT-EBELN.
      PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0120'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'RM06E-BSTPO(01)'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '=AH'.
      PERFORM BDC_FIELD       USING 'RM06E-EBELP'
                                    I_OUT-EBELP.
      PERFORM BDC_FIELD       USING 'RM06E-TCSELFLAG(01)'
                                    'X'.
      PERFORM BDC_TRANSACTION USING 'ME23'.
    ENDFORM.                    "PORECDNG
                        FORM MMRECDNG                                   *
    FORM MMRECDNG.
      PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0060'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'RMMG1-MATNR'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM BDC_FIELD       USING 'RMMG1-MATNR'
                                    I_OUT-MATNR.
      PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0070'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'MSICHTAUSW-DYTXT(01)'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '=ENTR'.
      PERFORM BDC_FIELD       USING 'MSICHTAUSW-KZSEL(01)'
                                    'X'.
      PERFORM BDC_TRANSACTION USING 'MM03'.
    ENDFORM.                    "MMRECDNG
                        FORM SALESRECDNG                                *
    FORM SALESRECDNG.
      PERFORM BDC_DYNPRO      USING 'SAPMV45A' '0102'.
      PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                    'VBAK-VBELN'.
      PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM BDC_FIELD       USING 'VBAK-VBELN'
                                    I_OUT-VBELN.
      PERFORM BDC_TRANSACTION USING 'VA03'.
    ENDFORM.                    "SALESRECDNG
                     FORM BDC_TRANSACTION                               *
    FORM BDC_TRANSACTION USING TCODE.
      CALL TRANSACTION TCODE USING BDCDATA MODE 'E'.
    ENDFORM.                    "BDC_TRANSACTION
                           FORM BDC_DYNPRO                              *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM = PROGRAM.
      BDCDATA-DYNPRO = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.                    "BDC_DYNPRO
                           INSERT FIELD                                  *
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR BDCDATA.
      BDCDATA-FNAM = FNAM.
      BDCDATA-FVAL = FVAL.
      APPEND BDCDATA.
    ENDFORM.                    "BDC_FIELD
    *&                  FORM  PURCHASEDATA_VALIDATION                      *
    FORM PURCHASEDATA_VALIDATION.
      SELECT EBELN EBELP MATNR
                 FROM EKPO
                 INTO TABLE I_EKPO
                 FOR ALL ENTRIES IN I_MARC
                 WHERE MATNR = I_MARC-MATNR
                 AND EBELN IN S_EBELN
                 AND WERKS EQ P_WERKS.
      IF I_EKPO[] IS INITIAL.
        WRITE:/ 'NO MATCHING DATA AVAILABLE FROM TABLE EKPO'.
        EXIT.
      ENDIF.
      DATA: T_EKPO LIKE I_EKPO OCCURS 0 WITH HEADER LINE.
      T_EKPO[] = I_EKPO[].
      REFRESH I_EKPO.
      FREE I_EKPO.
      LOOP AT T_EKPO.
        SELECT SINGLE EBELN FROM EKKO INTO EKPO-EBELN
        WHERE EBELN = T_EKPO-EBELN.
        IF SY-SUBRC = 0.
          MOVE-CORRESPONDING T_EKPO TO I_EKPO.
          APPEND I_EKPO.
          CLEAR I_EKPO.
        ELSE.
          CONTINUE.
        ENDIF.
      ENDLOOP.
      SORT I_EKPO.
    ENDFORM.                    "PURCHASEDATA_VALIDATION
    *&                  FORM  SALESDATA_VALIDATION                         *
    FORM SALESDATA_VALIDATION.
      SELECT VBELN POSNR MATNR
              FROM VBAP
              INTO CORRESPONDING FIELDS OF TABLE
              I_VBAP FOR ALL ENTRIES IN I_MARC
              WHERE MATNR = I_MARC-MATNR.
    IF I_VBAP[] IS INITIAL.
        WRITE:/ 'NO MATCHING DATA AVAILABLE FROM TABLE VBAP'.
        EXIT.
      ENDIF.
      DATA: T_VBAP LIKE I_VBAP OCCURS 0 WITH HEADER LINE.
      T_VBAP[] = I_VBAP[].
      REFRESH I_VBAP.
      FREE I_VBAP.
      LOOP AT T_VBAP.
        SELECT SINGLE VBELN FROM VBAK INTO VBAK-VBELN
        WHERE VBELN = T_VBAP-VBELN.
        IF SY-SUBRC = 0.
          MOVE-CORRESPONDING T_VBAP TO I_VBAP.
          APPEND I_VBAP.
          CLEAR I_VBAP.
        ELSE.
          CONTINUE.
        ENDIF.
      ENDLOOP.
      SORT I_VBAP.
    ENDFORM.                    "SALESDATA_VALIDATION
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • CodedUI : How to stop the TestMethod from iterating in a csv file?

    Hello All,
    I have a [TestMethod] which use a csv file. Now this csv file have some 20 rows in that. For one [TestMethod] I need to select one row from that csv, I am able to extract that row. No problem so far. 
    Once my [TestMethod] finished execution with this particular row I need to stop that. It should not take the next row from csv and execute the [TestMethod] with new set of values.
    What should I do to stop the execution after that single iteration?
    Thanks a tonne in advance.
    Thanks and Regards, Sajeev.

    Hi Sajeev,
    You may not be surprised to hear that this question (or something similar) comes up a lot.
    There are a number of basic solutions out there using if statements or loops with only one iteration (this one for example:
    https://social.msdn.microsoft.com/Forums/en-US/7571dbe5-495b-4e47-b012-1c09fbb40a4b/coded-ui-data-driven-test-limiting-the-number-of-iterations?forum=vsautotest)
    You can also ad named ranges to your CSV file and refer to these in your data source configuration instead of the sheet (this post has a lot of detail https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/79c9f86a-a223-4ab6-84af-a7c4baed4951/taking-data-from-single-excel-sheet-for-multiple-test-methods?forum=vstest)
    The drawback of the first type of solution is that all of the "empty" executions for the other iterations will still have results recorded, which makes analysis more difficult. The drawbacks of the second solution are that it is more complicated
    to implement and takes as much work as just creating a new sheet with the single row added (which might be the best option).
    Regardless, I recommend giving both solutions a go if you have time, purely from the point of view of having your own opinion of them.
    Hope this helps,

Maybe you are looking for

  • Help sql

    Hi, I have two functions.But some codes are the same so I want to merge in one function. My code is: function get_column_name (p_table_name in varchar2) return varchar2 is       l_var varchar2(100) := null;       l_str varchar2(2000) := null;       i

  • Please fix Lightroom for Sony A700

    The splotchy color noise of the Sony A700 processed in Lightroom (or ACR) needs to be fixed. It has come to the point where nearly any A700 user that participates on a photo forum knows that Lightroom is not a good Raw converter for the A700 at ISO 1

  • IPhoto 09 8.1.2 (424) very slow

    Using iPhoto 09 8.1.2 (424) iPhoto is very slow to respond. Have tried repairing permissions with no luck. This started suddenly and I am stumped. When I say slow I mean really slow. Any ideas?

  • Passing value from one object to another

    Hello all, Here is the situation: In a BEx query I will have a user entry variable for an object 0COMPANY. There is another object 0PCOMPANY that is used in the same report. I  want to accept the same value (that is entered by the user for 0COMPANY o

  • DB_CREATE_TABLE

    Hi, Plz tell me how to create a database table using function module DB_CREATE_TABLE in ABAP Editor. I was tried it but raise an exception "PROGRAM_NOT_GENERATED". Plz if you have any solution share with me.