Salesforce

How Do I Create Tasks that Dump Data Records Into Flat Text Files and Vice Versa? (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Do I Create Tasks that Dump Data Records Into Flat Text Files and Vice Versa? (Magic xpa 4.x)

One very common programming task is to dump data into a flat file, or to read data from a flat file. Fortunately, Magic xpa has a very nice facility for doing most of the work for you.

Dumping records to a text file

  1. Open up a new line in the Program repository by pressing F4 (Edit->Create Line).

  2. Press Ctrl+G (Options->Generate Program).

  1. The Program Generator dialog box will appear. Select:

Option: Export

Main source: Whatever data source you want to export. You can zoom to select from a list.

Columns: Zoom here to select which columns will export. By default, all columns will export, but in this example, we set most of them to zero so only the Last Name, First Name, Phone Type 1 and Phone Number 1 will export.

Text file: You can enter another file name here if you want. You can also change it within the generated program to use a variable or logical name path.

  1. Click OK.

Your program is now created, and when you run it, it will export every record from the main source. You can edit the program as you would any Magic xpa program, changing the output format and adding ranges to limit which records are exported.

Reading records from a text file

  1. Open up a new line in the Program repository by pressing F4 (Edit->Create Line).

  2. Press Ctrl+G (Options->Generate Program).

  1. The Program Generator dialog box will appear. Select:

Option: import

Main source: Whatever data source you want to import. You can zoom to select from a list.

Columns: Zoom here to change which columns will import. By default, all of the columns will import, as shown here.

Text file: You can enter another file name here if you want. You can also change it within the generated program to use a variable or logical name path.

  1. Click OK.

Your program is now created, and when you run it, it will import every record from the flat file. You may have to edit the import form to match your flat file, depending on the data layout.

Note that the automatically generated program does not check for duplicate records, so it is up to you to either run this on an empty data source, or make sure that the data isn’t duplicated. Otherwise, you will get error messages from the DBMS.

Hint: If you accept the defaults for the column layout, the export program Magic xpa creates is a perfect match for the import program. This way, you can use the generated programs as a quick way to copy data from one location to another.

See also

The Online and Rich Client Samples projects (program TS09 and RTS09)

Reference
Attachment 
Attachment