# A file for a bank or regulator | DRE

> Fixed-width or delimited files to the exact layout the other side asks for, dropped on SFTP.

[← All use cases](https://getdre.com/#use-cases)

# A file for a bank or regulator

Banks, regulators and partners send a layout spec: this column is 10 characters, right-aligned and zero-filled, that amount has an implied decimal point and a trailing sign. You keep the SQL plain and put the layout in YAML, where it can be read and reviewed.

Recorded from a real run: the command, then the file on the SFTP server.

Recorded from a real run: the command, then the file on the SFTP server.

[↓ Download the file (payments-20261001.dat)](https://getdre.com/media/downloads/payments-20261001.dat)

reports/bank\_payments/bank\_payments.yml

```yaml
queries: [payment_lines]
output:
  format: fixed_width
  extension: dat
  header: true
  line_ending: "\n"
  columns:
    - {name: order_id, width: 10, align: right, pad: "0", header: ORDER}
    - {name: order_date, width: 8, date_format: "%Y%m%d", header: DATE}
    - {name: sku, width: 8, truncate: true, header: SKU}
    - {name: qty, width: 4, header: QTY}
    - {name: unit_price, picture: "9(6)V99", header: PRICE}
    - {name: net_amount, width: 12, align: right, pad: "0", decimals: 2, decimal_point: implied, sign: trailing, header: NET}
    - {name: discount_pct, width: 3, align: right, pad: "0", null_fill: " ", header: DSC}
  destination:
    profile: sftp_password
    path: "/upload/payments-{{ run.date.yyyymmdd }}.dat"
```

reports/payments/payment\_lines.sql

```sql
select
    l.order_id,
    o.order_date,
    l.sku,
    l.qty,
    l.unit_price,
    -- refunds are negative, to exercise the sign options
    case when o.status = 'refunded' then -1 else 1 end * l.qty * l.unit_price * (100 - l.discount_pct) / 100.0 as net_amount,
    nullif(l.discount_pct, 0) as discount_pct
from order_lines l
join orders o using (order_id)
order by l.order_id, l.line_no
limit 50
```

terminal

```bash
dre run bank_payments
```

### What to notice

-   Widths, alignment, padding, implied decimals, COBOL pictures and signs are all declared per column.
-   The SQL stays plain. The layout lives in one reviewable YAML file.
-   Delimited files (pipe, tab, custom quoting and line endings) and encodings such as Windows-1252 are options too.
-   Delivery to SFTP, FTP or FTPS is a destination in the same file.

### In the docs

-   [Fixed-width columns →](https://getdre.com/docs/plugins/#fixed-width-columns)
-   [Plugins →](https://getdre.com/docs/plugins/)
