Variants & Job Scheduling

Selection variants, dynamic date fields, and job scheduling in SM36.

Overview

For the Extractor report to run automatically, you need two things:

  1. Selection variant – stores the selection parameters (which data types, which time period, which company codes)

  2. Background job (SM36) – starts the report periodically using the stored variant


1. Create a Selection Variant

Step by Step

  1. SE38 → Call report ZFI_BILENDO_EXPORT_V2 → F8 (Execute)

  2. Fill in the selection screen:

    • P_KNA1 = X (customer master)

    • P_BSID = X (open items)

    • P_BSAD = X (cleared items)

    • P_DELTA = X (delta load)

    • S_BUKRS = desired company codes

    • Date fields: → dynamic (see next section)

  3. Menu: Goto → Variants → Save as Variant

  4. Variant name: e.g., BILENDO_DAILY_DELTA

  5. Description: e.g., Bilendo Daily Delta Export

  6. Save

Recommended Selection Values

ParameterValueNote
P_KNA1XExtract customer master
P_BSEG–Usually not required
P_BSIDXOpen items
P_BSADXCleared items
P_ALL–Only for a one-time full load
P_DELTAXDefault: Delta
S_BUKRSAll relevant BUKRSRestriction to active company codes

2. Configuring Dynamic Date Fields

Fixed date values in the variant lead to outdated selections. Instead, you must use selection variables that calculate the current date on each run.

Which Fields Should Be Set Dynamically?

FieldSelect optionRecommended variableMeaning
Entry dateS_CPUDTD: Current date, offset -7 to 0Last 7 days
Clearing dateS_AUGDTD: Current date, offset -7 to 0Last 7 days
Entry timeS_CPUTM(fixed, e.g., 00:00:00 to 23:59:59)Optional: restriction

Instructions: Storing a Dynamic Date in a Variant

  1. Open the variant in change mode

  2. Click the "Attributes" button (or use the menu: Goto → Variants → Attributes)

  3. In the "Selection Variable" column, place the cursor in the S_CPUDT field (low value)

  4. Call up the F4 value help

  5. Select a variable:

    • D = Current date (for the "To" value)

    • D with offset -7 = Current date minus 7 days (for the "From" value)

  6. Follow the same procedure for S_AUGDT

  7. The fields are then displayed as not editable (grayed out) – this is correct

  8. Save the variant

Typical Configuration

S_CPUDT (Entry Date):
  From: D (current date) - 7 days
  To: D (current date)

S_AUGDT (Clearing Date):
  From: D (current date) - 7 days
  To: D (current date)

Recommendation: Use an overlap of at least 7 days. In SAP, postings can be entered retroactively, so time windows that are too narrow lead to data gaps in Bilendo.


3. Selection Logic in Detail

Open Items (BSID)

The class ZCL_FI_BILENDO_ASSIST_V2 (method get_bsid) makes selections as follows:

If the CPU date (S_CPUDT) is filled and covers only 1 day (because of the time of day):

If posting date (S_BUDAT) is filled:

Cleared Items (BSAD)

If CPU date (S_CPUDT) is filled:

If clearing date (S_AUGDT) is filled:

If Clearing Document (S_AUGBL) is filled:

Customer Master (KNA1)


4. Scheduling a Job (SM36)

Step by Step

  1. Call transaction SM36

  2. Assign a job name: BILENDO_EXPORT_DAILY

  3. Job class: A (highest priority) or B (normal)

Define the Step

  1. Click the "Steps" button → "ABAP/4 Program"

  2. Enter the following:

    • Program name: ZFI_BILENDO_EXPORT_V2

    • Variant: BILENDO_DAILY_DELTA

  3. "Copy" → The step is created

You can chain multiple steps for different company codes or different reports (e.g., export first, then import) in a single job.

Start Condition

  1. Click the "Start Condition" button → "Date/Time"

  2. Start date: Today's date (or the next desired day)

  3. Start time: e.g., 03:00:00 (before the Bilendo import window)

  4. Select the "Periodic" checkbox

  5. Period: "Daily" → "Save"

Release the Job

  1. Back on the main screen: Click the "Save" button

  2. The job appears in SM37 with the status "Released"

Job Monitoring (SM37)

StatusMeaningAction
ScheduledJob is waiting for start condition–
ActiveJob is currently running–
FinishedCompleted successfullyCheck the log
CanceledAn error occurredAnalyze the job log (SM37 → Job Log)

5. Job Configuration Variants

Variant A: One Job for All Company Codes

Job: BILENDO_EXPORT_DAILY
  Step 1: ZFI_BILENDO_EXPORT_V2 / Variant: BILENDO_DAILY_DELTA
          (S_BUKRS contains all company codes)
  Start condition: Daily 03:00

Variant B: Separate Jobs per Company Code

Job: BILENDO_EXPORT_BK1001
  Step 1: ZFI_BILENDO_EXPORT_V2 / Variant: BILENDO_DELTA_1001
  Start condition: Daily 03:00

Job: BILENDO_EXPORT_BK2001
  Step 1: ZFI_BILENDO_EXPORT_V2 / Variant: BILENDO_DELTA_2001
  Start condition: Daily 03:15

Variant C: Export + Import in One Job

Job: BILENDO_SYNC_DAILY
  Step 1: ZFI_BILENDO_EXPORT_V2 / Variant: BILENDO_DAILY_DELTA
  Step 2: ZFI_BILENDO_IMPORT_V2 / Variant: BILENDO_IMPORT_DAILY
  Start condition: Daily 03:00

Note: Variant C only makes sense if the Bilendo-side writeback files are already on the application server when the job runs. Otherwise, the import job should run with a time offset.


6. Variant for Two-Stage Delta (Every 6 Hours)

When using the improved two-stage delta logic (→ 04 - Extractor Report#Improved Delta Logic Two-Stage Selection), the job is scheduled every 6 hours. The delta windows are calculated programmatically in the get_open_delta() and get_cleared_delta() methods, so dynamic date fields in the variant are no longer required.

Variant: BILENDO_DELTA_6H

ParameterValueNote
P_KNA1XCustomer master (optional on each run)
P_BSIDXOpen items via get_open_delta()
P_BSADXCleared items via get_cleared_delta()
P_DELTAXEnables two-stage methods
S_BUKRSAll relevant BUKRS
S_CPUDTemptyCalculated internally (6-hour window)
S_AUGDTemptyCalculated internally (24-hour window)

SM36 Scheduling (Periodic, Every 6 Hours)

  1. SM36 → Job name: BILENDO_EXPORT_6H

  2. Step: ZFI_BILENDO_EXPORT_V2 / Variant BILENDO_DELTA_6H

  3. Start condition → Date/Time → Start time 00:00:00

  4. Select the checkbox "Periodic" → Period: "Hourly" → Hour value: 6

  5. Save

Run timeBSID windowBSAD window
00:00BKPF: CPUDT/CPUTM ≥ previous day 18:00BSAD: AUGDT ≥ previous day
06:00BKPF: CPUDT/CPUTM ≥ 00:00BSAD: AUGDT ≥ previous day
12:00BKPF: CPUDT/CPUTM ≥ 06:00BSAD: AUGDT ≥ previous day
18:00BKPF: CPUDT/CPUTM ≥ 12:00BSAD: AUGDT ≥ previous day

The BSAD selection always uses a 24-hour window (AUGDT ≥ yesterday), regardless of the run frequency. This creates a fourfold overlap, which ensures robustness in the event of errors.


7. Variant for Initial/Full Load

A separate variant is required for the initial load or a complete reload:

ParameterValueNote
P_ALLXFull load mode
P_DELTA–
S_CPUDTemptyNo time filter
S_AUGDTemptyNo time filter
S_BUKRSAll BUKRS

Variant name: e.g., BILENDO_INITIAL_FULL

⚠️ Caution: Depending on the data volume, a full load can cause significant runtime and system load. Coordinate with SAP Basis before running it in PRD.