MM--关于MM06E005增强的激活Note

You can use the sample source code attached here to recognize the basic functions of the exit. This example is, however, only one of many options that are offered by the customer enhancement.
The sample source code includes the following functions:

  • Supply of an additional field on header level
  • Supply of an additional field on item level
  • Derivation of a field on item level from the copied reference document


Now, in order to be able to use the sample source code, you must create field ZZFLAG on the header level of the document and field ZZFIELD on the item level.
Double-click on Include table CI_EKKODB
Enter the following values:

  •   Name    Component type DType Length DecPlace Short text
  •   ZZFLAG  CHAR1          CHAR  1      0        1-digit indicator


Save and activate the include table.

Double-click on Include table CI_EKPODB
Enter the following values:

  •   Name    Component type DType Length DecPlace Short Text
  •   ZZFIELD CHAR1          CHAR  1      0        1-digit indicator


Save and activate the include table.

In order to activate the sample source code, you additionally have to carry out the following changes on screens 0101 and 0111.

    1. Screen 0101: Create the following fields:

              "Checkbox"            Name: EKKO_CI-ZZFLAG

    2. Screen 0111: Create the following fields:

              "Input/output field"  Name: EKPO_CI-ZZFIELD

              "Pushbutton"          Name: BUTTON

                                    FctCode: ZZDETERMINE


The following assignments apply to the sample source code:
EXIT_SAPMM06E_006  -->  ZXM06F36
EXIT_SAPMM06E_007  -->  ZXM06F38
EXIT_SAPMM06E_008  -->  ZXM06F37
EXIT_SAPMM06E_009  -->  ZXM06F39
EXIT_SAPMM06E_016  -->  ZXM06F41
EXIT_SAPMM06E_017  -->  ZXM06F42
EXIT_SAPMM06E_018  -->  ZXM06F40

Copy the source code from the attachment and insert it into the corresponding function modules. Save and activate the function modules.
Create the following variables in the corresponding TOP include in order not to get any syntax errors:

*
*   INCLUDE ZXM06TOP
*
data: gl_aktyp type c,
      gl_no_screen type c,
      gl_rekko like ekko,
      gl_ekko_ci like ekko_ci,
      gl_ekpo_ci like ekpo_ci,
      gl_ekpo like ekpo,
      gl_ucomm like sy-ucomm.

types: begin of ekpo_tab,
          ebeln like ekpo-ebeln,
          ebelp like ekpo-ebelp,
          ekpo like ekpo,
       end of ekpo_tab.

data:  gt_ref_ekpo_tab type table of ekpo_tab.

Save and activate the TOP include.

On header level, you can now store a character, X or space, via field ZZFLAG on the database with the document and read it also again.
On item level, you can fill field ZZFIELD with a one-digit value and save it with the document. If you copy this document, the system displays an additional function button on tab page "Customer data". If you press this button, the value of the reference document is copied to field ZZFIELD.

If you want to store the source code as sample source code in your system, start Transaction SMOD. Enter MM06E005 as an enhancement. Select "Components". Press "Change". Position the cursor on the corresponding module and choose "Sample code". Create the corresponding include and copy the source code from the note. Save the include. Note that, of course, syntax errors may occur when you check components. This is because the includes of the sample code are not integrated into a program but rather are completely independent and, therefore, do not have any relationship to each other either. For this reason, only save the include and do not activate or check it. The sample code has to be copied into the corresponding function modules in order to become active.
If you use the user exit in the new purchase order, it is not guaranteed that the customer screen is always processed. To make sure that possible required fields are checked, include a corresponding message into the EXIT_SAPMM06E_012. This screen is always processed.

 

相关代码:

*----------------------------------------------------------------------*
*   INCLUDE ZXM06F36                                                   *
*----------------------------------------------------------------------*
*
* store transaction type for later modification of screen attributes
*
gl_aktyp = i_trtyp.
gl_no_screen = i_no_screen.
*
* store current state of customer data in ekko_ci (structure for screen)
*
ekko_ci  = i_ci_ekko.
*
* store reference document
*
if i_rekko-ebeln ne gl_rekko-ebeln and
   not i_rekko-ebeln is initial    and
   gl_rekko-ebeln is initial.
   ekko_ci-zzflag = i_rekko-zzflag.
   gl_rekko = i_rekko.
endif.
*----------------------------------------------------------------------*
*   INCLUDE ZXM06F37                                                   *
*----------------------------------------------------------------------*
*
* e_ci_ekko is the returning parameter
* gl_ekko_ci : values stored at PBO
*
e_ci_ekko        = gl_ekko_ci.
*
* ekko_ci contains the actual values of the Dynpro fields
* e_ci_update is only set if you really want the fields
* on the Dynpro to be saved. You must set it then to 'X'
* the field ekko_ci-zzflag will here only be saved if there
* was a change and the transaction is not in display mode
*
if gl_ekko_ci-zzflag ne ekko_ci-zzflag.
  e_ci_ekko-zzflag = ekko_ci-zzflag.
  if gl_aktyp ne 'A'.
    e_ci_update = 'X'.
  endif.
endif.
*----------------------------------------------------------------------*
*   INCLUDE ZXM06F38                                                   *
*----------------------------------------------------------------------*
*
* store ekko to gl_ekko
*
move-corresponding i_ekko to gl_ekko_ci.
*----------------------------------------------------------------------*
*   INCLUDE LXM06F39                                                   *
*----------------------------------------------------------------------*
clear: ekko_ci,
       ekpo_ci,
       gl_no_screen,
       gl_aktyp,
       gl_ekko_ci,
       gl_rekko,
       gl_ekpo,
       gl_ucomm.
refresh: gt_ref_ekpo_tab.
*----------------------------------------------------------------------*
*   INCLUDE ZXM06F40                                                   *
*----------------------------------------------------------------------*
*
* move stored global values back to the returning structure
*
e_ci_ekpo        = gl_ekpo_ci.
*
* in case the Button was clicked the value of ekpo_ci-zzfield
* will be taken from the copied PO
*
if i_ucomm = 'ZZDETERMINE'.
  data: ls_ref_ekpo like line of gt_ref_ekpo_tab.
*
* gt_ref_ekpo_tab contains all positions of the copied PO
*
  read table gt_ref_ekpo_tab into ls_ref_ekpo
      with key ebelp = gl_ekpo-ebelp.
  if sy-subrc is initial.
    ekpo_ci-zzfield = ls_ref_ekpo-ekpo-zzfield.
  endif.
else.
*
* return the function code of the Screen. This code will be handled
* in the SAP program. It can only be handled if you use SAP function
* codes
*
  e_ucomm = i_ucomm.
endif.
*
* ekko_ci contains the actual values of the Dynpro fields
* e_ci_update is only set if you really want the fields
* on the Dynpro to be saved. You must set it then to 'X'
* the field ekko_ci-zzfield will here only be saved if there
* was a change and the transaction is not in display mode
*
if gl_ekpo_ci-zzfield ne ekpo_ci-zzfield.
  e_ci_ekpo-zzfield = ekpo_ci-zzfield.
  if gl_aktyp ne 'A'.
    e_ci_update = 'X'.
  endif.
endif.
*----------------------------------------------------------------------*
*   INCLUDE ZXM06F41                                                   *
*----------------------------------------------------------------------*

data: ls_ref_ekpo like line of gt_ref_ekpo_tab.

*
* store transaction type for later modification of screen attributes
*
gl_aktyp = i_aktyp.

gl_no_screen = i_no_screen.


*
* store current state of customer data in ekko_ci (structure for screen)
*
ekpo_ci  = i_ci_ekpo.

gl_ekpo = i_ekpo.

if not i_rekpo-ebeln is initial and
   not i_ekpo-ebelp is initial.

  clear ls_ref_ekpo.

  read table gt_ref_ekpo_tab into ls_ref_ekpo
      with key ebelp = i_ekpo-ebelp.

  if ls_ref_ekpo-ekpo-ebeln ne i_rekpo-ebeln and
     ls_ref_ekpo-ekpo-ebelp ne i_rekpo-ebelp.

     ls_ref_ekpo-ebelp = i_ekpo-ebelp.
     ls_ref_ekpo-ekpo = i_rekpo.

     if sy-subrc is initial.
       modify gt_ref_ekpo_tab from ls_ref_ekpo index sy-tabix.
     else.
       append ls_ref_ekpo to gt_ref_ekpo_tab.
     endif.

  endif.

endif.
*----------------------------------------------------------------------*
*   INCLUDE ZXM06F42                                                   *
*----------------------------------------------------------------------*

move-corresponding i_ekpo to gl_ekpo_ci.
gl_ekpo = i_ekpo.

note number:407975

你可能感兴趣的:(function,include,reference,attributes,returning,structure)