Application Development and Automation 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: 
Read only

generate file in background runing

former_member810309
Participant
0 Likes
1,983

Hi everyone

in this code i want to generate file when my program is runing in background, i don't have any error but the file is not generated when i double-click in path from TVARVC.

plz help to understand it and if u want more details about problem i remain available.

Thnx a lot.

    IF p_sfl = 'X'.<br>      DATA lv_low TYPE rvari_val_255.<br><br>      SELECT SINGLE low<br>        FROM tvarvc<br>        INTO lv_low<br>        WHERE name = 'ZTAI'.<br><br>      OPEN DATASET lv_low FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.<br>      CHECK sy-subrc EQ 0.<br>      LOOP AT gt_flight INTO gs_flight.<br>        TRANSFER gs_flight TO lv_low.<br>      ENDLOOP.<br>      CLOSE DATASET lv_low.<br><br>    ELSEIF p_spfli = 'X'.<br>      OPEN DATASET lv_low FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.<br>      CHECK sy-subrc EQ 0.<br>      LOOP AT it_spfli INTO wa_spfli.<br>        TRANSFER wa_spfli TO lv_low.<br>      ENDLOOP.<br>      CLOSE DATASET lv_low.<br>    ENDIF.<br>

Hi everyone

in this code i want to generate file when my program is runing in background, i don't have any error but the file is not generated when i double-click in path from TVARVC.

plz help to understand it and if u want more details about problem i remain available.

Thnx a lot.

    IF p_sfl = 'X'.<br>      DATA lv_low TYPE rvari_val_255.<br><br>      SELECT SINGLE low<br>        FROM tvarvc<br>        INTO lv_low<br>        WHERE name = 'ZTAI'.<br><br>      OPEN DATASET lv_low FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.<br>      CHECK sy-subrc EQ 0.<br>      LOOP AT gt_flight INTO gs_flight.<br>        TRANSFER gs_flight TO lv_low.<br>      ENDLOOP.<br>      CLOSE DATASET lv_low.<br><br>    ELSEIF p_spfli = 'X'.<br>      OPEN DATASET lv_low FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.<br>      CHECK sy-subrc EQ 0.<br>      LOOP AT it_spfli INTO wa_spfli.<br>        TRANSFER wa_spfli TO lv_low.<br>      ENDLOOP.<br>      CLOSE DATASET lv_low.<br>    ENDIF.<br>
7 REPLIES 7
Read only

Sandra_Rossi
Active Contributor
1,863

Debug it and handle better the exceptions so that you get a log.

Read only

former_member751463
Participant
1,863

Hi,

You need to check the file in Application server. Run Tcode AL11 and check if the files present in the file path or not.

Provide some error message if open dataset fails. There could be authorization issue to access the file.

Thanks,

Aditya.

Read only

0 Likes
1,863

thanks
In AL11 the file didn't appear !

Read only

1,863

Put a error message after sy-subrc check. if open dataset fails, then you may have authrisation issue. in that case you need to check with your basis or security team.

Read only

0 Likes
1,863

hi

the problem is the authorization, so i change path and the file is created, now the problem is that my file is empty ^^ if u can give me some help plz !

thanks for all your answers.

Read only

0 Likes
1,863

chkoupi

By debugging your program, even if it runs in background, you will solve the issue on your own.
Read only

RaymondGiuseppi
Active Contributor
1,863

Did you try to add a call of AUTHORITY_CHECK_DATASET before OPEN or handling return code / exception from the OPEN DATASET and TRANSFER statements (and other part of your code)

  • example to illustrate
      OPEN DATASET lv_low FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE mess.
      IF sy-subrc = 8.
        MESSAGE mess TYPE 'E'.
      ELSE.
        LOOP AT gt_flight INTO gs_flight.
          TRY.
            TRANSFER gs_flight TO lv_low.
          CATCH cx_dynamic_check INTO lo_cx_ref.
            mess = lo_cx_ref->if_message~get_text( ).
            MESSAGE mess TYPE 'E'.
          ENDTRY       
        ENDLOOP.
        IF sy-subrc NE 0.
          MESSAGE 'No data read, D''oh!, did I forget to check?' TYPE 'E'.
        ENDIF.
        CLOSE DATASET lv_low.
      ENDIF.