You are on page 1of 12

PROGRAM trans_routine.

*---------------------------------------------------------------------*
* CLASS routine DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform DEFINITION.
PUBLIC SECTION.

* Attributs
DATA:
p_check_master_data_exist
TYPE RSODSOCHECKONLY READ-ONLY,
*- Instance for getting request runtime attributs;
* Available information: Refer to methods of
* interface 'if_rsbk_request_admintab_view'
p_r_request
TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.

PRIVATE SECTION.

TYPE-POOLS: rsd, rstr.

* Rule specific types


TYPES:
BEGIN OF _ty_s_SC_1,
* InfoObject: 0AC_DOC_NO Accounting document number.
AC_DOC_NO TYPE /BI0/OIAC_DOC_NO,
* InfoObject: 0COMP_CODE Company code.
COMP_CODE TYPE /BI0/OICOMP_CODE,
* InfoObject: 0ITEM_NUM Number of line item within accounting docum
*ent.
ITEM_NUM TYPE /BI0/OIITEM_NUM,
* InfoObject: 0FISCPER ������/�‫ �ڼ‬.
FISCPER TYPE /BI0/OIFISCPER,
* InfoObject: 0FISCVARNT �����ȱ�ʽ.
FISCVARNT TYPE /BI0/OIFISCVARNT,
* InfoObject: 0CHRT_ACCTS Chart of accounts.
CHRT_ACCTS TYPE /BI0/OICHRT_ACCTS,
* InfoObject: 0GL_ACCOUNT G/L Account.
GL_ACCOUNT TYPE /BI0/OIGL_ACCOUNT,
* InfoObject: 0AC_DOC_TYP Document type.
AC_DOC_TYP TYPE /BI0/OIAC_DOC_TYP,
* InfoObject: 0ACCT_TYPE Account type.
ACCT_TYPE TYPE /BI0/OIACCT_TYPE,
* InfoObject: 0BLINE_DATE Baseline Date For Due Date Calculation.
BLINE_DATE TYPE /BI0/OIBLINE_DATE,
* InfoObject: 0BUS_AREA Business area.
BUS_AREA TYPE /BI0/OIBUS_AREA,
* InfoObject: 0CLEAR_DATE Clearing date.
CLEAR_DATE TYPE /BI0/OICLEAR_DATE,
* InfoObject: 0CLR_DOC_NO Clearing Document Number.
CLR_DOC_NO TYPE /BI0/OICLR_DOC_NO,
* InfoObject: 0CO_AREA Controlling area.
CO_AREA TYPE /BI0/OICO_AREA,
* InfoObject: 0COORDER Order number.
COORDER TYPE /BI0/OICOORDER,
* InfoObject: 0COSTCENTER Cost Center.
COSTCENTER TYPE /BI0/OICOSTCENTER,
* InfoObject: 0CREATEDON Date on which the record was created.
CREATEDON TYPE /BI0/OICREATEDON,
* InfoObject: 0DOC_DATE Document Date.
DOC_DATE TYPE /BI0/OIDOC_DATE,
* InfoObject: 0FI_DOCSTAT Item Status.
FI_DOCSTAT TYPE /BI0/OIFI_DOCSTAT,
* InfoObject: 0FUNDS_CTR Funds Center.
FUNDS_CTR TYPE /BI0/OIFUNDS_CTR,
* InfoObject: 0LOC_CURTP2 Currency Type of Second Local Currency.
LOC_CURTP2 TYPE /BI0/OILOC_CURTP2,
* InfoObject: 0LOC_CURTP3 Currency Type of Third Local Currency.
LOC_CURTP3 TYPE /BI0/OILOC_CURTP3,
* InfoObject: 0ORG_DOC_CC Company Code for Source Document Number.
ORG_DOC_CC TYPE /BI0/OIORG_DOC_CC,
* InfoObject: 0ORG_DOC_CO Controlling Area for Source Document Numb
*er.
ORG_DOC_CO TYPE /BI0/OIORG_DOC_CO,
* InfoObject: 0ORG_DOC_NO Document Number of Source Document.
ORG_DOC_NO TYPE /BI0/OIORG_DOC_NO,
* InfoObject: 0ORG_DOC_YR Fiscal Year for Source Document Number.
ORG_DOC_YR TYPE /BI0/OIORG_DOC_YR,
* InfoObject: 0PART_PRCTR Partner profit center.
PART_PRCTR TYPE /BI0/OIPART_PRCTR,
* InfoObject: 0PBUS_AREA Trading partner business area of the busin
*ess partner.
PBUS_AREA TYPE /BI0/OIPBUS_AREA,
* InfoObject: 0PCOMPANY Partner company number.
PCOMPANY TYPE /BI0/OIPCOMPANY,
* InfoObject: 0PLANT Plant.
PLANT TYPE /BI0/OIPLANT,
* InfoObject: 0POST_KEY Posting key.
POST_KEY TYPE /BI0/OIPOST_KEY,
* InfoObject: 0PROFIT_CTR Profit Center.
PROFIT_CTR TYPE /BI0/OIPROFIT_CTR,
* InfoObject: 0PSTNG_DATE Posting date in the document.
PSTNG_DATE TYPE /BI0/OIPSTNG_DATE,
* InfoObject: 0REF_DOC_NO Reference document number.
REF_DOC_NO TYPE /BI0/OIREF_DOC_NO,
* InfoObject: 0SP_GL_IND Special G/L indicator.
SP_GL_IND TYPE /BI0/OISP_GL_IND,
* InfoObject: 0TXTLG ������.
TXTLG TYPE RSTXTLG,
* InfoObject: 0WBS_ELEMT Work Breakdown Structure Element (WBS Elem
*ent).
WBS_ELEMT TYPE /BI0/OIWBS_ELEMT,
* InfoObject: 0LOC_CURRCY Local currency.
LOC_CURRCY TYPE /BI0/OILOC_CURRCY,
* InfoObject: 0DOC_CURRCY Document currency.
DOC_CURRCY TYPE /BI0/OIDOC_CURRCY,
* InfoObject: 0LOC_CURRC2 Second Local Currency.
LOC_CURRC2 TYPE /BI0/OILOC_CURRC2,
* InfoObject: 0LOC_CURRC3 Third Local Currency.
LOC_CURRC3 TYPE /BI0/OILOC_CURRC3,
* InfoObject: 0DEBIT_LC Debit amount in local currency.
DEBIT_LC TYPE /BI0/OIDEBIT_LC,
* InfoObject: 0CREDIT_LC Credit amount in local currency.
CREDIT_LC TYPE /BI0/OICREDIT_LC,
* InfoObject: 0DEB_CRE_LC Amount in Local Currency with +/- Signs.
DEB_CRE_LC TYPE /BI0/OIDEB_CRE_LC,
* InfoObject: 0DEBIT_DC Debit amount in foreign currency.
DEBIT_DC TYPE /BI0/OIDEBIT_DC,
* InfoObject: 0CREDIT_DC Credit amount in foreign currency.
CREDIT_DC TYPE /BI0/OICREDIT_DC,
* InfoObject: 0DEB_CRE_DC Foreign currency amount with signs (+/-).
DEB_CRE_DC TYPE /BI0/OIDEB_CRE_DC,
* InfoObject: 0DEBIT_LC2 Debit Amount in 2nd Local Currency.
DEBIT_LC2 TYPE /BI0/OIDEBIT_LC2,
* InfoObject: 0CREDIT_LC2 Credit Amount in Second Local Currency.
CREDIT_LC2 TYPE /BI0/OICREDIT_LC2,
* InfoObject: 0DEB_CRE_L2 Amount in Second Local Currency with +/-
*Sign.
DEB_CRE_L2 TYPE /BI0/OIDEB_CRE_L2,
* InfoObject: 0DEBIT_LC3 Debit Amount in Third Local Currency.
DEBIT_LC3 TYPE /BI0/OIDEBIT_LC3,
* InfoObject: 0CREDIT_LC3 Credit Amount in Third Local Currency.
CREDIT_LC3 TYPE /BI0/OICREDIT_LC3,
* InfoObject: 0DEB_CRE_L3 Amount in Third Local Currency with +/- S
*ign.
DEB_CRE_L3 TYPE /BI0/OIDEB_CRE_L3,
* InfoObject: 0RECORDMODE BW �� ����: ����ģʽ.
RECORDMODE TYPE RODMUPDMOD,
* InfoObject: 0VALUE_DATE Value Date.
VALUE_DATE TYPE /BI0/OIVALUE_DATE,
* InfoObject: 0FUNC_AREA Functional area.
FUNC_AREA TYPE /BI0/OIFUNC_AREA,
* InfoObject: 0EMPLOYEE Ա��.
EMPLOYEE TYPE /BI0/OIEMPLOYEE,
* InfoObject: 0DOC_HD_TXT ƾ̧֤ͷ �ı �.
DOC_HD_TXT TYPE /BI0/OIDOC_HD_TXT,
* InfoObject: 0TRXN_KEY ����‫ � � �ؼ‬.
TRXN_KEY TYPE /BI0/OITRXN_KEY,
* InfoObject: 0BUS_TRXN ҵ����.
BUS_TRXN TYPE /BI0/OIBUS_TRXN,
* InfoObject: 0FUND Fund.
FUND TYPE /BI0/OIFUND,
* InfoObject: 0FM_AREA Financial management area.
FM_AREA TYPE /BI0/OIFM_AREA,
* InfoObject: 0MATERIAL Material.
MATERIAL TYPE /BI0/OIMATERIAL,
* InfoObject: 0CUSTOMER Customer number.
CUSTOMER TYPE /BI0/OICUSTOMER,
* InfoObject: 0VENDOR ��Ӧ��.
VENDOR TYPE /BI0/OIVENDOR,
* InfoObject: 0DOC_NUM BW: Document Number.
DOC_NUM TYPE /BI0/OIDOC_NUM,
* InfoObject: 0DOC_ITEM BW: Document Line Number.
DOC_ITEM TYPE /BI0/OIDOC_ITEM,
* InfoObject: ZTCODE �������.
/BIC/ZTCODE TYPE /BIC/OIZTCODE,
* InfoObject: ZUONR ������.
/BIC/ZUONR TYPE /BIC/OIZUONR,
* InfoObject: 0REF_KEY3 Reference Key 3.
REF_KEY3 TYPE /BI0/OIREF_KEY3,
* InfoObject: 0ALLOC_NMBR Allocation Number.
ALLOC_NMBR TYPE /BI0/OIALLOC_NMBR,
* InfoObject: 0POSTXT Item Text.
POSTXT TYPE /BI0/OIPOSTXT,
* InfoObject: ZBEKNZ ��/����.
/BIC/ZBEKNZ TYPE /BIC/OIZBEKNZ,
* InfoObject: ZDMBTR ���Ҷ���.
/BIC/ZDMBTR TYPE /BIC/OIZDMBTR,
* Field: RECORD.
RECORD TYPE RSARECORD,
END OF _ty_s_SC_1.
TYPES:
_ty_t_SC_1 TYPE STANDARD TABLE OF _ty_s_SC_1
WITH NON-UNIQUE DEFAULT KEY.

*$*$ begin of global - insert your declaration only below this line *-*

*** version 1.0 by luojianchao on 2014.1.10

TYPES: BEGIN OF ty_doc1,


org_doc_no TYPE /bi0/oiorg_doc_no,
comp_code TYPE /bi0/oicomp_code,
END OF ty_doc1.

TYPES: BEGIN OF ty_doc2,


org_doc_no TYPE /bi0/oiorg_doc_no,
END OF ty_doc2.

TYPES: BEGIN OF ty_doc3,


org_doc_yr TYPE /bi0/oiorg_doc_yr,
org_doc_no TYPE /bi0/oiorg_doc_no,
doc_item TYPE /bi0/oidoc_item,
END OF ty_doc3.

TYPES: BEGIN OF ty_doc4,


VENDOR TYPE /BI0/OIVENDOR,
PURCH_ORG TYPE /BI0/OIPURCH_ORG,
END OF ty_doc4.

TYPES: BEGIN OF ty_doc5,


org_doc_yr TYPE /bi0/oiorg_doc_yr,
org_doc_no TYPE /bi0/oiorg_doc_no,
END OF ty_doc5.

TYPES: BEGIN OF ty_doc6,


/BIC/ZUONR TYPE /BIC/OIZUONR,
VENDOR TYPE /BI0/OIvendor,
END OF ty_doc6.

TYPES: BEGIN OF ty_inv,


bbp_inv_id TYPE /bi0/oibbp_inv_id,
fiscyear TYPE /bi0/oifiscyear,
inv_pty TYPE /bi0/oiinv_pty,
END OF ty_inv.

TYPES: BEGIN OF ty_bf,


doc_num TYPE /bi0/oidoc_num,
doc_item TYPE /bi0/oidoc_item,
vendor TYPE /bi0/oivendor,
END OF ty_bf.

TYPES: BEGIN OF ty_ap,


AC_DOC_NO TYPE /BI0/OIAC_DOC_NO,
COMP_CODE TYPE /BI0/OICOMP_CODE,
CREDITOR TYPE /bi0/oiCREDITOR,
END OF ty_ap.

TYPES: BEGIN OF ty_hd,


DOC_NUM TYPE /BI0/OIDOC_NUM,
VENDOR TYPE /BI0/OIvendor,
INV_PARTY TYPE /BI0/OIINV_PARTY,
END OF ty_hd.

TYPES: BEGIN OF ty_vp,


/BIC/ZVEN_PORG TYPE /BIC/OIZVEN_PORG,
PURCH_ORG TYPE /BI0/OIPURCH_ORG,
INV_PARTY TYPE /BI0/OIINV_PARTY,
END OF ty_vp.

DATA :
*** for the ZFI_AP_4 of Doc and Company
it_doc1 TYPE TABLE OF ty_doc1,
wa_doc1 TYPE ty_doc1,
*** for the ZLIS02HD of PO
it_doc2 TYPE TABLE OF ty_doc2,
wa_doc2 TYPE ty_doc2,
*** for the ZLIS03BF of Material Doc and Item
it_doc3 TYPE TABLE OF ty_doc3,
wa_doc3 TYPE ty_doc3,
*** for the consignment of Vender
it_doc4 TYPE TABLE OF ty_doc4,
wa_doc4 TYPE ty_doc4,
*** for IR
it_doc5 TYPE TABLE OF ty_doc5,
wa_doc5 TYPE ty_doc5,
*** for GR
it_doc6 TYPE TABLE OF ty_doc6,
wa_doc6 TYPE ty_doc6,

it_inv TYPE TABLE OF ty_inv,


*** for the ZLIS03BF of Vender
it_bf TYPE TABLE OF ty_bf,
*** for the ZFI_AP_4 of CREDITOR
it_ap TYPE TABLE OF ty_ap,
*** for the ZLIS02HD of PI
it_hd TYPE TABLE OF ty_hd,
*** for the ZVEN_PORG of PI
it_vp TYPE TABLE OF ty_vp,
*** for the ZFIAPD08 of ZUONR
it_APD08 TYPE TABLE OF /BIC/AZFIAPD0800,
wa_APD08 TYPE /BIC/AZFIAPD0800.

DATA: tab_nam TYPE tabname,


*** for the PI Company and Vender
IT_ZCOMP_COV TYPE TABLE OF /BIC/MZCOMP_COV,
WA_ZCOMP_COV TYPE /BIC/MZCOMP_COV,
*** for Company On Live Time
IT_ZCOMP_COW TYPE TABLE OF /BIC/MZCOMP_COW,
WA_ZCOMP_COW TYPE /BIC/MZCOMP_COW,
*** for fetch pant
IT_ZPLANT TYPE TABLE OF /BIC/MZPLANT,
WA_ZPLANT TYPE /BIC/MZPLANT.

*$*$ end of global - insert your declaration only before this line *-*

METHODS
start_routine
IMPORTING
request type rsrequest
datapackid type rsdatapid
segid type rsbk_segid
EXPORTING
monitor type rstr_ty_t_monitors
CHANGING
SOURCE_PACKAGE type _ty_t_SC_1
RAISING
cx_rsrout_abort
cx_rsbk_errorcount.
METHODS
inverse_start_routine
IMPORTING
i_th_fields_outbound TYPE rstran_t_field_inv
I_R_SELSET_OUTBOUND TYPE REF TO CL_RSMDS_SET
i_is_main_selection TYPE rs_bool
i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
i_r_universe_inbound TYPE REF TO CL_RSMDS_UNIVERSE
CHANGING
c_th_fields_inbound TYPE rstran_t_field_inv
c_r_selset_inbound TYPE REF TO CL_RSMDS_SET
c_exact TYPE rs_bool.
ENDCLASS. "routine DEFINITION

*$*$ begin of 2nd part global - insert your code only below this line *

*$*$ end of 2nd part global - insert your code only before this line *

*---------------------------------------------------------------------*
* CLASS routine IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform IMPLEMENTATION.

*----------------------------------------------------------------------*
* Method start_routine
*----------------------------------------------------------------------*
* Calculation of source package via start routine
*----------------------------------------------------------------------*
* <-> source package
*----------------------------------------------------------------------*
METHOD start_routine.
*=== Segments ===

FIELD-SYMBOLS:
<SOURCE_FIELDS> TYPE _ty_s_SC_1.

DATA:
MONITOR_REC TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line *-*
... "insert your code here
*-- fill table "MONITOR" with values of structure "MONITOR_REC"
*- to make monitor entries
... "to cancel the update process
* raise exception type CX_RSROUT_ABORT.

*$*$ begin of routine - insert your code only below this line *-*
... "insert your code here
*-- fill table "MONITOR" with values of structure "MONITOR_REC"
*- to make monitor entries
... "to cancel the update process
* raise exception type CX_RSROUT_ABORT.

*** version 1.0 by luojianchao on 2014.1.10


*** ��
‫������ ˾�ݹ‬ʱ ��4 ȡ ������ǰ ����Ӧ t ��˾ ��G R/IR ����Ӧt ��˾ ȡ ZFI_AP_4 ��Doc ��Compan
y�ҵ�Vender��
*** �ǹ�Ӧt��˾ �ͷǼ��۵�REʱȡZFI_AP_4��Doc��Company�ҵ�Vender��
*** �ǹ�Ӧt��˾�ͼ��۵�REʱȡMaterial��Doc and item�ҵ�Vender,
*** �ǹ�Ӧt��˾�ͷǼ��۵�GRʱȡZLIS02HD��PO�ҵ�PI,
*** �ǹ�Ӧt��˾�ͼ��۵�GRʱȡZVEN_PORG��Vender�ҵ�PI

data: i_tabix type sy-tabix.

*** fetch the zpant


select * into table IT_ZPLANT FROM /BIC/MZPLANT where
/BIC/ZPLANT <> ''.
*** fetch the zcomp_cov
select * into table IT_ZCOMP_COV FROM /BIC/MZCOMP_COV where
/BIC/ZCOMP_COV <> ''.
*** fetch the zcomp_cow
select * into table IT_ZCOMP_COW FROM /BIC/MZCOMP_COW where
/BIC/ZCOMP_COW <> ''.

LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.


i_tabix = sy-tabix.
*** fetch PI company
"ȡ���Ƿ����߹�Ӧt�ж� hzg 2015-5-18
* read table IT_ZCOMP_COW into WA_ZCOMP_COW with key
* /BIC/ZCOMP_COW = <source_fields>-COMP_CODE.
*** for judge Company and On Live Time
"ȡ���Ƿ����߹�Ӧt�ж� hzg 2015-5-18
*if sy-subrc = 0 and
* <source_fields>-FISCPER >= WA_ZCOMP_COW-/BIC/ZFISCPER1.

*** for judge PI


read table IT_ZCOMP_COV into WA_ZCOMP_COV with key
/BIC/ZCOMP_COV = <source_fields>-COMP_CODE.

IF sy-subrc = 0.

if <source_fields>-vendor is INITIAL.
*** Fetch FI Doc and company for not consignment
wa_doc1-org_doc_no = <source_fields>-ac_doc_no.
wa_doc1-comp_code = <source_fields>-comp_code.
APPEND wa_doc1 TO it_doc1.
CLEAR wa_doc1.
wa_doc5-org_doc_yr = <source_fields>-org_doc_yr.
wa_doc5-org_doc_no = <source_fields>-org_doc_no.
APPEND wa_doc5 TO it_doc5.
CLEAR wa_doc5.

endif.

ELSE.
*** Fetch FI Doc and company for not consignment
if <source_fields>-vendor is INITIAL.
wa_doc1-org_doc_no = <source_fields>-ac_doc_no.
wa_doc1-comp_code = <source_fields>-comp_code.
APPEND wa_doc1 TO it_doc1.
CLEAR wa_doc1.

wa_doc5-org_doc_yr = <source_fields>-org_doc_yr.
wa_doc5-org_doc_no = <source_fields>-org_doc_no.
APPEND wa_doc5 TO it_doc5.
CLEAR wa_doc5.

*** fetch PO for not consignment


IF <source_fields>-/bic/ztcode <> 'MRKO'.
wa_doc2-org_doc_no = <source_fields>-DOC_NUM.
APPEND wa_doc2 TO it_doc2.
CLEAR wa_doc2.

ELSE.

*** fetch Material Doc and item for consignment


<source_fields>-org_doc_no = <source_fields>-/bic/zuonr+4(10).
<source_fields>-org_doc_yr = <source_fields>-/bic/zuonr+14(4).
CONCATENATE '00' <source_fields>-txtlg+17(4) INTO
<source_fields>-txtlg.

wa_doc3-org_doc_no = <source_fields>-/bic/zuonr+4(10).
wa_doc3-org_doc_yr = <source_fields>-/bic/zuonr+14(4).
wa_doc3-doc_item = <source_fields>-txtlg(6).
APPEND wa_doc3 TO it_doc3.
CLEAR wa_doc3.

ENDIF.

else.
*** fetch not consignment
IF <source_fields>-AC_DOC_TYP = 'WE' OR
<source_fields>-AC_DOC_TYP = 'WL' and <source_fields>-DOC_NUM
is not initial .

wa_doc2-org_doc_no = <source_fields>-DOC_NUM.
APPEND wa_doc2 TO it_doc2.
CLEAR wa_doc2.

*** fetch the consignment of vender


ELSEIF <source_fields>-AC_DOC_TYP = 'WA' or
<source_fields>-AC_DOC_TYP = 'WL' and
<source_fields>-DOC_NUM is initial.
wa_doc4-VENDOR = <source_fields>-vendor.
APPEND wa_doc4 TO it_doc4.
CLEAR wa_doc4.

*** for fetch the ZFIAPD08 of ZUONR


wa_doc6-/BIC/ZUONR = <source_fields>-/BIC/ZUONR.
wa_doc6-VENDOR = <source_fields>-vendor.
APPEND wa_doc6 TO it_doc6.
CLEAR wa_doc6.

ENDIF.

endif.

ENDIF.
"ȡ���Ƿ����߹�Ӧt�ж� hzg 2015-5-18
*else.
*
* delete SOURCE_PACKAGE index i_tabix.
*
*endif.

ENDLOOP.

SORT it_doc1 BY org_doc_no comp_code.


DELETE ADJACENT DUPLICATES FROM it_doc1 COMPARING ALL FIELDS.

SORT it_doc2 BY org_doc_no.


DELETE ADJACENT DUPLICATES FROM it_doc2 COMPARING ALL FIELDS.

SORT it_doc3 BY org_doc_no org_doc_yr doc_item.


DELETE ADJACENT DUPLICATES FROM it_doc3 COMPARING ALL FIELDS.

if it_doc1 IS NOT INITIAL.


CALL METHOD cl_rsd_odso=>get_tablnm
EXPORTING
i_odsobject = 'ZFI_AP_4'
IMPORTING
e_tablnm = tab_nam
EXCEPTIONS
name_error = 1
input_invalid = 2
OTHERS = 3.

*** for fetch ZFI_AP_4 CREDITOR


SELECT AC_DOC_NO
COMP_CODE
CREDITOR
INTO TABLE it_ap
FROM (tab_nam)
FOR ALL ENTRIES IN it_doc1
WHERE AC_DOC_NO = it_doc1-org_doc_no
AND COMP_CODE = it_doc1-comp_code
AND CREDITOR <> ''.
endif.

IF it_doc2 IS NOT INITIAL.


CALL METHOD cl_rsd_odso=>get_tablnm
EXPORTING
i_odsobject = 'ZLIS02HD'
IMPORTING
e_tablnm = tab_nam
EXCEPTIONS
name_error = 1
input_invalid = 2
OTHERS = 3.

*** for fetch ZLIS02HD PI


SELECT DOC_NUM
Vendor
INV_PARTY
INTO TABLE it_hd
FROM (tab_nam)
FOR ALL ENTRIES IN it_doc2
WHERE DOC_NUM = it_doc2-org_doc_no
AND FISCVARNT = 'K4'.
* AND INV_PARTY <> ''.
ENDIF.

IF it_doc3 IS NOT INITIAL.


CALL METHOD cl_rsd_odso=>get_tablnm
EXPORTING
i_odsobject = 'ZLIS03BF'
IMPORTING
e_tablnm = tab_nam
EXCEPTIONS
name_error = 1
input_invalid = 2
OTHERS = 3.

*** for fetch ZLIS03BF Vender


SELECT doc_num
doc_item
vendor
INTO TABLE it_bf
FROM (tab_nam)
FOR ALL ENTRIES IN it_doc3
WHERE fiscvarnt = 'K4'
AND doc_num = it_doc3-org_doc_no
AND doc_item = it_doc3-doc_item.
ENDIF.

IF it_doc4 IS NOT INITIAL.

*** for fetch ZVEN_PORG PI


SELECT /BIC/ZVEN_PORG
PURCH_ORG
INV_PARTY
INTO TABLE it_vp
FROM /BIC/MZVEN_PORG
FOR ALL ENTRIES IN it_doc4
WHERE /BIC/ZVEN_PORG = it_doc4-VENDOR AND
INV_PARTY <> ''.

ENDIF.
IF it_doc5 IS NOT INITIAL.

CALL METHOD cl_rsd_odso=>get_tablnm


EXPORTING
i_odsobject = 'ZLIS06IN'
IMPORTING
e_tablnm = tab_nam

EXCEPTIONS
name_error = 1
input_invalid = 2
OTHERS = 3
.
IF sy-subrc <> 0.
ENDIF.

*** for fetch ZLIS06IN Vendor


SELECT bbp_inv_id
fiscyear
inv_pty
INTO TABLE it_inv
FROM (tab_nam)
FOR ALL ENTRIES IN it_doc5
WHERE fiscyear = it_doc5-org_doc_yr
AND bbp_inv_id = it_doc5-org_doc_no.

endif.

IF it_doc6 IS NOT INITIAL.

sort it_doc6 by /BIC/ZUONR VENDOR.


delete adjacent duplicates from it_doc6 comparing /BIC/ZUONR VENDOR.

CALL METHOD cl_rsd_odso=>get_tablnm


EXPORTING
i_odsobject = 'ZFIAPD08'
IMPORTING
e_tablnm = tab_nam

EXCEPTIONS
name_error = 1
input_invalid = 2
OTHERS = 3
.
IF sy-subrc <> 0.
ENDIF.

*** for fetch the ZFIAPD08 of ZUONR


SELECT * INTO TABLE it_APD08 FROM (tab_nam)
FOR ALL ENTRIES IN it_doc6
WHERE /BIC/ZUONR = it_doc6-/BIC/ZUONR
and /BIC/ZVENDOR = it_doc6-VENDOR.

endif.

SORT it_inv BY bbp_inv_id fiscyear.


SORT it_bf BY doc_num doc_item.
SORT it_ap BY AC_DOC_NO COMP_CODE.
SORT it_hd BY DOC_NUM.
SORT it_vp BY /BIC/ZVEN_PORG PURCH_ORG.
SORT IT_ZPLANT BY /BIC/ZPLANT.
SORT it_APD08 by /BIC/ZUONR /BIC/ZVENDOR.

DELETE ADJACENT DUPLICATES FROM it_ap COMPARING


AC_DOC_NO COMP_CODE.
DELETE ADJACENT DUPLICATES FROM it_vp COMPARING
/BIC/ZVEN_PORG PURCH_ORG.
DELETE ADJACENT DUPLICATES FROM it_hd COMPARING
DOC_NUM.
DELETE ADJACENT DUPLICATES FROM it_inv COMPARING
bbp_inv_id fiscyear.
DELETE ADJACENT DUPLICATES FROM it_bf COMPARING
doc_num doc_item.

*$*$ end of routine - insert your code only before this line *-*
ENDMETHOD. "start_routine
*----------------------------------------------------------------------*
* Inverse method inverse_start_routine
*----------------------------------------------------------------------*
* This subroutine needs to be implemented only for direct access
* (for better performance) and for the Report/Report Interface
* (drill through).
* The inverse routine should transform a projection and
* a selection for the target to a projection and a selection
* for the source, respectively.
* If the implementation remains empty all fields are filled and
* all values are selected.
*----------------------------------------------------------------------*
* Customer comment:
*----------------------------------------------------------------------*
METHOD inverse_start_routine.

You might also like