sábado, 8 de enero de 2011

Antiguo codigo 2lis_02_acc

FORM routine_9998
TABLES DATA_PACKAGE TYPE _ty_t_SC_1_full
p_monitor STRUCTURE rsmonitor
p_monitor_recno STRUCTURE rsmonitors
CHANGING
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
LOOP AT DATA_PACKAGE.
IF NOT ( DATA_PACKAGE-PO_STATUS <> 'K'
* PO is not a replication from SRM System (in case of Extended Scenario
* PO is created in SRM and a copy of the PO is created in ERP with
* PO_STATUS = K)

AND ( DATA_PACKAGE-PROCESSKEY = '001' OR "Normal purchasing order
DATA_PACKAGE-PROCESSKEY = '011' OR Stock transport order
DATA_PACKAGE-PROCESSKEY = '021' OR Cross company order
* Only Purchase Orders

DATA_PACKAGE-PROCESSKEY = '004' OR " Normal scheduling agreement
DATA_PACKAGE-PROCESSKEY = '014' OR Stock transport agreement
DATA_PACKAGE-PROCESSKEY = '024') Cross company agreement -
* or Call Offs from schedule agreements

AND DATA_PACKAGE-BWAPPLNM EQ 'MM' ).
DELETE DATA_PACKAGE.
ENDIF.
ENDLOOP.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.


p_monitor[] = MONITOR[].
p_monitor_recno[] = MONITOR_RECNO[].
CLEAR: MONITOR[],
MONITOR_RECNO[].

ENDFORM. "routine_9998

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

* init variables

* generate a generic key for purchase category logical system and
* material group
PERFORM generic_objects_category_r3
TABLES MONITOR
USING COMM_STRUCTURE-gn_r3_ssy
COMM_STRUCTURE-gn_r3_ssy
COMM_STRUCTURE-matl_group
RECORD_NO
RECORD_ALL
SOURCE_SYSTEM
CHANGING RESULT
ABORT .


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

ENDFORM. "routine_0004

FORM routine_0001
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_52
CHANGING
RESULT TYPE _ty_s_TG_1_full-BBP_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

DATA: l_active_vendor LIKE RESULT.


l_hlp_chavl = COMM_STRUCTURE-vendor.
CALL FUNCTION 'RSAU_READ_MASTER_DATA'
EXPORTING
i_iobjnm = '0VENDOR'
i_chavl = l_hlp_chavl
i_attrnm = '0BPARTNER'
IMPORTING
e_attrval = l_active_vendor
EXCEPTIONS
read_error = 1
no_such_attribute = 2
wrong_import_parameters = 3
chavl_not_found = 4
OTHERS = 5.
CASE sy-subrc.
WHEN 1 OR 2 OR 3 OR 5.
* * Error during read --> Skip whole package

ABORT = 4.
* Copy error message into errorlog
MOVE-CORRESPONDING sy TO MONITOR.
APPEND MONITOR.
WHEN 0 OR 4.
* Vendor ID found successfull or not found
RESULT = l_active_vendor.

ABORT = 0.
ENDCASE.
sy-subrc = 0.


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

ENDFORM. "routine_0001

FORM routine_0003
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_53
CHANGING
RESULT TYPE _ty_s_TG_1_full-PRODUCT
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

PERFORM generic_object_product_r3
TABLES MONITOR
USING COMM_STRUCTURE-log_sys_be
COMM_STRUCTURE-material
RECORD_NO
RECORD_ALL
SOURCE_SYSTEM
CHANGING RESULT
ABORT.


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

ENDFORM. "routine_0003

FORM routine_0002
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_54
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

PERFORM generic_object_vendor_r3
TABLES MONITOR
USING COMM_STRUCTURE-log_sys
COMM_STRUCTURE-log_sys_be
COMM_STRUCTURE-vendor
RECORD_NO
RECORD_ALL
SOURCE_SYSTEM
CHANGING RESULT
ABORT.



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

ENDFORM. "routine_0002

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

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

METHOD compute_0GN_CAT_PUR.

* IMPORTING
* request type rsrequest
* datapackid type rsdatapid
* SOURCE_FIELDS-MATL_GROUP TYPE /BI0/OIMATL_GROUP
* SOURCE_FIELDS-GN_R3_SSY TYPE /BI0/OIGN_R3_SSY
* EXPORTING
* RESULT type _ty_s_TG_1-GN_CAT_PUR

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_51,
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_0004
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_0GN_CAT_PUR
*----------------------------------------------------------------------*
* Method invert_0GN_CAT_PUR
*----------------------------------------------------------------------*
*
* 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_0GN_CAT_PUR.

*$*$ 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_0GN_CAT_PUR
ENDCLASS. "routine IMPLEMENTATION

Antiguo Código de 2lis_03_bf

*&---------------------------------------------------------------------*
*& Form routine_9998
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->DATA_PACKAGE text
* -->P_MONITOR text
* -->P_MONITOR_RECNO text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_9998
TABLES DATA_PACKAGE TYPE _ty_t_SC_1_full
p_monitor STRUCTURE rsmonitor
p_monitor_recno STRUCTURE rsmonitors
CHANGING
ABORT LIKE sy-subrc
RAISING
cx_sy_arithmetic_error
cx_sy_conversion_error.

* init variables

* fill the internal table "MONITOR", to make monitor entries
* see OSS note 571669
LOOP AT DATA_PACKAGE.
IF DATA_PACKAGE-stockcat EQ 'V' OR
DATA_PACKAGE-stocktype EQ 'V'.
DELETE DATA_PACKAGE.
ENDIF.
ENDLOOP.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

p_monitor[] = MONITOR[].
p_monitor_recno[] = MONITOR_RECNO[].
CLEAR: MONITOR[],
MONITOR_RECNO[].

ENDFORM. "routine_9998

*&---------------------------------------------------------------------*
*& Form routine_0012
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0012
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_9
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSCNSSTCK
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 goods issue is considered
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issue from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* 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.
ELSE.
* if the returncode is not equal zero, the result will not be updated
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_0014
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0014
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_10
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 goods receipt is considered
IF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts
OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor
OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* 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.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0014

*&---------------------------------------------------------------------*
*& Form routine_0041
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0041
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_11
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_0041

*&---------------------------------------------------------------------*
*& Form routine_0010
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0010
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_12
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSVS_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 goods issue is considered
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issues from Stock Transfers
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cppvlc <> 0
* see OSS note 630254
AND ( 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 zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0010

*&---------------------------------------------------------------------*
*& Form routine_0011
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0011
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_13
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 goods receipt is considered
IF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts
OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor
OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer / Receipt
OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cppvlc <> 0
* see OSS note 630254
AND ( 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 zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
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_0038
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0038
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_15
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_0038

*&---------------------------------------------------------------------*
*& Form routine_0033
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0033
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_19
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSTOTSTCK
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 goods issue is considered
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issue from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0033

*&---------------------------------------------------------------------*
*& Form routine_0034
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0034
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_20
CHANGING
RESULT TYPE _ty_s_TG_1_full-RECTOTSTCK
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 goods receipt is considered
IF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts
OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor
OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer / Receipt
OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0034

*&---------------------------------------------------------------------*
*& Form routine_0035
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0035
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_21
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSVALSTCK
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 goods issue is considered
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issues from Stock Transfers
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
* additional check if orders on hand or projekt stock
* and if they are valuated (A or M)
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0
AND ( COMM_STRUCTURE-stockcat IS INITIAL OR
( COMM_STRUCTURE-stockcat CA 'EQ' AND
COMM_STRUCTURE-indspecstk CA 'AM' ) ).
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0035

*&---------------------------------------------------------------------*
*& Form routine_0036
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0036
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_22
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
* only goods receipt is considered
IF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts
OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor
OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer / Receipt
OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
* additional check if orders on hand or projekt stock
* and if they are valuated (A or M)
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0
AND ( COMM_STRUCTURE-stockcat IS INITIAL OR
( COMM_STRUCTURE-stockcat CA 'EQ' AND
COMM_STRUCTURE-indspecstk CA 'AM' ) ).
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0036

*&---------------------------------------------------------------------*
*& Form routine_0040
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0040
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_25
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_0040

*&---------------------------------------------------------------------*
*& Form routine_0037
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0037
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_31
CHANGING
RESULT TYPE _ty_s_TG_1_full-VENCONCON
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
* see OSS note 607710
* only goods issue is considered
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issues from Stock Transfers
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cppvlc <> 0
AND COMM_STRUCTURE-stockcat EQ 'K'.
* result value of the routine
RESULT = COMM_STRUCTURE-cppvlc.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0037

*&---------------------------------------------------------------------*
*& Form routine_0013
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0013
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_37
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSBLOSTCK
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 goods issue is considered
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issues from Stock Transfers
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only blocked stock is considered
AND COMM_STRUCTURE-stocktype EQ 'D'
AND COMM_STRUCTURE-stockcat NA 'KR'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.


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

ENDFORM. "routine_0013

*&---------------------------------------------------------------------*
*& Form routine_0017
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0017
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_38
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSQMSTCK
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 goods issue is considered
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issues from Stock Transfers
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only stock in qulality inspection is considered
AND COMM_STRUCTURE-stocktype CA 'BLOR'
AND COMM_STRUCTURE-stockcat NA 'KR'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.

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

ENDFORM. "routine_0017

*&---------------------------------------------------------------------*
*& Form routine_0023
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0023
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_39
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSTRANSST
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 goods issue is considered
IF ( COMM_STRUCTURE-processkey EQ '100' "Other Issues
OR COMM_STRUCTURE-processkey EQ '101' "Returns / Vendor
OR COMM_STRUCTURE-processkey EQ '104' "Material Transfer
OR COMM_STRUCTURE-processkey EQ '105' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '106' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '110' ) "Issues from Stock Transfers
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only stock in transit is considered
AND COMM_STRUCTURE-stocktype CA 'FH'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.

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

ENDFORM. "routine_0023

*&---------------------------------------------------------------------*
*& Form routine_0018
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0018
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_40
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 goods receipt is considered
IF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts
OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor
OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer / Receipt
OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only blocked stock is considered
AND COMM_STRUCTURE-stocktype EQ 'D'
AND COMM_STRUCTURE-stockcat NA 'KR'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0018

*&---------------------------------------------------------------------*
*& Form routine_0015
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0015
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_41
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 goods receipt is considered
IF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts
OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor
OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer / Receipt
OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD
OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other
OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only stock in qulality inspection is considered
AND COMM_STRUCTURE-stocktype CA 'BLOR'
AND COMM_STRUCTURE-stockcat NA 'KR'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.
* if abort is not equal zero, the update process will be canceled
ABORT = 0.

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

ENDFORM. "routine_0015

*&---------------------------------------------------------------------*
*& Form routine_0024
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0024
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_42
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 goods receipt is considered
IF ( COMM_STRUCTURE-processkey EQ '000' "Other Receipts
OR COMM_STRUCTURE-processkey EQ '001' "Goods Receipt / Vendor
OR COMM_STRUCTURE-processkey EQ '004' "Material Transfer / Receipt
OR COMM_STRUCTURE-processkey EQ '005' "Stock Adjustment InvD +
OR COMM_STRUCTURE-processkey EQ '006' "Stock Adjustment Other +
OR COMM_STRUCTURE-processkey EQ '010' ) "Receipt from Stock Transfer
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
* only stock in transit is considered
AND COMM_STRUCTURE-stocktype CA 'FH'
* only movements which are relevant for stock control
AND COMM_STRUCTURE-stockrelev EQ '1'
AND COMM_STRUCTURE-cpquabu <> 0.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu.
* if the returncode is zero, the result will be updated
RETURNCODE = 0.
ELSE.
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 4.
ENDIF.

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

ENDFORM. "routine_0024

*&---------------------------------------------------------------------*
*& Form routine_0029
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0029
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_43
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSSCRP
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
* goods issue posting into scrap
* only standard movement types are considered
* copied scrap movement types must be added in this routine
IF ( COMM_STRUCTURE-movetype EQ '551' "GI scrapping
OR COMM_STRUCTURE-movetype EQ '552' "GI scrapping
OR COMM_STRUCTURE-movetype EQ '553' "GI scrapping QI
OR COMM_STRUCTURE-movetype EQ '554' "GI scrapping QI
OR COMM_STRUCTURE-movetype EQ '555' "GI scrapping blocked
OR COMM_STRUCTURE-movetype EQ '556' ) "GI scrapping blocked
AND COMM_STRUCTURE-bwapplnm EQ 'MM'.
* result value of the routine
RESULT = COMM_STRUCTURE-cpquabu .
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
* if abort is not equal zero, the update process will be canceled
ELSE.
RETURNCODE = 4.
ENDIF.
ABORT = 0.

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

ENDFORM. "routine_0029

*&---------------------------------------------------------------------*
*& Form routine_0030
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_MONITOR text
* -->COMM_STRUCTURE text
* -->RESULT text
* -->RETURNCODE text
* -->ABORT text
* -->RAISING text
* -->CX_SY_ARITHMETIC_ERROR text
* -->CX_SY_CONVERSION_ERROR text
*----------------------------------------------------------------------*
FORM routine_0030
TABLES
p_monitor STRUCTURE rsmonitor
USING
COMM_STRUCTURE type _ty_s_SC_1__RULE_51
CHANGING
RESULT TYPE _ty_s_TG_1_full-ISSVALSCRP
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
* goods issue posting into scrap
* only standard movement types are considered
* copied scrap movement types must be added in this routine
IF ( COMM_STRUCTURE-movetype EQ '551' "GI scrapping
OR COMM_STRUCTURE-movetype EQ '552' "GI scrapping
OR COMM_STRUCTURE-movetype EQ '553' "GI scrapping QI
OR COMM_STRUCTURE-movetype EQ '554' "GI scrapping QI
OR COMM_STRUCTURE-movetype EQ '555' "GI scrapping blocked
OR COMM_STRUCTURE-movetype EQ '556' ) "GI scrapping blocked
AND COMM_STRUCTURE-bwapplnm EQ 'MM'
AND COMM_STRUCTURE-cppvlc <> 0 .
* result value of the routine
RESULT = COMM_STRUCTURE-cppvlc .
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
* if abort is not equal zero, the update process will be canceled
ELSE.
RETURNCODE = 4.
ENDIF.
ABORT = 0.

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

ENDFORM. "routine_0030

miércoles, 29 de diciembre de 2010

Transformation routines

1.- El clásico delete DELETE DATA_PACKAGE es ahora

DATA: l_tabix TYPE sy-tabix,
wa_source_package TYPE _ty_s_sc_1.

LOOP AT source_package
INTO wa_source_package.
l_tabix = sy-tabix.

IF ( wa_source_package-processkey NE '001' AND
wa_source_package-processkey NE '011' AND
wa_source_package-processkey NE '021' AND
wa_source_package-processkey NE '002' AND
wa_source_package-processkey NE '012' AND
wa_source_package-processkey NE '022' ) OR
wa_source_package-CPQUAOU EQ 0 OR
wa_source_package-numerator EQ 0 OR
wa_source_package-denomintr EQ 0.
DELETE
source_package
INDEX
l_tabix.

ENDIF.

ENDLOOP.
Ex: completar un dato en las subida
clear result.
select single /BIC/Z_GROUP
into result
from /BI0/PPROD_HIER
where PROD_HIER = SOURCE_FIELDS-PRDHA
and OBJVERS eq 'A'.




Ex.: 0COSTCENTER-->Cost center hierarchy

select single * from rshiedir into hier_wa where
objvers eq 'A' and
hietype eq '1' and
hienm eq hier_name and
dateto ge sy-datum .
if sy-subrc ne 0 .
raise invalid_hierarchy .
endif .

clear hier_detail .
move: hier_wa-hieid to hier_detail-hieid ,
hier_wa-objvers to hier_detail-objvers .


call function 'RSSH_HIERARCHY_READ'
exporting
i_rshiedirkey = hier_detail
* I_RSHIEDIRLOG =
i_date = sy-datum
importing
e_rshiedir = e_rshiedir
e_t_rsnodes = e_t_rsnodes
e_th_rsinterval = e_th_rsinterval
e_duplicate_leafs = e_duplicate_leafs
e_t_rsnodes_lnk = e_t_rsnodes_lnk
exceptions
invalid_hierarchy = 1
name_error = 2
iobj_not_found = 3
others = 4 .
case sy-subrc .

martes, 28 de diciembre de 2010

Atajo a SAP

Standard SAP GUI doesn’t allows to save password in the shortcuts. This can be achieved by doing these two steps.

1.) Executing sapshcut.exe which normally exists at C:\Program Files\SAP\FrontEnd\SAPgui.
Once this step is done then the variables which needs to be modified in REGEDIT are available for editing.

2.) Go to Command Prompt and type in REGEDIT -> HKEY_CURRENT_USER –> Software –> SAP –> SAPShortcut –> Security, Change the variable Enable Password from O to 1.

martes, 21 de diciembre de 2010

Obtener el año a partir de una fecha y restar 2 años

Coger la fecha de un prompt y restarle para conseguir en año n-2:

FormatNumber((Year(ToDate(UserResponse("Data fixada");""))-2);"####")

A partir del mes-año del prompt y restarle para conseguir en año n-2:

FormatNumber(ToNumber(Right(UserResponse("Mes analise (MMYYYY)");4))-2;"####")

Como extraer la clasificación del lote

Si sacaramos esto con código tendría que ser algo así:
* DATA:
* ld_tabix LIKE sy-tabix,
* v_matlot(28) TYPE c,
* v_atwrt LIKE ausp-atwrt,
* v_cuobj LIKE inob-cuobj,
* v_atinn LIKE cabn-atinn,
* v_clint LIKE klah-clint.

clear: v_atwrt, v_matlot, v_cuobj, v_atinn.
if not r_mc12vc0itm-charg is initial.
if not r_mc12vc0itm-matnr is initial.

CONCATENATE r_mc12vc0itm-matnr r_mc12vc0itm-charg INTO v_matlot.

SELECT SINGLE cuobj FROM inob INTO v_cuobj
WHERE klart = '023'
AND objek = v_matlot.

CALL FUNCTION 'CONVERSION_EXIT_ATINN_INPUT'
EXPORTING
input = 'CENTRO'
IMPORTING
output = v_atinn.

SELECT atwrt FROM ausp INTO v_atwrt UP TO 1 ROWS
WHERE objek = v_cuobj
AND atinn = v_atinn
AND klart = '023'
AND atzhl = 1.
ENDSELECT.

r_mc12vc0itm-zzwerks_fb = v_atwrt.
endif.
endif.


Se trata de evitar todo esto y sacar estos datos utilizando el standar:
Bases:
Datos del maestro del lote: MCH1.
Datos de clase maesro para el lote (023): CL03.

A diferencia del material, el lote no tiene el correspondiente extractor _ATTR.
Entonces:
Paso 1) crear un extractor de atributos para el lote en la RSO2, si se quiere derectamente sobre la tabla (MCH1 o MCHA) o se puede hacer una vista más personal
Paso 2) crear el extractor para la clasificación en la CTBW
Paso 3) crear el correspondiente infoobjeto en BW