*&---------------------------------------------------------------------*
*& Report ZCRM_SALE_UPLOAD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZCRM_SALE_UPLOAD.
TYPE-POOLS : slis.
DATA: gs_layout TYPE slis_layout_alv.
DATA: gs_variant LIKE disvariant.
DATA: g_repid LIKE sy-repid.
DATA: lt_excle_in TYPE zalsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA: ls_excle_in LIKE LINE OF lt_excle_in.
DATA: lc_fieldvalue TYPE fieldvalue, "字符值
lc_fldname TYPE fieldname. "字段名
FIELD-SYMBOLS: .
DATA lt_data LIKE ZTA_SALE_LOG OCCURS 0 WITH HEADER LINE .
DATA ls_data TYPE ZTA_SALE_LOG .
DATA ls_upload TYPE ZSA_URBAN_UPLOAD .
DATA ls_create TYPE zsa_sale_upload .
DATA ls_adr2 TYPE adr2 .
DATA ls_taxnum TYPE dfkkbptaxnum .
DATA lv_message(100) TYPE c .
DATA OBJECT_ID TYPE CRMT_OBJECT_ID.
*****************************************************************************
* selection screen
SELECTION-SCREEN BEGIN OF BLOCK so_document WITH FRAME TITLE iit.
PARAMETERS rb_b RADIOBUTTON GROUP rbg1 DEFAULT 'X'.
PARAMETERS rb_u RADIOBUTTON GROUP rbg1 .
PARAMETERS: p_file LIKE rlgrap-filename.
PARAMETERS rb_d RADIOBUTTON GROUP rbg1 .
SELECTION-SCREEN END OF BLOCK so_document.
INITIALIZATION.
iit = '商机模版上传'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
mask = ' '"',*.*,*.xls.'
mode = 'O'
title = text-t01
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0 AND sy-subrc <> 3.
MESSAGE '请选择目标文件' TYPE 'E' .
ENDIF.
START-OF-SELECTION.
IF rb_u = 'X'.
* get data as intertable from EXCEL file
REFRESH lt_excle_in .
CALL FUNCTION 'ZALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = '1'
i_begin_row = '2'
i_end_col = '52'
i_end_row = '50000'
TABLES
intern = lt_excle_in
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF lt_excle_in[] IS INITIAL .
EXIT .
ENDIF .
* data exchange
LOOP AT lt_excle_in INTO ls_excle_in.
AT NEW row.
CLEAR: ls_data ,ls_upload.
ENDAT.
lc_fieldvalue = ls_excle_in-value.
CONDENSE lc_fieldvalue.
ASSIGN COMPONENT ls_excle_in-col OF STRUCTURE ls_upload TO .
IF sy-subrc = 0.
= lc_fieldvalue.
ENDIF.
AT END OF row.
MOVE-CORRESPONDING ls_upload TO ls_data .
APPEND ls_data TO lt_data. CLEAR: ls_data ,ls_upload.
ENDAT.
ENDLOOP.
LOOP AT lt_data INTO ls_data.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = ls_data-guid.
ls_data-sign = 'I' .
*
*
* IF ls_data-ship_to_name IS INITIAL.
* ls_data-sign = 'E' .
* CONCATENATE ls_data-error_txt '客户名称为空,请输入' INTO ls_data-error_txt SEPARATED BY ';' .
* ENDIF.
*
* IF ls_data-contact_name IS NOT INITIAL AND ls_data-department IS NOT INITIAL.
* SELECT SINGLE abtnr INTO ls_data-abtnr
* FROM tb911
* WHERE bez20 = ls_data-department .
* IF ls_data-abtnr IS INITIAL.
* ls_data-sign = 'E' .
* CONCATENATE ls_data-error_txt '负责产品输入错误,请检查' INTO ls_data-error_txt SEPARATED BY ';' .
* ENDIF.
* ENDIF.
*
* CONDENSE ls_data-error_txt .
* SHIFT ls_data-error_txt LEFT DELETING LEADING ';' .
MODIFY lt_data FROM ls_data . CLEAR ls_data .
ENDLOOP .
ELSEIF rb_b = 'X' .
REFRESH lt_data .CLEAR ls_data .
SELECT * INTO TABLE lt_data
FROM zta_sale_log
WHERE sign = 'I' .
LOOP AT lt_data INTO ls_data.
* CLEAR ls_create .
MOVE-CORRESPONDING ls_data TO ls_create .
CLEAR OBJECT_ID.
call function 'ZFM_SALE_UPLOAD' "生成订单
exporting
iv_sale = ls_create
iv_type = 'ZA07'
IMPORTING
E_OBJECT_ID = OBJECT_ID
* E_ERROR =
* E_MESSAGE =
.
LS_DATA-CREATE_DATE = SY-DATUM.
LS_DATA-CREATE_TIME = SY-UZEIT.
IF OBJECT_ID IS NOT INITIAL.
ls_data-sign = 'S'.
LS_DATA-OBJECT_ID = OBJECT_ID.
ELSE .
ls_data-sign = 'E'.
ENDIF.
MODIFY lt_data FROM ls_data . CLEAR ls_data .
ENDLOOP.
ELSEIF rb_d = 'X' .
DELETE FROM zta_sale_log WHERE sign = 'I' .
COMMIT WORK .
ENDIF.
IF lt_data[] IS NOT INITIAL.
MODIFY zta_SALE_log FROM TABLE lt_data .
COMMIT WORK .
ENDIF.
END-OF-SELECTION.
gs_layout-zebra = 'X'.
gs_layout-colwidth_optimize = 'X'.
g_repid = sy-repid.
gs_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_structure_name = 'ZTA_SALE_LOG'
is_layout = gs_layout
TABLES
t_outtab = lt_data[].
阅读(854) | 评论(0) | 转发(0) |