ABAP顾问
分类:
2010-06-08 17:33:27
REPORT z_barry_test NO STANDARD PAGE HEADING .
PERFORM delete_cycle USING 'C:\ksu1.txt'.
*&---------------------------------------------------------------------*
*& Form delete
*&---------------------------------------------------------------------*
FORM delete_cycle USING filename TYPE string.
DATA: uname LIKE sy-uname,
t811c TYPE t811c,
msgtxt(200) .
DATA: BEGIN OF itab OCCURS 0 ,
kokrs LIKE tka01-kokrs ,
cycle LIKE t811c-cycle ,
sdate LIKE t811c-sdate ,
END OF itab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = itab
EXCEPTIONS
OTHERS = 17.
SORT itab .
DELETE ADJACENT DUPLICATES FROM itab.
LOOP AT itab.
t811c-tab = 'CCSS'.
TRANSLATE itab TO UPPER CASE.
CONCATENATE itab-kokrs itab-cycle INTO t811c-cycle .
t811c-sdate = itab-sdate.
CALL FUNCTION 'ENQUEUE_EKGALC'
EXPORTING
tab = t811c-tab
cycle = t811c-cycle
sdate = t811c-sdate
EXCEPTIONS
foreign_lock = 2.
CASE sy-subrc.
WHEN 0.
WHEN 2.
IF sy-msgv1 = sy-uname.
MESSAGE s055(ga) WITH t811c-cycle t811c-sdate.
EXIT.
ELSE.
uname = sy-msgv1.
MESSAGE s051(ga) WITH uname t811c-cycle t811c-sdate.
EXIT.
ENDIF.
ENDCASE.
CALL FUNCTION 'RK_AL_CYCLE_DELETE'
EXPORTING
im_t811c = t811c
EXCEPTIONS
wrong_cycle = 8
has_postings = 4
no_authority = 12
error_change_doc = 16.
CASE sy-subrc.
WHEN 0.
MESSAGE s008(ga) WITH t811c-cycle t811c-sdate INTO msgtxt.
WRITE / msgtxt.
WHEN 4.
MESSAGE e007(ga) WITH t811c-cycle t811c-sdate sy-dbcnt.
WHEN 8.
MESSAGE a006(ga) WITH t811c-cycle t811c-sdate.
WHEN 12.
MESSAGE e176(ga) WITH t811c-cycle t811c-sdate.
WHEN 16.
MESSAGE e810(ga).
ENDCASE.
ENDLOOP.
ENDFORM. "delete