Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

File not getting written to app server when prog is run in background

kiran_k8
Active Contributor
0 Kudos

Folks,                                                                                                                                                                                                                                                     

I have a program which has an option to display the data in an ALV report when run in foreground or tranfers the data to a text file to the application server when run in background.When running the report in the background mode (without debugger on) it is not tranferring the whole data but when the same report is executed in debugging in the background mode (with debugger on) it is perfectly fine.

It seems the link to appliction server is getting lost  when the program is executed in the background mode (with out debugger on).

I didn't get why the same is not happnening when the same report is executed in the background mode with debugger on.

Below is the logic in use.


{code}

OPEN DATASET l_v_file IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.
*  Transfer the data record line by line.

  IF sy-subrc IS NOT INITIAL. 

  MESSAGE e009.
*   Unable to open file from Application server

ENDIF.

*  transfer the header text to file

TRANSFER l_v_header TO l_v_file.

*  transfer the data to file

  LOOP AT l_i_csv_final INTO l_rec_csv_final. 

  TRANSFER l_rec_csv_final TO l_v_file.

   CLEAR l_rec_csv_final. 

ENDLOOP.

*  CLOSE Dataset

CLOSE DATASET l_v_file.

{code}

Can anybody throw some light on what could be the possible issue.

Thanks,
K.Kiran.

1 ACCEPTED SOLUTION

sandeep_katoch
Contributor
0 Kudos

Hi Kiran,

please check the user authority for writing records in background.

The second case which might cause the problem can be the application server which is executing the job in backroud. check in sm50 on which application server the background job is running.

may be some authorizations or configurations are missing...

6 REPLIES 6

sandeep_katoch
Contributor
0 Kudos

Hi Kiran,

please check the user authority for writing records in background.

The second case which might cause the problem can be the application server which is executing the job in backroud. check in sm50 on which application server the background job is running.

may be some authorizations or configurations are missing...

0 Kudos

Sandeep,

If I am not wrong....

If it is about authorisation,then it should not create the file in the first place but it is creating the file but not completely.The same when executed with debugger on is perfectly fine.

I will check the SM50 as you advised and also put a authority check.

Thanks.

0 Kudos

Yes Kiram you are right but creation and writing are two dfferent authorizations in SAP.

So may be creation authorization is there but write authorization may have any problem.

0 Kudos

How are you checking the file? Just wanted to think in a different direction whether the file is properly read from application server. Application server may not hold complete file data.

Amarpreet
Active Participant
0 Kudos

hi ,

this might be a shot in the dark, but i think checking if "sy-subrc is not initial"  might not have the intended effect.

While initial value of sy-subrc is '0' ,But i think the initial statement checks to see if the value is the defualt  for the data-type. ( i may be wrong , i'll test this in the morning when i have access to sap system) so in your statement . "IF SY-SUBRC IS NOT INITIAL" will alway be true because it is assigned the value 0 as a result of a successful OPEN DATASET statement.

i recommend using "IF SY-SUBRC NE 0 "

{code}

OPEN DATASET l_v_file IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.
*  Transfer the data record line by line.

  IF sy-subrc NE 0 .

       MESSAGE e009.
*   Unable to open file from Application server

ELSE.

*  transfer the header text to file

     TRANSFER l_v_header TO l_v_file.

*  transfer the data to file

       LOOP AT l_i_csv_final INTO l_rec_csv_final.

            TRANSFER l_rec_csv_final TO l_v_file.

             CLEAR l_rec_csv_final.

     ENDLOOP.    

*  CLOSE Dataset

     CLOSE DATASET l_v_file.

ENDIF.

{code}

This would also explain why a file gets created (OPEN DATASET runs successfully) but there's not data as the error message ends the run .

Hope this helps .

good luck

Former Member
0 Kudos

I remember running into something similar with a batch job that wrote a file to a remote server. I had to give SAPService<SID> write access to the directory.