Skip to end of metadata
Go to start of metadata

<Function module to Change PO using BAPI>

Overview description of module goes in here.
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. 
FUNCTION Z_BAPI_PO_CHANGE.

*"----------------------------------------------------------------------

""Local Interface:

*" IMPORTING

*" VALUE(PURCHASEORDER) TYPE BAPIMEPOHEADER-PO_NUMBER

*" VALUE(POADDRVENDOR) TYPE BAPIMEPOADDRVENDOR

*" VALUE(TESTRUN) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(MEMORY_UNCOMPLETE) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(MEMORY_COMPLETE) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(POEXPIMPHEADER) TYPE BAPIEIKP

*" VALUE(POEXPIMPHEADERX) TYPE BAPIEIKPX

*" VALUE(VERSIONS) TYPE BAPIMEDCM

*" VALUE(NO_MESSAGING) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(NO_MESSAGE_REQ) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(NO_AUTHORITY) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(NO_PRICE_FROM_PO) TYPE BAPIFLAG-BAPIFLAG

*" EXPORTING

*" VALUE(EXPHEADER) TYPE BAPIMEPOHEADER

*" VALUE(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 BAPIMEPOCOND

*" POCONDHEADERX STRUCTURE BAPIMEPOCONDX

*" 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 BAPIMEPOTEXT

*" 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

*" VALUE(POHEADER) TYPE BAPIMEPOHEADER

*" VALUE(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 ZP2P_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.

  • Ranges :r_ehub_pos for t_zconstants-constvalu.
    • Begin of Change SVALIDET(RD1K911990)
  • SELECT *
  • FROM zconstants_new
  • INTO TABLE t_zconstants
  • WHERE constname LIKE c_po_ehub_var. " EHUB_POS%

*

  • IF sy-subrc = 0.
  • SORT t_zconstants BY constvalu ASCENDING.
  • DELETE ADJACENT DUPLICATES FROM t_zconstants
  • COMPARING constvalu.
  • LOOP AT t_zconstants.
  • r_ehub_pos-sign = 'I'.
  • r_ehub_pos-option = 'EQ'.
  • r_ehub_pos-low = t_zconstants-constvalu.
  • APPEND r_ehub_pos.
  • CLEAR: r_ehub_pos,
  • t_zconstants.
  • ENDLOOP.
  • ENDIF.

**End of Change SVALIDET(RD1K911990)

*

    • Srini 18-May-2005 Start of changes
    • Developer Flexibility to debug issues
  • p_constname = 'BAPI_PO_CHANGE2'.

*

  • do.
  • CALL FUNCTION 'ZXA_GET_CONSTANT'
  • EXPORTING
  • const_name = p_constname
    • comp_code =
  • IMPORTING
  • const_value = g_constval
  • EXCEPTIONS
  • no_value_found = 1
  • null_value = 2
  • OTHERS = 3.
  • if g_constval NE 'X'.
  • exit.
  • endif.
  • enddo.

*Begin of comment RD1Kk911990

  • IF PURCHASEORDER+0(3) EQ '099' AND POHEADER-DOC_TYPE EQ 'ZEHS'.
  • POHEADER-DOC_TYPE = 'ZEH'.
  • ENDIF.

*End of comment RD1K911990

**********************************************************

*mod-003

**********************************************************

    • if not poheader-comp_code is initial.
  • if poheader-comp_code is initial.
  • clear: l_bukrs.
  • select single companycode
  • into l_bukrs
  • from zcompanycodes01
    • where companycode = poheader-comp_code and
  • where FSID = poheader-fsid and
  • le = poheader-le and
  • frmrc = poheader-frmrc.

*

  • if sy-subrc ne 0.
  • CLEAR L_MSGV1.
  • L_MSGV1 = POHEADER-DOC_TYPE.
    • Please Enter an Account number for line
  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • TYPE = C_MSGTYPE_E
  • CL = C_MSGID_Z001
  • NUMBER = C_MSGNR_618
  • PAR1 = L_MSGV1
  • IMPORTING
  • RETURN = RETURN.

*

  • APPEND RETURN.
  • CLEAR RETURN.
  • else.
  • poheader-comp_code = l_bukrs.
  • endif.
  • endif.

**********************************************************

*mod-003

**********************************************************

  • IF POHEADER-DOC_TYPE EQ 'ZEHS'.
  • POHEADER-DOC_TYPE = 'ZEH'.
  • ENDIF.
  • SORT poaccount BY po_item serial_no.

*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-serialno = 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-ERR_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,
  • 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-CREATE_TIMESTMP = POITEM-ARIBACRTTIMESTMP.

insert into ZP2P_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-serialno = 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-ERR_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.

  • IF NOT POHEADER-PURCH_ORG IS INITIAL.
  • IF POHEADER-PURCH_ORG IS INITIAL.
  • SELECT SINGLE PUR_ORG
  • INTO L_EKORG
  • FROM ZPUR_ORG
  • WHERE LE = POHEADER-LE AND
  • FRMRC = POHEADER-FRMRC AND
  • FSID = POHEADER-FSID.

*

  • 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 t_yreturn.
  • L_WA_ZERRORS-OBJECT = 'PURCHASE_ORDER'.
  • L_WA_ZERRORS-serialno = 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-ERR_MSG = t_yreturn-message.
  • append L_WA_ZERRORS to t_errors.
  • insert into ZP2P_ERRORS values L_WA_ZERRORS.
  • clear: L_WA_ZERRORS.
  • endloop.
  • EXIT.
  • ELSE.
  • POHEADER-PURCH_ORG = L_EKORG.
  • ENDIF.
  • ENDIF.
  • IF NOT POHEADER-PUR_GROUP IS INITIAL.
  • IF 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_046
  • PAR1 = L_CONST_NAME
  • PAR2 = L_COMP_CODE
  • IMPORTING
  • RETURN = RETURN.

*

  • APPEND RETURN.
  • CLEAR RETURN.

*

  • loop at t_yreturn.
  • L_WA_ZERRORS-OBJECT = 'PURCHASE_ORDER'.
  • L_WA_ZERRORS-serialno = 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-ERR_MSG = t_yreturn-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.

*

  • data: l_werks1 type werks_d.
  • LOOP AT poitem.
  • if poitem-plant is initial.
  • clear: l_werks1.
  • select single plant
  • into l_werks1
  • from zpo_plantmapping
  • where COMPANY_CODE = poheader-comp_code and
  • PUR_ORG = poheader-purch_org and
  • PUR_GROUP = poheader-pur_group and
  • LE = poheader-le and
  • FSID = poheader-fsid and
  • FRMRC = poheader-frmrc.
  • if sy-subrc ne 0.
  • PERFORM ERROR_HANDLING_PLANT USING POHEADER
  • poheader-comp_code
  • L_WA_ZERRORS.
  • EXIT.
  • else.
  • poitem-plant = l_werks1.
  • CLEAR: L_WERKS1.
  • endif.
  • endif.
    • IF POITEM-NET_PRICE NE POHEADER-CURRENCY.
    • POITEM-NET_PRICE = POHEADER-CURRENCY.
    • ENDIF.

*

  • IF POITEM-net_price NE 0.
  • POITEM-IR_IND = 'X'.
  • ENDIF.

*

  • POITEM-UNLIMITED_DLV = 'X'.
  • POITEM-UNDER_DLV_TOL = 0.
  • clear: poitem-ARIBACRTTIMESTMP,
  • poitem-ARIBAUPDTIMESTMP.

*

  • MODIFY POITEM TRANSPORTING UNLIMITED_DLV
  • UNDER_DLV_TOL
  • PLANT
  • IR_IND
  • ARIBACRTTIMESTMP
  • ARIBAUPDTIMESTMP.

*

*

  • ENDLOOP.

**********************************************************

*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.

  • IF NOT POHEADER-PURCH_ORG IS INITIAL.
  • IF POHEADER-PURCH_ORG IS INITIAL.
  • SELECT SINGLE PUR_ORG
  • INTO L_EKORG
  • FROM ZPUR_ORG
  • WHERE LE = POHEADER-LE AND
  • FRMRC = POHEADER-FRMRC AND
  • FSID = POHEADER-FSID.

*

  • 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 t_yreturn.
  • L_WA_ZERRORS-OBJECT = 'PURCHASE_ORDER'.
  • L_WA_ZERRORS-serialno = 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-ERR_MSG = t_yreturn-message.
  • append L_WA_ZERRORS to t_errors.
    • insert into ZP2P_ERRORS values L_WA_ZERRORS.
  • clear: L_WA_ZERRORS.
  • endloop.
  • EXIT.
  • ELSE.
  • POHEADER-PURCH_ORG = L_EKORG.
  • ENDIF.
  • ENDIF.

*

    • IF NOT POHEADER-PUR_GROUP IS INITIAL.
  • IF 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_046
  • 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-serialno = 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-ERR_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

***********************************************************

      • 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-serialno = 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-ERR_MSG = return-message.

append L_WA_ZERRORS to t_errors.

clear: L_WA_ZERRORS.

endloop.

SELECT max( serialno )

INTO L_SERIAL

FROM ZP2P_ERRORS.

LOOP AT T_ERRORS.

L_SERIAL = L_SERIAL + 1.

T_ERRORS-serialno = L_SERIAL.

MODIFY T_ERRORS TRANSPORTING serialno.

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-serialno = 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-ERR_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

***********************************************************

****************************************************

*mod-003

****************************************************

  • if not poheader-comp_code is initial.
  • select single companycode
  • into l_bukrs
  • from zcompanycodes01
  • where companycode = poheader-comp_code and
  • FSID = poheader-fsid and
  • le = poheader-le and
  • frmrc = poheader-frmrc.

*

  • if sy-subrc ne 0.
  • CLEAR L_MSGV1.
  • L_MSGV1 = POACCOUNT-PO_ITEM.
    • Please Enter an Account number for line
  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • TYPE = C_MSGTYPE_E
  • CL = C_MSGID_Z001
  • NUMBER = C_MSGNR_618
  • PAR1 = L_MSGV1
  • IMPORTING
  • RETURN = RETURN.

*

  • APPEND RETURN.
  • CLEAR RETURN.
  • loop at return.
  • L_WA_ZERRORS-OBJECT = 'PURCHASE_ORDER'.
  • L_WA_ZERRORS-serialno = 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-ERR_MSG = return-message.
  • append L_WA_ZERRORS to t_errors.
    • insert into ZP2P_ERRORS values L_WA_ZERRORS.
  • clear: L_WA_ZERRORS.
  • endloop.

*

  • ELSE.
  • poheader-comp_code = l_bukrs.
  • endif.
  • 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.

**********************************************************

*mod-003

***********************************************************

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

**********************************************************

*mod-003

***********************************************************

**********************************************************

*mod-003

***********************************************************

  • IF NOT POHEADER-PURCH_ORG IS INITIAL.
  • SELECT SINGLE PUR_ORG
  • INTO L_EKORG
  • FROM ZPUR_ORG
  • WHERE LE = POHEADER-LE AND
  • FRMRC = POHEADER-FRMRC AND
  • FSID = POHEADER-FSID.

*

  • 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-serialno = 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-ERR_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-PURCH_ORG = L_EKORG.
  • ENDIF.
  • 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-cREATE_TIMESTMP = POHEADER-ARIBACHGTIMESTMP.

insert into ZP2P_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-serialno = 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-ERR_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. "@SDR

&------------------------------------------------------&

**& Begin of Change: 26-Sep-2005 SDUTTARO RD1K910989 *&

*&------------------------------------------------------&

    • For PCO Order, populate the PO and accounting data into a Z table and
    • exit the program run.
  • PERFORM populate_nonpo_document TABLES poitem
  • return
  • potextheader
  • USING purchaseorder
  • poheader.
  • PERFORM populate_nonpo_accounting TABLES poaccount
  • return
  • USING poheader.

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

    • To make sure that the ztables do not get updated in case of
    • checkpoints 1, 2 and get updated only after approval
  • IF testrun IS INITIAL. "SDR

**&&---End of Addition: Soumya D Roy: 03/10/2006

  • PERFORM update_nonpodocument.

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

    • To delete PCOs. No deletion code is required for CRs & UTs
    • as these two cannot be deleted
  • ENDIF. "@SDR

**&&---End of Addition: Soumya D Roy: 03/10/2006

  • LOOP AT t_return.
  • MOVE: t_return-type TO return-type,
  • t_return-number TO return-number,
  • t_return-message TO return-message.
  • APPEND return.
  • CLEAR return.
  • ENDLOOP.

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

  • Code to build the message table for output to Ariba
  • for PCOs

*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.

**&&&&----- End of Addition: Soumya D Roy: 03/02/2006

  • EXIT.

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.

perform get_uom_conversion tables poitem

POITEMX

poaccount

poaccountx

poschedule

poschedulex

pocond

pocondx

Pocondheader

pocondheaderx

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'.

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

**To generate inbound IDOC for failed PO

  • perform idoc_create tables poitem
  • g_t_itemx_tmp
  • poaddrdelivery
  • poschedule
  • g_t_schdx_tmp
  • poaccount
  • poaccountprofitsegment
  • g_t_accntx_tmp
  • pocond
  • g_t_condx_tmp
  • polimits
  • pocontractlimits
  • poservices
  • posrvaccessvalues
  • poservicestext
  • extensionin
  • return
  • using c_flg_pochange "CHNG
  • purchaseorder
  • poheader
  • g_w_hdrx_tmp
  • poaddrvendor
  • testrun
  • memory_uncomplete
  • memory_complete .

*

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

loop at return.

L_WA_ZERRORS-OBJECT = 'PURCHASE_ORDER'.

L_WA_ZERRORS-serialno = 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-ERR_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( serialno )

INTO L_SERIAL

FROM ZP2P_ERRORS.

LOOP AT T_ERRORS.

L_SERIAL = L_SERIAL + 1.

T_ERRORS-serialno = L_SERIAL.

MODIFY T_ERRORS TRANSPORTING serialno.

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( serialno )

INTO L_SERIAL

FROM ZP2P_ERRORS.

LOOP AT T_ERRORS.

L_SERIAL = L_SERIAL + 1.

T_ERRORS-serialno = L_SERIAL.

MODIFY T_ERRORS TRANSPORTING serialno.

ENDLOOP.

INSERT ZP2P_ERRORS FROM TABLE T_ERRORS.

ENDFUNCTION.

*----------------------------------------------------------------------

*

  • INCLUDE LZZ_M3_PURCHASEORDER02F02

*

*----------------------------------------------------------------------

*

***********************************************************************

*

  • PROGRAM LZZ_M3_PURCHASEORDERF01
  • TITLE Include containing subroutines for Function group
  • ZZ_M3_PURCHASEORDER
  • AUTHOR Aveek Ghose
  • DATE WRITTEN 25.05.2006
  • R/3 RELEASE 4.6C

*----------------------------------------------------------------------

*&---------------------------------------------------------------------

*

*& Form filter_items

*&---------------------------------------------------------------------

*

  • Subroutine to obtain line items which have GL Account as blank.

*----------------------------------------------------------------------

*

  • -->P_T_TEMP_POACCOUNT line item accounting data

*----------------------------------------------------------------------

*

FORM filter_items TABLES p_t_temp_poaccount STRUCTURE bapimepoaccount.

IF NOT p_t_temp_poaccount[] IS INITIAL.

SORT p_t_temp_poaccount BY po_item.

DELETE p_t_temp_poaccount WHERE NOT gl_account IS initial.

DELETE ADJACENT DUPLICATES FROM p_t_temp_poaccount

COMPARING po_item.

ENDIF.

ENDFORM. " filter_items

&--------------------------------------------------------------------

*& Form POPULATE_NONPO_DOCUMENT

&--------------------------------------------------------------------

  • Update the table ZNONPO_DOCUMENT

---------------------------------------------------------------------

  • --> p_poitem Item data
  • --> p_return Error Messages
  • --> p_textheader Texts - Purchase Order
  • --> u_po Purchase Order Number
  • --> u_poheader Purchase Order Header Data

---------------------------------------------------------------------

FORM populate_nonpo_document TABLES p_poitem STRUCTURE bapimepoitem

p_return STRUCTURE bapiret2

p_textheader STRUCTURE bapimepotext

USING u_po

u_poheader STRUCTURE bapimepoheader

.

DATA: l_price LIKE p_poitem-net_price,

c_poitem LIKE bapimepotext-po_item VALUE '00000'.

CLEAR l_price.

t_znonpo_document-client = sy-mandt.

IF u_po IS INITIAL.

t_znonpo_document-documentnumber = u_poheader-po_number.

ELSE.

t_znonpo_document-documentnumber = u_po.

ENDIF.

t_znonpo_document-companycode = u_poheader-comp_code.

t_znonpo_document-documenttype = u_poheader-doc_type.

t_znonpo_document-suppliernumber = u_poheader-vendor.

t_znonpo_document-currency = u_poheader-currency.

  • LOOP AT p_textheader WHERE po_item = '00000'.

LOOP AT p_textheader WHERE po_item = c_poitem.

t_znonpo_document-description = p_textheader-text_line.

ENDLOOP.

LOOP AT p_poitem.

l_price = l_price + ( p_poitem-net_price * p_poitem-quantity ).

  • t_znonpo_document-requester = p_poitem-preq_name.

ENDLOOP.

t_znonpo_document-amount = l_price.

APPEND t_znonpo_document.

CLEAR t_znonpo_document.

ENDFORM. "POPULATE_NONPO_DOCUMENT

&--------------------------------------------------------------------

*& Form POPULATE_NONPO_ACCOUNTING

&--------------------------------------------------------------------

  • Update the table ZNONPO_ACCTG

---------------------------------------------------------------------

  • --> p_poaccount Account Assignment data for PO
  • --> p_return Error Messages
  • --> u_poheader Purchase Order Header Data

---------------------------------------------------------------------

FORM populate_nonpo_accounting TABLES p_poaccount STRUCTURE

bapimepoaccount

p_return STRUCTURE bapiret2

USING u_poheader STRUCTURE

bapimepoheader.

DATA: l_serial_no LIKE p_poaccount-serial_no.

*begin of change by DD - 09-Aug-2004,tpr2289

SORT p_poaccount BY GL_ACCounT COSTCENTER wbs_element

&------------------------------------------------------&

*& Begin of Addition: 26-Sep-2005 SDUTTARO RD1K911060 *&

&------------------------------------------------------&

serial_no. "@SDR

&------------------------------------------------------&

*& End of Addition: 26-Sep-2005 SDUTTARO RD1K911060 *&

&------------------------------------------------------&

DELETE ADJACENT DUPLICATES FROM p_poaccount

COMPARING GL_ACCounT

COSTCENTER

wbs_element

&------------------------------------------------------&

*& Begin of Addition: 26-Sep-2005 SDUTTARO RD1K911060 *&

&------------------------------------------------------&

serial_no. "@SDR

&------------------------------------------------------&

*& End of Addition: 26-Sep-2005 SDUTTARO RD1K911060 *&

&------------------------------------------------------&

*end of change by DD - 09-Aug-2004,tpr2289

SORT p_poaccount BY po_item.

*begin of change by DD - 13-Aug-2004,tpr2289

CLEAR l_serial_no.

*end of change by DD - 13-Aug-2004,tpr2289

LOOP AT p_poaccount.

*begin of change by DD - 13-Aug-2004,tpr2289

  • AT NEW po_item.
  • CLEAR l_serial_no.
  • ENDAT.

*end of change by DD - 13-Aug-2004,tpr2289

*sraman2 10/14/04

  • ADD 1 TO l_serial_no.

*sraman2 10/14/04

t_znonpo_acctg-client = sy-mandt.

t_znonpo_acctg-documentnumber = u_poheader-po_number.

*sraman2 10/14/04

  • t_znonpo_acctg-distnumber = l_serial_no.

*sraman2 10/14/04

t_znonpo_acctg-distnumber = p_poaccount-SERIAL_NO.

t_znonpo_acctg-distpercent = p_poaccount-distr_perc.

t_znonpo_acctg-distquantity = p_poaccount-quantity.

t_znonpo_acctg-glacct = p_poaccount-gl_account.

t_znonpo_acctg-costcenter = p_poaccount-costcenter.

*begin of change by DD - 24-June-2004

  • t_znonpo_acctg-internalorder = p_poaccount-orderid.

t_znonpo_acctg-pspnr = p_poaccount-wbs_element.

*end of change by DD - 24-June-2004

&------------------------------------------------------&

*& Begin of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

t_znonpo_acctg-ex_pro_no = p_poaccount-unload_pt.

"@SDR

&------------------------------------------------------&

*& End of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

APPEND t_znonpo_acctg.

CLEAR t_znonpo_acctg.

ENDLOOP.

ENDFORM. "POPULATE_NONPO_ACCOUNTING

&--------------------------------------------------------------------

*& Form UPDATE_NONPODOCUMENT

&--------------------------------------------------------------------

  • Update the Non PO Document

---------------------------------------------------------------------

  • --> t_RETURN Error Messages

---------------------------------------------------------------------

FORM update_nonpodocument.

CALL FUNCTION 'Z_P2P_INT_IN_NONPODOCUMENT'

EXPORTING

BYPASS_VENDOR = 'X' "add TPR2220 DDUTTA 08-Jul-2004

TABLES

p_nonpodoc = t_znonpo_document

p_nonpoacctg = t_znonpo_acctg

return = t_return.

ENDFORM. "UPDATE_NONPODOCUMENT

*&---------------------------------------------------------------------

*

*& Form EXTRACT_MESSAGES

*&---------------------------------------------------------------------

*

  • Select data from table zmessages

*----------------------------------------------------------------------

*

*FORM extract_messages .

*

  • SELECT * FROM zmessages INTO TABLE t_messages.

*

*ENDFORM. " EXTRACT_MESSAGES

*&---------------------------------------------------------------------

*

*& Form extract_longtext

*&---------------------------------------------------------------------

*

  • Extract the long text

*----------------------------------------------------------------------

*

  • --> u_id Message class
  • --> u_number Message number
  • --> u_msgv1 Message variable
  • --> u_msgv2 Message variable
  • --> u_msgv3 Message variable
  • --> u_msgv4 Message variable
  • --> u_override Override flag
  • --> u_shorttext Shorttext flag
  • --> u_longtext Longtext flag
  • --> u_message Message text

*----------------------------------------------------------------------

*

FORM extract_longtext USING u_id

u_number

u_msgv1

u_msgv2

u_msgv3

u_msgv4

u_override

u_shorttext

u_longtext

CHANGING u_message.

DATA: l_object LIKE doktl-object,

l_initial TYPE c,

l_variable(20) TYPE c,

l_length type i.

CLEAR: l_initial,

l_variable,

l_object.

IF u_override IS INITIAL AND

NOT u_longtext IS INITIAL.

  • extract long text

CONCATENATE u_id u_number INTO

l_object.

SELECT * FROM doktl WHERE

id EQ c_na AND "'NA'

object EQ l_object AND

langu EQ c_e. "E

IF doktl-doktext EQ c_cause. " '&CAUSE&'

l_initial = c_x. " 'X'

CLEAR u_message.

ELSE.

IF l_initial EQ c_x. "'X'

IF doktl-dokformat NE c_as AND " 'AS'

doktl-dokformat NE space.

EXIT.

ELSE.

DO.

REPLACE c_ampv INTO doktl-doktext WITH c_amp. " '&V' '&'

IF sy-subrc NE 0.

EXIT.

ENDIF.

ENDDO.

CONCATENATE u_message doktl-doktext

INTO u_message

SEPARATED BY space.

ENDIF.

ENDIF.

ENDIF.

ENDSELECT.

IF sy-subrc EQ 0.

SHIFT u_message LEFT DELETING LEADING space.

ENDIF.

ENDIF.

  • replace variables in the long text with the return message variables

DO.

l_variable = sy-index.

CONDENSE l_variable NO-GAPS.

CONCATENATE c_amp l_variable c_amp INTO l_variable. " '&'

l_length = strlen( l_variable ).

CASE sy-index.

WHEN 1.

REPLACE l_variable length l_length WITH u_msgv1 into u_message.

condense u_message.

IF sy-subrc NE 0.

EXIT.

ENDIF.

WHEN 2.

REPLACE l_variable length l_length INTO u_message WITH u_msgv2.

condense u_msgv2.

IF sy-subrc NE 0.

EXIT.

ENDIF.

WHEN 3.

REPLACE l_variable length l_length INTO u_message WITH u_msgv3.

condense u_msgv3.

IF sy-subrc NE 0.

EXIT.

ENDIF.

WHEN 4.

REPLACE l_variable length l_length INTO u_message WITH u_msgv4.

condense u_msgv4.

IF sy-subrc NE 0.

EXIT.

ENDIF.

WHEN OTHERS.

EXIT.

ENDCASE.

ENDDO.

ENDFORM. " extract_longtext

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

*&---------------------------------------------------------------------

*

*& Form get_constant

*&---------------------------------------------------------------------

*

  • Get the constant value from table ZCONSTANTS_NEW

*----------------------------------------------------------------------

*

  • -->U_CONST_NAME Name of constant
  • -->U_COMP_CODE Company code
  • <--CH_CONST_VAL Value of constant
  • <--CH_RET SY-SUBRC value

*----------------------------------------------------------------------

*

FORM get_constant USING u_const_name TYPE zconstname

u_comp_code TYPE bukrs

CHANGING ch_const_val TYPE zconstval

ch_ret TYPE sy-subrc.

*The constant value retrieval function module

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

const_name = u_const_name

comp_code = u_comp_code

IMPORTING

const_value = ch_const_val

EXCEPTIONS

no_value_found = 1

null_value = 2

OTHERS = 3.

IF sy-subrc <> 0.

ch_ret = sy-subrc.

ELSE.

ch_ret = 0.

ENDIF.

ENDFORM. " get_constant

*&---------------------------------------------------------------------

*

*& Form idoc_create

*&---------------------------------------------------------------------

*

  • Create IDOC if BAPI fails

*----------------------------------------------------------------------

*

*FORM idoc_create TABLES t_poitem STRUCTURE bapimepoitem

  • t_itemx_tmp STRUCTURE bapimepoitemx
  • t_poaddrdelivery STRUCTURE
  • bapimepoaddrdelivery
  • t_poschedule STRUCTURE bapimeposchedule
  • t_schdx_tmp STRUCTURE bapimeposchedulx
  • t_poaccount STRUCTURE bapimepoaccount
  • t_poaccountprofitsegment STRUCTURE
  • bapimepoaccountprofitsegment
  • t_accntx_tmp STRUCTURE bapimepoaccountx
  • t_pocond STRUCTURE bapimepocond
  • t_condx_tmp STRUCTURE bapimepocondx
  • t_polimits STRUCTURE bapiesuhc
  • t_pocontractlimits STRUCTURE bapiesucc
  • t_poservices STRUCTURE bapiesllc
  • t_posrvaccessvalues STRUCTURE bapiesklc
  • t_poservicestext STRUCTURE bapieslltx
  • t_extensionin STRUCTURE bapiparex
  • t_return_msg STRUCTURE bapiret2
  • USING
  • u_flg_create_change TYPE c
  • u_purchaseorder LIKE bapimepoheader-po_number
  • u_poheader STRUCTURE bapimepoheader
  • u_hdrx_tmp STRUCTURE bapimepoheaderx
  • u_poaddrvendor STRUCTURE bapimepoaddrvendor
  • u_testrun LIKE bapiflag-bapiflag
  • u_memory_uncomplete LIKE bapiflag-bapiflag
  • u_memory_complete LIKE bapiflag-bapiflag.

*

**---------------------------------------------------------------------

**

    • Local variables

**---------------------------------------------------------------------

**

  • DATA: l_bukrs_val TYPE zconstval, "Company Code value
  • l_bukrs TYPE bukrs, "Company code
  • l_sndpor TYPE zconstval, "Sender Port
  • l_sndprt TYPE zconstval, "Sender Partner Type
  • l_sndprn TYPE zconstval, "Sender Partner No
  • l_rcvpor TYPE zconstval, "Receiver Port
  • l_rcvprt TYPE zconstval, "Receiver Partner Type
  • l_rcvprn TYPE zconstval, "Receiver Partner No
  • l_dist_list TYPE zconstval, "Distribution List
  • l_sy_subrc LIKE sy-subrc, "Return value
  • l_subline(35) TYPE c, "Subject Line
  • l_errmsg(200) TYPE c. "Error Message

*

**---------------------------------------------------------------------

**

    • Internal Tables/Ranges

**---------------------------------------------------------------------

**

    • Table to store error messages
  • RANGES : t_errmsg FOR l_errmsg.

*

*

    • create IDoc control-record
  • CASE u_flg_create_change.
  • WHEN c_flg_pocreate. "CREA
  • w_idoc_comm-idoctyp = c_create_idoctyp. "ZMMPOC01
  • w_idoc_comm-mestyp = c_create_mestyp. "ZMMPOC
  • WHEN c_flg_pochange. "CHNG
  • w_idoc_comm-idoctyp = c_change_idoctyp. "ZMMPOH01
  • w_idoc_comm-mestyp = c_change_mestyp. "ZMMPOH
  • ENDCASE.
  • w_idoc_comm-mandt = sy-mandt.
  • w_idoc_comm-docrel = c_saprel. "46C
  • w_idoc_comm-direct = c_idoc_dir. "2

*

    • Get constant value of Company Code
  • PERFORM get_constant USING c_bukrs "ZRP_COMPCODE
  • u_poheader-comp_code
  • CHANGING l_bukrs_val
  • l_sy_subrc.
  • IF l_sy_subrc = 0.
    • Get constant value of Sender Port
  • l_bukrs = l_bukrs_val.
  • PERFORM get_constant USING c_sndpor "ZRP_SNDPOR
  • l_bukrs
  • CHANGING l_sndpor
  • l_sy_subrc.
  • IF l_sy_subrc = 0.
  • w_idoc_comm-sndpor = l_sndpor.
  • ENDIF.

*

    • Get constant value of Sender Partner type
  • PERFORM get_constant USING c_sndprt "ZRP_SNDPRT
  • l_bukrs
  • CHANGING l_sndprt
  • l_sy_subrc.
  • IF l_sy_subrc = 0.
  • w_idoc_comm-sndprt = l_sndprt.
  • ENDIF.

*

    • Get constant value of sender partner number
  • PERFORM get_constant USING c_sndprn "ZRP_SNDPRN
  • l_bukrs
  • CHANGING l_sndprn
  • l_sy_subrc.
  • IF l_sy_subrc = 0.
  • w_idoc_comm-sndprn = l_sndprn.
  • ENDIF.

*

    • Get constant value of Receiver port
  • PERFORM get_constant USING c_rcvpor "ZRP_RCVPOR
  • l_bukrs
  • CHANGING l_rcvpor
  • l_sy_subrc.
  • IF l_sy_subrc = 0.
  • w_idoc_comm-rcvpor = l_rcvpor.
  • ENDIF.

*

    • Get constant value of Receiver partner type
  • PERFORM get_constant USING c_rcvprt "ZRP_RCVPRT
  • l_bukrs
  • CHANGING l_rcvprt
  • l_sy_subrc.
  • IF l_sy_subrc = 0.
  • w_idoc_comm-rcvprt = l_rcvprt.
  • ENDIF.

*

    • Get constant value of Receiver partner number
  • PERFORM get_constant USING c_rcvprn "ZRP_RCVPRN
  • l_bukrs
  • CHANGING l_rcvprn
  • l_sy_subrc.
  • IF l_sy_subrc = 0.
  • w_idoc_comm-rcvprn = l_rcvprn.
  • ENDIF.
  • ENDIF.

*

  • CLEAR: w_syst_info, g_t_idoc_data.
  • REFRESH g_t_idoc_data.

*

    • call subroutine to create IDoc data-record
  • IF u_flg_create_change = c_flg_pocreate. "CREA
  • PERFORM zidoc_po_create1
  • TABLES
  • t_poitem
  • t_itemx_tmp
  • t_poaddrdelivery
  • t_poschedule
  • t_schdx_tmp
  • t_poaccount
  • t_poaccountprofitsegment
  • t_accntx_tmp
  • t_pocond
  • t_condx_tmp
  • t_polimits
  • t_pocontractlimits
  • t_poservices
  • t_posrvaccessvalues
  • t_poservicestext
  • t_extensionin
  • g_t_idoc_data
  • USING
  • u_poheader
  • u_hdrx_tmp
  • u_poaddrvendor
  • u_testrun
  • u_memory_uncomplete
  • u_memory_complete
  • w_syst_info.

*

  • ELSEIF u_flg_create_change = c_flg_pochange. "CHNG
  • PERFORM zidoc_po_change
  • TABLES
  • t_poitem
  • t_itemx_tmp
  • t_poaddrdelivery
  • t_poschedule
  • t_schdx_tmp
  • t_poaccount
  • t_poaccountprofitsegment
  • t_accntx_tmp
  • t_pocond
  • t_condx_tmp
  • t_polimits
  • t_pocontractlimits
  • t_poservices
  • t_posrvaccessvalues
  • t_poservicestext
  • t_extensionin
  • g_t_idoc_data
  • USING
  • u_purchaseorder
  • u_poheader
  • u_hdrx_tmp
  • u_poaddrvendor
  • u_testrun
  • u_memory_uncomplete
  • u_memory_complete
  • w_syst_info.

*

  • ENDIF.

*

*

**Call Function to create and post the IDOC

  • CALL FUNCTION 'IDOC_INBOUND_SINGLE'
  • EXPORTING
  • pi_idoc_control_rec_40 = w_idoc_comm
  • IMPORTING
  • pe_idoc_number = g_idoc_no
  • TABLES
  • pt_idoc_data_records_40 = g_t_idoc_data
  • EXCEPTIONS
  • idoc_not_saved = 1
  • OTHERS = 2.

*

  • IF sy-subrc <> 0.
    • IDOC_INBOUND_SINGLE failed. IDOC can not be created.
  • MESSAGE e000(z001) WITH text-004.
  • ELSE.
    • Get constant value of Distribution list
  • PERFORM get_constant USING c_dist_list "ZRP_DISTLIST
  • l_bukrs
  • CHANGING l_dist_list
  • l_sy_subrc.
  • IF l_sy_subrc <> 0.
    • Distribution list does not exist
  • MESSAGE e000(z001) WITH text-001.
  • ELSE.

**Subject Line

  • CASE u_flg_create_change.
  • WHEN c_flg_pocreate. "CREA

**PO CREATE failed for PO

  • CONCATENATE text-005
  • u_poheader-po_number
  • INTO l_subline
  • SEPARATED BY space.
  • WHEN c_flg_pochange. "CHNG

**PO change failed for PO

  • CONCATENATE text-002
  • u_purchaseorder
  • INTO l_subline
  • SEPARATED BY space.
  • ENDCASE.

*

**Generate Error Message table to display along with message in inbox.

*

  • CLEAR t_errmsg.
  • REFRESH t_errmsg.

*

  • t_errmsg-sign = c_sign. "I
  • t_errmsg-option = c_option. "EQ

*

**Error Messages :

  • t_errmsg-low = text-006.
  • APPEND t_errmsg.

*

  • CLEAR t_errmsg-low.
  • LOOP AT t_return_msg
  • WHERE type = c_msgtype_e. "E
  • t_errmsg-low = t_return_msg-message.
  • APPEND t_errmsg.
  • CLEAR t_errmsg-low.
  • ENDLOOP.

*

**IDOC number posted is

  • CONCATENATE text-003
  • g_idoc_no
  • INTO l_errmsg
  • SEPARATED BY space.

*

  • t_errmsg-low = l_errmsg.
  • APPEND t_errmsg.

*

**Notify users in distribution list of the failure

  • SUBMIT z_util_notify_distlist AND RETURN
  • WITH p_rgroup = l_dist_list
  • WITH p_objdes = l_subline
  • WITH s_msg IN t_errmsg
  • WITH p_idocno = g_idoc_no.
  • ENDIF.
  • ENDIF.

*ENDFORM. " idoc_create

&--------------------------------------------------------------------

*& Form ZIDOC_PO_CHANGE

&--------------------------------------------------------------------

  • CREATE IDOC DATA RECORD FOR PO CHANGE

---------------------------------------------------------------------

*FORM zidoc_po_change

  • TABLES poitem STRUCTURE bapimepoitem
  • poitemx STRUCTURE bapimepoitemx
  • poaddrdelivery STRUCTURE bapimepoaddrdelivery
  • poschedule STRUCTURE bapimeposchedule
  • poschedulex STRUCTURE bapimeposchedulx
  • poaccount STRUCTURE bapimepoaccount
  • poaccountprofitsegment STRUCTURE
  • bapimepoaccountprofitsegment
  • poaccountx STRUCTURE bapimepoaccountx
  • pocond STRUCTURE bapimepocond
  • pocondx STRUCTURE bapimepocondx
  • polimits STRUCTURE bapiesuhc
  • pocontractlimits STRUCTURE bapiesucc
  • poservices STRUCTURE bapiesllc
  • posrvaccessvalues STRUCTURE bapiesklc
  • poservicestext STRUCTURE bapieslltx
  • extensionin STRUCTURE bapiparex
  • idoc_data STRUCTURE edi_dd40
  • USING
  • purchaseorder LIKE bapimepoheader-po_number
  • poheader LIKE bapimepoheader
  • poheaderx LIKE bapimepoheaderx
  • poaddrvendor LIKE bapimepoaddrvendor
  • testrun LIKE bapiflag-bapiflag
  • memoryuncomplete LIKE bapiflag-bapiflag
  • memorycomplete LIKE bapiflag-bapiflag
  • syst_info LIKE syst .

*

  • DATA: z1zmmpoh LIKE z1zmmpoh.
  • DATA: z1bpmepoheader LIKE z1bpmepoheader.
  • DATA: z1bpmepoheaderx LIKE z1bpmepoheaderx.
  • DATA: z1bpmepoaddrvendor LIKE z1bpmepoaddrvendor.
  • DATA: z1bpmepoaddrvendor1 LIKE z1bpmepoaddrvendor1.
  • DATA: z1bpmepoitem LIKE z1bpmepoitem.
  • DATA: z1bpmepoitemx LIKE z1bpmepoitemx.
  • DATA: z1bpmepoaddrdelivery LIKE z1bpmepoaddrdelivery.
  • DATA: z1bpmepoaddrdelivery1 LIKE z1bpmepoaddrdelivery1.
  • DATA: z1bpmeposchedule LIKE z1bpmeposchedule.
  • DATA: z1bpmeposchedulx LIKE z1bpmeposchedulx.
  • DATA: z1bpmepoaccount LIKE z1bpmepoaccount.
  • DATA: z1bpmepoaccountprofitsegmen LIKE z1bpmepoaccountprofitsegmen.
  • DATA: z1bpmepoaccountx LIKE z1bpmepoaccountx.
  • DATA: z1bpmepocond LIKE z1bpmepocond.
  • DATA: z1bpmepocondx LIKE z1bpmepocondx.
  • DATA: e1bpesuhc LIKE e1bpesuhc.
  • DATA: e1bpesucc LIKE e1bpesucc.
  • DATA: e1bpesllc LIKE e1bpesllc.
  • DATA: e1bpesklc LIKE e1bpesklc.
  • DATA: e1bpeslltx LIKE e1bpeslltx.
  • DATA: e1bpparex LIKE e1bpparex.

*

    • go through all IDoc-segments

**

*

    • for segment 'Z1ZMMPOH'

**

  • CLEAR: z1zmmpoh,
  • idoc_data.
  • MOVE purchaseorder
  • TO z1zmmpoh-purchaseorder.
  • MOVE testrun
  • TO z1zmmpoh-testrun.
  • MOVE memoryuncomplete
  • TO z1zmmpoh-memory_uncomplete.
  • MOVE memorycomplete
  • TO z1zmmpoh-memory_complete.
  • idoc_data-sdata = z1zmmpoh.
  • idoc_data-segnam = c_z1zmmpoh. "Z1ZMMPOH
  • APPEND idoc_data.

*

*

    • for segment 'Z1BPMEPOHEADER'

**

  • CLEAR: z1bpmepoheader,
  • idoc_data.
  • MOVE-CORRESPONDING poheader
  • TO z1bpmepoheader.
  • IF NOT z1bpmepoheader IS INITIAL.
  • CONDENSE z1bpmepoheader-dscnt1_to.
  • CONDENSE z1bpmepoheader-dscnt2_to.
  • CONDENSE z1bpmepoheader-dscnt3_to.
  • CONDENSE z1bpmepoheader-dsct_pct1.
  • CONDENSE z1bpmepoheader-dsct_pct2.
  • CONDENSE z1bpmepoheader-exch_rate.
  • idoc_data-sdata = z1bpmepoheader.
  • idoc_data-segnam = c_z1bpmepoheader. "Z1BPMEPOHEADER
  • APPEND idoc_data.
  • ENDIF.

*

    • for segment 'Z1BPMEPOHEADERX'

**

  • CLEAR: z1bpmepoheaderx,
  • idoc_data.
  • MOVE-CORRESPONDING poheaderx
  • TO z1bpmepoheaderx.
  • IF NOT z1bpmepoheaderx IS INITIAL.
  • idoc_data-sdata = z1bpmepoheaderx.
  • idoc_data-segnam = c_z1bpmepoheaderx. "Z1BPMEPOHEADERX.
  • APPEND idoc_data.
  • ENDIF.

*

    • for segment 'Z1BPMEPOADDRVENDOR'

**

  • CLEAR: z1bpmepoaddrvendor,
  • idoc_data.
  • MOVE-CORRESPONDING poaddrvendor
  • TO z1bpmepoaddrvendor.
  • idoc_data-sdata = z1bpmepoaddrvendor.
  • idoc_data-segnam = c_z1bpmepoaddrvendor.

"Z1BPMEPOADDRVENDOR

  • APPEND idoc_data.

*

    • for segment 'Z1BPMEPOADDRVENDOR1'

**

  • CLEAR: z1bpmepoaddrvendor1,
  • idoc_data.
  • MOVE-CORRESPONDING poaddrvendor
  • TO z1bpmepoaddrvendor1.
  • idoc_data-sdata = z1bpmepoaddrvendor1.
  • idoc_data-segnam = c_z1bpmepoaddrvendor1.

*"Z1BPMEPOADDRVENDOR1

  • APPEND idoc_data.

*

    • for segment 'Z1BPMEPOITEM'

**

  • LOOP AT poitem
  • .
  • CLEAR: z1bpmepoitem,
  • idoc_data.
  • MOVE-CORRESPONDING poitem
  • TO z1bpmepoitem.
  • CONDENSE z1bpmepoitem-quantity.
  • CONDENSE z1bpmepoitem-conv_num1.
  • CONDENSE z1bpmepoitem-conv_den1.
  • CONDENSE z1bpmepoitem-net_price.
  • CONDENSE z1bpmepoitem-price_unit.
  • CONDENSE z1bpmepoitem-gr_pr_time.
  • CONDENSE z1bpmepoitem-reminder1.
  • CONDENSE z1bpmepoitem-reminder2.
  • CONDENSE z1bpmepoitem-reminder3.
  • CONDENSE z1bpmepoitem-over_dlv_tol.
  • CONDENSE z1bpmepoitem-under_dlv_tol.
  • CONDENSE z1bpmepoitem-plan_del.
  • CONDENSE z1bpmepoitem-net_weight.
  • CONDENSE z1bpmepoitem-gross_wt.
  • CONDENSE z1bpmepoitem-volume.
  • CONDENSE z1bpmepoitem-points.
  • CONDENSE z1bpmepoitem-minremlife.
  • idoc_data-sdata = z1bpmepoitem.
  • idoc_data-segnam = c_z1bpmepoitem. "Z1BPMEPOITEM
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOITEMX'

**

  • LOOP AT poitemx
  • .
  • CLEAR: z1bpmepoitemx,
  • idoc_data.
  • MOVE-CORRESPONDING poitemx
  • TO z1bpmepoitemx.
  • idoc_data-sdata = z1bpmepoitemx.
  • idoc_data-segnam = c_z1bpmepoitemx. "Z1BPMEPOITEMX
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOADDRDELIVERY'

**

  • LOOP AT poaddrdelivery
  • .
  • CLEAR: z1bpmepoaddrdelivery,
  • idoc_data.
  • MOVE-CORRESPONDING poaddrdelivery
  • TO z1bpmepoaddrdelivery.
  • idoc_data-sdata = z1bpmepoaddrdelivery.
  • idoc_data-segnam = c_z1bpmepoaddrdelivery.

*"Z1BPMEPOADDRDELIVERY

  • APPEND idoc_data.

*

    • for segment 'Z1BPMEPOADDRDELIVERY1'

**

  • CLEAR: z1bpmepoaddrdelivery1,
  • idoc_data.
  • MOVE-CORRESPONDING poaddrdelivery
  • TO z1bpmepoaddrdelivery1.
  • idoc_data-sdata = z1bpmepoaddrdelivery1.
  • idoc_data-segnam = c_z1bpmepoaddrdelivery1.

"Z1BPMEPOADDRDELIVERY1

  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOSCHEDULE'

**

  • LOOP AT poschedule
  • .
  • CLEAR: z1bpmeposchedule,
  • idoc_data.
  • MOVE-CORRESPONDING poschedule
  • TO z1bpmeposchedule.
  • CONDENSE z1bpmeposchedule-quantity.
  • idoc_data-sdata = z1bpmeposchedule.
  • idoc_data-segnam = c_z1bpmeposchedule. "Z1BPMEPOSCHEDULE
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOSCHEDULX'

**

  • LOOP AT poschedulex
  • .
  • CLEAR: z1bpmeposchedulx,
  • idoc_data.
  • MOVE-CORRESPONDING poschedulex
  • TO z1bpmeposchedulx.
  • idoc_data-sdata = z1bpmeposchedulx.
  • idoc_data-segnam = c_z1bpmeposchedulx. "Z1BPMEPOSCHEDULX
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOACCOUNT'

**

  • LOOP AT poaccount
  • .
  • CLEAR: z1bpmepoaccount,
  • idoc_data.
  • MOVE-CORRESPONDING poaccount
  • TO z1bpmepoaccount.
  • CONDENSE z1bpmepoaccount-quantity.
  • CONDENSE z1bpmepoaccount-distr_perc.
  • CONDENSE z1bpmepoaccount-net_value.
  • CONDENSE z1bpmepoaccount-nond_itax.
  • idoc_data-sdata = z1bpmepoaccount.
  • idoc_data-segnam = c_z1bpmepoaccount. "Z1BPMEPOACCOUNT
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOACCOUNTPROFITSEGMEN'

**

  • LOOP AT poaccountprofitsegment
  • .
  • CLEAR: z1bpmepoaccountprofitsegmen,
  • idoc_data.
  • MOVE-CORRESPONDING poaccountprofitsegment
  • TO z1bpmepoaccountprofitsegmen.
  • idoc_data-sdata = z1bpmepoaccountprofitsegmen.
    • "Z1BPMEPOACCOUNTPROFITSEGMEN
  • idoc_data-segnam = c_z1bpmepoaccountprofitsegmen.
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOACCOUNTX'

**

  • LOOP AT poaccountx
  • .
  • CLEAR: z1bpmepoaccountx,
  • idoc_data.
  • MOVE-CORRESPONDING poaccountx
  • TO z1bpmepoaccountx.
  • idoc_data-sdata = z1bpmepoaccountx.
  • idoc_data-segnam = c_z1bpmepoaccountx. "Z1BPMEPOACCOUNTX
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOCOND'

**

  • LOOP AT pocond
  • .
  • CLEAR: z1bpmepocond,
  • idoc_data.
  • MOVE-CORRESPONDING pocond
  • TO z1bpmepocond.
  • CONDENSE z1bpmepocond-cond_value.
  • CONDENSE z1bpmepocond-cond_p_unt.
  • CONDENSE z1bpmepocond-conbaseval.
  • CONDENSE z1bpmepocond-conexchrat.
  • CONDENSE z1bpmepocond-numconvert.
  • CONDENSE z1bpmepocond-denominato.
  • CONDENSE z1bpmepocond-scalbasval.
  • idoc_data-sdata = z1bpmepocond.
  • idoc_data-segnam = c_z1bpmepocond. "Z1BPMEPOCOND
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOCONDX'

**

  • LOOP AT pocondx
  • .
  • CLEAR: z1bpmepocondx,
  • idoc_data.
  • MOVE-CORRESPONDING pocondx
  • TO z1bpmepocondx.
  • idoc_data-sdata = z1bpmepocondx.
  • idoc_data-segnam = c_z1bpmepocondx. "Z1BPMEPOCONDX
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'E1BPESUHC'

**

  • LOOP AT polimits
  • .
  • CLEAR: e1bpesuhc,
  • idoc_data.
  • MOVE-CORRESPONDING polimits
  • TO e1bpesuhc.
  • CONDENSE e1bpesuhc-limit.
  • CONDENSE e1bpesuhc-exp_value.
  • CONDENSE e1bpesuhc-free_limit.
  • CONDENSE e1bpesuhc-ssc_limit.
  • CONDENSE e1bpesuhc-ssc_perc.
  • CONDENSE e1bpesuhc-tmp_limit.
  • CONDENSE e1bpesuhc-tmp_perc.
  • CONDENSE e1bpesuhc-cont_perc.
  • idoc_data-sdata = e1bpesuhc.
  • idoc_data-segnam = c_e1bpesuhc. "E1BPESUHC
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'E1BPESUCC'

**

  • LOOP AT pocontractlimits
  • .
  • CLEAR: e1bpesucc,
  • idoc_data.
  • MOVE-CORRESPONDING pocontractlimits
  • TO e1bpesucc.
  • CONDENSE e1bpesucc-limit.
  • idoc_data-sdata = e1bpesucc.
  • idoc_data-segnam = c_e1bpesucc. "E1BPESUCC
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'E1BPESLLC'

**

  • LOOP AT poservices
  • .
  • CLEAR: e1bpesllc,
  • idoc_data.
  • MOVE-CORRESPONDING poservices
  • TO e1bpesllc.
  • CONDENSE e1bpesllc-outl_level.
  • CONDENSE e1bpesllc-quantity.
  • CONDENSE e1bpesllc-ovf_tol.
  • CONDENSE e1bpesllc-price_unit.
  • CONDENSE e1bpesllc-gr_price.
  • CONDENSE e1bpesllc-target_val.
  • CONDENSE e1bpesllc-form_val1.
  • CONDENSE e1bpesllc-form_val2.
  • CONDENSE e1bpesllc-form_val3.
  • CONDENSE e1bpesllc-form_val4.
  • CONDENSE e1bpesllc-form_val5.
  • CONDENSE e1bpesllc-userf2_num.
  • idoc_data-sdata = e1bpesllc.
  • idoc_data-segnam = c_e1bpesllc. "E1BPESLLC
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'E1BPESKLC'

**

  • LOOP AT posrvaccessvalues
  • .
  • CLEAR: e1bpesklc,
  • idoc_data.
  • MOVE-CORRESPONDING posrvaccessvalues
  • TO e1bpesklc.
  • CONDENSE e1bpesklc-percentage.
  • idoc_data-sdata = e1bpesklc.
  • idoc_data-segnam = c_e1bpesklc. "E1BPESKLC
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'E1BPESLLTX'

**

  • LOOP AT poservicestext
  • .
  • CLEAR: e1bpeslltx,
  • idoc_data.
  • MOVE-CORRESPONDING poservicestext
  • TO e1bpeslltx.
  • idoc_data-sdata = e1bpeslltx.
  • idoc_data-segnam = c_e1bpeslltx.

"E1BPESLLTX

  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'E1BPPAREX'

**

  • LOOP AT extensionin
  • .
  • CLEAR: e1bpparex,
  • idoc_data.
  • MOVE-CORRESPONDING extensionin
  • TO e1bpparex.
  • idoc_data-sdata = e1bpparex.
  • idoc_data-segnam = c_e1bpparex. "E1BPPAREX
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • end of through all IDoc-segments

**

*

*ENDFORM. " ZIDOC_PO_CHANGE

*&---------------------------------------------------------------------

*

*& Form ZIDOC_PO_CREATE1

*&---------------------------------------------------------------------

*

  • CREATE IDOC DATA RECORD FOR PO CREATE1

*----------------------------------------------------------------------

*

*FORM zidoc_po_create1

  • TABLES poitem STRUCTURE bapimepoitem
  • poitemx STRUCTURE bapimepoitemx
  • poaddrdelivery STRUCTURE bapimepoaddrdelivery
  • poschedule STRUCTURE bapimeposchedule
  • poschedulex STRUCTURE bapimeposchedulx
  • poaccount STRUCTURE bapimepoaccount
  • poaccountprofitsegment STRUCTURE
  • bapimepoaccountprofitsegment
  • poaccountx STRUCTURE bapimepoaccountx
  • pocond STRUCTURE bapimepocond
  • pocondx STRUCTURE bapimepocondx
  • polimits STRUCTURE bapiesuhc
  • pocontractlimits STRUCTURE bapiesucc
  • poservices STRUCTURE bapiesllc
  • posrvaccessvalues STRUCTURE bapiesklc
  • poservicestext STRUCTURE bapieslltx
  • extensionin STRUCTURE bapiparex
  • idoc_data STRUCTURE edi_dd40
  • USING poheader LIKE bapimepoheader
  • poheaderx LIKE bapimepoheaderx
  • poaddrvendor LIKE bapimepoaddrvendor
  • testrun LIKE bapiflag-bapiflag
  • memoryuncomplete LIKE bapiflag-bapiflag
  • memorycomplete LIKE bapiflag-bapiflag
  • syst_info LIKE syst .

*

  • DATA: z1zmmpoc LIKE z1zmmpoc.
  • DATA: z1bpmepoheader LIKE z1bpmepoheader.
  • DATA: z1bpmepoheaderx LIKE z1bpmepoheaderx.
  • DATA: z1bpmepoaddrvendor LIKE z1bpmepoaddrvendor.
  • DATA: z1bpmepoaddrvendor1 LIKE z1bpmepoaddrvendor1.
  • DATA: z1bpmepoitem LIKE z1bpmepoitem.
  • DATA: z1bpmepoitemx LIKE z1bpmepoitemx.
  • DATA: z1bpmepoaddrdelivery LIKE z1bpmepoaddrdelivery.
  • DATA: z1bpmepoaddrdelivery1 LIKE z1bpmepoaddrdelivery1.
  • DATA: z1bpmeposchedule LIKE z1bpmeposchedule.
  • DATA: z1bpmeposchedulx LIKE z1bpmeposchedulx.
  • DATA: z1bpmepoaccount LIKE z1bpmepoaccount.
  • DATA: z1bpmepoaccountprofitsegmen LIKE z1bpmepoaccountprofitsegmen.
  • DATA: z1bpmepoaccountx LIKE z1bpmepoaccountx.
  • DATA: z1bpmepocond LIKE z1bpmepocond.
  • DATA: z1bpmepocondx LIKE z1bpmepocondx.
  • DATA: e1bpesuhc LIKE e1bpesuhc.
  • DATA: e1bpesucc LIKE e1bpesucc.
  • DATA: e1bpesllc LIKE e1bpesllc.
  • DATA: e1bpesklc LIKE e1bpesklc.
  • DATA: e1bpeslltx LIKE e1bpeslltx.
  • DATA: e1bpparex LIKE e1bpparex.

*

    • go through all IDoc-segments

**

*

    • for segment 'Z1ZMMPOC'

**

  • CLEAR: z1zmmpoc,
  • idoc_data.
  • MOVE testrun
  • TO z1zmmpoc-testrun.
  • MOVE memoryuncomplete
  • TO z1zmmpoc-memory_uncomplete.
  • MOVE memorycomplete
  • TO z1zmmpoc-memory_complete.
  • idoc_data-sdata = z1zmmpoc.
  • idoc_data-segnam = c_z1zmmpoc. "Z1ZMMPOC
  • APPEND idoc_data.

*

*

    • for segment 'Z1BPMEPOHEADER'

**

  • CLEAR: z1bpmepoheader,
  • idoc_data.
  • MOVE-CORRESPONDING poheader
  • TO z1bpmepoheader.
  • IF NOT z1bpmepoheader IS INITIAL.
  • CONDENSE z1bpmepoheader-dscnt1_to.
  • CONDENSE z1bpmepoheader-dscnt2_to.
  • CONDENSE z1bpmepoheader-dscnt3_to.
  • CONDENSE z1bpmepoheader-dsct_pct1.
  • CONDENSE z1bpmepoheader-dsct_pct2.
  • CONDENSE z1bpmepoheader-exch_rate.
  • idoc_data-sdata = z1bpmepoheader.
  • idoc_data-segnam = c_z1bpmepoheader. "Z1BPMEPOHEADER
  • APPEND idoc_data.
  • ENDIF.

*

    • for segment 'Z1BPMEPOHEADERX'

**

  • CLEAR: z1bpmepoheaderx,
  • idoc_data.
  • MOVE-CORRESPONDING poheaderx
  • TO z1bpmepoheaderx.
  • IF NOT z1bpmepoheaderx IS INITIAL.
  • idoc_data-sdata = z1bpmepoheaderx.
  • idoc_data-segnam = c_z1bpmepoheaderx. "Z1BPMEPOHEADERX
  • APPEND idoc_data.
  • ENDIF.

*

    • for segment 'Z1BPMEPOADDRVENDOR'

**

  • CLEAR: z1bpmepoaddrvendor,
  • idoc_data.
  • MOVE-CORRESPONDING poaddrvendor
  • TO z1bpmepoaddrvendor.
  • idoc_data-sdata = z1bpmepoaddrvendor.
  • idoc_data-segnam = c_z1bpmepoaddrvendor. "Z1BPMEPOADDRVENDOR
  • APPEND idoc_data.

*

    • for segment 'Z1BPMEPOADDRVENDOR1'

**

  • CLEAR: z1bpmepoaddrvendor1,
  • idoc_data.
  • MOVE-CORRESPONDING poaddrvendor
  • TO z1bpmepoaddrvendor1.
  • idoc_data-sdata = z1bpmepoaddrvendor1.
  • idoc_data-segnam = c_z1bpmepoaddrvendor1. "Z1BPMEPOADDRVENDOR1
  • APPEND idoc_data.

*

    • for segment 'Z1BPMEPOITEM'

**

  • LOOP AT poitem
  • .
  • CLEAR: z1bpmepoitem,
  • idoc_data.
  • MOVE-CORRESPONDING poitem
  • TO z1bpmepoitem.
  • CONDENSE z1bpmepoitem-quantity.
  • CONDENSE z1bpmepoitem-conv_num1.
  • CONDENSE z1bpmepoitem-conv_den1.
  • CONDENSE z1bpmepoitem-net_price.
  • CONDENSE z1bpmepoitem-price_unit.
  • CONDENSE z1bpmepoitem-gr_pr_time.
  • CONDENSE z1bpmepoitem-reminder1.
  • CONDENSE z1bpmepoitem-reminder2.
  • CONDENSE z1bpmepoitem-reminder3.
  • CONDENSE z1bpmepoitem-over_dlv_tol.
  • CONDENSE z1bpmepoitem-under_dlv_tol.
  • CONDENSE z1bpmepoitem-plan_del.
  • CONDENSE z1bpmepoitem-net_weight.
  • CONDENSE z1bpmepoitem-gross_wt.
  • CONDENSE z1bpmepoitem-volume.
  • CONDENSE z1bpmepoitem-points.
  • CONDENSE z1bpmepoitem-minremlife.
  • idoc_data-sdata = z1bpmepoitem.
  • idoc_data-segnam = c_z1bpmepoitem. "Z1BPMEPOITEM
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOITEMX'

**

  • LOOP AT poitemx
  • .
  • CLEAR: z1bpmepoitemx,
  • idoc_data.
  • MOVE-CORRESPONDING poitemx
  • TO z1bpmepoitemx.
  • idoc_data-sdata = z1bpmepoitemx.
  • idoc_data-segnam = c_z1bpmepoitemx. "Z1BPMEPOITEMX
  • APPEND idoc_data.
  • ENDLOOP.

*

*

    • for segment 'Z1BPMEPOADDRDELIVERY'

**

  • LOOP AT poaddrdelivery
  • .
  • CLEAR: z1bpmepoaddrdelivery,
  • idoc_data.
  • MOVE-CORRESPONDING poaddrdelivery
  • TO z1bpmepoaddrdelivery.
  • idoc_data-sdata = z1bpmepoaddrdelivery.
  • idoc_data-segnam = c_z1bpmepoaddrdelivery. "Z1BPMEPOADDRDELIVERY
  • APPEND idoc_data.

*

    • for segment 'Z1BPMEPOADDRDELIVERY1'

**

  • CLEAR: z1bpmepoaddrdelivery1,
  • idoc_data.
  • MOVE-CORRESPONDING poaddrdelivery
  • TO z1bpmepoaddrdelivery1.
  • idoc_data-sdata = z1bpmepoaddrdelivery1.
    • Z1BPMEPOADDRDELIVERY1
  • idoc_data-segnam = c_z1bpmepoaddrdelivery1.
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'Z1BPMEPOSCHEDULE'

**

  • LOOP AT poschedule
  • .
  • CLEAR: z1bpmeposchedule,
  • idoc_data.
  • MOVE-CORRESPONDING poschedule
  • TO z1bpmeposchedule.
  • CONDENSE z1bpmeposchedule-quantity.
  • idoc_data-sdata = z1bpmeposchedule.
  • idoc_data-segnam = c_z1bpmeposchedule. "Z1BPMEPOSCHEDULE
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'Z1BPMEPOSCHEDULX'

**

  • LOOP AT poschedulex
  • .
  • CLEAR: z1bpmeposchedulx,
  • idoc_data.
  • MOVE-CORRESPONDING poschedulex
  • TO z1bpmeposchedulx.
  • idoc_data-sdata = z1bpmeposchedulx.
  • idoc_data-segnam = c_z1bpmeposchedulx. "Z1BPMEPOSCHEDULX
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'Z1BPMEPOACCOUNT'

**

  • LOOP AT poaccount
  • .
  • CLEAR: z1bpmepoaccount,
  • idoc_data.
  • MOVE-CORRESPONDING poaccount
  • TO z1bpmepoaccount.
  • CONDENSE z1bpmepoaccount-quantity.
  • CONDENSE z1bpmepoaccount-distr_perc.
  • CONDENSE z1bpmepoaccount-net_value.
  • CONDENSE z1bpmepoaccount-nond_itax.
  • idoc_data-sdata = z1bpmepoaccount.
  • idoc_data-segnam = c_z1bpmepoaccount. "Z1BPMEPOACCOUNT
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'Z1BPMEPOACCOUNTPROFITSEGMEN'

**

  • LOOP AT poaccountprofitsegment
  • .
  • CLEAR: z1bpmepoaccountprofitsegmen,
  • idoc_data.
  • MOVE-CORRESPONDING poaccountprofitsegment
  • TO z1bpmepoaccountprofitsegmen.
  • idoc_data-sdata = z1bpmepoaccountprofitsegmen.
    • Z1BPMEPOACCOUNTPROFITSEGMEN
  • idoc_data-segnam = c_z1bpmepoaccountprofitsegmen.
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'Z1BPMEPOACCOUNTX'

**

  • LOOP AT poaccountx
  • .
  • CLEAR: z1bpmepoaccountx,
  • idoc_data.
  • MOVE-CORRESPONDING poaccountx
  • TO z1bpmepoaccountx.
  • idoc_data-sdata = z1bpmepoaccountx.
  • idoc_data-segnam = c_z1bpmepoaccountx. "Z1BPMEPOACCOUNTX
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'Z1BPMEPOCOND'

**

  • LOOP AT pocond
  • .
  • CLEAR: z1bpmepocond,
  • idoc_data.
  • MOVE-CORRESPONDING pocond
  • TO z1bpmepocond.
  • CONDENSE z1bpmepocond-cond_value.
  • CONDENSE z1bpmepocond-cond_p_unt.
  • CONDENSE z1bpmepocond-conbaseval.
  • CONDENSE z1bpmepocond-conexchrat.
  • CONDENSE z1bpmepocond-numconvert.
  • CONDENSE z1bpmepocond-denominato.
  • CONDENSE z1bpmepocond-scalbasval.
  • idoc_data-sdata = z1bpmepocond.
  • idoc_data-segnam = c_z1bpmepocond. "Z1BPMEPOCOND
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'Z1BPMEPOCONDX'

**

  • LOOP AT pocondx
  • .
  • CLEAR: z1bpmepocondx,
  • idoc_data.
  • MOVE-CORRESPONDING pocondx
  • TO z1bpmepocondx.
  • idoc_data-sdata = z1bpmepocondx.
  • idoc_data-segnam = c_z1bpmepocondx. "Z1BPMEPOCONDX
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'E1BPESUHC'

**

  • LOOP AT polimits
  • .
  • CLEAR: e1bpesuhc,
  • idoc_data.
  • MOVE-CORRESPONDING polimits
  • TO e1bpesuhc.
  • CONDENSE e1bpesuhc-limit.
  • CONDENSE e1bpesuhc-exp_value.
  • CONDENSE e1bpesuhc-free_limit.
  • CONDENSE e1bpesuhc-ssc_limit.
  • CONDENSE e1bpesuhc-ssc_perc.
  • CONDENSE e1bpesuhc-tmp_limit.
  • CONDENSE e1bpesuhc-tmp_perc.
  • CONDENSE e1bpesuhc-cont_perc.
  • idoc_data-sdata = e1bpesuhc.
  • idoc_data-segnam = c_e1bpesuhc. "E1BPESUHC
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'E1BPESUCC'

**

  • LOOP AT pocontractlimits
  • .
  • CLEAR: e1bpesucc,
  • idoc_data.
  • MOVE-CORRESPONDING pocontractlimits
  • TO e1bpesucc.
  • CONDENSE e1bpesucc-limit.
  • idoc_data-sdata = e1bpesucc.
  • idoc_data-segnam = c_e1bpesucc. "E1BPESUCC
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'E1BPESLLC'

**

  • LOOP AT poservices
  • .
  • CLEAR: e1bpesllc,
  • idoc_data.
  • MOVE-CORRESPONDING poservices
  • TO e1bpesllc.
  • CONDENSE e1bpesllc-outl_level.
  • CONDENSE e1bpesllc-quantity.
  • CONDENSE e1bpesllc-ovf_tol.
  • CONDENSE e1bpesllc-price_unit.
  • CONDENSE e1bpesllc-gr_price.
  • CONDENSE e1bpesllc-target_val.
  • CONDENSE e1bpesllc-form_val1.
  • CONDENSE e1bpesllc-form_val2.
  • CONDENSE e1bpesllc-form_val3.
  • CONDENSE e1bpesllc-form_val4.
  • CONDENSE e1bpesllc-form_val5.
  • CONDENSE e1bpesllc-userf2_num.
  • idoc_data-sdata = e1bpesllc.
  • idoc_data-segnam = c_e1bpesllc. "E1BPESLLC
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'E1BPESKLC'

**

  • LOOP AT posrvaccessvalues
  • .
  • CLEAR: e1bpesklc,
  • idoc_data.
  • MOVE-CORRESPONDING posrvaccessvalues
  • TO e1bpesklc.
  • CONDENSE e1bpesklc-percentage.
  • idoc_data-sdata = e1bpesklc.
  • idoc_data-segnam = c_e1bpesklc. "E1BPESKLC
  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'E1BPESLLTX'

**

  • LOOP AT poservicestext
  • .
  • CLEAR: e1bpeslltx,
  • idoc_data.
  • MOVE-CORRESPONDING poservicestext
  • TO e1bpeslltx.
  • idoc_data-sdata = e1bpeslltx.
  • idoc_data-segnam = c_e1bpeslltx.

"E1BPESLLTX

  • APPEND idoc_data.
  • ENDLOOP.

*

    • for segment 'E1BPPAREX'

**

  • LOOP AT extensionin
  • .
  • CLEAR: e1bpparex,
  • idoc_data.
  • MOVE-CORRESPONDING extensionin
  • TO e1bpparex.
  • idoc_data-sdata = e1bpparex.
  • idoc_data-segnam = c_e1bpparex. "E1BPPAREX
  • APPEND idoc_data.
  • ENDLOOP.

*

    • end of through all IDoc-segments

**

*

*ENDFORM. " ZIDOC_PO_CREATE1

*

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

***BV-27-May-2004 - Begin of Changes for SCR2***

*&---------------------------------------------------------------------

*

*& Form get_account_assignment

*&---------------------------------------------------------------------

*

  • Retrieve the account assignment value from Z table zacctasgmnt
  • and modify the poitem and poitemx data.

*----------------------------------------------------------------------

*

  • -->T_POITEM PO item data
  • -->T_POITEMX PO itemx data
  • -->T_POACCOUNT PO account data
  • -->T_COMPCODE Company code

*----------------------------------------------------------------------

*

FORM get_account_assignment TABLES t_poitem STRUCTURE bapimepoitem

t_poitemx STRUCTURE bapimepoitemx

t_poaccount STRUCTURE

bapimepoaccount

t_poaccountx STRUCTURE

bapimepoaccountx

t_yreturn STRUCTURE bapiret2

USING t_compcode TYPE bukrs

t_poheader TYPE bapimepoheader

.

DATA: t_acct_assignmt LIKE zacctasgmnt OCCURS 0 WITH HEADER LINE.

DATA: l_acct_present(1) TYPE c,

l_cc_present(1) TYPE c,

l_wbs_present(1) TYPE c,

l_acct_assign TYPE zconstval,

l_wa_poaccount type bapimepoaccount,

l_flag(1) type c,

L_flag1(1) type c,

&------------------------------------------------------&

*& Begin of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

l_index TYPE sy-tabix,

"@SDR

l_itemindex TYPE sy-tabix,

"@SDR

l_msgv1 TYPE sy-msgv1,

"@SDR

l_msgv2 TYPE sy-msgv2,

"@SDR

l_constname TYPE zconstname VALUE 'CONVERSION',

"@SDR

l_constval TYPE zconstval ,

"@SDR

l_conv_val TYPE zconstval ,

"@SDR

l_constname_gr TYPE zconstname VALUE 'NONVAL_GRIR' ,

"@SDR

l_constval_gr TYPE zconstval ,

"@SDR

l_ex_pro_no TYPE zexprono ,

"@SDR

l_ex_cc TYPE z_ex_cc ,

"@SDR

l_ex_acc_no TYPE z_acc_no ,

"@SDR

l_costcenter TYPE kostl ,

"@SDR

l_reference TYPE ablad ,

"@SDR

l_psga_glacct TYPE zconstname VALUE 'PSGA_ACCOUNT'.

"@SDR

&------------------------------------------------------&

*& End of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

*BV-08-July-2004 -Begin - Change error handling for zxa_get_constant

DATA : L_CONST_NAME LIKE SY-MSGV1, "Constant name

L_COMP_CODE LIKE SY-MSGV2, "Company code

l_acct_assmnt TYPE knttp.

*BV-08-July-2004 -End - Change error handling for zxa_get_constant

  • Retrieve Account assignment category

SELECT * FROM zacctasgmnt

INTO TABLE t_acct_assignmt

WHERE comp_code EQ t_compcode.

IF sy-subrc = 0.

  • Retrieve Account assignment constant

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

const_name = c_acct_assign

comp_code = t_compcode

IMPORTING

const_value = l_acct_assign

EXCEPTIONS

no_value_found = 1

null_value = 2

OTHERS = 3.

IF sy-subrc <> 0.

**BV-08-July-2004 -Begin - Change error handling for zxa_get_constant

*Constant not defined for company code.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_acct_assign. "ZRP_ACCT_ASSIGN

L_COMP_CODE = t_compcode.

**BV-08-July-2004 -End - Change error handling for zxa_get_constant

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e "E

cl = c_msgid_z001

**BV-08-July-2004 -Begin - Change error handling for zxa_get_constant

  • number = c_msgnr_045 "045

number = c_msgnr_046 "046

PAR1 = L_CONST_NAME "ZRP_ACCT_ASSIGN

PAR2 = L_COMP_CODE

**BV-08-July-2004 -End - Change error handling for zxa_get_constant

IMPORTING

return = t_yreturn.

APPEND t_yreturn.

CLEAR t_yreturn.

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT.

ENDIF.

ENDIF.

&------------------------------------------------------&

*& Begin of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

  • Requirement very specific to Alza

IF t_compcode = c_bukrs_alza. " 1155 "@SDR

  • Check whether the conversion check is switched on for the
  • specific business unit.

CLEAR: l_constval. "@SDR

CALL FUNCTION 'ZXA_GET_CONSTANT' "@SDR

EXPORTING "@SDR

const_name = l_constname "@SDR

comp_code = t_compcode "@SDR

IMPORTING "@SDR

const_value = l_conv_val "@SDR

EXCEPTIONS "@SDR

no_value_found = 1 "@SDR

null_value = 2 "@SDR

OTHERS = 3. "@SDR

"@SDR

IF sy-subrc <> 0. "@SDR

CLEAR l_conv_val. "@SDR

l_msgv1 = l_constname. "@SDR

l_msgv2 = t_compcode. "@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_e "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_046 "@SDR

PAR1 = l_msgv1 "CONVERSION "@SDR

PAR2 = l_msgv2 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn , "@SDR

l_conv_val, "@SDR

l_msgv1 , "@SDR

l_msgv2 .

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT. "@SDR

ENDIF. "@SDR

  • Check whether the Non-valuated GR indicator is Switched ON or OFF

CLEAR: l_constval_gr. "@SDR

CALL FUNCTION 'ZXA_GET_CONSTANT' "@SDR

EXPORTING "@SDR

const_name = l_constname_gr "@SDR

comp_code = t_compcode "@SDR

IMPORTING "@SDR

const_value = l_constval_gr "@SDR

EXCEPTIONS "@SDR

no_value_found = 1 "@SDR

null_value = 2 "@SDR

OTHERS = 3. "@SDR

"@SDR

IF sy-subrc <> 0. "@SDR

CLEAR l_constval_gr. "@SDR

l_msgv1 = l_constname_gr. "@SDR

l_msgv2 = t_compcode. "@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_e "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_046 "@SDR

PAR1 = l_msgv1 "CONVERSION "@SDR

PAR2 = l_msgv2 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn , "@SDR

l_constval_gr, "@SDR

l_msgv1 , "@SDR

l_msgv2 . "@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT. "@SDR

ENDIF. "@SDR

ENDIF. "@SDR

&------------------------------------------------------&

*& End of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

LOOP AT t_poitem.

CLEAR: l_acct_present, l_cc_present, l_wbs_present.

&------------------------------------------------------&

*& Begin of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

l_itemindex = sy-tabix.

"@SDR

&------------------------------------------------------&

*& End of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

LOOP AT t_poaccount WHERE po_item = t_poitem-po_item.

CLEAR: t_acct_assignmt.

&------------------------------------------------------&

*& Begin of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

  • Requirement very specific to Alza

IF t_compcode = c_bukrs_alza. " 1155 "@SDR

  • Arrest the cuurent record number for the loop.

l_index = sy-tabix. "@SDR

  • If the conversion switch is on for the specific business unit
  • use custom mapping tables to fetch the corresponding WBS
  • Elements, GL accounts and Cost Centers

IF l_conv_val = 'X'. " Conversion is switched ON "@SDR

  • Use the below custom FM to retrieve the corresponding GL
  • account from SAP fro the external GL Account Number

IF ( NOT t_compcode IS INITIAL ) "@SDR

AND ( NOT t_poaccount-gl_account IS INITIAL ). "@SDR

IF NOT t_poaccount-costcenter IS INITIAL. "@SDR

SHIFT t_poaccount-costcenter LEFT "@SDR

DELETING LEADING c_zeros. "@SDR

l_ex_cc = t_poaccount-costcenter. "@SDR

CALL FUNCTION 'Z_COSTCTR_GET' "@SDR

EXPORTING "@SDR

P_BUKRS = t_compcode "@SDR

P_EX_CC = l_ex_cc "@SDR

IMPORTING "@SDR

P_COSTCTR = l_costcenter "@SDR

EXCEPTIONS "@SDR

NO_VALUE_FOUND = 1 "@SDR

NULL_VALUE_FOUND = 2 "@SDR

OTHERS = 3. "@SDR

IF sy-subrc <> 0. "@SDR

t_poaccount-costcenter = space. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING costcenter. "@SDR

READ TABLE t_poaccountx WITH "@SDR

KEY po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-costcenter = space. "@SDR

MODIFY t_poaccountx INDEX l_index "@SDR

TRANSPORTING costcenter. "@SDR

ENDIF. "@SDR

l_msgv1 = l_costcenter. "@SDR

l_msgv2 = t_compcode. "@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_e "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_072 "@SDR

PAR1 = l_msgv1 "@SDR

PAR2 = l_msgv2 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

CLEAR: l_index, "@SDR

l_costcenter. "@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn, "@SDR

l_constval, "@SDR

l_msgv1 , "@SDR

l_msgv2 . "@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT. "@SDR

ELSE. "@SDR

SHIFT l_costcenter LEFT "@SDR

DELETING LEADING c_zeros. "@SDR

IF l_costcenter = c_psgaw_cc. " 54123 "@SDR

CLEAR: l_constval. "@SDR

CALL FUNCTION 'ZXA_GET_CONSTANT' "@SDR

EXPORTING "@SDR

const_name = l_psga_glacct "@SDR

comp_code = t_compcode "@SDR

IMPORTING "@SDR

const_value = l_constval "@SDR

EXCEPTIONS "@SDR

no_value_found = 1 "@SDR

null_value = 2 "@SDR

OTHERS = 3. "@SDR

"@SDR

IF sy-subrc <> 0. "@SDR

t_poaccount-gl_account = space. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING gl_account. "@SDR

READ TABLE t_poaccountx WITH KEY "@SDR

po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-gl_account = space. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING gl_account. "@SDR

ENDIF. "@SDR

CLEAR l_constval. "@SDR

l_msgv1 = l_constname. "@SDR

l_msgv2 = t_compcode. "@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_e "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_046 "@SDR

PAR1 = l_msgv1 "CONVERSION "@SDR

PAR2 = l_msgv2 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn , "@SDR

l_constval, "@SDR

l_msgv1 , "@SDR

l_msgv2 . "@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number

.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT. "@SDR

ELSE. "@SDR

MOVE l_constval TO "@SDR

t_poaccount-gl_account. "@SDR

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "@SDR

INPUT = t_poaccount-gl_account

IMPORTING "@SDR

OUTPUT = t_poaccount-gl_account.

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING gl_account. "@SDR

ENDIF. "@SDR

ELSE. "@SDR

SHIFT t_poaccount-gl_account LEFT "@SDR

DELETING LEADING c_zeros. "@SDR

SHIFT t_poaccount-gl_account "@SDR

BY 1 PLACES RIGHT. "@SDR

t_poaccount-gl_account+0(1) = 'P'. "@SDR

l_ex_acc_no = t_poaccount-gl_account. "@SDR

CALL FUNCTION 'Z_GLACCT_GET' "@SDR

EXPORTING "@SDR

P_BUKRS = t_compcode "@SDR

P_EX_ACC_NO = l_ex_acc_no "@SDR

IMPORTING "@SDR

P_GLACCT = "@SDR

t_poaccount-gl_account "@SDR

EXCEPTIONS "@SDR

NO_VALUE_FOUND = 1 "@SDR

NULL_VALUE_FOUND = 2 "@SDR

OTHERS = 3. "@SDR

"@SDR

IF sy-subrc = 0. "@SDR

  • Assign the retrieved GL Account from SAP tothe
  • account assignment strcuture after the mapping
  • is successful

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "@SDR

INPUT = t_poaccount-gl_account

IMPORTING "@SDR

OUTPUT = t_poaccount-gl_account.

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING gl_account. "@SDR

ELSE. "@SDR

t_poaccount-gl_account = space. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING gl_account. "@SDR

READ TABLE t_poaccountx WITH KEY "@SDR

po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-gl_account = space. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING gl_account. "@SDR

ENDIF. "@SDR

  • Issue an error message that the mapping of the
  • external Reference Number to SAP GL Account
  • has not been possible as no mapping or null
  • mapping has been maintained in the custom mapping table

l_msgv1 = t_poaccount-gl_account. "@SDR

l_msgv2 = t_compcode. "@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_e "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_071 "@SDR

PAR1 = l_msgv1 "@SDR

PAR2 = l_msgv2 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

CLEAR: l_index, "@SDR

t_poaccount-gl_account. "@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn, "@SDR

l_constval, "@SDR

l_msgv1 , "@SDR

l_msgv2 . "@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number

.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT. "@SDR

ENDIF. "@SDR

ENDIF. "@SDR

ENDIF. "@SDR

ELSE. "@SDR

t_poaccount-gl_account = space. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING gl_account. "@SDR

READ TABLE t_poaccountx "@SDR

WITH KEY po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-gl_account = space. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING gl_account. "@SDR

ENDIF. "@SDR

ENDIF. "@SDR

ENDIF. "@SDR

IF l_costcenter = c_psgaw_cc. " 54123 "@SDR

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "@SDR

EXPORTING "@SDR

INPUT = l_costcenter "@SDR

IMPORTING "@SDR

OUTPUT = l_costcenter. "@SDR

t_poaccount-costcenter = l_costcenter. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING costcenter. "@SDR

t_poaccount-wbs_element = space. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING wbs_element. "@SDR

READ TABLE t_poaccountx "@SDR

WITH KEY po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-wbs_element = space. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING wbs_element. "@SDR

ENDIF. "@SDR

ELSE. "@SDR

  • Check whether REFERENCE field is the same as Department

MOVE t_poaccount-unload_pt TO l_reference. "@SDR

SHIFT l_reference LEFT DELETING LEADING c_zeros. "@SDR

  • Check for external GL accounts starting with P164, P165 or
  • P169 and Reference is blank or starts with 4 zeros

IF ( ( l_ex_acc_no+0(4) = c_p164 "P164 "@SDR

OR l_ex_acc_no+0(4) = c_p165 "P165 "@SDR

OR l_ex_acc_no+0(4) = c_p169 ) "P169 "@SDR

AND ( l_reference IS INITIAL

"@SDR

OR ( t_poaccount-unload_pt+0(4) = c_4zeros ) ) ).

"@SDR

CLEAR: l_constval. "@SDR

CALL FUNCTION 'ZXA_GET_CONSTANT' "@SDR

EXPORTING "@SDR

const_name = c_wbs_default "@SDR

comp_code = t_compcode "@SDR

IMPORTING "@SDR

const_value = l_constval "@SDR

EXCEPTIONS "@SDR

no_value_found = 1 "@SDR

null_value = 2 "@SDR

OTHERS = 3. "@SDR

"@SDR

IF sy-subrc <> 0. "@SDR

t_poaccount-wbs_element = space. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING wbs_element. "@SDR

READ TABLE t_poaccountx WITH KEY "@SDR

po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-wbs_element = space. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING wbs_element. "@SDR

ENDIF. "@SDR

CLEAR l_constval. "@SDR

l_msgv1 = l_constname. "@SDR

l_msgv2 = t_compcode. "@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_e "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_046 "@SDR

PAR1 = l_msgv1 "CONVERSION "@SDR

PAR2 = l_msgv2 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn , "@SDR

l_constval, "@SDR

l_msgv1 , "@SDR

l_msgv2 . "@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT. "@SDR

ELSE. "@SDR

t_poaccount-wbs_element = l_constval. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING wbs_element. "@SDR

READ TABLE t_poaccountx WITH KEY "@SDR

po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-wbs_element = 'X'. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING wbs_element. "@SDR

ENDIF. "@SDR

t_poaccount-costcenter = space. "@SDR

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING costcenter. "@SDR

READ TABLE t_poaccountx WITH KEY "@SDR

po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-costcenter = space. "@SDR

MODIFY t_poaccountx INDEX l_index "@SDR

TRANSPORTING costcenter. "@SDR

ENDIF. "@SDR

ENDIF. "@SDR

ELSE.

"@SDR

IF t_poaccount-costcenter = l_reference.

"@SDR

  • Map the Popelsoft Cost Center into SAP Cost Center

IF ( NOT t_compcode IS INITIAL )

"@SDR

AND ( NOT t_poaccount-costcenter IS INITIAL ).

"@SDR

SHIFT t_poaccount-costcenter LEFT "@SDR

DELETING LEADING c_zeros. "@SDR

l_ex_cc = t_poaccount-costcenter. "@SDR

CALL FUNCTION 'Z_COSTCTR_GET' "@SDR

EXPORTING "@SDR

P_BUKRS = t_compcode "@SDR

P_EX_CC = l_ex_cc "@SDR

IMPORTING "@SDR

P_COSTCTR = "@SDR

t_poaccount-costcenter "@SDR

EXCEPTIONS "@SDR

NO_VALUE_FOUND = 1 "@SDR

NULL_VALUE_FOUND = 2 "@SDR

OTHERS = 3. "@SDR

"@SDR

IF sy-subrc = 0. "@SDR

  • Assign the retrieved Cost Center from SAP to the
  • account assignment strcuture after the mapping is
  • successful

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' "@SDR

EXPORTING "@SDR

INPUT = t_poaccount-costcenter

IMPORTING "@SDR

OUTPUT = t_poaccount-costcenter.

MODIFY t_poaccount INDEX l_index "@SDR

TRANSPORTING costcenter. "@SDR

ELSE. "@SDR

READ TABLE t_poaccountx WITH KEY "@SDR

po_item = t_poaccount-po_item "@SDR

serial_no = t_poaccount-serial_no. "@SDR

IF sy-subrc = 0. "@SDR

t_poaccountx-costcenter = space. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING costcenter. "@SDR

ENDIF. "@SDR

  • Issue an error message that the mapping of the
  • external Reference Number to SAP WBS Element has
  • not been possible as no mapping or null mapping
  • has been maintained in the custom mapping table

l_msgv1 = t_poaccount-costcenter. "@SDR

l_msgv2 = t_compcode. "@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_e "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_072 "@SDR

PAR1 = l_msgv1 "@SDR

PAR2 = l_msgv2 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

CLEAR: l_index, "@SDR

t_poaccount-costcenter. "@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn, "@SDR

l_constval, "@SDR

l_msgv1 , "@SDR

l_msgv2 . "@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number

.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT. "@SDR

ENDIF. "@SDR

ENDIF.

"@SDR

ELSE.

"@SDR

  • IF the first 4 digits of the Reference field is 0, even
  • then charge it to a cost center else to a project

IF ( NOT t_poaccount-unload_pt IS INITIAL )

"@SDR

AND ( NOT t_compcode IS INITIAL ).

"@SDR

IF t_poaccount-unload_pt+0(4) = c_4zeros.

"@SDR

IF NOT t_poaccount-costcenter IS INITIAL.

"@SDR

SHIFT t_poaccount-costcenter LEFT

"@SDR

DELETING LEADING c_zeros.

"@SDR

l_ex_cc = t_poaccount-costcenter.

"@SDR

CALL FUNCTION 'Z_COSTCTR_GET'

"@SDR

EXPORTING

"@SDR

P_BUKRS = t_compcode

"@SDR

P_EX_CC = l_ex_cc

"@SDR

IMPORTING

"@SDR

P_COSTCTR =

"@SDR

t_poaccount-costcenter

"@SDR

EXCEPTIONS

"@SDR

NO_VALUE_FOUND = 1

"@SDR

NULL_VALUE_FOUND = 2

"@SDR

OTHERS = 3.

"@SDR

"@SDR

IF sy-subrc = 0.

"@SDR

  • Assign the retrieved Cost Center from SAP to the
  • account assignment strcuture after the mapping is
  • successful

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

"@SDR

EXPORTING

"@SDR

INPUT = t_poaccount-costcenter

IMPORTING

"@SDR

OUTPUT = t_poaccount-costcenter

.

MODIFY t_poaccount INDEX l_index

"@SDR

TRANSPORTING costcenter.

"@SDR

ELSE.

"@SDR

READ TABLE t_poaccountx WITH KEY

"@SDR

po_item = t_poaccount-po_item

"@SDR

serial_no = t_poaccount-serial_no.

"@SDR

IF sy-subrc = 0.

"@SDR

t_poaccountx-costcenter = space.

"@SDR

MODIFY t_poaccountx INDEX sy-tabix

"@SDR

TRANSPORTING costcenter.

"@SDR

ENDIF.

"@SDR

  • Issue an error message that the mapping of the
  • external Reference Number to SAP WBS Element has
  • not been possible as no mapping or null mapping
  • has been maintained in the custom mapping table

l_msgv1 = t_poaccount-costcenter.

"@SDR

l_msgv2 = t_compcode.

"@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

"@SDR

EXPORTING

"@SDR

TYPE = c_msgtype_e

"@SDR

CL = c_msgid_z001

"@SDR

NUMBER = c_msgnr_072

"@SDR

PAR1 = l_msgv1

"@SDR

PAR2 = l_msgv2

"@SDR

IMPORTING

"@SDR

RETURN = t_yreturn.

"@SDR

CLEAR: l_index,

"@SDR

t_poaccount-costcenter.

"@SDR

"@SDR

APPEND t_yreturn.

"@SDR

CLEAR: t_yreturn,

"@SDR

l_constval,

"@SDR

l_msgv1 ,

"@SDR

l_msgv2 .

"@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number

.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number

.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT.

"@SDR

ENDIF.

"@SDR

ENDIF.

"@SDR

ELSE.

  • Use the below custom FM to retrieve the corresponding
  • WBS element from SAP for the external Reference number
  • available if at all

l_ex_pro_no = t_poaccount-unload_pt.

"@SDR

CALL FUNCTION 'Z_WBSELEM_GET'

"@SDR

EXPORTING

"@SDR

P_BUKRS = t_compcode

"@SDR

P_EX_PRO_NO = l_ex_pro_no

"@SDR

IMPORTING

"@SDR

P_WBS_ELEMENT =

"@SDR

t_poaccount-wbs_element

"@SDR

EXCEPTIONS

"@SDR

NO_VALUE_FOUND = 1

"@SDR

NULL_VALUE_FOUND = 2

"@SDR

OTHERS = 3.

"@SDR

"@SDR

IF sy-subrc = 0.

"@SDR

  • Assign the retrieved WBS Element from SAP to the
  • account assignment strcuture after the mapping is
  • successful

MODIFY t_poaccount INDEX l_index

"@SDR

TRANSPORTING wbs_element.

"@SDR

READ TABLE t_poaccountx WITH KEY

"@SDR

po_item = t_poaccount-po_item

"@SDR

serial_no = t_poaccount-serial_no.

"@SDR

IF sy-subrc = 0.

"@SDR

t_poaccountx-wbs_element = 'X'. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING wbs_element. "@SDR

ENDIF.

"@SDR

t_poaccount-costcenter = space.

"@SDR

MODIFY t_poaccount INDEX l_index

"@SDR

TRANSPORTING costcenter.

"@SDR

READ TABLE t_poaccountx

"@SDR

WITH KEY po_item = t_poaccount-po_item

"@SDR

serial_no = t_poaccount-serial_no.

"@SDR

IF sy-subrc = 0.

"@SDR

t_poaccountx-costcenter = space. "@SDR

MODIFY t_poaccountx INDEX sy-tabix "@SDR

TRANSPORTING costcenter. "@SDR

ENDIF.

"@SDR

ELSE.

"@SDR

  • Issue an error message that the mapping of the
  • external Reference Number to SAP WBS Element has
  • not been possible as no mapping or null mapping
  • has been maintained in the custom mapping table

l_msgv1 = t_poaccount-unload_pt. "@SDR

l_msgv2 = t_compcode. "@SDR

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_e "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_066 "@SDR

PAR1 = l_msgv1 "@SDR

PAR2 = l_msgv2 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

CLEAR: l_index, "@SDR

t_poaccount-wbs_element. "@SDR

"@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn, "@SDR

l_constval, "@SDR

l_msgv1 , "@SDR

l_msgv2 . "@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number

.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT. "@SDR

ENDIF.

"@SDR

ENDIF.

"@SDR

ENDIF.

"@SDR

ENDIF.

"@SDR

ENDIF.

"@SDR

ENDIF. "@SDR

  • IF t_poaccount-wbs_element IS INITIAL.

"@SDR

  • ELSE.

"@SDR

  • CLEAR t_poaccount-costcenter.

"@SDR

  • MODIFY t_poaccount INDEX l_index

"@SDR

  • TRANSPORTING costcenter.

"@SDR

  • READ TABLE t_poaccountx

"@SDR

  • WITH KEY po_item = t_poaccount-po_item.

"@SDR

  • IF sy-subrc = 0.

"@SDR

  • t_poaccountx-costcenter = space.

"@SDR

  • MODIFY t_poaccountx INDEX sy-tabix TRANSPORTING

"@SDR

  • costcenter.

"@SDR

*

  • ENDIF.

"@SDR

  • ENDIF.

"@SDR

ELSE. " Conversion is switched OFF "@SDR

  • If the conversion switch is OFF, issue a warning message
  • saying that the Division/Location, Subcode and Reference
  • fields are no longer used for Alza; contents will be
  • ignored

IF NOT t_poaccount-unload_pt IS INITIAL.

CALL FUNCTION 'BALW_BAPIRETURN_GET2' "@SDR

EXPORTING "@SDR

TYPE = c_msgtype_w "@SDR

CL = c_msgid_z001 "@SDR

NUMBER = c_msgnr_067 "@SDR

IMPORTING "@SDR

RETURN = t_yreturn. "@SDR

"@SDR

APPEND t_yreturn. "@SDR

CLEAR: t_yreturn, "@SDR

l_constval. "@SDR

loop at t_yreturn.

l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.

l_wa_zerrors-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

ENDIF. "@SDR

ENDIF. "@SDR

ENDIF.

"@SDR

&------------------------------------------------------&

*& End of Addition: 26-Sep-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

IF NOT t_poaccount-costcenter IS INITIAL.

l_cc_present = c_x. "X

ENDIF.

IF NOT t_poaccount-wbs_element IS INITIAL.

l_wbs_present = c_x. "X

ENDIF.

IF NOT t_poaccount-gl_account IS INITIAL.

l_acct_present = c_x. "X

ENDIF.

READ TABLE t_acct_assignmt WITH KEY

cost_center = l_cc_present

wbs_element = l_wbs_present

gl_account = l_acct_present.

IF t_acct_assignmt-acct_assgmnt = l_acct_assign. "F

EXIT.

ENDIF.

ENDLOOP.

IF sy-subrc EQ 0.

t_poitem-acctasscat = t_acct_assignmt-acct_assgmnt.

MODIFY t_poitem.

READ TABLE t_poitemx WITH KEY po_item = t_poitem-po_item.

IF sy-subrc EQ 0.

t_poitemx-acctasscat = c_x. "X

MODIFY t_poitemx INDEX sy-tabix.

ENDIF.

ENDIF.

&------------------------------------------------------&

*& Begin of Addition: 21-oct-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

  • Final Invoice Indicator checked for all POs for conversion

IF t_compcode = c_bukrs_alza AND l_constval_gr = c_x. "@SDR

t_poitem-final_inv = c_x. "@SDR

MODIFY t_poitem INDEX l_itemindex TRANSPORTING final_inv. "@SDR

READ TABLE t_poitemx WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-final_inv = c_x. "@SDR

MODIFY t_poitemx INDEX sy-tabix TRANSPORTING final_inv."@SDR

ENDIF. "@SDR

ENDIF. "@SDR

  • NON VALUATED GR Indicator
  • Case1: NONVAL GR (Active) GR from Ariba (Active) With Split

IF t_compcode = c_bukrs_alza "1155 "@SDR

AND l_constval_gr = c_x "X "@SDR

AND t_poitem-gr_ind = c_x "X "@SDR

AND NOT t_poitem-distrib IS INITIAL . "@SDR

  • GR Flag (Active) Non val GR (active)

t_poitem-gr_non_val = c_x. "X "@SDR

MODIFY t_poitem INDEX l_itemindex "@SDR

TRANSPORTING gr_non_val. "@SDR

READ TABLE t_poitemx "@SDR

WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-gr_non_val = c_x. "X "@SDR

MODIFY t_poitemx INDEX sy-tabix "@SDR

TRANSPORTING gr_non_val. "@SDR

ENDIF. "@SDR

  • Case 2: NONVAL GR (Active) GR from Ariba (Active) Without Split

ELSEIF t_compcode = c_bukrs_alza "1155 "@SDR

AND l_constval_gr = c_x "X "@SDR

AND t_poitem-gr_ind = c_x "X "@SDR

AND t_poitem-distrib IS INITIAL . "@SDR

  • GR Flag (Active) Non val GR (active)

t_poitem-gr_non_val = c_x. "X "@SDR

MODIFY t_poitem INDEX l_itemindex "@SDR

TRANSPORTING gr_non_val. "@SDR

READ TABLE t_poitemx "@SDR

WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-gr_non_val = c_x. "X "@SDR

MODIFY t_poitemx INDEX sy-tabix "@SDR

TRANSPORTING gr_non_val. "@SDR

ENDIF. "@SDR

  • Case 3: NONVAL GR (Active) GR from Ariba (InActive) With Split

ELSEIF t_compcode = c_bukrs_alza "1155 "@SDR

AND l_constval_gr = c_x "X "@SDR

AND t_poitem-gr_ind IS INITIAL "@SDR

AND NOT t_poitem-distrib IS INITIAL . "@SDR

  • GR Flag (InActive) Non val GR (Inactive)

t_poitem-gr_non_val = space. "@SDR

MODIFY t_poitem INDEX l_itemindex "@SDR

TRANSPORTING gr_non_val. "@SDR

READ TABLE t_poitemx "@SDR

WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-gr_non_val = space. "@SDR

MODIFY t_poitemx INDEX sy-tabix "@SDR

TRANSPORTING gr_non_val. "@SDR

ENDIF. "@SDR

  • Case 4: NONVAL GR (Active) GR from Ariba (InActive) Without Split

ELSEIF t_compcode = c_bukrs_alza "1155 "@SDR

AND l_constval_gr = c_x "X "@SDR

AND t_poitem-gr_ind IS INITIAL "@SDR

AND t_poitem-distrib IS INITIAL . "@SDR

  • GR Flag (InActive) Non val GR (Inactive)

t_poitem-gr_non_val = space. "@SDR

MODIFY t_poitem INDEX l_itemindex "@SDR

TRANSPORTING gr_non_val. "@SDR

READ TABLE t_poitemx "@SDR

WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-gr_non_val = space. "@SDR

MODIFY t_poitemx INDEX sy-tabix "@SDR

TRANSPORTING gr_non_val. "@SDR

ENDIF. "@SDR

  • Case 5: NONVAL GR (InActive) GR from Ariba (Active) With Split

ELSEIF t_compcode = c_bukrs_alza "1155 "@SDR

AND l_constval_gr = 'Y' "@SDR

AND t_poitem-gr_ind = c_x "X "@SDR

AND NOT t_poitem-distrib IS INITIAL . "@SDR

  • GR Flag (Active) Non val GR (active)

t_poitem-gr_non_val = c_x. "X "@SDR

MODIFY t_poitem INDEX l_itemindex "@SDR

TRANSPORTING gr_non_val. "@SDR

READ TABLE t_poitemx "@SDR

WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-gr_non_val = c_x. "X "@SDR

MODIFY t_poitemx INDEX sy-tabix "@SDR

TRANSPORTING gr_non_val. "@SDR

ENDIF. "@SDR

  • Case 6: NONVAL GR (InActive) GR from Ariba (Active) Without Split

ELSEIF t_compcode = c_bukrs_alza "1155 "@SDR

AND l_constval_gr = 'Y' "@SDR

AND t_poitem-gr_ind = c_x "X "@SDR

AND t_poitem-distrib IS INITIAL . "@SDR

  • GR Flag (Active) Non val GR (Inactive)

t_poitem-gr_non_val = space. "@SDR

MODIFY t_poitem INDEX l_itemindex "@SDR

TRANSPORTING gr_non_val. "@SDR

READ TABLE t_poitemx "@SDR

WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-gr_non_val = space. "@SDR

MODIFY t_poitemx INDEX sy-tabix "@SDR

TRANSPORTING gr_non_val. "@SDR

ENDIF. "@SDR

  • Case 7: NONVAL GR (InActive) GR from Ariba (InActive) With Split

ELSEIF t_compcode = c_bukrs_alza "1155 "@SDR

AND l_constval_gr = 'Y' "@SDR

AND t_poitem-gr_ind IS INITIAL "@SDR

AND NOT t_poitem-distrib IS INITIAL . "@SDR

  • GR Flag (InActive) Non val GR (Inactive)

t_poitem-gr_non_val = space. "@SDR

MODIFY t_poitem INDEX l_itemindex "@SDR

TRANSPORTING gr_non_val. "@SDR

READ TABLE t_poitemx "@SDR

WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-gr_non_val = space. "@SDR

MODIFY t_poitemx INDEX sy-tabix "@SDR

TRANSPORTING gr_non_val. "@SDR

ENDIF. "@SDR

  • Case 8: NONVAL GR (InActive) GR from Ariba (InActive) W/O Split

ELSEIF t_compcode = c_bukrs_alza "1155 "@SDR

AND l_constval_gr = 'Y' "@SDR

AND t_poitem-gr_ind IS INITIAL "@SDR

AND t_poitem-distrib IS INITIAL . "@SDR

  • GR Flag (InActive) Non val GR (Inactive)

t_poitem-gr_non_val = space. "@SDR

MODIFY t_poitem INDEX l_itemindex "@SDR

TRANSPORTING gr_non_val. "@SDR

READ TABLE t_poitemx "@SDR

WITH KEY po_item = t_poitem-po_item. "@SDR

IF sy-subrc = 0. "@SDR

t_poitemx-gr_non_val = space. "@SDR

MODIFY t_poitemx INDEX sy-tabix "@SDR

TRANSPORTING gr_non_val. "@SDR

ENDIF. "@SDR

ENDIF. "@SDR

&------------------------------------------------------&

*& End of Addition: 21-oct-2005 SDUTTARO RD1K910316 *&

&------------------------------------------------------&

&----------------------------------------------------&

*& Begin of Addition: -Sep-2005 SDUTTARO RD1K910316 *&

&----------------------------------------------------&

  • Clear all the local variables.

CLEAR: l_index ,

"@SDR

l_constval ,

"@SDR

l_itemindex,

"@SDR

l_ex_pro_no.

"@SDR

&----------------------------------------------------&

*& End of Addition: -Sep-2005 SDUTTARO RD1K910316 *&

&----------------------------------------------------&

ENDLOOP.

************************************************************

  • MOD-003

***********************************************************

DATA: L_TABIX TYPE SY-TABIX.

  • Retrieve Account assignment category
  • SELECT * FROM zacctasgmnt
  • INTO TABLE t_acct_assignmt
  • WHERE comp_code EQ t_compcode.

*

  • IF sy-subrc = 0.
    • Retrieve Account assignment constant
  • CALL FUNCTION 'ZXA_GET_CONSTANT'
  • EXPORTING
  • const_name = c_acct_assign
  • comp_code = t_compcode
  • IMPORTING
  • const_value = l_acct_assign
  • EXCEPTIONS
  • no_value_found = 1
  • null_value = 2
  • OTHERS = 3.
  • IF sy-subrc <> 0.
  • CLEAR : L_CONST_NAME,
  • L_COMP_CODE.

*

  • L_CONST_NAME = c_acct_assign. "ZRP_ACCT_ASSIGN
  • L_COMP_CODE = t_compcode.
  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • type = c_msgtype_e "E
  • cl = c_msgid_z001
  • number = c_msgnr_046 "046
  • PAR1 = L_CONST_NAME "ZRP_ACCT_ASSIGN
  • PAR2 = L_COMP_CODE
  • IMPORTING
  • return = t_yreturn.

*

  • APPEND t_yreturn.
  • CLEAR t_yreturn.

*

  • EXIT.
  • ENDIF.
  • ENDIF.

data: l_prart type ps_prart,

l_belkz type ps_belkz,

l_glaccount type ZCONSTVAL,

l_anln1 type anln1,

l_anln2 type anln2,

P_XSPEB type xspeb_anla.

constants: c_gl_acc_po type ZCONSTname value 'Z_P2P_GL_ACC_PO'.

DATA: L_werks type werks_d.

data: l_location type stort_t499s.

data: l_prev_item type ebelp.

data: l_glacc(10) type c.

data: l_cost(10) type c.

LOOP AT t_poitem.

CLEAR: l_acct_present, l_cc_present, l_wbs_present.

l_itemindex = sy-tabix.

"@SDR

CLEAR: t_acct_assignmt.

LOOP AT t_poaccount WHERE po_item = t_poitem-po_item.

l_tabix = sy-tabix.

CLEAR: L_ACCT_ASSMNT.

SELECT SINGLE ACCT_ASSGMNT

INTO L_ACCT_ASSMNT

FROM ZP2P_ACCTASSCATG

WHERE ZACCT_TYPE = T_POACCOUNT-ZACCT_TYPE.

if sy-subrc = 0.

t_poitem-acctasscat = l_acct_assmnt.

modify t_poitem transporting acctasscat.

endif.

ENDLOOP.

ENDLOOP.

LOOP AT t_poitem.

CLEAR: l_acct_present, l_cc_present, l_wbs_present.

l_itemindex = sy-tabix.

"@SDR

CLEAR: t_acct_assignmt.

LOOP AT t_poaccount WHERE po_item = t_poitem-po_item.

l_tabix = sy-tabix.

*MOD-004

IF NOT t_poaccount-costcenter IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-costcenter

IMPORTING

OUTPUT = l_cost.

IF L_COST NE '0000000000'.

MOVE: L_COST TO T_POACCOUNT-COSTCENTER.

ENDIF.

ENDIF.

IF NOT t_poaccount-gl_account IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-gl_account

IMPORTING

OUTPUT = l_glacc.

IF L_GLACC NE '0000000000'.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

ENDIF.

ENDIF.

*MOD-004

**MOD-003

  • if l_tabix > 1.
  • perform check_split_accounts using t_poaccount-gl_account
  • l_glaccount
  • t_poheader
  • t_compcode
  • l_prev_item
  • t_poitem-po_item.
  • endif.

*MOD-003

  • Split Accounting check
  • if t_poaccount-gl_account = l_glaccount.
  • CLEAR : L_CONST_NAME,
  • L_COMP_CODE.

*

  • L_CONST_NAME = l_glaccount.
  • L_COMP_CODE = t_compcode.
  • 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.
  • l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.
  • l_wa_zerrors-COMP_CODE = t_poheader-comp_code.
  • l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.
  • l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.
  • l_wa_zerrors-ZDATE = sy-datum.
    • l_wa_zerrors-ERR_MSG = c_msgnr_613.
  • read table t_yreturn index 1.
  • l_wa_zerrors-ERR_MSG = t_yreturn-message.
  • insert into zerrors values l_wa_zerrors.
  • clear: l_wa_zerrors.

*

  • ENDIF.
  • endif.

clear: l_prart, l_belkz.

If t_poaccount-zacct_type = C_W1. "'W'.

*********************************************

  • Case 1 Expense WBS

*********************************************

CLEAR: L_ACCT_ASSMNT.

SELECT SINGLE ACCT_ASSGMNT

INTO L_ACCT_ASSMNT

FROM ZP2P_ACCTASSCATG

WHERE ZACCT_TYPE = T_POACCOUNT-ZACCT_TYPE.

IF L_ACCT_ASSMNT = C_P1.

  • IF t_poitem-acctasscat = C_P1. "'P'.

IF NOT t_poaccount-gl_account IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-gl_account

IMPORTING

OUTPUT = l_glacc.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

clear: l_flag.

*mod-004

  • perform validate_gl_account using t_poaccount-gl_account
  • t_compcode
  • changing l_flag.

*mod-004

perform validate_gl_account using l_glacc

t_compcode

changing l_flag.

IF L_FLAG NE 'X'.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

PERFORM GET_CONSTANT_ZXA USING t_poheader

t_compcode

l_wa_zerrors

changing l_glaccount.

IF sy-subrc <> 0.

EXIT.

ELSE.

if not t_poaccount-wbs_element is initial.

perform check_project_type

using t_poaccount-wbs_element

t_poheader

t_compcode.

endif.

endif.

endif.

endif.

IF L_ACCT_ASSMNT = C_K1.

  • IF t_poitem-acctasscat = C_K1. "'K'.

IF NOT t_poaccount-gl_account IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-gl_account

IMPORTING

OUTPUT = l_glacc.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

*mod-004

  • perform validate_gl_account using t_poaccount-gl_account
  • t_compcode
  • changing l_flag.

*MOD-004

perform validate_gl_account using l_glacc

t_compcode

changing l_flag.

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

PERFORM GET_CONSTANT_ZXA USING t_poheader

t_compcode

l_wa_zerrors

changing l_glaccount.

IF sy-subrc <> 0.

EXIT.

ELSE.

IF NOT T_POACCOUNT-WBS_ELEMENT IS INITIAL.

perform check_project_type

using t_poaccount-wbs_element

t_poheader

t_compcode.

ENDIF.

endif.

endif.

ENDIF.

IF NOT t_poaccount-costcenter IS INITIAL AND

t_poaccount-costcenter NE '0000000000'.

*MOD-004

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-costcenter

IMPORTING

OUTPUT = l_cost.

MOVE: L_COST TO T_POACCOUNT-COSTCENTER.

  • perform validate_costcenter using t_poaccount-costcenter
  • changing l_flag.

*MOD-004

perform validate_costcenter using l_cost

changing l_flag.

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_COST USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

l_cc_present = c_x. "X

ENDIF.

ENDIF.

*Case 1

**********************************************************************

**********************************************************************

*Case 2 : Capital WBS- New Asset

If t_poaccount-zacct_type = C_N1. "'N'.

  • Case 1 Expense WBS

CLEAR: L_ACCT_ASSMNT.

SELECT SINGLE ACCT_ASSGMNT

INTO L_ACCT_ASSMNT

FROM ZP2P_ACCTASSCATG

WHERE ZACCT_TYPE = T_POACCOUNT-ZACCT_TYPE.

IF L_ACCT_ASSMNT = C_P1.

  • IF t_poitem-acctasscat = C_P1. "'P'.

IF NOT t_poaccount-gl_account IS INITIAL.

*MOD-004

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-gl_account

IMPORTING

OUTPUT = l_glacc.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

  • perform validate_gl_account_exp_wbs
  • using t_poaccount-gl_account
  • t_compcode
  • changing l_flag.

*MOD-004

perform validate_gl_account_exp_wbs

using l_glacc

t_compcode

changing l_flag.

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

PERFORM GET_CONSTANT_ZXA USING t_poheader

t_compcode

l_wa_zerrors

changing l_glaccount.

IF sy-subrc <> 0.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

EXIT.

ELSE.

if not t_poaccount-wbs_element is initial.

perform check_project_type

using t_poaccount-wbs_element

t_poheader

t_compcode.

if sy-subrc NE 0.

EXIT.

ENDIF.

endif.

endif.

endif.

  • endif.

if not t_poitem-plant is initial.

clear: l_werks.

select single werks

into l_werks

from t499s

where werks = t_poitem-plant.

if sy-subrc ne 0.

PERFORM ERROR_HANDLING_PLANT USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

EXIT.

endif.

  • select single werks
  • into l_werks
  • from t001w
  • where werks = t_poitem-plant.
  • if sy-subrc ne 0.
  • PERFORM ERROR_HANDLING_PLANT USING T_POHEADER
  • T_COMPCODE
  • L_WA_ZERRORS.
  • EXIT.
  • endif.

Clear: l_werks.

select single werks

into l_werks

from ANLZ

where bukrs = t_compcode and

werks = t_poitem-plant.

if sy-subrc ne 0.

PERFORM ERROR_HANDLING_ANLZ USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

EXIT.

endif.

  • clear: l_werks.
  • select single werks
  • into l_werks
  • from t499s
  • where werks = t_poitem-plant.
  • if sy-subrc ne 0.
  • PERFORM ERROR_HANDLING_PLANT USING T_POHEADER
  • T_COMPCODE
  • L_WA_ZERRORS.
  • EXIT.
  • endif.

endif.

  • If not t_poitem-plant is initial.

If not t_poaccount-zplant is initial.

select single werks stand

into (l_werks, l_location )

from t499s

where werks = t_POACCOUNT-ZPLANT AND

  • poitem-plant and

stand = t_poaccount-zlocation.

if sy-subrc ne 0.

PERFORM ERROR_HANDLING_location USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

EXIT.

endif.

endif.

endif.

  • IF t_poitem-acctasscat = C_K1. "'K'.

IF L_ACCT_ASSMNT = C_K1.

CLEAR: L_ACCT_ASSMNT.

SELECT SINGLE ACCT_ASSGMNT

INTO L_ACCT_ASSMNT

FROM ZP2P_ACCTASSCATG

  • FROM ZPOACCTASGMNTCAT

WHERE ZACCT_TYPE = T_POACCOUNT-ZACCT_TYPE.

IF NOT t_poaccount-gl_account IS INITIAL.

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  • EXPORTING "@SDR
  • INPUT = t_poaccount-gl_account
  • IMPORTING "@SDR
  • OUTPUT = t_poaccount-gl_account.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "@SDR

INPUT = t_poaccount-gl_account

IMPORTING "@SDR

OUTPUT = l_glacc.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

  • perform validate_gl_account using t_poaccount-gl_account
  • t_compcode
  • changing l_flag.

perform validate_gl_account using l_glacc

t_compcode

changing l_flag.

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

PERFORM GET_CONSTANT_ZXA USING t_poheader

t_compcode

l_wa_zerrors

changing l_glaccount.

IF sy-subrc <> 0.

EXIT.

ELSE.

IF NOT T_POACCOUNT-WBS_ELEMENT IS INITIAL.

perform check_project_type

using t_poaccount-wbs_element

t_poheader

t_compcode.

ENDIF.

endif.

endif.

ENDIF.

*MOD-004

IF NOT t_poaccount-costcenter IS INITIAL AND

t_poaccount-costcenter NE '0000000000'.

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  • EXPORTING
  • INPUT = t_poaccount-costcenter
  • IMPORTING
  • OUTPUT = t_poaccount-costcenter.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-costcenter

IMPORTING

OUTPUT = l_cost.

IF t_poaccount-costcenter NE '0000000000'.

MOVE: L_COST TO T_POACCOUNT-COSTCENTER.

ENDIF.

*MOD-004

  • perform validate_costcenter using t_poaccount-costcenter
  • changing l_flag.

*MOD-004

perform validate_costcenter using l_cost

changing l_flag.

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_COST USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

l_cc_present = c_x. "X

ENDIF.

l_cc_present = c_x. "X

endif.

  • Case 2

***********************************************************************

*case 3 Capital WBS Existing Asset

***********************************************************************

If t_poaccount-zacct_type = C_A1. "'A'.

  • Case 1 Expense WBS

CLEAR: L_ACCT_ASSMNT.

SELECT SINGLE ACCT_ASSGMNT

INTO L_ACCT_ASSMNT

FROM ZP2P_ACCTASSCATG

  • FROM ZPOACCTASGMNTCAT

WHERE ZACCT_TYPE = T_POACCOUNT-ZACCT_TYPE.

IF L_ACCT_ASSMNT = C_P1.

IF NOT t_poaccount-gl_account IS INITIAL.

*MOD-004

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  • EXPORTING "@SDR
  • INPUT = t_poaccount-gl_account
  • IMPORTING "@SDR
  • OUTPUT = t_poaccount-gl_account.

*

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "@SDR

INPUT = t_poaccount-gl_account

IMPORTING "@SDR

OUTPUT = l_glacc.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

  • perform validate_gl_account_exp_wbs
  • using t_poaccount-gl_account
  • t_compcode
  • changing l_flag.

*MOD-004

perform validate_gl_account_exp_wbs

using l_glacc

t_compcode

changing l_flag.

IF L_FLAG NE 'X'.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

EXIT.

ENDIF.

PERFORM GET_CONSTANT_ZXA USING t_poheader

t_compcode

l_wa_zerrors

changing l_glaccount.

IF sy-subrc <> 0.

EXIT.

ELSE.

if not t_poaccount-wbs_element is initial.

perform check_project_type

using t_poaccount-wbs_element

t_poheader

t_compcode.

if sy-subrc NE 0.

EXIT.

ENDIF.

endif.

endif.

if not t_poaccount-asset_no is initial.

PERFORM GET_ASSET_DATA USING T_COMPCODE

T_POACCOUNT

T_POHEADER

CHANGING P_XSPEB.

if sy-subrc ne 0.

EXIT.

ELSE.

IF P_XSPEB eq C_X. "'X'.

PERFORM ERROR_HANDLING_XSPEBG USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

EXIT.

ENDIF.

endif.

endif.

  • if not t_poitem-plant is initial.
  • select single werks
  • into l_werks
  • from t001w
  • where werks = t_poitem-plant.
  • if sy-subrc ne 0.
  • PERFORM ERROR_HANDLING_PLANT USING T_POHEADER
  • T_COMPCODE
  • L_WA_ZERRORS.
  • EXIT.
  • endif.
  • Clear: l_werks.
  • IF NOT T_POITEM-PLANT IS INITIAL.
  • select single werks
  • into l_werks
  • from ANLZ
  • where bukrs = t_compcode and
  • werks = t_poitem-plant.
  • if sy-subrc ne 0.
  • PERFORM ERROR_HANDLING_ANLZ USING T_POHEADER
  • T_COMPCODE
  • L_WA_ZERRORS.
  • EXIT.
  • endif.
  • ENDIF.
  • clear: l_werks.
  • IF NOT T_POITEM-PLANT IS INITIAL.
  • select single werks
  • into l_werks
  • from t499s
  • where werks = t_poitem-plant.
  • if sy-subrc ne 0.
  • PERFORM ERROR_HANDLING_PLANT USING T_POHEADER
  • T_COMPCODE
  • L_WA_ZERRORS.
  • EXIT.
  • endif.
  • ENDIF.
  • endif.
  • If not t_poitem-plant is initial.
  • select single werks stand
  • into (l_werks, l_location )
  • from t499s
  • where werks = t_POACCOUNT-ZPLANT AND
  • stand = t_poaccount-Zlocation.
  • if sy-subrc ne 0.
  • PERFORM ERROR_HANDLING_location USING T_POHEADER
  • T_COMPCODE
  • L_WA_ZERRORS.
  • EXIT.
  • endif.
  • endif.

endif.

endif.

  • IF t_poitem-acctasscat = C_K1. "'K'.

IF L_ACCT_ASSMNT = C_K1.

IF NOT t_poaccount-gl_account IS INITIAL.

*MOD-004

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  • EXPORTING "@SDR
  • INPUT = t_poaccount-gl_account
  • IMPORTING "@SDR
  • OUTPUT = t_poaccount-gl_account.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "@SDR

INPUT = t_poaccount-gl_account

IMPORTING "@SDR

OUTPUT = l_glacc.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

  • perform validate_gl_account using t_poaccount-gl_account
  • t_compcode
  • changing l_flag.

*MOD-004

perform validate_gl_account using l_glacc

t_compcode

changing l_flag.

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

PERFORM GET_CONSTANT_ZXA USING t_poheader

t_compcode

l_wa_zerrors

changing l_glaccount.

IF sy-subrc <> 0.

EXIT.

ELSE.

IF NOT T_POACCOUNT-WBS_ELEMENT IS INITIAL.

perform check_project_type

using t_poaccount-wbs_element

t_poheader

t_compcode.

ENDIF.

endif.

endif.

ENDIF.

IF NOT t_poaccount-costcenter IS INITIAL AND

t_poaccount-costcenter NE '0000000000'.

*mod-004

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  • EXPORTING
  • INPUT = t_poaccount-costcenter
  • IMPORTING
  • OUTPUT = t_poaccount-costcenter.

*MOD-004

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-costcenter

IMPORTING

OUTPUT = l_cost.

IF T_POACCOUNT-COSTCENTER NE '0000000000'.

MOVE: L_COST TO T_POACCOUNT-COSTCENTER.

ENDIF.

*MOD-004

  • perform validate_costcenter using t_poaccount-costcenter
  • changing l_flag.

*MOD-004

perform validate_costcenter using l_cost

changing l_flag.

*mod-004

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_COST USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

l_cc_present = c_x. "X

ENDIF.

ENDIF.

  • Case 3

***********************************************************************

  • Case 4

**********************************************************************

If t_poaccount-zacct_type = C_C1. "'C'.

CLEAR: L_ACCT_ASSMNT.

SELECT SINGLE ACCT_ASSGMNT

INTO L_ACCT_ASSMNT

  • FROM ZPOACCTASGMNTCAT

FROM ZP2P_ACCTASSCATG

WHERE ZACCT_TYPE = T_POACCOUNT-ZACCT_TYPE.

  • IF t_poitem-acctasscat = C_K1. "'K'.

IF L_ACCT_ASSMNT = C_K1.

IF NOT t_poaccount-gl_account IS INITIAL.

*MOD-004

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  • EXPORTING "@SDR
  • INPUT = t_poaccount-gl_account
  • IMPORTING "@SDR
  • OUTPUT = t_poaccount-gl_account.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-gl_account

IMPORTING

OUTPUT = l_glacc.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

  • perform validate_gl_account using t_poaccount-gl_account
  • t_compcode
  • changing l_flag.

*mod-004

perform validate_gl_account using l_glacc

t_compcode

changing l_flag.

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

PERFORM GET_CONSTANT_ZXA USING t_poheader

t_compcode

l_wa_zerrors

changing l_glaccount.

IF sy-subrc <> 0.

EXIT.

ELSE.

IF NOT T_POACCOUNT-WBS_ELEMENT IS INITIAL.

perform check_project_type

using t_poaccount-wbs_element

t_poheader

t_compcode.

ENDIF.

endif.

endif.

ENDIF.

IF NOT t_poaccount-costcenter IS INITIAL AND

t_poaccount-costcenter NE '0000000000'.

*mod-004

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  • EXPORTING
  • INPUT = t_poaccount-costcenter
  • IMPORTING
  • OUTPUT = t_poaccount-costcenter.

*MOD-004

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_poaccount-costcenter

IMPORTING

OUTPUT = l_cost.

IF t_poaccount-costcenter NE '0000000000'.

MOVE: L_COST TO T_POACCOUNT-COSTCENTER.

ENDIF.

  • perform validate_costcenter using t_poaccount-costcenter
  • changing l_flag.

perform validate_costcenter using l_cost

changing l_flag.

*MOD-004

IF L_FLAG NE C_X. "'X'.

PERFORM ERROR_HANDLING_COST USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

l_cc_present = c_x. "X

ENDIF.

  • IF t_poitem-acctasscat = C_P1. "'P'.

IF L_ACCT_ASSMNT = C_P1.

IF NOT t_poaccount-gl_account IS INITIAL.

*MOD-004

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  • EXPORTING "@SDR
  • INPUT = t_poaccount-gl_account
  • IMPORTING "@SDR
  • OUTPUT = t_poaccount-gl_account.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "@SDR

INPUT = t_poaccount-gl_account

IMPORTING "@SDR

OUTPUT = l_glacc.

MOVE: L_GLACC TO T_POACCOUNT-GL_ACCOUNT.

clear: l_flag.

  • perform validate_gl_account using t_poaccount-gl_account
  • t_compcode
  • changing l_flag.

perform validate_gl_account using L_GLACC

t_compcode

changing l_flag.

IF L_FLAG NE 'X'.

PERFORM ERROR_HANDLING_GL USING T_POHEADER

T_COMPCODE

L_WA_ZERRORS.

ENDIF.

PERFORM GET_CONSTANT_ZXA USING t_poheader

t_compcode

l_wa_zerrors

changing l_glaccount.

IF sy-subrc <> 0.

EXIT.

ELSE.

if not t_poaccount-wbs_element is initial.

perform check_project_type

using t_poaccount-wbs_element

t_poheader

t_compcode.

endif.

endif.

endif.

endif.

endif.

l_glaccount = t_poaccount-gl_account.

l_prev_item = t_poitem-po_item.

MODIFY T_POACCOUNT.

ENDLOOP.

clear: t_poitem.

ENDLOOP.

****************************************************************

*Case 4

****************************************************************

*****************************************************

*MOD-003

***************************************************

ENDFORM. " get_account_assignment

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

*&---------------------------------------------------------------------

*

*& Form check_and_create_vendor

*&---------------------------------------------------------------------

*

  • This subroutine prefixes the vendor number with 1 , checks if
  • the vendor is already created in the system , if not createsthe
  • vendor

*----------------------------------------------------------------------

*

  • -->P_T_DOCUMENT text

*----------------------------------------------------------------------

*

FORM check_and_create_vendor

tables p_t_return STRUCTURE bapiret2

*Begin of Change DDUTTA 03-Aug-2004 TPR 2288

using p_suppliername type lfa1-name1

*end of Change DDUTTA 03-Aug-2004 TPR 2288

changing P_DOCUMENT structure znonpo_document.

data : l_vend_actgrp type ZCONSTVAL, "vendor account grp

l_vend_paytrm type ZCONSTVAL, "vendor payment term

L_VEND_RECON type ZCONSTVAL, "vendor recon acct

L_VEND_ekorg type ZCONSTVAL, "vendor recon acct

L_MSGV1 LIKE SY-MSGV1, "Message variable1

L_LENGTH TYPE I. "Vendor string length.

*BV-08-July-2004 -Begin - Change error handling for zxa_get_constant

DATA : L_CONST_NAME LIKE SY-MSGV1, "Constant name

L_COMP_CODE LIKE SY-MSGV2. "Company code

*BV-08-July-2004 -End - Change error handling for zxa_get_constant

*For PO Create, check the existence of Vendor in SAP for the given

*company code.

*If Vendor do not exist, create a new one. However, If Vendor exists,

*but not for the incoming company code, extend the Vendor Master for

*that company code.

clear g_flg_vendor.

  • Retrieve vendor account group Constant

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

CONST_NAME = C_VEND_ACTGRP

COMP_CODE = p_document-companycode

IMPORTING

CONST_VALUE = L_VEND_ACTGRP

EXCEPTIONS

NO_VALUE_FOUND = 1

NULL_VALUE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

***BV-08-July-2004 Begin Change error handling for zxa_get_constant

*Constant not defined for company code.

****************************************

  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • TYPE = SY-MSGTY
  • CL = SY-MSGID
  • NUMBER = SY-MSGNO
  • PAR1 = SY-MSGV1
  • PAR2 = SY-MSGV2
  • PAR3 = SY-MSGV3
  • PAR4 = SY-MSGV4
  • IMPORTING
  • RETURN = p_t_return.

*

  • APPEND p_t_return.
  • CLEAR p_t_return.

****************************************

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = C_VEND_ACTGRP. "ZRP_VEND_ACTGRP

L_COMP_CODE = p_document-companycode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

TYPE = c_msgtype_e

CL = c_msgid_z001

NUMBER = c_msgnr_046

PAR1 = L_CONST_NAME "ZRP_VEND_ACTGRP

PAR2 = L_COMP_CODE

IMPORTING

RETURN = p_t_return.

APPEND p_t_return.

CLEAR p_t_return.

EXIT.

**BV-08-July-2004 End Change error handling for zxa_get_constant

ENDIF.

*Retrieve vendor payment terms Constant

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

CONST_NAME = C_VEND_PAYTRM

COMP_CODE = p_document-companycode

IMPORTING

CONST_VALUE = L_VEND_PAYTRM

EXCEPTIONS

NO_VALUE_FOUND = 1

NULL_VALUE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

**BV-08-July-2004 Begin Change error handling for zxa_get_constant

*Constant not defined for company code

****************************************

  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • TYPE = SY-MSGTY
  • CL = SY-MSGID
  • NUMBER = SY-MSGNO
  • PAR1 = SY-MSGV1
  • PAR2 = SY-MSGV2
  • PAR3 = SY-MSGV3
  • PAR4 = SY-MSGV4
  • IMPORTING
  • RETURN = p_t_return.

*

  • APPEND P_t_return.
  • CLEAR P_t_return.

****************************************

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = C_VEND_PAYTRM. "ZRP_VEND_PAYTRM

L_COMP_CODE = p_document-companycode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

TYPE = c_msgtype_e

CL = c_msgid_z001

NUMBER = c_msgnr_046

PAR1 = L_CONST_NAME "ZRP_VEND_PAYTRM

PAR2 = L_COMP_CODE

IMPORTING

RETURN = p_t_return.

APPEND p_t_return.

CLEAR p_t_return.

EXIT.

**BV-08-July-2004 End Change error handling for zxa_get_constant

ENDIF.

*Retrieve vendor Reconciliation Account Constant

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

CONST_NAME = C_VEND_RECON

COMP_CODE = p_document-companycode

IMPORTING

CONST_VALUE = L_VEND_RECON

EXCEPTIONS

NO_VALUE_FOUND = 1

NULL_VALUE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

**BV-08-July-2004 Begin Change error handling for zxa_get_constant

*Constant not defined for company code

****************************************

  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • TYPE = SY-MSGTY
  • CL = SY-MSGID
  • NUMBER = SY-MSGNO
  • PAR1 = SY-MSGV1
  • PAR2 = SY-MSGV2
  • PAR3 = SY-MSGV3
  • PAR4 = SY-MSGV4
  • IMPORTING
  • RETURN = P_t_return.

*

  • APPEND P_t_return.
  • CLEAR P_t_return.

****************************************

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = C_VEND_RECON. "ZRP_VEND_RECON

L_COMP_CODE = p_document-companycode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

TYPE = c_msgtype_e

CL = c_msgid_z001

NUMBER = c_msgnr_046

PAR1 = L_CONST_NAME "ZRP_VEND_RECON

PAR2 = L_COMP_CODE

IMPORTING

RETURN = p_t_return.

APPEND p_t_return.

CLEAR p_t_return.

EXIT.

***BV-08-July-2004 End Change error handling for zxa_get_constant

ENDIF.

*Retrieve vendor purchase org Constant

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

CONST_NAME = C_VEND_EKORG

COMP_CODE = p_document-companycode

IMPORTING

CONST_VALUE = L_VEND_EKORg

EXCEPTIONS

NO_VALUE_FOUND = 1

NULL_VALUE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

**BV-08-July-2004 Begin Change error handling for zxa_get_constant

*Constant not defined for company code

****************************************

  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • TYPE = SY-MSGTY
  • CL = SY-MSGID
  • NUMBER = SY-MSGNO
  • PAR1 = SY-MSGV1
  • PAR2 = SY-MSGV2
  • PAR3 = SY-MSGV3
  • PAR4 = SY-MSGV4
  • IMPORTING
  • RETURN = P_t_return.

*

  • APPEND P_t_return.
  • CLEAR P_t_return.

****************************************

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = C_VEND_EKORG. "ZRP_EHUB_PURORG

L_COMP_CODE = p_document-companycode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

TYPE = c_msgtype_e

CL = c_msgid_z001

NUMBER = c_msgnr_046

PAR1 = L_CONST_NAME "ZRP_EHUB_PURORG

PAR2 = L_COMP_CODE

IMPORTING

RETURN = p_t_return.

APPEND p_t_return.

CLEAR p_t_return.

EXIT.

**BV-08-July-2004 End Change error handling for zxa_get_constant

ENDIF.

*Zero Pad and Prefix 1 to Vendor.

IF NOT p_document-suppliernumber IS INITIAL.

*remove any leading zeros for vendor populated from webmethods

shift p_document-suppliernumber left deleting leading '0'.

L_LENGTH = STRLEN( p_document-suppliernumber ).

IF L_LENGTH < 10.

shift p_document-suppliernumber right deleting trailing space.

*To pad leading zeros to Vendor

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = p_document-suppliernumber

IMPORTING

OUTPUT = p_document-suppliernumber.

*To replace first character with 1.

MOVE '1' TO p_document-suppliernumber(1).

ELSE. "Vendor is 10 char in length

CLEAR L_MSGV1.

L_MSGV1 = p_document-suppliernumber.

*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 = P_t_return.

APPEND P_t_return.

CLEAR P_t_return.

ENDIF.

ENDIF.

*

SELECT SINGLE * FROM LFA1 WHERE

LIFNR = p_document-suppliernumber.

IF SY-SUBRC NE 0.

  • Vendor Master (General Section)

W_LFA1-LIFNR = p_document-suppliernumber.

*Begin of Change DDUTTA 03-Aug-2004 TPR 2288

    • if Supplier name is not passed from Ariba - populate vendor name
    • with "Ariba Vendor"

if p_suppliername is initial.

*End of Change DDUTTA 03-Aug-2004 TPR 2288

W_LFA1-NAME1 = C_ARIBAVENDOR." 'ARIBA VENDOR'

W_LFA1-MCOD1 = C_ARIBAVENDOR." 'ARIBA VENDOR'

*Begin of Change DDUTTA 03-Aug-2004 TPR 2288

else.

W_LFA1-NAME1 = p_suppliername.

W_LFA1-MCOD1 = p_suppliername.

endif.

*End of Change DDUTTA 03-Aug-2004 TPR 2288

W_LFA1-LAND1 = C_US. " 'US'

W_LFA1-SPRAS = C_E. " 'E'

W_LFA1-KTOKK = L_VEND_ACTGRP.

W_LFB1-LIFNR = p_document-suppliernumber.

W_LFB1-BUKRS = p_document-companycode.

W_LFB1-AKONT = L_VEND_RECON.

W_LFB1-ZTERM = L_VEND_PAYTRM.

W_LFM1-LIFNR = p_document-suppliernumber.

W_LFM1-EKORG = l_vend_ekorg.

W_LFM1-WAERS = p_document-CURRENCY.

MOVE C_N TO G_FLG_VENDOR. " 'N'

ELSE.

  • Vendor Master (General Section)

W_LFA1-LIFNR = p_document-suppliernumber.

*Begin of Change DDUTTA 03-Aug-2004 TPR 2288

    • if Supplier name is not passed from Ariba - populate vendor name
    • with "Ariba Vendor"

if p_suppliername is initial.

*End of Change DDUTTA 03-Aug-2004 TPR 2288

W_LFA1-NAME1 = C_ARIBAVENDOR." 'ARIBA VENDOR'

W_LFA1-MCOD1 = C_ARIBAVENDOR." 'ARIBA VENDOR'

*Begin of Change DDUTTA 03-Aug-2004 TPR 2288

else.

W_LFA1-NAME1 = p_suppliername.

W_LFA1-MCOD1 = p_suppliername.

endif.

*End of Change DDUTTA 03-Aug-2004 TPR 2288

W_LFA1-LAND1 = C_US. " 'US'

W_LFA1-SPRAS = C_E. " 'E'

W_LFA1-KTOKK = L_VEND_ACTGRP.

SELECT SINGLE * FROM LFB1 WHERE

LIFNR = p_document-suppliernumber

AND BUKRS = p_document-COMPanyCODE.

IF SY-SUBRC NE 0.

W_LFB1-LIFNR = p_document-suppliernumber.

W_LFB1-BUKRS = P_document-COMPanyCODE.

W_LFB1-AKONT = L_VEND_RECON.

W_LFB1-ZTERM = L_VEND_PAYTRM.

G_FLG_VENDOR = C_N. " 'N'

ENDIF.

SELECT SINGLE * FROM LFM1 WHERE

LIFNR = p_document-suppliernumber

AND EKORG = l_vend_ekorg.

IF SY-SUBRC NE 0.

W_LFM1-LIFNR = p_document-suppliernumber.

W_LFM1-EKORG = l_vend_ekorg.

W_LFM1-WAERS = p_document-CURRENCY.

G_FLG_VENDOR = C_N. " 'N'

ENDIF.

ENDIF.

IF G_FLG_VENDOR = C_N. " 'N'

refresh t_zreturn.

CALL FUNCTION 'Z_VENDOR_INSERT'

EXPORTING

I_LFA1 = W_LFA1

I_LFB1 = W_LFB1

I_LFM1 = W_LFM1

TABLES

T_XLFAS = T_XLFAS

T_XLFB5 = T_XLFB5

T_XLFBK = T_XLFBK

T_XLFZA = T_XLFZA

ZRETURN = T_ZRETURN.

  • If Vendor create fails or the transaction commit fails, populate the
  • the Return structure and exit the program

READ TABLE T_ZRETURN WITH KEY TYPE = C_E. " 'E'

IF SY-SUBRC EQ 0.

APPEND LINES OF T_ZRETURN TO P_t_return.

loop at p_t_return.

concatenate 'Error Creating Vendor -'(010)

p_t_return-message

into p_t_return-message.

modify p_t_return.

endloop.

EXIT.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = C_X " 'X'

IMPORTING

RETURN = p_t_return.

IF P_t_return-type = C_E. " 'E'

APPEND P_t_return.

EXIT.

ELSE.

CLEAR P_t_return.

ENDIF.

ENDIF.

ENDIF.

ENDFORM. " check_and_create_vendor

*&---------------------------------------------------------------------

*

*& Form validate_costcenter

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_L_WA_PO_ACCOUNT_COSTCENTER text

*----------------------------------------------------------------------

*

FORM validate_costcenter USING

P_L_WA_PO_ACCOUNT_COSTCENTER type bapimepoaccount-costcenter

changing lv_flag type c.

data: l_kostl type kostl.

lv_flag = ' '.

SELECT SINGLE kostl

into l_kostl

FROM CSKS

WHERE KOSTL = P_L_WA_PO_ACCOUNT_COSTCENTER.

IF SY-SUBRC = 0.

LV_FLAG = 'X'.

ENDIF.

endform. " validate_costcenter

*&---------------------------------------------------------------------

*

*& Form validate_wbs_element

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_L_WA_POACCOUNT_WBS_ELEMENT text
  • <--P_L_FLAG1 text

*----------------------------------------------------------------------

*

FORM validate_wbs_element

USING P_L_WA_POACCOUNT_WBS_ELEMENT type bapimepoaCcount-wbs_element

CHANGING P_L_FLAG1.

DATA: L_PSPNR type ps_posnr.

SELECT SINGLE pspnr

into l_pspnr

FROM PRPS

WHERE PSPNR = P_L_WA_POACCOUNT_WBS_ELEMENT.

IF SY-SUBRC = 0.

P_L_FLAG1 = 'X'.

ENDIF.

ENDFORM. " validate_wbs_element

*&---------------------------------------------------------------------

*

*& Form validate_gl_account

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_L_WA_POACCOUNT_GL_ACCOUNT text
  • <--P_L_FLAG2 text

*----------------------------------------------------------------------

*

FORM validate_gl_account USING T_POACCOUNT-GL_ACCOUNT type

bapimepoaccount-gl_account

t_compcode type t001-bukrs

CHANGING P_L_FLAG2 type c.

CONSTANTS: C_EXP_WBS_ELEMENT TYPE SAKNR VALUE '0064511012'.

data: t_acct_assignmt type standard table of ZACCTASGMNT.

data: l_acct_assign TYPE zconstval.

data: l_ex_acc_no TYPE z_acc_no.

  • SHIFT t_poaccount-gl_account LEFT
  • DELETING LEADING c_zeros. "
  • SHIFT t_poaccount-gl_account
  • BY 1 PLACES RIGHT.
  • t_poaccount-gl_account+0(1) = 'P'.
  • l_ex_acc_no = t_poaccount-gl_account.
  • CALL FUNCTION 'Z_GLACCT_GET'
  • EXPORTING
  • P_BUKRS = t_compcode
  • P_EX_ACC_NO = l_ex_acc_no
  • IMPORTING
  • P_GLACCT = t_poaccount-gl_account
  • EXCEPTIONS "
  • NO_VALUE_FOUND = 1
  • NULL_VALUE_FOUND = 2
  • OTHERS = 3.
  • IF sy-subrc = 0.
  • Assign the retrieved GL Account from SAP to the
  • account assignment strcuture after the mapping
  • is successful

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "@SDR

INPUT = t_poaccount-gl_account

IMPORTING "@SDR

OUTPUT = t_poaccount-gl_account.

DATA: L_saknr type saknr.

DATA: g_glacct TYPE saknr.

DATA: p_glacct TYPE saknr.

    • Retrieve the corresponding SAP GL Account from the custom mapping
    • table corresponding to the combination of the Business Unit and
    • Peoplesoft GL Account passed to the Function Module
  • SELECT SINGLE saknr " WBS Element
  • FROM zgl_acc_map
  • INTO g_glacct
  • WHERE bukrs = c_bukrs
  • AND ex_acc_no = l_ex_acc_no.

*

  • IF sy-subrc = 0.

IF t_poaccount-gl_account IS INITIAL.

p_l_flag2 = ' '.

ELSE.

  • if t_poaccount-gl_account ne '0064511012'.

*MOD-005

if t_poaccount-gl_account ne C_EXP_WBS_ELEMENT.

  • if t_poaccount-gl_account EQ C_EXP_WBS_ELEMENT.

*MOD-005

p_l_flag2 = 'X'.

else.

p_l_flag2 = ' '.

endif.

ENDIF.

  • endif.

ENDFORM. " validate_gl_account

*&---------------------------------------------------------------------

*

*& Form validate_gl_account_exp_wbs

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POACCOUNT_GL_ACCOUNT text
  • -->P_T_COMPCODE text
  • <--P_L_FLAG text

*----------------------------------------------------------------------

*

FORM validate_gl_account_exp_wbs USING T_POACCOUNT_GL_ACCOUNT type

bapimepoaccount-gl_account

t_compcode type t001-bukrs

CHANGING P_L_FLAG2 type c.

constants: c_cap_wbs_new_asset type saknr value '0064511012'.

data: t_acct_assignmt type standard table of ZACCTASGMNT.

data: l_acct_assign TYPE zconstval.

data: l_ex_acc_no TYPE z_acc_no.

*

  • SHIFT t_poaccount_gl_account LEFT
  • DELETING LEADING c_zeros. "
  • SHIFT t_poaccount_gl_account
  • BY 1 PLACES RIGHT.
  • t_poaccount_gl_account+0(1) = 'P'.
  • l_ex_acc_no = t_poaccount_gl_account.
  • CALL FUNCTION 'Z_GLACCT_GET'
  • EXPORTING
  • P_BUKRS = t_compcode
  • P_EX_ACC_NO = l_ex_acc_no
  • IMPORTING
  • P_GLACCT = t_poaccount_gl_account
  • EXCEPTIONS "
  • NO_VALUE_FOUND = 1
  • NULL_VALUE_FOUND = 2
  • OTHERS = 3.
  • IF sy-subrc = 0.
  • Assign the retrieved GL Account from SAP to the
  • account assignment strcuture after the mapping
  • is successful

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING "@SDR

INPUT = t_poaccount_gl_account

IMPORTING "@SDR

OUTPUT = t_poaccount_gl_account.

DATA: L_saknr type saknr.

DATA: g_glacct TYPE saknr.

DATA: p_glacct TYPE saknr.

    • Retrieve the corresponding SAP GL Account from the custom mapping
    • table corresponding to the combination of the Business Unit and
    • Peoplesoft GL Account passed to the Function Module
  • SELECT SINGLE saknr " WBS Element
  • FROM zgl_acc_map
  • INTO g_glacct
  • WHERE bukrs = c_bukrs
  • AND ex_acc_no = l_ex_acc_no.

*

  • IF sy-subrc = 0.

IF t_poaccount_gl_account IS INITIAL.

p_l_flag2 = ' '.

ELSE.

  • if t_poaccount_gl_account eq '0064511012'.

if t_poaccount_gl_account eq c_cap_wbs_new_asset.

p_l_flag2 = 'X'.

else.

p_l_flag2 = ' '.

endif.

ENDIF.

  • endif.

ENDFORM. " validate_gl_account_exp_wbs

*&---------------------------------------------------------------------

*

*& Form check_split_accounts

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POACCOUNT_GL_ACCOUNT text
  • -->P_L_GLACCOUNT text

*----------------------------------------------------------------------

*

*FORM check_split_accounts USING t_POACCOUNT_GL_ACCOUNT type saknr

  • L_GLACCOUNT type ZCONSTVAL
  • t_poheader type bapimepoheader
  • t_compcode type bukrs
  • l_prev_item type ebelp
  • t_poitem-po_item type ebelp.

*

  • .

*

  • data: l_wa_zeerors type zerrors.
  • DATA : L_CONST_NAME LIKE SY-MSGV1, "Constant name
  • L_COMP_CODE LIKE SY-MSGV2. "Company code

*

*

  • if t_poaccount_gl_account = l_glaccount.
  • CLEAR : L_CONST_NAME,
  • L_COMP_CODE.

*

  • L_CONST_NAME = l_glaccount.
  • L_COMP_CODE = t_compcode.
  • 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-serialno = sy-tabix.
  • l_wa_zerrors-COMP_CODE = t_compcode.
  • l_wa_zerrors-zid = t_yreturn-id.
  • l_wa_zerrors-type = t_yreturn-type.
  • l_wa_zerrors-znumber = t_yreturn-number.
  • l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.
  • l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.
  • l_wa_zerrors-ZDATE = sy-datum.
  • l_wa_zerrors-ERR_MSG = t_yreturn-message.
  • insert into ZP2P_ERRORS values l_wa_zerrors.
  • clear: l_wa_zerrors.
  • endloop.

*

  • ENDIF.

*

*ENDFORM. " check_split_accounts

*&---------------------------------------------------------------------

*

*& Form check_project_type

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_PO_ACCOUNT_WBS_ELEMENT text
  • -->P_T_POHEADER text
  • -->P_T_COMPCODE text

*----------------------------------------------------------------------

*

FORM check_project_type USING t_WBS_ELEMENT type ps_posid

t_POHEADER type bapimepoheader

t_COMPCODE type bukrs.

data: l_prart type ps_prart.

  • l_belkz type ps_belkz.

clear: l_prart, l_belkz.

DATA :L_CONST_NAME LIKE SY-MSGV1, "Constant name

L_COMP_CODE LIKE SY-MSGV2. "Company code

select single prart belkz

into (l_prart, l_belkz)

from prps

where posid = t_wbs_element.

if sy-subrc = 0.

  • IF l_prart ne 'NC'.
  • CLEAR : L_CONST_NAME,
  • L_COMP_CODE.
  • L_CONST_NAME = c_gl_acc_po.
  • L_COMP_CODE = t_compcode.
  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • type = c_msgtype_e
  • cl = c_msgid_z001
  • number = c_msgnr_622
  • PAR1 = L_CONST_NAME
  • PAR2 = L_COMP_CODE
  • IMPORTING
  • return = t_yreturn.

*

  • APPEND t_yreturn.
  • CLEAR t_yreturn.

*

  • l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.
  • l_wa_zerrors-COMP_CODE = t_poheader-comp_code.
  • l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.
  • l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.
  • l_wa_zerrors-ZDATE = sy-datum.
    • l_wa_zerrors-ERR_MSG = c_msgnr_614.
  • read table t_yreturn index 1.
  • l_wa_zerrors-ERR_MSG = t_yreturn-message.
  • insert into zerrors values l_wa_zerrors.
  • clear: l_wa_zerrors.
  • EXIT.
  • ENDIF.
  • IF L_BELKZ NE 'X'.
  • CLEAR : L_CONST_NAME,
  • L_COMP_CODE.
  • L_CONST_NAME = c_gl_acc_po.
  • L_COMP_CODE = t_compcode.
  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'
  • EXPORTING
  • type = c_msgtype_e
  • cl = c_msgid_z001
  • number = c_msgnr_623
  • PAR1 = L_CONST_NAME
  • PAR2 = L_COMP_CODE
  • IMPORTING
  • return = t_yreturn.

*

  • APPEND t_yreturn.
  • CLEAR t_yreturn.
  • l_wa_zerrors-OBJECT = 'PURCHASE_ORDER'.
  • l_wa_zerrors-COMP_CODE = t_poheader-comp_code.
  • l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.
  • l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.
  • l_wa_zerrors-ZDATE = sy-datum.
    • l_wa_zerrors-ERR_MSG = c_msgnr_614.
  • read table t_yreturn index 1.
  • l_wa_zerrors-ERR_MSG = t_yreturn-message.
  • insert into zerrors values l_wa_zerrors.
  • clear: l_wa_zerrors.
  • EXIT.
  • ENDIF.

ENDIF.

ENDFORM. " check_project_type

*&---------------------------------------------------------------------

*

*& Form ERROR_HANDLING_GL

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POHEADER text
  • -->P_T_COMPCODE text
  • -->P_L_WA_ERRORS text

*----------------------------------------------------------------------

*

FORM ERROR_HANDLING_GL USING T_POHEADER TYPE BAPIMEPOHEADER

T_COMPCODE TYPE BUKRS

L_WA_ZERRORS TYPE ZP2P_ERRORS.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_gl_acc_po.

L_COMP_CODE = t_compcode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e

cl = c_msgid_z001

number = c_msgnr_614

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-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

ENDFORM. " ERROR_HANDLING_GL

*&---------------------------------------------------------------------

*

*& Form GET_CONSTANT_ZXA

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POHEADER text
  • -->P_T_COMPCODE text
  • -->P_L_WA_ZERRORS text
  • <--P_L_GLACCOUNT text

*----------------------------------------------------------------------

*

FORM GET_CONSTANT_ZXA USING T_POHEADER TYPE BAPIMEPOHEADER

T_COMPCODE TYPE BUKRS

L_WA_ZERRORS TYPE ZP2P_ERRORS

CHANGING L_GLACCOUNT TYPE ZCONSTVAL.

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

const_name = c_gl_acc_po

comp_code = t_compcode

IMPORTING

const_value = l_glaccount

EXCEPTIONS

no_value_found = 1

null_value = 2

OTHERS = 3.

IF sy-subrc <> 0.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_gl_acc_po.

L_COMP_CODE = t_compcode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e "E

cl = c_msgid_z001

number = c_msgnr_614

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-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT.

ENDIF.

ENDFORM. " GET_CONSTANT_ZXA

*&---------------------------------------------------------------------

*

*& Form ERROR_HANDLING_COST

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POHEADER text
  • -->P_T_COMPCODE text
  • -->P_L_WA_ZERRORS text

*----------------------------------------------------------------------

*

FORM ERROR_HANDLING_COST USING T_POHEADER TYPE BAPIMEPOHEADER

T_COMPCODE TYPE BUKRS

L_WA_ZERRORS TYPE ZP2P_ERRORS.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_acct_assign.

L_COMP_CODE = t_compcode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e "E

cl = c_msgid_z001

number = c_msgnr_621 "046

PAR1 = L_CONST_NAME "ZRP_ACCT_ASSIGN

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-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

ENDFORM. " ERROR_HANDLING_COST

*&---------------------------------------------------------------------

*

*& Form ERROR_HANDLING_PLANT

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POHEADER text
  • -->P_T_COMPCODE text
  • -->P_L_WA_ZERRORS text

*----------------------------------------------------------------------

*

FORM ERROR_HANDLING_PLANT USING T_POHEADER TYPE BAPIMEPOHEADER

T_COMPCODE TYPE BUKRS

L_WA_ZERRORS TYPE ZP2P_ERRORS.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_po_werks.

L_COMP_CODE = t_compcode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e

cl = c_msgid_z001

number = c_msgnr_404

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-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

ENDFORM. " ERROR_HANDLING_PLANT

*&---------------------------------------------------------------------

*

*& Form ERROR_HANDLING_ANLZ

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POHEADER text
  • -->P_T_COMPCODE text
  • -->P_L_WA_ZERRORS text

*----------------------------------------------------------------------

*

FORM ERROR_HANDLING_ANLZ USING T_POHEADER TYPE BAPIMEPOHEADER

T_COMPCODE TYPE BUKRS

L_WA_ZERRORS TYPE ZP2P_ERRORS.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_po_werks.

L_COMP_CODE = t_compcode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e

cl = c_msgid_z001

number = c_msgnr_615

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-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT.

ENDFORM. " ERROR_HANDLING_ANLZ

*&---------------------------------------------------------------------

*

*& Form ERROR_HANDLING_location

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POHEADER text
  • -->P_T_COMPCODE text
  • -->P_L_WA_ZERRORS text

*----------------------------------------------------------------------

*

FORM ERROR_HANDLING_location USING T_POHEADER TYPE BAPIMEPOHEADER

T_COMPCODE TYPE BUKRS

L_WA_ZERRORS TYPE ZP2P_ERRORS.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_po_werks.

L_COMP_CODE = t_compcode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e

cl = c_msgid_z001

number = c_msgnr_616

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-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

.

EXIT.

ENDFORM. " ERROR_HANDLING_location

*&---------------------------------------------------------------------

*

*& Form GET_ASSET_DATA

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_COMPCODE text
  • -->P_T_POACCOUNT text
  • -->P_T_POHEADER text

*----------------------------------------------------------------------

*

FORM GET_ASSET_DATA USING T_COMPCODE TYPE BUKRS

T_POACCOUNT TYPE BAPIMEPOACCOUNT

T_POHEADER TYPE BAPIMEPOHEADER

CHANGING L_XSPEB type xspeb_anla.

data: l_prart type ps_prart,

l_werks type werks_d,

l_belkz type ps_belkz,

l_glaccount type ZCONSTVAL,

l_anln1 type anln1,

l_anln2 type anln2.

Clear: l_werks,

l_anln1,

l_anln2,

l_xspeb.

select single anln1 anln2 xspeb

into (l_anln1, l_anln2, l_xspeb)

from ANLA

where bukrs = t_compcode and

anln1 = t_poaccount-asset_no and

anln2 = t_poaccount-sub_number.

if sy-subrc ne 0.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_po_werks.

L_COMP_CODE = t_compcode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e

cl = c_msgid_z001

number = c_msgnr_620

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-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

endif.

ENDFORM. " GET_ASSET_DATA

*&---------------------------------------------------------------------

*

*& Form ERROR_HANDLING_XSPEBG

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_T_POHEADER text
  • -->P_T_COMPCODE text
  • -->P_L_WA_ZERRORS text

*----------------------------------------------------------------------

*

FORM ERROR_HANDLING_XSPEBG USING T_POHEADER TYPE BAPIMEPOHEADER

T_COMPCODE TYPE BUKRS

L_WA_ZERRORS TYPE ZP2P_ERRORS.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = c_po_werks.

L_COMP_CODE = t_compcode.

CALL FUNCTION 'BALW_BAPIRETURN_GET2'

EXPORTING

type = c_msgtype_e

cl = c_msgid_z001

number = c_msgnr_624

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-serialno = sy-tabix.

l_wa_zerrors-COMP_CODE = t_compcode.

l_wa_zerrors-zid = t_yreturn-id.

l_wa_zerrors-type = t_yreturn-type.

l_wa_zerrors-znumber = t_yreturn-number.

l_wa_zerrors-BEACON_DOC_NO = t_poheader-po_number.

l_wa_zerrors-SRC_DOC_NO = t_poheader-po_number.

l_wa_zerrors-ZDATE = sy-datum.

l_wa_zerrors-ERR_MSG = t_yreturn-message.

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT.

ENDFORM. " ERROR_HANDLING_XSPEBG

*&---------------------------------------------------------------------

*

*& Form get_uom_conversion

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_POHEADER text
  • -->P_POITEM text
  • -->P_POACCOUNT text
  • -->P_POHEADERX text
  • -->P_POITEMX text
  • -->P_POACCOUNTX text

*----------------------------------------------------------------------

*

FORM get_uom_conversion TABLES t_poitem STRUCTURE bapimepoitem

t_poitemx STRUCTURE bapimepoitemx

t_account STRUCTURE bapimepoaccount

t_accountx STRUCTURE bapimepoaccountx

t_poschedule structure

BAPIMEPOSCHEDULE

t_poschedulex structure

BAPIMEPOSCHEDULX

t_pocond structure BAPIMEPOCOND

T_pocondx structure BAPIMEPOCONDX

t_pocondheader structure bapimepocondheader

t_pocondheaderx structure bapimepocondheaderx

changing t_poheader type bapimepoheader

t_poheaderx TYPE bapimepoheaderx.

*MOD-004

  • DATA: t_ZAPPL_UOM_CONVER TYPE STANDARD TABLE OF ZAPPL_UOM_CONVER
  • INITIAL SIZE 0 WITH HEADER LINE.

*MOD-004

DATA: t_ZAPPL_UOM_CONVER TYPE STANDARD TABLE OF ZP2P_UOM_CONVERS

INITIAL SIZE 0 WITH HEADER LINE.

  • DATA: t_ZEHUB_UOM_CONVER TYPE STANDARD TABLE OF ZEHUB_UOM_CONVER
  • INITIAL SIZE 0 WITH HEADER LINE.

*

  • SELECT *
  • FROM ZAPPL_UOM_CONVER
  • INTO TABLE t_ZAPPL_UOM_CONVER.
  • MOD-004
  • SELECT *
  • FROM ZAPPL_UOM_CONVER
  • INTO TABLE t_ZAPPL_UOM_CONVER.

*MOD-004

SELECT *

FROM ZP2P_UOM_CONVERS

INTO TABLE t_ZAPPL_UOM_CONVER.

IF sy-subrc = 0.

SORT t_ZAPPL_UOM_CONVER BY APPL_JNJISO ASCENDING.

ENDIF.

data:lv_polen type i,

lv_orderpoint(3) TYPE C.

constants : lc_zero type c value '0'.

*Hard-coded fields

t_poheader-langu = 'E'.

t_poheaderX-langu = c_x.

T_POHEADERX-doc_type = c_x.

T_POHEADERX-purch_org = c_x.

T_POHEADERX-pur_group = c_x.

T_POHEADERX-currency = c_x.

T_POHEADERX-doc_date = c_x.

IF NOT T_poheader-comp_code IS INITIAL.

T_POHEADERX-comp_code = c_x.

ENDIF.

IF NOT T_poheader-po_number IS INITIAL.

T_poheaderx-po_number = c_x.

ENDIF.

    • T_poheader-creat_date = sy-datum.
  • IF NOT T_poheader-creat_date IS INITIAL.
  • T_poheaderx-creat_date = c_x.
  • ENDIF.

IF NOT T_poheader-vendor IS INITIAL.

T_poheaderx-vendor = c_x.

ENDIF.

IF NOT T_poheader-PO_NUMBER is initial.

t_poheaderx-po_number = c_x.

endif.

IF NOT T_poheader-COMP_CODE is initial.

t_poheaderx-comp_code = c_x.

endif.

IF NOT T_poheader-DOC_TYPE is initial.

t_poheaderx-doc_type = c_x.

endif.

IF NOT T_poheader-DELETE_IND is initial.

t_poheaderx-delete_ind = c_x.

endif.

IF NOT T_poheader-STATUS is initial.

t_poheaderx-status = c_x.

endif.

IF NOT T_poheader-CREAT_DATE is initial.

t_poheaderx-creat_date = c_x.

endif.

IF NOT T_poheader-CREATED_BY is initial.

t_poheaderx-created_by = c_x.

endif.

IF NOT T_poheader-ITEM_INTVL is initial.

t_poheaderx-item_intvl = c_x.

endif.

IF NOT T_poheader-VENDOR is initial.

t_poheaderx-vendor = c_x.

endif.

IF NOT T_poheader-LANGU is initial.

t_poheaderx-langu = c_x.

endif.

IF NOT T_poheader-LANGU_ISO is initial.

t_poheaderx-langu_iso = c_x.

endif.

IF NOT T_poheader-PMNTTRMS is initial.

t_poheaderx-PMNTTRMS = c_x.

endif.

IF NOT T_poheader-DSCNT1_TO is initial.

t_poheaderx-DSCNT1_TO = c_x.

endif.

IF NOT T_poheader-DSCNT2_TO is initial.

t_poheaderx-DSCNT2_TO = c_x.

endif.

IF NOT T_poheader-DSCNT3_TO is initial.

t_poheaderx-DSCNT3_TO = c_x.

endif.

IF NOT T_poheader-DSCT_PCT1 is initial.

t_poheaderx-DSCT_PCT1 = c_x.

endif.

IF NOT T_poheader-DSCT_PCT2 is initial.

t_poheaderx-DSCT_PCT1 = c_x.

endif.

IF NOT T_poheader-PURCH_ORG is initial.

t_poheaderx-po_number = c_x.

endif.

IF NOT T_poheader-PUR_GROUP is initial.

t_poheaderx-PURCH_ORG = c_x.

endif.

IF NOT T_poheader-CURRENCY is initial.

t_poheaderx-CURRENCY = c_x.

endif.

IF NOT T_poheader-CURRENCY_ISO is initial.

t_poheaderx-CURRENCY_ISO = c_x.

endif.

IF NOT T_poheader-EXCH_RATE is initial.

t_poheaderx-EXCH_RATE = c_x.

endif.

IF NOT T_poheader-EX_RATE_FX is initial.

t_poheaderx-EX_RATE_FX = c_x.

endif.

IF NOT T_poheader-DOC_DATE is initial.

t_poheaderx-DOC_DATE = c_x.

endif.

IF NOT T_poheader-VPER_START is initial.

t_poheaderx-VPER_START = c_x.

endif.

IF NOT T_poheader-VPER_END is initial.

t_poheaderx-VPER_END = c_x.

endif.

IF NOT T_poheader-WARRANTY is initial.

t_poheaderx-WARRANTY = c_x.

endif.

IF NOT T_poheader-QUOTATION is initial.

t_poheaderx-QUOTATION = c_x.

endif.

IF NOT T_poheader-QUOT_DATE is initial.

t_poheaderx-QUOT_DATE = c_x.

endif.

IF NOT T_poheader-REF_1 is initial.

t_poheaderx-REF_1 = c_x.

endif.

IF NOT T_poheader-SALES_PERS is initial.

t_poheaderx-SALES_PERS = c_x.

endif.

IF NOT T_poheader-TELEPHONE is initial.

t_poheaderx-TELEPHONE = c_x.

endif.

IF NOT T_poheader-SUPPL_VEND is initial.

t_poheaderx-SUPPL_VEND = c_x.

endif.

IF NOT T_poheader-CUSTOMER is initial.

t_poheaderx-CUSTOMER = c_x.

endif.

IF NOT T_poheader-AGREEMENT is initial.

t_poheaderx-AGREEMENT = c_x.

endif.

IF NOT T_poheader-GR_MESSAGE is initial.

t_poheaderx-GR_MESSAGE = c_x.

endif.

IF NOT T_poheader-SUPPL_PLNT is initial.

t_poheaderx-SUPPL_PLNT = c_x.

endif.

IF NOT T_poheader-INCOTERMS1 is initial.

t_poheaderx-INCOTERMS1 = c_x.

endif.

IF NOT T_poheader-INCOTERMS2 is initial.

t_poheaderx-INCOTERMS2 = c_x.

endif.

IF NOT T_poheader-COLLECT_NO is initial.

t_poheaderx-COLLECT_NO = c_x.

endif.

IF NOT T_poheader-DIFF_INV is initial.

t_poheaderx-DIFF_INV = c_x.

endif.

IF NOT T_poheader-OUR_REF is initial.

t_poheaderx-OUR_REF = c_x.

endif.

IF NOT T_poheader-LOGSYSTEM is initial.

t_poheaderx-LOGSYSTEM = c_x.

endif.

IF NOT T_poheader-SUBITEMINT is initial.

t_poheaderx-SUBITEMINT = c_x.

endif.

IF NOT T_poheader-PO_REL_IND is initial.

t_poheaderx-PO_REL_IND = c_x.

endif.

IF NOT T_poheader-REL_STATUS is initial.

t_poheaderx-REL_STATUS = c_x.

endif.

IF NOT T_poheader-VAT_CNTRY is initial.

t_poheaderx-VAT_CNTRY = c_x.

endif.

IF NOT T_poheader-VAT_CNTRY_ISO is initial.

t_poheaderx-VAT_CNTRY_ISO = c_x.

endif.

IF NOT T_poheader-REASON_CANCEL is initial.

t_poheaderx-REASON_CANCEL = c_x.

endif.

  • poitem details.

LOOP AT T_POITEM.

  • LOOP AT T_POITEMX WHERE PO_ITEM = T_POITEM-PO_ITEM.

t_poitemx-po_item = t_poitem-po_item.

IF NOT T_poitem-po_item IS INITIAL.

T_POITEMX-po_itemx = c_x.

ENDIF.

IF NOT t_poitem-matl_group IS INITIAL.

T_poitemx-matl_group = c_x.

ENDIF.

IF NOT t_poitem-plant IS INITIAL.

T_poitemx-plant = c_x.

ENDIF.

IF NOT t_poitem-short_text IS INITIAL.

T_poitemx-short_text = c_x.

ENDIF.

IF NOT t_poitem-vend_mat IS INITIAL.

T_poitemx-vend_mat = c_x.

ENDIF.

READ TABLE t_ZAPPL_UOM_CONVER

  • WITH KEY aribauom = t_poitem-orderpr_un.

WITH KEY APPL_JNJISO = t_poitem-orderpr_un.

IF sy-subrc = 0.

T_poitem-orderpr_un =

  • t_ZAPPL_UOM_CONVER-APPLUOM.

t_ZAPPL_UOM_CONVER-SAP_UOM.

IF NOT T_poitem-orderpr_un IS INITIAL.

T_poitemx-orderpr_un = c_x.

ENDIF.

ENDIF.

IF NOT t_poitem-orderpr_un IS INITIAL.

T_poitemx-orderpr_un = c_x.

ENDIF.

IF NOT t_poitem-quantity IS INITIAL.

T_POITEMX-quantity = c_x.

ENDIF.

if not t_poitem-distrib is initial.

t_poitemx-distrib = c_x.

endif.

IF NOT t_poitem-incoterms1 IS INITIAL.

T_POITEMX-incoterms1 = c_x.

ENDIF.

if not t_poitem-incoterms2 is initial.

t_poitemx-incoterms2 = c_x.

endif.

if not t_poitem-PART_INV is initial.

t_poitemx-PART_INV = c_x.

endif.

CLEAR t_ZAPPL_UOM_CONVER.

READ TABLE t_ZAPPL_UOM_CONVER

WITH KEY APPL_JNJISO = t_poitem-po_unit.

  • WITH KEY aribauom = t_poitem-po_unit

.

IF sy-subrc = 0.

T_poitem-po_unit =

  • t_ZAPPL_UOM_CONVER-APPLUOM.

t_ZAPPL_UOM_CONVER-SAP_UOM.

IF NOT T_poitem-po_unit IS INITIAL.

T_poitemx-po_unit = c_x.

ENDIF.

ENDIF.

IF NOT t_poitem-net_price IS INITIAL.

T_poitemx-net_price = c_x.

ENDIF.

IF NOT t_poitem-price_unit IS INITIAL.

T_poitemx-price_unit = c_x.

ENDIF.

IF NOT T_poitem-net_price IS INITIAL.

T_poitemx-ir_ind = c_x.

ENDIF.

    • Translate the GR Indicator external value to internal format
  • for Z_BAPI_PO_CREATE1 to handle

if not t_poitem-gr_ind is initial.

t_poitemx-gr_ind = c_x.

endif.

if not t_poitem-ORDERPR_UN is initial.

t_poitemx-orderpr_un = c_x.

endif.

IF NOT T_poitem-preq_name IS INITIAL.

T_poitemx-preq_name = c_x.

ENDIF.

  • For Service Order POs

IF not T_poitem-trackingno is initial.

T_poitemx-trackingno = c_x.

ENDIF.

T_poitem-unlimited_dlv = c_x.

T_poitemx-unlimited_dlv = c_x.

T_poitemx-delete_ind = c_x.

T_poitemx-gr_ind = c_x.

T_poitemx-distrib = c_x.

T_poitemx-ir_ind = c_x.

T_poitemx-acctasscat = c_x.

APPEND T_POITEMX.

CLEAR: t_poitemx.

  • ENDLOOP.

MODIFY T_POITEM TRANSPORTING PO_UNIT orderpr_un.

ENDLOOP.

delete t_poitem where po_item = '0000'.

delete t_poitemx where po_item = '0000'.

      • POaccount data

data: l_tabix type sy-tabix.

LOOP AT t_poitem.

LOOP AT t_account. " Where po_item = t_poitem-po_item.

  • l_tabix = sy-tabix.
  • READ TABLE t_poitem index l_tabix.

*

  • t_accountx-po_item = t_account-po_item.

***********************************************

**mod-004

if not t_account-po_item is initial.

t_accountx-po_item = t_account-po_item.

else.

t_accountx-po_item = t_poitem-po_item.

t_account-po_item = t_poitem-po_item.

endif.

*mod-004

**********************************************

IF NOT t_account-po_item IS INITIAL.

t_accountx-po_itemx = c_x.

ENDIF.

IF NOT t_account-serial_no IS INITIAL.

t_accountx-SERIAL_NO = t_account-serial_no.

t_accountx-serial_nox = c_x.

ENDIF.

  • To change the value of T_POITEM-DISTRIB
  • to 2 in case of a split

IF t_account-serial_no > 1.

READ TABLE T_POITEM WITH KEY po_item = t_account-po_item.

IF sy-subrc = 0.

t_poitem-distrib = '2'.

MODIFY t_poitem INDEX sy-tabix TRANSPORTING distrib.

READ TABLE t_poitemx WITH KEY po_item = t_poitem-po_item.

IF sy-subrc = 0.

t_poitemx-distrib = 'X'.

MODIFY t_poitemx INDEX sy-tabix TRANSPORTING distrib.

ENDIF.

ENDIF.

ENDIF.

  • l_tabix = sy-tabix.
  • t_accountx-po_item = l_tabix.
  • IF NOT t_accountx-po_item IS INITIAL.
  • t_accountx-po_item = c_x.
  • ENDIF.

*

IF NOT t_account-costcenter IS INITIAL.

t_accountx-costcenter = c_x.

ENDIF.

IF NOT t_account-gl_account IS INITIAL.

t_accountx-gl_account = c_x.

ENDIF.

IF NOT t_account-unload_pt IS INITIAL.

t_accountx-unload_pt = c_x.

ENDIF.

IF NOT t_account-wbs_element IS INITIAL.

t_accountx-wbs_element = c_x.

ENDIF.

IF NOT t_account-distr_perc IS INITIAL.

t_accountx-distr_perc = c_x.

ENDIF.

IF NOT t_account-net_value IS INITIAL.

t_accountx-net_value = c_x.

ENDIF.

IF NOT t_account-quantity IS INITIAL.

t_accountx-quantity = c_x.

ENDIF.

APPEND T_accountx.

CLEAR: t_accountx.

  • READ TABLE t_accountx
  • WITH KEY po_item = t_account-po_item
  • serial_no = t_account-serial_no.
  • IF sy-subrc = 0.
  • MODIFY t_accountx.
  • ENDIF.

modify t_account.

ENDLOOP.

ENDLOOP.

delete t_account where po_item = '0000'.

delete t_accountx where po_item = '0000'.

*****************************************************************

*MOD-004

sort t_accountx by po_item.

delete adjacent duplicates from t_accountx comparing

po_item.

MOD-004********************************************************

loop at t_poschedule.

loop at t_poitem.

IF NOT t_poschedule-po_item IS INITIAL.

t_poschedulex-po_item = t_poschedule-po_item.

t_poschedulex-PO_ITEMX = C_X.

else.

t_poschedule-po_item = t_poitem-po_item.

t_poschedulex-po_item = t_poitem-po_item.

t_poschedulex-PO_ITEMX = C_X.

ENDIF.

IF NOT t_poschedule-sched_line IS INITIAL.

t_poschedulex-sched_line = t_poschedule-sched_line.

ELSE.

t_poschedule-sched_line = t_poitem-po_item.

t_poschedulex-sched_line = t_poitem-po_item.

ENDIF.

IF NOT t_poschedule-SCHED_LINE IS INITIAL.

t_poschedulex-SCHED_LINEX = C_X.

ENDIF.

IF NOT t_poschedule-DELIVERY_DATE IS INITIAL.

t_poschedulex-DELIVERY_DATE = c_x.

ENDIF.

IF NOT t_poschedule-quantity IS INITIAL.

t_poschedulex-quantity = c_x.

ENDIF.

APPEND t_poschedulex.

Clear: t_poschedulex.

modify t_poschedule.

endloop.

endloop.

delete t_poschedule where po_item = '0000'.

delete t_poschedulex where po_item = '0000'.

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

sort t_poschedulex by po_item sched_line.

delete adjacent duplicates from t_poschedulex comparing

po_item

sched_line.

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

LOOP AT t_poitem.

LOOP AT t_POCOND.

IF T_POCOND-ITM_NUMBER IS INITIAL.

T_POCOND-ITM_NUMBER = t_POITEM-PO_ITEM.

T_POCONDX-ITM_NUMBER = t_POITEM-PO_ITEM.

T_POCONDHEADER-ITM_NUMBER = t_POITEM-PO_ITEM.

T_POCONDHEADERX-ITM_NUMBER = t_POITEM-PO_ITEM.

ELSE.

T_POCONDX-ITM_NUMBER = T_POCOND-ITM_NUMBER.

T_POCONDHEADER-ITM_NUMBER = t_POITEM-PO_ITEM.

T_POCONDHEADERX-ITM_NUMBER = T_POCOND-ITM_NUMBER.

ENDIF.

IF T_POCOND-COND_ST_NO IS INITIAL.

T_POCOND-COND_ST_NO = '001'.

T_POCONDX-COND_ST_NO = T_POCOND-COND_ST_NO.

T_POCONDHEADER-COND_ST_NO = T_POCOND-COND_ST_NO.

T_POCONDHEADERX-COND_ST_NO = T_POCOND-COND_ST_NO.

ELSE.

T_POCONDX-COND_ST_NO = T_POCOND-COND_ST_NO.

T_POCONDHEADER-COND_ST_NO = T_POCOND-COND_ST_NO.

T_POCONDHEADERX-COND_ST_NO = T_POCOND-COND_ST_NO.

ENDIF.

IF T_POCOND-COND_COUNT IS INITIAL.

T_POCOND-COND_COUNT = '01'.

T_POCONDX-COND_COUNT = '01'.

T_POCONDHEADER-COND_COUNT = '01'.

T_POCONDHEADERX-COND_COUNT = '01'.

ELSE.

T_POCONDX-COND_COUNT = T_POCOND-COND_COUNT.

T_POCONDHEADER-COND_COUNT = '01'.

T_POCONDHEADERX-COND_COUNT = T_POCOND-COND_COUNT.

ENDIF.

  • MOD-004 IF T_POCOND-CHANGE_ID IS INITIAL.

T_POCOND-CHANGE_ID = 'I'.

T_POCONDX-CHANGE_ID = C_X.

T_POCONDHEADER-CHANGE_ID = 'I'.

T_POCONDHEADERX-CHANGE_ID = C_X.

  • T_POCONDHEADER-CHANGE_ID = 'I'.
  • T_POCONDHEADERX-CHANGE_ID = C_X.

*MOD-004 ENDIF.

  • MDO-004

IF NOT T_POCONDHEADER-COND_TYPE IS INITIAL.

T_POCONDHEADER-COND_TYPE = 'PBXX'.

ENDIF.

IF NOT T_POCONDHEADER-COND_TYPE IS INITIAL.

T_POCONDHEADERX-COND_TYPE = C_X..

ENDIF.

IF T_POCONDHEADER-COND_VALUE IS INITIAL.

T_POCONDHEADER-COND_VALUE = T_POCOND-COND_VALUE.

ENDIF.

IF NOT T_POCONDHEADER-COND_VALUE IS INITIAL.

T_POCONDHEADERX-COND_VALUE = C_X.

ENDIF.

IF NOT T_POCONDHEADER-CHANGE_ID IS INITIAL.

T_POCONDHEADER-CHANGE_ID = 'I'.

ENDIF.

IF NOT T_POCONDHEADER-CHANGE_ID IS INITIAL.

T_POCONDHEADERX-CHANGE_ID = C_X.

ENDIF.

IF NOT t_POCOND-CONDITION_NO IS INITIAL.

t_POCONDX-CONDITION_NO = C_X.

ENDIF.

IF NOT t_POCONDHEADER-CONDITION_NO IS INITIAL.

t_POCONDHEADERX-CONDITION_NO = C_X.

ENDIF.

*MOD-004

IF NOT t_POCOND-CONDITION_NO IS INITIAL.

t_POCONDX-CONDITION_NOX = C_X.

ENDIF.

IF NOT t_POCONDHEADER-CONDITION_NO IS INITIAL.

t_POCONDHEADERX-CONDITION_NOX = C_X.

ENDIF.

IF NOT t_POCOND-ITM_NUMBER IS INITIAL.

t_POCONDX-ITM_NUMBERX = C_X.

ENDIF.

IF NOT t_POCONDHEADER-ITM_NUMBER IS INITIAL.

t_POCONDHEADERX-ITM_NUMBERX = C_X.

ENDIF.

IF NOT t_POCOND-COND_ST_NO IS INITIAL.

t_POCONDX-COND_ST_NOX = C_X.

ENDIF.

IF NOT t_POCONDHEADER-COND_ST_NO IS INITIAL.

t_POCONDHEADERX-COND_ST_NOX = C_X.

ENDIF.

IF NOT t_POCOND-COND_COUNT IS INITIAL.

t_POCONDX-COND_COUNT = C_X.

ENDIF.

IF NOT t_POCONDHEADER-COND_COUNT IS INITIAL.

t_POCONDHEADERX-COND_COUNT = C_X.

ENDIF.

IF NOT t_POCOND-COND_TYPE IS INITIAL.

t_POCONDX-COND_TYPE = C_X.

ENDIF.

IF NOT t_POCONDHEADER-COND_TYPE IS INITIAL.

t_POCONDHEADERX-COND_TYPE = C_X.

ENDIF.

IF NOT t_POCOND-COND_VALUE IS INITIAL.

t_POCONDX-COND_VALUE = C_X.

ENDIF.

IF NOT t_POCONDHEADER-COND_VALUE IS INITIAL.

t_POCONDHEADERX-COND_VALUE = C_X.

ENDIF.

IF NOT t_POCOND-CURRENCY IS INITIAL.

t_POCONDX-CURRENCY = C_X.

ENDIF.

IF NOT t_POCONDHEADER-CURRENCY IS INITIAL.

t_POCONDHEADERX-CURRENCY = C_X.

ENDIF.

IF NOT t_POCOND-CURRENCY_ISO IS INITIAL.

t_POCONDX-CURRENCY_ISO = C_X.

ENDIF.

IF NOT t_POCONDHEADER-CURRENCY_ISO IS INITIAL.

t_POCONDHEADERX-CURRENCY_ISO = C_X.

ENDIF.

IF NOT t_POCOND-COND_UNIT IS INITIAL.

t_POCONDX-COND_UNIT = C_X.

ENDIF.

IF NOT t_POCONDHEADER-COND_UNIT IS INITIAL.

t_POCONDHEADERX-COND_UNIT = C_X.

ENDIF.

IF NOT t_POCOND-COND_UNIT_ISO IS INITIAL.

t_POCONDX-COND_UNIT_ISO = C_X.

ENDIF.

IF NOT t_POCONDHEADER-COND_UNIT_ISO IS INITIAL.

t_POCONDHEADERX-COND_UNIT_ISO = C_X.

ENDIF.

IF NOT t_POCOND-COND_P_UNT IS INITIAL.

t_POCONDX-COND_P_UNT = C_X.

ENDIF.

IF NOT t_POCONDHEADER-COND_P_UNT IS INITIAL.

t_POCONDHEADERX-COND_P_UNT = C_X.

ENDIF.

IF NOT t_POCOND-APPLICATIO IS INITIAL.

t_POCONDX-APPLICATIO = C_X.

ENDIF.

IF NOT t_POCONDHEADER-APPLICATIO IS INITIAL.

t_POCONDHEADERX-APPLICATIO = C_X.

ENDIF.

IF NOT T_POCOND-CONPRICDAT IS INITIAL.

t_POCONDX-CONPRICDAT = C_X.

ENDIF.

IF NOT T_POCONDHEADER-CONPRICDAT IS INITIAL.

t_POCONDHEADERX-CONPRICDAT = C_X.

ENDIF.

IF NOT t_POCOND-CALCTYPCON IS INITIAL.

t_POCONDX-CALCTYPCON = C_X.

ENDIF.

IF NOT t_POCONDHEADER-CALCTYPCON IS INITIAL.

t_POCONDHEADERX-CALCTYPCON = C_X.

ENDIF.

IF NOT t_POCOND-CONBASEVAL IS INITIAL.

t_POCONDX-CONBASEVAL = C_X.

ENDIF.

IF NOT t_POCONDHEADER-CONBASEVAL IS INITIAL.

t_POCONDHEADERX-CONBASEVAL = C_X.

ENDIF.

APPEND T_POCONDX.

CLEAR: T_POCONDX.

APPEND: T_POCONDHEADER, T_POCONDHEADERX.

CLEAR: T_POCONDHEADER, T_POCONDHEADERX.

MODIFY T_POCOND TRANSPORTING ITM_NUMBER COND_ST_NO COND_COUNT.

ENDLOOP.

ENDLOOP.

sort t_pocond by itm_number.

sort t_pocondx by itm_number.

sort t_pocondheader by itm_number.

sort t_pocondheaderx by itm_number.

delete adjacent duplicates from t_pocond comparing itm_number.

delete adjacent duplicates from t_pocondx comparing itm_number.

delete adjacent duplicates from t_pocondheader comparing itm_number.

delete adjacent duplicates from t_pocondheaderx comparing itm_number.

ENDFORM. " get_uom_conversion

*&---------------------------------------------------------------------

*

*& Form GET_INCOTERMS_LINE_ITEM

*&---------------------------------------------------------------------

*

  • text

*----------------------------------------------------------------------

*

  • -->P_POHEADER text
  • <--P_POITEM text

*----------------------------------------------------------------------

*

FORM GET_INCOTERMS_LINE_ITEM tables

T_POITEM STRUCTURE BAPIMEPOITEM

using

T_POHEADER type BAPIMEPOHEADER.

DATA: t_zmm_mapping_flds LIKE zmm_mapping_flds

OCCURS 0 WITH HEADER LINE.

CONSTANTS: c_inco_trms type ZFLDNAME value 'INCOTERMS'.

SELECT * FROM zmm_mapping_flds

INTO TABLE t_zmm_mapping_flds.

IF sy-subrc EQ 0.

LOOP AT T_POITEM.

SORT t_zmm_mapping_flds BY mapg_field gsdb_val.

READ TABLE t_zmm_mapping_flds WITH KEY

mapg_field = c_inco_trms " 'INCOTERMS'

gsdb_val = T_POITEM-INCOTERMS1 BINARY SEARCH.

IF sy-subrc = 0.

t_poitem-incoterms1 = t_zmm_mapping_flds-beacon_val.

ELSE.

t_poitem-incoterms1 = 'CIF'.

ENDIF.

READ TABLE t_zmm_mapping_flds WITH KEY

mapg_field = c_inco_trms " 'INCOTERMS'

gsdb_val = T_POITEM-INCOTERMS2 BINARY SEARCH.

IF sy-subrc = 0.

t_poitem-incoterms2 = t_zmm_mapping_flds-beacon_val.

ELSE.

t_poitem-incoterms2 = t_poitem-incoterms1.

ENDIF.

MODIFY t_POITEM TRANSPORTING INCOTERMS1 INCOTERMS2.

ENDLOOP.

ENDIF.

ENDFORM.