В ABAP есть много инструментов классов, функциональных модулей, отчетов, которые позволяют творить практически любые операции над данными. Если ABAP функционала недостаточно, существует возможность воспользоваться командами сервера, благо есть необходимый функционал.
Для начала настроим внешнюю команду в SAP(Транзакция SM69)
И далее вызываем в коде ФМ SXPG_COMMAND_EXECUTE
Код
form createserverdirectory using value(path).
* Parameters for remove command.
data: param1 type sxpgcolist-parameters.
* Return status
data: funcstatus type extcmdexex-status.
* Command line listing returned by the function
data: iserveroutput type standard table of btcxpm.
data: waserveroutput type btcxpm.
* Targetsystem type conversion variable.
data: target type rfcdisplay-rfchost.
* Operating system
data: operatingsystem type sxpgcolist-opsystem.
* Head for split command.
data: head type string..
data: tail type string.
param1 = path.
target = sy-host.
operatingsystem = sy-opsys.
call function 'SXPG_COMMAND_EXECUTE'
exporting
commandname = 'ZMKDIR'
additional_parameters = param1
operatingsystem = operatingsystem
targetsystem = target
stdout = 'X'
stderr = 'X'
terminationwait = 'X'
importing
status = funcstatus
tables
exec_protocol = iserveroutput[]
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.
if sy-subrc = 0.
* Although the function succeded did the external command actually work
if funcstatus = 'E'.
* External command returned with an error
if sy-opsys cs 'Windows NT'.
read table iserveroutput index 1 into waserveroutput.
if waserveroutput-message ns 'already exists'.
* An error occurred creating the directory on the server
message e000(oo) with 'An error occurred creating a directory'.
endif.
else.
read table iserveroutput index 2 into waserveroutput.
split waserveroutput-message at space into head tail.
shift tail left deleting leading space.
if tail <> 'Do not specify an existing file.'.
* An error occurred creating the directory on the server
message e000(oo) with 'An error occurred creating a directory'.
endif.
endif.
endif.
else.
case sy-subrc.
when 1.
* No permissions to run the command
message e000(oo) with 'No permissions to run external command ZMKDIR'.
when 2.
* External command not found
message e000(oo) with 'External comand ZMKDIR not found'.
when others.
* Unable to create the directory
message e000(oo) with 'An error occurred creating a directory'
', subrc:'
sy-subrc.
endcase.
endif.
endform."createServerDirectory
Комментариев нет:
Отправить комментарий