2023 Jan 25 4:35 PM
There is a custom program which uses OPEN DATASET, TRANSFER, CLOSER DATASET commands to create a file, transfer the data and close the file respectively. I am checking SY-SUBRC value after each operations. Even though there are no failure in the above mentioned statements, sometimes the files are generating successfully and sometimes not.
Could somebody tell the reason?
2023 Jan 26 1:08 PM
For these intermittent errors, when you have several application servers, it's frequent that the path where you write the file was not mapped by the administrators in all the servers. You can see that quickly by switching to each server via SM51, and run AL11 to verify if you find the path or not.
Reply by OP:
My answer:
2023 Jan 25 4:41 PM
2023 Jan 26 5:52 AM
Hi Raymond
Please find the code below:
IF gt_output IS NOT INITIAL.
IF lv_destination IS INITIAL.
CONCATENATE lv_path lv_filename INTO lv_destination SEPARATED BY '/'.
ENDIF.
* Create file at the destination folder
IF gv_opndata_set IS INITIAL.
OPEN DATASET lv_destination FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE lv_msg_text.
IF sy-subrc NE 0.
MESSAGE e000(zcf_fallout) WITH lv_msg_text.
ELSE.
gv_opndata_set = abap_true.
PERFORM build_fieldcat_and_layout CHANGING lt_fcat.
PERFORM build_al11_header USING lt_fcat
CHANGING lv_header.
IF lv_header IS NOT INITIAL.
TRANSFER lv_header TO lv_destination.
ENDIF.
ENDIF.
ENDIF.
* Create Instance of Converter Class
CALL METHOD cl_rsda_csv_converter=>create
EXPORTING
i_delimiter = ' '
RECEIVING
r_r_conv = DATA(lo_conv).
DATA(lo_data) = cl_rsda_csv_converter=>get_char_workarea( ls_output ).
ASSIGN lo_data->* TO FIELD-SYMBOL(<lfs_data>).
LOOP AT gt_output ASSIGNING FIELD-SYMBOL(<lfs_output>). "#EC CI_LOOP_INTO_WA
CALL METHOD lo_conv->structure_to_csv
EXPORTING
i_s_data = <lfs_output> " I_S_DATA
IMPORTING
e_data = <lfs_data>. " E_DATA
REPLACE ALL OCCURRENCES OF cl_rsda_csv_converter=>c_default_delimiter IN <lfs_data> WITH space.
* CONDENSE <lfs_data> NO-GAPS.
* Transfer content to destination file
TRANSFER <lfs_data> TO lv_destination.
ENDLOOP.
CLOSE DATASET lv_destination.
IF sy-subrc IS INITIAL.
MESSAGE s001(zcf_fallout) WITH lv_filename p_path.
ENDIF.
2023 Jan 25 4:48 PM
For these intermittent errors, when you have several application servers, it's frequent that the path where you write the file was not mapped by the administrators in all the servers. You can see that quickly by switching to each server via SM51, and run AL11 to verify if you find the path or not.
2023 Jan 25 8:11 PM
When we have experienced this in the past it was always an authorization issue. You could watch it all of the way through the process and it will have good return codes, but the file never gets there
2023 Jan 26 5:55 AM
Hi Rich,
We do not get anything in SU53 so it is not an authorization issue. In case if it would have been an authorization issue, no files should have been placed at all
2023 Jan 26 8:39 AM
Hello,
I guess the comment from sandra.rossi leads into the right direction. My first thought when reading "sometimes the files are generating successfully and sometimes not" was, that your problem raises because of multiple application servers in your system. Sometimes your program / job runs on this server, next time on another one.
If there is a dedicated file server available in your system, you should use this file server for your files. If not, ask your basis for a common directory valid for all application servers. Or, in case there is a successor program / job, expecting the written file as an input file, ensure that it is running on the same application server than the one creating the file.
Kind regards
Jan
2023 Jan 26 9:17 AM
Thanks sandra.rossi. i think you pointed towards the correct direction. i checked the applications server using transaction SM51 and found that there are multiple Application Servers. When i switched from an application server to another one i could see the file there.
So the program is creating a file as expected now.
Do we somehow pass the application server anywhere in some parameter so that everytime the file can be dropped to that server?
2023 Jan 26 1:07 PM
ashish_verma
This customizing is to be done by the administrator, to map the paths of all application servers to a common place.
NB: I create an answer.
jmodaal FYI
2023 Jan 26 1:08 PM
For these intermittent errors, when you have several application servers, it's frequent that the path where you write the file was not mapped by the administrators in all the servers. You can see that quickly by switching to each server via SM51, and run AL11 to verify if you find the path or not.
Reply by OP:
My answer: