# SAP Migration CSV Mapper

## Project Overview

This is a single-page Vue.js application that facilitates data migration from CSV files to SAP systems. It provides a visual interface for mapping CSV columns to SAP target fields and applying transformations.

## Key Components

### HTML Structure (`mapper.html`)

- Uses Vue 3 with Tailwind CSS for styling
- Three-column layout:
  1. **CSV Source Data Column**: Drag-and-drop CSV upload, field preview
  2. **Mapping Column**: SAP target fields with drag-and-drop mapping, constants, and transformations
  3. **XML Output Column**: Generated SpreadsheetML XML preview and download

### JavaScript Logic (`mapper.js`)

- **Vue 3 Composition API** setup with reactive state management
- **File Processing**:
  - CSV parsing using PapaParse
  - XML parsing with fallback handling for SAP-specific markup issues
- **Mapping Features**:
  - Drag-and-drop field mapping
  - Constant value assignment
  - Auto-mapping based on field name similarity
- **Transformations** (4 types):
  - **Lookup Tables**: Value replacement mappings
  - **Date Formatting**: Convert between date formats
  - **String Operations**: Uppercase, trim, replace, regex, substring, etc.
  - **JavaScript Expressions**: Custom value transformations

### Utilities (`mapper-utils.js`)

- CSV parsing and XML manipulation functions
- Date parsing/formatting utilities
- Transformation application logic
- SpreadsheetML XML row splicing

### Styling (`mapper.css`)

- Custom J&S theme colors
- Tailwind CSS overrides for consistent branding
- Drag-and-drop visual feedback

## Core Functionality

1. **Load SAP Template**: Upload SpreadsheetML (.xml) file to detect target schema
2. **Load CSV Data**: Upload source data file
3. **Field Mapping**: Drag CSV fields to SAP fields or set constants
4. **Data Transformation**: Apply lookups, date conversions, string operations, or JS expressions
5. **Validation**: Check for required fields and missing data
6. **XML Generation**: Produce migration-ready SpreadsheetML output

## Technical Features

- **Robust XML Parsing**: Handles malformed SAP templates with sanitization
- **Smart Field Detection**: Automatically identifies SAP fields using regex patterns
- **Auto-Mapping**: Intelligent field matching based on naming similarity
- **Preview System**: Live transformation previews
- **Validation**: Comprehensive checks for required fields and data completeness
- **Export Options**: Download or copy generated XML

## Use Case

This tool appears designed for SAP HCM (Human Capital Management) data migrations, where HR data from various sources needs to be mapped to SAP's specific field structures and formats. The test data in the project shows examples of employee data migration with mapper outputs.
