• No results found

Enhancements

N/A
N/A
Protected

Academic year: 2021

Share "Enhancements"

Copied!
187
0
0

Loading.... (view fulltext now)

Full text

(1)

Enhancement Framework

Validating the Document Types in MIRO and MIR7 While Posting the

Entry

Scenario:

By using Transaction code MIRO & MIR7 user can change the document type and post the entry. In order to prevent the user from using different document types apart from “RE” and “AN” an enhancement need to be developed to hard stop the transaction.

By this, system should show an error message as below if the user uses other document types apart from RE and AN.

Error Message:

Document Type “Entered by User (E.g. SA, KZ, and etc)” is not allowed for this transaction.

Step by step Solution: Step 1:

Find the enhancement point in the include ‘LFDCBFC0’.

a) To find the enhancement point, go to Program àààà Enhance (Or)

(2)

b) Go to Editàààà Enhancement Operations àààà Show Implicit Enhancement Options.

Step 2:

Now, we will observe commas like below.

(3)

Go to Implicit enhancement option at the beginning of the form ‘CHECK_DOCUMENT_TYPE’ andRight

click àààà Enhancement Implementation àààà Create.

Step 4:

Now it will ask for Enhancement Type.

Step 5:

(4)

Here you can write the custom code for modifying the functionality.

DATA : lv_message TYPE string . IF sy-tcode EQ 'MIRO' or

sy-tcode EQ 'MIR7'. IF bkpf-blart NE 'RE' AND bkpf-blart NE 'AN'.

CONCATENATE 'Document "' bkpf-blart '" is not allowed for this Transaction' INTO lv_message . MESSAGE lv_message TYPE 'E' .

ENDIF. ENDIF.

Activate the code and enhancement. Step 7:

Check in MIRO and MIR7 by selecting the Document Types other than RE and AN, it will throw an error message.

(5)

Scenario on the combination of Transaction variant and

enhancement framework

Requirement: Requirement is to create a custom transaction of MEK2 to hide some personal data

related to vendor and Material (i.e. descriptions) and to restrict the further drill down’s from the menu.

This can be done by the combination of implicit enhancement technique and transaction variant. Following are the screenshots that describe step by step procedure of the requirement.

Solution:

First we will restrict the further drilldowns from the menu bar by Transaction variant. Create a transaction variant for MEK2.

Go to the Transaction SHD0.

Give the transaction code and the transaction variant name and click on create button.

(6)

Then it will lead you to the MEK2 ( Change condition records transaction).

Give the condition type PB00 Gross Price and click on the Key combination and select the 4th radio button and click continue.

Then the following screen appears. Give Name and short text to the screen variant.

Click on continue button.

In the next screen, give the proper input values with the help of search help and click on enter.

Note: The descriptions which are needed to be hidden will be taken care by implicit enhancement

technique.

As of know we are working to restrict the further drill downs to other TCodes via menu bar by transaction variant.

(7)

After clicking on execute button, Press enter.

Then following screen appears. Then click on the menu functions button.

After clicking on the menu functions button, expand the menu bar in the tree and select the menu functions and press on deactivate button on the bottom and press on continue button.

(8)

Note: Here the customer wants to restrict the drilldowns to MM03, XD03 and so on... Now click on exit and save button.

Finally enter description and save the variant.

Now go back and create a transaction code for the created transaction variant. Click on Goto-> Create variant transaction

(9)

Give the name and short text and press continue.

(10)

Finally we deactivated the menu functions to restrict the further drilldowns through transaction variant. Now we will work on implicit enhancement technique to hide the descriptions of material and vendor. This scenario would work from ECC6.0 onwards.

In Enhancement Framework, we can add our own Code at particular points.

Note: While debugging the standard SAP program, we have to decide at which place we would need to

write our own code. There we need to check whether enhancement can be implemented.

So while debugging the standard program of MEK2 i.e (SAPMV13A), it is found that code need to be written in this include MV13AKOM.

Click on display,

By debugging we will come to know that the code should be written in the form FILL_DEFAULT. So now click on the enhance button.

(11)

The following screen appears after clicking the option Show implicit enhancement options

“““Indicates that we can write the code here.

Now right click on the line below and create the enhancement implementation.

(12)

Now choose Code

The following screen appears. Now click on Create implementation button at the bottom.

After clicking on the create button, Give the name and the description of the enhancement and click on continue.

(13)

Now the created implementation appears in the below list. Select the enhancement and click on continue.

Now place the desired code in the Enhancement and End Enhancement section shown below.

(14)

Code:

DATA: LV_STCODE TYPE SHDTV-TCODE.

CALL 'DY_GET_CURRENT_TRANSACTION' “GET THE TCODE FOR TRANSACTION VARIANT ID 'TRANSACTION_NAME' FIELD LV_STCODE. IF LV_STCODE = 'ZMEK2’. CASE FD_FIELD. WHEN ‘LIFNR’. CLEAR ‘LFA1-NAME1’. WHEN ‘MATNR’. CLEAR ‘MAAPV-ARKTX’. WHEN ‘EKORG’. CLEAR ‘T024E-EKOTX’. ENDCASE. ENDIF. Output:

Now when you execute ZMEK2,

The descriptions of vendor, material and purchase organization are hidden by implicit enhancement technique.

(15)

Picking material description from custom table in the SAP Sales

Order (VA01 and VA02) using enhancement framework

This scenario would work from ECC6.0 onwards.

In Enhancement Framework, we can add our own Code at particular points.

While debugging the standard SAP program, we have to decide at which place we would need to write our own code. There we need to check whether enhancement can be implemented.

Requirement: In Sales Order (VA01 & VA02), we have to pick the Material Description from Custom

(16)
(17)

While debugging it is found that the code needs to be written in

theFORM USEREXIT_MOVE_FIELD_TO_VBAP. Now click on Enhance button as shown below.

(18)

It shows the screen as below :

(19)

Then it shows the Screen as below:

""" indicates we can write our code here.

(20)
(21)

Select Code.

(22)

In the above screen, click on Create Composite Implementation and the following Screen appears.

Then click on Continue button (Green tick).

In the below Screen, Select the Enhancement Implementation which we have created now and click on Continue button.

(23)

(24)

Code:

ENHANCEMENT 315 ZSD_EI_BOQDESC. "active version * Modification Done By : Sajid Shaik.

* Date : 08.06.2009

* Requirement Given by : Avinash Gyale

* Requirement : Material Description should be fetched from BOQ based on the Plant and Boq Typ e 'Erection or Civil'.

* : This should work only for Order type ZCO1 - Civil & Order type ZER1 - Erection DATA : VAR_ARKTX TYPE VBAP-ARKTX,

VAR_MAKTX TYPE ZBOQ_ITEM-MAKTX, VAR_TENDERID TYPE ZBOQ_ITEM-TENDERID, VAR_LENGTH TYPE INT4.

IF ( SY-TCODE EQ 'VA01' OR SY-TCODE EQ 'VA02' ) AND ( AUART EQ 'ZCO1' OR VBAK-AUART EQ 'ZER1' ) AND VBAP-WERKS IS NOT INITIAL.

CLEAR : VAR_ARKTX,VAR_MAKTX,VAR_TENDERID . IF VBAK-AUART EQ 'ZCO1'.

(25)

BAP-WERKS AND TYPE EQ '3'. IF SY-SUBRC NE 0.

ENDIF.

ELSEIF VBAK-AUART EQ 'ZER1'.

SELECT SINGLE TENDERID FROM ZBOQ_HEADER INTO VAR_TENDERID WHERE WERKS EQ V BAP-WERKS AND TYPE EQ '2'.

IF SY-SUBRC NE 0. ENDIF.

ENDIF.

SELECT SINGLE MAKTX FROM ZBOQ_ITEM INTO VAR_MAKTX WHERE TENDERID EQ VAR_TEN DERID.

IF SY-SUBRC NE 0. ENDIF.

VAR_LENGTH = STRLEN( VAR_MAKTX ). IF VAR_LENGTH LE 40.

VAR_ARKTX = VAR_MAKTX(VAR_LENGTH). ELSE.

VAR_ARKTX = VAR_MAKTX(40). ENDIF.

IF VAR_ARKTX IS NOT INITIAL. VBAP-ARKTX = VAR_ARKTX. ENDIF.

ENDIF.

ENDENHANCEMENT. Then Save and Activate it. OUTPUT :

(26)
(27)

Setting the screen elements as mandatory in the transaction DP95

using Enhancement Framework

Scenario:

In this scenario, we would set the fields ‘Sales’ and ‘Order’ as Mandatory in the transaction DP95. Following are the technical attributes of these fields (go to technical details by clicking on F1 on the fields) Screen field names – so_vbeln-low(Sales) and so_aufnr-low (Order).

(28)

Go to system à status

Double click on Program RVPKMASS.

(29)

Click on “Spiral Button” or ProgramàEnhance

Click on “Spiral Button” or ProgramàEnhance

(30)

Edit à enhancement operationsàShow implicit enhancement

(31)

Place the cursor on the enhancement point and create the enhancement is as shown below screen. Enhancement implementationàcreate

(32)

Create the New Enhancement is as shown in below

screen.

Select the appropriate enhancement and click on continue.

Place the below code in the enhancement spot.

(33)

At selection-screen output. Loop at screen. If screen-name = 'so_vbeln-low'. Screen-required = '1'. Modify screen. Endif. If screen-name = 'so_aufnr-low'. Screen-required = '1'. Modify screen. Endif. Endloop.

(34)

Click on Save, Check and Activate.

OUTPUT:-Demo on Enhancement Framework

Restrict users (sales persons) to view or change Sales order data - Using Enhancement framework:

Source Code Enhancement is one of the enhancement technologies available under Enhancement Framework. Implementing this technology is also called as Source Code Plug-In. Technically the source code plug-in implementations are stored in a separate include program and not as part of the original source program.

There are two types of Source Code enhancements possible. • Implicit enhancement option

• Explicit enhancement option Example Scenario:

One sales person can’t see or change another sales person’s sales orders. In my program, I have used following users.

(35)

Sales person1 (user 1): lz8xzf Owner for Sales order no: 174. Sales person2 (user 2): lzn4rm

Steps to Implement the Implicit enhancement option: Step1: Go to SE38 and Open include MV45AFZB

Step2: In order to implement any of these Source code enhancements, you need to be in ‘change Enhancement mode’ (the spiral icon available in the editor).

Step3: Go to EDIT option in the menu and choose Enhancement Operations -> Show implicit Enhancement Options

(36)

All Implicit Enhancement option will be displayed. All yellow lines indicate Implicit Enhancement options. In ABAP programs, implicit enhancement options are predefined at the following places:

Begin/End of an include.

Begin/End of Method/Function Module/Form Routine

End of a structure

End of Private/Protected/Public Section of a local class

Step4: Place the cursor on the yellow line and choose

(37)

Enhancement implementation à Create.

Step5: Give Implementation name and then create.

(38)

Step 7: Once the development is completed you can test the scenario.

When Sales person (lzn4rm) tries to Open Sales order no 174, it gives error message ’Access Denied’.

(39)

Restrict the modification of Delivery item texts - Using Implicit

enhancement technique

1. Go to transaction code - VL02N + press enter

2 .Goto->Item->texts

Now you can see the item texts in editable mode

(40)

Note:

To make it non editable you need to enhance the code .

First you need to debug the application and find the exact place where you need to add the functionality You must be knowing that each and every subroutine and method (not modules )will be having implicit enhancement options at the beginning and at the end .

In this particular case we have to enhance the subroutine PERFORM TEXT_CONTROL_EINGABEBEREIT. 3. Go to this subroutine and then Program –> Enhance

(41)

4 .Then follow Edit ->Enhancement Operations -> Show implicit enhancement Options

(42)

6 . Go to implicit enhancement option at the end of the form and do right click -> Enhancement Implementation -> Create

7 .Now it will ask for Enhancement type

We have to implement code and it will look like this

(43)

Here you can write the custom code for modifying the functionality 8. Include name LV70TFT3

ENHANCEMENT 4 ZTEXT_MODIF_BLOCK. "active version call method gv_text_editor->set_readonly_mode

exporting readonly_mode = gv_text_editor->true exceptions error_cntl_call_method = 1 invalid_parameter = 2 others = 3. ENDENHANCEMENT.

(44)

User Exits/Screen Exits/Menu Exits

Adding custom tab to the transaction VF01/VF02/VF03 item detail

screen

(45)

Custom Tab to be added in the item detail

SAP has provided a custom tab in the tab strip (Program name – SAPMV60A) screen 6002 which is having the function code ‘PFCU’.

In order to fulfill the requirement we need a custom subscreen with some custom fields in that screen.

(46)

1. Creating the Custom fields

a) Create the Z fields to the table VBRP, by appending the structure.

(47)

Note: the added fields should follow the naming convention that they should start with ‘ZZxxxxx’.

c) Save and activate.

2. Creating the screen and adding the Z fields

(48)

b) Get the field from the dictionary which needs to be added to the screen.

(49)

c) Save and activate the screen.

(50)

In the ‘MODULE PBO_6002’ the subroutine PBO_6002_TABSTRIP_POS specifies the position of the tab.

In order to activate the custom tab for this requirement which is having the function code ‘PFCU’, the module CUST_ITEM_ACTIVATE needs to be implemented.

(51)

To make use of this logic use enhancement frame work. We have enhancement spots at the begin/end of the subroutine.

4. Steps to write the code in the enhancement spots.

a. First to find the enhancement spots click on the spiral icon in the menu bar, and next click on the edit àààà enhancement operations -ààà show implicit enhancement options. à

(52)

Start of the enhancement spot

End of the enhancement spot

(53)

Click on the create enhancement implementation

(54)

Click enter and save in a package.

Select your implementation and then continue.

In between the ENHANCEMENT and ENDENHANCEMENT statements Insert the below code.

Insert your code as below.

(55)

Activate the enhancement and check in the vf01/vf02/vf03 you can find the custom tab with the custom

fields.

The Data automatically populates to the database table when the data is entered into the Z fields. But where as in display mode it is changeable for it to be made disable, a simple code is to be added.

The screen in VF03 before which is in changeable

(56)

After adding the code the screen is as follows in VF03 transaction.

Automatically filling the field "payment terms" and disable the same

while creating PO using the transaction ME22N

The requirement is to capture contract number wise payment terms while creating PO. This contract number is maintained in Z-Table along with vendor and payment terms etc. When we select the contract number the corresponding payment terms should automatically reflect in payment terms irrespective of the original value and make that field display mode immediately.

To add the contract number in the standard PO , we have to enhance the screen using the exit ‘MM06E005’.

(57)

Click on Create button and provide the meaningful description in the following screen.

(58)

Step3: Now click on ‘Component’ button and activate the project.

Double click on screen ‘0101’. Then it opens screen painter to add the contract number.

(59)

Select the contract number field from the table EKKO (Add the field contract number to the structure ‘CI_EKKODB’).

Save and activate.

Step4: Go back to ‘Flow logic’ and write the following code in POV (Process on Value-Request) to get the

F4 help.

(60)
(61)

TABLES ekko.

DATA: fs_return TYPE ddshretval,

it_return LIKE TABLE OF fs_return. DATA: BEGIN OF fs_value,

vendorno TYPE lifnr,

contractno TYPE bbp_er_ctr_no, cstart TYPE vbdat_veda, cend TYPE vndat_veda, pterm TYPE dzterm, END OF fs_value,

it_value LIKE TABLE OF fs_value. DATA: w_lifnr TYPE lifnr.

FIELD-SYMBOLS : <fs_ekko> TYPE ekko. ASSIGN ('(SAPLMEPO)EKKO') TO <fs_ekko>. IF sy-subrc EQ 0.

MOVE <fs_ekko>-lifnr TO w_lifnr. ENDIF. SELECT vendorno contractno con_start_dt con_end_dt payment_terms FROM zcontract

(62)

INTO TABLE it_value

WHERE vendorno EQ w_lifnr.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'CONTRACTNO' * DYNPPROG = ' ' * DYNPNR = ' ' * DYNPROFIELD = ' ' value_org = 'S' * IMPORTING * USER_RESET = TABLES value_tab = it_value return_tab = it_return EXCEPTIONS parameter_error = 1 no_values_found = 2 OTHERS = 3 . IF sy-subrc EQ 0.

READ TABLE it_return INTO fs_return INDEX 1. IF sy-subrc EQ 0.

ASSIGN ('(SAPLMEPO)EKKO') TO <fs_ekko>. MOVE :fs_return-fieldval TO ekko-contractno, ekko-contractno TO <fs_ekko>-contractno.

READ TABLE it_value INTO fs_value WITH KEY contractno = ekko-contractno.

IF sy-subrc EQ 0. IF sy-subrc EQ 0.

MOVE fs_value-pterm TO <fs_ekko>-zterm. ENDIF.

ENDIF. ENDIF. ENDIF.

Step5: Save and activate include.

When you execute the ME22N,

When we select the contract number ‘9001’, the automatically the payment term field is filled with ‘0001’ as shown.

(63)

Now it is in enable mode. We have to make it to display mode.

We can achieve this by enhance the method FS_GET in the method PBO of the classCL_BASIC_MODEL_VIEW_MM (Write the enhancement spot in the method FS_GET).

Step6: Now create the enhancement spot in the method ‘FS_GET’ and write the following code as

shown.

FIELD-SYMBOLS: <fs_ekko> TYPE ekko,

(64)

ASSIGN ('(SAPLMEPO)EKKO') TO <fs_ekko>. IF sy-subrc EQ 0.

IF <fs_ekko>-bsart EQ 'NB' AND <fs_ekko>-contractno NE space.

READ TABLE my_fieldselection assigning <fs_fieldselection> WITH KEY metafield = '11'. IF sy-subrc EQ 0.

<fs_fieldselection>-fieldstatus = '*'. ENDIF.

ENDIF. ENDIF.

Step7: Now execute the transaction ME22N,

After selecting the contract number, the payment term field would be disabled.

Adding custom fields to the Purchase Order transaction ME22N

STEPS:

Enhancement used: MM06E005

(65)

2.Give the enhance name as MM06E005 and save.

Click on components button the following screen is displayed.

(66)

3.Create the required custom fields using the includes CI_EKKODB and CI_EKPODB

The above 5 fields are added.

(67)

Code in PBO

5.The following two function Exits are used for adding custom fields at item level: EXIT_SAPMM06E_016 (Export Data to Customer Sub screen for PO)

EXIT_SAPMM06E_018 (Import Data from Customer Sub screen for PO) Click on the Function Module: EXIT_SAPMM06E_016

(68)

Double click on the include and write the following code

(69)

The following is the code for the function module EXIT_SAPMM06E_018

(70)

Enter some data in the custom fields and save.

7.Go to EKPO table and check the data.

Adding a field to "Sales Org View2" of MM01/MM02 (No screen

exit/BaDI available)

Requirement: In standard transaction Material Management (MM01/MM02), a custom field is to be

added in the sales org view2 tab. There is no screen exit or BADI's available. We achieve this through configuration.

Step1: Go to transaction SPRO and click on Create Program for Customized Sub screens as shown

(71)

Step2: Click on execute button, the following screen appears and provide the function group ZMGD1.

Click on save button.

Step3: Now go to SE80 and select FUNCTION GROUP and give the created function group ZMGD1 as

shown.

These TWO screens (0001, 0002) are default screens.

Step4: Now we have to identify the screen no where we need to add custom field. In this case, we

consider sales org view2 and screen no 2157. Now select standard function group MGD1 of the transaction MM01. It contains all screens and sub screens of Material Management Transaction.

(72)

Step5: Now right click on the screen no and copy the screen no to our function group ZMGD1 as show.

We will get the following screen.

(73)

Click on Ok button. We will get the following status message ' Screen SAPLZMGD1 2157 created'

Step6: Now if we check the function group ZMGD1, screen no 2157 copied to our function group as

shown.

Step7: Now add the field WBS Element in the table standard table MVKE as shown.

(74)

Step9: Get the WBS Element from the table MVKE.

Activate the screen.

In flow logic, add the following code in PAI.

Activate the screen.

Step10: Again go to SPRO, click on Define Structure of Data Screens for Each Screen Sequence as

(75)

Click on execute button. The following screen appears. Select the screen sequence no 21

Click on Data screen.

Now select the sale org view2 as shown.

(76)

Provide the name SAPLZMGD1 and save it.

(77)

Step12: When checked at table MVKE,

Printing Attachments Of Work Order Via IW32

Scenario:

• Business requirement is to display all the attachments related to work order and print the selected attachments via tcode IW32.

• This can be done manually from IW32, but it requires lot of efforts as each time required attachment needs to be opened and printed. So, it’s a time consuming procedure.

• So, in this tutorial we demonstrate how we can achieve this using custom functionality using Enhancement.

(78)

1. Go to IW32 and open the work

order.

2. Select ‘services for

object’.

3. Select attachment list, it will display the attachments for the work

(79)

4. In current scenario, for printing the attachments, user have to follow the above procedure, open the document and then print it. Every time, user must to open the document manually and then print it. 5. So, the procedure becomes time consuming and also involves lots of efforts.

6. In order to achieve this functionality, I have used Enhancement IW010018 to display all the attachments related to work order and we can print as all the attachments at the same time.

7. Below I have demonstrated this functionality.

Enhancement IW010018:

(80)

Data declaration for the exits:

We are using function pool ‘SAPLXWOC’ to create the custom Subscreen and to write logic for populating the table control and printing the attachments.

Include ‘ZXWOCTOP’ must be used for data declaration.

The internal tables being used in the function exit as well as in the screen exit must be declared in this

(81)

Include ‘ZXWOCZZZ’ must be used to write any logic in the PBO and PAI of the screen.

Coding for Function exit:

We need to start with the function exit ‘EXIT_SAPLCOIH_018’.

1. Double click on include ‘ZXWOCU15’ and create it.

2. Create a function module and call it in this include.

ØWe have CAUFVD structure available in this Function exit. Based on the work order number (CAUFVD-AUFNR), Equipment number (CAUFVD-EQUNR), functional location (CAUFVD-TPLNR), task lists (CAUFVD-PLNTY, CAUFVD-PLNNR, CAUFVD-PLNAL) we can fetch the related attachment names. ØFor that we need to use 2 tables, ‘SRGBTBREL’ and ‘SOOD’.

(82)

ØTable SRGBTBREL will fetch the unique identification number for each attachment (INSTID_B). Using this number, we can fetch attachment name and its details.

ØBelow is the screenshot of the data fetching from these 2 tables. Internal table I_OBJECTS, will be populated with the attachment details. We can take the desired fields from the internal table into new internal table I_WORK and pass it to screen exit.

So, I_WORK will be populated with the details of the attachments of the work order.

(83)

1. Create a screen ‘0900’ in program ‘SAPLXWOC’, which is called in the program

‘SAPLCOIH’.

Create it as a subscreen type.

(84)

Create a pushbutton to print the selected attachments. Function code for pushbutton should be ‘ENT1’. No other function code works for the pushbutton in the enhancement tab.

3. Now, go to flow logic tab and in PBO of the screen, write a logic to to fill the table cotrol. We will use the internal table (I_WORK) populated in the function exit.

(85)

In tcode IW32, when we goto enhancement tab, the list of attachment present for that order will be displayed. Then, user can select the attachments to be printed and press ‘Print’ button.

So, we need to check the selected entries and print them, this logic will be written in PAI of the screen.

4. Below is the screenshot of the coding for PAI, Module STATUS_0900. It will fetch the selected attachments.

(86)

5. MODULE F_USER_COMMAND_0900_AFTER_LOOP witll check the sy-ucomm and print the attachments.

For printing the attahcments, we need to read the contents of the attachment using FM‘SO_DOCUMENT_READ_API1' into internal table.

We need to pass the unique identification number for the attachment (I_WORK-INSTID_B) to the FM and fetch the contents of the attachment into internal table ‘I_TAB_OBJCONTX’.

6. We are using class ‘CL_GUI_FRONTEND_SERVICES’ to get the attachment path and to print

(87)

So , we need to call METHOD ‘CL_GUI_FRONTEND_SERVICES=>GET_SAPGUI_WORKDIR’ to fetch the path/name of the attachment.

If attachment is of URL type, then this FM will give us the full path of the attachment else if attachment is of external type, then name of the attachment will be fetched.

After that we need to download it on the local system using FM ‘GUI_DOWNLOAD’.

Then print the attachment using method ‘CL_GUI_FRONTEND_SERVICES=>EXECUTE’ with

document path and ‘Print’ command.

The selected attachments will be printed.

Demo of printing attachments via IW32:

Now, let’s see how enhancement tab displays the attachment details. 1. Go to IW32. Open work order having attachments.

(88)

2. Go to enhancement tab, it will display attachment list.

3. Select the attachment and press ‘Print’

(89)

4. It will display message at the bottom after download is completed.

5. Once downloading of the attachment is done, attachment is opened for printing and once printed it is closed.

6. So, the required attachments are printed.

Adding Fields to CJI3 Report

Target Readers: SAP ABAP developers with basic knowledge of Customer Exits and Basic ABAP

syntaxes.

Purpose of the document: To add Vendor No and Vendor Name in report CJI3.

In CJI3 Vendor name will come for only invoices, when offsetting account type(GKONT) is K, but for GRN documents system will not show the vendor no, so to get this we need to add two fields Vendor No(LIFNR) and Name(NAME1) in CJI3 report where report should give Vendor details for GRN documents also.

Enhancement Process:

1. Add fields to structure “RKPOS” using field exit“CI_RKPOS” using Customer exit “COOMEP01”.

2. Add fields to the view “V_TKALV”, so that these fields should get added to the field catalog of CJI3 report.

(90)

3. Add required code in the exit “EXIT_SAPLKAEP_001”

Step 1.

Goto CMOD and Create a Project.

Goto Enhancement Assignment and add “COOMEP01” and double click on include “CI_RKPOS”. Add customer required fields as shown below:

(91)
(92)

Step 2:

Now we need to add the above fields in the field catalog of CJI3 .

For that we need to maintain View V_TKALV. Goto SM34, enter V_TKALV and Press Maintain

button

Double click on “Field catalog information” And press push button “New Entries”.

(93)
(94)
(95)

Press on New Entries and create the following entries:

Now save the entries.

Step 3.

Add required code in “EXIT_SAPLKAEP_001”.

*&---* *& Include ZXKAEPU01

*&---* IF I_REP_OBJECT = 'PD'.

IF CS_RECORD-GKONT IS NOT INITIAL AND CS_RECORD-GKOAR = 'K'. CS_RECORD-ZZLIFNR = CS_RECORD-GKONT.

CS_RECORD-ZZNAME1 = CS_RECORD-GKONT_KTXT. ELSEIF CS_RECORD-EBELN IS NOT INITIAL.

SELECT SINGLE LIFNR FROM EKKO INTO CS_RECORD-ZZLIFNR WHERE EBELN = CS_RECORD-EBELN.

IF SY-SUBRC = 0.

(96)

WHERE LIFNR = CS_RECORD-ZZLIFNR. ENDIF.

ENDIF. ENDIF.

I_REP_OBJECT specifies which report you are using, so as to avoid unnecessary selection we need to keep the required value only. For CJI3 report the value for I_REP_OBJECT is ‘PD’.

And activate the enhancement as shown below.

(97)
(98)
(99)

Screen Exit for Notification Header (TCode: IW21) and show the

custom fields in standard report for notifications (IW28, IW29)

The user exit used is QQMA0001. Steps are given below. 1. Create a project YPM01 in CMOD transaction code.

(100)

2. Add the enhancement assignment QQMA0001 in the project.

3. Go to Components and double click on the screen 0100.

4. Before creating the customer fields in screen, create the fields in QMEL table of structure CI_QMEL.

5. Then create the custom fields in screen 0100.

6. Open FM EXIT_SAPMIWO0_008 and create include ZXQQMU0. This FM is used to pass the value from table to screen fields.

7. Open FM EXIT_SAPMIWO0_009 and create include ZXQQMU08. This FM is used to pass the value from screen to structure to store the value in table.

(101)

8. Activate the project. Now go to IW21 and see the custom fields. Functional consultant will do the configuration where to show these fields.

9. Now we can see how we can get these values in the standard report for notification. The transaction codes are IW28 and IW29.

10. Implement the BADI BADI_EAM_SINGLELEVEL_LIST, and in method FILL_ADD_FIELDS write your logic to fill alv.

(102)

12. Now run tcode IW28 and execute. If you are not finding the custom fields, then choose Settings->Layouts->Current.

13. You can view your group in the filter. Choose the custom fields from that.

(103)

Modifications to the SAP standard menu

Scenario:

You would like to include the link to your company intranet portal or the end user manual in all the SAP transactions for making it easier to the end-users.

Pre-requisites:

Create a transaction which navigates to the required portal or the end user manual as required.

Procedure:

Go to transaction SE41.

Enter the program name MENUSYST.

(104)

Select the radio button Status and select the value MEN using F4.

Click on change. Following screen would be displayed:

Double-click on System. The menu is expanded.

(105)

Now you can add your own menu items here. Please note that the change would reflect in all the transactions this is being used.

Select the position where you would like to include your custom menu-item and do the right-click. Now select “Insert entry” from the context menu.

(106)

ZCOMPANY is the custom transaction code created for testing purpose. Now double-click on “ZCOMPANY”.

(107)

Save and activate.

Testing the scenario:

Come back to the main screen and click on “Test”

You can observe that the new custom menu item is part of the standard menu (as shown below):

(108)

We can even have sub-menu as well (see the screenshot below):

We can also deactivate any of the menu-items as required. To do this:

(109)

Following message is displayed:

Now the menu would look as follows (you can observe that the function “Own Jobs” is deactivated):

(110)

You can activate the function by clicking on “Function Code” again.

Working with Menu Exits

Menu exits add items to the pull down menus in standard SAP applications. You can use these menu items to call up your screens or to trigger entire add-on applications.

SAP creates menu exits by defining special menu items in the Menu painter. These special entries have function codes that begin with ‘+’ (a plus sign). You can specify the menu items text when activating the item in an add-on project.

Note: along with Menu exits SAP also provides the function module exit to attach the functionality for

each menu option.

We can add customer menu options in two places:

• To the initial screen on the SAP menu (Area Menus) • To the standard menus of the standard transactions.

Example: Adding custom menu options for the standard transaction MC94.

Identify the menu exit from the standard transaction, i.e. through SMOD.

Go to transaction SMOD. and press F4.

Choose from information system, if you get a screen as shown below.

(111)

You will get the below screen. Enter the package name in Package and press enter.

(You will get the package name using attributes of the program for the transaction)

These are the list of exits available and MCP20003 is the Menu exit.

(112)

Go to the initial screen of SMOD transaction and enter the enhancement name and select the option component and click on display to check the list of components from the enhancement.

(113)

Note: since the function codes for the menu options are already available, it is enough to provide the

meaningful descriptions. But this enables the options only and the functionality can be linked in the function code.

Execute the COMD transaction and provide the project name and click on Create button if the project is not yet created. Else deactivate the project by clicking on and open the project in change mode.

(114)

Provide the enhancement name, save it and click on components

Now you will get the components of the exit. Double click on required function code i.e. +CU1.

(115)

Once the test is provided, we need to link the functionalities for the already activated function codes through the function module exits.

Double click on the function module exit EXIT_SAPMMCP6_003.

Now double click on include ZXSOPU03. It will ask for creation click on Yes.

(116)

Now back to the initial screen of COMD and activate the project

Note: Make sure that the project is always activated and so that the additional functions get activated.

Testing the enhancement

We need to execute the corresponding standard transaction to make sure that the additional options are available and the corresponding functions are called.

(117)

Enter the Material group and Material number. Now click on Active version.

Now you will get a screen as shown below.

Now in Menu à Extras à Customer functions you can find the Menu item “Create program - SSR3KOR” which is created now.

(118)

Click on Create program – SSR3KOR. You will get SE38 screen where you can create a program.

Adding custom fields to CS01, CS02 and CS03 (Bill Of Materials)

Requirement: Customer wanted to add two new fields Country and Vendor number to Bill of materials

header level.

Procedure: We need to add customer specific fields to BOM header level, first we need to add these two

fields to BOM header record table i.e. STKO, then create a sub screen two hold these two fields and write the corresponding logic in the Functional exits provided.

(119)

The above steps are explained below in Detail.

STEP 1: Create an Append structure for table STKO.

Go to SE11 and provide table name STKO.

Click on button Append structure

Give name for Append structure “ZSTKO”

Add new fields to Append structure. ZZLAND1 and ZZVENDOR

Check and Activate the append structure. A list of tables adjusted will be displayed.

STEP 2: Find an Enhancement for BOM.

Bill of materials transaction CS01/02/03 is assigned to package “CS”. We can search for relevant Enhancements in CS package.

(120)

In the search box provide Package name as “CS”

Then Execute. You will get list of available Enhancements for the given package.

With the given short text or the enhancement we can use Enhancement PCSD0003.

To see the Enhancement components press display button.

(121)

Select the relevant Enhancement and you can test the enhancement from SMOD transaction main screen.

STEP 3: Create a project for Enhancement.

Go to CMOD(Project management of SAP Enhancements) In the Initial Screen give any name (ZTEST) for Project. Then press create

(122)

In the Next screen fill description for project and save as local object/ save to a package.

Then Click on the enhancement assignments button Add the selected enhancement there and enter then save.

Go to back to Attributes of Enhancement project ZTEST screen

Use COMPONENTS button to see the components for the enhancement.

(123)

From the above screen you can see Project and enhancement Implementation are in red color and other components also.

Double click on screen exit. It will take you to Screen painter. Add customer fields to the screen.

Go to screen properties and mark it as sub screen.

Now go back to components.

Click on the function exit then press enter.

In the next screen you can see Function Module EXIT_SAPLCSDI_004 In the function Module you can see a Include ZXCSAU04.

Double click on the include

(124)

Include is ready to implement your code logic.

(125)

Double click on the USERDATA structure and Add an append structure.

Add two customer fields to the Append structure.

Then go back to include and write your code logic.

(126)

Save include. Check and activate. Then go back to components list. Add code to another function exit.

We have implemented function exits and screen exit.

Then activate project.

When we activate the project red button will turn into green. Components will turn into green.

For change and display transactions change the screen parameters.

(127)

Go to CS03 and give any material number, Plant and BOM usage press enter. Select header button to navigate to header window.

There you can see a tab “Customer fields” and two customer fields.

Implementing Screen-exit for transaction MIGO

Requirement:

Add new Tab to MIGO and store the custom values in a Z table, as there is no provision for adding custom fields in MSEG table except for Accounting details by Standard Include (CI_COBL).

Solution:

(128)

Create a program with the screen type sub-screen in SE80 and design the layout for the custom fields. Declare the custom fields in a Z**TOP include.

(129)

Under the PBO method declare the program name and screen number as shown

below:

Under PAI method declare the field to ‘X’.

Under the line modify method declare a flag and set to ‘X’ checking for material document number by which we can set the fields to be in display mode when we open MIGO for display of material document created after doing goods receipt.

Under the POST_DOCUMENT method write the code for appending the value to Z table along with the values of the line item (In this case production order number, material, …….). For these values to be available here in this method use the memory concept “Export to memory id” in the method LINE_MODIFY.

In order to do any validations to the custom fields, go to transaction SE80 and mention the program Name created and in PROCESS ON VALUE_REQUEST create a module and provide the validations required for those custom Fields.

(130)

In order to make the fields to be in display mode during the display of material document, create a module under PBO and import the flag value and the production order number details in the method LINE_MODIFY and if that flag = ‘X’, use

LOOP AT SCREEN. IF SCREEN-NAME = 'ZZGBAGS'. SCREEN-INPUT = '0'. MODIFY SCREEN. ENDIF. ENDLOOP.

Retrieve the values from the Z table matching the key field (production order number) and pass the value of the custom field on to the screen.

ZZBAGS = (fetched value from Z table).

(131)

Changing the description of the standard SAP fields

Consider the following scenario:

When entering the customer master details, we have the provision for entering the telephone number with extension, fax and telebox. Assume that we also need to enter the mobile number of the customer for which there is no provision. Also assume that we do not use telebox for any of our customers and want to use that field for entering the mobile number. Though you can directly enter the mobile number in the field “telebox” , the description ‘telebox’ always misguides us. See the screenshot below:

(132)

This tutorial focuses on changing the field descriptions for scenarios similar to above.

All the short-descriptions for the fields are retrieved from the data element level of the corresponding fields. So we need to change the descriptions at the data-element level.

So our first step is to know the data element used for the field “Telebox”. Press F1 and then F9 to know the data element. See the screenshot below:

(133)

Make a note of the data element.

(134)

Click on Goto à Text enhancements à Keywords à Change

(135)

Enter the data element.

Click enter. The following screen would appear:

Now change the descriptions as per the requirement. See the screenshot below:

(136)

Click on save.

Now to verify the changes, go to SE11 and enter the table name ADDR1_DATA. Check the short description for the field EXTENSION2:

Also go to transaction XD01 / XD02 and check the field:

(137)

The description “Telebox” is now changed to “Mobile No”.

Implement screen exit for MM01/MM02/MM03

Requirement:

Add new field(s) to MM01 basic data 1 view (screen) and store the values into a Ztable along with material number as primary key.

Solution:

1. Go to Transaction SPRO, Display IMG.

2. Go to Logistics-General à Material Master à Configuring the material master and execute ‘Create

Program for Customized

(138)

3. Create a function group of your own with Y or Z. In this case the function group name given ZMGD1.

4. Go to transaction SE80 and open the function group created, here the function group is ZMGD1.

5. Open the screen 0001. Using screen design layout (SE51), customize the screen according to the requirement.

(139)

6. Write the flow logic in PAI and PBO as per the requirement.

7. PBO

(140)

o Inactive the fields for input when material is displayed (MM03)

o Retrieve the data from Ztable for material change/display (MM02/MM03)

8. PAI

(141)

9. Now go to transaction SPRO, Display IMG then go to Logistics-General à Material Master à Configuring the material master and execute ‘Define Structure of Data Screens for Each Screen

Sequence’.

10. Select the corresponding screen sequence number and double click on data screen button. In this

case screen sequence ‘21’ has

modified.

(142)

11. Select logical screen 07 (Basic Data 1) and double click on Subscreens.

12. In change view of subscreens, modify the program name of sub screen 21à07à08 to the subscreen program name which is created in step 6. In this case the program name is SAPLZMGD1.

Save the

modifications.

13. Now to save the given enhanced field value in the Ztable, write the required code in the user exit EXIT_SAPLMGMU_001.

(143)

Execute the transaction MM01/MM02/MM03 and test the scenario developed.

How to implement screen exit for a SAP standard transaction

Introduction

SAP provides standard transactions to enter data into database. But a client may want to maintain some additional information in SAP other than what is provided.

To make provisions for this, additional screens have to be provided and additional fields must be added into appropriate database table.

To pave way for this, SAP has provided the option for screen exits. Usually, SAP provides the following: 1. An append structure in the database table with the new fields.

2. A subscreen area into the standard screen – where the programmer can attach his subscreen of his own program with the new fields.

3. A function group under which the new subscreen has to be created with the new fields.

4. Function exits to synchronize the PBO and PAI of the standard SAP program with the PBO and PAI of the subscreen – so that data can flow back and forth between the standard SAP program and the program written by the developer for the subscreen. These function modules also exist in the same function group under which the subscreen will have to be developed.

Finally, a linkage has to be done between the subscreen area of standard SAP screen with the custom subscreen constructed by the developer.

Typically, SAP provides an enhancement in which the developer can create an append structure, use the function exits to synchronize the PBO and PAI of the standard SAP program and the custom subscreen program, and make the necessary linking( as mentioned above in step 4. But, again, this is not a hard and fast rule. Linking in some case, is also done by configurations.) SAP also usually provides the name of the function group under which the subscreen has to be developed.

Necessary guidance about implementing a screen exit development is usually available in the Documentation section of the enhancement ( can be availed by transaction SMOD).

Pre-Requisites

The developer to work on screen exit should have essential knowledge on the following: • DDIC concepts, including the knowledge of append structure.

(144)

• Concept of SAP Enhancements and implementing them using Projects. • Concept of function exits.

• Knowledge on Module Pool – including subscreens, Tabstrip controls etc.

Steps

Guidelines

So, a developer can follow the guidelines mentioned below to implement a screen exit to a standard SAP transaction, as and when required:

Find out the Required Enhancements

1. Go to SMOD. Press F4 in the Enhancement field. In the next popup window, click pushbutton ‘SAP Applications’. A list will appear that contains information on all the enhancements, categorized under functional areas. Developer must search for the enhancements relevant to his functional area of interest – for e.g., Purchasing, Asset Accounting, etc.

2. Note down the enhancements. Then, come to the initial screen of SMOD and view the documentation of each enhancement to find out which one is required for your development.

Utilize the Enhancement in a Project

After you have found one, do as directed in the documentation. Generally, the steps are as follows: 1. Create a project using CMOD including your enhancement.

2. Create the append structure with new fields.

3. Go to the desired function group and create a subscreen with the new fields. Write PBO and PAI for the subscreen, if required.

4. Use the function exits in the enhancement to link the PBO and PAI of the subscreen with that of the main SAP program supporting the SAP transaction.

5. Maintain necessary linkage between the subscreen area of standard SAP program with the custom subscreen developed along with the custom program name. This can be done in the project (developed by CMOD including the enhancement) or outside as a part of configuration. 6. Activate the project.

7. Test to ensure that required functionality are met.

Case Study 1

Add three new custom fields for Asset master and maintain information for them

Requirement

Three fields in the legacy system have to be maintained in Asset master. These fields are: 1. Original Asset number – 20 characters

2. Location 2 – 15 Characters. 3. Model no – 20 characters Location 2 should start with ‘L’.

(145)

Pre-Analysis

Finding out the Enhancement

As described above, the enhancement is determined. It was found, that enhancement AIST0002 will serve the purpose. It contains the following components (can be viewed by transaction SMOD):

Exit Type Description EXIT_SAPL1022_001 Function Exit Check of User-Defined Fields when Using Create and Change BAPI EXIT_SAPLAIST_002 Function Exit Transfer Data for User Subscreens in PBO. EXIT_SAPLAIST_003 Function Exit Transfer of User-Defined Fields to SAP Master Data Transactions CI_ANLU Customizing Include Include structure to add new fields

Studying the Function Exits

The function module level documentation for the function exits are then viewed from transaction SE37. The documentation clearly laid out for the purpose for their use:

EXIT_SAPLAIST_002

Function module Level Documentation

This function module is called by asset master data maintenance at the start of the dialog. (When changing, it is called after reading of the data from the database; when creating it is called after the transfer of the default values from the asset class and reference asset.) The purpose of the function module is to enable this function group to recognize the master data. For interpreting or controlling master data fields that are important for user fields, it is possible to transfer to global variables at this point, so that they can be recognized when the user subscreens are processed.

Import Parameters

Understanding

This function module is called at the PBO to pass the information retrieved from the database to pass them to the custom subscreen and its underlying program. Import parameter : I_ANLU will be populated with the values for user-defined fields which will be passed to the subscreen program. So, there must be some sort of variable assignment from I_ANLU.

EXIT_SAPLAIST_003

Function module Documentation: This function module is called by SAP asset master data maintenance after the screens are processed, but before saving. The purpose of the function module is to transfer fields entered on user sub-screens of SAP asset data maintenance to the database for updating. The export parameter for this function module is:

Understanding

This function module will be used to transfer the user entered data in the subscreen fields to the main SAP program, which will then be saved into the database.

(146)

Studying the Documentation of the Enhancement

The enhancement documentation (as is viewed from the initial screen of SMOD] also supports the idea. Moreover, it informs that we need to develop a subscreen under function group XAIS. This is the function group under which the two function exit modules also exist. So, if the custom subscreen refers to the global data of the function group XAIS, then those values will also be available to these function exits as well.

Going to SE80 and viewing the function group XAIS helps us to inform that there are three DDIC tables declared for it:

Deciding the Final course of Action

After making all the investigations, the final course of action was determined. SrlNo Step Justification

1. A project has to be created using transaction CMOD where the enhancement AIST0002 will be included.

2. Customizing include CI_ANLU has to be created with the custom fields demanded When CI_ANLU will be developed, the custom fields will get appended to the database table ANLU. Also, these fields will be used to create screen fields in the new subscreen.

3. A custom subscreen, say, 9000 will be developed under function group XAIS. The screen group for the screen will be ‘CUST’ (or any name). The three custom fields added to table ANLU (by creating CI_ANLU) will be used to create new fields in the screen.

In the PAI of the subscreen, validation for Location to start with ‘L’ will be added. The subscreen with three new fields has to be developed so that it can be attached to a subscreen area of the asset master screens.

1. In the custom include of the function exit module ‘EXIT_SAPLAIST_002’, the following code will be written:-

ANLU = I_ANLU. I_ANLU is the import parameter of this FM. The value is assigned to the global variable ANLU, referring which the three new subscreen fields are developed. So, data retrieved from database table ANLU will be passed to this FM as I_ANLU by the standard SAP main program. The value will be taken and passed to the global variable of the function group XAIS, so that the three custom fields (referring to ANLU of XAIS) get populated.

1. In the custom include of the function exit module ‘EXIT_SAPLAIST_003’, the following code will be written:-

E_ANLU = ANLU. The changed values in the subscreen fields exist in global variable ANLU for the function group XAIS. This function exit module will pass the data back to the SAP main program as E_ANLU.

1. Proper linkage/configuration has to be done so that the new subscreens get linked to the appropriate subscreen area of the Asset master screen. This has to be done – otherwise, the new custom subscreen will not be displayed in the Asset master screens.

(147)

Development

Creating a Project to include the enhancement

1. Go to transaction CMOD and create a project.

2. Enter a description for the project. Then, click on the pushbutton ‘Enhancement Assignments’ in the Application Toolbar.

3. Enter the name of the enhancement and Save. 4. Go to ‘Components’.

Creating Custom Include for ANLU

The screen shown below will appear, showing all the enhancement components under the assignment AIST0002. Double-click on the name of the Include Structure to create it.

Create the include structure with three new fields, as required. Then, save and activate it.

Develop the subscreen and the program

Go to transaction SE80. For the function group XAIS, create a new subscreen 9000. Create it as subscreen.

Then, go to the Layout of the screen and create three new fields from Database table ANLU. Drag the fields in the screen body and place them.

Then, save and activate the screen and come back to screen flow editor. Create the PAI module to add validation for field “Location 2”, as required . Activate the whole function group and come out.

Write code in the Function Exits to synchronize the programs

Now, code has to be written in the function modules EXIT_SAPLAIST_002 and EXIT_SAPLAIST_003 so that data flows to and fro between the main SAP program and custom subscreen program. For that, go back to transaction CMOD and change the function exits.

Write code in the function module EXIT_SAPLAIST_002 called once at the beginning of the transaction: Write code in EXIT_SAPLAIST_003 to pass the data from the subscreen to SAP main program.

References

Related documents

From the Records Menu , select “ Read/Write Collisions .” Once the “Archive Collision Records” screen appears, simply enter a range of dates and then click on the

Step 1: Click “Middle Button” button in “Oscar Main Menu” &gt;&gt; click and select “Macro.. Manager” property

If you wish to delete a report setup that you have created, select the appropriate report setup on the Revision Class Setup Retrieve screen and click the

To edit custom devices, select the device in the Advanced Settings: Database screen, then click the Edit button that appears instead the View button that is shown for

From the Main Screen in VAG-COM (shown on Page 6 of this Manual) click the [Options] button to go into the Options screen (shown on Page 31 of this Manual).. H Select the

6. On the Choose Install Folder screen, click the Choose button to select where you want the software installed. Click Next.On the Choose Shortcut Location screen, select On

6 In the next screen you will select the SMS action from the Select an Action Type drop down list as  shown above, and then click the Next button. 

Inside the DHCP server screen, you see a button called Edit Network Interface, click this button and select eth1 then click save. Now click on the Start Sever button to start