Vous êtes sur la page 1sur 8

*eject ************************************************************************ * Funct. Mod.

: Y_SLS_IDOC_INPUT_DESADV * * Group : YLII SAP Release : 30F * * Date : 03/02/2000 Language : E * * -------------------------------------------------------------------- * * IDoc inbound processing CALL TRANSACTION VL02. * * Message Type DESADV - Post goods issue delivery * ************************************************************************ * Author : Jan Van Gorp * * Company : Janssen Pharmaceutica NV * * Turnhoutsebaan 30 * * B-2340 BEERSE (BELGIUM) * * Tel 32/14/60.34.84 Fax 32/14/60.34.55 * ************************************************************************ * Change history search string: * ** 1 04/06/2000 Michiel Strybol "D0001 * ** Automatic GR posting for inbound 'DESADV' * * 2 13/11/2000 Guido Buitendijk ICT-Europe N.V. " 13112000 * * Bug fix: refresh BDCDATA. * * 3 27/06/2001 Hennie de Nooijer Solvision N.V. " SLS000342 * * Conversion to 4.6c: mostly corrections of BIM's. * * 4 02/07/2001 Karen Verrecas " SLS000342 * * Upgrade 46C: conversion of BI VL02--> VL02N * 5 03/09/2001 Karen Verrecas * Syntax error * 6 02/22/2011 Rajsikhar Nandi "E2-SLS00000922 * * For Sodiac it s required to update the real carrier in * * the delivery in case it deviates from the original * * allocated carrier. * ************************************************************************ FUNCTION y_sls_desadv_call_transaction. *"---------------------------------------------------------------------*"*"Local Interface: *" IMPORTING *" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD *" EXPORTING *" VALUE(UPDATESUCCEEDED) LIKE SY-FTYPE *" VALUE(DELIVERYNUMBER) LIKE BDWFRETVAR-DOC_NUMBER *" TABLES *" IDOC_DATA STRUCTURE EDIDD *" ERRORMESSAGES STRUCTURE BDCMSGCOLL *"---------------------------------------------------------------------TABLES: e1edk06. " Contains WDS goods issue date id=035 * Begin of change by rnandi65 for E2-SLS00000922 on 02/22/2011 TYPES: BEGIN OF lt_vbpa, vbeln TYPE vbeln, parvw TYPE parvw, lifnr TYPE lifnr, END OF lt_vbpa. * DATA: w_e1edka2 TYPE e1edka2, "SEGMENT E1EDKA2 li_vbpa TYPE STANDARD TABLE OF lt_vbpa, lw_vbpa TYPE lt_vbpa, l_lifnr TYPE lifnr, l_bdc TYPE char1, l_modify TYPE char1,

l_tabix TYPE sy-tabix, l_num(2) TYPE n, l_tab_char TYPE char4, i_e1edka2 TYPE STANDARD TABLE OF e1edka2. * End of change by rnandi65 for E2-SLS00000922 on 02/22/2011 *-----Table containing Document header date segment DATA: itab_e1edk06 LIKE e1edk06 OCCURS 0 WITH HEADER LINE. **--** Start of insertion 06.04.2000 **-------------------------------** **Table containing data for automatic GR posting * data : begin of itab_ylgrpo occurs 0, * ebeln like ekpo-ebeln, * ebelp like ekpo-ebelp, * matnr like ekpo-matnr, * werks like ekpo-werks, * lgort like ekpo-lgort, * charg like lips-charg, * lfimg like lips-lfimg, * vrkme like lips-vrkme, * elikz like ekpo-elikz, * end of itab_ylgrpo. * **Tables for Idoc processing * data : t_idoc_data like edi_dd occurs 0 with header line, * t_idoc_control like edi_dc occurs 0 with header line. * * data : s_e1mbxyh like e1mbxyh, * s_e1mbxyi like e1mbxyi. **--** End of insertion 06.04.2000 **---------------------------------** *-Local variables DATA: h_vbeln LIKE h_gidat LIKE * h_automatic(1) flag(1) TYPE likp-vbeln, syst-datum, type c, " c. " SLS delivery note number " WDS goods issue date id=035 Indicator for automatic GR posting " Indicator for virtual error messages

* BEGIN OF PROCESSING AND CALL TRANSACTION VL02 ************************ * Initialisations CLEAR : flag, h_vbeln. REFRESH: bdcmsg. REFRESH: bdcdata. " 13112000 * Take over of IDOC-Data LOOP AT idoc_data. CASE idoc_data-segnam. * Begin of change by rnandi65 for E2-SLS00000922 on 02/22/2011 WHEN 'E1EDKA2'. CLEAR w_e1edka2. MOVE idoc_data-sdata TO w_e1edka2. APPEND w_e1edka2 TO i_e1edka2. * End of change by rnandi65 for E2-SLS00000922 on 02/22/2011 WHEN 'E1EDK06'. CLEAR itab_e1edk06. MOVE idoc_data-sdata TO itab_e1edk06. APPEND itab_e1edk06. WHEN 'E1EDP07'. IF h_vbeln IS INITIAL.

Get SLS-delivery number. CLEAR e1edp07. MOVE idoc_data-sdata TO e1edp07. h_vbeln = e1edp07-bstnk. ENDIF. WHEN OTHERS. ENDCASE. ENDLOOP.

**--** Start of insertion 06.04.2000 **-------------------------------** **Check for automatic GR posting * clear likp. * select single lfart from likp into likp-lfart * where vbeln eq h_vbeln. * * check likp-lfart eq 'NL' or * likp-lfart eq 'ZNL'. * * clear itab_ylgrpo. * refresh itab_ylgrpo. * * select charg lfimg vrkme vgbel vgpos from lips * into corresponding fields of lips * where vbeln eq h_vbeln. * * clear ekko. * select single bsart reswk from ekko * into corresponding fields of ekko * where ebeln eq lips-vgbel. * * check ekko-bsart eq 'UB'. * * clear ekpo. * select single * from ekpo where ebeln eq lips-vgbel * and ebelp eq lips-vgpos. * * clear yls24. * select single * from yls24 where reswk eq ekko-reswk * and werks eq ekpo-werks. * * check yls24-auto eq 'X'. * * move 'X' to h_automatic. * * clear itab_ylgrpo. * move-corresponding ekpo to itab_ylgrpo. * move-corresponding lips to itab_ylgrpo. * append itab_ylgrpo. * * endselect. **--** End of insertion 06.04.2000 **---------------------------------** * Get goods issue date out of ITAB_E1EDK06. CLEAR : h_gidat, itab_e1edk06. READ TABLE itab_e1edk06 WITH KEY iddat = '035'. IF sy-subrc = 0. h_gidat = itab_e1edk06-datum. ENDIF.

* SLS delivery number must be filled. IF h_vbeln IS INITIAL. flag = 'X'. updatesucceeded = ' '. CLEAR bdcmsg. bdcmsg-msgid = 'YL'. bdcmsg-msgnr = '295'. APPEND bdcmsg. ENDIF. * Get goods issue date must be filled. IF h_gidat IS INITIAL. flag = 'X'. updatesucceeded = ' '. CLEAR bdcmsg. bdcmsg-msgid = 'YL'. bdcmsg-msgnr = '294'. APPEND bdcmsg. ENDIF. * Begin of change by rnandi65 for E2-SLS00000922 on 02/22/2011 DATA: s_ybs00001 TYPE ybs00001, s_ybs00002 TYPE ybs00002, l_vstel LIKE likp-vstel, d_item LIKE ybs00001-item. d_item = 'SCM-SLS-FSS-SWH-06'. CLEAR: s_ybs00001, l_bdc, l_modify. PERFORM f_check_active IN PROGRAM ybr00001 USING d_item CHANGING s_ybs00001. IF s_ybs00001-enabled = 'X'. SELECT SINGLE vstel FROM likp INTO l_vstel WHERE vbeln = h_vbeln. IF sy-subrc = 0. SELECT SINGLE * FROM ybs00002 INTO s_ybs00002 WHERE item = d_item AND field = 'VSTEL' AND value = l_vstel. IF sy-subrc = 0. CLEAR: l_bdc, l_modify. READ TABLE i_e1edka2 INTO w_e1edka2 WITH KEY parvw = 'ZC'. IF sy-subrc = 0. SELECT vbeln parvw lifnr INTO TABLE li_vbpa FROM vbpa WHERE vbeln = h_vbeln AND posnr = '000000'. IF sy-subrc = 0. SORT li_vbpa BY parvw.

READ TABLE li_vbpa INTO lw_vbpa WITH KEY parvw = 'ZC' BINARY SEARCH. IF sy-subrc = 0. l_tabix = sy-tabix. IF lw_vbpa-lifnr NE w_e1edka2-partn. CLEAR l_lifnr. SELECT SINGLE lifnr FROM lfa1 INTO l_lifnr WHERE lifnr = w_e1edka2-partn. IF sy-subrc <> 0. * real carrier &1 does not exist in vendor master flag = 'X'. updatesucceeded = ' '. CLEAR bdcmsg. bdcmsg-msgid = 'YSLS'. bdcmsg-msgnr = '248'. bdcmsg-msgtyp = 'E'. APPEND bdcmsg. ELSE. l_bdc = 'X'. l_modify = 'C'. "Change ENDIF. ENDIF. ELSE. * if zc not exist, had to add zc. CLEAR l_lifnr. SELECT SINGLE lifnr FROM lfa1 INTO l_lifnr WHERE lifnr = w_e1edka2-partn. IF sy-subrc <> 0. flag = 'X'. updatesucceeded = ' '. CLEAR bdcmsg. bdcmsg-msgid = 'YSLS'. bdcmsg-msgnr = '248'. bdcmsg-msgtyp = 'E'. APPEND bdcmsg. ELSE. l_bdc = 'X'. l_modify = 'A'. "Add ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. ELSE. flag = 'X'. updatesucceeded = ' '. CLEAR bdcmsg. bdcmsg-msgid = 'YL'. bdcmsg-msgnr = '294'. bdcmsg-msgtyp = 'E'. bdcmsg-msgv1 = h_vbeln. APPEND bdcmsg. ENDIF. ENDIF.

* End of change by rnandi65 for E2-SLS00000922 on 02/22/2011 * Prepare GI for transaction VL02. IF flag NE 'X'. * Prepare dynpro '0101' program 'SAPMV50A'. * PERFORM BDC_DYNPRO USING 'SAPMV50A' '0101'. "SLS000342 PERFORM bdc_dynpro USING 'SAPMV50A' '4004'. "SLS000342 PERFORM bdc_field USING 'LIKP-VBELN' h_vbeln 'C' ' '. PERFORM bdc_field USING 'BDC_OKCODE' * 'ENT2' 'C' ' '. "SLS000342 '/00' 'C' ' '. "SLS000342 * Begin of change by rnandi65 for E2-SLS00000922 on 02/22/2011 IF l_bdc = 'X'. PERFORM bdc_dynpro USING 'SAPMV50A' '1000'. PERFORM bdc_field USING 'BDC_OKCODE' '=HPAR_T' 'C' ' '. PERFORM bdc_dynpro USING 'SAPMV50A' '2000'. IF l_modify = 'A'. * Get the index to add the new ZC partner if no entry in the delivery exists. CLEAR l_tabix. DESCRIBE TABLE li_vbpa LINES l_tabix. l_tabix = l_tabix + 1. l_num = l_tabix. l_tab_char = l_num. PERFORM bdc_field USING 'GVS_TC_DATA-REC-PARVW (*)' 'ZC' 'C' l_tab_char. ELSEIF l_modify = 'C'. l_num = l_tabix. l_tab_char = l_num. ENDIF. PERFORM bdc_field PERFORM bdc_field USING 'GVS_TC_DATA-REC-PARTNER (*)' w_e1edka2-partn 'C' l_tab_char. USING 'BDC_OKCODE' '=BACK_T' 'C' ' '.

ENDIF. * End of change by rnandi65 for E2-SLS00000922 on 02/22/2011 * Prepare dynpro '0200' program 'SAPMV50A'. PERFORM bdc_dynpro USING 'SAPMV50A' '0200'. "SLS000342 PERFORM bdc_dynpro USING 'SAPMV50A' '1000'. "SLS000342 PERFORM bdc_field USING 'BDC_OKCODE' '=T\06' 'C' ' '. "SLS000342 * 02/07/2001: function code WADI doesn't exist in transaction VL02N * 'WADI' 'C' ' '. "SLS000342 * Prepare dynpro '0301' program 'SAPMV50A'. * PERFORM BDC_DYNPRO USING 'SAPMV50A' '0301'. "SLS000342 PERFORM bdc_dynpro USING 'SAPMV50A' '1000'. "SLS000342 PERFORM bdc_field USING 'LIKP-WADAT_IST' h_gidat 'D' ' '. PERFORM bdc_field USING 'BDC_OKCODE' "SLS000342 '=T\02' 'C' ' '. "SLS000342 PERFORM bdc_dynpro USING 'SAPMV50A' '1000'. "SLS000342 PERFORM bdc_field USING 'BDC_OKCODE' "SLS000342 'WABU_T' 'C' ' '. "SLS000342 PERFORM bdc_dynpro USING 'SAPMV50A' '1000'. "SLS000342 PERFORM bdc_field USING 'BDC_OKCODE' "SLS000342 'SICH_T' 'C' ' '. "SLS000342 * 02/07/2001: function code WABI doesn't exist in transaction VL02N * 'WABI' 'C' ' '. "SLS000342

* *

Execute transaction VL02. PERFORM CALL_TRANSACTION USING 'VL02' INPUT_METHOD 'S'. "SLS000342 PERFORM call_transaction USING 'VL02N' input_method 'S'. "SLS000342 IF sy-subrc EQ 0. READ TABLE bdcmsg WITH KEY msgtyp = 'E'. "SLS000342 IF sy-subrc NE 0. "SLS000342 updatesucceeded = 'X'. deliverynumber = h_vbeln. "SLS000342 ELSE. "SLS000342 updatesucceeded = ' '. "SLS000342 ENDIF. "SLS000342 **--** Start of insertion 06.04.2000 **-------------------------------** * if h_automatic eq 'X'. "D0001 ** Trigger YLGRPO "D0001 ** get sender and receiver information "D0001 * read table idoc_contrl index 1. "D0001 * "D0001 * loop at itab_ylgrpo. "D0001 * "D0001 * refresh t_idoc_data. "D0001 * "D0001 ** fill control record "D0001 * clear t_idoc_control. "D0001 * refresh t_idoc_control. "D0001 * t_idoc_control-tabnam = 'EDI_DC'. "D0001 * t_idoc_control-mandt = sy-mandt. "D0001 * t_idoc_control-docrel = sy-saprl. "D0001 * t_idoc_control-direct = '2'. "D0001 * t_idoc_control-mestyp = 'YLGRPO'. "D0001 * t_idoc_control-sndpor = idoc_contrl-sndpor. "D0001 * t_idoc_control-sndprt = idoc_contrl-sndprt. "D0001 * t_idoc_control-sndprn = idoc_contrl-sndprn. "D0001 * t_idoc_control-rcvpor = idoc_contrl-rcvpor. "D0001 * t_idoc_control-rcvprt = idoc_contrl-rcvprt. "D0001 * t_idoc_control-rcvprn = idoc_contrl-rcvprn. "D0001 * t_idoc_control-serial = sy-datum. "D0001 * t_idoc_control-serial+8 = sy-uzeit. "D0001 * t_idoc_control-doctyp = 'ZWMMID01'. "D0001 * t_idoc_control-cimtyp = 'ZWMMID01'. "D0001 * t_idoc_control-idoctyp = 'WMMBID01'. "D0001 * append t_idoc_control. "D0001 * "D0001 ** fill data records "D0001 * clear s_e1mbxyh. "D0001 * s_e1mbxyh-bldat = space. "D0001 * s_e1mbxyh-budat = h_gidat. "D0001 * "D0001 * clear t_idoc_data. "D0001 * t_idoc_data-segnam = 'E1MBXYH'. "D0001 * move s_e1mbxyh to t_idoc_data-sdata. "D0001 * append t_idoc_data. "D0001 * "D0001 * clear s_e1mbxyi. "D0001 * s_e1mbxyi-matnr = itab_ylgrpo-matnr. "D0001 * s_e1mbxyi-werks = itab_ylgrpo-werks. "D0001 * s_e1mbxyi-lgort = itab_ylgrpo-lgort. "D0001 * s_e1mbxyi-charg = itab_ylgrpo-charg. "D0001 * s_e1mbxyi-ebeln = itab_ylgrpo-ebeln. "D0001 * s_e1mbxyi-ebelp = itab_ylgrpo-ebelp. "D0001 * s_e1mbxyi-bwart = '101'. "D0001

* s_e1mbxyi-insmk = 'S'. "D0001 * s_e1mbxyi-erfme = itab_ylgrpo-vrkme. "D0001 * s_e1mbxyi-erfmg = itab_ylgrpo-lfimg. "D0001 * s_e1mbxyi-elikz = itab_ylgrpo-elikz. "D0001 * "D0001 * clear t_idoc_data. "D0001 * t_idoc_data-segnam = 'E1MBXYI'. "D0001 * move s_e1mbxyi to t_idoc_data-sdata. "D0001 * append t_idoc_data. "D0001 * "D0001 ** send idoc. "D0001 * call function 'INBOUND_IDOC_PROCESS' "D0001 * tables "D0001 * idoc_control = t_idoc_control "D0001 * idoc_data = t_idoc_data "D0001 * exceptions "D0001 * others = 1. "D0001 * "D0001 * endloop. "D0001 * "D0001 * endif. "D0001 **--** End of insertion 06.04.2000 **---------------------------------** ELSE. updatesucceeded = ' '. ENDIF. ENDIF. * Copy messages bdcmsg into errormessages. errormessages[] = bdcmsg[]. ENDFUNCTION.