Scenario

The standard SAP EM overdue list /SAPTRX/EE_OVD_LIST does not support creating it in the background. This report generates a spool list. In the job that creates the spool list we maintain the distribution list to email it to the recipients.


Maintaining a distribution list

Maintain a shared distribution list using transaction SO23


Creating the job

Create a job using transaction SM36 with step ZSAPTRX_EE_OVERDUE_LIST and Spool list recipient being the distribution list created above.


Report

The report below was copied from /SAPTRX/EE_OVD_LIST and modified to work in the backround.


Selection Texts

  • P_AO_ID          Application object ID
  • P_AO_SYS       Application system
  • P_AO_TP          Application Object Type
  • P_EVCODE      Event internal code
  • P_EVGRP         Event code group
  • P_EVTDAT       Expected event date
  • P_MSGDAT      Expected message date
  • P_PARCS         Partner ID Codeset (Sender)
  • P_PARID          Partner ID (Sender)
  • P_TRID             Tracking ID
  • P_TRIDTP         Tracking ID codeset
  • P_TROBTP       Business process type
  • P_TRTP            Event handler type
  • P_VARI             Report Display Variant
  • S_LBL              Participation Label
  • S_MATNR         Material Number
  • S_MRPCRL       MRP Controller
  • S_PLANT          Plant
  • S_PLNDTE       PO Planned Delivery Date
  • S_PONUM        PO Number
  • S_POORG        Purchasing Organization
  • S_POTYP         PO Type
  • S_VNDNO        Vendor Number


Text Symbols

  • 001                   Event handler
  • 002                   Expected event
  • 011                   Appl obj type
  • 013                   Appl System
  • 014                   Appl obj ID
  • 015                   Track ID Codeset
  • 016                   Tracking ID
  • 017                   PO NUMBER
  • 018                   PO LINE
  • 019                   Material
  • 020                   Material
  • 021                   PLANT
  • 022                   PO TYPE
  • 023                   PO ORG
  • 024                   MRP CTL
  • 025                   Planned Deliv Dt
  • 026                   Vendor
  • 027                   Vendor Name
  • 028                   Overdue Days
  • T01                   Variant for Report
  • T02                   Display variant
  • T03                   Report Display Variant
  • T04                   Parameter Selections


ABAP Code

*&———————————————————————*

*& Report ZSAPTRX_EE_OVERDUE_LIST                                     *

*&———————————————————————*

REPORT  ZSAPTRX_EE_OVERDUE_LIST.

TYPE-POOLS: sscr, slis.

TABLES: /saptrx/eh_hdr,

        /saptrx/eh_expev.

CONSTANTS: c_true     VALUE ‘X’,

            report     TYPE rsvar-report VALUE ‘ZSAPTRX_EE_OVERDUE_LIST’.

DATA: variante        LIKE disvariant,          

      def_variante    LIKE disvariant,          

      variant_exit(1) TYPE c,

      variant_save(1) TYPE c,
alv_default_variant    LIKE disvariant-variant,

      layout          TYPE slis_layout_alv,

      fieldcat        TYPE slis_t_fieldcat_alv,

      gs_layout       TYPE lvc_s_layo,

      gs_var_layout   TYPE disvariant,

      ls_fieldcat     TYPE slis_fieldcat_alv,

      lt_fieldcat     TYPE slis_t_fieldcat_alv,

      wa_fieldcat1    TYPE LINE OF slis_t_fieldcat_alv.

TYPES: BEGIN OF to_ex_ev,

         ao_system       LIKE /saptrx/eh_hdr-ao_system,

         ao_type         LIKE /saptrx/eh_hdr-ao_type,

         ao_id           LIKE /saptrx/eh_hdr-ao_id,

         trackingidtype  LIKE /saptrx/eh_hdr-trackingidtype,

         trackingid      LIKE /saptrx/eh_hdr-trackingid.

        INCLUDE STRUCTURE /saptrx/eh_expev_dyn.

TYPES:   po_number(10)   TYPE n,

         po_line(6)      TYPE n,

         matnr(10)       TYPE c,

         matx(33)        TYPE c,

         plant(4)        TYPE c,

         po_type(4)      TYPE c,

         po_org(4)       TYPE c,

         mrp_cntrl(3)    TYPE c,

         po_pln_dte      TYPE sy-datum,

         vendor_no(10)   TYPE c,

         vendor_name(20) TYPE c,

         overdue_days(5) type n,

po_item_qty(10)    type p decimals 0,

         po_gr_qty(10)      type p decimals 0,

         po_gr_diff(10)     type p decimals 0,

         par_lbl(11)   type c.

TYPES: END OF to_ex_ev.

INITIALIZATION.

  variant_save = ‘A’.

  CLEAR variante.

  variante-report = sy-repid.

  def_variante = variante.

  CALL FUNCTION ‘REUSE_ALV_VARIANT_DEFAULT_GET’

    EXPORTING

      i_save     = variant_save

    CHANGING

      cs_variant = def_variante

    EXCEPTIONS

      not_found  = 2.

  IF sy-subrc = 0.

    MOVE  def_variante-variant  TO alv_default_variant.

    p_vari = def_variante-variant.

  ENDIF.

AT SELECTION-SCREEN.

  IF NOT p_vari IS INITIAL.

    MOVE variante TO def_variante.

    MOVE p_vari TO def_variante-variant.

    CALL FUNCTION ‘REUSE_ALV_VARIANT_EXISTENCE’

      EXPORTING

        i_save     = variant_save

      CHANGING

        cs_variant = def_variante.

    variante = def_variante.

  ELSE.

    CLEAR variante.

    variante-report = sy-repid.

  ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.

  PERFORM f4_for_variant.

START-OF-SELECTION.

  PERFORM get_data.

  IF g_exp_ev IS INITIAL.

    MESSAGE i252(aq).  ” no records found

    EXIT.

  ENDIF.

END-OF-SELECTION.

*** Main Program

  PERFORM build_fieldcatalog.

  gs_layout-no_hgridln = c_true.

  gs_var_layout-report = report.

  CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’

      EXPORTING

           i_callback_program       = v_pgm

           i_callback_pf_status_set = ‘STATUS’

           i_callback_user_command  = ‘USER_COMMAND’

           is_layout                = layout

           it_fieldcat              = lt_fieldcat[]

           i_default                = ‘X’

           i_save                   = ‘A’              

           is_variant               = variante         

      TABLES

           t_outtab                 = g_exp_ev

           EXCEPTIONS

           OTHERS                   = 2.

  IF  NOT sy-subrc IS INITIAL.        

    MESSAGE ID sy-msgid TYPE  ‘S’     NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

*&———————————————————————*

*&      Module  pbo OUTPUT

*&———————————————————————*

FORM build_fieldcatalog.

  DATA: BEGIN OF l_cols OCCURS 14,

           col_name LIKE ls_fieldcat-fieldname,

           position LIKE ls_fieldcat-col_pos,

        END OF l_cols,

        l_col       LIKE LINE OF l_cols.

  l_cols-col_name = ‘EVENT_CODE’.

  l_cols-position = 6.                  APPEND l_cols.

  l_cols-col_name = ‘MSG_EXP_DATE’.

  l_cols-position = 7.                  APPEND l_cols.

  l_cols-col_name = ‘LATEST_MSG_DATE’.

  l_cols-position = 8.                  APPEND l_cols.

  l_cols-col_name = ‘MSG_RCVD_DATE’.

  l_cols-position = 9.                  APPEND l_cols.

  l_cols-col_name = ‘EVENT_EXP_DATE’.

  l_cols-position = 10.                 APPEND l_cols.

  l_cols-col_name = ‘EVENT_DATE’.

  l_cols-position = 11.                 APPEND l_cols.

  l_cols-col_name = ‘LATEST_EV_DATE’.

  l_cols-position = 12.                 APPEND l_cols.

  l_cols-col_name = ‘PARTNER_ID_TYPE’.

  l_cols-position = 13.                 APPEND l_cols.

  l_cols-col_name = ‘PARTNER_ID’.

  l_cols-position = 14.                 APPEND l_cols.

  l_cols-col_name = ‘LOC_ID_TYPE’.

  l_cols-position = 15.                 APPEND l_cols.

  l_cols-col_name = ‘LOC_ID_1’.

  l_cols-position = 16.                 APPEND l_cols.

  l_cols-col_name = ‘MSG_STATUS’.

  l_cols-position = 17.                 APPEND l_cols.

  ls_fieldcat-fieldname  = ‘AO_TYPE’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Appl obj type’ (011).

  ls_fieldcat-intlen     = 4.

  ls_fieldcat-outputlen  = 4.

  ls_fieldcat-col_pos    = 2.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘AO_ID’.

  ls_fieldcat-col_pos    = 3.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Appl obj ID’ (014).

  ls_fieldcat-intlen     = 30.

  ls_fieldcat-outputlen  = 12.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘AO_SYSTEM’.

  ls_fieldcat-col_pos    = 1.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Appl System'(013).

  ls_fieldcat-intlen     = 30.

  ls_fieldcat-outputlen  = 12.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘TRACKINGIDTYPE’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Track ID Codeset'(015).

  ls_fieldcat-intlen     = 20.

  ls_fieldcat-outputlen  = 10.

  ls_fieldcat-col_pos    = 4.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘TRACKINGID’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Tracking ID'(016).

  ls_fieldcat-intlen     = 50.

  ls_fieldcat-outputlen  = 20.

  ls_fieldcat-col_pos    = 5.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PO_NUMBER’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘PO NUMBER'(017).

  ls_fieldcat-intlen     = 10.

  ls_fieldcat-outputlen  = 10.

  ls_fieldcat-col_pos    = 18.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PO_LINE’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘PO LINE'(018).

  ls_fieldcat-intlen     = 7.

  ls_fieldcat-outputlen  = 7.

  ls_fieldcat-col_pos    = 19.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘MATNR’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Material'(019).

  ls_fieldcat-intlen     = 10.

  ls_fieldcat-outputlen  = 10.

  ls_fieldcat-col_pos    = 20.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘MATX’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Material'(020).

  ls_fieldcat-intlen     = 33.

  ls_fieldcat-outputlen  = 33.

  ls_fieldcat-col_pos    = 21.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PLANT’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘PLANT'(021).

  ls_fieldcat-intlen     = 4.

  ls_fieldcat-outputlen  = 4.

  ls_fieldcat-col_pos    = 22.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PO_TYPE’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘PO TYPE'(022).

  ls_fieldcat-intlen     = 4.

  ls_fieldcat-outputlen  = 4.

  ls_fieldcat-col_pos    = 23.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PO_ORG’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘PO ORG'(023).

  ls_fieldcat-intlen     = 4.

  ls_fieldcat-outputlen  = 4.

  ls_fieldcat-col_pos    = 24.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘MRP_CNTRL’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘MRP CTL'(024).

  ls_fieldcat-intlen     = 3.

  ls_fieldcat-outputlen  = 3.

  ls_fieldcat-col_pos    = 25.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PO_PLN_DTE’.

  ls_fieldcat-inttype    = ‘D’.

  ls_fieldcat-reptext_ddic    = ‘Planned Deliv Dte'(025).

  ls_fieldcat-intlen     = 8.

  ls_fieldcat-outputlen  = 8.

  ls_fieldcat-col_pos    = 26.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘VENDOR_NO’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Vendor'(026).

  ls_fieldcat-intlen     = 10.

  ls_fieldcat-outputlen  = 10.

  ls_fieldcat-col_pos    = 27.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘VENDOR_NAME’.

  ls_fieldcat-inttype    = ‘C’.

  ls_fieldcat-reptext_ddic    = ‘Vendor Name'(027).

  ls_fieldcat-intlen     = 20.

  ls_fieldcat-outputlen  = 20.

  ls_fieldcat-col_pos    = 28.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘OVERDUE_DAYS’.

  ls_fieldcat-inttype    = ‘N’.

  ls_fieldcat-reptext_ddic    = ‘Overdue Days'(028).

  ls_fieldcat-intlen     = 5.

  ls_fieldcat-outputlen  = 5.

  ls_fieldcat-col_pos    = 29.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PO_ITEM_QTY’.

  ls_fieldcat-reptext_ddic    = ‘PO QTY'(029).

  ls_fieldcat-intlen     = 13.

  ls_fieldcat-outputlen  = 13.

  ls_fieldcat-col_pos    = 30.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PO_GR_QTY’.

  ls_fieldcat-reptext_ddic    = ‘GR QTY'(030).

  ls_fieldcat-intlen     = 13.

  ls_fieldcat-outputlen  = 13.

  ls_fieldcat-col_pos    = 31.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PO_GR_DIFF’.

  ls_fieldcat-reptext_ddic    = ‘PO/GR QTY DIFF'(031).

  ls_fieldcat-intlen     = 10.

  ls_fieldcat-outputlen  = 10.

  ls_fieldcat-col_pos    = 32.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  ls_fieldcat-fieldname  = ‘PAR_LBL’.

  ls_fieldcat-reptext_ddic    = ‘LBL'(032).

  ls_fieldcat-intlen     = 11.

  ls_fieldcat-outputlen  = 11.

  ls_fieldcat-col_pos    = 33.

  APPEND ls_fieldcat TO lt_fieldcat.

  CLEAR ls_fieldcat.

  CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’

    EXPORTING

      i_program_name   = ‘ZSAPTRX_EE_OVERDUE_LIST

      i_structure_name = ‘/SAPTRX/EH_EXPEV’

    CHANGING

      ct_fieldcat      = fieldcat.

  LOOP AT fieldcat INTO wa_fieldcat1.

    READ TABLE l_cols INTO l_col

                       WITH KEY col_name = wa_fieldcat1-fieldname.

    IF sy-subrc = 0.

      wa_fieldcat1-col_pos = l_col-position.

      APPEND wa_fieldcat1 TO lt_fieldcat.

    ENDIF.

  ENDLOOP.

  1. ENDFORM. “build_fieldcatalog

*&———————————————————————*

*&      Form  get_data

*&———————————————————————*

FORM get_data.

  DATA: l_tst       TYPE timestamp,

        save_guid   LIKE /saptrx/eh_info-eh_guid.

  DATA:  lt_exp_ev_guids TYPE TABLE OF to_ex_ev

          WITH HEADER LINE.

  DATA: li_hdr_info TYPE STANDARD TABLE OF zem_pur_eh

          WITH HEADER LINE.

  DATA: BEGIN OF t_params OCCURS 0,

          eh_guid LIKE /saptrx/eh_info-eh_guid,

          param_name  LIKE /saptrx/eh_info-param_name,

          param_value LIKE /saptrx/eh_info-param_value,

        END OF t_params.

  DATA: BEGIN OF li_params OCCURS 0,

          eh_guid         LIKE /saptrx/eh_info-eh_guid,

          po_number(10)   TYPE n,

          po_line(6)      TYPE n,

          matnr(10)       TYPE c,

          matx(33)        TYPE c,

          plant(4)        TYPE c,

          po_type(4)      TYPE c,

          po_org(4)       TYPE c,

          mrp_cntrl(3)    TYPE c,

          po_pln_dte      TYPE sy-datum,

          vendor_no(10)   TYPE c,

          vendor_name(20) TYPE c,

          po_item_qty(10) TYPE p decimals 0,

          po_gr_qty(10)   TYPE p decimals 0,

          par_label(11)   TYPE c,

      END OF li_params.

  CONSTANTS: co_not_expected TYPE /saptrx/ee_msg_status VALUE ‘ ‘.

  GET TIME STAMP FIELD l_tst.

  IF p_msgdat[] IS INITIAL.

    p_msgdat-sign = ‘I’.

    p_msgdat-option = ‘BT’.

    p_msgdat-low = ‘0’.

    p_msgdat-high = l_tst.

    APPEND p_msgdat.

  ENDIF.

  REFRESH meindex.

  LOOP AT p_msgdat.

    meindex-sign = p_msgdat-sign.

    meindex-option = p_msgdat-option.

    meindex-low = p_msgdat-low+1(12).

    meindex-high = p_msgdat-high+1(12).

    APPEND meindex.

  ENDLOOP.

  IF p_evtdat[] IS INITIAL.

    p_evtdat-sign = ‘I’.

    p_evtdat-option = ‘BT’.

    p_evtdat-low = ‘0’.

    p_evtdat-high = l_tst.

    APPEND p_evtdat.

  ENDIF.

  REFRESH eeindex.

  LOOP AT p_evtdat.

    eeindex-sign = p_evtdat-sign.

    eeindex-option = p_evtdat-option.

    eeindex-low = p_evtdat-low+1(12).

    eeindex-high = p_evtdat-high+1(12).

    APPEND eeindex.

  ENDLOOP.

  REFRESH evstat.

  evstat-sign = ‘I’.

  evstat-option = ‘EQ’.

  evstat-low = ‘O’.

  APPEND evstat.

  REFRESH g_exp_ev.

  SELECT o~eh_guid o~ao_system o~ao_type o~ao_id o~trackingidtype

         o~trackingid e~event_code

         e~event_group e~partner_id_type e~msg_exp_date

         e~orig_msg_exp_dte e~earliest_msg_dte e~latest_msg_date

         e~msg_rcvd_date e~event_exp_date e~orig_ev_exp_date

         e~earliest_ev_date e~latest_ev_date e~event_date

         e~msg_status e~partner_id_type e~partner_id

     INTO CORRESPONDING FIELDS OF TABLE t_exp_ev

     FROM /saptrx/eh_hdr AS o INNER JOIN /saptrx/eh_expev AS e

     ON   o~eh_guid = e~eh_guid

     WHERE

     o~eh_active = c_true            AND

     o~trackingidtype    IN p_tridtp AND

     o~trackingid        IN p_trid   AND

     o~ao_system         IN p_ao_sys AND

     o~ao_type           IN p_ao_tp  AND

     o~ao_id             IN p_ao_id  AND

     o~bus_proc_type     IN p_trobtp AND

     o~eh_type           IN p_trtp   AND

     e~event_code        IN p_evcode AND

     e~event_group       IN p_evgrp  AND

     e~partner_id_type   IN p_parcs AND

     e~partner_id        IN p_parid  AND

   ( ( e~msg_status      IN evstat   AND

       e~msg_exp_index   IN meindex ) OR

     ( e~msg_status      = co_not_expected AND

       e~event_status    IN evstat AND

       e~event_exp_index IN eeindex ) ).

  APPEND LINES OF t_exp_ev TO g_exp_ev.

  SORT t_exp_ev BY eh_guid.

  lt_exp_ev_guids[] = t_exp_ev[] .

  DELETE ADJACENT DUPLICATES FROM lt_exp_ev_guids

    COMPARING eh_guid.

  SELECT eh_guid param_name param_value INTO TABLE t_params

      FROM /saptrx/eh_info FOR ALL ENTRIES IN lt_exp_ev_guids

      WHERE  eh_guid = lt_exp_ev_guids-eh_guid.

  SELECT eh_guid param_name param_value APPENDING TABLE t_params

      FROM /saptrx/eh_cntrl FOR ALL ENTRIES IN lt_exp_ev_guids

      WHERE  eh_guid = lt_exp_ev_guids-eh_guid.

  SELECT * INTO TABLE li_hdr_info FROM zem_pur_eh

   FOR ALL ENTRIES IN lt_exp_ev_guids

      WHERE  eh_guid = lt_exp_ev_guids-eh_guid.

  SORT: t_params BY eh_guid, li_hdr_info BY eh_guid.

  CLEAR save_guid.

  LOOP AT t_params.

*combine all parameter values for the same guid

    IF NOT save_guid IS INITIAL.

      IF NOT t_params-eh_guid = save_guid.

        save_guid = t_params-eh_guid.

        APPEND li_params.

        CLEAR li_params.

        li_params-eh_guid = t_params-eh_guid.

      ENDIF.

    ELSE.

      li_params-eh_guid = t_params-eh_guid.

      save_guid = t_params-eh_guid.

    ENDIF.

    READ TABLE li_hdr_info

     WITH KEY eh_guid = t_params-eh_guid

     BINARY SEARCH.

    IF sy-subrc = 0.

      li_params-po_number = li_hdr_info-po_number.

      li_params-plant     = li_hdr_info-plant.

      li_params-po_type   = li_hdr_info-po_type.

      li_params-vendor_no =  li_hdr_info-vendor_no.

    ENDIF.

    IF t_params-param_name = ‘PO_NUMBER’.

      li_params-po_number = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘VENDOR_NUMBER’.

      li_params-vendor_no = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘VENDOR_NAME’.

      li_params-vendor_name = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘PO_LINE_NUMBER’.

      li_params-po_line = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘MATERIAL’.

      li_params-matnr = t_params-param_value+8(10).

    ENDIF.

    IF t_params-param_name = ‘MATERIAL_TEXT’.

      li_params-matx = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘PURCHASE_ORG’.

      li_params-po_org = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘MRP_CONTROLLER’.

      li_params-mrp_cntrl = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘PO_LATEST_DLV_DATE’.

      li_params-po_pln_dte = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘PO_ITEM_QTY’.

      li_params-po_ITEM_qty = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘PO_GR_QTY’.

      li_params-PO_gr_qty = t_params-param_value.

    ENDIF.

    IF t_params-param_name = ‘PARTICIPATION_LABEL’.

      li_params-par_label = t_params-param_value.

    ENDIF.

  ENDLOOP.

*in case of 1st or last

  IF NOT li_params IS INITIAL.

    APPEND li_params.

  ENDIF.

  DELETE li_params WHERE

po_number NOT IN s_ponum  OR

matnr     NOT IN s_matnr  OR

plant     NOT IN s_plant  OR

po_type   NOT IN s_potyp OR

po_org    NOT IN s_poorg   OR

                    mrp_cntrl NOT IN s_mrpcrl  OR

po_pln_dte  NOT IN s_plndte OR

vendor_no NOT IN s_vndno    or

par_label not in s_lbl.

  LOOP AT g_exp_ev ASSIGNING <fs_exp_ev>.

    READ TABLE li_params WITH KEY

       eh_guid =  <fs_exp_ev>-eh_guid

       BINARY SEARCH.

    IF NOT sy-subrc = 0.

      DELETE g_exp_ev.” from <fs_exp_ev>.

    ELSE.

      <fs_exp_ev>-po_number = li_params-po_number.

      <fs_exp_ev>-po_line   = li_params-po_line.

      <fs_exp_ev>-matnr     = li_params-matnr.

      <fs_exp_ev>-matx      = li_params-matx.

      <fs_exp_ev>-plant     = li_params-plant.

      <fs_exp_ev>-po_type   = li_params-po_type.

      <fs_exp_ev>-po_org    = li_params-po_org.

       <fs_exp_ev>-mrp_cntrl = li_params-mrp_cntrl.

      <fs_exp_ev>-po_pln_dte  = li_params-po_pln_dte.

       <fs_exp_ev>-vendor_no = li_params-vendor_no.

      <fs_exp_ev>-vendor_name = li_params-vendor_name.

      <fs_exp_ev>-po_item_qty = li_params-po_item_qty.

       <fs_exp_ev>-po_gr_qty  = li_params-po_gr_qty.

      <FS_EXP_EV>-PAR_LBL  = li_params-par_label.

*get number of overdue days

      IF NOT <fs_exp_ev>-event_exp_date IS INITIAL.

        date1 = <fs_exp_ev>-event_exp_date+1(8).

        date2 = sy-datum.

        time1 = <fs_exp_ev>-event_exp_date+9(6).

        time2 = sy-uzeit.

        PERFORM datetime_difference

                USING date1 time1 date2 time2

                  datediff .

        IF sy-subrc = 0.

           <fs_exp_ev>-overdue_days = datediff.

        ENDIF.

      ENDIF.

*get po/gr qty diff

      <fs_exp_ev>-po_gr_diff =

      <fs_exp_ev>-po_item_qty – <fs_exp_ev>-po_gr_qty .

    ENDIF.

  ENDLOOP.

ENDFORM. ” get_data

*&———————————————————————*

*&      Form  F4_FOR_VARIANT

*&———————————————————————*

FORM f4_for_variant .

  CALL FUNCTION ‘REUSE_ALV_VARIANT_F4’

       EXPORTING

            is_variant          = variante

            i_save              = variant_save

       IMPORTING

            e_exit              = variant_exit

            es_variant          = def_variante

       EXCEPTIONS

            not_found = 2.

  IF sy-subrc = 2.

    MESSAGE ID sy-msgid TYPE ‘S’ NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ELSE.

    IF variant_exit = space.

      p_vari = def_variante-variant.

    ENDIF.

  ENDIF.

ENDFORM. ” F4_FOR_VARIANT

*&———————————————————————*

*&      Form  PF_STATUS_SET

*&———————————————————————*

FORM status USING     extab TYPE slis_t_extab.

  SET PF-STATUS ‘STANDARD_FULLSCREEN’.   “EXCLUDING EXTAB.

ENDFORM. “STATUS

*&———————————————————————*

*&      Form  USER_COMMAND

*&———————————————————————*

FORM user_command USING r_ucomm LIKE sy-ucomm

               rs_selfield TYPE slis_selfield.

  DATA: ls_ee    TYPE to_ex_ev,

        l_tabix LIKE sy-tabix.

  l_tabix = rs_selfield-tabindex.

  CASE r_ucomm.

    WHEN ‘DETAILS’ OR ‘&IC1’.

      READ TABLE  g_exp_ev INTO ls_ee INDEX l_tabix.

      CALL FUNCTION ‘/SAPTRX/EH_DETAILS’

        EXPORTING

          i_guid = ls_ee-eh_guid.

  ENDCASE.

ENDFORM.                               ” USER_COMMAND

*&———————————————————————*

*&      Form  DATETIME_DIFFERENCE

*&———————————————————————*

*       Calculate difference between two dates/times                   *

*———————————————————————-*

*  –>  date1 Date 1

*  –>  time1 Time 1

*  –>  date2 Date 2

*  –>  time2 Time 2

*  <–  daydiff Datedifference (absolute)

*  <–  hourdiff Timedifference (absolute)

*  <–  earliest Flag to show which datetime is earlier (1 or 2)

*———————————————————————-*

FORM datetime_difference

       USING date1 TYPE d time1 TYPE t

             date2 TYPE d time2 TYPE t

             daydiff TYPE p .

  DATA: d1 TYPE d, d2 TYPE d, t1 TYPE t, t2 TYPE t.

  DATA: timediff TYPE t,

        hourdiff TYPE p,

        earliest TYPE c.

  FIELD-SYMBOLS: <h>, <m>, <s>.

* Which date/time is earlier ?

  IF date1 > date2.

    earliest = ‘2’.

  ELSEIF date2 > date1.

    earliest = ‘1’.

  ELSE.

    IF time1 > time2.

      earliest = ‘2’.

    ELSEIF time2 > time1.

      earliest = ‘1’.

    ELSE.

*—- Both are equal

      earliest = ‘0’.

      daydiff = 0.

      hourdiff = 0.

      EXIT.

    ENDIF.

  ENDIF.

* Assign dates / times and swap it if necessary

  IF earliest = ‘1’.

    d1 = date1.

    t1 = time1.

    d2 = date2.

    t2 = time2.

  ELSE.

    d1 = date2.

    t1 = time2.

    d2 = date1.

    t2 = time1.

  ENDIF.

* Calculate hours difference

  timediff = t2 – t1.

  ASSIGN timediff+0(2) TO <h>.

  ASSIGN timediff+2(2) TO <m>.

  ASSIGN timediff+4(2) TO <s>.

  hourdiff = <h> + ( <m> / 60 ) + ( <s> / 3600 ).

* If no date difference then exit

  IF d2 = d1.

    daydiff = 0.

    EXIT.

  ENDIF.

* Check for time underflow and correct second date

  IF timediff > t2.

    d2 = d2 – 1.

  ENDIF.

* Calculate date difference

  daydiff = d2 – d1.

ENDFORM.                               ” DATETIME_DIFFERENCE

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply