‎2008 Nov 21 10:52 AM
Hi Experts,
As part of an interface implementation, i need to create and delete directories.
I am using the following method to create directory on our Unix sap server.
*to create directory
CONCATENATE
'mkdir'
LV_DIR
INTO UNIXCOM
SEPARATED BY SPACE.
CALL 'SYSTEM' ID 'COMMAND' FIELD UNIXCOM
ID 'TAB' FIELD TABL[].
I am getting sy-subrc = -1 but directory is created. Same is the case with Delete directory.
How to ensure whether directory is created or not from sy-subrc?
I think ideally i should get sy-subrc = 0, but why am i getting -1?
pls help to resolve this problem.
Many thanks,
Simha
‎2008 Nov 21 12:01 PM
CONCATENATE
'mkdir'
LV_DIR
INTO UNIXCOM
SEPARATED BY SPACE.
CALL 'SYSTEM' ID 'COMMAND' FIELD UNIXCOM
ID 'TAB' FIELD TABL[].
*Loop and write the contents og the internal table that should help you.
loop at itabl.
write/:itabl-line.
endloop.
Regards
Neha
‎2008 Nov 21 12:53 PM
Hi Neha,
The contents of the table is empty.
This will be run in the background, so i would not know and will not be able to decide on the contents of the retuned Internal table TABL[]
Am i supposed to get sy-subrc = 0 ?
Pls help.
Thanks,
Simha
‎2008 Nov 21 5:49 PM
Hello,
I think that we ran into this situation during an upgrade. The sy-subrc used to be 0 if
successful and then after the upgrade it changed to -1.
The command was always successful even though the return code was -1 and the
return table was always empty.
Another way to do this is to create OS commands in SM69 and thne execute them with the
FM: SXPG_COMMAND_EXECUTE. If you do this you avoid using a 'feature' that is not
offically supported by SAP ( is CALL SYSTEM).
Regards
Greg Kern
‎2008 Nov 24 4:59 AM
Hi Greg Kern,
Thanks for your inputs. Points noted, but what could be the reason for this change?
But can i take sy-subrc = -1 as success always?
regards,
Simha
‎2008 Nov 24 5:52 PM
Hello Simha,
We did assume that -1 was a successful return from the call system. However, since
we could not assume that this would not change in the future we worked at converting
the call systems to call fm sxpg*.
As for a reason, the call system method is not officaily supported by SAP so then can
change whatever they want to with no notice or explanation.
Regards
Greg Kern
‎2008 Nov 25 10:34 AM
Hi Greg Kern,
Thanks for your inputs.
I will try this by entering in system commands thru sm69.
I am closing this thread.
Regards,
Simha
‎2019 Jun 21 8:37 PM
Hey,
I am getting return code 2 for my command. I am trying to decrypt a file using linux command. What does the return code 2 mean? I didn't find anything on SAP help yet.
Regards,
Avinash Vaishya
‎2019 Jun 22 10:25 AM
Avinash Vaishya it's normal that you don't find anything on SAP help because all C programs are undocumented and you shouldn't call them. Instead of CALL 'SYSTEM', you should use the official and documented way: define your OS command (mkdir or whatever you want) via transaction code SM49, and call it via the function module SXPG_COMMAND_EXECUTE (documentation supplied within the function module itself).