Skip to Content

Hi,

sometimes you must implement modification for multi sales deal terms in VB21 by screen 123 (Dialog Box for Overlapping Dates) off.

So You must modify 2 programs:

1.  MV13AF0G

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

*       FORM  GUELTIGKEIT_PRUEFEN_AGREEMENT                            *

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

*       The validity periods for condition records in sales deals may  *

*       not overlap in any way with condition records with the same    *

*       condition type and variable key but on a different agreement.  *

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

FORM gueltigkeit_pruefen_verkaufsak USING all

                                          sichern

                                 CHANGING value(gp_subrc).

“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””$”$\SE:(1) Form GUELTIGKEIT_PRUEFEN_VERKAUFSAK, Start                                                                                                        A

*$*$-Start: (1)———————————————————————————$*$*

ENHANCEMENT 1  Z_MV13AFOG.    “active version

DATA: BEGIN OF S_KNUMH OCCURS 0,

        KNUMH TYPE KNUMH,

        datab TYPE kodatab,

        datbi TYPE kodatbi,

        ANSWER,

      END OF S_KNUMH.

IF sy-ucomm = ‘SICH’.

   IMPORT s_knumh TO s_knumh FROM MEMORY ID ‘KNUMH’.

ENDIF.

RANGES s_ucomm FOR sy-ucomm.

s_ucomm-sign = ‘I’.

s_ucomm-option = ‘EQ’.

s_ucomm-low = ‘SICH’.

APPEND s_ucomm.

s_ucomm-sign = ‘I’.

s_ucomm-option = ‘EQ’.

s_ucomm-low = ‘ABRE’.

APPEND s_ucomm.

s_ucomm-sign = ‘I’.

s_ucomm-option = ‘EQ’.

s_ucomm-low = ‘SIC1’.

APPEND s_ucomm.

s_ucomm-sign = ‘I’.

s_ucomm-option = ‘EQ’.

s_ucomm-low = ‘OPT1’.

APPEND s_ucomm.

s_ucomm-sign = ‘I’.

s_ucomm-option = ‘EQ’.

s_ucomm-low = ‘ENT1’.

APPEND s_ucomm.

s_ucomm-sign = ‘I’.

s_ucomm-option = ‘EQ’.

s_ucomm-low = ‘OPT1’.

APPEND s_ucomm.

SORT s_ucomm BY low ASCENDING.

IF fcode = ‘ENT1’.

   sy-ucomm = ‘ENT1’.

ENDIF.

IF sy-ucomm IN s_ucomm AND sy-tcode = ‘VB21’.

   DATA: lv_ksdat            LIKE t681-ksdat,

         lv_flag             TYPE flag,

         lv_no_popup         TYPE flag,

         lv_new_flag         TYPE flag,

         lv_old_flag         TYPE flag,

         lv_new_rec          TYPE flag,

         lv_zvflg_save_deal  TYPE zvflg_save_deal,

         lv_title(30),

         lv_answer,

         lv_question(400),

         lv_matnr            TYPE matnr,

         lv_knuma_ag         TYPE knuma_ag,

         lv_new_datab        TYPE kodatab,     ” nowa data poczatkowa obowiazywania warunku

         lv_new_datbi        TYPE kodatbi,     ” nowa data koncowa obowiazywania warunku

         lv_old_datab        TYPE kodatab,     ” aktualna data poczatkowa obowiazywania warunku

         lv_old_datbi        TYPE kodatbi.     ” aktualna data koncowa obowiazywania warunku

   DATA : BEGIN OF s_komg .

           INCLUDE STRUCTURE komg.

   DATA : END OF  s_komg .

   IMPORT lv_popup TO lv_no_popup FROM MEMORY ID sy-uname.

   PERFORM time_vake_akt_fill(sapmv130) USING no.

*if not TIME_VAKE_AKT[] is INITIAL.

*    READ TABLE time_vake_akt INDEX 1

**  TCTRL_FAST_ENTRY-CURRENT_LINE

*    .

*

*    IF sy-subrc = 0.

   LOOP AT  time_vake_akt.

         PERFORM vake_next(sapmv130) USING yes.

         IF NOT rv13a-datab = ‘00000000’.

           lv_new_datab = rv13a-datab.

         ELSE.

           lv_new_datab = rv130-datab.

         ENDIF.

         IF NOT rv13a-datbi = ‘00000000’.

           lv_new_datbi = rv13a-datbi.

         ELSE.

           lv_new_datbi = rv130-datbi.

         ENDIF.

     READ TABLE S_KNUMH WITH KEY KNUMH = time_vake_akt-knumh

                                 DATAB = lv_new_datab

                                 DATBI = lv_new_datBI.

     IF NOT SY-SUBRC = 0.

       CALL FUNCTION ‘SD_CONDITION_KOMG_FILL’

         EXPORTING

           p_kotabnr = time_vake_akt-kotabnr

           p_kvewe   = time_vake_akt-kvewe

           p_vakey   = time_vake_akt-vakey

         IMPORTING

           p_komg    = s_komg.

       SELECT SINGLE zvflg_save_deal FROM zpon INTO lv_zvflg_save_deal

         WHERE vkorg = kona-vkorg

           AND vtweg = kona-vtweg

           AND spart = kona-spart

           AND kunnr = s_komg-kunnr.

       IF NOT sy-subrc = 0.

         SELECT SINGLE zvflg_save_deal FROM zpon INTO lv_zvflg_save_deal

          WHERE vkorg = kona-vkorg

            AND vtweg = kona-vtweg

            AND spart = kona-spart.

         IF NOT sy-subrc = 0.

           EXIT.

         ENDIF.

       ENDIF.

       IF lv_zvflg_save_deal = ‘X’.

         lv_old_datab = time_vake_akt-datab.

         lv_old_datbi = time_vake_akt-datbi.

         lv_matnr = s_komg-matnr.

         SELECT SINGLE knuma_ag FROM konp INTO lv_knuma_ag

           WHERE knumh = time_vake_akt-knumh.

*    ENDIF.

*if not lv_new_rec = ‘X’.

         IF ( ( lv_new_datab = ‘00000000’ ) AND ( lv_new_datbi = ‘00000000’ ) ).

           lv_new_flag = ”.

         ENDIF.

         IF ( ( lv_old_datab = ‘00000000’ ) AND ( lv_old_datbi = ‘00000000’ ) ).

           lv_old_flag = ”.

         ENDIF.

         IF ( lv_new_datbi = lv_old_datbi ) AND ( lv_old_datab BETWEEN lv_new_datab AND lv_new_datbi ).

           lv_old_flag = ‘X’.

         ENDIF.

         IF ( lv_new_datbi = lv_old_datab ) AND ( lv_new_datab < lv_old_datab ).

           lv_old_flag = ‘X’.

         ENDIF.

         IF ( lv_new_datab = lv_old_datab ) AND ( lv_new_datbi BETWEEN lv_old_datab AND lv_old_datbi ).

           lv_new_flag = ‘X’.

         ENDIF.

         IF ( lv_new_datbi > lv_old_datbi ) AND ( lv_new_datab BETWEEN lv_old_datab AND lv_old_datbi ).

           lv_new_flag = ‘X’.

         ENDIF.

         IF ( lv_new_datab < lv_old_datab ) AND ( lv_new_datbi BETWEEN lv_old_datab AND lv_old_datbi ).

           lv_new_flag = ‘X’.

         ENDIF.

         IF ( lv_new_datbi = lv_old_datbi ) AND ( lv_new_datab BETWEEN lv_old_datab AND lv_old_datbi ).

           lv_new_flag = ‘X’.

         ENDIF.

         IF ( lv_new_datab = lv_old_datab ) AND ( lv_old_datbi BETWEEN lv_new_datab AND lv_new_datbi ).

           lv_new_flag = ”.

         ENDIF.

         IF ( lv_new_datbi = lv_old_datbi ) AND ( lv_new_datab BETWEEN lv_old_datab AND lv_old_datbi ).

           lv_old_flag = ‘X’.

         ENDIF.

         IF ( lv_new_datab = lv_old_datbi ) AND ( lv_new_datbi > lv_old_datbi ).

           lv_new_flag = ‘X’.

         ENDIF.

*    IF ( ( lv_new_datab BETWEEN lv_old_datab AND lv_old_datbi ) AND ( lv_new_datbi BETWEEN lv_old_datab AND lv_old_datbi ) ).

         IF ( ( lv_new_datab > lv_old_datab AND lv_new_datab < lv_old_datbi ) AND ( lv_new_datbi < lv_old_datbi  AND lv_new_datbi > lv_old_datab ) ).

           lv_old_flag = ”.

           lv_new_flag = ”.

         ENDIF.

*         IF ( ( lv_old_datab BETWEEN lv_new_datab AND lv_new_datbi ) AND ( lv_old_datbi BETWEEN lv_new_datab AND lv_new_datbi ) ).

if ( lv_old_datab > lv_new_datab ) and ( LV_OLD_DATBI < LV_new_DATBI ).

*           lv_old_flag = ”.

           lv_old_flag = ‘X’.

*           lv_new_flag = ”.

         ENDIF.

         IF lv_new_flag = ‘X’ OR lv_old_flag = ‘X’.

*      IF ( NOT lv_new_datab = lv_old_datab ) and ( NOT lv_new_datbi = lv_old_datbi ).

*    if ( ( not lv_new_datab BETWEEN lv_old_datab and lv_old_datbi ) and ( not lv_new_datbi BETWEEN lv_old_datab and lv_old_datbi ) ).

           lv_flag = ‘X’.

           CONCATENATE ‘The validity period of new condition overlaps with different conditions. These conditions will be edited when you save! Material:’ lv_matnr

           ‘, Old Sales Deal:’ lv_knuma_ag

           ‘, New beginnig date: ‘ lv_new_datab ‘, New end date: ‘

           lv_new_datbi ‘. Old beginning date: ‘

           lv_old_datab ‘, Old end date: ‘ lv_old_datbi ‘. Are You Sure?’ INTO lv_question.

*    endif.

*      ENDIF.

         ENDIF.

*endif.

*endloop.

         IF lv_flag = ‘X’.

           IMPORT lv_answer TO lv_answer FROM MEMORY ID ‘ANSWER’.

           IF

*             lv_no_popup = ” OR

             ( ( lv_answer IS INITIAL ) OR ( lv_answer = ‘A’ ) ).

             CALL FUNCTION ‘POPUP_TO_CONFIRM’

               EXPORTING

                titlebar                    = ‘Sales Deal Warning’

*     DIAGNOSE_OBJECT             = ‘ ‘

                 text_question               = lv_question

                text_button_1               = ‘Yes’

                icon_button_1               = ‘ ‘

                text_button_2               = ‘No’

                icon_button_2               = ‘ ‘

                default_button              = ‘2’

                display_cancel_button       = ‘X’

*     USERDEFINED_F1_HELP         = ‘ ‘

                start_column                = 25

                start_row                   = 6

*     POPUP_TYPE                  =

*     IV_QUICKINFO_BUTTON_1       = ‘ ‘

*     IV_QUICKINFO_BUTTON_2       = ‘ ‘

              IMPORTING

                answer                      = lv_answer

*     TABLES

*     PARAMETER                   =

              EXCEPTIONS

                text_not_found              = 1

                OTHERS                      = 2.

             EXPORT lv_answer TO MEMORY ID ‘ANSWER’.

             IF lv_answer = ‘1’ OR lv_answer = ‘2’.

               lv_no_popup = ‘X’.

               EXPORT lv_no_popup TO MEMORY ID ‘NO_POPUP’.

               lv_ksdat = t681-ksdat.

               CLEAR t681-ksdat.

               IF lv_answer = ‘2’.

                 s_knumh-DATBI = lv_new_datbi.

                 s_knumh-DATAB = lv_new_datAB.

                 s_knumh-KNUMH = time_vake_akt-knumh.

                 APPEND s_knumh.

               ENDIF.

             ENDIF.

           ELSE.

             IF lv_answer = ‘1’

*               OR lv_answer = ‘2’

               .

               lv_no_popup = ‘X’.

               EXPORT lv_no_popup TO MEMORY ID ‘NO_POPUP’.

               lv_ksdat = t681-ksdat.

               CLEAR t681-ksdat.

*               IF lv_answer = ‘2’.

*

*                 s_knumh-DATBI = lv_new_datbi.

*                 s_knumh-DATAB = lv_new_datAB.

*                 s_knumh-KNUMH = time_vake_akt-knumh.

*                 APPEND s_knumh.

*

*               ENDIF.

             ENDIF.

           ENDIF.

         ENDIF.

       ENDIF.

       CLEAR: lv_new_datab, lv_old_datab, lv_new_datbi, lv_old_datbi, lv_knuma_ag, lv_new_flag, lv_old_flag.

     ENDIF.

   ENDLOOP.

   DELETE ADJACENT DUPLICATES FROM s_knumh.

   EXPORT s_knumh TO MEMORY ID ‘KNUMH’.

ENDIF.

ENDENHANCEMENT.

*$*$-End:   (1)———————————————————————————$*$*

  LOCAL: ivake,

         konp, xkonp,

         vake, xvake, time_vake, time_vake_key,

         read_tabix, rv13a,

         konh,

         svake,

         skonp,

         ivake_tabix_selkz,

         low_tabix_ivake,

         high_tabix_ivake.

  DATA: ivake_tabix LIKE sy-tabix,

        overlap,

        save_dyngr LIKE sy-dyngr,

        column_left TYPE p.

  DATA: BEGIN OF save_xvake_tab OCCURS 0.

          INCLUDE STRUCTURE xvake.

  DATA: END OF save_xvake_tab.

  DATA: BEGIN OF save_ivake_tab OCCURS 0.

          INCLUDE STRUCTURE ivake.

  DATA: END OF save_ivake_tab.

  DATA: BEGIN OF save_xkonp_tab OCCURS 0.

          INCLUDE STRUCTURE xkonp.

  DATA: END OF save_xkonp_tab.

  save_dyngr = sy-dyngr.

  save_xkonp_tab[] = xkonp[].

  save_xvake_tab[] = xvake[].

  ivake_check = all.

  REFRESH save_ivake_tab.

  gp_subrc = 0.

  CHECK fcode = fcode_sichern      OR

        fcode = fcode_v13a_sichern OR

        fcode = fcode_weiter.

* Structure with Validity Periods ?

  IF t681-ksdat = charx.

* Initialize mimimum and maximum ivake indices

    CLEAR: low_tabix_ivake, high_tabix_ivake, ivake_tabix_selkz.

* Build ivake if needed

    save_ivake_tab[] = ivake[].

    IF ivake_check = ‘X’ AND sy-dyngr NE ‘VARS’.

      REFRESH ivake.

      LOOP AT xvake.

        MOVE-CORRESPONDING xvake TO ivake.

        ivake-tabix = sy-tabix.

        APPEND ivake.

      ENDLOOP.

      SORT ivake.

    ENDIF.

* Read all Conditions from ivake

    LOOP AT ivake.

* For variable screen, don’t process dummy entries in ivake

      CHECK NOT ivake-kotabnr IS INITIAL.

* Process only 1 KNUMH or all KNUMH’s ???

      IF ivake_check = ‘ ‘.

        CHECK ivake-knumh = vake-knumh.

      ENDIF.

* Mark Position in table IVAKE

      ivake_tabix = sy-tabix.

* Initialize overlap flag

      CLEAR overlap.

* Read XVAKE

      READ TABLE xvake INDEX ivake-tabix.

* Check to make sure it’s an agreement

      IF abtyp_general NE abtyp-agreement.

        IF ivake_check = ‘ ‘.

          CHECK NOT konp-knuma_ag IS INITIAL.

        ELSE.

          READ TABLE xkonp INDEX xvake-tabix2.

          CHECK NOT xkonp-knuma_ag IS INITIAL.

        ENDIF.

      ENDIF.

* If dates have changed then update XVAKE with new ones (reset later)

      IF ivake_check = ‘ ‘.

        IF xvake-datab NE rv13a-datab.

          xvake-datab = rv13a-datab.

          MODIFY xvake INDEX ivake-tabix.

        ENDIF.

        IF xvake-datbi NE rv13a-datbi.

          xvake-datbi = rv13a-datbi.

          MODIFY xvake INDEX ivake-tabix.

        ENDIF.

      ENDIF.

* Change made ?

      IF xvake-updkz <> space.

        MOVE-CORRESPONDING xvake TO time_vake_key.

* Read time-dependent records

        READ TABLE time_vake WITH KEY time_vake_key BINARY SEARCH.

* Fill the table with the actual validity periods

        WHILE sy-subrc    = 0               AND

              xvake-kotabnr = time_vake-kotabnr AND

              xvake-kschl = time_vake-kschl AND

              xvake-vakey = time_vake-vakey.

* Next record in table

          read_tabix = sy-tabix + 1.

* Check to see if another condition record that is active and assigned

* to a sales deal overlaps with the record being processed.

          IF NOT ( xvake-updkz = updkz_update    AND        “Update

                   xvake-knumh = time_vake-knumh ).         “Same record

            SELECT * FROM konp

                   WHERE knumh = time_vake-knumh.

              EXIT.

            ENDSELECT.

            IF NOT konp-knuma_ag IS INITIAL AND             “agreement

               konp-loevm_ko IS INITIAL.                    “not deleted

              IF ( time_vake-datab <  xvake-datab AND     “limited

                   time_vake-datbi <= xvake-datbi AND

                   time_vake-datbi >= xvake-datab ) OR

                 ( time_vake-datab >= xvake-datab AND    “limited

                  time_vake-datab <= xvake-datbi AND

*                ( time_vake-datab >= xvake-datab and    “total overlap

*                  time_vake-datbi <= xvake-datbi ) or

                   time_vake-datbi >  xvake-datbi ) OR

                 ( time_vake-datab < xvake-datab AND     “split

                   time_vake-datbi > xvake-datbi ).

* Set Overlap Flag

                overlap = charx.

                gp_subrc = 4.

                EXIT.

              ENDIF.

            ENDIF.

          ENDIF.

* Read next record

          READ TABLE time_vake INDEX read_tabix.

        ENDWHILE.

      ENDIF.

* Set Selection Flag

      ivake-selkz = overlap.

      MODIFY ivake.

* Set smallest and largest indices for range of overlapping records

      IF overlap = charx.

        IF low_tabix_ivake IS INITIAL.

          low_tabix_ivake   = ivake_tabix.

          gp_subrc = 8.

        ENDIF.

        high_tabix_ivake = ivake_tabix.

      ENDIF.

    ENDLOOP.

  ENDIF.

  IF gp_subrc NE 0.

    IF NOT low_tabix_ivake IS INITIAL.

      time_vakey = space.

      PERFORM vake_next(sapmv130) USING yes.

* Call error popup window

      CALL SCREEN 123 STARTING AT 20 1.

      CLEAR time_vakey.

* Delete/mark entries

      LOOP AT ivake.

        IF ivake-selkz = updkz_delete.

          DELETE ivake.

        ENDIF.

        IF ivake-selkz = char_plus OR

           ivake-selkz = charx.

          ivake-selkz = charx.

          MODIFY ivake.

        ENDIF.

      ENDLOOP.

    ENDIF.

  ENDIF.

* Set XVAKE back to how it was upon entering this form

* (in some cases, we modified the DATAB and DATBI dates)

  REFRESH xvake.

  xvake[] = save_xvake_tab[].

  xkonp[] = save_xkonp_tab[].

* Loop at saved ivake and update the selection indicator

* for entries with errors

  DESCRIBE TABLE save_ivake_tab LINES sy-tfill.

  IF sy-tfill <> 0.

    IF ( sichern = ‘X’ ) AND

       ( save_dyngr = ‘SEER’ OR save_dyngr = ‘VARS’ ).

      LOOP AT save_ivake_tab.

        MOVE-CORRESPONDING save_ivake_tab TO time_vake_key.

        READ TABLE ivake WITH KEY time_vake_key BINARY SEARCH.

        IF sy-subrc = 0.

          IF ivake-selkz NE save_ivake_tab-selkz.

            MOVE ivake-selkz TO save_ivake_tab-selkz.

            MODIFY save_ivake_tab.

          ENDIF.

        ENDIF.

      ENDLOOP.

    ENDIF.

    ivake[] = save_ivake_tab[].

  ENDIF.

  ivake_tabix_selkz = 0.

“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””$”$\SE:(2) Form GUELTIGKEIT_PRUEFEN_VERKAUFSAK, End                                                                                                          A

*$*$-Start: (2)———————————————————————————$*$*

ENHANCEMENT 2  Z_MV13AFOG.    “active version

if

*   lv_flag = ‘X’ and

   lv_answer = ‘1’ or lv_answer = ‘2’.

t681-ksdat = lv_ksdat.

ENDIF.

ENDENHANCEMENT.

*$*$-End:   (2)———————————————————————————$*$*

ENDFORM.                    “GUELTIGKEIT_PRUEFEN_VERKAUFSAK

2.  MV13AF0K

*———————————————————————*

*       FORM KONDITION_SICHERN                                        *

*———————————————————————*

*       Aufruf des Programms zur Fortschreibung der Konditionssätze   *

*———————————————————————*

FORM kondition_sichern.

“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””$”$\SE:(1) Form KONDITION_SICHERN, Start                                                                                                                     A

*$*$-Start: (1)———————————————————————————$*$*

ENHANCEMENT 3  Z_MV13AFOG.    “active version

* wylaczenie pop-upa przy drugim przebiegu

  data: lv_popup type flag VALUE ‘X’.

  IMPORT lv_no_popup TO lv_popup FROM MEMORY ID ‘NO_POPUP’.

  EXPORT lv_popup to MEMORY ID sy-uname.

ENDENHANCEMENT.

*$*$-End:   (1)———————————————————————————$*$*

  DATA: bomat_okay        TYPE c,

        einheiten_okay    TYPE c,

        partner_okay      TYPE c,

        waers_okay        TYPE c,

        save_xvake        LIKE xvake,

        l_answer          TYPE c,

        lt_error_messages LIKE arrangerra

                          OCCURS 0 WITH HEADER LINE.

* ZUrücksetzen Returncode

  read_subrc = 0.

* Datumüberlappungsprüfung

  IF t681-ksdat = charx AND

* im Batch-Input nicht erforderlich

     syst-binpt = space AND

* keine Prüfung bei Bonus-Konditionen

     abtyp_general NA abtyp-bonus_all.

* check if agreement number exists for any xvake

    save_xvake = xvake.

    IF abtyp_general NE abtyp-agreement.

      LOOP AT xvake.

*        skonp-tabix = xvake-tabix2.            “note 1358096

        READ TABLE xkonp INDEX xvake-tabix2.

        IF NOT xkonp-knuma_ag IS INITIAL.

          EXIT.

        ENDIF.

      ENDLOOP.

    ENDIF.

* if agreement number exists for any xvake or in sales deal, check

* for overlaps

    IF abtyp_general = abtyp-agreement OR

       NOT xkonp-knuma_ag IS INITIAL.

* Gueltigkeit pruefen für alle Konditionen in Absprache

      PERFORM gueltigkeit_pruefen_verkaufsak

                               USING ‘X’ ‘X’

                               CHANGING  read_subrc.

      IF ivake-knumh NE vake-knumh.

        MOVE-CORRESPONDING vake TO time_vake_key.

        READ TABLE ivake WITH KEY time_vake_key BINARY SEARCH.

      ENDIF.

      IF read_subrc NE 0.

        svake-tabix = ivake-tabix.

        fcode = fcode_gleiche_seite.

        PERFORM fcode_bearbeiten(sapmv130)

                  USING fcode agidv t681s-dynpronr t685-posgr.

        EXIT.

      ENDIF.

    ENDIF.

    xvake = save_xvake.

* Gueltigkeit pruefen bzgl. Budgetierung

    PERFORM budget_date_check

               USING rv13a-datab rv13a-datbi yes

               CHANGING  read_subrc.

    IF read_subrc = 8.

      fcode = fcode_gleiche_seite.

      PERFORM fcode_bearbeiten(sapmv130)

              USING fcode agidv t681s-dynpronr t685-posgr.

      EXIT.

    ENDIF.

* Gueltigkeit pruefen bzgl. Überlappung

    PERFORM gueltigkeitspruefung USING read_subrc.

  ENDIF.

* Nachbearbeitung erforderlich ?

  IF read_subrc = 8.

* auf das Schnellerfassungsbilc

    fcode = fcode_gleiche_seite.

    PERFORM fcode_bearbeiten(sapmv130)

            USING fcode agidv t681s-dynpronr t685-posgr.

  ELSE.

    IF abtyp_general CA abtyp-bonus_all.

      PERFORM bomat_vollstaendig USING bomat_okay.

      IF bomat_okay = no.

        IF used_by_idoc = no.          “WD_IDOC

          MESSAGE i199.

          fcode = fcode_bomat.

        ELSE.                          “WD_IDOC

          returncode = 20.             “WD_IDOC

          fcode = fcode_leave_dialog.  “WD_IDOC

        ENDIF.                         “WD_IDOC

* und wieder einmal in Fcode-Bearbeitung

        PERFORM fcode_bearbeiten(sapmv130)

                USING fcode agidv t681s-dynpronr t685-posgr.

        EXIT.

      ENDIF.

      PERFORM kondper_kmein_vollstaendig USING einheiten_okay.

      IF einheiten_okay = no.

* Kondition lesen

        READ TABLE xkonp INDEX xvake-tabix2.

        konp = xkonp.

         *konp = konp.

        skonp-tabix = xvake-tabix2.

        IF used_by_idoc = no.          “WD_IDOC

          MESSAGE i013(mn).

          fcode = fcode_var_sicht.

        ELSE.                          “WD_IDOC

          returncode = 21.             “WD_IDOC

          fcode = fcode_leave_dialog.  “WD_IDOC

        ENDIF.                         “WD_IDOC

* und wieder einmal in Fcode-Bearbeitung

        PERFORM fcode_bearbeiten(sapmv130)

                USING fcode agidv t681s-dynpronr t685-posgr.

        EXIT.

      ENDIF.

* Staffeln Komplett gepflegt (Auf Bezugsgröße prüfen)

      PERFORM staffel_complet_check USING staffel_einheiten_okay.

      IF staffel_einheiten_okay NE yes.

* Kondition lesen

        READ TABLE xkonp INDEX xvake-tabix2.

        konp = xkonp.

         *konp = konp.

        skonp-tabix = xvake-tabix2.

        IF used_by_idoc = no.          “WD_IDOC

          IF staffel_einheiten_okay = no.

            MESSAGE i010(mn).

          ENDIF.

          fcode = fcode_var_sicht.

        ELSE.                          “WD_IDOC

          returncode = 22.             “WD_IDOC

          fcode = fcode_leave_dialog.  “WD_IDOC

        ENDIF.                         “WD_IDOC

* und wieder einmal in Fcode-Bearbeitung

        PERFORM fcode_bearbeiten(sapmv130)

                USING fcode agidv t681s-dynpronr t685-posgr.

        EXIT.

      ENDIF.

* Absprachepartner gepflegt prüfen

* keine Prüfung bei Idoc Verarbeitung

      IF used_by_idoc = no.            “WD_IDOC

        PERFORM absprachepartner_complete USING partner_okay.

        IF partner_okay = no.

          fcode = fcode_bonus_partner.

* und wieder einmal in Fcode-Bearbeitung

          PERFORM fcode_bearbeiten(sapmv130)

                 USING fcode agidv t681s-dynpronr t685-posgr.

          EXIT.

        ENDIF.

      ENDIF.                           “WD-IDOC

* Absprachewaehrungen prüfen

* keine Prüfung bei Idoc Verarbeitung

      IF used_by_idoc = no.            “WD_IDOC

        PERFORM absprache_waehrung_check USING waers_okay.

        IF waers_okay = no.

          fcode = fcode_gleiche_seite.

* und wieder einmal in Fcode-Bearbeitung

          PERFORM fcode_bearbeiten(sapmv130)

                 USING fcode agidv t681s-dynpronr t685-posgr.

          EXIT.

        ENDIF.

      ENDIF.                           “WD-IDOC

      IF used_by_idoc = no.            “WD_IDOC

* Falls Bonus Einkauf und nicht anzeige

        IF abtyp_general = abtyp-bonus_ein

                         AND t180-aktyp <> aktyp-display.

* Meldungen

* Nachrichtenfindung nötig

          CALL FUNCTION ‘MM_ARR_START_NAFI_BY_ANBED’

            EXPORTING

              i_kappl           = t6b1-kappl_kona

              i_kalsm           = t6b1-kalsm_kona

              i_kona            = kona

            IMPORTING

              e_answer          = l_answer

            TABLES

              t_mmpa            = xmmpa

              t_error_messages  = lt_error_messages

            EXCEPTIONS

              inconsistent_data = 1

              OTHERS            = 2.

* Normales Fehler

          IF sy-subrc <> 0.

* Meldung ausgeben

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

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

          ENDIF.

* Fehlerfall

          IF NOT lt_error_messages[] IS INITIAL.

* Meldung absetzen via FB

            CALL FUNCTION ‘MM_ARRANG_DISP_ARRANG_ERR_MSG’

              TABLES

                error_messages = lt_error_messages[].

          ENDIF.

* Abbrechen aktiv

          IF l_answer = ‘A’.

            fcode = fcode_gleiche_seite.

* und wieder einmal in Fcode-Bearbeitung

            PERFORM fcode_bearbeiten(sapmv130)

                   USING fcode agidv t681s-dynpronr t685-posgr.

            EXIT.

          ENDIF.

        ENDIF.

      ENDIF.                           “WD-IDOC

    ENDIF.

* Check consistency of scale group

    IF abtyp_general = abtyp-bonus.

      DATA: BEGIN OF check_scale OCCURS 0,

              prsch LIKE konp-prsch,

              kzbzg LIKE konp-kzbzg,

              konms LIKE konp-konms,

              konws LIKE konp-konws,

            END OF check_scale.

      CLEAR read_subrc.

      LOOP AT xkonp WHERE NOT prsch IS INITIAL.

        READ TABLE check_scale WITH KEY prsch = xkonp-prsch.

        IF check_scale-prsch EQ xkonp-prsch AND

         ( check_scale-kzbzg NE xkonp-kzbzg  OR

           check_scale-konms NE xkonp-konms  OR

           check_scale-konws NE xkonp-konws ).

          read_subrc = 4.

          EXIT.

        ELSE.

          MOVE-CORRESPONDING xkonp TO check_scale.

          COLLECT check_scale.

        ENDIF.

      ENDLOOP.

      IF NOT read_subrc IS INITIAL.

        MESSAGE i493 WITH check_scale-prsch.

        fcode = fcode_gleiche_seite.

        PERFORM fcode_bearbeiten(sapmv130)

                USING fcode agidv t681s-dynpronr t685-posgr.

        EXIT.

      ENDIF.

    ENDIF.

* Datenbankänderung durchführen

    PERFORM kondition_sichern_db.

* kein Entsperren der Sätze

    dequeue_all = no.

    IF control_flags-no_navigation EQ abap_true.

      EXIT.

    ENDIF.

* Zum Anforderungsbild zurueck

    PERFORM anforderungsbild.

  ENDIF.

ENDFORM.                    “kondition_sichern

To report this post you need to login first.

1 Comment

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

Leave a Reply