Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Table maintenance event 01 Before Saving the Data in the Database

Clemenss
Active Contributor
0 Kudos

Hi,

Please don't post any answer if you did not do exactly this. I can't waste my time with recomendations for beginners. TNX.

According to SAP docu, event 01 of table maintenance generator is provided to take special action before saving new, changed or deleted entries to the database.

My maintenance dialog worked fine for a year. Starting last week, it creates a dump. The dump tells me that the field-symbol TOTAL has not been assigned. Actually SAP docu tells me to use internal table TOTAL.

Please: If and only if you know what exactly is wrong, answer here.

Too bad we can't reward negative points for useless answers.

Hope it gets better, TiA,

Clemens

4 REPLIES 4

Former Member

Hi,

Too bad we can't reduce points for rudeness.

Regards, Joerg

andreas_mann3
Active Contributor
0 Kudos

Hi Clemens,

why does nobody answer your question ?

i've no solution - but some hints

so you must decide ,if you waste your time !

1) search for <total> in your program (SAPLZ...)

- there're only 6 occurrences and 2 with assign - command

2) set break-points to this coding-lines and debug

What you've changed / modified at event 01

When did the dump occurs ?

-by saving

-by new entries

regards and blessed weekend to all abaplers

<a href="https://www.sdn.sap.com:443/irj/servlet/prt/porta

l/prtroot/com.sap.sdn.businesscard.SDNBusinessCard?u=i

Wo3ssHlIihvCrADIEGqaw%3D%3D">Andreas</a>

0 Kudos

just to let you know about the solution:

In the past the tables TOTAL and EXTRACT where composed of the table/view structure itself and an

INCLUDE STRUCTURE VIMTBFLAGS

This is actual Documentation what is actually wrong.

But, be aware:

SAP now uses a structure called VIMFLAGTAB with less one field and slightly different field names.

... I could solve the problem working on the clients system over VPN. During VPN connection I don't have internet acccess so that I was not disturbed

Sorry for my rude posting before but things get worse here from day to day. Hope the end is mot ahead!

And please note: If I don't ask for hints I don't want any.

Clemens

Former Member
0 Kudos

Clemens,

Are you sure that the sturture of the table wasn't changed? I had problems with 'TOTAL' in the past for a very small table where SAP was using TOTAL_S instead of TOTAL.

Anyway, in BEFORE_SAVE event, I don't use TOTAL. I use <table/view_name>_TOTAL internal table which is declared in L<F.grp>_MTT00 include. I am my pasting my code from event 01. It is working fine. The ZMMVBASELINE is my maintenance view. I hope it will help you.

FORM BEFORE_SAVE.
  data : begin of l_err_ret,
         INFNR like eine-infnr,
         EKORG like eine-ekorg,
         ESOKZ like eine-esokz,
         WERKS like eine-werks,
         msgtxt(132),
         end of l_err_ret.
  data : t_err_ret like standard table of l_err_ret with header line.

  data : l_lifnr like lfa1-lifnr,
         l_subrc like sy-subrc.

  data : l_text1 type string,
         l_text2 type string.

  DATA : L_TMP_BL LIKE VZMMTBASELINE.
*--------Clear both X table
  clear  :  I_XZMMBASELINE.
  refresh : I_XZMMBASELINE.

  clear : i_yzmmbaseline.
  refresh : i_yzmmbaseline.


*-----Check the combo of vendor and catalog
  Loop at zmmvbaseline_total where action = 'N'.
    if zmmvbaseline_total-lifnr is initial or
       zmmvbaseline_total-katalogid is initial.
      l_subrc = 4.
      exit.
    endif.

    l_lifnr = zmmvbaseline_total-lifnr.
    shift l_lifnr left deleting leading '0'.
    shift l_lifnr left deleting leading  space.

    select single fieldvalue into  l_lifnr
                  from IOCI_FCONV
                  where KATALOG  =  zmmvbaseline_total-KATALOGID
                  and   fieldname = 'RIHFCOM_XL-FLIEF'
                  and   fieldvalue = l_lifnr
                  and   valuetyp = '2'.
    if sy-subrc <> 0.
      l_subrc = '5'.
      exit.
    endif.
  Endloop.

  if l_subrc = '4'.
    sy-subrc = 4.
    message S398(00) with text-006.
    exit.
  endif.

  if l_subrc = '5'.
    concatenate text-007 zmmvbaseline_total-KATALOGID
                       into l_text1 separated by space.

    concatenate text-008  l_lifnr
                         into l_text2 separated by space.
    message S398(00) with  l_text1 l_text2 text-009 space.
    sy-subrc = '4'.
    exit.
  endif.


*-----Read the database to get the before save snapshot of the entries
*-----which are being processed
  if not zmmvbaseline_total[] is initial.
    select *  into corresponding fields of table i_xzmmbaseline
              from zmmtbaseline
              for all entries in zmmvbaseline_total
              where KATALOGID  = zmmvbaseline_total-KATALOGID
              and   LIFNR      = zmmvbaseline_total-LIFNR
              and   IDNLF      = zmmvbaseline_total-IDNLF.
  endif.

*--------Prepare the Y table
  Loop at zmmvbaseline_total.
    clear i_yzmmbaseline.
    move-corresponding zmmvbaseline_total to i_yzmmbaseline.
    i_yzmmbaseline-kz = zmmvbaseline_total-action.
    append i_yzmmbaseline.

    if zmmvbaseline_total-action = 'N' or
       zmmvbaseline_total-action = 'U'.

      clear t_err_ret.
      refresh t_err_ret.

      CALL FUNCTION 'Z_MM_UPDATE_PURINFO'
           EXPORTING
                LIFNR                = i_yzmmbaseline-lifnr
                IDNLF                = i_yzmmbaseline-idnlf
                NETPR                = i_yzmmbaseline-netpr
                WAERS                = i_yzmmbaseline-WAERS
                PEINH                = '1'
                BPRME                = i_yzmmbaseline-peinh
                TESTMODE             = 'X'
           TABLES
                T_RETURN             = t_err_ret
           EXCEPTIONS
                VENDOR_INVALID       = 1
                NO_PUR_INFO_REC      = 2
                CURRENCY_INVALID     = 3
                PRICING_UNIT_INVALID = 4
                OTHERS               = 5.
      if sy-subrc <> 2.
        IF SY-SUBRC <> 0 or not t_err_ret[] is initial.
          read table t_err_ret index 1.
         message S398(00) with text-003 t_err_ret-INFNR t_err_ret-ekorg
                                                    t_err_ret-werks.
          leave screen.
        ENDIF.
      ELSEIF SY-SUBRC = 0 OR SY-SUBRC = '2'.
*-----ADJUST THE  EXISTING RECORD---------------*
        CLEAR L_TMP_BL.
        MOVE-CORRESPONDING zmmvbaseline_totaL TO L_TMP_BL.
        PERFORM ADJUST_EXISTING_RECORDS
                    USING  L_TMP_BL.

*-------------------------------------------------*
      ENDIF.
    ENDIF.
  endloop.

  sy-subrc = 0.
endform.