SAP SD Routines Explanation

March 16, 2018 | Author: Sarosh | Category: Subroutine, Rounding, Areas Of Computer Science, Computer Programming, Technology
Share Embed Donate


Short Description

SAP Sales and Distribution Routines Explanation...

Description

What is the difference between a User Exit and Routines in SAP SD? Routines Routines are short sub-programs that carry out various checks during document processing. In the SD module, you can create and process routines for copying requirements, data transfer, requirements and formulas using transaction VOFM. Besides the routines delivered to you with the system, you can create your own individual routines. Transaction VOFM allows you to follow a standardized procedure for creating routines. The name ranges are predefined for routines delivered to you with the system and for routines created by the customer. This name convention guarantees that your own routines are not overwritten during a Release upgrade. Copying requirements and data transfer The routines for coying requirements and data transfer are defined for the document types sales orders, deliveries, billing documents, sales activities, as well as for texts. You specify copying requirements and the data transfers when defining the document flow for each document type. You enter the routines for texts in the access sequences for texts. o Copying requirements determine which data is copied during the copying of documents. A copying requirement could define, for example, that the same customer must appear in the document header when you copy an inquiry to a quotation. o Routines for data transfer make a detailed control of the copying of fields possible. A data transfer could define, for example, that particular item fields can only be copied in combination with other particular fields and can only be copied into contracts or credit and debit memos. Requirements and formulas Routines for requirements and formulas are used for functions using the condition technique. You enter these routines in the pricing procedure or the condition types. Requirements are also used for statistics. o A requirement in pricing can determine that an access is dependent on a particular precondition. It can carry out a check of the document currency, for example, and, depending on whether it is a foreign or the local currency, allow or deny the access. o Formulas are used in pricing to define various factors for pricing. Formulas are defined for scale base value, condition base value, condition amount, group key, and rounding rules. The formula for a rounding rule could define, for example, that all calculated amounts are rounded to two places behind the decimal point during a price change of the condition record. The formula for a condition base value could define, that the header discount is distributed among the order items according to volume an not value of the item, as is the case in the standard SAP R/3 System. Creating routines There are two methods to create a routine

1. Creating by overwriting When using this method, a note appears as a commentary in the routine to be newly created. 2. Creating When creating a new routine, an ABAP with internal number assignment is created. You always have to activate a new routine before using it. Each routine for requirements and formulas, copying requirements and data transfers is stored in a separate program. For each new routine an entry is added in table TFRM and TFRMT. For each routine, a long text can be stored as a text module. Most routines must be changed in client 000. Transaction VOFM can be transported as XPRAs, which means that after the import all routines can be activated. Name ranges for routines The standard routines are to be within the number range 001-599 (for 2 digit formula numbers, 01-49) The user routines are to be within the number range 600-999 (for 2 digit formula numbers, 50-99). Interface to the transport system For technical reasons, an interface to the transport system is not possible at the moment. Until up to and including Release 3.0, developments have to be transported manually using correction numbers and transport requests.

******** User exit********* In this step you can implement the user exits listed below. Note You should carry out this step only if both of the following apply: o The SAP standard processes does not suit your needs. o You are a competent ABAP/4 programmer. User exit Replaces PBEN0001 Feature BAREA PBEN0002 Feature BENGR PBEN0003 Feature BSTAT PBEN0004 Feature CSTV1 PBEN0005 Feature CRDV1 PBEN0006 Feature ELIGR PBEN0007 Feature TRMTY PBEN0008 Function HR_BEN_CALC_BENEFIT_COST PBEN0009 Function HR_BEN_CALC_BENEFIT_CREDIT PBEN0010 Function HR_BEN_CALC_BENEFIT_SALARY

PBEN0011 Function HR_BEN_CALC_COVERAGE_AMOUNT PBEN0012 Form CALC_ELIG_DATE PBEN0013 Form CALC_TERM_DATE PBEN0014 Function HR_BEN_CALC_SAVE_ER_CONTRIB PBEN0015 Form CHECK_ELIG_SERVICE PBEN0016 Function HR_BEN_CALC_PARTICIPATION_DATE PBEN0017 Feature EVTGR PBEN0018 Feature COVGR PBEN0019 Feature EECGR PBEN0020 Feature ERCGR PBEN0021 Funtionmodule HR_BEN_CALC_SPEN_ER_CONRIB PBEN0022 Function HR_BEN_GET_PROCESS_DATES PBEN0023 Function HR_BEN_CALC_CUTOFF_AGE PBEN0024 Function HR_BEN_CALC_CUTOFF_LOS PBEN0025 Function HR_BEN_CALC_CUTOFF_SAL PCOB0001 COBRA Letter PCOB0004 Form HR_BEN_COB_GET_TOTAL_COSTS If you need to implement any of these User exits, you first create a project for the user exit, then assign the user exit(s) to your project. Then you write the coding for the user exit, and finally activate the project. For general information about user exits, in the R/3 Library, go to Basis components and look at the Enhancements section. In addition there is detailed information about each user exit that you can access when you assign it to your project (see below). Activities Start by creating your project. 1. Enter a name for your project. 2. Select Modification -> Create. 3. Enter a short text for your project and select save. Next assign the user exit to your project. 4. Select Components. 5. Enter the name(s) of the user exits you want to implement. 6. Select SAP documentation, if you want detailed information on this user exit. 7. Select save. 8. Select back. Next make your coding modifications.

9. Select enhancement components. 10. Select change. 11. Select the user exit you want to write code for. 12. Select the include zxpbco01. The system will then prompt you to create this include, and you can continue to write your coding in it. Next activate your project. 13. Return to the initial screen and select activate project. *******************

SAP User Exits Routine User exits are routine which SAP allows you to add in additional customized programs process without affecting the standard SAP programs. SAP user exit are usually declare as a form routine :form userexit_xxxxx ........................ endform In VL01 - Create Delivery Order, standard program SAPMV50A, the standard program did not check for storage location equal to space, and delivery quantity less than one when the user click the save button. Therefore I have to insert the additional checking into the userexit routine. Steps:• • • • •

Goto transaction VL01 to pick a Sales Order for delivery (you don't have to save the data) In the initial screen, click System -> Status -> Double click on Program (Screen) In the dialog program SAPMV50A, click Edit -> Search/replace Type userexit in the Find field, then click the In program radio button and hit Enter A number of userexit routine will be display. You'll have to roughly decide which is the correct userexit routine to used.

form userexit_save_document_prepare. case xlips-pstyv. when 'TAX' or 'REX'. * Accept this two Delivery item category when 'REN'. if xlips-lgort = space.

*

Reject this Delivery item category message e001. endif.

when others. if xlips-matnr space. * Check storage location not space if xlips-lgort = space. message e002. endif. * Check delivery quantity not zero if xlips-pikmg < 1. message e003. endif. endif. endcase. endform. What is the use of user-exit and all? Is it about modifying SAP program? Suppose that you need some functionality which is not provided in sap what do you do. Sap has provided you with three options. 1) Customizing. 2) Modifications. 3) User Exits. So what are these three in the first case when you take Customization is nothing but you are customizing SAP according to your need and requirement for example you want the Purchase Order Numbers to start with (sequential no) this kind of stuff is done in customization. Modification is nothing but you are modifying SAP std code which is written during developing your SAP std programms or screens. Thirdly to avoid modifications SAP has provide you with some exit points like for example after the PBO event in module pool programming comes the PAI. so in between these two events you wanted the change something so SAP has provided with an exit point. that exit point is called user exits. for example user exits for me21 PO Create is MM06005 if I am not wrong. they are nothing but simple function module within which you write your code which functions just like normal program and executes between the PAI and PBO events. **********

Inbound processing is widely the reverse process of an outbound.. The received IDoc

has to be unpacked, interpreted and transferred to an application for further processing. Inbound processing function module

Below is the example of an inbound function module. This module expects an IDoc with rows of plain text and will save this text under a given name to SAP's text database. The procedure will extract the text name and the text line from the IDoc and hand over the text data to the function module READ_TEXT which will store the text in the text pool.

FUNCTION *"---------------------------------------------------------------------*"*"Lokale Schnittstelle: *" IMPORTING *" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD *" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC *" EXPORTING *" VALUE(WORKFLOW_RESULT) LIKE BDWFAP_PAR-RESULT *" VALUE(APPLICATION_VARIABLE) LIKE BDWFAP_PAR-APPL_VAR *" VALUE(IN_UPDATE_TASK) LIKE BDWFAP_PAR-UPDATETASK *" VALUE(CALL_TRANSACTION_DONE) LIKE BDWFAP_PAR-CALLTRANS *" TABLES *" IDOC_CONTRL STRUCTURE EDIDC *" IDOC_DATA STRUCTURE EDIDD *" IDOC_STATUS STRUCTURE BDIDOCSTAT *" RETURN_VARIABLES STRUCTURE BDWFRETVAR *" SERIALIZATION_INFO STRUCTURE BDI_SER *"---------------------------------------------------------------------DATA: XTHEAD LIKE THEAD . DATA: TLINES LIKE TLINE OCCURS 0 WITH HEADER LINE. CLEAR XTHEAD. REFRESH TLINES. * *** --- Unpacking the IDoc --- *** LOOP AT IDOC_DATA. CASE IDOC_DATA-SEGNAM. WHEN 'YAXX_THEAD'. MOVE IDOC_DATA-SDATA TO XTHEAD. WHEN 'YAXX_TLINE'. MOVE IDOC_DATA-SDATA TO TLINES. ENDCASE. ENDLOOP. * *** --- Calling the application to process the received data --- *** CALL FUNCTION 'SAVE_TEXT' EXPORTING HEADER = XTHEAD SAVEMODE_DIRECT = 'X' TABLES LINES = TLINES. ADD SY-SUBRC TO OK. * füllen IDOC_Status * fill IDOC_Status IDOC_STATUS-DOCNUM IDOC_STATUS-MSGV1 IDOC_STATUS-MSGV2 IDOC_STATUS-MSGID IDOC_STATUS-MSGNO

= = = = =

IDOC_CONTRL-DOCNUM. IDOC_CONTRL-IDOCTP. XTHEAD. '38'. '000'.

IF OK NE 0. IDOC_STATUS-STATUS = '51'. IDOC_STATUS-MSGTY = 'E'. ELSE. IDOC_STATUS-STATUS = '53'. IDOC_STATUS-MSGTY = 'S'. CALL_TRANSACTION_DONE = 'X'. ENDIF. APPEND IDOC_STATUS. ENDFUNCTION.

Unpacking the IDoc data

The received IDoc data is processed record by record and unpacking is a simple discrimination by case according the segment name provided with each record..

* *** --- Unpacking the IDoc --- *** LOOP AT IDOC_DATA.bb CASE IDOC_DATA-SEGNAM. WHEN 'YAXX_THEAD'. PERFORM UNPACK_IDOC TABLES IDOC_DATA USING XTHEAD. WHEN 'YAXX_TLINE'. PERFORM UNPACK_TAB TABLES IDOC_DATA TLINES. ENDCASE. ENDLOOP.

Application processing

When the IDoc is unpacked it needs to be passed to the application. In our case this will be a simple call to a standard function which is going to store the data to the text database.

* *** --- Calling the application to process the received data --- *** CALL FUNCTION 'SAVE_TEXT' EXPORTING HEADER = XTHEAD SAVEMODE_DIRECT = 'X' TABLES LINES = TLINES.

Writing a status log

Finally the processing routine needs to pass a status record to the IDoc processor. This status indicates successful or unsuccessful processing and will be added as a log entry to the table EDIDS.

* fill IDOC_Status IF OK NE 0. IDOC_STATUS-STATUS = '51'. ... ELSE. IDOC_STATUS-STATUS = '53'. ... ENDIF. APPEND IDOC_STATUS.

The status value '51' indicates a general error during application processing and the status '53' indicates everything is OK. There are numerous other status values, with distinct meanings, but '51' and '53' are the most common ones.

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF