Study at NTG
Study at NTG
Maintenance Generator
Business Requirement:
Filtering data in Table Maintenance Generator(TMG) is cumbersome and definitely has
a very limited functionality.
You can also filter the data from the Overview screen, but that too is not very
flexible
Sometimes users might want to have more flexible functionality to select the data from
the view/table viz., a selection-screen to select the data.
For demonstration purpose, i've created a custom maintenance view ZVSFLIGHT for
the
table SFLIGHT.
The TMG is defined for the maintenance view and the callback routine for the Event 'AA'
is
defined.
For the sake of simplicity, I've created a selection-screen with 2 elements: A parameter
for Airline ID & and Select-option for the flight date.
*----------------------------------------------------------------------*
***INCLUDE LZVSFLIGHTF01 .
*----------------------------------------------------------------------*
DATA: gv_fldate TYPE s_date.
*--------------------------------------------------------------------*
* Custom Selection-Screen
*--------------------------------------------------------------------*
SELECTION-SCREEN: BEGIN OF SCREEN 100 TITLE text-s01.
PARAMETERS: p_carrid TYPE s_carr_id.
SELECT-OPTIONS: s_fldate FOR gv_fldate.
SELECTION-SCREEN: END OF SCREEN 100.
*&---------------------------------------------------------------------*
*& Form sub_zvsflight_read_data
*&---------------------------------------------------------------------*
* Read the Flight data
*----------------------------------------------------------------------*
FORM sub_zvsflight_read_data.
* Read the SAP documentation on Event AA: Instead of the Standard Data Read
Routine
*
http://help.sap.com/saphelp_nw04s/helpdata/en/91/ca9f56a9d111d1a5690000e82deaa
a/content.htm
ENDFORM. "SUB_ZVSFLIGHT_READ_DATA
Please note that the data can be loaded into the internal table TOTAL using the subroutines:
You can read the data from the underlying table using Open SQL statements, but i prefer to use
these subroutines.
Voila!
When the user tries to maintain the data using this view, he/she will be presented with a
selection-screen pop-
up.
The data input will be used to filter the data which is displayed in the TMG overview screen.
//////////////////////////////////////////////////////////////////////////////////////////////
INTRODUCTION:
I got the requirement to capture the Created by Created on and
Updated by Updated on logs for the custom table using Table
Maintenance Generator events.
Here is the step by step process to capture the table change logs.
Step 1:
Create a custom table.
Step 2:
Click on utilities, go to table maintenance generator.
Step 3:
Enter the details of the function group, propose screen numbers
and click on save, we will provide the package name.
There are two different maintenance screen types
2. Two step
one step
Two step
----------------------------------------------------------------
------
***INCLUDE LZTEMP_DTLSF01.
----------------------------------------------------------------
------
FORM update.
** -- Data Declarations
DATA: lv_timestamp TYPE tzonref-tstamps.
*-- Time stamp conversion
CALL FUNCTION 'ABI_TIMESTAMP_CONVERT_INTO'
EXPORTING
iv_date = sy-datum
iv_time = sy-uzeit
IMPORTING
ev_timestamp = lv_timestamp
EXCEPTIONS
conversion_error = 1
OTHERS = 2.
FIELD-SYMBOLS: <fs_field> TYPE any .
LOOP AT total.
CHECK <action> EQ aendern.
** -- Updated By
ASSIGN COMPONENT 'UPDTD_BY' OF STRUCTURE <vim_total_struc> TO
<fs_field>.
IF sy-subrc EQ 0.
<fs_field> = sy-uname.
ENDIF.
** -- Updated On
ASSIGN COMPONENT 'UPDTD_ON' OF STRUCTURE <vim_total_struc> TO
<fs_field>.
IF sy-subrc EQ 0.
<fs_field> = lv_timestamp.
ENDIF.
READ TABLE extract WITH KEY <vim_xtotal_key>.
IF sy-subrc EQ 0.
extract = total.
MODIFY extract INDEX sy-tabix.
ENDIF.
IF total IS NOT INITIAL.
MODIFY total.
ENDIF.
ENDLOOP.
ENDFORM.
Once the code is completed then we need check and activate the
include.Here we need to activate the below two objects.
Create Event
Select the Create event and press enter, the following screen will
appear.
Same process we have to go for the Create event.
Source Code
----------------------------------------------------------------
------
***INCLUDE LZTEMP_DTLSF02.
----------------------------------------------------------------
------
FORM create.
** -- Data Declarations
DATA: lv_timestamp TYPE tzonref-tstamps.
*-- Time stamp conversion
CALL FUNCTION 'ABI_TIMESTAMP_CONVERT_INTO'
EXPORTING
iv_date = sy-datum
iv_time = sy-uzeit
IMPORTING
ev_timestamp = lv_timestamp
EXCEPTIONS
conversion_error = 1
OTHERS = 2.
** -- Created On & Created By
ztemp_dtls-crtd_by = sy-uname.
ztemp_dtls-crtd_on = lv_timestamp.
ENDFORM.
Following the above steps, we can see the table create and
update logs for a custom table, which contains the fields "Date
on which record was created" and "Name of the person who
created the object".
////////////////////////////////////////////////////////////////////////////////////////////////
record – infotype record values to be updated, inserted etc (will be structure of infortyoe you are
updating)
recordnumber – sequence nunber from infotype record you are updating
COP = Copy
DEL = Delete
DIS = Display
EDQ = Lock/unlock
INS = Create
LIS9 = Delimit
MOD = Change
“This code is required and locks the record ready for modification
EXPORTING
number = p_pernr.
validitybegin = p_record-begda.
validityend = p_record-endda.
p_record-endda = pn-begda – 1.
EXPORTING
infty = ‘0071’
subtype = p_record-subty
objectid = P_record-objps
validityend = validityend
validitybegin = validitybegin
record = p_record
recordnumber = p_record-SEQNR
operation = change
nocommit = nocommit
dialog_mode = ‘0’
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.
“endloop.
EXPORTING
number = p_pernr.
“This code is required and locks the record ready for modification
EXPORTING
number = p_pernr.
validitybegin = p_record-begda.
validityend = p_record-endda.
p_record-pernr = p_pernr
p_record-begda = pn-begda.
p_record-endda = validityend.
EXPORTING
infty = ‘0071’
subtype = p_record-subty
validityend = validityend
validitybegin = validitybegin
record = p_record
operation = insert
nocommit = nocommit
dialog_mode = ‘0’
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.
EXPORTING
number = p_pernr.
Operatio Description
n
COP Copy
DEL Delete
DIS Display
EDQ Lock/unlock
INS Create
LIS9 Delimit
MOD Change
REPORT ztest_notepad .
DATA:p0015 TYPE p0015.
DATA:RETURN LIKE bapireturn1.
p0015-pernr = '00909089'.
p0015-subty = '1500'.
p0015-endda = '99991231'.
p0015-begda = sy-datum.
p0015-lgart = '1500'.
p0015-betrg = '100.00'.
p0006-pernr = employeenumber.
p0006-subty = subtype.
p0006-infty = '0006'.
p0006-objps = objectid.
p0006-sprps = lockindicator.
p0006-begda = validitybegin.
p0006-endda = validityend.
p0006-seqnr = recordnumber.
p0006-anssa = subtype.
p0006-name2 = coname.
p0006-stras = streetandhouseno.
p0006-ort01 = city.
p0006-ort02 = district.
p0006-pstlz = postalcodecity.
p0006-STATE = STATE.
p0006-land1 = COUNTRY.
p0006-telnr = telephonenumber.
p0006-entkm = distanceinkm.
p0006-entk2 = distanceinkm1.
p0006-wkwng = companyownedapt.
p0006-busrt = busroute.
p0006-com01 = commtype1.
p0006-num01 = commnumber1.
p0006-com02 = commtype2.
p0006-num02 = commnumber2.
p0006-com03 = commtype3.
p0006-num03 = commnumber3.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
1) All wage types are stored in T512W and T512T for Wage Type Texts