在服务器端创建文件(create a sequential file)

来源:互联网 发布:台湾中视源码 编辑:程序博客网 时间:2024/05/18 17:03

 tables: KNA1.
*TYPE-POOLS: Z100T.
TYPES: BEGIN OF Z100T_REC,
       cus_num like KNA1-KUNNR,
       name like KNA1-NAME1,
       s_term like KNA1-SORTL,
       city like KNA1-ORT01,
       pos_code like KNA1-PSTLZ,
       country type KNA1-SPRAS,
       Language type Kna1-spras,
end of Z100T_REC.
DATA: STRU TYPE standard table of Z100T_REC with header line.

selection-screen begin of block blk1 with frame title text-t01.
parameters:
       cu type KNA1-KUNNR obligatory,
       na type KNA1-NAME1 obligatory,
       s type KNA1-SORTL obligatory,
       ci type KNA1-ORT01 obligatory,
       po type KNA1-PSTLZ obligatory,
       co type KNA1-LAND1 obligatory,
       La type Kna1-spras OBLIGATORY default 'EN'.

selection-screen end of block blk1.



selection-screen begin of block blk2 with frame title text-t02.
parameters: p_fname TYPE STRING default 'ZFILE100_SF01.txt' obligatory.
selection-screen end of block blk2.

selection-screen begin of block blk3 with frame title text-t03.
parameters: add radiobutton group gr1,
            app radiobutton group gr1.
selection-screen end of block blk3.


start-of-selection.
DO 10 TIMES.
  stru-cus_num = cu.
  stru-name  = na.
  stru-s_term = s.
  stru-city = ci.
  stru-pos_code = po.
  stru-country = co.
  stru-language = la.
  append stru.
ENDDO.

  IF add 'X'.
    open dataset p_fname for output in text mode encoding default.
  LOOP AT stru.
    transfer stru to p_fname.
    IF SY-SUBRC NE 0.
      WRITE: / 'Error transferring record.'.
      stop.
    ENDIF.
  ENDLOOP.

  ENDIF.
IF add <> 'X'.
    open dataset p_fname for appending in text mode encoding default.
    transfer stru to p_fname.
    IF SY-SUBRC NE 0.
      WRITE: / 'Error transferring record.'.
    ENDIF.
ENDIF.
write: / 'Data transfer successful'.
end-of-selection.
close  dataset p_fname.

原创粉丝点击