我想在后台将所有bkpf的字段提取到制表符分隔文件中。 我们怎么做呢?
提前致谢 利亚
PS:执行exec_in_bckgr无法理解在SUBMIT中使用p_bckgr = space更改复选框的程序代码。
REPORT zfor_get_bkrf_bseg4.
TABLES: bkpf.
DATA: it_bkpf TYPE STANDARD TABLE OF bkpf,
ls_bkpf TYPE bkpf,
i_filename LIKE rlgrap-filename.
FIELD-SYMBOLS: <fs_field>.
SELECTION-SCREEN BEGIN OF BLOCK selection WITH FRAME TITLE text-s01.
SELECT-OPTIONS: so_bukrs FOR bkpf-bukrs,
so_budat FOR bkpf-budat OBLIGATORY.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN ULINE.
PARAMETERS: p_bkgrd AS CHECKBOX USER-COMMAND check DEFAULT 'X'.
" File Path on Application Server or on Local PC according to p_bkgrd
PARAMETERS: p_paths TYPE btcxpgpar DEFAULT '/tmp' MODIF ID sg1.
SELECTION-SCREEN END OF BLOCK selection.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_paths.
DATA: c_fnh_mask TYPE dxfields-filemask VALUE '*',
search_dir TYPE dxfields-longpath .
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = search_dir
filemask = c_fnh_mask
IMPORTING
serverfile = p_paths
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
START-OF-SELECTION.
IF p_bkgrd = 'X'.
PERFORM exec_in_bckgr.
ELSE.
PERFORM get_data.
PERFORM download_tables_paths.
ENDIF.
END-OF-SELECTION.
WRITE: i_filename , ' is created' .
FORM get_data .
SELECT * INTO TABLE it_bkpf
FROM bkpf
WHERE bukrs IN so_bukrs AND
budat IN so_budat.
ENDFORM. " GET_DATA
FORM download_tables_paths .
DATA:lv_line(4096) TYPE c,
lv_field_type(10) TYPE c,
lv_field_text(10) TYPE c.
" Build FineName
CONCATENATE p_paths '/' 'BKPF' sy-datum sy-uzeit '.txt'
INTO i_filename.
REPLACE ALL OCCURRENCES OF '//' IN i_filename WITH '/'.
* Process further only if found some data
IF NOT it_bkpf[] IS INITIAL.
" Open file for Output
OPEN DATASET i_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
LOOP AT it_bkpf INTO ls_bkpf.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE ls_bkpf TO <fs_field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF lv_line IS INITIAL.
lv_line = <fs_field>.
ELSE.
DESCRIBE FIELD <fs_field> TYPE lv_field_type.
IF lv_field_type = 'P' OR lv_field_type = 'I'.
lv_field_text = <fs_field>.
CONDENSE lv_field_text NO-GAPS.
CONCATENATE lv_line '|' lv_field_text INTO lv_line.
ELSE.
CONCATENATE lv_line '|' <fs_field> INTO lv_line.
ENDIF.
ENDIF.
ENDDO.
TRANSFER lv_line TO i_filename.
CLEAR: lv_line.
ENDLOOP.
ENDIF.
CLOSE DATASET i_filename.
ENDIF.
ENDFORM.
FORM exec_in_bckgr .
DATA: jobname1 TYPE tbtcjob-jobname,
jobcount1 TYPE tbtcjob-jobcount.
jobname1 = 'ZFOR_GET_BKRF_BSEG2'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = jobname1
IMPORTING
jobcount = jobcount1
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE s368(00) WITH 'Error Creating Job'
sy-subrc.
EXIT.
ENDIF.
SUBMIT zfor_get_bkrf_bseg2
WITH so_bukrs IN so_bukrs
WITH so_budat IN so_budat
WITH p_bckgr = space
WITH p_paths = p_paths
VIA JOB jobname1 NUMBER jobcount1
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = jobcount1
jobname = jobname1
* sdlstrtdt = sdate
* sdlstrttm = stime
* strtimmed = 'X' " Start immediately
EXCEPTIONS
invalid_startdate = 1
jobname_missing = 2
job_close_failed = 3
job_nosteps = 4
job_notex = 5
lock_failed = 6
OTHERS = 7.
IF sy-subrc > 0.
MESSAGE s368(00) WITH 'Closing Job Failed'
sy-subrc.
EXIT.
ENDIF.
ENDFORM.
该程序太简单了,我不明白为什么该网站要求我添加更多评论。 好吧,如果我在CALL FUNCTION'JOB_CLOSE'中启用 strtimmed ='X',那么程序会连续创建作业,我必须通过SM50杀死它。 如果我禁用STRTIMED,那么它会创建一个作为SCHEDULE的作业。我将它作为立即运行,它创建并运行一个作业而不创建文件,而在前台程序运行正常。
所以我的问题是:SAP ECC6的代码是否正常?
提前致谢 利亚
答案 0 :(得分:1)
以下代码可能是一个解决方案。 从10.000包中的BSEG中选择您的行,以csv格式将其传输到打开的文件中。
self.window.frame = [[UIScreen mainScreen] bounds]
答案 1 :(得分:0)
最后有人告诉我我的代码有什么问题。我在 WITH p_bckgr = space 中错过了 D 。 我认为如果错了,SAP会显示错误,但这是错误的想法。 所以正确的是 WITH p_bkgrd = space 。
全部谢谢