SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

RFC Purchase Order Change



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Sep 07, 2007 5:19 pm    Post subject: RFC Purchase Order Change Reply with quote

Author: Aveek Ghose

* This function module is called during PO change in Ariba.
* The call to this function module is from WebMethods. The function
* module performs custom validations on data provided from Ariba and
* then calls BAPI_PO_CHANGE. The error messages are returned to Ariba.

Code:
FUNCTION Z_BC1_BAPI_PO_CHANGE02.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(PURCHASEORDER) TYPE  BAPIMEPOHEADER-PO_NUMBER
*"     REFERENCE(POADDRVENDOR) TYPE  BAPIMEPOADDRVENDOR
*"     REFERENCE(TESTRUN) TYPE  BAPIFLAG-BAPIFLAG
*"     REFERENCE(MEMORY_UNCOMPLETE) TYPE  BAPIFLAG-BAPIFLAG
*"     REFERENCE(MEMORY_COMPLETE) TYPE  BAPIFLAG-BAPIFLAG
*"     REFERENCE(POEXPIMPHEADER) TYPE  BAPIEIKP
*"     REFERENCE(POEXPIMPHEADERX) TYPE  BAPIEIKPX
*"     REFERENCE(VERSIONS) TYPE  BAPIMEDCM
*"     REFERENCE(NO_MESSAGING) TYPE  BAPIFLAG-BAPIFLAG
*"     REFERENCE(NO_MESSAGE_REQ) TYPE  BAPIFLAG-BAPIFLAG
*"     REFERENCE(NO_AUTHORITY) TYPE  BAPIFLAG-BAPIFLAG
*"     REFERENCE(NO_PRICE_FROM_PO) TYPE  BAPIFLAG-BAPIFLAG
*"  EXPORTING
*"     REFERENCE(EXPHEADER) TYPE  BAPIMEPOHEADER
*"     REFERENCE(EXPPOEXPIMPHEADER) TYPE  BAPIEIKPX
*"  TABLES
*"      RETURN STRUCTURE  BAPIRET2
*"      POITEM STRUCTURE  BAPIMEPOITEM
*"      POITEMX STRUCTURE  BAPIMEPOITEMX
*"      POADDRDELIVERY STRUCTURE  BAPIMEPOADDRDELIVERY
*"      POSCHEDULE STRUCTURE  BAPIMEPOSCHEDULE
*"      POSCHEDULEX STRUCTURE  BAPIMEPOSCHEDULX
*"      POACCOUNT STRUCTURE  BAPIMEPOACCOUNT
*"      POACCOUNTPROFITSEGMENT STRUCTURE  BAPIMEPOACCOUNTPROFITSEGMENT
*"      POACCOUNTX STRUCTURE  BAPIMEPOACCOUNTX
*"      POCONDHEADER STRUCTURE  BAPIMEPOCONDHEADER
*"      POCONDHEADERX STRUCTURE  BAPIMEPOCONDHEADERX
*"      POCOND STRUCTURE  BAPIMEPOCOND
*"      POCONDX STRUCTURE  BAPIMEPOCONDX
*"      POLIMITS STRUCTURE  BAPIESUHC
*"      POCONTRACTLIMITS STRUCTURE  BAPIESUCC
*"      POSERVICES STRUCTURE  BAPIESLLC
*"      POSRVACCESSVALUES STRUCTURE  BAPIESKLC
*"      POSERVICESTEXT STRUCTURE  BAPIESLLTX
*"      EXTENSIONIN STRUCTURE  BAPIPAREX
*"      EXTENSIONOUT STRUCTURE  BAPIPAREX
*"      POEXPIMPITEM STRUCTURE  BAPIEIPO
*"      POEXPIMPITEMX STRUCTURE  BAPIEIPOX
*"      POTEXTHEADER STRUCTURE  BAPIMEPOTEXTHEADER
*"      POTEXTITEM STRUCTURE  BAPIMEPOTEXT
*"      ALLVERSIONS STRUCTURE  BAPIMEDCM_ALLVERSIONS
*"      POPARTNER STRUCTURE  BAPIEKKOP
*"      POCOMPONENTS STRUCTURE  BAPIMEPOCOMPONENT
*"      POCOMPONENTSX STRUCTURE  BAPIMEPOCOMPONENTX
*"      POSHIPPING STRUCTURE  BAPIITEMSHIP
*"      POSHIPPINGX STRUCTURE  BAPIITEMSHIPX
*"      POSHIPPINGEXP STRUCTURE  BAPIMEPOSHIPPEXP
*"      POHISTORY STRUCTURE  BAPIEKBE
*"      POHISTORY_TOTALS STRUCTURE  BAPIEKBES
*"      POCONFIRMATION STRUCTURE  BAPIEKES
*"      NFMETALLITMS STRUCTURE  /NFM/BAPIDOCITM
*"  CHANGING
*"     REFERENCE(POHEADER) TYPE  BAPIMEPOHEADER
*"     REFERENCE(POHEADERX) TYPE  BAPIMEPOHEADERX
*"----------------------------------------------------------------------
************************************************************************
* PROGRAM        Z_BC1_BAPI_PO_CHANGE
* TITLE          Function module to Change PO using BAPI
* AUTHOR         Aveek Ghose
* DATE WRITTEN   24.05.2006
* R/3 RELEASE    4.6C
*-----------------------------------------------------------------------
* COPIED FROM    N/A
*
* This function module is called during PO change in Ariba.
* The call to this function module is from WebMethods. The function
* module performs custom validations on data provided from Ariba and
* then calls BAPI_PO_CHANGE. The error messages are returned to Ariba.
*
*-----------------------------------------------------------------------
* PROGRAM TYPE    Function module
* DEV. CLASS      ZP2P
* LOGICAL DB      N/A
*-----------------------------------------------------------------------
* SCREENS         N/A
* GUl TITLE       N/A
* GUl STATUS      N/A
* TRANSACTIONS    N/A
* USER EXITS      N/A
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
*----------------------------------------------------------------------*
*        DB-Tables
*----------------------------------------------------------------------*
  TABLES: ekkn,        "Account Assignment in Purchasing Document
          ekbe.        "History per Purchasing Document
*         zconstants_new. "Constants for various interfaces
*                                & programs with comp code
*----------------------------------------------------------------------*
*        Global variables
*----------------------------------------------------------------------*
  DATA: g_cnt_poaccount   TYPE i,         "No. of records in POACCOUNT
        g_cnt_ekkn        TYPE i,         "No. of records in EKKN
        g_msgv1 LIKE sy-msgv1.            "Message variable1

*----------------------------------------------------------------------*
*        Internal Tables
*----------------------------------------------------------------------*
  DATA: g_t_poaccount_tmp LIKE poaccount  OCCURS 0 WITH HEADER LINE,
        g_t_poaccount1    LIKE poaccount  OCCURS 0 WITH HEADER LINE,
        g_t_poaccountx1   LIKE poaccountx OCCURS 0 WITH HEADER LINE,
        g_t_poaccount     LIKE poaccount  OCCURS 0 WITH HEADER LINE,

*PVU-20-May-2004 - Changes for SCR1
        g_t_itemx_tmp     LIKE poitemx      OCCURS 0 WITH HEADER LINE,
        g_t_schdx_tmp     LIKE poschedulex  OCCURS 0 WITH HEADER LINE,
        g_t_accntx_tmp    LIKE poaccountx   OCCURS 0 WITH HEADER LINE,
        g_t_condx_tmp     LIKE pocondx      OCCURS 0 WITH HEADER LINE.
*       T_Zconstants      LIKE ZCONSTANTS_NEW OCCURS 0 WITH HEADER LINE.
*RD1K911982

*PVU-20-May-2004 - End Changes for SCR1
*----------------------------------------------------------------------*
*        Structure
*----------------------------------------------------------------------*
  DATA:  g_w_hdrx_tmp LIKE poheaderx. "PVU-20-May-2004 - Changes for SCR1
*  DATA: p_constname TYPE  zconstname,  "Constant Name
*        g_constval  TYPE  zconstval,   "Constant Value
*        c_po_ehub_var LIKE ZCONSTANTS_NEW-CONSTname  value 'EHUB_POS%'.
  DATA : L_CONST_NAME  LIKE SY-MSGV1,   "Constant name
         L_COMP_CODE   LIKE SY-MSGV2.   "Company code
  DATA:  L_WA_TIMESTAMP TYPE ZPO_TIMESTAMP.
  data: l_waers type waers.
  DATA: L_EKORG TYPE EKORG.
  DATA: L_SERIAL TYPE I.

  DATA : L_VEND_ACTGRP(30) TYPE C,        "Vendor Account Group
         L_VEND_PAYTRM(30) TYPE C,        "Vendor Payment Terms
         L_VEND_RECON(30)  TYPE C,        "Vendor Reconciliation Account
         L_MSGV1           LIKE SY-MSGV1, "Message variable1
         L_WBS_EXTERNAL    LIKE BAPIMEPOACCOUNT-WBS_ELEMENT,
                                           "WBS external format
         L_WBS_INTERNAL    LIKE BAPIMEPOACCOUNT-WBS_ELEMENT,
         L_bukrs type bukrs.

**********************************************************
*mod-003
**********************************************************

*Clear internal tables and global variables
  REFRESH: g_t_poaccount_tmp,
           g_t_poaccount1,
           g_t_poaccountx1,
           g_t_poaccount,
           return,
*          g_t_idoc_data,
           g_t_itemx_tmp,
           g_t_schdx_tmp,
           g_t_accntx_tmp,
           g_t_condx_tmp.

  CLEAR: g_cnt_poaccount,
         g_cnt_ekkn,
         g_msgv1.
*        g_distr_perc,
*        g_distr_perc1,
*        g_adjust_perc,
*         g_idoc_no,
*         g_w_hdrx_tmp.

  IF poheader-po_number+0(1) = 'C'.
    poheader-doc_type = 'ZAC'.
  ENDIF.
  IF poheader-po_number+0(1) = 'P'.
    poheader-doc_type = 'ZAP'.
  ENDIF.
  IF poheader-po_number IS INITIAL.
    poheader-doc_type = 'ZAPS'.
  ENDIF.

  IF purchaseorder(3) <> c_pco.
    g_t_poaccount[] = poaccount[].
* To retrieve the line items with blank GL Account Number
*   PERFORM filter_items TABLES g_t_poaccount.
    LOOP AT g_t_poaccount.
      CLEAR g_msgv1.
      g_msgv1 = g_t_poaccount-po_item.
*   Please Enter an Account number for line
      CALL FUNCTION 'BALW_BAPIRETURN_GET2'
           EXPORTING
                type   = c_msgtype_e  "E
                cl     = c_msgid_z001                       "Z001
                number = c_msgnr_037  "037
                par1   = g_msgv1
           IMPORTING
                return = return.

      APPEND return.
      CLEAR  return.
      loop at return.
        l_wa_ZERRORS-OBJECT     = 'PURCHASE_ORDER'.
        l_wa_ZERRORS-serial_no   = sy-tabix.
        l_wa_ZERRORS-COMP_CODE  = poheader-comp_code.
        l_wa_ZERRORS-zid        = return-id.
        l_wa_ZERRORS-znumber    = return-number.
        l_wa_ZERRORS-BEACON_DOC_NO = poheader-po_number.
        l_wa_ZERRORS-SRC_DOC_NO = poheader-po_number.
        l_wa_ZERRORS-ZDATE      = sy-datum.
        l_wa_ZERRORS-ERROR_MSG    = return-message.
        append l_wa_ZERRORS to t_errors.
*       insert into ZP2P_ERRORS values l_wa_ZP2P_ERRORS.
        clear: L_WA_ZERRORS.
      endloop.
      CLEAR g_msgv1.
    ENDLOOP.

    SORT return BY type.
* On Error, exit the function module
    READ TABLE return
         WITH KEY type = c_msgtype_e               "E
         BINARY SEARCH.
    IF sy-subrc EQ 0.
      EXIT.
    ENDIF.

***Begin of Change - BVIJAYA  01-July-2004  TPR-2239
*  If line item is marked for deletion, Clear the final_inv indicator,
*  so that the condition value[conditions tab(po header)] reflects the
*  correct gross price for the remaining items.

    SORT poitem  BY po_item.
    SORT poitemx BY po_item.
    LOOP AT poitem.

      IF NOT poitem-delete_ind IS INITIAL.   "delete ind marked.
* sraman2 07/17/04
*For item deletion to work properly
*indicator should be 'D'. webmethods passes indicator 'X'.
        poitem-delete_ind = 'D'.
* sraman2 07/17/04
        CLEAR poitem-final_inv.
        MODIFY poitem.

        READ TABLE poitemx WITH KEY po_item = poitem-po_item.
        IF sy-subrc = 0.
          poitemx-final_inv = c_checked.   "X
          MODIFY poitemx INDEX sy-tabix.
        ENDIF.
      else.
      ENDIF.
    ENDLOOP.
  endif.

****************************************************
*mod-003
****************************************************
    DATA: L_TABIX TYPE SY-TABIX.
    LOOP AT POITEM.
      TBX = SY-TABIX.
      l_wa_timestamp-mandt          = SY-MANDT.
      l_wa_timestamp-EBELN          = POHEADER-PO_NUMBER.
      l_wa_timestamp-EBELP          = POITEM-PO_ITEM.
      l_wa_timestamp-CHANGE_IND     = ' '.
      l_wa_timestamp-DATE_TIME_STMP = POITEM-ARIBACRTTIMESTMP.
      insert into ZPO_TIMESTAMP values l_wa_timestamp.
      clear: poheader-ARIBACRTTIMESTMP,
             poheader-ARIBACHGTIMESTMP.

      IF NOT POITEM-DISTRIB IS INITIAL.
        CLEAR : L_CONST_NAME,
                L_COMP_CODE.

        READ TABLE POACCOUNT INDEX L_TABIX.
        IF SY-SUBRC EQ 0.
          L_CONST_NAME  = POACCOUNT-GL_ACCOUNT.
          L_COMP_CODE   = L_comp_code.
          CALL FUNCTION 'BALW_BAPIRETURN_GET2'
               EXPORTING
                    type   = c_msgtype_e  "E
                    cl     = c_msgid_z001
                    number = c_msgnr_613
                    PAR1   = L_CONST_NAME
                    PAR2   = L_COMP_CODE
               IMPORTING
                    return = t_yreturn.

          APPEND t_yreturn.
          CLEAR  t_yreturn.
          loop at t_yreturn.
            L_WA_ZERRORS-OBJECT       = 'PURCHASE_ORDER'.
            L_WA_ZERRORS-serial_no     = sy-tabix.
            L_WA_ZERRORS-COMP_CODE    = poheader-comp_code.
            L_WA_ZERRORS-zid          = t_yreturn-id.
            L_WA_ZERRORS-znumber      = t_yreturn-number.
            L_WA_ZERRORS-BEACON_DOC_NO = poheader-po_number.
            L_WA_ZERRORS-SRC_DOC_NO = poheader-po_number.
            L_WA_ZERRORS-ZDATE      = sy-datum.
            L_WA_ZERRORS-ERROR_MSG    = t_yreturn-message.
            append L_WA_ZERRORS to t_errors.
*         insert into ZP2P_ERRORS values L_WA_ZERRORS.
            clear: L_WA_ZERRORS.
          endloop.
        ENDIF.
      ENDIF.
    ENDLOOP.

    if not poheader-currency is initial.
      if not poheader-vendor is initial.
        loop at pocond.
          SELECT SINGLE WAERS
          INTO L_WAERS
          FROM LFM1 WHERE
          LIFNR = POHEADER-VENDOR
          AND EKORG = POHEADER-PURCH_ORG.

          IF SY-SUBRC NE 0.
            IF L_WAERS NE  poheader-currency.
              pocond-cond_value = 'PBXX'.
              pocond-currency    = l_waers.
              modify pocond transporting cond_value currency.
            endif.
          ENDIF.
        endloop.
      ENDIF.
    ENDIF.

    IF NOT TESTRUN IS INITIAL.
      POHEADER-VENDOR = '4259999999'.
      poheader-doc_type = 'ZAPS'.
    ENDIF.


**********************************************************
*mod-003
***********************************************************

    if not poheader-currency is initial.
      if not poheader-vendor is initial.
        loop at pocond.
          SELECT SINGLE WAERS
          INTO L_WAERS
          FROM LFM1 WHERE
          LIFNR = POHEADER-VENDOR
          AND EKORG = POHEADER-PURCH_ORG.

          IF SY-SUBRC NE 0.
            IF L_WAERS NE  poheader-currency.
              pocond-cond_value = 'PBXX'.
              pocond-currency    = l_waers.
              modify pocond transporting cond_value currency.
            endif.
          ENDIF.
        endloop.
      ENDIF.
    ENDIF.

    IF NOT TESTRUN IS INITIAL.
      POHEADER-VENDOR = '4259999999'.
      poheader-doc_type = 'ZAPS'.
    ENDIF.

**********************************************************
*mod-003
***********************************************************
*-- Retrieve Account Assignment
    PERFORM get_account_assignment TABLES   poitem
                                            poitemx
                                            poaccount
                                            poaccountx
                                            t_yreturn
                                   USING    poheader-comp_code
                                            poheader.

****************************************************
*mod-003
****************************************************
    IF NOT t_yreturn[] IS INITIAL.
      APPEND LINES OF t_yreturn TO RETURN.
      loop at return.
        L_WA_ZERRORS-OBJECT     = 'PURCHASE_ORDER'.
        L_WA_ZERRORS-serial_no   = sy-tabix.
        L_WA_ZERRORS-COMP_CODE  = poheader-comp_code.
        L_WA_ZERRORS-zid        = return-id.
        L_WA_ZERRORS-znumber    = return-number.
        L_WA_ZERRORS-BEACON_DOC_NO = poheader-po_number.
        L_WA_ZERRORS-SRC_DOC_NO = poheader-po_number.
        L_WA_ZERRORS-ZDATE      = sy-datum.
        L_WA_ZERRORS-ERROR_MSG    = return-message.
        append L_WA_ZERRORS to t_errors.
        clear: L_WA_ZERRORS.
      endloop.

      SELECT max( serial_no )
         INTO L_SERIAL
         FROM ZP2P_ERRORS.

      LOOP AT T_ERRORS.
        L_SERIAL = L_SERIAL + 1.
        T_ERRORS-serial_no = L_SERIAL.
        MODIFY T_ERRORS TRANSPORTING serial_no.
      ENDLOOP.
      INSERT ZP2P_ERRORS FROM TABLE T_ERRORS.
    ENDIF.

    READ TABLE t_yreturn WITH KEY type = 'E'.
    IF sy-subrc = 0.
      EXIT.
    ENDIF.

*For Non-PCO Orders, do not update the GR and IR Indicator if the
*indicator passed in the current run is same as in PO.
  SORT poitem BY po_item.
  SORT poitemx BY po_item.
  LOOP AT poitem.
    SELECT SINGLE wepos                  "Goods receipt indicator
                  repos                  "Invoice receipt indicator
    INTO (ekpo-wepos, ekpo-repos)
    FROM ekpo
    WHERE ebeln = purchaseorder AND
          ebelp = poitem-po_item.

    IF sy-subrc EQ 0.
      IF ekpo-wepos EQ poitem-gr_ind.
        READ TABLE poitemx
             WITH KEY po_item = poitem-po_item
             BINARY SEARCH.
        IF sy-subrc EQ 0.
          CLEAR poitemx-gr_ind.
          MODIFY poitemx INDEX sy-tabix.
        ENDIF.
      ENDIF.

      IF ekpo-repos EQ poitem-ir_ind.
        READ TABLE poitemx
              WITH KEY po_item = poitem-po_item
              BINARY SEARCH.
        IF sy-subrc EQ 0.
          CLEAR poitemx-ir_ind.
          MODIFY poitemx INDEX sy-tabix.
        ENDIF.
      ENDIF.
    ENDIF.
  ENDLOOP.

*Logic for addition, deletion and change of records in
*account assignment

  LOOP AT poaccount.

    CLEAR  g_t_poaccount_tmp.
    MOVE-CORRESPONDING poaccount TO g_t_poaccount_tmp.
    APPEND g_t_poaccount_tmp.
    ADD 1 TO g_cnt_poaccount.

    AT END OF po_item.
      SORT g_t_poaccount_tmp.
* For single account assignment, if the goods receipt is not posted,
* set the non-valuated indicator to blank.
      IF g_cnt_poaccount EQ 1.
        SELECT belnr                 "History per Purchasing Document
        INTO ekbe-belnr
        FROM ekbe
        UP TO 1 ROWS
        WHERE ebeln = purchaseorder AND
              ebelp = g_t_poaccount_tmp-po_item AND
              vgabe = 1.
        ENDSELECT.
        IF sy-subrc NE 0.
*PVU-08-May-2004 - Set the no valuated GR indicator to blank in POITEM
          READ TABLE poitem
               WITH KEY po_item = g_t_poaccount_tmp-po_item
               BINARY SEARCH.
          IF sy-subrc EQ 0.
            CLEAR poitem-gr_non_val .
            MODIFY poitem INDEX sy-tabix.
          ENDIF.
*PVU-08-May-2004 - End of Set the no valuated GR indicator to blank
          READ TABLE poitemx
               WITH KEY po_item = g_t_poaccount_tmp-po_item
               BINARY SEARCH.
          IF sy-subrc EQ 0.
            poitemx-gr_non_val = c_checked.
            MODIFY poitemx INDEX sy-tabix.
          ENDIF.
        ENDIF.
      ENDIF.

      CLEAR: ekkn.

      SELECT * FROM ekkn
      WHERE ebeln = purchaseorder AND
            ebelp = poaccount-po_item
      ORDER BY zekkn.

        ADD 1 TO g_cnt_ekkn.

**BV-12-July-2004- Begin of change - split line accounting
*clear the headerline before data population
        CLEAR : g_t_poaccount1,
                g_t_poaccountx1.
**BV-12-July-2004- End of change - split line accounting

        READ TABLE g_t_poaccount_tmp INDEX g_cnt_ekkn.

        IF sy-subrc EQ 0.
          g_t_poaccount1-po_item     = g_t_poaccount_tmp-po_item.
          g_t_poaccount1-serial_no   = ekkn-zekkn.
          g_t_poaccount1-quantity    = g_t_poaccount_tmp-quantity.
          g_t_poaccount1-gl_account  = g_t_poaccount_tmp-gl_account.
          READ TABLE poitem
               WITH KEY po_item = poaccount-po_item. "dd
*PVU-11-May-2004-Set cost center or WBS element depending on acc.assgn.
          IF poitem-acctasscat = c_costcenter.                   "K
            g_t_poaccount1-costcenter  = g_t_poaccount_tmp-costcenter .
          ELSEIF poitem-acctasscat = c_wbs.                      "P
            g_t_poaccount1-wbs_element = g_t_poaccount_tmp-wbs_element.
          ENDIF.
*PVU-11-May-2004-End of set cost center or WBS element.
          g_t_poaccount1-orderid     = g_t_poaccount_tmp-orderid.
          g_t_poaccount1-distr_perc  = g_t_poaccount_tmp-distr_perc.

          APPEND g_t_poaccount1.

          g_t_poaccountx1-po_item    = g_t_poaccount_tmp-po_item.
          g_t_poaccountx1-serial_no  = ekkn-zekkn.
          g_t_poaccountx1-po_itemx   = c_checked.
          g_t_poaccountx1-quantity   = c_checked.
          g_t_poaccountx1-gl_account = c_checked.
*PVU-11-May-2004-Set cost center or WBS element depending on acc.assgn.
          IF poitem-acctasscat = c_costcenter.                   "K
            g_t_poaccountx1-costcenter = c_checked.
          ELSEIF poitem-acctasscat = c_wbs.                      "P
            g_t_poaccountx1-wbs_element = c_checked.
          ENDIF.
*PVU-11-May-2004-End of set cost center or WBS element.
          g_t_poaccountx1-orderid    = c_checked.
          g_t_poaccountx1-distr_perc = c_checked.

          APPEND g_t_poaccountx1.
*If line is deleted from account assignment in Ariba
*then delete that line from SAP PO
        ELSE.
          g_t_poaccount1-po_item     = g_t_poaccount_tmp-po_item.
          g_t_poaccount1-serial_no   = ekkn-zekkn.
          g_t_poaccount1-delete_ind  = c_checked.
          g_t_poaccount1-quantity    = ekkn-menge.
          g_t_poaccount1-gl_account  = ekkn-sakto.
*PVU-11-May-2004-Set cost center or WBS element depending on acc.assgn.
          IF poitem-acctasscat = c_costcenter.                   "K
            g_t_poaccount1-costcenter  = ekkn-kostl.
          ELSEIF poitem-acctasscat = c_wbs.                      "P
            g_t_poaccount1-wbs_element = ekkn-ps_psp_pnr.
          ENDIF.
*PVU-11-May-2004-End of set cost center or WBS element.
          g_t_poaccount1-orderid     = ekkn-aufnr.

          APPEND g_t_poaccount1.

          g_t_poaccountx1-po_item     = g_t_poaccount_tmp-po_item.
          g_t_poaccountx1-serial_no   = ekkn-zekkn.
          g_t_poaccountx1-po_itemx    = c_checked.
          g_t_poaccountx1-delete_ind  = c_checked.
          g_t_poaccountx1-quantity    = c_checked.
          g_t_poaccountx1-gl_account  = c_checked.
*PVU-11-May-2004-Set cost center or WBS element depending on acc.assgn.
          IF poitem-acctasscat = c_costcenter.                   "K
            g_t_poaccountx1-costcenter  = c_checked.
          ELSEIF poitem-acctasscat = c_wbs.                      "P
            g_t_poaccountx1-wbs_element = c_checked.
          ENDIF.
*PVU-11-May-2004-End of set cost center or WBS element.
          g_t_poaccountx1-orderid     = c_checked.

          APPEND g_t_poaccountx1.

        ENDIF.

        SUBTRACT 1 FROM g_cnt_poaccount.

      ENDSELECT.

**BV-12-July-2004- Begin of change - split line accounting
*clear the headerline before data population
      CLEAR : g_t_poaccount1,
              g_t_poaccountx1.
**BV-12-July-2004- End of change  - split line accounting

* If new lines are added to account assignment in Ariba
* add those lines to SAP PO
      IF g_cnt_poaccount GT 0.
        g_cnt_ekkn = ekkn-zekkn.

        SORT g_t_poaccount_tmp DESCENDING BY serial_no.
        LOOP AT g_t_poaccount_tmp.
          ADD 1 TO g_cnt_ekkn.

          g_t_poaccount1-po_item     = g_t_poaccount_tmp-po_item.
          g_t_poaccount1-serial_no   = g_cnt_ekkn.
          g_t_poaccount1-quantity    = g_t_poaccount_tmp-quantity.
          g_t_poaccount1-gl_account  = g_t_poaccount_tmp-gl_account.
*PVU-11-May-2004-Set cost center or WBS element depending on acc.assgn.
          IF poitem-acctasscat = c_costcenter.                   "K
            g_t_poaccount1-costcenter  = g_t_poaccount_tmp-costcenter.
          ELSEIF poitem-acctasscat = c_wbs.                      "P
            g_t_poaccount1-wbs_element = g_t_poaccount_tmp-wbs_element.
          ENDIF.
*PVU-11-May-2004-End of set cost center or WBS element.
          g_t_poaccount1-orderid     = g_t_poaccount_tmp-orderid.
          g_t_poaccount1-distr_perc  = g_t_poaccount_tmp-distr_perc.
          APPEND g_t_poaccount1.

          g_t_poaccountx1-po_item    = g_t_poaccount_tmp-po_item.
          g_t_poaccountx1-serial_no  = g_cnt_ekkn.
          g_t_poaccountx1-po_itemx   = c_checked.
          g_t_poaccountx1-quantity   = c_checked.
          g_t_poaccountx1-gl_account = c_checked.
*PVU-11-May-2004-Set cost center or WBS element depending on acc.assgn.
          IF poitem-acctasscat = c_costcenter.                   "K
            g_t_poaccountx1-costcenter = c_checked.
          ELSEIF poitem-acctasscat = c_wbs.                      "P
            g_t_poaccountx1-wbs_element = c_checked.
          ENDIF.
*PVU-11-May-2004-End of set cost center or WBS element.
          g_t_poaccountx1-orderid    = c_checked.
          g_t_poaccountx1-distr_perc = c_checked.
          APPEND g_t_poaccountx1.

          SUBTRACT 1 FROM g_cnt_poaccount.

          IF g_cnt_poaccount EQ 0.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDIF.
      CLEAR: g_cnt_poaccount, g_cnt_ekkn.
      REFRESH g_t_poaccount_tmp.
    ENDAT.

  ENDLOOP.

  REFRESH: poaccount, poaccountx.
  CLEAR:   poaccount, poaccountx.

  APPEND LINES OF g_t_poaccount1 TO poaccount.
  APPEND LINES OF g_t_poaccountx1 TO poaccountx.

  REFRESH: g_t_poaccount1, g_t_poaccountx1.
  SORT: poaccount, poaccountx.

*For POs Converted from legacy system, populate the item quantity and
*price based on the original purchase order qty/price. Also, populate
*the actual qty and price passed by Ariba in the Net weight and gross
*weight fields.
  LOOP AT poitem.
    CLEAR: ekpo.
    SELECT SINGLE menge                    "Purchase order quantity
                  netpr                    "Net price in PO
    INTO (ekpo-menge, ekpo-netpr)
    FROM ekpo
    WHERE  ebeln EQ purchaseorder   AND
           ebelp EQ poitem-po_item. "AND
    IF sy-subrc EQ 0.

* Turn off Final Invoice Indicator if net price or quantity is higher
* than the existing value.
      IF poitem-quantity  GT ekpo-menge OR
         poitem-net_price GT ekpo-netpr.
        CLEAR poitem-final_inv.
        READ TABLE poitemx
             WITH KEY po_item = poitem-po_item
             BINARY SEARCH.
        IF sy-subrc EQ 0.
          poitemx-final_inv   = c_checked.
          MODIFY poitemx INDEX sy-tabix.
        ENDIF.
      ENDIF.

      MODIFY poitem.
    ENDIF.
  ENDLOOP.
*endif.

****Start of changes by Balaji V - 08-June-04
****Zero Pad and Prefix 1 to Vendor.
  DATA : L_LENGTH   TYPE I.
  "Vendor string length.
*         L_MSGV1    LIKE SY-MSGV1. "Message variable1

  IF NOT POHEADER-VENDOR IS INITIAL.

*remove any leading zeros for vendor populated from webmethods
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
         EXPORTING
              INPUT  = POHEADER-VENDOR
         IMPORTING
              OUTPUT = POHEADER-VENDOR.

    L_LENGTH = STRLEN( POHEADER-VENDOR ).

    IF L_LENGTH < 10.

*To pad leading zeros to Vendor
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
           EXPORTING
                INPUT  = POHEADER-VENDOR
           IMPORTING
                OUTPUT = POHEADER-VENDOR.

*To replace first character with 1.
      MOVE '1' TO POHEADER-VENDOR(1).

    ELSE.       "Vendor is 10 char in length

      CLEAR L_MSGV1.
      L_MSGV1 = POHEADER-VENDOR.
*Zero Padding and Prefixing 1 Not possible.Vendor is 10 Character
*length
      CALL FUNCTION 'BALW_BAPIRETURN_GET2'
           EXPORTING
                TYPE   = C_MSGTYPE_I  "I
                CL     = C_MSGID_Z001                       "Z001
                NUMBER = C_MSGNR_040  "040
                PAR1   = L_MSGV1
           IMPORTING
                RETURN = RETURN.

      APPEND RETURN.
      CLEAR  RETURN.
      loop at return.
        L_WA_ZERRORS-OBJECT     = 'PURCHASE_ORDER'.
        L_WA_ZERRORS-serial_no   = sy-tabix.
        L_WA_ZERRORS-COMP_CODE  = poheader-comp_code.
        L_WA_ZERRORS-zid        = return-id.
        L_WA_ZERRORS-znumber    = return-number.
        L_WA_ZERRORS-BEACON_DOC_NO = poheader-po_number.
        L_WA_ZERRORS-SRC_DOC_NO = poheader-po_number.
        L_WA_ZERRORS-ZDATE      = sy-datum.
        L_WA_ZERRORS-ERROR_MSG    = return-message.
        append L_WA_ZERRORS to t_errors.
*   insert into ZP2P_ERRORS values L_WA_ZERRORS.
        clear: L_WA_ZERRORS.
      endloop.

    ENDIF.

  ENDIF.
****End of changes by Balaji V - 08-June-04


**********************************************************
*mod-003
***********************************************************

  if not poheader-currency is initial.
    if not poheader-vendor is initial.
      loop at pocond.
        SELECT SINGLE WAERS
        INTO L_WAERS
        FROM LFM1 WHERE
        LIFNR = POHEADER-VENDOR
        AND EKORG = POHEADER-PURCH_ORG.

        IF SY-SUBRC NE 0.
          IF L_WAERS NE  poheader-currency.
            pocond-cond_value = 'PBXX'.
            pocond-currency    = l_waers.

            modify pocond transporting cond_value currency.
          endif.
        ENDIF.
      endloop.
    ENDIF.
  ENDIF.
**********************************************************
*mod-003
***********************************************************
*  IF NOT TESTRUN IS INITIAL.
*    POHEADER-VENDOR = '4259999999'.
*    poheader-doc_type = 'ZAP'.
*  ENDIF.
**********************************************************
*mod-003
**********************************************************
  LOOP AT POITEM.
    l_wa_timestamp-mandt          = SY-MANDT.
    l_wa_timestamp-EBELN          = POHEADER-PO_NUMBER.
    l_wa_timestamp-EBELP          = POITEM-PO_ITEM.
    l_wa_timestamp-CHANGE_IND     = ' '.
    l_wa_timestamp-DATE_TIME_STMP = POHEADER-ARIBACHGTIMESTMP.
    insert into ZPO_TIMESTAMP values l_wa_timestamp.
  ENDLOOP.

  DATA: g_constval(10) type c.

  IF NOT POHEADER-PUR_GROUP IS INITIAL.
    clear: g_constval.
    CALL FUNCTION 'ZXA_GET_CONSTANT'
         EXPORTING
              const_name     = c_p2p_pur_org
              comp_code      = POHEADER-COMP_CODE
         IMPORTING
              const_value    = g_constval
         EXCEPTIONS
              no_value_found = 1
              null_value     = 2
              OTHERS         = 3.

    IF SY-SUBRC NE 0.
      CLEAR : L_CONST_NAME,
              L_COMP_CODE.

      L_CONST_NAME  = C_p2p_pur_org.
      L_COMP_CODE   = POHEADER-COMP_CODE.

      CALL FUNCTION 'BALW_BAPIRETURN_GET2'
           EXPORTING
                TYPE   = c_msgtype_e
                CL     = c_msgid_z001
                NUMBER = c_msgnr_619
                PAR1   = L_CONST_NAME
                PAR2   = L_COMP_CODE
           IMPORTING
                RETURN = RETURN.

      APPEND RETURN.
      CLEAR  RETURN.

      loop at return.
        L_WA_ZERRORS-OBJECT     = 'PURCHASE_ORDER'.
        L_WA_ZERRORS-serial_no   = sy-tabix.
        L_WA_ZERRORS-COMP_CODE  = poheader-comp_code.
        L_WA_ZERRORS-zid        = return-id.
        L_WA_ZERRORS-znumber    = return-number.
        L_WA_ZERRORS-BEACON_DOC_NO = poheader-po_number.
        L_WA_ZERRORS-SRC_DOC_NO = poheader-po_number.
        L_WA_ZERRORS-ZDATE      = sy-datum.
        L_WA_ZERRORS-ERROR_MSG    = return-message.
        append L_WA_ZERRORS to t_errors.
*   insert into ZP2P_ERRORS values L_WA_ZERRORS.
        clear: L_WA_ZERRORS.
      endloop.
      EXIT.
    ELSE.
      POHEADER-PUR_GROUP = G_CONSTVAL.
    ENDIF.
  ENDIF.
**********************************************************
*mod-003
**********************************************************
  IF purchaseorder(3) = c_pco.                       "PCO
*&------------------------------------------------------*&
*& Begin of Change: 26-Sep-2005 SDUTTARO RD1K910989     *&
*&------------------------------------------------------*&
*   Map the external fields for ALZA with account assignment
*    IF poheader-comp_code = c_bukrs_alza.                          "@SDR
**--    Retrieve Account Assignment
      PERFORM get_account_assignment TABLES   poitem              "@SDR
                                              poitemx             "@SDR
                                              poaccount           "@SDR
                                              poaccountx          "@SDR
                                              t_yreturn           "@SDR
                                     USING    poheader-comp_code  "@SDR
                                              poheader.           "@SDR

  ENDIF.
*
*-- Round off to 100 percent due to small difference in one decimal
*-- point rounding (in Ariba/wM)
  SORT poaccount BY po_item distr_perc.
  LOOP AT poaccount.
    ADD poaccount-distr_perc TO g_distr_perc.
    AT END OF po_item.
*-- Round off to 100 percent due to small difference in one decimal
*-- point rounding (in Ariba/wM)
      IF g_distr_perc GT 0.
        g_distr_perc = 100 - g_distr_perc.
        g_adjust_perc = c_checked.
      ENDIF.
    ENDAT.
    IF g_adjust_perc = c_checked.
      g_distr_perc1 = g_distr_perc + poaccount-distr_perc.
      IF g_distr_perc1 = 100.
        poaccount-distr_perc = 0.
      ELSE.
        poaccount-distr_perc = g_distr_perc1.
      ENDIF.
      MODIFY poaccount.
      CLEAR poaccount.
      CLEAR: g_distr_perc, g_distr_perc1.
    ENDIF.
    CLEAR g_adjust_perc.
  ENDLOOP.
  SORT poaccount.

  SORT poschedule BY po_item sched_line.
  SORT poschedulex BY po_item sched_line.

*PVU-20-May-2004 - Start Changes for SCR1

***************************************************
**MOD-003
**************************************************
*Populate the change indicator structures before calling BAPI_PO_CHANGE
*so that IDOC can be populated with this data
  IF NOT poheaderx IS INITIAL.
    g_w_hdrx_tmp = poheaderx.
  ENDIF.
  IF NOT poitemx[] IS INITIAL.
    g_t_itemx_tmp[] = poitemx[].
  ENDIF.
  IF NOT poschedulex[] IS INITIAL.
    g_t_schdx_tmp[] = poschedulex[].
  ENDIF.
  IF NOT poaccountx[] IS INITIAL.
    g_t_accntx_tmp[] = poaccountx[].
  ENDIF.
  IF NOT pocondx[] IS INITIAL.
    g_t_condx_tmp[] = pocondx[].
  ENDIF.
***************************************************
**MOD-003
**************************************************

*PVU-20-May-2004 - End Changes for SCR1

*sraman2 06/28/04
*-- Default the Material Group to 99 if the incoming commodity
*-- code don't exist in SAP
  LOOP AT poitem.
    SELECT SINGLE matkl INTO t023-matkl FROM t023
      WHERE matkl = poitem-matl_group.
    IF sy-subrc NE 0.
      MOVE: '99' TO poitem-matl_group.
      MODIFY poitem.
    ENDIF.
    CLEAR  poitem.
  ENDLOOP.
*sraman2 06/28/04

*&---Begin of Addition: Soumya D Roy: 03/27/2006

* Logic for PO changes which are listed in table ZCONVERTEDPOS.
* ZCONVERTEDPOS contains Purchase Orders ie. both Material and
* Service which have either NONVAL GR checked or GR checked respectively
* and are invoiced. Any changes to these POs from Ariba would not let
* other quantity or amount or text description changes to flow into SAP.
* This piece of code will keep the Indicators' status same as in SAP
* and also let the user perform the change.
*Begin of change by svalidet RD1K911990
*  IF purchaseorder+0(3) = '099'.
*  IF purchaseorder+0(3) in r_ehub_pos[].
*End of change by svalidet RD1K911990

    CALL FUNCTION 'Z_CONVERTED_POS'
         EXPORTING
              P_PURCHASEORDER = purchaseorder
              P_POHEADER      = poheader
         TABLES
              P_POITEM        = poitem
              P_POITEMX       = poitemx.

*  ENDIF.

**************************************************************
*mod-003
**************************************************************
  perform get_uom_conversion  tables poitem
                                     POITEMX
                                     poaccount
                                     poaccountx
                                     poschedule
                                     poschedulex
                            changing poheader
                                     poheaderx.
**************************************************************
*mod-003
**************************************************************
*Populate the change indicator structures before calling BAPI_PO_CHANGE
*so that IDOC can be populated with this data
  IF NOT poheaderx IS INITIAL.
    g_w_hdrx_tmp = poheaderx.
  ENDIF.
  IF NOT poitemx[] IS INITIAL.
    g_t_itemx_tmp[] = poitemx[].
  ENDIF.
  IF NOT poschedulex[] IS INITIAL.
    g_t_schdx_tmp[] = poschedulex[].
  ENDIF.
  IF NOT poaccountx[] IS INITIAL.
    g_t_accntx_tmp[] = poaccountx[].
  ENDIF.
  IF NOT pocondx[] IS INITIAL.
    g_t_condx_tmp[] = pocondx[].
  ENDIF.
***************************************************
**MOD-003
**************************************************

  CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      purchaseorder          = purchaseorder
      poheader               = poheader
      poheaderx              = poheaderx
      poaddrvendor           = poaddrvendor
      testrun                = testrun
      memory_uncomplete      = memory_uncomplete
      memory_complete        = memory_complete
*      poexpimpheader         = poexpimpheader
*      poexpimpheaderx        = poexpimpheaderx
*      versions               = versions
*      no_messaging           = no_messaging
*      no_message_req         = no_message_req
*      no_authority           = no_authority
*      no_price_from_po       = no_price_from_po
    IMPORTING
      expheader              = expheader
*      exppoexpimpheader      = exppoexpimpheader
    TABLES
      return                 = return
      poitem                 = poitem
      poitemx                = poitemx
      poaddrdelivery         = poaddrdelivery
      poschedule             = poschedule
      poschedulex            = poschedulex
      poaccount              = poaccount
      poaccountprofitsegment = poaccountprofitsegment
      poaccountx             = poaccountx
      pocondheader           = pocondheader
      pocondheaderx          = pocondheaderx
      pocond                 = pocond
      pocondx                = pocondx
      polimits               = polimits
      pocontractlimits       = pocontractlimits
      poservices             = poservices
      posrvaccessvalues      = posrvaccessvalues
      poservicestext         = poservicestext
      extensionin            = extensionin
      extensionout           = extensionout
*      poexpimpitem           = poexpimpitem
*      poexpimpitemx          = poexpimpitemx
      potextheader           = potextheader
      potextitem             = potextitem .
*      allversions            = allversions
*      popartner              = popartner.

* Code inserted to commit work
  SORT return BY type.
  IF testrun IS INITIAL.
    READ TABLE return
         WITH KEY type = c_msgtype_e               "E.
         BINARY SEARCH.
    IF sy-subrc NE 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ELSE.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      loop at return.
        L_WA_ZERRORS-OBJECT     = 'PURCHASE_ORDER'.
        L_WA_ZERRORS-serial_no   = sy-tabix.
        L_WA_ZERRORS-COMP_CODE  = poheader-comp_code.
        L_WA_ZERRORS-zid        = return-id.
        L_WA_ZERRORS-znumber    = return-number.
        L_WA_ZERRORS-BEACON_DOC_NO = poheader-po_number.
        L_WA_ZERRORS-SRC_DOC_NO = poheader-po_number.
        L_WA_ZERRORS-ZDATE      = sy-datum.
        L_WA_ZERRORS-ERROR_MSG    = return-message.
        append L_WA_ZERRORS to t_errors.
*       insert into ZP2P_ERRORS values L_WA_ZERRORS.
        clear: L_WA_ZERRORS.
      endloop.
      SELECT max( serial_no )
       INTO L_SERIAL
       FROM ZP2P_ERRORS.

      LOOP AT T_ERRORS.
        L_SERIAL = L_SERIAL + 1.
        T_ERRORS-serial_no = L_SERIAL.
        MODIFY T_ERRORS TRANSPORTING serial_no.
      ENDLOOP.

      INSERT ZP2P_ERRORS FROM TABLE T_ERRORS.
    ENDIF.
  ELSE.
*   CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  ENDIF.

*GENERATE CUSTOM RETURN MESSAGES BASED ON MESSAGE ID AND NUMBER FROM
*maintenance table ZMESSAGES
  CALL FUNCTION 'Z_MM_BUILD_MESSAGES'
       TABLES
            return = return.

  SORT return BY type id number.
  READ TABLE return
        WITH KEY id = space
                 number = c_msgnr_000               "000
        BINARY SEARCH.

  IF sy-subrc EQ 0 AND sy-tabix NE 1.
    DELETE return INDEX sy-tabix.
    INSERT return INDEX 1.
  ENDIF.

  SELECT max( serial_no )
       INTO L_SERIAL
       FROM ZP2P_ERRORS.

  LOOP AT T_ERRORS.
    L_SERIAL = L_SERIAL + 1.
    T_ERRORS-serial_no = L_SERIAL.
    MODIFY T_ERRORS TRANSPORTING serial_no.
  ENDLOOP.

  INSERT ZP2P_ERRORS FROM TABLE T_ERRORS.

ENDFUNCTION.

 * regenerated at 11/22/2006 08:39:25 by  AGHOSE
FUNCTION-POOL ZDEV                       MESSAGE-ID SV.
************************************************************************
* PROGRAM        LZZ_M3_PURCHASEORDERTOP02
* TITLE          Top include of Function group ZZ_M3_PURCHASEORDER
* AUTHOR
* DATE WRITTEN
* R/3 RELEASE
*-----------------------------------------------------------------------
* COPIED FROM    N/A
*
* Tables and Data declaration used by function modules.
*
*-----------------------------------------------------------------------
* PROGRAM TYPE    Include
* DEV. CLASS      ZP2P
* LOGICAL DB      N/A
*-----------------------------------------------------------------------
* SCREENS         N/A
* GUl TITLE       N/A
* GUl STATUS      N/A
* TRANSACTIONS    N/A
* USER EXITS      N/A
*-----------------------------------------------------------------------
* CHANGE HISTORY
* Date          By   Correction Number & Brief Description      Release
* 16-April-2004 BV   RD1K906779          Initial Development    4.6C
* 20-May-2004   PVU  SCR1 Changes to create IDOc when error     4.6C
* 27-May-2004   BV   SCR2 Retrieve Acct Assgnmt from Z table    4.6C
* 08-04-04    RD1K907813  TPR-2289
* 26-sep-2005 SDUTTARO  RD1K910316  Extending the Checkpoints 1, 2&3,
*                                   create PO for multiple business unit
*                                   specifically for Alza.
*-----------------------------------------------------------------------

*----------------------------------------------------------------------*
*        DB-Tables
*----------------------------------------------------------------------*
TABLES:  lfa1,    "Vendor Master (General Section)
         lfb1,    "Vendor Master (Company Code)
         lfm1,    "Vendor master record purchasing organization data
         t023.    "Material groups

*PU-21/04/2004 - Added by Pranali for PO Change
TABLES : doktl,      "Documentation - text lines
         ekpo.       "Purchasing Document Item

*----------------------------------------------------------------------*
*        Constants
*----------------------------------------------------------------------*
*BV-29/04/2004 - Added by Balaji for PO Create
CONSTANTS : c_aribavendor(12) TYPE c VALUE 'ARIBA VENDOR',
            c_n(1)            TYPE c VALUE 'N',       "Vendor flag
            c_e(1)            TYPE c VALUE 'E',       "Message type
            c_x(1)            TYPE c VALUE 'X',       "Constant 'X'
            c_y(1)            TYPE c VALUE 'Y',       "Constant 'X'

**MOD-003
            C_W1(1)           TYPE C value 'W',
            C_N1(1)           TYPE C VALUE 'N',
            C_A1(1)           TYPE C VALUE 'A',
            C_C1(1)           TYPE C VALUE 'C',
            C_P1              TYPE KNTTP VALUE 'P',
            C_K1              TYPE KNTTP VALUE 'K',
            C_NC              TYPE PS_PRART VALUE 'NC',
            c_gl_acc_po(20)   type c value 'Z_P2P_GL_ACC_PO',

*MOD-003
            c_us(2)           TYPE c VALUE 'US',      "Country
            c_pco(3)          TYPE c VALUE 'PCO',     "PO Number prefix
            c_001(3)          TYPE c VALUE '001',     "Message class

            c_vend_actgrp(15) TYPE c VALUE 'ZRP_VEND_ACTGRP', "Acctgroup
            c_vend_paytrm(15) TYPE c VALUE 'ZRP_VEND_PAYTRM', "Payterms
            c_vend_recon(15)  TYPE c VALUE 'ZRP_VEND_RECON',  "ReconAcc

**Begin of change DDUTTA 26-June-2004 TPR 2220
            c_vend_ekorg(15)  type c value 'ZRP_EHUB_PURORG', "purch org
**End   of change DDUTTA 26-June-2004 TPR 2220
            c_na(2)           TYPE c VALUE 'NA',       "Document Class
            c_cause(7)        TYPE c VALUE '&CAUSE&',  "Text line
            c_as(2)           TYPE c VALUE 'AS',  "Documentation format
            c_ampV(2)         TYPE c VALUE '&V',  "constant &V
            c_amp(1)          TYPE c VALUE '&',   "Place holder &
            c_msgid_Z001      LIKE sy-msgid VALUE 'Z001',"Message Class
            c_msgtype_i       TYPE bapi_mtype VALUE 'I', "Err Msg Type
            c_msgtype_s       TYPE bapi_mtype VALUE 'S',"Success Msg Typ
            c_msgnr_038       TYPE SYMSGNO VALUE '038', "Message no.038
            c_msgnr_039       TYPE SYMSGNO VALUE '039', "Message no.039
            c_msgnr_040       TYPE SYMSGNO VALUE '040', "Message no.040
            c_msgnr_041       TYPE SYMSGNO VALUE '041', "Message no.041
            c_msgnr_042       TYPE SYMSGNO VALUE '042', "Message no.042
            c_msgnr_043       TYPE SYMSGNO VALUE '043', "Message no.043
            c_msgnr_044       TYPE SYMSGNO VALUE '044', "Message no.044
            c_msgnr_347       TYPE SYMSGNO VALUE '347', "Message no.347
            c_msgnr_613       TYPE SYMSGNO VALUE '613', "Message no.347
            c_msgnr_619       TYPE SYMSGNO VALUE '619',
            c_msgnr_620       TYPE SYMSGNO VALUE '620',
            c_msgnr_621       TYPE SYMSGNO VALUE '621',
            c_msgnr_622       TYPE SYMSGNO VALUE '622',
            c_msgnr_623       TYPE SYMSGNO VALUE '623',
            c_msgnr_624       TYPE SYMSGNO VALUE '624',
**Begin of change KKALDA 03-AUGUST-2004 TPR 2289
            c_msgnr_047       TYPE SYMSGNO VALUE '047', "Message no.047
**End of change KKALDA 03-AUGUST-2004 TPR 2289

            c_zero            LIKE sy-subrc VALUE 0,    "Zero
            c_minusone        LIKE sy-subrc VALUE -1,   "Minus one
            c_four            LIKE sy-subrc VALUE 4.    "Four

*BV-27-May-2004 - Begin of Changes for SCR2.
CONSTANTS :
      c_acct_assign(15) TYPE c  VALUE 'ZRP_ACCT_ASSIGN', "Acct assign
      c_msgnr_045       TYPE SYMSGNO VALUE '045'.        "Message no.045

*BV-27-May-2004 - End of Changes for SCR2.

*BV-08-July-2004 - Begin - Change error handling for ZXA_GET_CONSTANT
 CONSTANTS : c_msgnr_046 TYPE SYMSGNO VALUE '046'.       "Message no.046
*BV-08-July-2004 - End   - Change error handling for ZXA_GET_CONSTANT

*PU-21/04/2004 - Added by Pranali for Vendor create
CONSTANTS : c_insert TYPE c VALUE 'I',                    "Insert Vendor
            c_update TYPE c VALUE 'U',                    "Update Vendor
            c_msgtype_e TYPE bapi_mtype VALUE 'E', "Error Message Type
            c_checked(1) TYPE c VALUE 'X',                "Checked flag
            c_xk01 TYPE sytcode VALUE 'XK01',       "XK01 transaction
            c_xk02 TYPE sytcode VALUE 'XK02',       "XK02 transaction
            c_msgid_f2(2) TYPE c VALUE 'F2',           "Message class F2
            c_msgnr_175(3) TYPE c VALUE '175',         "Message no. 175
            c_msgnr_271(3) TYPE c VALUE '271',         "Message no. 271
            c_msgnr_173(3) TYPE c VALUE '173',         "Message no. 173
            c_msgnr_056(3) TYPE c VALUE '056',         "Message no. 056

            c_msgnr_614 TYPE SYMSGNO VALUE '614',
            c_msgnr_615 TYPE SYMSGNO VALUE '615',
            c_msgnr_616 TYPE SYMSGNO VALUE'616',
            c_msgnr_617 TYPE SYMSGNO VALUE '617',
            c_msgnr_404 TYPE SYMSGNO VALUE '404',
            c_msgnr_618 TYPE SYMSGNO VALUE'618',
            c_msgnr_644 TYPE SYMSGNO VALUE'644'.

CONSTANTS:     C_VENDOR TYPE ELIFN VALUE '4259999999',
               C_DOC_TYPE TYPE ESART VALUE 'ZAPS',
               C_CURRENCY TYPE WAERS VALUE 'EUR',
               C_NETPR  TYPE NETPR VALUE '1.00'.

*PVU-07-May-2004 - Added by Pranali for PO change
Constants :
        c_msgnr_000  type SYMSGNO value '000',         "Message no. 000
        c_msgnr_037  TYPE SYMSGNO VALUE '037',         "Message no. 037
        c_msgnr_634  TYPE SYMSGNO VALUE '634',         "Message no. 634
        c_costcenter(1) type c value 'K',              "Acc.assgn - K
        c_wbs(1) type c value 'P',                     "Acc.assgn - P

*PVU-20-May-2004 - Changes for SCR1
        C_BUKRS  TYPE ZCONSTNAME VALUE 'ZRP_COMPCODE', "Comp Code
        C_SNDPOR TYPE ZCONSTNAME VALUE 'ZRP_SNDPOR',   "Sender Port
        C_SNDPRT TYPE ZCONSTNAME VALUE 'ZRP_SNDPRT',   "Sender PartType
        C_SNDPRN TYPE ZCONSTNAME VALUE 'ZRP_SNDPRN',   "Sender Part No
        C_RCVPOR TYPE ZCONSTNAME VALUE 'ZRP_RCVPOR',   "Rec Port
        C_RCVPRT TYPE ZCONSTNAME VALUE 'ZRP_RCVPRT',   "Rec Part Type
        C_RCVPRN TYPE ZCONSTNAME VALUE 'ZRP_RCVPRN',   "Rec Part No
        C_DIST_LIST  TYPE ZCONSTNAME VALUE 'ZRP_DISTLIST', "Dist List
        C_CREATE_IDOCTYP(8) type c value 'ZMMPOC01',   "IDOC Basic Type
        C_CREATE_MESTYP(6)  type c value 'ZMMPOC',     "IDOC Msg Type
        C_CHANGE_IDOCTYP(8) TYPE C VALUE 'ZMMPOH01' ,  "IDOC Basic Type
        C_CHANGE_MESTYP(6)  TYPE C VALUE 'ZMMPOH',     "IDOC Msg Type
        C_SAPREL(3)  TYPE C VALUE '46C',               "SAP Release
        C_IDOC_DIR(1) TYPE C VALUE  '2',               "IDOC direction
        C_FLG_POCHANGE(4) type c value 'CHNG',         "PO CHANGE FLAG
        C_FLG_POCREATE(4) type c value 'CREA',         "PO CREATE FLAG
        c_sign(1) type c value 'I',                    "Ranges sign
        c_option(2) type c value 'EQ',                 "Ranges option
*IDOC segments
        C_Z1ZMMPOC(8) type c value 'Z1ZMMPOC',
        C_Z1ZMMPOH(8) type c value 'Z1ZMMPOH',
        C_Z1BPMEPOHEADER(14) type c value 'Z1BPMEPOHEADER',
        C_Z1BPMEPOHEADERX(15) type c value 'Z1BPMEPOHEADERX',
        C_Z1BPMEPOADDRVENDOR(18) type c value 'Z1BPMEPOADDRVENDOR',
        C_Z1BPMEPOADDRVENDOR1(19) type c value 'Z1BPMEPOADDRVENDOR1',
        C_Z1BPMEPOITEM(12) type c value 'Z1BPMEPOITEM',
        C_Z1BPMEPOITEMX(13) type c value 'Z1BPMEPOITEMX',
        C_Z1BPMEPOADDRDELIVERY(20) type c value 'Z1BPMEPOADDRDELIVERY',
       C_Z1BPMEPOADDRDELIVERY1(21) type c value 'Z1BPMEPOADDRDELIVERY1',
        C_Z1BPMEPOSCHEDULE(16) type c value 'Z1BPMEPOSCHEDULE',
        C_Z1BPMEPOSCHEDULX(16) type c value 'Z1BPMEPOSCHEDULX',
        C_Z1BPMEPOACCOUNT(15) type c value 'Z1BPMEPOACCOUNT',
        C_Z1BPMEPOACCOUNTPROFITSEGMEN(27) type c value
                                        'Z1BPMEPOACCOUNTPROFITSEGMEN',
        C_Z1BPMEPOACCOUNTX(16) type c value 'Z1BPMEPOACCOUNTX',
        C_Z1BPMEPOCOND(12) type c value 'Z1BPMEPOCOND',
        C_Z1BPMEPOCONDX(13) type c value 'Z1BPMEPOCONDX',
        C_E1BPESUHC(9) type c value 'E1BPESUHC',
        C_E1BPESUCC(9) type c value 'E1BPESUCC',
        C_E1BPESLLC(9) type c value 'E1BPESLLC',
        C_E1BPESKLC(9) type c value 'E1BPESKLC',
        C_E1BPESLLTX(10) type c value 'E1BPESLLTX',
        C_E1BPPAREX(9) type c value 'E1BPPAREX',
*MOD-011
*          c_object type zobject value 'PURCHASE_ORDER',
           c_error(1) type c value 'E',      "Error
           c_ignore(1) type c value 'I',     "Ignore
           c_success(1) type c value 'S',    "Success

           c_1(1) type c value '1',           "Serial Number
           c_mesg_id(4) type c value 'Z001',  "Message Id
*          c_cred_note type ztrype value 'G', "Financial cred Note
           c_doc_cur type curtp value '00',  "Document Currency
           c_loc_cur type curtp value '10'.  "Local Currency

*MOD-011

*PVU-20-May-2004 - End Changes for SCR1

   CONSTANTS: c_msgnr_066    TYPE symsgno VALUE '066',             "@SDR
              c_msgnr_067    TYPE symsgno VALUE '067',             "@SDR
              c_msgnr_071    TYPE symsgno VALUE '071',             "@SDR
              c_msgnr_072    TYPE symsgno VALUE '072',             "@SDR
              c_bukrs_alza   TYPE bukrs   VALUE '1155',            "@SDR
              c_zeros        TYPE C       VALUE '0',               "@SDR
              c_msgtype_w    TYPE bapi_mtype VALUE 'W', "Warning    @SDR
                                                        "Message    @SDR
                                                        "Type       @SDR
              c_psgaw_cc     TYPE kostl      VALUE '54123'.        "@SDR

   CONSTANTS: c_p164(4) TYPE C VALUE 'P164',                       "@SDR
              c_p165(4) TYPE C VALUE 'P165',                       "@SDR
              c_p169(4) TYPE C VALUE 'P169',                       "@SDR
              c_wbs_default TYPE zconstname VALUE 'Z_WBS_DEFAULT', "@SDR
              c_4zeros(4) TYPE C VALUE '0000'.                     "@SDR

*&------------------------------------------------------*&
*& Begin of Addition: 03/27/2006                        *&
*&------------------------------------------------------*&
* CONSTANTS: c_convpos TYPE zconstname VALUE 'CONVERTEDPOS%'.
*  DATA: BEGIN OF t_zconstants OCCURS 0,
*         bukrs     TYPE bukrs,
*         constname TYPE zconstname,
*         constvalu TYPE zconstval,
*        END OF   t_zconstants,
*
*        BEGIN OF  t_zconvpos OCCURS 0,
*         ebeln TYPE ebeln,
*         ebelp TYPE ebelp,
*         wepos TYPE wepos,
*         weunb TYPE weunb,
*        END OF   t_zconvpos.

*&------------------------------------------------------*&
*& End of Addition: 03/27/2006                          *&
*&------------------------------------------------------*&

*----------------------------------------------------------------------*
*        Global variables
*----------------------------------------------------------------------*

DATA : g_flg_vendor TYPE c,
       g_override   TYPE c.

*BV-29/04/2004 - Added by Balaji for PO Create
DATA: g_distr_perc(5) TYPE p DECIMALS 1,
      g_distr_perc1(5) TYPE p DECIMALS 1,
      g_adjust_perc   TYPE c.

*PU-21/04/2004 - Added by Pranali for Vendor create
DATA: g_mode   LIKE ctu_params-dismode VALUE 'N',  "Background Mode
      g_update LIKE ctu_params-updmode VALUE 'S',  "Update  Mode
      g_textmsg TYPE bapi_msg,                     "Message Text
      g_text(200) TYPE c,                          "Message Text

*PVU-20-May-2004 - Changes for SCR1
      g_idoc_no LIKE edidc-docnum.                 "IDOC number

*----------------------------------------------------------------------*
*        Internal Tables
*----------------------------------------------------------------------*
DATA: t_zreturn LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
      t_xlfas LIKE flfas OCCURS 0 WITH HEADER LINE,
      t_xlfb5 LIKE flfb5 OCCURS 0 WITH HEADER LINE,
      t_xlfbk LIKE flfbk OCCURS 0 WITH HEADER LINE,
      t_xlfza LIKE flfza OCCURS 0 WITH HEADER LINE,
      t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
      t_tempreturn LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

*BV-27-May-2004 - Begin of Changes for SCR2.
      t_yreturn LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
*BV-27-May-2004 - End of Changes for SCR2.

**BV- 30/04/2004 - Added by Balaji for PO Create
*      t_znonpo_document LIKE znonpo_document OCCURS 0 WITH HEADER LINE,
*      t_znonpo_acctg    LIKE znonpo_acctg_struc OCCURS 0 WITH HEADER
*      LINE.
*
*mod-009
*PU-21/04/2004 - Added by Pranali for PO Change
* DATA: t_messages LIKE zmessages OCCURS 0 WITH HEADER LINE,
*DATA: t_messages LIKE zp2p_messages OCCURS 0 WITH HEADER LINE,
*mod-009

*PVU-20-May-2004 - Changes for SCR1
      g_t_idoc_data LIKE edi_dd40 OCCURS 0 WITH HEADER LINE.
*PVU-20-May-2004 - End Changes for SCR1

*PU-21/04/2004 - Added by Pranali for Vendor create
DATA: t_t_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,    "BDC table
      t_t_bdc_msg LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE. "BDC Msg.

*----------------------------------------------------------------------*
*        Work Area/Structures
*----------------------------------------------------------------------*
DATA : w_lfa1  LIKE lfa1,    "work area-Vendor Master (General Section)
       w_lfb1  LIKE lfb1,    "work area-Vendor Master (Company Code)
       w_lfm1  LIKE lfm1,    "work area-Vendor master (pur.org.data)

*PU-21/04/2004 - Added by Pranali for Vendor create
       wa_return TYPE bapiret2,              "Work area of return table

*PVU-20-May-2004 - Changes for SCR1
       w_idoc_comm LIKE edi_dc40,            "IDoc Control Record
       w_syst_info LIKE syst.                "ABAP System Fields

*mod-003*******************************************************
CONSTANTS :c_p2p_pur_org(20) type c VALUE 'Z_P2P_PUR_ORG'.
** DATA:  L_WA_ZERRORS TYPE ZERRORS.
*DATA:  L_WA_ZERRORS TYPE ZP2P_ERRORS.
*mod-003*******************************************************
* DATA:  t_errors LIKE zerrors OCCURS 0 WITH HEADER LINE.
 DATA:  t_errors LIKE zp2p_errors OCCURS 0 WITH HEADER LINE.
*mod-003*******************************************************
DATA : L_CONST_NAME  LIKE SY-MSGV1,   "Constant name
       L_COMP_CODE   LIKE SY-MSGV2.  "Company code
constants: c_po_werks(8) type c value 'PO_WERKS'.
DATA: t_t001w LIKE t001w OCCURS 0 WITH HEADER LINE,
      t_ADRC LIKE ADRC OCCURS 0 WITH HEADER LINE.
data: l_belkz type ps_belkz.
*data: L_XSPEB type xspeb_anla.*
data: tbx TYPE  SY-TABIX.
DATA: L_WA_ZERRORS TYPE ZP2P_ERRORS.
*M0D-011
* To hold error Entries
*DATA:  t_error type standard table of zp2p_errors initial  size 0.
**    To post error records
*DATA: wa_error type zp2p_errors.
*MOD-011
  INCLUDE LSVIMDAT                                . "general data decl.
  INCLUDE LZDEVT00                                . "view rel. data dcl.
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ММ All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.