finding user exit cor1 cork

13
Creating a Process Order (COR1) Click enter -> It is here where the first user exit should be. We've got all the info we need to produce an error message if there is another open order (any order whose status is not CLSD) of order type ZPSO for the material number entered (in this case SPECIALORDER) OR there is inventory for the entered plant (in this case BRD1) and material combo (in this case SPECIALORDER) – for inventory see transaction MMBE (see next page for discussion on how to get MMBE results). CHECK_MATERIAL_PLANT is a MODULE in the PAI for COR1 that looks promising for an implicit enhancement because it calls the subroutine check_material_plant in INCLUDE LCOKOF1V. MODULES do not have implicit enhancement hooks but subroutines do. At this point in the code CAUFVD-MATNR seems to hold the material number. CAUFVD-WERKS is the Production Plant. AUFPAR-PI_AUFART is the Process Order Type. Make sure the SY-TCODE is COR1. CAUFV is a view that holds Order Type (AUART), Material Number (PLNBEZ) & Plant (WERKS). In order to figure out status, I need the object number for the orders for which I want status. AUFK-OBJNR is object number. Then I search JEST for active statuses (INACT = space) for CAUFV-OBJNR of interest making sure none of the statuses = I0046 (CLSD).

Upload: ahmed-velid

Post on 24-Apr-2015

202 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Finding User Exit Cor1 Cork

Creating a Process Order (COR1)

Click enter -> It is here where the first user exit should be. We've got all the info we need to produce an error message if there is another open order (any order whose status is not CLSD) of order type ZPSO for the material number entered (in this case SPECIALORDER) OR there is inventory for the entered plant (in this case BRD1) and material combo (in this case SPECIALORDER) – for inventory see transaction MMBE (see next page for discussion on how to get MMBE results). CHECK_MATERIAL_PLANT is a MODULE in the PAI for COR1 that looks promising for an implicit enhancement because it calls the subroutine check_material_plant in INCLUDE LCOKOF1V. MODULES do not have implicit enhancement hooks but subroutines do. At this point in the code CAUFVD-MATNR seems to hold the material number. CAUFVD-WERKS is the Production Plant. AUFPAR-PI_AUFART is the Process Order Type. Make sure the SY-TCODE is COR1. CAUFV is a view that holds Order Type (AUART), Material Number (PLNBEZ) & Plant (WERKS). In order to figure out status, I need the object number for the orders for which I want status. AUFK-OBJNR is object number. Then I search JEST for active statuses (INACT = space) for CAUFV-OBJNR of interest making sure none of the statuses = I0046 (CLSD).

Page 2: Finding User Exit Cor1 Cork

MMBE Discussion: From what I can tell the tables that hold inventory are MCHB, MARD, MARC. Then I have to check quantities (CLABS, CUMLM, CINSM, etc). And this list of tables might not be complete. There is a BAPI -> BAPI_MATERIAL_STOCK_REQ_LIST. This looks like maybe the way to go. Input into the BAPI: MATERIAL = CAUFVD-MATNR PLANT = CAUFVD-WERKS GET_IND_LINES = space GET_TOTAL_LINES = 'X' Exported from the BAPI: MRP_LIST- PLNT_STOCK MRP_STOCK_DETAIL- TOTAL_STCK Table MRP_TOTAL_LINES MRP_TOTAL_LINES - MRP_ELEMNT = Stock MRP_TOTAL_LINES - REC_REQD_QTY But there are other MRP elements in this table. MMBE reports the following:

This indicates a total of 10,002.000 + 2 reserved + 2 receipt reserved = 10,006.000. The BAPI table MRP_IND_LINES indicates the following which looks more like 10,004.000 (this run indicated detail lines should be returned):

The output parameter MRP_STOCK_DETAIL might be more promising but it holds more quantity: TOTAL_STCK = 10,001.000 FIXED_ISSUES = 2.000 PL_RECEIPT = 10.000 There are a lot of dollar fields in MRP_STOCK_DETAIL. Do I check them all? If there are any quantities greater than zero? What if I look for any rows in MRP_TOTAL_LINES? Material SXAQNP has a single row that contains all zeros in MRP_TOTAL_LINES. MMBE reports the same. Does this mean there is inventory? GM_RRB by definition can't have inventory because it is a service. Both MMBE and MRP_TOTAL_LINES are empty for GM_RRB. I'm inclinded to ingore the tables (send space for GET_IND_LINES – others default to space) and just focus on total quantity fields in the structure BAPI_MRP_STOCK_DETAIL.

Page 3: Finding User Exit Cor1 Cork

Another avenue of investigation is transaction MM03 / Plant Stock view. There is a Plant Stocks in Current Period section:

SE30 indicates that the only inventory table this transaction went up against were MARC (Plant Data for Material) and MARD (Storage Location Data for Material). I don't see anything useful in MARC. MARD looks more promising with LABST holding the unrestricted stock. SPEME is blocked. INSME is Quality Inspected. EINME is Restricted. I'm told I need to find Blocked, Quality Inspection, Restricted, and Unrestricted Use. I was also told that the structure RMMG3 could be helpful. I think I need to look at all periods but I'm not sure. Below is what is in MARD for B4622:

Notice the A in SPERR. That indicates "Physical inventory not yet completed for material." LFMON is the period. So 09 is a prior period and 11 is the current period. Hmmm. I'm told it is only current period stock that I'm interested in. So how did that 1.000 get into current period above. I think there is programming logic that will be tough to figure out.

Page 4: Finding User Exit Cor1 Cork

To continue creating a Process Order, enter quantity:

Just say YES to dialog that comes up:

Page 5: Finding User Exit Cor1 Cork

Enter LGVLYC10 for the material on the 4th screen:

Page 6: Finding User Exit Cor1 Cork

And SAVE on the 5th screen:

Page 7: Finding User Exit Cor1 Cork

CORK (Process Order Confirmations (Total)) Screen 1:

The user goes to Goods Movement by clicking on the Goods Movements button on next screen:

Page 8: Finding User Exit Cor1 Cork

Enter today's date on the 3rd CORK screen:

On the 4th screen need to choose a batch from the drop down menu for each of the Goods Movements Materials:

Then SAVE and make sure all goods movements are processed correctly (the message RU110 Confirmation saved (Goods movements: 4, failed: 0 Make sure failed is zero before settling. If not zero, send email to – ask Shiv for proper email address – SQM group – [email protected]) The 2nd user exit goes here. If there is a failure & order type is ZSPO (maybe later will add ZBD1), email should be sent to QM notification group. If there is no failure call transaction K088 OR submit program RKO7CO88 to automatically run order settlement.

Page 9: Finding User Exit Cor1 Cork

Message RU110 is issued from Function Module CO_RU_CONF_POST. The failed number is held in the variable tmp_retro_err, which is set at line 691. Once I have data I can test, I want to debug CORK, placing a break point at line 691 and the beginning of the function module. I need to figure out if there are any user exits I could use. If not I want to figure out how to restrict the user exit at the end of the FM to the specific item I want (SY-TCODE = CORK, order type = ZSPO (CAUFVD-AUART?) SY- MSGID = 'RU' SY- MSGNO = 110). caufvd-aufnr seems to hold the order number. CO_RU_CONF_POST does not work because the order is locked and KO88 fails. I actually found an enhancement point, CO_RU_CONFIRMATION_POST_05 SPOTS ES_SAPLCORF in CO_RU_CONFIRMATION_POST that looks like it will do the job. Confirmation transaction has been committed and all the necessary variables are populated at this point except for SY-MSGID & SY-MSGNO but these have been exported to memory so I can import with the following code: import sy-msgid to lv_brd_msgid from memory id 'CATS_TRANSFER_PM_PS'. import sy-msgno to lv_brd_msgno from memory id 'CATS_TRANSFER_PM_PS'. K088. Set parameter ID CAC to controlling area associated with company code caufvd-bukrs. Otherwise, a pop-up can ask for controlling area if this parameter ID is not set. Period is the current period. Make sure Test Run is unchecked. Execute is the action to be taken:

I created a BDC Session Recording in 500 KO88_CAF: Program Screen Start ID Field Name Field Value T KO88 SAPLKO71 1000 X BDC_OKCODE =AUSF LKO74-PERIO 11 LKO74-GJAHR 2009 LKO74-VAART 1 LKO74-TESTLAUF

Page 10: Finding User Exit Cor1 Cork

CODIA-AUFNR 10000046 Instead of KO88, I think I should submit program RKO7CO88. I still need to set parameter ID CAC to 1000 or a pop-up will appear in the submission of RKO7CO88. That won't work because I am not able to choose the order number with RKO7CO88. Oh well… BDC_OKCODE =AUSF (execute) LKO74-VAART 1 (Processing Type -> Automatic) LKO74-TESTLAUF blank (Test Run) I ran into another challenge because my call transaction to KO88 only worked if I was in the debugger! I tried everything I could think of and nothing seemed to work. Then I finally tried putting in a 15 second wait loop and everything worked perfectly! It seems the COMMIT WORK AND WAIT that CORK had already done on the confirmation doesn't really wait!

Page 11: Finding User Exit Cor1 Cork

The following code works: import sy-msgid to lv_brd_msgid from memory id 'CATS_TRANSFER_PM_PS'. import sy-msgno to lv_brd_msgno from memory id 'CATS_TRANSFER_PM_PS'. if lv_brd_msgid = 'RU' and lv_brd_msgno = '110'. lv_brd_aufnr = caufvd-aufnr. lv_brd_comp_code = caufvd-bukrs. lv_brd_mode = 'N'. " no display lv_brd_update = 'S'. " synchronous clear lt_brd_msg. refresh lt_brd_msg. clear ls_brd_docdata-obj_descr. lv_brd_retro_err = n_items_total_back_flush - n_items_ok_back_flush. if lv_brd_retro_err = 0. " no errors were encountered lv_brd_text = 'Be patient - Waiting 15 seconds for Comfirmation to complete'. call function 'SAPGUI_PROGRESS_INDICATOR' exporting text = lv_brd_text. * Wait 15 seconds do 15 times. wait up to 1 seconds. enddo. call function 'SAPGUI_PROGRESS_INDICATOR' exporting text = 'Launching settlement'. clear: lv_brd_msgv3, lv_brd_msgv4. lv_brd_msgv1 = n_items_ok_back_flush. lv_brd_msgv2 = lv_brd_retro_err. call function 'BAPI_CONTROLLINGAREA_FIND' exporting companycodeid = lv_brd_comp_code importing controllingareaid = lv_brd_controlling.

Page 12: Finding User Exit Cor1 Cork

call function 'BAPI_COMPANYCODE_GET_PERIOD' exporting companycodeid = lv_brd_comp_code posting_date = sy-datum importing fiscal_year = lv_brd_year fiscal_period = lv_brd_period. lv_brd_perio = lv_brd_period. lv_brd_gjahr = lv_brd_year. lt_brd_bdctab-program = 'SAPLKO71'. lt_brd_bdctab-dynpro = '1000'. lt_brd_bdctab-dynbegin = 'X'. append lt_brd_bdctab. clear lt_brd_bdctab. lt_brd_bdctab-fnam = 'LKO74-PERIO'. lt_brd_bdctab-fval = lv_brd_perio. append lt_brd_bdctab. clear lt_brd_bdctab. lt_brd_bdctab-fnam = 'LKO74-BUPERIO'. lt_brd_bdctab-fval = lv_brd_perio. append lt_brd_bdctab. clear lt_brd_bdctab. lt_brd_bdctab-fnam = 'LKO74-GJAHR'. lt_brd_bdctab-fval = lv_brd_gjahr. append lt_brd_bdctab. clear lt_brd_bdctab. lt_brd_bdctab-fnam = 'LKO74-VAART'. lt_brd_bdctab-fval = '1'. append lt_brd_bdctab. clear lt_brd_bdctab. lt_brd_bdctab-fnam = 'LKO74-TESTLAUF'. lt_brd_bdctab-fval = ' '. append lt_brd_bdctab. clear lt_brd_bdctab. lt_brd_bdctab-fnam = 'CODIA-AUFNR'. lt_brd_bdctab-fval = lv_brd_aufnr. append lt_brd_bdctab. clear lt_brd_bdctab. lt_brd_bdctab-fnam = 'BDC_OKCODE'. lt_brd_bdctab-fval = '=AUSF'. append lt_brd_bdctab. clear lt_brd_bdctab. set parameter id 'CAC' field lv_brd_controlling.

Page 13: Finding User Exit Cor1 Cork

call transaction 'KO88' using lt_brd_bdctab mode lv_brd_mode update lv_brd_update messages into lt_brd_msg. if sy-subrc = 0. clear lt_brd_msg. refresh lt_brd_msg. message id lv_brd_msgid type lv_brd_msgty number lv_brd_msgno with n_items_ok_back_flush lv_brd_retro_err lv_brd_msgv3 lv_brd_msgv4. endif. " no errors from settlement (KO88) endif.. " no errors from confirmation (CORK)