Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI to create PO and GR

Former Member
0 Kudos
324

Hi,

Can anybody send me some sample code to handle multiple files in application server. My requirement is to create an interface to create PO and GR from the file residing in Application server. Multiple files will be in application server. No selection screens are there. BAPI used are BAPI_PO_CREATE1 and BAPI_GOODSMVT_CREATE. And If anyone has already created this interface, please give me some idea of how to read multiple files and if possible send some sample code.

Any help will be greatly appreciated.

Regards,

Naveen

1 REPLY 1

Former Member
0 Kudos
75

Hi Try This:

FUNCTION ZBC1BAPIPOCREATE02.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(TESTRUN) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(MEMORY_UNCOMPLETE) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(MEMORY_COMPLETE) TYPE BAPIFLAG-BAPIFLAG

*" VALUE(POEXPIMPHEADER) TYPE ZBAPIEIKP

*" VALUE(POEXPIMPHEADERX) TYPE ZBAPIEIKPX

*" VALUE(VERSIONS) TYPE ZBAPIMEDCM

*" 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(EXPPURCHASEORDER) TYPE BAPIMEPOHEADER-PO_NUMBER

*" VALUE(EXPHEADER) TYPE BAPIMEPOHEADER

*" VALUE(EXPPOEXPIMPHEADER) TYPE ZBAPIEIKP

*" TABLES

*" RETURN STRUCTURE BAPIRET2

*" POITEM STRUCTURE BAPIMEPOITEM

*" POITEMX STRUCTURE BAPIMEPOITEMX

*" POADDRDELIVERY STRUCTURE BAPIMEPOADDRDELIVERY

*" POSCHEDULE STRUCTURE BAPIMEPOSCHEDULE

*" POSCHEDULEX STRUCTURE BAPIMEPOSCHEDULX

*" POACCOUNT STRUCTURE BAPIMEPOACCOUNT

*" POACCOUNTPROFITSEGMENT STRUCTURE BAPIMEPOACCOUNTPROFITSEGMENT

*" POACCOUNTX STRUCTURE BAPIMEPOACCOUNTX

*" POCONDHEADER STRUCTURE BAPIMEPOCONDHEADER

*" POCONDHEADERX STRUCTURE BAPIMEPOCONDHEADERX

*" POCOND STRUCTURE BAPIMEPOCOND

*" POCONDX STRUCTURE BAPIMEPOCONDX

*" POLIMITS STRUCTURE BAPIESUHC

*" POCONTRACTLIMITS STRUCTURE BAPIESUCC

*" POSERVICES STRUCTURE BAPIESLLC

*" POSRVACCESSVALUES STRUCTURE BAPIESKLC

*" POSERVICESTEXT STRUCTURE BAPIESLLTX

*" EXTENSIONIN STRUCTURE BAPIPAREX

*" EXTENSIONOUT STRUCTURE BAPIPAREX

*" POEXPIMPITEM STRUCTURE ZBAPIEIPO

*" POEXPIMPITEMX STRUCTURE ZBAPIEIPOX

*" POTEXTHEADER STRUCTURE BAPIMEPOTEXT

*" POTEXTITEM STRUCTURE BAPIMEPOTEXT

*" ALLVERSIONS STRUCTURE ZBAPIMEDCM_ALLVERSIONS

*" POPARTNER STRUCTURE BAPIEKKOP

*" CHANGING

*" VALUE(POHEADER) TYPE BAPIMEPOHEADER

*" VALUE(POHEADERX) TYPE BAPIMEPOHEADERX

*" VALUE(POADDRVENDOR) TYPE BAPIMEPOADDRVENDOR

*" EXCEPTIONS

*" WRONG_FUNCTION_CALLED

*" TIMEOUT

*" TCPIP_ERROR

*" CONNECT_FAILED

*" INTERNAL_ERROR

*" SYSTEM_FAILURE

*" COMMUNICATION_FAILURE

*"----


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

  • Program : Z_BC1_BAPI_PO_CREATE01

  • TITLE Function Module to create PO using BAPI

  • AUTHOR Aveek Ghose, IBM

  • DATE WRITTEN 20-May-2006

  • R/3 RELEASE 4.6C

  • CTS: RD1K912067

*----


  • COPIED FROM N/A

*

  • This function module is called during PR Creation in Ariba ( at

  • checkpoint1, checkpoint2 and checkpoint3) and also during posting of

  • PO in SAP. The call to this function module is from WebMethods.

*

*----


  • 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

*----


----


  • Local variables

----


CONSTANTS: C_VENDOR TYPE ELIFN VALUE '4259999999',

C_DOC_TYPE TYPE ESART VALUE 'ZAPS',

C_CURRENCY TYPE WAERS VALUE 'EUR',

C_NETPR TYPE NETPR VALUE '1.00',

C_99 TYPE CHAR2 VALUE '99',

C_00 TYPE CHAR2 VALUE '00'.

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_LENGTH TYPE I, "Vendor string length.

L_WBS_EXTERNAL LIKE BAPIMEPOACCOUNT-WBS_ELEMENT,

"WBS external format

L_WBS_INTERNAL LIKE BAPIMEPOACCOUNT-WBS_ELEMENT,

L_bukrs type bukrs.

DATA: l_werks1 type werks_d.

"WBS internal format

*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

  • DATA: L_WA_TIMESTAMP TYPE ZPO_TIMESTAMP.

DATA: L_WA_TIMESTAMP TYPE ZP2P_TIMESTAMP.

DATA: l_serial_no LIKE poaccount-serial_no.

DATA: L_SERIAL TYPE I.

DATA: L_RETURN TYPE C.

DATA: L_EXIT TYPE I.

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

----


  • Internal Table

----


DATA : T_TEMP_POACCOUNT LIKE POACCOUNT OCCURS 0 WITH HEADER LINE,

"To store items with blank GL

*PVU-22-May-2004 - Start 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_SCHD_TMP LIKE POSCHEDULE 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.

----


  • Structure

----


DATA: G_W_HDRX_TMP LIKE POHEADERX.

DATA: p_constname TYPE zconstname, "Constant Name

g_constval TYPE zconstval, "Constant Value

tbx TYPE SY-TABIX.

data: l_waers type waers.

DATA: L_EKORG TYPE EKORG.

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

----


CLEAR : G_FLG_VENDOR,

  • start of change for TPR2220 - DDUTTA - 07/08/2004

t_znonpo_document,

t_znonpo_acctg,

  • End of change for TPR2220 - DDUTTA - 07/08/2004

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

G_IDOC_NO,

G_W_HDRX_TMP.

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

REFRESH : RETURN, T_ZRETURN,

  • start of change for TPR2220 - DDUTTA - 07/08/2004

t_znonpo_document,

t_znonpo_acctg,

  • End of change for TPR2220 - DDUTTA - 07/08/2004

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

G_T_IDOC_DATA,

G_T_ITEMX_TMP,

G_T_SCHDX_TMP,

G_T_ACCNTX_TMP,

G_T_CONDX_TMP.

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

  • Srini 17-May-2005 Start of changes

  • Developer Flexibility to debug issues

p_constname = 'BAPI_PO_CREATE2'.

do.

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

const_name = p_constname

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

  • Add of change: SDR: 12-Aug-2005

  • IF poheader-po_number IS INITIAL.

  • poheader-doc_type = 'ZEHS'.

  • else.

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

*mod-003

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

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.

DELETE FROM ZP2P_ERRORS WHERE BEACON_DOC_NO = POHEADER-PO_NUMBER.

DELETE FROM ZP2P_ERRORS WHERE TYPE NE C_E.

  • DELETE FROM ZERRORS WHERE BEACON_DOC_NO = POHEADER-PO_NUMBER.

  • DELETE FROM ZERRORS WHERE TYPE NE C_E.

*MOD-004

l_wa_timestamp-mandt = SY-MANDT.

l_wa_timestamp-EBELN = POHEADER-PO_NUMBER.

l_wa_timestamp-EBELP = '00'.

l_wa_timestamp-CREATE_TIMESTMP = POHEADER-ARIBACRTTIMESTMP.

l_wa_timestamp-CREATE_TIMESTMP = POHEADER-ARIBACHGTIMESTMP.

insert into ZP2P_TIMESTAMP values l_wa_timestamp.

*MOD-004

  • ENDIF.

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

*mod-003

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

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

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

select single companycode

into l_bukrs

from ZP2P_COMPANYCODE

where FSID = poheader-fsid and

le = poheader-le and

frmrc = poheader-frmrc.

if sy-subrc ne 0.

CLEAR L_MSGV1.

L_MSGV1 = T_TEMP_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.

else.

  • poheader-comp_code = l_bukrs.

endif.

endif.

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

*mod-003

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

  • End of Change: SDR: 12-Aug-2005

  • Srini 10-May-2005 Start of changes

  • Pass the value of SERIAL_NO from POACCOUNT to POACCOUNTX.

LOOP AT POACCOUNTX.

MOVE SY-TABIX to TBX.

READ TABLE POACCOUNT INDEX TBX.

IF SY-SUBRC EQ 0 AND POACCOUNTX-SERIAL_NO IS INITIAL.

POACCOUNTX-SERIAL_NO = POACCOUNT-SERIAL_NO.

MODIFY POACCOUNTX INDEX TBX.

ENDIF.

ENDLOOP.

  • Srini 10-May-2005 End of changes

  • Srini 17-May-2005 End of changes

T_TEMP_POACCOUNT[] = POACCOUNT[].

  • To retrieve the line items with blank GL Account Number

PERFORM FILTER_ITEMS TABLES T_TEMP_POACCOUNT.

LOOP AT T_TEMP_POACCOUNT.

CLEAR L_MSGV1.

L_MSGV1 = T_TEMP_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 = 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-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

ENDLOOP.

  • On Error, exit the function module

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

IF SY-SUBRC EQ 0.

EXPHEADER = POHEADER.

EXPHEADER-CODE = '99'.

EXIT.

ENDIF.

*MOD-005

    • On Error, exit the function module

  • l_exit = 0.

  • LOOP AT RETURN WHERE TYPE = C_E.

  • L_EXIT = 1.

  • expheader = poheader.

  • EXPHEADER-CODE = C_99.

  • RETURN-RETURN_CODE = C_99.

  • RETURN-SEQ_CODE = C_99.

  • MODIFY RETURN TRANSPORTING RETURN_CODE SEQ_CODE.

  • ENDLOOP..

  • IF L_EXIT = 1.

  • EXIT.

  • ENDIF.

**MOD-005

*MOD-005

**MOD-004

  • L_RETURN = ' '..

  • LOOP AT RETURN WHERE TYPE = C_E.

  • RETURN-RETURN_CODE = '99'.

  • L_RETURN = C_X.

  • MODIFY RETURN TRANSPORTING RETURN_CODE.

  • ENDLOOP.

*

  • IF L_RETURN = C_X.

  • EXIT.

  • ENDIF.

*

**MOD-004

    • Begin of Change: Soumya D Roy: 12/27/2005

  • Forcibly refresh the T_YRETURN table as a part of the conversion

  • program since this table is not getting refreshed

REFRESH t_yreturn.

CLEAR t_yreturn.

    • End of Change: Soumya D Roy: 12/27/2005

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

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

*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 = 'A'.

l_wa_timestamp-CREATE_TIMESTMP = POITEM-ARIBACRTTIMESTMP.

l_wa_timestamp-CHANGE_TIMESTMP = POITEM-ARIBACHGTIMESTMP.

  • l_wa_timestamp-DATE_TIME_STMP = POITEM-ARIBACRTTIMESTMP.

  • insert into ZPO_TIMESTAMP values l_wa_timestamp.

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-type = t_yreturn-type.

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 zerrors 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_type = '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 PURCH_ORG

INTO L_EKORG

FROM ZP2P_PURCHASEORG

  • 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-type = return-type.

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

append l_wa_zerrors to t_errors.

  • insert into zerrors 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-type = return-type.

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

append l_wa_zerrors to t_errors.

  • insert into zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT.

ELSE.

POHEADER-PUR_GROUP = G_CONSTVAL.

ENDIF.

ENDIF.

LOOP AT poitem.

if poitem-plant is initial.

clear: l_werks1.

select single plant

into l_werks1

from ZP2P_PLANTMAPING

where COMPANY_CODE = poheader-comp_code and

PURCH_ORG = poheader-purch_org and

PURCH_GROUP = poheader-pur_group and

LE = poheader-le and

FSID = poheader-fsid and

  • MRC = poheader-mrc 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.

*mod-004

IF POITEM-net_price NE 0.

POITEM-IR_IND = 'X'.

ENDIF.

*mod-004

IF POITEM-net_price eq 0.

POITEM-IR_IND = 'X'.

ENDIF.

*MOD-004

if POITEM-GR_IND = C_Y..

POITEM-GR_IND = C_X.

ELSEIF POITEM-GR_IND = C_X.

POITEM-GR_IND = C_X.

ELSE.

POITEM-GR_IND = ' '.

endif.

*MOD-004

  • if POITEM-GR_IND = 'Y'..

  • POITEM-GR_IND = 'X'.

  • endif.

if POITEM-INCOTERMS1 is initial.

POITEM-INCOTERMS1 = 'CIF'.

endif.

if POITEM-INCOTERMS2 is initial.

POITEM-INCOTERMS2 = 'CIF'.

endif.

LOOP AT POACCOUNT WHERE PO_ITEM = POITEM-PO_ITEM.

IF POITEM-DISTRIB IS INITIAL.

POACCOUNT-DISTR_PERC = '0.00'.

MODIFY POACCOUNT TRANSPORTING DISTR_PERC.

ENDIF.

ENDLOOP.

POITEM-UNLIMITED_DLV = 'X'.

POITEM-UNDER_DLV_TOL = 0.

clear: poitem-ARIBACRTTIMESTMP,

poitem-ARIBACHGTIMESTMP.

MODIFY POITEM TRANSPORTING UNLIMITED_DLV

UNDER_DLV_TOL

PLANT

IR_IND

GR_IND

INCOTERMS1

INCOTERMS2

ARIBACRTTIMESTMP

ARIBACHGTIMESTMP.

ENDLOOP.

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

&----


&

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

&----


&

READ TABLE t_yreturn WITH KEY type = 'W'.

IF sy-subrc <> 0.

expheader = poheader.

EXPHEADER-CODE = '99'.

ENDIF.

**MOD-005

    • On Error, exit the function module

  • l_exit = 0.

  • LOOP AT RETURN WHERE TYPE = C_E.

  • L_EXIT = 1.

  • expheader = poheader.

  • EXPHEADER-CODE = '99'.

  • RETURN-RETURN_CODE = C_99.

  • RETURN-SEQ_CODE = C_99.

  • MODIFY RETURN TRANSPORTING RETURN_CODE SEQ_CODE.

  • ENDLOOP..

  • IF L_EXIT = 1.

  • EXIT.

  • ENDIF.

**MOD-005

&----


&

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

&----


&

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_type = 'PBXX'.

  • pocond-currency = l_waers.

  • modify pocond transporting cond_value currency.

  • endif.

  • ENDIF.

  • endloop.

  • ENDIF.

  • ENDIF.

*

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

*currency check MOD-004

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

  • DATA: l_header TYPE REF TO cl_po_header_handle_mm,

  • l_item TYPE REF TO cl_po_item_handle_mm,

  • l_tkomv TYPE STANDARD TABLE OF komv INITIAL SIZE 10,

  • l_item_conditions_changed TYPE mmpur_bool.

*

    • header level pocond data

  • CHECK NOT l_item IS INITIAL.

*

  • CHECK NOT l_item->po_item_number IS INITIAL.

*

  • l_header ?= l_item->my_parent.

*

  • CALL METHOD l_header->get_tkomv IMPORTING

  • ex_tkomv = l_tkomv.

*

*

  • l_item_conditions_changed = mmpur_no.

  • PERFORM pai_item_conditions IN PROGRAM saplmepo

  • TABLES l_tkomv

  • USING poitem-po_item

  • CHANGING l_item_conditions_changed.

*

  • IF NOT l_item_conditions_changed IS INITIAL.

*

  • CALL METHOD l_header->set_tkomv EXPORTING

  • im_tkomv = l_tkomv

  • im_item_conditions_changed = l_item_conditions_changed.

*

  • Item level POCOND data

  • LOOP AT POITEM.

*. CALL FUNCTION 'MEPO_DOC_PBO_ITEM_CONDITIONS'

  • EXPORTING

  • im_ebelp = poitem-po_item

  • EXCEPTIONS

  • error_message = 1.

  • ENDLOOP.

  • ENDIF.

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

*currency check mod-004

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

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

*MOD-003

IF NOT TESTRUN IS INITIAL.

POHEADER-VENDOR = '4259999999'.

poheader-doc_type = 'ZAPS'.

ENDIF.

*MOD-003

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

  • IF NOT POHEADER-PURCH_ORG IS INITIAL.

IF POHEADER-PURCH_ORG IS INITIAL.

SELECT SINGLE PURCH_ORG

INTO L_EKORG

FROM ZP2P_PURCHASEORG

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-type = return-type.

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 zerrors 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-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT.

ELSE.

POHEADER-PUR_GROUP = G_CONSTVAL.

ENDIF.

ENDIF.

*MOD-004

LOOP AT POACCOUNT.

if POACCOUNT-COSTCENTER EQ '0000000000' OR

POACCOUNT-COSTCENTER EQ '0'.

POACCOUNT-COSTCENTER = ' '.

MODIFY POACCOUNT.

endif.

ENDLOOP.

*MOD-004

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

*MOD-003

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

IF NOT TESTRUN IS INITIAL.

L_SERIAL_NO = 0.

L_TABIX = 0.

  • POHEADER-VENDOR = C_VENDOR.

  • poheader-doc_type = C_DOC_TYPE.

  • poheader-comp_code = l_bukrs.

  • POHEADER-DOC_DATE = SY-DATUM.

  • POHEADER-CURRENCY = C_CURRENCY.

  • POHEADER-NETPR = C_NETPR.

LOOP AT POACCOUNT.

L_TABIX = L_TABIX + 1.

LOOP AT POITEM.

if POACCOUNT-PO_ITEM is initial.

POACCOUNT-PO_ITEM = SY-TABIX.

endif.

if POACCOUNT-SERIAL_NO is initial.

POACCOUNT-SERIAL_NO = L_TABIX.

endif.

MODIFY POACCOUNT.

ENDLOOP.

ENDLOOP.

*MOD-004

IF POCOND[] IS INITIAL and

NOT TESTRUN IS INITIAL.

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

LOOP AT POITEM.

pocond-itm_number = poitem-po_item.

POCOND-COND_ST_NO = SY-TABIX.

POCOND-COND_COUNT = SY-TABIX.

pocond-cond_value = poitem-net_price.

pocond-cond_type = 'PBXX'.

POCOND-CHANGE_ID = 'I'.

if not pocond-currency is initial.

pocond-currency = l_waers.

endif.

  • POCONDHEADER-itm_number = poitem-po_item.

  • POCONDHEADER-COND_ST_NO = SY-TABIX.

  • POCONDHEADER-COND_COUNT = SY-TABIX.

  • pocondHEADER-cond_value = poitem-net_price.

  • pocondHEADER-cond_type = 'PBXX'.

  • POCONDHEADER-CHANGE_ID = 'I'.

  • if not pocond-currency is initial.

  • pocondHEADER-currency = l_waers.

  • endif.

APPEND: POCOND,POCONDHEADER.

CLEAR: POCOND, POCONDHEADER.

ENDLOOP.

  • endif.

  • ENDIF.

ENDIF.

*MOD-004

IF POITEM[] IS INITIAL.

POITEM-SHORT_TEXT = 'Simulation'(001).

if poitem-plant is initial.

clear: l_werks1.

select single plant

into l_werks1

  • from zpo_plantmapping

from zp2p_plantmaping

where COMPANY_CODE = poheader-comp_code and

PURCH_ORG = poheader-purch_org and

PURCH_GROUP = poheader-pur_group and

LE = poheader-le and

  • MRC = poheader-mrc and

FSID = poheader-fsid and

FRMRC = poheader-frmrc.

IF SY-SUBRC = 0.

poitem-plant = l_werks1.

ENDIF.

endif.

if poitem-po_item is initial.

POITEM-PO_ITEM = L_TABIX.

endif.

if poitem-plant is initial.

poitem-plant = l_werks1.

endif.

if POITEM-MATL_GROUP is initial.

POITEM-MATL_GROUP = '99'.

endif.

if POITEM-QUANTITY is initial.

POITEM-QUANTITY = '1'.

endif.

if POITEM-PO_UNIT is initial.

POITEM-PO_UNIT = 'EA'.

endif.

if POITEM-ORDERPR_UN is initial.

POITEM-ORDERPR_UN = 'EA'.

endif.

if POITEM-NET_PRICE is initial.

POITEM-NET_PRICE = '1.00'.

endif.

if POITEM-PRICE_UNIT is initial.

POITEM-PRICE_UNIT = '1.00'.

endif.

  • if POITEM-DISTRIB is initial.

  • POITEM-DISTRIB = ' '.

  • endif.

  • if POITEM-PART_INV is initial.

  • POITEM-PART_INV = ' '.

  • endif.

*MOD-004

if POITEM-GR_IND = C_Y..

POITEM-GR_IND = C_X.

ELSEIF POITEM-GR_IND = C_X.

POITEM-GR_IND = C_X.

ELSE.

POITEM-GR_IND = ' '.

endif.

*MOD-004

**MOD-004

  • if POITEM-GR_IND is initial or

  • POITEM-GR_IND = c_y.

  • POITEM-GR_IND = c_x.

  • ELSE.

  • POITEM-GR_IND = ' '.

  • ENDIF.

**MOD-004

if POITEM-IR_IND is initial.

POITEM-IR_IND = 'X'.

endif.

if POITEM-INCOTERMS1 is initial.

POITEM-INCOTERMS1 = 'CIF'.

endif.

if POITEM-INCOTERMS2 is initial.

POITEM-INCOTERMS2 = 'CIF'.

endif.

if POITEM-PREQ_ITEM is initial.

POITEM-PREQ_ITEM = '123456'.

endif.

APPEND POITEM.

CLEAR: POITEM.

ENDIF.

  • if POACCOUNT-PO_ITEM is initial.

  • POACCOUNT-PO_ITEM = SY-TABIX.

  • endif.

  • if POACCOUNT-SERIAL_NO is initial.

  • POACCOUNT-SERIAL_NO = L_TABIX.

  • endif.

  • MODIFY POACCOUNT.

  • ENDIF.

  • ENDLOOP.

PERFORM get_account_assignment TABLES poitem

poitemx

poaccount

poaccountx

t_yreturn

USING poheader-comp_code

poheader.

IF NOT t_yreturn[] IS INITIAL.

APPEND LINES OF t_yreturn TO RETURN.

READ TABLE t_yreturn WITH KEY type = 'W'.

IF sy-subrc <> 0.

EXPHEADER = POHEADER.

EXPHEADER-CODE = '99'.

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 ZERRORS FROM TABLE T_ERRORS.

INSERT ZP2P_ERRORS FROM TABLE T_ERRORS.

**MOD-005

    • On Error, exit the function module

  • l_exit = 0.

  • LOOP AT RETURN WHERE TYPE = C_E.

  • L_EXIT = 1.

  • EXPHEADER = POHEADER.

  • EXPHEADER-CODE = '99'.

  • RETURN-RETURN_CODE = C_99.

  • RETURN-SEQ_CODE = C_99.

  • MODIFY RETURN TRANSPORTING RETURN_CODE SEQ_CODE.

  • ENDLOOP.

  • IF L_EXIT = 1.

  • EXIT.

  • ENDIF.

**MOD-005

EXIT.

ENDIF.

ENDIF.

PERFORM GET_INCOTERMS_LINE_ITEM tables poitem

using poheader.

perform get_uom_conversion tables poitem

POITEMX

poaccount

poaccountx

poschedule

poschedulex

pocond

pocondx

pocondheader

pocondheaderx

changing poheader

poheaderx.

ENDIF.

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

*mod-003

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

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

*sraman2 10/14/04

IF POHEADER-PO_NUMBER(3) = C_PCO.

  • DATA: l_serial_no LIKE poaccount-serial_no.

loop at POACCOUNT.

ADD 1 TO l_serial_no.

POACCOUNT-SERIAL_NO = l_serial_no.

modify POACCOUNT.

endloop.

endif.

*sraman2 10/14/04

SORT POACCOUNT BY PO_ITEM.

LOOP AT POACCOUNT.

check poheader-quotation+0(2) ne 'CR' and

poheader-quotation+0(2) ne 'UT'.

IF NOT POACCOUNT-WBS_ELEMENT IS INITIAL. "line item posting to

"WBS element

CLEAR L_MSGV1.

L_MSGV1 = POACCOUNT-PO_ITEM.

  • Mod-004

  • Line Item NOT eligible for PCARD

  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'

  • EXPORTING

  • TYPE = C_MSGTYPE_I "I

  • CL = C_MSGID_Z001 "Z001

  • NUMBER = C_MSGNR_038 "038

  • PAR1 = L_MSGV1

  • IMPORTING

  • RETURN = RETURN.

  • APPEND RETURN.

  • CLEAR RETURN.

*mod-004

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-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

clear: l_wa_zerrors.

ELSE.

IF NOT POACCOUNT-COSTCENTER IS INITIAL.

"line item posting to cost center.

READ TABLE POITEM WITH KEY PO_ITEM = POACCOUNT-PO_ITEM.

IF SY-SUBRC = 0.

IF NOT POITEM-DISTRIB IS INITIAL.

CLEAR L_MSGV1.

L_MSGV1 = POACCOUNT-PO_ITEM.

*Mod-004

  • Line Item NOT eligible for PCARD

  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'

  • EXPORTING

  • TYPE = C_MSGTYPE_I "I

  • CL = C_MSGID_Z001 "Z001

  • NUMBER = C_MSGNR_038 "038

  • PAR1 = L_MSGV1

  • IMPORTING

  • RETURN = RETURN.

  • APPEND RETURN.

  • CLEAR RETURN.

*mod-004

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 = return-id.

l_wa_zerrors-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

ELSE. "line item does NOT contain split accounting

CLEAR L_MSGV1.

L_MSGV1 = POACCOUNT-PO_ITEM.

    • Line Item Eligible for PCARD

  • CALL FUNCTION 'BALW_BAPIRETURN_GET2'

  • EXPORTING

  • TYPE = C_MSGTYPE_I "I

  • CL = C_MSGID_Z001 "Z001

  • NUMBER = C_MSGNR_039 "039

  • PAR1 = L_MSGV1

  • IMPORTING

  • RETURN = RETURN.

  • APPEND RETURN.

  • CLEAR RETURN.

*MOD-004

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 = return-id.

l_wa_zerrors-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

  • To convert WBS Element from External format to Internal Format.

LOOP AT POACCOUNT WHERE NOT WBS_ELEMENT IS INITIAL.

CLEAR : L_WBS_EXTERNAL,

L_WBS_INTERNAL.

L_WBS_EXTERNAL = POACCOUNT-WBS_ELEMENT.

CALL FUNCTION 'CONVERSION_EXIT_ABPSN_INPUT'

EXPORTING

INPUT = L_WBS_EXTERNAL

IMPORTING

OUTPUT = L_WBS_INTERNAL.

POACCOUNT-WBS_ELEMENT = L_WBS_INTERNAL.

*sraman2 06/23/04

  • MODIFY POACCOUNT INDEX SY-TABIX TRANSPORTING WBS_ELEMENT.

MODIFY POACCOUNT.

*sraman2 06/23/04

ENDLOOP.

*Rounding off to 100 percent.

SORT POACCOUNT BY PO_ITEM DISTR_PERC.

*MOD-003

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_X. " 'X'

ENDIF.

ENDAT.

IF G_ADJUST_PERC = C_X. " 'X'

  • ADD g_distr_perc TO POACCOUNT-DISTR_PERC.

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.

*MOD-003

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

  • Retrieve vendor account group Constant

CALL FUNCTION 'ZXA_GET_CONSTANT'

EXPORTING

CONST_NAME = C_VEND_ACTGRP

COMP_CODE = POHEADER-COMP_CODE

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.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = C_VEND_ACTGRP. "ZRP_VEND_ACTGRP

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

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-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

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 = POHEADER-COMP_CODE

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

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = C_VEND_PAYTRM. "ZRP_VEND_PAYTRM

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

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-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

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 = POHEADER-COMP_CODE

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.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

L_CONST_NAME = C_VEND_RECON. "ZRP_VEND_RECON

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

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-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

EXIT.

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

ENDIF.

*Zero Pad and Prefix 1 to Vendor.

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 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 = return-id.

l_wa_zerrors-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

ENDIF.

ENDIF.

IF TESTRUN IS INITIAL.

SELECT SINGLE * FROM LFA1 WHERE

LIFNR = POHEADER-VENDOR.

IF SY-SUBRC NE 0.

  • Vendor Master (General Section)

IF POADDRVENDOR-NAME IS INITIAL.

MOVE C_ARIBAVENDOR TO POADDRVENDOR-NAME. " 'ARIBA VENDOR'

ENDIF.

W_LFA1-LIFNR = POHEADER-VENDOR.

W_LFA1-NAME1 = POADDRVENDOR-NAME.

W_LFA1-MCOD1 = POADDRVENDOR-NAME.

W_LFA1-LAND1 = C_US. " 'US'

W_LFA1-SPRAS = C_E. " 'E'

W_LFA1-KTOKK = L_VEND_ACTGRP.

W_LFB1-LIFNR = POHEADER-VENDOR.

W_LFB1-BUKRS = POHEADER-COMP_CODE.

W_LFB1-AKONT = L_VEND_RECON.

W_LFB1-ZTERM = L_VEND_PAYTRM.

W_LFM1-LIFNR = POHEADER-VENDOR.

W_LFM1-EKORG = POHEADER-PURCH_ORG.

W_LFM1-WAERS = POHEADER-CURRENCY.

MOVE C_N TO G_FLG_VENDOR. " 'N'

ELSE.

  • Vendor Master (General Section)

IF POADDRVENDOR-NAME IS INITIAL.

MOVE C_ARIBAVENDOR TO POADDRVENDOR-NAME. " 'ARIBA VENDOR'

ENDIF.

W_LFA1-LIFNR = POHEADER-VENDOR.

W_LFA1-NAME1 = POADDRVENDOR-NAME.

W_LFA1-MCOD1 = POADDRVENDOR-NAME.

W_LFA1-LAND1 = C_US. " 'US'

W_LFA1-SPRAS = C_E. " 'E'

W_LFA1-KTOKK = L_VEND_ACTGRP.

SELECT SINGLE * FROM LFB1 WHERE

LIFNR = POHEADER-VENDOR

AND BUKRS = POHEADER-COMP_CODE.

IF SY-SUBRC NE 0.

W_LFB1-LIFNR = POHEADER-VENDOR.

W_LFB1-BUKRS = POHEADER-COMP_CODE.

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 = POHEADER-VENDOR

AND EKORG = POHEADER-PURCH_ORG.

IF SY-SUBRC NE 0.

W_LFM1-LIFNR = POHEADER-VENDOR.

W_LFM1-EKORG = POHEADER-PURCH_ORG.

W_LFM1-WAERS = POHEADER-CURRENCY.

G_FLG_VENDOR = C_N. " 'N'

ENDIF.

ENDIF.

IF G_FLG_VENDOR = C_N. " 'N'

  • 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 RETURN.

  • EXIT.

  • ELSE.

  • CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT = C_X " 'X'

  • IMPORTING

  • RETURN = RETURN.

*

  • IF RETURN-TYPE = C_E. " 'E'

  • APPEND RETURN.

  • EXIT.

  • ELSE.

  • CLEAR RETURN.

  • ENDIF.

  • ENDIF.

ELSE.

*M0D-003

SELECT SINGLE * FROM LFA1 WHERE

LIFNR = POHEADER-VENDOR.

IF SY-SUBRC EQ 0.

SELECT SINGLE * FROM LFB1 WHERE

LIFNR = POHEADER-VENDOR

AND BUKRS = POHEADER-COMP_CODE.

IF SY-SUBRC NE 0.

SELECT SINGLE * FROM LFM1 WHERE

LIFNR = POHEADER-VENDOR AND

EKORG = POHEADER-PURCH_ORG.

IF SY-SUBRC = 0.

POHEADER-INCOTERMS1 = LFM1-INCO1.

POHEADER-INCOTERMS2 = LFM1-INCO2.

ENDIF.

ENDIF.

ENDIF.

*MOD-003

ENDIF.

  • For PCO Order, populate the PO and accounting data into a Z table .

IF POHEADER-PO_NUMBER(3) = C_PCO. " 'PCO'

PERFORM POPULATE_NONPO_DOCUMENT TABLES POITEM

RETURN

POTEXTHEADER

USING POHEADER-PO_NUMBER

POHEADER.

PERFORM POPULATE_NONPO_ACCOUNTING TABLES POACCOUNT

RETURN

USING POHEADER.

PERFORM UPDATE_NONPODOCUMENT.

LOOP AT T_RETURN.

MOVE: T_RETURN-TYPE TO RETURN-TYPE,

T_RETURN-ID TO RETURN-ID,

T_RETURN-NUMBER TO RETURN-NUMBER,

T_RETURN-MESSAGE TO RETURN-MESSAGE.

APPEND RETURN.

CLEAR RETURN.

ENDLOOP.

EXIT.

ENDIF.

ENDIF.

*Move RETURN table messages to temp return table.

REFRESH T_TEMPRETURN.

APPEND LINES OF RETURN TO T_TEMPRETURN.

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

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

*mod-003

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

**Populate the change indicator structures before calling

  • BAPI_PO_CREATE1

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

**MOD-003

  • IF NOT POSCHEDULE[] IS INITIAL.

  • G_T_SCHD_TMP[] = POSCHEDULE[].

  • ENDIF.

**MOD-03

  • 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-22-May-2004 - End Changes for SCR1

*sraman2 06/07/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 TRANSPORTING matl_group.

ENDIF.

CLEAR poitem.

ENDLOOP.

*sraman2 06/07/04

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

*mod-003

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

  • 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-PRICE_UNIT 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

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

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

*mod-003

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

if testrun is initial.

PERFORM GET_INCOTERMS_LINE_ITEM tables poitem

using poheader.

perform get_uom_conversion tables poitem

POITEMX

poaccount

poaccountx

poschedule

poschedulex

pocond

pocondx

pocondheader

pocondheaderx

changing poheader

poheaderx.

endif.

*MOD-004

LOOP AT POITEM.

IF NOT POITEM-DISTRIB IS INITIAL.

CLEAR : L_CONST_NAME,

L_COMP_CODE.

READ TABLE POACCOUNT INDEX SY-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-type = t_yreturn-type.

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.

clear: l_wa_zerrors.

endloop.

IF NOT t_yreturn[] IS INITIAL.

APPEND LINES OF t_yreturn TO RETURN.

READ TABLE t_yreturn WITH KEY type = 'E'.

IF sy-subrc = 0.

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.

DELETE T_ERRORS WHERE TYPE NE C_E.

DELETE T_ERRORS WHERE TYPE IS INITIAL.

INSERT ZP2P_ERRORS FROM TABLE T_ERRORS.

**MOD-005

    • On Error, exit the function module

  • l_exit = 0.

  • LOOP AT RETURN WHERE TYPE = C_E.

  • L_EXIT = 1.

  • EXPHEADER = POHEADER.

  • EXPHEADER-CODE = '99'.

  • RETURN-RETURN_CODE = C_99.

  • RETURN-SEQ_CODE = C_99.

  • MODIFY RETURN TRANSPORTING RETURN_CODE SEQ_CODE.

  • ENDLOOP.

  • IF L_EXIT = 1.

  • EXIT.

  • ENDIF.

**MOD-005

  • INSERT ZERRORS FROM TABLE T_ERRORS.

**MOD-004

  • L_RETURN = ' '.

  • LOOP AT RETURN WHERE TYPE = C_E.

  • RETURN-RETURN_CODE = '99'.

  • L_RETURN = C_X.

  • MODIFY RETURN TRANSPORTING RETURN_CODE.

  • ENDLOOP.

  • IF L_RETURN = C_X.

  • EXIT.

  • ENDIF.

**MOD-004

  • EXPHEADER = POHEADER.

  • EXPHEADER-CODE = '99'.

*MOD-004

EXIT.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

IF NOT t_yreturn[] IS INITIAL.

APPEND LINES OF t_yreturn TO RETURN.

READ TABLE t_yreturn WITH KEY type = 'E'.

IF sy-subrc = 0.

**MOD-005

    • On Error, exit the function module

  • l_exit = 0.

  • LOOP AT RETURN WHERE TYPE = C_E.

  • L_EXIT = 1.

  • EXPHEADER = POHEADER.

  • EXPHEADER-CODE = '99'.

  • RETURN-RETURN_CODE = C_99.

  • RETURN-SEQ_CODE = C_99.

  • MODIFY RETURN TRANSPORTING RETURN_CODE SEQ_CODE.

  • ENDLOOP.

  • IF L_EXIT = 1.

  • EXIT.

  • ENDIF.

**MOD-005

*MOD-005

  • EXPHEADER = POHEADER.

  • EXPHEADER-CODE = '99'.

*MOD-005

EXIT.

ENDIF.

ENDIF.

*MOD-004

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

*mod-003

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

*Populate the change indicator structures before calling BAPI_PO_CREATE1

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

*MOD-003

IF NOT POSCHEDULE[] IS INITIAL.

G_T_SCHD_TMP[] = POSCHEDULE[].

ENDIF.

*MOD-03

IF NOT POACCOUNTX[] IS INITIAL.

G_T_ACCNTX_TMP[] = POACCOUNTX[].

ENDIF.

IF NOT POCONDX[] IS INITIAL.

G_T_CONDX_TMP[] = POCONDX[].

ENDIF.

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

*mod-003

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

*MOD-004

LOOP AT poitem.

IF NOT poitem-delete_ind IS INITIAL. "delete ind marked.

*For item deletion to work properly

*indicator should be 'D'. webmethods passes indicator 'X'.

CASE POITEM-DELETE_IND.

WHEN 'A'.

POITEM-DELETE_IND = ' '.

WHEN 'C'.

POITEM-DELETE_IND = ' '.

WHEN 'D'.

POITEM-DELETE_IND = 'D'.

CLEAR poitem-final_inv.

WHEN 'X'.

POITEM-DELETE_IND = 'D'.

CLEAR poitem-final_inv.

ENDCASE.

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.

*MOD-004

*Call PO Create BAPI.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

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

EXPPURCHASEORDER = EXPPURCHASEORDER

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.

sort return by TYPE

ID

NUMBER

MESSAGE

LOG_NO

LOG_MSG_NO

MESSAGE_V1

MESSAGE_V2

MESSAGE_V3

MESSAGE_V4

PARAMETER

ROW

FIELD

SYSTEM.

delete adjacent duplicates from RETURN

comparing TYPE

ID

NUMBER

MESSAGE

LOG_NO

LOG_MSG_NO

MESSAGE_V1

MESSAGE_V2

MESSAGE_V3

MESSAGE_V4

PARAMETER

ROW

FIELD

SYSTEM.

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-type = return-type.

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 zerrors values l_wa_zerrors.

clear: l_wa_zerrors.

endloop.

*append temp return table to RETURN table.

APPEND LINES OF T_TEMPRETURN TO RETURN.

READ TABLE RETURN WITH KEY TYPE = C_E.

IF SY-SUBRC = 0 .

EXPHEADER-CODE = C_99.

ELSE.

EXPHEADER-CODE = C_00.

ENDIF.

**MOD-005

    • On Error, exit the function module

  • l_exit = 0.

  • LOOP AT RETURN WHERE TYPE = C_E.

  • L_EXIT = 1.

  • EXPHEADER = POHEADER.

  • EXPHEADER-CODE = C_99.

  • RETURN-RETURN_CODE = C_99.

  • RETURN-SEQ_CODE = C_99.

  • MODIFY RETURN TRANSPORTING RETURN_CODE SEQ_CODE.

  • ENDLOOP.

  • IF L_EXIT = 1.

  • EXIT.

  • ENDIF.

**MOD-005

IF TESTRUN IS INITIAL AND

NOT EXPPURCHASEORDER IS INITIAL.

*sraman2 6/25/04

*This check for 'E' is not necessary.

*This is causing order creation issues

*for some scenarios

  • READ TABLE RETURN WITH KEY TYPE = C_E. "E

  • IF SY-SUBRC NE 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  • ENDIF.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

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

*To generate inbound IDOC for failed PO

  • IF TESTRUN IS INITIAL.

  • 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_POCREATE "CREA

  • EXPPURCHASEORDER

  • POHEADER

  • G_W_HDRX_TMP

  • POADDRVENDOR

  • TESTRUN

  • MEMORY_UNCOMPLETE

  • MEMORY_COMPLETE.

*

  • ENDIF.

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

ENDIF.

*Generate Custom Return messages based on Message Id and number from

*maintenance table ZMESSAGES

CALL FUNCTION 'Z_MM_BUILD_MESSAGES'

TABLES

RETURN = RETURN.

READ TABLE RETURN WITH KEY ID = SPACE

NUMBER = C_MSGNR_000. "000

IF SY-SUBRC EQ 0 AND SY-TABIX NE 1.

DELETE RETURN INDEX SY-TABIX.

INSERT RETURN INDEX 1.

ENDIF.

  • DATA: L_SERIAL TYPE I.

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.

DELETE T_ERRORS WHERE TYPE NE C_E.

DELETE T_ERRORS WHERE TYPE IS INITIAL.

  • INSERT ZERRORS FROM TABLE T_ERRORS.

  • DELETE FROM ZERRORS WHERE TYPE NE C_E.

IF NOT T_ERRORS IS INITIAL.

INSERT ZP2P_ERRORS FROM TABLE T_ERRORS.

ENDIF.

DELETE FROM ZP2P_ERRORS WHERE TYPE NE C_E.

ENDFUNCTION.

----


***INCLUDE LZPORFCFUNCF01 .

----


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

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

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

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

costcenter = 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 creates the

  • 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_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 N