Populate Multiple Structures With A Single Source File

Jimbo's picture

File already used.LSMW blocks the use of a single source file to fill multiple structures. SAP clearly intended that each file loaded to fill a structure be unique as each structure is related in a hierarchy to other structures by fieldname(s). If a file is related to itself then every record is related to at least one other record in the same file. Accidentally linking a file to more than one structure is an easy way to cause catastrophic errors and SAP has included a check in LSMW to prevent this.

Some objects in SAP have too many fields to be easily imported into LSMW using a single source file and some developers will try to split these fields across multiple files to simplify the management of the fields in smaller files. Where the LSMW object has been configured to use multiple files, but the source data comes as a single file it is possible to use the same file multiple times in a relational way.

Often times relational data is extracted as a single flat table and arrives as a simple text file or spreadsheet that needs to be further massaged for loading into SAP. An example of this is a source file for material characteristics that has multiple lines for a material/classification combination where each line is a single characteristic value. In this situation the one-to-many relationship to records within the file make it more cumbersome to deal with, but a simple skip_transaction command applied to redundant entries solves this easily enough.

While Windows™ does not have case-sensitive filenames, SAP does. Changing one character in each iteration of the filename is enough to trick LSMW into allowing the same file to be used for multiple structures and avoid the "File is already specified." error message. This Material Master LSMW object has four structures each with a 1:1 relationship to each other. In effect, there is a single record in all four structures for each material. The client had previously manually broken the single source file into four relational files, but it was unnecessary. By changing the case of a single letter in each filename it was possible to use a single file for all four structures.

LSMW recognizes that there are fields in each file that are not mapped in the structure. This is another great fail-safe built into LSMW to prevent the careless loss of of data integrity, but in this case the error message can be ignored with impunity.

LSMW reports what has been read into the system and no data has been omitted.