sábado, 8 de enero de 2011

Antiguo código de 2lis_03_bx

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: 0BASE_UOM Unidade de medida básica.
BASE_UOM TYPE /BI0/OIBASE_UOM,
* InfoObject: 0CPQUABU BW: quantidade em unidade de medida básica.
CPQUABU TYPE /BI0/OICPQUABU,
* InfoObject: 0INDSPECSTK Código avaliação estoque especial.
INDSPECSTK TYPE /BI0/OIINDSPECSTK,
* InfoObject: 0STOCKCAT Tipos de valor não-cumulativo.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* Field: RECORD.
RECORD TYPE RSARECORD,
END OF _ty_s_SC_1.
TYPES:
BEGIN OF _ty_s_TG_1,
* InfoObject: 0RECVALSTCK (7) Quantidade entrada no estoque avaliad
*o.
RECVALSTCK TYPE /BI0/OIRECVALSTCK,
END OF _ty_s_TG_1.

*$*$ begin of global - insert your declaration only below this line *-*
... "insert your code here
*$*$ end of global - insert your declaration only before this line *-*

METHODS
compute_0RECVALSTCK
IMPORTING
request type rsrequest
datapackid type rsdatapid
SOURCE_FIELDS type _ty_s_SC_1
EXPORTING
RESULT type _ty_s_TG_1-RECVALSTCK
monitor type rstr_ty_t_monitor
RAISING
cx_rsrout_abort
cx_rsrout_skip_record
cx_rsrout_skip_val.
METHODS
invert_0RECVALSTCK
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 *
*$*$ begin of version
*-- migration tool version 19.02.2009
*$*$ end of version
*$*$ end of rule type
TYPES:
BEGIN OF _ty_s_TG_1_full,
* InfoObject: 0CHNGID Änderungslauf ID.
CHNGID TYPE /BI0/OICHNGID,
* InfoObject: 0RECORDTP Satztyp.
RECORDTP TYPE /BI0/OIRECORDTP,
* InfoObject: 0REQUID Request ID.
REQUID TYPE /BI0/OIREQUID,
* InfoObject: 0CALDAY Kalendertag.
CALDAY TYPE /BI0/OICALDAY,
* InfoObject: 0CALMONTH Kalenderjahr / Monat.
CALMONTH TYPE /BI0/OICALMONTH,
* InfoObject: 0CALWEEK Kalenderjahr / Woche.
CALWEEK TYPE /BI0/OICALWEEK,
* InfoObject: 0CALYEAR Kalenderjahr.
CALYEAR TYPE /BI0/OICALYEAR,
* InfoObject: 0MATERIAL Material.
MATERIAL TYPE /BI0/OIMATERIAL,
* InfoObject: 0PLANT Werk.
PLANT TYPE /BI0/OIPLANT,
* InfoObject: 0STOR_LOC Lagerort.
STOR_LOC TYPE /BI0/OISTOR_LOC,
* InfoObject: 0BATCH Chargennummer.
BATCH TYPE /BI0/OIBATCH,
* InfoObject: 0STOCKTYPE Bestandsausprägung.
STOCKTYPE TYPE /BI0/OISTOCKTYPE,
* InfoObject: 0STOCKCAT Bestandstypen.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* InfoObject: 0GN_VENDOR Lieferant.
GN_VENDOR TYPE /BI0/OIGN_VENDOR,
* InfoObject: 0RECVS_VAL Zugangswert Bewerteter Bestand.
RECVS_VAL TYPE /BI0/OIRECVS_VAL,
* InfoObject: 0ISSVS_VAL Abgangswert Bewerteter Bestand.
ISSVS_VAL TYPE /BI0/OIISSVS_VAL,
* InfoObject: 0ISSBLOSTCK Abgangsmenge Gesperrter Bestand.
ISSBLOSTCK TYPE /BI0/OIISSBLOSTCK,
* InfoObject: 0ISSCNSSTCK Abgangsmenge Konsignationsbestand.
ISSCNSSTCK TYPE /BI0/OIISSCNSSTCK,
* InfoObject: 0ISSQMSTCK Abgangsmenge Qualitätsbestand.
ISSQMSTCK TYPE /BI0/OIISSQMSTCK,
* InfoObject: 0ISSTRANSST Abgangsmenge Transitbestand.
ISSTRANSST TYPE /BI0/OIISSTRANSST,
* InfoObject: 0RECBLOSTCK Zugangsmenge Gesperrter Bestand.
RECBLOSTCK TYPE /BI0/OIRECBLOSTCK,
* InfoObject: 0RECCNSSTCK Zugangsmenge Konsignationsbestand.
RECCNSSTCK TYPE /BI0/OIRECCNSSTCK,
* InfoObject: 0RECQMSTCK Zugangsmenge Qualitätsbestand.
RECQMSTCK TYPE /BI0/OIRECQMSTCK,
* InfoObject: 0RECTRANSST Zugangsmenge Transitbestand.
RECTRANSST TYPE /BI0/OIRECTRANSST,
* InfoObject: 0ISSSCRP Abgangsmenge Ausschuss.
ISSSCRP TYPE /BI0/OIISSSCRP,
* InfoObject: 0ISSVALSCRP Abgangswert Ausschuss.
ISSVALSCRP TYPE /BI0/OIISSVALSCRP,
* InfoObject: 0RECTOTSTCK Zugangsmenge Gesamt Bestand.
RECTOTSTCK TYPE /BI0/OIRECTOTSTCK,
* InfoObject: 0ISSTOTSTCK Abgangsmenge Gesamtbestand.
ISSTOTSTCK TYPE /BI0/OIISSTOTSTCK,
* InfoObject: 0ISSVALSTCK Abgangsmenge Bewerteter Bestand.
ISSVALSTCK TYPE /BI0/OIISSVALSTCK,
* InfoObject: 0RECVALSTCK Zugangsmenge Bewerteter Bestand.
RECVALSTCK TYPE /BI0/OIRECVALSTCK,
* InfoObject: 0VENCONCON Verbrauchswerte Lieferantenkonsignationsbe
*stand.
VENCONCON TYPE /BI0/OIVENCONCON,
* InfoObject: 0LOC_CURRCY Hauswährung.
LOC_CURRCY TYPE /BI0/OILOC_CURRCY,
* InfoObject: 0BASE_UOM Basismengeneinheit.
BASE_UOM TYPE /BI0/OIBASE_UOM,
* Field: RECORD Nummer des Datensatzes.
RECORD TYPE RSARECORD,
END OF _ty_s_TG_1_full.

TYPES:
BEGIN OF _ty_s_SC_1__RULE_9,
* InfoObject: 0CPQUABU BW: Menge in Basismengeneinheit.
CPQUABU TYPE /BI0/OICPQUABU,
* InfoObject: 0INDSPECSTK Kennzeichen Bewertung Sonderbestand.
INDSPECSTK TYPE /BI0/OIINDSPECSTK,
* InfoObject: 0STOCKCAT Bestandstypen.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* InfoObject: 0BASE_UOM Basismengeneinheit.
BASE_UOM TYPE /BI0/OIBASE_UOM,
END OF _ty_s_SC_1__RULE_9.

TYPES:
BEGIN OF _ty_s_SC_1__RULE_10,
* InfoObject: 0GN_R3_SSY Quellsystem der R/3 Entität.
GN_R3_SSY TYPE /BI0/OIGN_R3_SSY,
* InfoObject: 0STOCKCAT Bestandstypen.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* InfoObject: 0STOCKTYPE Bestandsausprägung.
STOCKTYPE TYPE /BI0/OISTOCKTYPE,
* InfoObject: 0VENDOR Lieferant.
VENDOR TYPE /BI0/OIVENDOR,
END OF _ty_s_SC_1__RULE_10.

TYPES:
BEGIN OF _ty_s_SC_1__RULE_11,
* InfoObject: 0CPQUABU BW: Menge in Basismengeneinheit.
CPQUABU TYPE /BI0/OICPQUABU,
* InfoObject: 0STOCKCAT Bestandstypen.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* InfoObject: 0STOCKTYPE Bestandsausprägung.
STOCKTYPE TYPE /BI0/OISTOCKTYPE,
* InfoObject: 0BASE_UOM Basismengeneinheit.
BASE_UOM TYPE /BI0/OIBASE_UOM,
END OF _ty_s_SC_1__RULE_11.

TYPES:
BEGIN OF _ty_s_SC_1__RULE_14,
* InfoObject: 0GN_R3_SSY Quellsystem der R/3 Entität.
GN_R3_SSY TYPE /BI0/OIGN_R3_SSY,
* InfoObject: 0STOCKCAT Bestandstypen.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* InfoObject: 0VENDOR Lieferant.
VENDOR TYPE /BI0/OIVENDOR,
END OF _ty_s_SC_1__RULE_14.

TYPES:
BEGIN OF _ty_s_SC_1__RULE_20,
* InfoObject: 0CPQUABU BW: Menge in Basismengeneinheit.
CPQUABU TYPE /BI0/OICPQUABU,
* InfoObject: 0STOCKCAT Bestandstypen.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* InfoObject: 0STOCKTYPE Bestandsausprägung.
STOCKTYPE TYPE /BI0/OISTOCKTYPE,
* InfoObject: 0BASE_UOM Basismengeneinheit.
BASE_UOM TYPE /BI0/OIBASE_UOM,
END OF _ty_s_SC_1__RULE_20.

TYPES:
BEGIN OF _ty_s_SC_1__RULE_21,
* InfoObject: 0CPQUABU BW: Menge in Basismengeneinheit.
CPQUABU TYPE /BI0/OICPQUABU,
* InfoObject: 0STOCKCAT Bestandstypen.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* InfoObject: 0STOCKTYPE Bestandsausprägung.
STOCKTYPE TYPE /BI0/OISTOCKTYPE,
* InfoObject: 0BASE_UOM Basismengeneinheit.
BASE_UOM TYPE /BI0/OIBASE_UOM,
END OF _ty_s_SC_1__RULE_21.

TYPES:
BEGIN OF _ty_s_SC_1__RULE_22,
* InfoObject: 0CPQUABU BW: Menge in Basismengeneinheit.
CPQUABU TYPE /BI0/OICPQUABU,
* InfoObject: 0STOCKTYPE Bestandsausprägung.
STOCKTYPE TYPE /BI0/OISTOCKTYPE,
* InfoObject: 0BASE_UOM Basismengeneinheit.
BASE_UOM TYPE /BI0/OIBASE_UOM,
END OF _ty_s_SC_1__RULE_22.

TYPES:
BEGIN OF _ty_s_SC_1__RULE_30,
* InfoObject: 0CPPVLC BW: Einkaufswert in Hauswährung.
CPPVLC TYPE /BI0/OICPPVLC,
* InfoObject: 0INDSPECSTK Kennzeichen Bewertung Sonderbestand.
INDSPECSTK TYPE /BI0/OIINDSPECSTK,
* InfoObject: 0STOCKCAT Bestandstypen.
STOCKCAT TYPE /BI0/OISTOCKCAT,
* InfoObject: 0LOC_CURRCY Hauswährung.
LOC_CURRCY TYPE /BI0/OILOC_CURRCY,
END OF _ty_s_SC_1__RULE_30.

* Additional declaration for update rule interface
DATA:
MONITOR type standard table of rsmonitor WITH HEADER LINE,
MONITOR_RECNO type standard table of rsmonitors WITH HEADER LINE,
RECORD_NO LIKE SY-TABIX,
RECORD_ALL LIKE SY-TABIX,
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS.


* global definitions from update rules
INCLUDE rsbctgn_top.
INCLUDE rsbctgn_update_rules.

FORM routine_0011
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_9
CHANGING
RESULT TYPE _ty_s_TG_1_full-RECVALSTCK
RETURNCODE LIKE sy-subrc
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* additional check if orders on hand or projekt stock
* and if they are valuated (A or M)
IF COMM_STRUCTURE-stockcat IS INITIAL OR
( COMM_STRUCTURE-stockcat CA 'EQ' AND
COMM_STRUCTURE-indspecstk CA 'AM' ).
* if the returncode is not equal zero, the result will not be updated
RESULT = COMM_STRUCTURE-cpquabu.
RETURNCODE = 0.
ELSE.
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

p_monitor[] = MONITOR[].
CLEAR MONITOR[].

ENDFORM. "routine_0011

FORM routine_0013
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_10
CHANGING
RESULT TYPE _ty_s_TG_1_full-GN_VENDOR
RETURNCODE LIKE sy-subrc
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* ... determine consolidated key
IF COMM_STRUCTURE-stockcat CA 'KQ' OR
COMM_STRUCTURE-stocktype CA 'QRS'.
PERFORM gn_get_global_key TABLES MONITOR
USING COMM_STRUCTURE-gn_r3_ssy
g_c_bwbeoty_r3vendor
COMM_STRUCTURE-vendor
RECORD_NO
RECORD_ALL
CHANGING RESULT
ABORT.
ENDIF.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.

p_monitor[] = MONITOR[].
CLEAR MONITOR[].

ENDFORM. "routine_0013

FORM routine_0003
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_11
CHANGING
RESULT TYPE _ty_s_TG_1_full-RECCNSSTCK
RETURNCODE LIKE sy-subrc
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* only consignment stock is considered
CASE COMM_STRUCTURE-stockcat.
WHEN 'K'.
RESULT = COMM_STRUCTURE-cpquabu.
RETURNCODE = 0.
WHEN space.
IF COMM_STRUCTURE-stocktype CA 'KLM'.
RESULT = COMM_STRUCTURE-cpquabu.
RETURNCODE = 0.
ELSE.
RETURNCODE = 4.
ENDIF.
WHEN OTHERS.
RETURNCODE = 4.
ENDCASE.
ABORT = 0.

p_monitor[] = MONITOR[].
CLEAR MONITOR[].

ENDFORM. "routine_0003

FORM routine_0014
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_14
CHANGING
RESULT TYPE _ty_s_TG_1_full-GN_VENDOR
RETURNCODE LIKE sy-subrc
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* ... determine consolidated key
IF COMM_STRUCTURE-stockcat EQ 'K'.
PERFORM gn_get_global_key TABLES MONITOR
USING COMM_STRUCTURE-gn_r3_ssy
g_c_bwbeoty_r3vendor
COMM_STRUCTURE-vendor
RECORD_NO
RECORD_ALL
CHANGING RESULT
ABORT.
* if the returncode is not equal zero, the result will not be updated
Endif.
RETURNCODE = 0.


p_monitor[] = MONITOR[].
CLEAR MONITOR[].

ENDFORM. "routine_0014

FORM routine_0002
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_20
CHANGING
RESULT TYPE _ty_s_TG_1_full-RECBLOSTCK
RETURNCODE LIKE sy-subrc
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* only blocked stock is considered
IF COMM_STRUCTURE-stocktype EQ 'D' AND
COMM_STRUCTURE-stockcat NA 'KR'.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
ELSE.
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

p_monitor[] = MONITOR[].
CLEAR MONITOR[].

ENDFORM. "routine_0002

FORM routine_0004
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_21
CHANGING
RESULT TYPE _ty_s_TG_1_full-RECQMSTCK
RETURNCODE LIKE sy-subrc
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* only stock in quality inspection is considered
IF COMM_STRUCTURE-stocktype CA 'BLOR' AND
COMM_STRUCTURE-stockcat NA 'KR'.
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
ELSE.
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

p_monitor[] = MONITOR[].
CLEAR MONITOR[].

ENDFORM. "routine_0004

FORM routine_0012
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_22
CHANGING
RESULT TYPE _ty_s_TG_1_full-RECTRANSST
RETURNCODE LIKE sy-subrc
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* only stock in transit is considered
IF COMM_STRUCTURE-stocktype CA 'FH'.
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
ELSE.
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

p_monitor[] = MONITOR[].
CLEAR MONITOR[].

ENDFORM. "routine_0012

FORM routine_0001
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_30
CHANGING
RESULT TYPE _ty_s_TG_1_full-RECVS_VAL
RETURNCODE LIKE sy-subrc
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* only valuated stock is considered
IF COMM_STRUCTURE-stockcat IS INITIAL OR
( COMM_STRUCTURE-stockcat CA 'EQ' AND
COMM_STRUCTURE-indspecstk CA 'AM' ).
* result value of the routine
RESULT = COMM_STRUCTURE-cppvlc.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
ELSE.
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

p_monitor[] = MONITOR[].
CLEAR MONITOR[].

ENDFORM. "routine_0001

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

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

METHOD compute_0RECVALSTCK.

* IMPORTING
* request type rsrequest
* datapackid type rsdatapid
* SOURCE_FIELDS-BASE_UOM TYPE /BI0/OIBASE_UOM
* SOURCE_FIELDS-CPQUABU TYPE /BI0/OICPQUABU
* SOURCE_FIELDS-INDSPECSTK TYPE /BI0/OIINDSPECSTK
* SOURCE_FIELDS-STOCKCAT TYPE /BI0/OISTOCKCAT
* EXPORTING
* RESULT type _ty_s_TG_1-RECVALSTCK

DATA:
MONITOR_REC TYPE rsmonitor.

*$*$ begin of routine - insert your code only below this line *-*
Data:
l_monitor TYPE STANDARD TABLE OF rsmonitor,
*--
COMM_STRUCTURE type _ty_s_SC_1__RULE_9,
l_subrc type sy-tabix,
l_abort type sy-tabix,
Ls_monitor type rsmonitor,
ls_monitor_recno type rsmonitors.

REFRESH:
MONITOR.

* Runtime attributs
SOURCE_SYSTEM = p_r_request->get_logsys( ).
MOVE-CORRESPONDING SOURCE_FIELDS to COMM_STRUCTURE.

* Migrated update rule call
Perform routine_0011
TABLES
l_monitor
USING
COMM_STRUCTURE
CHANGING
RESULT
l_subrc
l_abort.

*-- Convert Messages in Transformation format
LOOP AT l_monitor INTO ls_monitor.
move-CORRESPONDING ls_monitor to MONITOR_REC.
append monitor_rec to MONITOR.
ENDLOOP.
IF l_subrc <> 0.
RAISE EXCEPTION TYPE cx_rsrout_skip_val.
ENDIF.
IF l_abort <> 0.
RAISE EXCEPTION TYPE CX_RSROUT_ABORT.
ENDIF.

*$*$ end of routine - insert your code only before this line *-*
ENDMETHOD. "compute_0RECVALSTCK
*----------------------------------------------------------------------*
* Method invert_0RECVALSTCK
*----------------------------------------------------------------------*
*
* 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.
*
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
METHOD invert_0RECVALSTCK.

*$*$ begin of inverse routine - insert your code only below this line*-*
... "insert your code here
*$*$ end of inverse routine - insert your code only before this line *-*

ENDMETHOD. "invert_0RECVALSTCK
ENDCLASS. "routine IMPLEMENTATION

No hay comentarios: