Sunteți pe pagina 1din 16

*&---------------------------------------------------------------------*

*& Include
ZIXX_DATA_UPLOAD
*&---------------------------------------------------------------------*
*
* This include is used to provide the necessary selection screen
* fields and subroutines to upload a text file from the application or
* presentation servers. It gives search help capabilities for either
* application or presentation server files.
*
*
* Caution:
*
See documentation for class ZCLXX_FILE_SERVICES, methods
*
APP_UPLOAD_TEXT and GUI_UPLOAD for further information and
*
constraints on uploading text files.
*
*
* Usage:
*
*
By default, the selection screen will allow the user to choose
*
whether to upload the file from the application or presentation
*
server. The developer can, however, can limit the user's ability
*
to choose where to upload the file from. The following variables
*
can be set at INITIALIZAITON...
*
*
GW_UPLOAD_PC
*
GW_UPLOAD_AP
*
*
By default, these variable are set to 'X'. If GW_UPLOAD_PC is
*
set to INITIAL, the radio buttons will disappear and the user
*
will be forced to choose a file on the application server. The
*
same applies to GW_UPLOAD_AP.
*
*
If these variable are used, there is required code in the report
*
program at the selection-screen output event. The following code
*
must be inserted...
*
*
AT SELECTION-SCREEN OUTPUT.
*
PERFORM upload_screen_output.
*
*
This will cause the proper field formatting to occur based on the
*
contents of GW_UPLOAD_PC and GW_UPLOAD_AP.
*
*
*
The field GW_UPLOAD_APPDIR can be set to the default directory to
*
display on the application server. It is set to /usr/sap/ by
*
default but can be changed at INITIALIZATION.
*
*
*
There are three text elements that can be set for the selection
*
screen block...
*
*
TEXT-UF0 - defaults to 'Upload File'
*
TEXT-UF1 - defaults to 'Upload From PC'
*
TEXT-UF2 - defaults to 'Upload From App Server'
*
*
*
When it is time to upload the file, the form UPLOAD can be called
*
with the following parameters...
*
* HAS_SEPARATOR - Whether or not file has separator(defaults to tab)

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

FILETYPE
ALT_SEPARATOR
DISPLAY_ERROR
ERROR_OCCURRED
TABLE

Filetype used to upload


Alternate separator (other than tab)
Whether or not to issue error msg if occurs
Whether or not error occurred
Table to upload into

When this subroutine is called, it knows where to upload the data


from and how to do it.
The following is an example of how to upload a file separated by
commas and the developer handle the error...
PERFORM upload USING 'X' "has_separator
'ASC' "filetype
',' "alt_separator
space "display_error
error "error_occurred
some_table.
if not error is initial.
*some error occurred so handle it.
endif.
To check the File name in ZDTXX_FILENAM Table please
use the
PERFORM UPDATE_TABLE.
This is used to check whether the same file is being uploaded
twice a day. To stop the same from being processed twice
To move the file from New to Processed Folder in APP SER use
PERFORM FILE_MOVING.

*----------------------------------------------------------------------*
DATA:
*
DATA:

gw_upload_pc(1) VALUE 'X', "says to display pc file field


gw_upload_ap(1) VALUE 'X',
"says to display app server file field
initial directory on app server for f4 lookup
gw_upload_appdir TYPE rlgrap-filename VALUE '/usr/sap/',
gw_upload_f4title TYPE string.
gv_fname
TYPE zdtxx_filenam-fname,
gw_zdtxx_filenam TYPE zdtxx_filenam,
gv_answer
TYPE c,
gv_title1(15)
TYPE c VALUE 'Confirmation',
gv_question(50) TYPE c VALUE
'Do you have Control Record in the Flat file?'.

TABLES: zdtxx_filenam.
*----------------------------------------------------------------------*
* Selection Screen
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK upload WITH FRAME TITLE uplblock.
*Radio for PC
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_uprdpc RADIOBUTTON GROUP upl USER-COMMAND upl DEFAULT 'X'.
SELECTION-SCREEN COMMENT 4(25) uplpc." for field p_uprdpc.
PARAMETERS: p_upfile TYPE rlgrap-filename.
SELECTION-SCREEN END OF LINE.

*Radio for APP file


SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS: p_uprdap RADIOBUTTON GROUP upl.
SELECTION-SCREEN COMMENT 4(25) uplap." for field p_uprdap.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK upload.
*SELECTION-SCREEN BEGIN OF BLOCK dwnload WITH FRAME TITLE dwnblock.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 1(06) chk.
*PARAMETERS: p_chk TYPE c AS CHECKBOX.
*SELECTION-SCREEN COMMENT 4(28) dwnfile.
*PARAMETERS: p_dfile TYPE rlgrap-filename
*
DEFAULT '/usr/sap/interfaces/inbound/processed/'.
*SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN END OF BLOCK dwnload.
*
*SELECTION-SCREEN BEGIN OF BLOCK conrec WITH FRAME TITLE contrec.
*SELECTION-SCREEN BEGIN OF LINE.
*PARAMETERS: p_cntr TYPE c AS CHECKBOX.
*SELECTION-SCREEN COMMENT 4(28) contrecd.
*SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN END OF BLOCK conrec.
*----------------------------------------------------------------------*
* Initialization
*----------------------------------------------------------------------*
INITIALIZATION.
"#EC *
* generate texts
MOVE 'Upload File'(uf0) TO uplblock.
"#EC *
MOVE 'Upload From PC'(uf1) TO uplpc.
"#EC *
MOVE 'Upload From App Server'(uf2) TO uplap.
"#EC *
MOVE uplblock TO gw_upload_f4title.
* MOVE 'Moving File'(ud0) TO dwnblock.
"#EC *
* MOVE 'Download to Processed folder'(ud1) TO dwnfile.
"#EC *
* MOVE 'Control Record Validation'(uc0) TO contrec.
"#EC *
* MOVE 'Control Record Exists'(uc1) TO contrecd.
"#EC *
* MOVE 'Check'(ud2) TO chk.
*----------------------------------------------------------------------*
* At Selection Screen Value-Requests
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_upfile.
IF NOT p_uprdpc IS INITIAL.
CALL METHOD zclxx_file_services=>f4_pc_single_file
EXPORTING
i_window_title = gw_upload_f4title
IMPORTING
e_file
= p_upfile.
ELSEIF NOT p_uprdap IS INITIAL.
CALL METHOD zclxx_file_services=>f4_app_single_file
EXPORTING
i_initial_directory = gw_upload_appdir
IMPORTING
e_file
= p_upfile.
ENDIF.

*----------------------------------------------------------------------*
* At Selection Screen
*----------------------------------------------------------------------*
*AT SELECTION-SCREEN ON p_cntr.
* IF p_cntr IS INITIAL.
*
*
CALL FUNCTION 'POPUP_TO_CONFIRM'
*
EXPORTING
* titlebar
= gv_title1
** DIAGNOSE_OBJECT
= ' '
*
text_question
= gv_question
** TEXT_BUTTON_1
= 'Ja'(001)
** ICON_BUTTON_1
= ' '
** TEXT_BUTTON_2
= 'Nein'(002)
** ICON_BUTTON_2
= ' '
** DEFAULT_BUTTON
= '1'
** DISPLAY_CANCEL_BUTTON
= 'X'
** USERDEFINED_F1_HELP
= ' '
** START_COLUMN
= 25
** START_ROW
= 6
** POPUP_TYPE
=
** IV_QUICKINFO_BUTTON_1
= ' '
** IV_QUICKINFO_BUTTON_2
= ' '
* IMPORTING
* answer
= gv_answer
** TABLES
** PARAMETER
=
** EXCEPTIONS
** TEXT_NOT_FOUND
= 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.
*
*
IF gv_answer = '1'.
*
MESSAGE e030(zmcxx_services). "DISPLAY LIKE 'E'.
*
LEAVE LIST-PROCESSING.
*
ELSEIF gv_answer = 'A'.
*
EXIT.
**
LEAVE LIST-PROCESSING.
*
ENDIF.
*
* ENDIF.
*----------------------------------------------------------------------*
* Subroutines
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&
Form upload_screen_output
*&---------------------------------------------------------------------*
*
At Screen output routines
*----------------------------------------------------------------------*
FORM upload_screen_output.
* see if they said not to use pc upload, if so select the app server

* radio button
IF gw_upload_pc IS INITIAL.
CLEAR p_uprdpc.
p_uprdap = 'X'.
ENDIF.
LOOP AT SCREEN.
check to see if we are only using one upload field
CASE screen-name.
WHEN 'P_UPRDPC' OR 'P_UPRDAP'.
*
pc and app radio button
IF gw_upload_pc IS INITIAL OR gw_upload_ap IS INITIAL.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
WHEN 'UPLPC'.
*
pc comment
IF gw_upload_pc IS INITIAL.
MOVE 'Upload From App Server'(uf2) TO uplpc.
"#EC *
ELSEIF gw_upload_ap IS INITIAL.
MOVE 'Upload From PC'(uf1) TO uplpc.
"#EC *
ENDIF.
WHEN 'UPLAP'.
*
app comment
IF gw_upload_ap IS INITIAL OR gw_upload_pc IS INITIAL.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
*
WHEN 'P_DFILE'.
*
screen-input = 0.
**
p_dfile = '/usr/sap/interfaces/inbound/processed/'
.
*
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
*

ENDFORM.

" upload_screen_output

*&---------------------------------------------------------------------*
*&
Form Update_Table
*&---------------------------------------------------------------------*
*
Upload the file Name into Dtabase table ZDTXX_FILENAM
*----------------------------------------------------------------------*
FORM update_table.
IF p_upfile IS INITIAL.
error_occurred = abap_true.
IF display_error = abap_true.
Begin of Insertion "MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
MESSAGE s011(zmcxx_services) DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
*
ENDIF.
EXIT.
ELSE.
MESSAGE e011(zmcxx_services).
ENDIF.
*
End of Insertion " MVALLATHAN 09/09/08
*
*
*

ELSE.
make sure the input file already uploaded on that day
DATA :
lv_upfile TYPE rlgrap-filename,
lv_slash
TYPE c,
li_ftab
TYPE TABLE OF string,
lv_line
TYPE i.
IF p_uprdap = 'X'.
lv_slash = '/'.
ELSEIF p_uprdpc = 'X'.
lv_slash = '\'.
ENDIF.

*
*
*
*
*

SPLIT p_upfile AT lv_slash INTO TABLE li_ftab.


DESCRIBE TABLE li_ftab LINES lv_line.
READ TABLE li_ftab INTO lv_upfile INDEX lv_line.
TRANSLATE lv_upfile TO UPPER CASE.
CONDENSE lv_upfile.
SELECT SINGLE fname
FROM zdtxx_filenam
INTO gv_fname
WHERE fname = lv_upfile.
Begin of change done by NGS on 10/07/2008.
Commented to restrict duplicate file upload forever instead of
checking for the same day.
AND sy_date = sy-datum.
End of change done by NGS on 10/07/2008.
IF sy-subrc = 0.
IF sy-batch <> 'X'.

MESSAGE s029(zmcxx_services) DISPLAY LIKE 'E'.


LEAVE LIST-PROCESSING.
ENDIF.
EXIT.
ELSE.
MESSAGE e029(zmcxx_services).
ENDIF.
End of Insertion " MVALLATHAN 09/09/08
ENDIF.
ENDIF.

ENDFORM.

" upload

*&---------------------------------------------------------------------*
*&
Form upload
*&---------------------------------------------------------------------*
*
Upload the file based on selection screen
*----------------------------------------------------------------------*
*
-->HAS_SEPARATOR Whether or not file has separator
*
-->FILETYPE
Filetype used to uplaod
*
-->ALT_SEPARATOR Alternate separator (other than tab)
*
-->DISPLAY_ERROR Whether or not to issue error msg if occurs
*
-->ERROR_OCCURRED Whether or not error occurred
*
-->TABLE
Table to upload into
*----------------------------------------------------------------------*
FORM upload USING has_separator TYPE abap_bool
filetype
TYPE char10

value(alt_separator)
display_error TYPE abap_bool
error_occurred TYPE abap_bool
table TYPE STANDARD TABLE.

"#EC *

** To get confirmation from the user whether the Flat file is having
** Control record which gives Flat File Name, Time stamp amd
** Total number of records to be uploaded as first line.
* IF p_cntr IS INITIAL.
*
*
CALL FUNCTION 'POPUP_TO_CONFIRM'
*
EXPORTING
* titlebar
= gv_title1
** DIAGNOSE_OBJECT
= ' '
*
text_question
= gv_question
** TEXT_BUTTON_1
= 'Ja'(001)
** ICON_BUTTON_1
= ' '
** TEXT_BUTTON_2
= 'Nein'(002)
** ICON_BUTTON_2
= ' '
** DEFAULT_BUTTON
= '1'
** DISPLAY_CANCEL_BUTTON
= 'X'
** USERDEFINED_F1_HELP
= ' '
** START_COLUMN
= 25
** START_ROW
= 6
** POPUP_TYPE
=
** IV_QUICKINFO_BUTTON_1
= ' '
** IV_QUICKINFO_BUTTON_2
= ' '
* IMPORTING
* answer
= gv_answer
** TABLES
** PARAMETER
=
** EXCEPTIONS
** TEXT_NOT_FOUND
= 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.
*
*
IF gv_answer = '1'.
*
MESSAGE S030(zmcxx_services) DISPLAY LIKE 'E'.
*
LEAVE LIST-PROCESSING.
*
ELSEIF gv_answer = 'A'.
**
EXIT.
*
LEAVE LIST-PROCESSING.
*
ENDIF.
*
* ENDIF.
PERFORM update_table.
* PERFORM control_rec.
DATA: file
rc

TYPE string,
TYPE sy-subrc.

IF p_upfile IS INITIAL.
*
error_occurred = abap_true.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.

IF display_error = abap_true.
MESSAGE s011(zmcxx_services) DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
EXIT.
ELSE.
MESSAGE e029(zmcxx_services).
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ELSE.
IF NOT p_uprdpc IS INITIAL.
*

read in the file from PC


file = p_upfile.
IF alt_separator IS INITIAL.
do not supply alternate separator
CALL METHOD zclxx_file_services=>gui_upload
EXPORTING
i_filename
= file
i_filetype
= filetype
i_has_field_separator = has_separator
CHANGING
ct_data_tab
= table
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
not_supported_by_gui
= 17
error_no_gui
= 18
OTHERS
= 19.
rc = sy-subrc.
ELSE.
CALL METHOD zclxx_file_services=>gui_upload
EXPORTING
i_filename
= file
i_filetype
= filetype
i_has_field_separator = has_separator
i_alternate_delimiter = alt_separator
CHANGING
ct_data_tab
= table
EXCEPTIONS
file_open_error
= 1
file_read_error
= 2
no_batch
= 3

gui_refuse_filetransfer
invalid_type
no_authority
unknown_error
bad_data_format
header_not_allowed
separator_not_allowed
header_too_long
unknown_dp_error
access_denied
dp_out_of_memory
disk_full
dp_timeout
not_supported_by_gui
error_no_gui
OTHERS
rc = sy-subrc.
ENDIF.

=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19.

IF rc <> 0.
*
error_occurred = abap_true.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
IF display_error = 'X'.
*
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E' WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
LEAVE LIST-PROCESSING.
ENDIF.
ELSE.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ELSE.
PERFORM update_filename_table.
IF NOT table IS INITIAL.
*
IF p_cntr = 'X'.
*
DELETE table INDEX 1.
*
ENDIF.
ELSE.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
MESSAGE s007(zmcxx_services) DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e007(zmcxx_services).
ENDIF.
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ENDIF.
*

ELSEIF NOT p_uprdap IS INITIAL.


read in file from app server
IF has_separator = abap_true.

has separator, if none passed then default to tab


IF alt_separator IS INITIAL.
alt_separator = cl_abap_char_utilities=>horizontal_tab.
ENDIF.
CALL METHOD zclxx_file_services=>app_upload_text
EXPORTING
i_filename
= p_upfile
i_delimiter
= alt_separator
CHANGING
ct_data_tab
= table
EXCEPTIONS
file_open_error
= 1
error_splitting_record = 2
field_type_not_allowed = 3
OTHERS
= 4.
rc = sy-subrc.

ELSE.
no separator
CALL METHOD zclxx_file_services=>app_upload_text
EXPORTING
i_filename
= p_upfile
CHANGING
ct_data_tab
= table
EXCEPTIONS
file_open_error
= 1
error_splitting_record = 2
field_type_not_allowed = 3
OTHERS
= 4.
rc = sy-subrc.
ENDIF.

IF rc <> 0.
*
error_occurred = abap_true.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
IF display_error = abap_true.
*
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E' WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
LEAVE LIST-PROCESSING.
ENDIF.
ELSE.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ELSE.
PERFORM update_filename_table.
IF NOT table IS INITIAL.
*
IF p_cntr = 'X'.
*
DELETE table INDEX 1.
*
ENDIF.
ELSE.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
MESSAGE s007(zmcxx_services) DISPLAY LIKE 'E'.

LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e007(zmcxx_services).
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ENDIF.
ENDIF.
ELSE.
* this should never occur unless another radio button is added
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
MESSAGE s012(zmcxx_services) DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e012(zmcxx_services).
ENDIF.
ENDIF.
ENDIF.
ENDFORM.

" upload

*&---------------------------------------------------------------------*
*&
Form control_rec
*&---------------------------------------------------------------------*
*
To Check Control Record
*----------------------------------------------------------------------*
FORM control_rec ." USING table TYPE STANDARD TABLE.
* IF p_cntr = 'X'.
TYPES: BEGIN OF lt_table,
name(53) TYPE c,
dati(14) TYPE c,
norec(10) TYPE c,
END OF lt_table.
DATA : li_table TYPE TABLE OF lt_table,
lw_table TYPE lt_table,
lv_upfile TYPE rlgrap-filename,
lv_lines(10) TYPE n,
lv_slash
TYPE c,
li_ftab
TYPE TABLE OF string,
lv_line
TYPE i,
lv_separator
TYPE abap_char1,
lv_rc
TYPE syst-subrc,
file
TYPE string.
IF p_uprdap = 'X'.
lv_slash = '/'.
ELSEIF p_uprdpc = 'X'.
lv_slash = '\'.
ENDIF.
SPLIT p_upfile AT lv_slash INTO TABLE li_ftab.
DESCRIBE TABLE li_ftab LINES lv_line.
READ TABLE li_ftab INTO lv_upfile INDEX lv_line.
TRANSLATE lv_upfile TO UPPER CASE.

"#EC TRANSLANG

CONDENSE lv_upfile.
lv_separator = cl_abap_char_utilities=>horizontal_tab.
IF NOT p_uprdpc IS INITIAL.
file = p_upfile.
CALL METHOD zclxx_file_services=>gui_upload
EXPORTING
i_filename
= file
i_filetype
= 'ASC'
i_has_field_separator = 'X'
i_alternate_delimiter = lv_separator
CHANGING
ct_data_tab
= li_table
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
not_supported_by_gui
= 17
error_no_gui
= 18
OTHERS
= 19.
lv_rc = sy-subrc.
ELSEIF NOT p_uprdap IS INITIAL.
* read in file from app server
CALL METHOD zclxx_file_services=>app_upload_text
EXPORTING
i_filename
= p_upfile
i_delimiter
= lv_separator
CHANGING
ct_data_tab
= li_table
EXCEPTIONS
file_open_error
= 1
error_splitting_record = 2
field_type_not_allowed = 3
OTHERS
= 4.
lv_rc = sy-subrc.
ENDIF.
IF lv_rc <> 0.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch = 'X'.
*
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E' WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.


ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ENDIF.
READ TABLE li_table INTO lw_table INDEX 1.
IF sy-subrc = 0.
DESCRIBE TABLE li_table LINES lv_lines.
TRANSLATE lv_upfile TO UPPER CASE.
"#EC TRANSLANG
TRANSLATE lw_table TO UPPER CASE.
"#EC TRANSLANG
CONDENSE lv_upfile.
IF lv_upfile = lw_table-name.
lv_lines = lv_lines - 1.
IF lv_lines <> lw_table-norec.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
MESSAGE s028(zmcxx_services) DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e028(zmcxx_services).
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ENDIF.
ELSE.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
MESSAGE s027(zmcxx_services) DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e027(zmcxx_services).
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ENDIF.
ENDIF.
* ENDIF.
ENDFORM .

"control_rec

*&---------------------------------------------------------------------*
*&
Form file_moving
*&---------------------------------------------------------------------*
*
To move the file
*----------------------------------------------------------------------*
FORM file_moving USING table TYPE STANDARD TABLE.
IF NOT p_uprdap IS INITIAL.
DATA lv_delim TYPE c.
*
IF p_chk = 'X'.
DATA : lv_upfile TYPE rlgrap-filename,
lv_dfile TYPE rlgrap-filename,
lv_slash
TYPE c,
li_ftab
TYPE TABLE OF string,
lv_line
TYPE i.
IF p_uprdap = 'X'.
lv_slash = '/'.
ELSEIF p_uprdpc = 'X'.
lv_slash = '\'.

ENDIF.
SPLIT p_upfile AT lv_slash INTO TABLE li_ftab.
DESCRIBE TABLE li_ftab LINES lv_line.
READ TABLE li_ftab INTO lv_upfile INDEX lv_line.
TRANSLATE lv_upfile TO UPPER CASE.

"#EC TRANSLANG

CONDENSE lv_upfile.
*Logic to Move file in APP SER from NEW to Proccessed folder
CONCATENATE '/usr/sap/interfaces/INBOUND/PROCESSED/'
lv_upfile INTO lv_dfile.
* Begin of change in the folder name to Upper case with respect to the
* intruction given by Sambath from onsite
*
*

CONCATENATE '/usr/sap/interfaces/inbound/processed/'
lv_upfile INTO lv_dfile.

* End of change in the folder name to Upper case with respect to the
* intruction given by Sambath from onsite
lv_delim = cl_abap_char_utilities=>horizontal_tab.
CALL METHOD zclxx_file_services=>app_download_text
EXPORTING
i_filename
= lv_dfile
i_delimiter
= lv_delim
CHANGING
ct_data_tab
= table
EXCEPTIONS
file_open_error
= 1
field_type_not_allowed = 2
no_data
= 3
OTHERS
= 4.
IF sy-subrc <> 0.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E' WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ELSE.
*
Delete from new folder
* open the dataset in text mode
OPEN DATASET p_upfile FOR OUTPUT IN TEXT MODE " MESSAGE app_msg
ENCODING DEFAULT.
DELETE DATASET p_upfile.
CLOSE DATASET p_upfile.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
*

"Update_Table

*&---------------------------------------------------------------------*
*&
Form update_filename_table
*&---------------------------------------------------------------------*

*
text
*----------------------------------------------------------------------*
FORM update_filename_table.
* logic to insert file name into table
* make sure the input file already uploaded on that day
DATA :

lv_upfile TYPE rlgrap-filename,


lv_slash
TYPE c,
li_ftab
TYPE TABLE OF string,
lv_line
TYPE i.

IF p_uprdap = 'X'.
lv_slash = '/'.
ELSEIF p_uprdpc = 'X'.
lv_slash = '\'.
ENDIF.

*
*
*
*
*

SPLIT p_upfile AT lv_slash INTO TABLE li_ftab.


DESCRIBE TABLE li_ftab LINES lv_line.
READ TABLE li_ftab INTO lv_upfile INDEX lv_line.
TRANSLATE lv_upfile TO UPPER CASE.
"#EC TRANSLANG
CONDENSE lv_upfile.
IF sy-subrc = 0.
SELECT SINGLE fname
FROM zdtxx_filenam
INTO gv_fname
WHERE fname = lv_upfile.
Begin of change done by NGS on 10/07/2008.
Commented to restrict duplicate file upload forever instead of
checking for the same day.
AND sy_date = sy-datum.
End of change done by NGS on 10/07/2008.

IF sy-subrc = 0.
*Begin of Insertion " MVALLATHAN 09/09/08
IF sy-batch <> 'X'.
MESSAGE s029(zmcxx_services) DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e029(zmcxx_services).
ENDIF.
*End of Insertion " MVALLATHAN 09/09/08
ELSE.
*
gw_zdtxx_filenam-fname = lv_upfile.
*
gw_zdtxx_filenam-sy_date = sy-datum.
zdtxx_filenam-fname = lv_upfile.
zdtxx_filenam-sy_date = sy-datum.
INSERT zdtxx_filenam. " values gw_zdtxx_filenam.
COMMIT WORK.
ENDIF.
ENDIF.
ENDFORM.
"update_filename_table
*&---------------------------------------------------------------------*
*&
Form delete_filename_table
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM delete_filename_table.

* logic to delete file name into table


* make sure the input file already uploaded on that day
DATA :

lv_upfile TYPE rlgrap-filename,


lv_slash
TYPE c,
li_ftab
TYPE TABLE OF string,
lv_line
TYPE i.

IF p_uprdap = 'X'.
lv_slash = '/'.
ELSEIF p_uprdpc = 'X'.
lv_slash = '\'.
ENDIF.
SPLIT p_upfile AT lv_slash INTO TABLE li_ftab.
DESCRIBE TABLE li_ftab LINES lv_line.
READ TABLE li_ftab INTO lv_upfile INDEX lv_line.
TRANSLATE lv_upfile TO UPPER CASE.
CONDENSE lv_upfile.
IF sy-subrc = 0.
SELECT SINGLE fname
FROM zdtxx_filenam
INTO gv_fname
WHERE fname = lv_upfile.
IF sy-subrc = 0.
zdtxx_filenam-fname = lv_upfile.
zdtxx_filenam-sy_date = sy-datum.
delete zdtxx_filenam.
COMMIT WORK.
ELSE.
IF sy-batch <> 'X'.
MESSAGE s033(zmcxx_services) DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE e033(zmcxx_services).
ENDIF.
ENDIF.
ENDIF.
ENDFORM.

"update_filename_table

"#EC TRANSLANG

S-ar putea să vă placă și