Vous êtes sur la page 1sur 5

REPORT ZAARCGINTF303.

************************************************************************
* SYSTEM NAME : GROBAL INTERFACE/CONVERSION
* PROGRAM NAME : ZAARCGINTF303
* PROGRAM TYPE : DATA CHECK
* CREATE BY
: IBM (SATOMI KONDO)
* CREATE DATE : 2001/10/31
*----------------------------------------------------------------------*
* <DESCRIPTION>
* Asset Master Data Check
* This program is executed as a previous step of RAALTD01 (Asset
* Master Add/Change)
*----------------------------------------------------------------------*
* <UPDATE LOG>
* UPDATE BY
:
* UPDATE DATE :
* DESCRIPTION :
*
************************************************************************
*
*----------------------------------------------------------------------*
*
SPECIFIED DATABASE
*----------------------------------------------------------------------*
TABLES: t001,
"Company Codes
anka.
"Asset classes - general data
*
*----------------------------------------------------------------------*
*
DEFINE PARAMETERS
*----------------------------------------------------------------------*
PARAMETERS:
p_input(40) TYPE c LOWER CASE DEFAULT ' '
OBLIGATORY, "INPUT FILE NAME
p_error(40) TYPE c LOWER CASE DEFAULT ' '
OBLIGATORY. "ERROR FILE NAME
*
*----------------------------------------------------------------------*
*
INPUT FILE
*----------------------------------------------------------------------*
*
*--- ASSET MASTER&TRANS. FILE --*
DATA: BEGIN OF t_i0303 OCCURS 0,
mandt
LIKE zrcgi030err-mandt,
bukrs
LIKE zrcgi030err-bukrs,
anlkl
LIKE zrcgi030err-anlkl,
oldn1
LIKE zrcgi030err-oldn1,
oldn2
LIKE zrcgi030err-oldn2,
tcode
LIKE zrcgi030err-tcode,
rctyp
LIKE zrcgi030err-rctyp,
rec(4641) TYPE c,
END OF t_i0303.
*
*----------------------------------------------------------------------*
*
OUTPUT FILE
*----------------------------------------------------------------------*
*
*--- ERROR FILE ----------------*
DATA: t_error
LIKE zrcgi030err.
*
*----------------------------------------------------------------------*
*
CONSTANT DEFINITION
*----------------------------------------------------------------------*

*
*--- CONSTANT ------------------*
CONSTANTS: BEGIN OF cns,
err_field(12)
TYPE c VALUE 'ERROR FIELD:',
client(6)
TYPE c VALUE 'Client',
"FIELD NAME
company_code(11) TYPE c VALUE 'CompanyCode',
"FIELD NAME
asset_class(10) TYPE c VALUE 'AssetClass',
"FIELD NAME
trans_code(15) TYPE c VALUE 'TransactionCode', "FIELD NAME
record_type(10) TYPE c VALUE 'RecordType',
"FIELD NAME
as91(4)
TYPE c VALUE 'AS91',
"TRANSACTION CODE
as92(4)
type c value 'AS92',
"TRANSACTION CODE
as94(4)
TYPE c VALUE 'AS94',
"TRANSACTION CODE
a(1)
TYPE c VALUE 'A',
"RECORD TYPE
b(1)
TYPE c VALUE 'B',
"RECORD TYPE
END OF cns.
*
*----------------------------------------------------------------------*
*
COUNTER DEFINITION
*----------------------------------------------------------------------*
*
*--- COUNTERS ------------------*
DATA: BEGIN OF ctr,
input(08) TYPE p,
"INPUT DATA COUNTER
output(08) TYPE p,
"OUTPUT DATA COUNTER
normal(08) TYPE p,
"NORMAL DATA COUNTER
error(08) TYPE p,
"ERROR DATA COUNTER
END OF ctr.
*
*----------------------------------------------------------------------*
*
FLAG DEFINITION
*----------------------------------------------------------------------*
*
*--- FLAG ----------------------*
DATA: BEGIN OF flg,
err_rec
TYPE c,
"ERROR RECORD
END OF flg.
*
*----------------------------------------------------------------------*
*
OTHER WORK FIELDS
*----------------------------------------------------------------------*
*
*--- WORK FIELDS ---------------*
DATA: BEGIN OF wrk,
err_field LIKE zrcgc004err-errorf, "ERROR FIELD NAME
END OF wrk.
*
*----------------------------------------------------------------------*
*
INCLUDE
*----------------------------------------------------------------------*
INCLUDE zcmrcgincl001.
INCLUDE zcmrcgincl002.
*
************************************************************************
*
PROCESS CONTROL
************************************************************************
*
START-OF-SELECTION.
*

*--- INITIAL PROCESS -----------*


PERFORM init_rtn.

*
*

*--- MAIN PROCESS --------------*


PERFORM main_rtn.

END-OF-SELECTION.
*
*--- END PROCESS ---------------*
PERFORM end_rtn.
*
*----------------------------------------------------------------------*
*
(1.0) FORM:INIT_RTN
*----------------------------------------------------------------------*
*
COUNTER CLEAR AND PARAMETER CHECK AND FILE OPEN
*----------------------------------------------------------------------*
FORM init_rtn.
*
*--- PROGRAM START MESSAGE -----*
PERFORM program_start.
*
*
*--- CLEAR ---------------------*
CLEAR ctr.
CLEAR flg.
CLEAR wrk.
*
*
*--- PARAMETER CHECK -----------*
* IF p_input IS INITIAL. MESSAGE a997(zg) WITH 'P_INPUT'. ENDIF.
* IF p_error IS INITIAL. MESSAGE a997(zg) WITH 'P_OUTPUT'. ENDIF.
*
*
*--- INPUT FILE OPEN -----------*
PERFORM open_indata USING p_input 'INFILE'.
*
*
*--- ERROR FILE OPEN -----------*
PERFORM open_outdata USING p_error 'ERRFILE'.
*
ENDFORM.
*----------------------------------------------------------------------*
*
(2.0) FORM:MAIN_RTN
*----------------------------------------------------------------------*
*
READ FILE AND BATCH INPUT PROCESS
*----------------------------------------------------------------------*
FORM main_rtn.
*
*
*--- READ INPUT FILE -----------*
DO.
READ DATASET p_input INTO t_i0303.
*
IF sy-subrc <> 0.
EXIT.
ENDIF.
*
APPEND t_i0303.
ENDDO.
*
*
*--- CHECK DATA PROCESS --------*
LOOP AT t_i0303.
*
*--- CLEAR ----------------*
CLEAR: flg,
wrk.
*
*
*--- INPUT COUNTER 1UP ----*
ctr-input = ctr-input + 1.
*
*
*--- CHECK FIELD VALUE-----*
PERFORM check_data.
*
IF flg-err_rec = 'X'.

ctr-error = ctr-error + 1.
PERFORM error_file_rtn.
ELSE.
ctr-normal = ctr-normal + 1.
ENDIF.
*
ctr-output = ctr-output + 1.
*
ENDLOOP.
*
ENDFORM.
*----------------------------------------------------------------------*
*
(3.0) FORM:END_RTN
*----------------------------------------------------------------------*
*
PROGRAM END PROCESS
*----------------------------------------------------------------------*
FORM end_rtn.
*
*--- COUNT REPORT --------------*
PERFORM cnt_report USING 'INPUT RECORD COUNT : ' ctr-input.
PERFORM cnt_report USING 'OUTPUT RECORD COUNT : ' ctr-output.
PERFORM cnt_report USING 'NORMAL RECORD COUNT : ' ctr-normal.
PERFORM cnt_report USING 'ERROR RECORD COUNT : ' ctr-error.
*
*
*--- FILE CLOSE ----------------*
PERFORM close_dataset USING p_input 'INFILE'.
PERFORM close_dataset USING p_error 'ERRFILE'.
*
*
*--- PROGRAM END MESSAGE -------*
PERFORM program_end.
*
ENDFORM.
*----------------------------------------------------------------------*
*
FORM:ERROR_FILE_RTN
*----------------------------------------------------------------------*
*
WRITE ERROR FILE
*----------------------------------------------------------------------*
FORM error_file_rtn.
*
*--- EDIT ERROR FIELD ----------*
MOVE cns-err_field TO wrk-err_field(12).
CONDENSE wrk-err_field.
*
*--- OUTPUT ERROR FILE ---------*
MOVE-CORRESPONDING t_i0303 TO t_error.
MOVE wrk-err_field TO t_error-errorf.
TRANSFER t_error TO p_error.
*
ENDFORM.
*----------------------------------------------------------------------*
*
FORM:CHECK_DATA
*----------------------------------------------------------------------*
*
CHECK FIELD VALUE
*----------------------------------------------------------------------*
FORM check_data.
*
*--- CLIENT --------------------*
IF t_i0303-mandt <> sy-mandt.
MOVE cns-client TO wrk-err_field+13(6).
flg-err_rec = 'X'.
ENDIF.
*
*--- COMPANY CODE---------------*
IF t_i0303-bukrs IS INITIAL.
MOVE cns-company_code TO wrk-err_field+20(11).

flg-err_rec = 'X'.
ELSE.
SELECT SINGLE * FROM t001 WHERE bukrs = t_i0303-bukrs.
IF sy-subrc <> 0.
MOVE cns-company_code TO wrk-err_field+20(11).
flg-err_rec = 'X'.
ENDIF.
ENDIF.
*
*--- ASSET CLASS ---------------*
IF t_i0303-anlkl IS INITIAL.
MOVE cns-asset_class TO wrk-err_field+32(10).
flg-err_rec = 'X'.
ELSE.
SELECT SINGLE * FROM anka WHERE anlkl = t_i0303-anlkl.
IF sy-subrc <> 0.
MOVE cns-asset_class TO wrk-err_field+32(10).
flg-err_rec = 'X'.
ENDIF.
ENDIF.
*
*--- TRANSACTION CODE-----------*
IF t_i0303-tcode <> cns-as91 AND
t_i0303-tcode <> cns-as92 and
t_i0303-tcode <> cns-as94.
MOVE cns-trans_code TO wrk-err_field+43(15).
flg-err_rec = 'X'.
ENDIF.
*
*--- RECORD TYPE ---------------*
IF t_i0303-rctyp <> cns-a AND
t_i0303-rctyp <> cns-b.
MOVE cns-record_type TO wrk-err_field+59(10).
flg-err_rec = 'X'.
ENDIF.
*
ENDFORM.
************************************************************************