cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading files to SAP(Application Server)

former_member322327
Participant
0 Kudos

Hi everyone:

I developed one program to transfer a internal table to a file in the server.

If I make a job to run this program, the file is not created.

If I run the program like a transaction the file is created and I see the file in AL11 transaction but I don't find the file in the path in Unix (SO).

Any idea about this?

Thanks

Eduardo Campos

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Eduardo,

if you use the open dataset/close dataset sentences, then is very useful to check the return code of after it.

If r.c. <> 0, put a message Exxx -your message-, and maybe, it helps you to find the error.

Hope this help you.

Carles

former_member322327
Participant
0 Kudos

Hi Carles,

I check the return code.

OPEN DATASET p_arch FOR OUTPUT MESSAGE v_msg

IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

MESSAGE e000 WITH v_msg.

ENDIF.

There isn't error.

Former Member
0 Kudos

Hi Eduardo,

why cant u check it in directory 'DIR_SAPUSERS '.

Regards,

kiran

Washington
Explorer
0 Kudos

Eduardo,

if you are using some fm like ws_download, change to the "open/close dataset" command.

former_member322327
Participant
0 Kudos

Hi Washintong,

I user "open/close data set"

OPEN DATASET p_arch FOR OUTPUT MESSAGE v_msg

IN TEXT MODE ENCODING DEFAULT

TRANSFER i_interfase TO p_arch.

CLOSE DATASET: p_arch.

Regards

former_member181966
Active Contributor
0 Kudos

I am assuming that you have object "S_dataset" ( AL11 ) authorizations right ? You’re running background job with your user name?

Like on our site we have different user to kickoff the batch jobs .

Other wise its a good idea to check sy-subrc and if it fails then through message !!

Hope this’ll give you idea!!

<b>P.S award the points.</b>

Good luck

Thanks

Saquib Khan

former_member188685
Active Contributor
0 Kudos

Hi,

Show your Complete code. and it is must to check the sy-subrc after the Open dataset and close dataset.

and are you transfering single record or multiple records. you are not using any loop/endloop for your transfer.

OPEN DATASET p_arch FOR OUTPUT MESSAGE v_msg
IN TEXT MODE ENCODING DEFAULT
if sy-subrc = 0.
TRANSFER i_interfase TO p_arch.
endif.
CLOSE DATASET: p_arch.

can you show your code.

Regards

vijay

former_member322327
Participant
0 Kudos

Hi Saquib:

Yes I'm running the job with my user.

Sorry, but I don't know what is "S_dataset" ( AL11 ) authorizations right

Can you explain me?

Regards.

former_member322327
Participant
0 Kudos

Hi Vijay:

Yes I have a loop:

FORM f_generar_salida .

DATA: lv_saldo TYPE betrw_kk,

lv_ultimo_periodo(8),

lv_cuantos_periodos(4).

*--- DEVK907798 VMJO 22/DIC/2005 (INICIO)

TRANSLATE p_arch TO LOWER CASE.

*--- DEVK907798 VMJO 22/DIC/2005 (FIN)

OPEN DATASET p_arch FOR OUTPUT MESSAGE v_msg

IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

*--- DEVK907786 VMJO 20/DIC/2005 (INICIO)

**--- TEXT-009 Error al abrir archivo de interfase

  • MESSAGE e000 WITH text-009.

*--- TEXT-009 Error al abrir archivo de interfase

MESSAGE e000 WITH v_msg.

*--- DEVK907786 VMJO 20/DIC/2005 (FIN)

ENDIF.

CLEAR: i_salida.

REFRESH: i_salida.

CLEAR: i_interfase.

REFRESH: i_interfase.

v_cont = 1.

v_lin = 5000.

DESCRIBE TABLE i_hrp1000_st LINES v_lines.

v_lines = v_lines / 5000.

v_lines = v_lines + 1.

v_porc = 100 / v_lines.

v_total = v_porc.

LOOP AT i_hrp1000_st.

v_tabix = sy-tabix.

CLEAR i_salida.

IF v_tabix = 1.

*--- text-010 Procesando Estudiantes

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

percentage = v_total

text = text-010.

ENDIF.

IF v_tabix > v_lin.

v_cont = v_cont + 1.

v_lin = 5000 * v_cont.

LOOP AT i_vacia.

ENDLOOP.

v_total = v_porc * v_cont.

*--- text-010 Procesando Estudiantes

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

percentage = v_total

text = text-010.

ENDIF.

*--- Id Estudiante

i_salida-id_st = i_hrp1000_st-objid.

*--- Lee Nombre del Estudiante

READ TABLE i_hrp1702

WITH KEY objid = i_hrp1000_st-objid.

IF sy-subrc EQ 0.

i_salida-nombre_st = i_hrp1702-vorna.

i_salida-apater_st = i_hrp1702-midnm.

i_salida-amater_st = i_hrp1702-rufnm.

ELSE.

i_salida-nombre_st = c_null.

i_salida-apater_st = c_null.

i_salida-amater_st = c_null.

ENDIF.

*--- Lee Nivel de Estudio del Estudiante

READ TABLE i_hrp1705

WITH KEY objid = i_hrp1000_st-objid.

IF sy-subrc EQ 0.

i_salida-nivest_st = i_hrp1705-stgrp.

ELSE.

i_salida-nivest_st = c_null.

ENDIF.

*--- Busca Nombre de Carrera del Estudiante

*--- Lee Objeto de Estudio del Estudiante

READ TABLE i_hrp1001_cs

WITH KEY objid = i_hrp1000_st-objid.

IF sy-subrc EQ 0.

*--- Lee Carrera relacionada al Objeto de Estudio del Estudiante

READ TABLE i_hrp1001_sc

WITH KEY objid = i_hrp1001_cs-sobid_8.

IF sy-subrc EQ 0.

*--- Lee Nombre de la Carrera del Estudiante

READ TABLE i_hrp1000_sc

WITH KEY objid = i_hrp1001_sc-sobid_8.

IF sy-subrc EQ 0.

*--- Nombre de la Carrera

i_salida-nombre_sc = i_hrp1000_sc-mc_short.

ELSE.

i_salida-nombre_sc = c_null.

ENDIF.

ELSE.

i_salida-nombre_sc = c_null.

ENDIF.

ELSE.

i_salida-nombre_sc = c_null.

ENDIF.

*--- Escuela Porcedencia

i_salida-esc_proce = c_null.

v_objid_st = i_hrp1000_st-objid.

*--- Campus del Estudiante

PERFORM f_obtener_campus_st.

IF v_switch = 0.

i_salida-campus_st = v_st_campus.

ELSE.

i_salida-campus_st = c_null.

ENDIF.

*--- Busca Examen de Admisión

*--- Lee Numero de Dato Adicional del Estudiante

READ TABLE i_hrp1001_adm

WITH KEY objid = i_hrp1000_st-objid.

IF sy-subrc EQ 0.

*--- Lee Código de Admisión del Estudiante

READ TABLE i_hrpad530

WITH KEY adatanr = i_hrp1001_adm-adatanr.

IF sy-subrc EQ 0.

*--- Código de Admisión

IF NOT i_hrpad530-adm_code IS INITIAL.

i_salida-examen_adm = i_hrpad530-adm_code.

ELSE.

i_salida-examen_adm = c_null.

ENDIF.

ELSE.

i_salida-examen_adm = c_null.

ENDIF.

ELSE.

i_salida-examen_adm = c_null.

ENDIF.

*--- Matricula

i_salida-matricula = i_hrp1000_st-mc_short.

  • Inicia modificación 30/Mar/06 ECV DEVK908155

  • Saldo del estudiante

CLEAR lv_saldo.

PERFORM f_saldo USING i_hrp1000_st-mc_short

CHANGING lv_saldo.

i_salida-saldo = lv_saldo.

  • Ultimo periodo inscrito y cantidad de periodos en los que ha estado

  • inscrito.

PERFORM f_periodos USING i_hrp1000_st-objid

CHANGING lv_ultimo_periodo

lv_cuantos_periodos.

i_salida-periodo = lv_ultimo_periodo.

i_salida-contador = lv_cuantos_periodos.

  • Termina modificación 30/Mar/06 ECV DEVK908155

APPEND i_salida.

PERFORM f_genera_interfase.

ENDLOOP.

CLOSE DATASET: p_arch.

ENDFORM.

FORM f_genera_interfase .

CLEAR i_interfase.

CONCATENATE i_interfase-linea i_salida-id_st c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-nombre_st c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-apater_st c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-amater_st c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-nivest_st c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-nombre_sc c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-esc_proce c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-campus_st c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-matricula c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-examen_adm c_p

INTO i_interfase-linea.

  • Inicia modificación 30/Mar/06 ECV DEVK908155

CONCATENATE i_interfase-linea i_salida-saldo c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-periodo c_p

INTO i_interfase-linea.

CONCATENATE i_interfase-linea i_salida-contador c_p

INTO i_interfase-linea.

  • Termina modificación 30/Mar/06 ECV DEVK908155

APPEND i_interfase.

TRANSFER i_interfase TO p_arch.

ENDFORM. " f_genera_interfase

former_member181966
Active Contributor
0 Kudos

Yes its authorizations object , which has different read, write value set in your profile . Well if you are able to save it in foreground, then its not the problem .

Why don’t you post your code . We can take a look.

Have you check sy-subrc ?

Hope this’ll give you idea!!

<b>P.S award the points.</b>

Good luck

Thanks

Saquib Khan

former_member322327
Participant
0 Kudos

Yes I check sy-subrc, I post the code some minutes ago.

Regards

former_member188685
Active Contributor
0 Kudos

Hi Campos,

are you calling this perform inside a loop. if so it is really cause you a lot of problem.

since every loop it will open the file, and then it will write the content.

instead you can try like this..

open dataset ..

if sy-subrc = 0.

loop at..

perform .... "with out open dataset

endloop.

close dataset ..

this will open the dataset only once.

Regards

vijay

former_member322327
Participant
0 Kudos

No I don´t open the dataset in a loop. I open dataset only once.

The loop is for read the internal table.

Former Member
0 Kudos

hi Eduardo,

In AL11 search for the file in <b>temp</b> folder..

or else specify the path where u want to download the file in the transaction ....

Regards,

Santosh

former_member322327
Participant
0 Kudos

Hi Santosh:

In AL11 the file is in this folder /usr/sap/tmp/interfase_crm.txt

Regards.

Former Member
0 Kudos

Hi Eduardo,

It should work in back ground job also if you are

writing to appl server.

By any chance your program has any conditions like

sy-batch <> 'X'. please check this.

Thanks&Regards,

Siri.

former_member322327
Participant
0 Kudos

Hi Srilatha,

We don't use sy-batch.

Regards.