1、BDC不好使,网上找到 CALL CALL TRANSACTION 代码,修改,批量重读PP主数据
- *&---------------------------------------------------------------------*
- *& Report ZPPPR_RESETPPDATA
- *&
- *&---------------------------------------------------------------------*
- *&
- *&
- *&---------------------------------------------------------------------*
- REPORT zpppr_resetppdata.
- INCLUDE zco02.
- DATA:
- ls_bdc LIKE bdcdata,
- lt_bdc LIKE STANDARD TABLE OF bdcdata.
- DATA:
- w_dis_mode TYPE char1 VALUE 'E',
- w_upd_mode TYPE char1 VALUE 'S',
- w_session LIKE apqi-groupid VALUE 'SESSION1-54' .
- DATA:BEGIN OF gt_list OCCURS 0 ,
- aufnr LIKE caufvd-aufnr,
- plauf LIKE rc62f-plauf,
- aufld LIKE rc62f-aufld ,
- END OF gt_list.
- SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLE text-002.
- PARAMETERS:txtfile LIKE rlgrap-filename DEFAULT 'D:\RESET_PP_DATA.TXT'.
- SELECTION-SCREEN END OF BLOCK bl2.
- AT SELECTION-SCREEN ON VALUE-REQUEST FOR txtfile.
- PERFORM filename_find.
- START-OF-SELECTION.
- PERFORM sub_uploaddata_header.
- PERFORM fill_bdc_tab.
- * PERFORM set_ppdata.
- * PERFORM set_ppdata2.
- * WRITE 'OK'.
- *&---------------------------------------------------------------------*
- *& Form filename_find
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- * --> p1 text
- * <-- p2 text
- *----------------------------------------------------------------------*
- FORM filename_find .
- CALL FUNCTION 'WS_FILENAME_GET'
- EXPORTING
- def_filename = txtfile
- def_path = 'D:\'
- mask = 'C*.TXT'
- mode = 'O'
- title = 'File Name'
- IMPORTING
- filename = txtfile
- EXCEPTIONS
- inv_winsys = 1
- no_batch = 2
- selection_cancel = 3
- selection_error = 4
- OTHERS = 5.
- ENDFORM. " filename_find
- *&---------------------------------------------------------------------*
- *& Form sub_uploaddata_header
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- * --> p1 text
- * <-- p2 text
- *----------------------------------------------------------------------*
- FORM sub_uploaddata_header .
- CALL FUNCTION 'WS_UPLOAD'
- EXPORTING
- filename = txtfile
- filetype = 'DAT'
- TABLES
- data_tab = gt_list
- EXCEPTIONS
- conversion_error = 1
- file_open_error = 2
- file_read_error = 3
- invalid_type = 4
- no_batch = 5
- unknown_error = 6
- invalid_table_width = 7
- gui_refuse_filetransfer = 8
- customer_error = 9
- OTHERS = 10.
- ENDFORM. " sub_uploaddata_header
- *&---------------------------------------------------------------------*
- *& Form set_ppdata
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- * --> p1 text
- * <-- p2 text
- *----------------------------------------------------------------------*
- FORM set_ppdata .
- LOOP AT gt_list.
- PERFORM bdc_dynpro USING 'SAPLCOKO1' '1010'.
- PERFORM bdc_field USING 'BDC_CURSOR' 'CAUFVD-AUFNR'.
- PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
- PERFORM bdc_field USING 'RC27M-MATNR' gt_list-aufnr.
- PERFORM bdc_field USING 'R62CLORD-FLG_OVIEW' 'X'.
- PERFORM bdc_dynpro USING 'SAPLCOKO1' '0115'.
- PERFORM bdc_field USING 'BDC_OKCODE' '=STAK'.
- PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPLCOKO1 0120SUBSCR_0115'.
- PERFORM bdc_dynpro USING 'SAPLCOKO1' '0131'.
- PERFORM bdc_field USING 'BDC_OKCODE' '=ENT1'.
- PERFORM bdc_field USING 'BDC_CURSOR' 'RC62F-PLAUF'.
- PERFORM bdc_field USING 'RC62F-NEW_ROUT' 'X'.
- PERFORM bdc_field USING 'RC62F-PLAUF' gt_list-plauf.
- PERFORM bdc_field USING 'RC62F-NEW_BOM' 'X'.
- PERFORM bdc_field USING 'RC62F-AUFLD' gt_list-aufld.
- PERFORM bdc_dynpro USING 'SAPLCOKO1' '0115'.
- PERFORM bdc_field USING 'BDC_OKCODE' '=FREI'.
- PERFORM bdc_dynpro USING 'SAPLCOKO1' '0115'.
- PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.
- PERFORM bdc_transaction USING 'CO02'.
- ENDLOOP.
- ENDFORM. " set_ppdata
- *&---------------------------------------------------------------------*
- *& Form open_group
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- * --> p1 text
- * <-- p2 text
- *----------------------------------------------------------------------*
- *&---------------------------------------------------------------------*
- *& Form set_ppdata2
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- * --> p1 text
- * <-- p2 text
- *----------------------------------------------------------------------*
- FORM set_ppdata2 .
- ENDFORM. " set_ppdata2
- *&---------------------------------------------------------------------*
- *& Form fill_bdc_tab
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- FORM fill_bdc_tab .
- LOOP AT gt_list.
- REFRESH:lt_bdc.
- PERFORM populate_bdc_tab USING:
- '1' 'SAPLCOKO1' '0110',
- '' 'BDC_CURSOR' 'CAUFVD-AUFNR',
- '' 'BDC_OKCODE' '/00',
- '' 'CAUFVD-AUFNR' gt_list-aufnr," '10302095',
- '' 'R62CLORD-FLG_OVIEW' 'X',
- '1' 'SAPLCOKO1' '0115',
- '' 'BDC_OKCODE' '=STAK',
- '' 'BDC_SUBSCR' 'SAPLCOKO1 0120SUBSCR_0115',
- '1' 'SAPLCOKO1' '0131',
- '' 'BDC_OKCODE' '=ENT1',
- '' 'BDC_CURSOR' 'RC62F-PLAUF',
- '' 'RC62F-NEW_ROUT' 'X',
- '' 'RC62F-PLAUF' gt_list-plauf,"'2012.03.26',
- '' 'RC62F-NEW_BOM' 'X',
- '' 'RC62F-AUFLD' gt_list-aufld,"'2012.03.26',
- '1' 'SAPLCOKO1' '0115',
- '' 'BDC_OKCODE' '=FREI',
- '' 'BDC_SUBSCR' 'SAPLCOKO1 0120SUBSCR_0115',
- '' 'BDC_CURSOR' 'CAUFVD-GAMNG',
- '1' 'SAPLCOKO1' '0115',
- '' 'BDC_OKCODE' '=BU',
- '' 'BDC_SUBSCR' 'SAPLCOKO1 0120SUBSCR_0115',
- '' 'BDC_CURSOR' 'CAUFVD-GAMNG'.
- CALL TRANSACTION 'CO02'
- USING lt_bdc
- MODE w_dis_mode
- UPDATE w_upd_mode.
- ENDLOOP.
- ENDFORM. "fill_bdc_tab
- *&---------------------------------------------------------------------*
- *& Form populate_bdc_tab
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- * -->FLAG text
- * -->VAR1 text
- * -->VAR2 text
- *----------------------------------------------------------------------*
- FORM populate_bdc_tab USING flag TYPE char1
- var1 TYPE any
- var2 TYPE any.
- CLEAR ls_bdc.
- IF flag = '1'.
- ls_bdc-program = var1.
- ls_bdc-dynpro = var2.
- ls_bdc-dynbegin = 'X'.
- ELSE.
- ls_bdc-fnam = var1.
- ls_bdc-fval = var2.
- ENDIF.
- APPEND ls_bdc TO lt_bdc.
- ENDFORM. "populate_bdc_tab
阅读(3433) | 评论(0) | 转发(0) |