REPORT ZZSNI001 MESSAGE-ID ZZ.
*
************************************************************************
*  Reading via DD03P                    By   Erikki Tikka              *
*                                                                      *
*                                       Date 15.10.1996                *
*                                                                      *
************************************************************************
SELECTION-SCREEN COMMENT /1(79) TEXT-100.
SELECTION-SCREEN COMMENT /1(79) TEXT-101.  " Reading .....
SELECTION-SCREEN COMMENT /1(79) TEXT-102.
SELECTION-SCREEN COMMENT /1(79) TEXT-103.
SELECTION-SCREEN ULINE.
*
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(35) TEXT-110.   " Input-file
PARAMETERS: INFILE(45) TYPE C DEFAULT '/usr/sap/trans/testdata/eti/'
                                      LOWER CASE.
SELECTION-SCREEN END OF LINE.
*
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(35) TEXT-120.   "How many headers
PARAMETERS: CHOOSE(5) TYPE C DEFAULT '999'.
SELECTION-SCREEN END OF LINE.
*
*
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(35) TEXT-140.
PARAMETERS: LIST TYPE C DEFAULT 'x'.      "Listing
SELECTION-SCREEN END OF LINE.
*
DATA:CNTI TYPE I, CNTO LIKE CNTI, CNT1 LIKE CNTI.
*
DATA:INDATA(3000) TYPE C.
*
TABLES:BKPF, DD03P.
*
DATA:BEGIN OF INTAB OCCURS 0.
        INCLUDE STRUCTURE DD03P.
DATA:END OF INTAB.
*
DATA:BEGIN OF BVBAKKOM.
        INCLUDE STRUCTURE BVBAKKOM.
DATA:END OF BVBAKKOM.
*
DATA:BEGIN OF BVBPAKOM.
        INCLUDE STRUCTURE BVBPAKOM.
DATA:END OF BVBPAKOM.
*
DATA:BEGIN OF BVBAPKOM.
        INCLUDE STRUCTURE BVBAPKOM.
DATA:END OF BVBAPKOM.
*
DATA:A(35).
FIELD-SYMBOLS:<F>.
*
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
  OPEN DATASET INFILE FOR INPUT IN TEXT MODE.
  IF SY-SUBRC <> 0.
    MESSAGE E999 WITH 'Open failed for input-file' INFILE.
  ENDIF.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
  WRITE: / 'Input', INFILE.
  WRITE: /.
  WHILE SY-SUBRC = 0.
    READ DATASET INFILE INTO INDATA.
    IF SY-SUBRC = 0.
      CNTI = CNTI + 1.
      IF INDATA(8) <> 'BVBAKKOM'.
        CNT1 = CNT1 + 1.
      ENDIF.
      IF CNT1 <= CHOOSE AND LIST = 'X'.
        PERFORM LISTING.
      ELSE.
        SY-SUBRC = 4.
      ENDIF.
    ENDIF.
  ENDWHILE.
*
  PERFORM END-REPORT.
*
*---------------------------------------------------------------------*
*  Listing of one record
*---------------------------------------------------------------------*
FORM LISTING.
*
  CASE INDATA(8).
*
    WHEN 'BVBAKKOM'.
      SELECT * FROM DD03P INTO TABLE INTAB
        WHERE TABNAME = 'BVBAKKOM'
          AND DDLANGUAGE = 'E'.
      SORT INTAB BY POSITION.
      BVBAKKOM = INDATA.
      WRITE /.
      DO.
        ASSIGN COMPONENT SY-INDEX OF
               STRUCTURE BVBAKKOM TO <F>.
        IF SY-SUBRC <> 0. EXIT. ENDIF.
        READ TABLE INTAB INDEX SY-INDEX.
        A = <F>.
        WRITE:/ INTAB-FIELDNAME, A.
      ENDDO.
*
    WHEN 'BVBPAKOM'.
      SELECT * FROM DD03P INTO TABLE INTAB
        WHERE TABNAME = 'BVBPAKOM'
          AND DDLANGUAGE = 'E'.
      SORT INTAB BY POSITION.
      BVBPAKOM = INDATA.
      WRITE /.
      DO.
        ASSIGN COMPONENT SY-INDEX OF
               STRUCTURE BVBPAKOM TO <F>.
        IF SY-SUBRC <> 0. EXIT. ENDIF.
        READ TABLE INTAB INDEX SY-INDEX.
        A = <F>.
        WRITE:/ INTAB-FIELDNAME, A.
      ENDDO.
*
    WHEN 'BVBAPKOM'.
      SELECT * FROM DD03P INTO TABLE INTAB
        WHERE TABNAME = 'BVBAPKOM'
          AND DDLANGUAGE = 'E'.
      SORT INTAB BY POSITION.
      BVBAPKOM = INDATA.
      WRITE /.
      DO.
        ASSIGN COMPONENT SY-INDEX OF
               STRUCTURE BVBAPKOM TO <F>.
        IF SY-SUBRC <> 0. EXIT. ENDIF.
        READ TABLE INTAB INDEX SY-INDEX.
        A = <F>.
        WRITE:/ INTAB-FIELDNAME, A.
      ENDDO.
  ENDCASE.
  SY-SUBRC = 0.
ENDFORM.
*---------------------------------------------------------------------*
*  counters
*---------------------------------------------------------------------*
FORM END-REPORT.
*
  WRITE /.
  WRITE: / 'Input  ', CNTI.
ENDFORM.