Chinaunix首页 | 论坛 | 博客
  • 博客访问: 286455
  • 博文数量: 62
  • 博客积分: 2966
  • 博客等级: 少校
  • 技术积分: 615
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-07 23:16
个人简介

Be a simple man

文章分类

全部博文(62)

文章存档

2012年(6)

2011年(15)

2010年(6)

2009年(3)

2008年(5)

2007年(27)

我的朋友

分类:

2007-06-08 11:13:24

REPORT z_jason_test999 .
 
DATA: BEGIN OF intab OCCURS 0 ,
        f1 LIKE mseg-menge,
        f2(10) TYPE c,
        f3(10) TYPE c,
        f4 TYPE c,
      END OF intab.
 
DATA: dname(40) TYPE c VALUE '/usr/sap/BQD/DVEBMGS00/work/0002.txt'.
 
START-OF-SELECTION.

  intab-f1 = '-123.456'.
  intab-f2 = ''.
  intab-f3 = 'A3'.
  APPEND intab.
  intab-f1 = '3'.
  intab-f2 = 'B2'.
  intab-f3 = 'B3'.
  intab-f4 = 'A'.
  APPEND intab.

  PERFORM ftoline TABLES intab[]
                  USING  dname.

*&---------------------------------------------------------------------*
*&      Form  ftoline
*&---------------------------------------------------------------------*
FORM ftoline TABLES   p_intab
             USING    p_dname.
 
  DATA: BEGIN OF outtab OCCURS 0,
          line(1000) TYPE c,
        END OF outtab.
 
  DATA: tab TYPE x VALUE '09',
        enter(2) TYPE x VALUE '0D0A'.
 
  DATA: BEGIN OF headtab OCCURS 0,
          length    TYPE i,
          decimals  TYPE i,
          type_kind TYPE c,
          name(30)  TYPE c,
        END OF headtab.
 
  DATA: n TYPE i.
  DATA:  descr_ref TYPE REF TO cl_abap_structdescr.

  FIELD-SYMBOLS: TYPE abap_compdescr,
                 TYPE ANY,
                 TYPE ANY.
  DATA: str TYPE string,
        text1 TYPE c.
 
  descr_ref ?= cl_abap_typedescr=>describe_by_data( intab ).
  LOOP AT descr_ref->components ASSIGNING .
    MOVE-CORRESPONDING TO headtab.
    APPEND headtab.
  ENDLOOP.
 
  DESCRIBE TABLE headtab LINES n.
 
  LOOP AT p_intab ASSIGNING .
    DO n TIMES.
      ASSIGN COMPONENT sy-index OF STRUCTURE TO .
      str = .
      READ TABLE headtab INDEX sy-index.
      IF headtab-type_kind = 'I' OR headtab-type_kind = 'P'.
        SEARCH str FOR '-'.
        IF sy-subrc = 0 AND sy-fdpos <> 0.
          SPLIT str AT '-' INTO str text1.
          CONDENSE str.
          CONCATENATE '-' str INTO str.
        ELSE.
          CONDENSE str.
        ENDIF.
      ENDIF.
      CONCATENATE outtab tab str  INTO outtab.
    ENDDO.
    SHIFT outtab.
    APPEND outtab.
    CLEAR outtab.
  ENDLOOP.
 
  OPEN DATASET p_dname FOR OUTPUT IN BINARY MODE.
  IF sy-subrc NE 0.
    EXIT.
  ENDIF.
  LOOP AT outtab.
    str = outtab.
    TRANSFER str TO p_dname.
    TRANSFER enter TO p_dname.
  ENDLOOP.
  CLOSE DATASET p_dname.
 
ENDFORM.                    " ftoline
阅读(514) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~