Settlement Procedure as Job

 

Settlement procedures that are implemented as jobs run identically to procedures controlled by workflows. The mains difference between these 2 forms of implementation is that the workflow environment contains additional functions (such as schedule monitoring, agent determination, and so on) that are not available if the settlement procedure is mapped as a job.

If you want to execute a settlement run for multiple settlement units, you should choose to map the settlement procedure as a job. This allows you to avoid dynamic parallel processing with a large number of parallel settlement steps, which can have a negative impact on performace if you map the settlement procedure as a workflow.

Note Note

If you still choose to map the procedure as a workflow, you can read how to avoid performance-critical dynamic parallel processing under Settlement Procedure as a Workflow.

End of the note.

You can use the standard settlement reports as a template for implementing new settlement steps.

The structure of a settlement report is always the same:

Syntax Syntax

REPORTreedmsettlproc_vv2_synth

  1. *******************************************
  2. * global prameters of settlement run
  3. PARAMETER: settldocTYPE e_edmsettldoc OBLIGATORY,
  4. settlrunTYPE e_edmsettldocrun OBLIGATORY.
  5. *******************************************
  6. * global data definition
  7. DATA: process_ref  TYPE REF TO cl_isu_edm_settlprocess,
  8. settlunits TYPE t_settlunit,
  9. settlunit TYPE e_edmsettlunit,
  10. impvalues TYPE t_settlsteppar_contvalue,
  11. impprofiles TYPEt_settlsteppar_contprofile,
  12. expvalues TYPE t_settlsteppar_contvalue,
  13. expprofiles TYPEt_settlsteppar_contprofile,
  14. settlsteplevel TYPE e_settlsteplevel.
  15. *******************************************
  16. * class interface
  17. CLASS cl_isu_edm_settlement DEFINITION LOAD.
  18. START-OF-SELECTION.
  19. *******************************************
  20. * Laufstatus Gestartet setzen
  21. *******************************************
  22. * Instanz des Bilanzierungslaufs erzeugen
  23. *******************************************
  24. * Bilanzierungsschritte ausführen
  25. *******************************************
  26. * Laufstatus Beendet mit OK setzen
End of the code.

Activities

Settlement run status

The first activity in the report to map a settlement procedue is to set the status of the settlement run to Started (cl_isu_edm_settlement=>co_settlrunstatus_started). In the settlement workbench, the user can then follow the status of the settlement run.

Syntax Syntax

  1. START-OF-SELECTION.
  2. *******************************************
  3. * set initial status
  4. CALL METHOD cl_isu_edm_settlement=>cl_set_run_status
  5. EXPORTING x_status = cl_isu_edm_settlement=>co_settlrunstatus_started
  6. x_settldoc = settldoc
  7. x_settldocrun = settlrun
  8. EXCEPTIONS OTHERS = 1.
  9. IF sy-subrc <> 0.
  10. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
  11. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  12. EXIT.
  13. ENDIF.
End of the code.

It is not possible to start additional runs for settlement documents that use the same data basis (that is the same settlement units) until the status has been set to Finished with OK (cl_isu_edm_settlement=>co_settlrunstatus_ok) or Terminated (cl_isu_edm_settlement=>co_settlrunstatus_error). The Finished with OK status should be the last action in the workflow. The Terminated status should be set before the job is terminated after a critical error. Otherwise, a new run for the settlement document cannot be created and backbilling cannot start.

Syntax Syntax

  1. *******************************************
  2. * set final status of settlement run
  3. CALL METHOD cl_isu_edm_settlement=>cl_set_run_status
  4. EXPORTING x_status = cl_isu_edm_settlement=>co_settlrunstatus_ok
  5. * in case of an error: x_status = cl_isu_edm_settlement=>co_settlrunstatus_error
  6. x_settldoc = settldoc
  7. x_settldocrun = settlrun
  8. EXCEPTIONS
  9. OTHERS = 1
  10. IF sy-subrc <> 0.
  11. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
  12. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  13. EXIT.
  14. ENDIF.
End of the code.
Generate Settlement Run Instance

An instance of the settlement run must first be generated in order to execute the settlement steps. The document number and the run number, which are provided by the settlement workbench at the beginning of a job, are required as input parameters.

Syntax Syntax

  1. PARAMETER: settldocTYPE e_edmsettldoc OBLIGATORY,
  2. settlrunTYPE e_edmsettldocrun OBLIGATORY.
  3. DATA: process_ref TYPE REF TO cl_isu_edm_settlprocess,
  4. Settlunits TYPE t_settlunit,
  5. settlunit TYPE e_edmsettlunit,
  6. settlsteplevel TYPE e_settlsteplevel,
  7. temp_settlsteplevel TYPE e_settlsteplevel,
  8. impvalues TYPE t_settlsteppar_contvalue,
  9. impprofiles TYPEt_settlsteppar_contprofile,
  10. expvalues TYPE t_settlsteppar_contvalue,
  11. expprofiles TYPEt_settlsteppar_contprofile.
  12. *******************************************
  13. * set initial status first !
  14. CALL METHOD cl_isu_edm_settlement=>cl_set_run_status
  15. EXPORTING x_status = cl_isu_edm_settlement=>co_settlrunstatus_started
  16. x_settldoc = settldoc
  17. x_settldocrun = settlrun
  18. EXCEPTIONS OTHERS = 1.
  19. IF sy-subrc <> 0.
  20. MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
  21. WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  22. EXIT.
  23. ENDIF.
  24. *******************************************
  25. CREATE OBJECT process_ref
  26. EXPORTING x_settldoc = settldoc
  27. EXCEPTIONS others = 1.
  28. IF sy-subrc <> 0.
  29. exit_error_repeat_msg.
  30. ENDIF.
  31. *******************************************
  32. * create new run instance
  33.  CALL METHOD process_ref->create_settldocrun
  34. EXPORTING x_settldoc = settldoc
  35. x_settldocrun = settlrun
  36. IMPORTING yt_settlunit = settlunits
  37. EXCEPTIONS OTHERS = 1.
  38. IF sy-subrc <> 0.
  39. exit_error_repeat_msg.
  40. ENDIF.
End of the code.

If the settlement run was successfully instantiated, the yt_settlunit output parameter contains the table with all the settlement units that are taken into account in the settlement document.

Execute Settlement Step

The method of class CL_ISU_EDM_SETTLPROCESS is used to execute settlement steps. An instance of the settlement run must have been generated beforehand as described under Generate Instance of Settlement Run. Input parameter x_settlstep determines which settlement run is executed. The name of the settlement step to be executed is entered in capital letters in the input parameter.

Syntax Syntax

  1. *******************************************
  2. * call of a single settlement step
  3. * calculate suplier factors (as profile and single value)
  4. CALL METHOD process_ref->start_step
  5. EXPORTING x_settlstep = 'FACTSUP'
  6. xt_impprofiles = impprofiles
  7. xt_impvalues = impvalues
  8. xt_settlunits = settlunits
  9. IMPORTING yt_expprofiles = expprofiles
  10. yt_expvalues = expvalues
  11. CHANGING xy_settlsteplevel = settlsteplevel
  12. EXCEPTIONS OTHERS = 1.
  13. IF sy-subrc <> 0.
  14. * e.g. set status of settlement run and quit processing
  15. MESSAGE s415(eedmset)
  16. CALL METHOD cl_isu_edm_settlement=>cl_set_run_status
  17. EXPORTING x_status = cl_isu_edm_settlement=>co_settlrunstatus_error
  18. x_settldoc = settldoc
  19. x_settldocrun = settlrun
  20. EXCEPTIONS others = 1.
  21. IF sy-subrc <> 0.
  22. * e.g. repeat sy-subrc
  23. ENDIF.
  24. EXIT.
  25. ENDIF.
  26. APPEND LINES OF expprofiles TO impprofiles.
  27. APPEND LINES OF expvalues TO impvalues.
End of the code.

The interface is the same for all settlement steps:

X_SETTLSTEP

Name of settlement step

XT_IMPVALUES

Table of value parameters for settlement steps (optional)

XT_IMPPROFILES

Table of profile parameters for settlement steps (optional)

XT_SETTLUNITS or X_SETTLUNIT

List of settlement units for global settlement steps or individual settlement unit

YT_EXPVALUES

Table of value parameters for settlement steps

YT_EXPPROFILES

Table of profile parameters for settlement steps

Y_COMPLETED_WITH_WARNINGS

Return parameter

XY_SETTLSTEPLEVEL

Level of settlement step processing

Generally, all the settlement units (with the exception of steps that run for each settlement unit) and all the parameters (profiles and values) are transferred to the settlement step and the results are added to the parameter container. The settlement step has an automatic filter to calculate the required input parameters.

The y_completed_with_warnings parameter can be evaluated in order to determine whether the settlement step ended with a warning.

An exception when calling start_step means that a critical error has occurred during execution of the settlement step. The simplest way of handling this error could be to set the status of the settlement step and then terminate the job.

Some settlement steps can only run for each settlement unit. For these settlement steps, the name of the respective settlement unit has to be transferred to parameter x_settlunit. Parameter xt_settlunits is used for settlement steps that process data from multiple settlement units.

Syntax Syntax

  1. *******************************************
  2. * call of a settlement step, that is processed for one settlement unit only
  3. LOOP AT settlunits INTO settlunit.
  4. *******************************************
  5. * calculate load profile of all interval metered customers of one
  6. * settlement unit
  7. temp_settlsteplevel = settlsteplevel.
  8. CALL METHOD process_ref->start_step
  9. EXPORTING x_settlstep = 'SUMINTSU'
  10. xt_impprofiles = impprofiles
  11. xt_impvalues = impvalues
  12. x_settlunit = settlunit
  13. IMPORTING yt_expprofiles = expprofiles
  14. yt_expvalues = expvalues
  15. CHANGING xy_settlsteplevel = temp_settlsteplevel
  16. EXCEPTIONS OTHERS = 1.
  17. IF sy-subrc <> 0.
  18. * e.g. set status of settlement run and quitt processing
  19. EXIT.
  20. ENDIF.
  21. APPEND LINES OF expprofiles TO impprofiles.
  22. APPEND LINES OF expvalues TO impvalues.
  23. ENDLOOP.
  24. settlsteplevel = temp_settlsteplevel.
End of the code.

The processing level (settlsteplevel) of the settlement step in the settlement unit is raised each time method start_step is called. To ensure that each settlement unit has the same processing level, the processing level should be reset in loops.

Set Alert

You can trigger an alert from a job (for example, if a settlement step that is critical for further processing is terminated due to an error).

Syntax Syntax

  1. DATA: wa_alert TYPE eedmsettlmsgalert,
  2. lt_alert TYPE t_eedmsettlmsgalert.
  3. wa_alert-msgty = 'E'.
  4. wa_alert-msgno = '488'.
  5. wa_alert-msgid = 'EEDMSET'.
  6. wa_alert-msgv1 = settldoc.
  7. wa_alert-msgv2 = settlrun.
  8. *wa_alert-msgv3 = .
  9. *wa_alert-msgv4 = .
  10. *wa_alert-settlunit = .
  11. *wa_alert-grid_id = .
  12. wa_alert-settldoc = settldoc.
  13. wa_alert-settldocrun = settlrun.
  14. wa_alert-settlalertstatus = 
  15. cl_isu_edm_settlement=>co_settlalertstatus_activ.
  16. append wa_alert to lt_alert.
  17. * set alert
  18. CALL METHOD cl_isu_edm_settlement=>cl_alert_write.
  19. EXPORTING xt_alert = lt_alert
  20. EXCEPTIONS others = 0.
End of the code.

The following components of eedmsettlmsgalert must be specified:

  • MSGTY: Message Type

  • MSGID: Message Class

  • MSGNO: Message Number

  • SETTLDOC: Settlement Document

  • SETTLDOCRUN: Number of Settlement Run

  • SETTLALERTSTATUS: Activate Alert (cl_isu_edm_settlement=>co_settlalertstatus_activ)

The alert input parameters are entered in the same way as the system fields (SY-MSGNO, SY-MSGID, SY-MSGTY, SY-MSGV1, SY-MSGV2, SY-MSGV3, and SY-MSGV4). You need to specfiy the alert context (settlement unit, grid) if the message refers to a specfiic settlement unit and/or grid.

An alert must be confirmed manually in the settlement workbench. Special authorization is required to view or confirm alerts.

An alert generates a BOR event simultaneously that can be used in an additional workflow to send a notification mail, for example.

Set or Read Parameter Value

Access to table t_settlsteppar_contvalue can be used to set or read parameter values. The parameter name must be entered in capital letters.

Read Run Data

You can use the reference to the settlement run process_ref->run_information to obtain read-only access to the settlement run information. The following data is available:

  • SETTLDOCMODE: Mode of Settlement Run (for example, Simulation, Active)

  • SETTLRUNTYPE: Type of Settlement Run (for example, Backbilling Following an Error)