ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ABAP data extract demo (T352B)(转帖)

ABAP data extract demo (T352B)(转帖)

原创 Linux操作系统 作者:haojin_99 时间:2009-07-14 11:12:53 0 删除 编辑

*-------------------------------------------------------------------*
* Report Name: ZBI_T352B
* Generated At: Monday, February 23, 2009 16:25:00
*-------------------------------------------------------------------*


REPORT ZBI_T352B.


* Step 1. Declare Table
TABLES:
T352B.


* Step 2. Declare Internal table
DATA:  BEGIN OF IT_T352B OCCURS 0.
INCLUDE STRUCTURE T352B.
DATA:  END OF IT_T352B.


* Step 3. Declare Structure
DATA:  BEGIN OF ST_1 OCCURS 1,
F_1(9)  TYPE C, " For T352B-RBNR
F_2(8)  TYPE C, " For T352B-FEGRP
F_3(8)  TYPE C, " For T352B-URGRP
F_4(8)  TYPE C, " For T352B-MAGRP
F_5(8)  TYPE C, " For T352B-MFGRP
F_6(8)  TYPE C, " For T352B-OTGRP
F_7(18) TYPE C, " For T352B-FRKLS
F_8(1)  TYPE C, " For T352B-FRKLSKZ
F_9(2)  TYPE C, " For T352B-QMTYP
F_10(3) TYPE C, " For T352B-UNITFLBEW
F_11(3) TYPE C, " For T352B-DECIMALS
F_12(1) TYPE C, " For T352B-MSGTP
END OF ST_1.

DATA:  IT_1 LIKE ST_1 OCCURS 0 WITH HEADER LINE.

DATA: W_EXTRACT_CNT  TYPE I.

CLEAR IT_1.
REFRESH IT_1.
CLEAR IT_T352B.
REFRESH IT_T352B.

INCLUDE ZAOO4000.
INCLUDE ZAOO4001.

OPEN DATASET DSN FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC <> 0.
WRITE:/ 'Unable to open dataset:',DSN.
EXIT.
ENDIF.

SELECT
RBNR
FEGRP
URGRP
MAGRP
MFGRP
OTGRP
FRKLS
FRKLSKZ
QMTYP
UNITFLBEW
DECIMALS
MSGTP
INTO (IT_T352B-RBNR,
IT_T352B-FEGRP,
IT_T352B-URGRP,
IT_T352B-MAGRP,
IT_T352B-MFGRP,
IT_T352B-OTGRP,
IT_T352B-FRKLS,
IT_T352B-FRKLSKZ,
IT_T352B-QMTYP,
IT_T352B-UNITFLBEW,
IT_T352B-DECIMALS,
IT_T352B-MSGTP
)
FROM T352B.

IT_1-F_1 = IT_T352B-RBNR.
IT_1-F_2 = IT_T352B-FEGRP.
IT_1-F_3 = IT_T352B-URGRP.
IT_1-F_4 = IT_T352B-MAGRP.
IT_1-F_5 = IT_T352B-MFGRP.
IT_1-F_6 = IT_T352B-OTGRP.
IT_1-F_7 = IT_T352B-FRKLS.
IT_1-F_8 = IT_T352B-FRKLSKZ.
IT_1-F_9 = IT_T352B-QMTYP.
IT_1-F_10 = IT_T352B-UNITFLBEW.
IT_1-F_11 = IT_T352B-DECIMALS.
IT_1-F_12 = IT_T352B-MSGTP.

TRANSFER IT_1 TO DSN LENGTH 77.
ADD 1 TO W_EXTRACT_CNT.
ENDSELECT.

WRITE : / 'Extract count to file: ', W_EXTRACT_CNT.

* CLOSE DSN dataset.
CLOSE DATASET DSN.

INCLUDE ZAOO4002.

 


*______________________________________________________________________*
* Include ZAOO4000                                                     *
*                                                Creation: 09-09-2000  *
*                                                                      *
* SAP Name    : $PROG                            Version:              *
*                                                                      *
* Programmer  : Chris Milstead                   Last Update:          *
*                                                                      *
*______________________________________________________________________*
* Description :  Data fields definition for generic dynamic file       *
*                assignment for Data Stage Extraction tool             *
*______________________________________________________________________*

* Change History:                                                      *
*     Programmer        Date    Req. #            Action               *
* ==================  ========  ======  ===============================*
* cjm3                09/11/00          Create                         *
*______________________________________________________________________*

DATA: DSN   LIKE RLGRAP-FILENAME.
DATA: V_PARAM(255) TYPE C.


*______________________________________________________________________*
* Include ZAOO4000                                                     *
*                                                Creation: 09-09-2000  *
*                                                                      *
* SAP Name    : $PROG                            Version:              *
*                                                                      *
* Programmer  : Chris Milstead                   Last Update:          *
*                                                                      *
*______________________________________________________________________*
* Description :  Perform. file name assignment for dynamic file         *
*                for Data Stage Extraction tool                        *
*______________________________________________________________________*

* Change History:                                                      *
*     Programmer        Date    Req. #            Action               *
* ==================  ========  ======  ===============================*
* cjm3                09/11/00          Create                         *
* jzhou               05/14/08          Modified V_PARAM logic to allow*
*                                       longer names than 12 characters*
*______________________________________________________________________*

MOVE SY-REPID+0(36) TO V_PARAM.         "V01.01
MOVE '.dat'         TO V_PARAM+36(4).   "V01.01
condense V_PARAM no-gaps.               "V01.01

*MOVE SY-REPID      TO V_PARAM.
*MOVE '.dat'        TO V_PARAM+8(4).
PERFORM. RETRIEVE_FILE_NAME USING DSN.

 


*______________________________________________________________________*
* Include ZAOO4000                                                     *
*                                                Creation: 09-09-2000  *
*                                                                      *
* SAP Name    : $PROG                            Version:              *
*                                                                      *
* Programmer  : Chris Milstead                   Last Update:          *
*                                                                      *
*______________________________________________________________________*
* Description :  Perform. file name assignment for dynamic file         *
*                for Data Stage Extraction tool                        *
*______________________________________________________________________*

* Change History:                                                      *
*     Programmer        Date    Req. #            Action               *
* ==================  ========  ======  ===============================*
* cjm3                09/11/00          Create                         *
*______________________________________________________________________*

*---------------------------------------------------------------------*
*       FORM. RETRIEVE_FILE_NAME                                       *
*---------------------------------------------------------------------*
* Get the physical file name by using the logical file name.  A       *
* variable is passed into the FORM. which will contain the physical    *
* file name after the function call.                                  *
*---------------------------------------------------------------------*
*  -->  LV_FILENAME                                                   *
*---------------------------------------------------------------------*
FORM. RETRIEVE_FILE_NAME USING DSN LIKE RLGRAP-FILENAME.
*** Call function to read the file name using logical filename.  The
*** physical file name is returned by the function into lv_filename.
  CALL FUNCTION 'FILE_GET_NAME'
       EXPORTING
            LOGICAL_FILENAME = 'ZA_SR002276'
            PARAMETER_1      = V_PARAM
       IMPORTING
            FILE_NAME        = DSN
       EXCEPTIONS
            FILE_NOT_FOUND   = 1
            OTHERS           = 2.

ENDFORM.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/181844/viewspace-609114/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-12-17

  • 博文量
    13
  • 访问量
    39378