Hi,
I have to upload Vendor Master data from the application server using standard program RFBIKR00. For this I have written the following code:-
REPORT ZREPORT
NO STANDARD PAGE HEADING
MESSAGE-ID ZFI
LINE-COUNT 65
LINE-SIZE 120.
&----
*& TABLES
&----
Internal to store the list of files.
DATA : BEGIN OF T_LISTFILES OCCURS 0.
INCLUDE STRUCTURE SALFLDIR.
DATA: END OF T_LISTFILES.
Internal table to hold the external file data.
DATA: BEGIN OF T_INPUTFILE OCCURS 0,
LINE(1000) TYPE C,
END OF T_INPUTFILE.
&----
*& PROGRAM VARIABLES
&----
DATA: V_DIRFILES TYPE SALFILE-LONGNAME VALUE '/holdarchlogs/outbound',
V_FILENAME(128) TYPE C,
V_FILEPATH(256) TYPE C,
V_MSG(256) TYPE C.
----
*S T A R T - O F - S E L E C T I O N *
----
START-OF-SELECTION.
Perform to get the list of all the files in a specific directory of application server.
PERFORM GET_DIRECTORY_FILES.
Perform to process the logic
PERFORM PROCESS_FILES.
&----
*& Form GET_DIRECTORY_FILES
&----
Perform to get the list of all the files in a specific directory of application server
----
FORM GET_DIRECTORY_FILES .
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
NAME = V_DIRFILES
TABLES
FILE_TBL = T_LISTFILES
EXCEPTIONS
ARGUMENT_ERROR = 1
NOT_FOUND = 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.
ELSE.
SORT T_LISTFILES BY NAME.
CLEAR T_LISTFILES.
ENDIF.
ENDFORM. " GET_DIRECTORY_FILES
&----
*& Form PROCESS_FILES
&----
Perform to process the logic
----
FORM PROCESS_FILES .
LOOP AT T_LISTFILES .
DELETE T_LISTFILES WHERE NAME = '.' .
DELETE T_LISTFILES WHERE NAME = '..'.
CLEAR T_LISTFILES.
ENDLOOP.
Open the file
LOOP AT T_LISTFILES.
CONCATENATE V_DIRFILES '/' T_LISTFILES-NAME INTO V_FILEPATH.
OPEN DATASET V_FILEPATH FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE V_MSG.
WRITE: V_FILEPATH.
IF SY-SUBRC <> 0.
WRITE: 'File cannot be opened', V_MSG.
EXIT.
ENDIF.
Reading the file.
DO.
READ DATASET V_FILEPATH INTO T_INPUTFILE.
IF SY-SUBRC <> 0.
EXIT.
ELSE.
SUBMIT RFBIKR00 AND RETURN.
ENDIF.
APPEND T_INPUTFILE.
WRITE:/ T_INPUTFILE.
ENDDO.
Close the file.
CLOSE DATASET V_FILEPATH.
ENDLOOP.
Here when I am testing 3 info message come (breakpoint setup in the submit statement):-
1.) No such file or directory
2.) File could not be opened
3.) ...Editing was terminated.
So to test with a real time scenario... I created a .txt file with the structure of BGR00, BLFA1, BLFB1 this i uploaded in an internal table using GUI_UPLOAD and then transfered it to application server... my problem is that application server is not showing all the content of the .txt file that I created on my c: drive. For this I have written the following code:-
REPORT ZPCFILE_UNIX.
DATA: FILENAME1(100) value '/holdarchlogs/outbound/appsertestfile.txt',
FILENAME(100) value
'C:\Testfiles\AP-INT-001 TEST FILE.txt',
MSGS(256),
g_file type string.
DATA: BEGIN OF T_DATATAB OCCURS 0,
line(1000) type c,
END OF T_DATATAB.
G_FILE = FILENAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = G_FILE
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = T_DATATAB
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.
open file
OPEN DATASET FILENAME1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE MSGS.
IF SY-SUBRC <> 0.
WRITE: 'File could not be opened', MSGS.
ENDIF.
transfering data.
LOOP AT T_DATATAB.
TRANSFER T_DATATAB TO FILENAME1.
ENDLOOP.
Close file.
CLOSE DATASET FILENAME1.
Please tell me what is going wrong in the "SUBMIT RFBIKR00 AND RETURN" statement.
Thank You,
SB.