Difference between revisions of "SAP ABAP UNIX"
From SapWiki
Line 1: | Line 1: | ||
+ | ==Ejecutar comando de sistema operativo== | ||
+ | (Los comandos se definen en la tran. SM69) | ||
+ | Función SXPG_COMMAND_EXECUTE | ||
+ | |||
+ | ejemplo: | ||
+ | |||
+ | FORM mueve_ficheros USING p_file p_dir p_dire CHANGING p_subrc. | ||
+ | |||
+ | DATA: BEGIN OF lt_btcxpm OCCURS 0. | ||
+ | INCLUDE STRUCTURE btcxpm. | ||
+ | DATA: END OF lt_btcxpm. | ||
+ | DATA: l_para LIKE sxpgcolist-parameters, | ||
+ | l_aux_dir1(200), | ||
+ | l_aux_dir2(200), | ||
+ | l_string TYPE string. | ||
+ | |||
+ | CONCATENATE p_dir '/' p_file INTO l_aux_dir1. | ||
+ | CONCATENATE p_dire '/' p_file INTO l_aux_dir2. | ||
+ | CONCATENATE l_aux_dir1 l_aux_dir2 INTO l_para SEPARATED BY space. | ||
+ | |||
+ | IF sy-subrc <> 0. | ||
+ | * Implement suitable error handling here | ||
+ | ENDIF. | ||
+ | |||
+ | CALL FUNCTION 'SXPG_COMMAND_EXECUTE' | ||
+ | EXPORTING | ||
+ | commandname = 'ZMV' | ||
+ | additional_parameters = l_para | ||
+ | TABLES | ||
+ | exec_protocol = lt_btcxpm | ||
+ | EXCEPTIONS | ||
+ | no_permission = 1 | ||
+ | command_not_found = 2 | ||
+ | parameters_too_long = 3 | ||
+ | security_risk = 4 | ||
+ | wrong_check_call_interface = 5 | ||
+ | program_start_error = 6 | ||
+ | program_termination_error = 7 | ||
+ | x_error = 8 | ||
+ | parameter_expected = 9 | ||
+ | too_many_parameters = 10 | ||
+ | illegal_command = 11 | ||
+ | wrong_asynchronous_parameters = 12 | ||
+ | cant_enq_tbtco_entry = 13 | ||
+ | jobcount_generation_error = 14 | ||
+ | OTHERS = 15. | ||
+ | p_subrc = sy-subrc. | ||
+ | |||
+ | IF sy-subrc <> 0. | ||
+ | CASE sy-subrc. | ||
+ | WHEN 1. | ||
+ | MESSAGE e010(0t) WITH 'Sin autorizacion para comando OS ZMV' INTO l_string. "#EC NOTEXT | ||
+ | WHEN 2. | ||
+ | MESSAGE e010(0t) WITH 'Comando OS ZMV no existe' INTO l_string. "#EC NOTEXT | ||
+ | WHEN OTHERS. | ||
+ | MESSAGE e010(0t) WITH 'ZMV errorcode: ' sy-subrc INTO l_string. "#EC NOTEXT | ||
+ | ENDCASE. | ||
+ | |||
+ | WRITE:/ l_string. | ||
+ | ENDIF. | ||
+ | ENDFORM. | ||
+ | |||
+ | |||
+ | |||
==PUT/GET archivos a/desde servidor FTP== | ==PUT/GET archivos a/desde servidor FTP== | ||
− | |||
Funciones: FTP_CONNECT, FTP_COMMAND, FTP_R3_TO_CLIENT, FTP_SERVER_TO_R3 | Funciones: FTP_CONNECT, FTP_COMMAND, FTP_R3_TO_CLIENT, FTP_SERVER_TO_R3 | ||
Programa ejemplo: RSFTP003 | Programa ejemplo: RSFTP003 |
Revision as of 14:43, 2 April 2020
==Ejecutar comando de sistema operativo== (Los comandos se definen en la tran. SM69) Función SXPG_COMMAND_EXECUTE
ejemplo:
FORM mueve_ficheros USING p_file p_dir p_dire CHANGING p_subrc. DATA: BEGIN OF lt_btcxpm OCCURS 0. INCLUDE STRUCTURE btcxpm. DATA: END OF lt_btcxpm. DATA: l_para LIKE sxpgcolist-parameters, l_aux_dir1(200), l_aux_dir2(200), l_string TYPE string. CONCATENATE p_dir '/' p_file INTO l_aux_dir1. CONCATENATE p_dire '/' p_file INTO l_aux_dir2. CONCATENATE l_aux_dir1 l_aux_dir2 INTO l_para SEPARATED BY space. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. CALL FUNCTION 'SXPG_COMMAND_EXECUTE' EXPORTING commandname = 'ZMV' additional_parameters = l_para TABLES exec_protocol = lt_btcxpm EXCEPTIONS no_permission = 1 command_not_found = 2 parameters_too_long = 3 security_risk = 4 wrong_check_call_interface = 5 program_start_error = 6 program_termination_error = 7 x_error = 8 parameter_expected = 9 too_many_parameters = 10 illegal_command = 11 wrong_asynchronous_parameters = 12 cant_enq_tbtco_entry = 13 jobcount_generation_error = 14 OTHERS = 15. p_subrc = sy-subrc. IF sy-subrc <> 0. CASE sy-subrc. WHEN 1. MESSAGE e010(0t) WITH 'Sin autorizacion para comando OS ZMV' INTO l_string. "#EC NOTEXT WHEN 2. MESSAGE e010(0t) WITH 'Comando OS ZMV no existe' INTO l_string. "#EC NOTEXT WHEN OTHERS. MESSAGE e010(0t) WITH 'ZMV errorcode: ' sy-subrc INTO l_string. "#EC NOTEXT ENDCASE. WRITE:/ l_string. ENDIF. ENDFORM.
PUT/GET archivos a/desde servidor FTP
Funciones: FTP_CONNECT, FTP_COMMAND, FTP_R3_TO_CLIENT, FTP_SERVER_TO_R3 Programa ejemplo: RSFTP003
Unix Varios
Trn. SM69 : Comandos Sistema Operativo FM. BRAN_DIR_CREATE : crear directorio (ojo con las validaciones internas pero se puede usar de base) Trn. CG3Z / Reporte RC1TCG3Z : Upload fichero a servidor Trn. CG3Y / Reporte RC1TCG3Y : Download fichero desde servidor FM. CACS_FILE_COPY : copiar de servidor a PC y viceversa Rep. RSBDCOS0 : Ejecutar comando SO (grabado en log sistema y ficheros Trace)