Tuesday, November 26, 2013

gui_upload


****************************
********SALES1.TXT**********
****************************
C1    S1    I1    1000
C1    S1    I2    2000
C1    S1    I3    3000
C1    S2    I4    4000
C1    S2    I5    5000
C1    S2    I6    6000
C2    S3    I7    7000
C2    S3    I8    8000
C2    S4    I9    9000
C2    S4    I10    10000


*&---------------------------------------------------------------------*
*& Report  ZGDEMO_CTRL_BREAK_STS_3PM
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZGDEMO_CTRL_BREAK_STS_3PM.

TYPES : BEGIN OF TY_SALES,
          KUNNR TYPE KUNNR,
          VBELN TYPE VBELN_VA,
          VBELP TYPE VBELP,
          NETPR TYPE NETPR,
        END OF   TY_SALES.

DATA : WA_SALES TYPE TY_SALES,
       IT_SALES TYPE TABLE OF TY_SALES.

*************************************
*        START-OF-SELECTION.        *
*************************************
START-OF-SELECTION.

PERFORM UPLOAD_DATA.

SORT IT_SALES BY KUNNR VBELN.

LOOP AT IT_SALES INTO WA_SALES.
                   WRITE : / WA_SALES-KUNNR,
                          WA_SALES-VBELN,
                          WA_SALES-VBELP,
                          WA_SALES-NETPR.

AT END OF VBELN.
    SUM.
    ULINE.
    WRITE : / 'SUM OF SO' , WA_SALES-VBELN, 'IS',WA_SALES-NETPR
COLOR 5 .

ENDAT.


AT END OF KUNNR.
    SUM.
    ULINE.
    WRITE : / 'SUM OF CUSTOMER' , WA_SALES-KUNNR, 'IS',WA_SALES-NETPR
COLOR 1 .

ENDAT.

AT LAST.
    SUM.
    ULINE.
    WRITE : / 'SUM OF ALL CUSTOMERS' COLOR 5, WA_SALES-NETPR COLOR 3.
ENDAT.

ENDLOOP.

*&---------------------------------------------------------------------*
*&      Form  UPLOAD_DATA
*&---------------------------------------------------------------------*
FORM UPLOAD_DATA .
      call function 'GUI_UPLOAD'
        exporting
          FILENAME                      = 'C:\SALES1.TXT'
*         FILETYPE                      = 'ASC'
         HAS_FIELD_SEPARATOR           = 'X'
*         HEADER_LENGTH                 = 0
*         READ_BY_LINE                  = 'X'
*         DAT_MODE                      = ' '
*         CODEPAGE                      = ' '
*         IGNORE_CERR                   = ABAP_TRUE
*         REPLACEMENT                   = '#'
*         CHECK_BOM                     = ' '
*       IMPORTING
*         FILELENGTH                    =
*         HEADER                        =
        TABLES
          DATA_TAB                      = IT_SALES
*       EXCEPTIONS
*         FILE_OPEN_ERROR               = 1
*         FILE_READ_ERROR               = 2
*         NO_BATCH                      = 3
*         GUI_REFUSE_FILETRANSFER       = 4
*         INVALID_TYPE                  = 5
*         NO_AUTHORITY                  = 6
*         UNKNOWN_ERROR                 = 7
*         BAD_DATA_FORMAT               = 8
*         HEADER_NOT_ALLOWED            = 9
*         SEPARATOR_NOT_ALLOWED         = 10
*         HEADER_TOO_LONG               = 11
*         UNKNOWN_DP_ERROR              = 12
*         ACCESS_DENIED                 = 13
*         DP_OUT_OF_MEMORY              = 14
*         DISK_FULL                     = 15
*         DP_TIMEOUT                    = 16
*         OTHERS                        = 17
                .
      if SY-SUBRC = 0.
          WRITE / 'DATA IS SUCCESSFULLY UPLOADED'.
      endif.

ENDFORM.                    " UPLOAD_DATA

No comments: