Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

PRESENTATION FILE

1)USING GUI_UPLOAD.

*&---------------------------------------------------------------------*
*& Report  ZINT_UPD1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZINT_UPD1.
typesbegin of ty_file,
  text(150),
  end of ty_file.
typesbegin of wa_kna1,
  kunnr type kunnr,
  name1 type name1,
  sortl type sortl,
  stras type stras,
  ort01 type ort01,
  land1 type land1,
  spras type spras,
  end of wa_kna1.
  typesBEGIN OF WA_KNBK,
          KUNNR TYPE KNBK-KUNNR,
          BANKS TYPE KNBK-BANKS,
          BANKL TYPE KNBK-BANKL,
          BANKN TYPE KNBK-BANKN,
        END OF WA_KNBK.


  data :it_file type standard table of ty_file,
        wa_file type ty_file,
        it_kna1 type standard table of wa_kna1,
        wa_kna1 type wa_kna1,
        it_knbk type standard table of wa_knbk,
        wa_knbk type wa_knbk.

  data v_id(2).

  start-of-selection.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      = 'D:\XD01_KNBK.TXT'
*     FILETYPE                      = 'ASC'
*     HAS_FIELD_SEPARATOR           = ' '
*     HEADER_LENGTH                 = 0
*     READ_BY_LINE                  = 'X'
*     DAT_MODE                      = ' '
*     CODEPAGE                      = ' '
*     IGNORE_CERR                   = ABAP_TRUE
*     REPLACEMENT                   = '#'
*     CHECK_BOM                     = ' '
*     VIRUS_SCAN_PROFILE            =
*     NO_AUTH_CHECK                 = ' '
*   IMPORTING
*     FILELENGTH                    =
*     HEADER                        =
    TABLES
      DATA_TAB                      = IT_FILE
*   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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  "spliting the file and moving to corresponding internal tables.

  loop at it_file into wa_file.
    if wa_file+0(2) = '10'.
      split wa_file AT ',' into v_id
      wa_kna1-kunnr
      wa_kna1-name1
      wa_kna1-sortl
      wa_kna1-stras
      wa_kna1-ort01
      wa_kna1-land1
      wa_kna1-spras.
append wa_kna1 to it_kna1.
elseif wa_file+0(2) = '20'.
   split wa_file AT ',' into v_id
      wa_knbk-kunnr
      wa_knbk-banks
      wa_knbk-bankl
      wa_knbk-bankn.
   append wa_knbk to it_knbk.
endif.
endloop.
write : / 'customer master general data'.
uline.
loop at it_kna1 into wa_kna1.
  write : / wa_kna1-kunnr,
  wa_kna1-name1,
  wa_kna1-sortl,
  wa_kna1-stras,
  wa_kna1-ort01,
  wa_kna1-land1,
  wa_kna1-spras.
  clear wa_kna1.
  endloop.
  skip 2.
  write :/ 'customer master bank data'.
  uline.
  loop at it_knbk into wa_knbk.
 write : / wa_knbk-kunnr,
 wa_knbk-banks,
 wa_knbk-bankl,
 wa_knbk-bankn.
clear wa_knbk.
endloop.

2) FOR EXCEL FILE

 

*&---------------------------------------------------------------------*
*& Report  ZINT_UPD2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZINT_UPD2.
TYPESbegin of wa_t001_txt,
  bukrs type bukrs,
  butxt type butxt,
  ort01 type ort01,
  land1 type land1,
  waers type waers,
  end of wa_t001_txt.

  data : it_too1_exl type STANDARD TABLE OF wa_t001_txt,
        wa_too1_exl type wa_t001_txt.
  data : it_return type STANDARD TABLE OF alsmex_tabline,
         wa_return type alsmex_tabline,
        wa_returns type alsmex_tabline.

  data : v_file type string,
        v_mask(10type c.
"  PARAMETERS p_file type rlgrap-filename.
  PARAMETERS p_file(128type c.
  AT SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
   " V_MASK = '*TXT'.
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
   EXPORTING
     PROGRAM_NAME        = SYST-REPID
*     DYNPRO_NUMBER       = SYST-DYNNR
*     FIELD_NAME          = ' '
*     STATIC              = ' '
 "    MASK                = 'V_MASK'
    CHANGING
      FILE_NAME           = P_FILE
   EXCEPTIONS
     MASK_TOO_LONG       = 1
          OTHERS              = 2
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  START-OF-SELECTION.
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME                      = p_file
      I_BEGIN_COL                   = 1
      I_BEGIN_ROW                   = 1
      I_END_COL                     = 4
      I_END_ROW                     = 4
    TABLES
      INTERN                        = it_return.
*   EXCEPTIONS
*     INCONSISTENT_PARAMETERS       = 1
*     UPLOAD_OLE                    = 2
*     OTHERS                        = 3
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  IF sy-subrc  = 0.
    MESSAGE 'success' type 'S'.

    sort it_return by row col.
    " move all the rows and column data into itab.
    LOOP AT it_return into wa_returns.
CASE wa_returns-col.
  WHEN 1.
    wa_too1_exl-bukrs = wa_returns-value.
  WHEN 2.
    wa_too1_exl-butxt = wa_returns-value.
    WHEN 3.
    wa_too1_exl-ort01 = wa_returns-value.
   WHEN 4.
    wa_too1_exl-land1 = wa_returns-value.

  WHEN OTHERS.
ENDCASE.

"at end of each row
"after moving all the column data
"append that data as row
at END OF row.
APPEND wa_too1_exl to it_too1_exl.
clear: wa_return, wa_too1_exl.
endat.

    ENDLOOP.
  ENDIF.

  loop at it_too1_exl into wa_too1_exl.
    WRITE : / wa_too1_exl-bukrs, wa_too1_exl-butxt, wa_too1_exl-ort01, wa_too1_exl-land1.
    ENDLOOP.

    AT SELECTION-SCREEN.
      TRANSLATE p_file TO UPPER CASE.

3) GUI_DOWNLOAD

*&---------------------------------------------------------------------*
*& Report  ZINT_UPD3
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZINT_UPD3.
TYPES : BEGIN OF wa_veda,
        vbeln type vbeln_va,
        vposn TYPE posnr_va,
        vlaufz TYPE vlauf_veda,
        vabndat TYPE vadat_veda,
        vbegdat TYPE vbdat_veda,
        vuntdat TYPE vudat_veda,
  end of wa_veda.
data : it_veda type STANDARD TABLE OF wa_veda,
      wa_veda type wa_veda.

START-OF-SELECTION.
  select vbeln
    vposn
    vlaufz
    vbegdat
    vuntdat
    into table it_veda
    from veda
    UP TO 20 rows.

end-of-SELECTION.
  if not it_veda is INITIAL.
    loop at it_veda into wa_veda.
      WRITE : / wa_veda-vbeln,
      wa_veda-vposn,
      wa_veda-vabndat,
      wa_veda-vbegdat,
      wa_veda-vuntdat.
      clear wa_veda.
    ENDLOOP.
  else.
    write : / 'No RECORDS'.
    ENDIF.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
*       BIN_FILESIZE                    =
        FILENAME                        = 'd:\download.xls'
       FILETYPE                        = 'ASC'
*       APPEND                          = ' '
       WRITE_FIELD_SEPARATOR           = 'X'
*       HEADER                          = '00'
*       TRUNC_TRAILING_BLANKS           = ' '
*       WRITE_LF                        = 'X'
*       COL_SELECT                      = ' '
*       COL_SELECT_MASK                 = ' '
*       DAT_MODE                        = ' '
*       CONFIRM_OVERWRITE               = ' '
*       NO_AUTH_CHECK                   = ' '
*       CODEPAGE                        = ' '
*       IGNORE_CERR                     = ABAP_TRUE
*       REPLACEMENT                     = '#'
*       WRITE_BOM                       = ' '
*       TRUNC_TRAILING_BLANKS_EOL       = 'X'
*       WK1_N_FORMAT                    = ' '
*       WK1_N_SIZE                      = ' '
*       WK1_T_FORMAT                    = ' '
*       WK1_T_SIZE                      = ' '
*     IMPORTING
*       FILELENGTH                      =
      TABLES
        DATA_TAB                        = it_veda
*       FIELDNAMES                      =
*     EXCEPTIONS
*       FILE_WRITE_ERROR                = 1
*       NO_BATCH                        = 2
*       GUI_REFUSE_FILETRANSFER         = 3
*       INVALID_TYPE                    = 4
*       NO_AUTHORITY                    = 5
*       UNKNOWN_ERROR                   = 6
*       HEADER_NOT_ALLOWED              = 7
*       SEPARATOR_NOT_ALLOWED           = 8
*       FILESIZE_NOT_ALLOWED            = 9
*       HEADER_TOO_LONG                 = 10
*       DP_ERROR_CREATE                 = 11
*       DP_ERROR_SEND                   = 12
*       DP_ERROR_WRITE                  = 13
*       UNKNOWN_DP_ERROR                = 14
*       ACCESS_DENIED                   = 15
*       DP_OUT_OF_MEMORY                = 16
*       DISK_FULL                       = 17
*       DP_TIMEOUT                      = 18
*       FILE_NOT_FOUND                  = 19
*       DATAPROVIDER_EXCEPTION          = 20
*       CONTROL_FLUSH_ERROR             = 21
*       OTHERS                          = 22
              .
    IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

 

 

 

 

 

 

 

 

 

 

  • No labels