Logical command in ABAP.....Urgent
Hi,
i am pretty new using ABAP program so i neeed help urgently. i am trying to move a file on the application server from one directory to the other and i was using the open dataset function to do that. but the file i am trying to move is pretty big and because i am using internal table to store, it is causing problems with the space.
i have consulted the basis guys and they have managed to create a logical file for copying from one directory to the other on the application server. to help you furthter. i am enclosing the mail sent to me.
I have created a logical command which should copy the file from one location to the other but you need to pass it the source dir and file name and the destination dir and file name.
The logical command is ZCOPY and uses cmd /c copy
Copies one or more files to another location.
COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
[+ source [/A | /B] [+ ...]] [destination [/A | /B]]
source Specifies the file or files to be copied.
/A Indicates an ASCII text file.
/B Indicates a binary file.
destination Specifies the directory and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/N Uses short filename, if available, when copying a file with a
non-8dot3 name.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line. Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.
the problem now is i have no idea about how to use the logical command. can any one help me.
Thank you,
Ravi.
If memory is not an issue, then there should be no reason why this should not work.
report zrich_0001.
parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
data: itab type table of string with header line.
start-of-selection.
* Read old file
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into itab.
if sy-subrc <> 0.
exit.
endif.
append itab.
enddo.
endif.
close dataset d1.
* Write to new file
open dataset d2 for output in text mode.
loop at itab.
transfer itab to d2.
endloop.
close dataset d2.
* Delete the old file
delete dataset d1.
Regards,
Rich Heilman
Similar Messages
-
Logical Database in Abap Objects
Hi to All
I want do it a program report using a Logical Database.
Is this possible ??? But when I make a GET <node>, occurs the following error:
"" Statement "ENDMETHOD" missing. ""
I'm doing the following:
CLASS MONFIN IMPLEMENTATION.
METHOD TRAER_DATOS.
GET VBRK.
ENDMETHOD.
ENDCLASS.
Please, somebody tell me how I use the logical database in Abap Objects.
Thank you very much
Regards
Dario R.Hi there
Logical databases whilst of "some use" are not really part of OO.
If you want to use a logical database in an abap OO program I would create a special class which just does the get data from your DB and pass this either at record or table level.
Techniques such as GET XXXX LATE aren't really part of any OO type of application since at Object Instantiation time you should be able to access ALL the attributes of that object.
As far as OO is concerned Logical databases are a throwback to "Dinosaur Technology".
Since however modules such as SD and FI are still heavily reliant on relational structures (i.e linked tables etc) then there is still some limited life in this stuff but for OO try and solve it by another method.
If you really must use this stuff in OO then do it via a FMOD call and save the data in a table which your method will pass back to your application program.
You can't issue a GET command directly in a method.
Cheers
Jimbo -
I want to execute UNIX COMMAND in ABAP
Hi All,
I want to execute a UNIX XOMMAND sh <scriptname> <filename> to replace divsion codes.in ABAP.
But, I came to know that we can't (2) or try the following program but unfortunately the command CALL SYSTEM is not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the program SAPMSOS0.
REPORT ZUNIXCOM .
DATA: U_COMMAND(200).
Table for system messages
DATA: BEGIN OF RT OCCURS 100 ,
LINE(100) ,
END OF RT .
START-OF-SELECTION .
MOVE 'unix command' to U_COMMAND .
REFRESH RT.
CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND
ID 'TAB' FIELD RT-SYS .
LOOP AT RT.
WRITE : / RT-LINE .
ENDLOOP.
So please can u help me how to call a unix command from ABAP. it is very urgent. I want complete details and all possible solutions
<removed_by_moderator>
Thanks,
gyanaraj
Edited by: Julius Bussche on Aug 26, 2008 11:29 AMSelvaraj Gyanaraj wrote:>
> So please can u help me how to call a unix command from ABAP.
I was about to help you.
>it is very urgent.
I changed my mind.
>I want complete details and all possible solutions
I'm glad I changed my mind.
>Points are surely rewarded.
Too late. -
Please tell me how to execute DOS commands from within ABAP.
1.create your shell script your_shell_script.sh:
src=$1
dst=$2
mv -f $src $dst
2. Create your command Z_YOUR_COMMAND using SM69:
- Operating system command: /bin/sh (the path to your shell interpretator)
- Parameters for operating system command:
/home/sap/bin/your_shell_script.sh (the path to your shell script)
- Set "Additional parameters allowed" checkbox
3. Call your command from ABAP:
data:
param type sxpgcolist-parameters.
status type extcmdexex-status,
exitcode type extcmdexex-exitcode,
it_log type table of btcxpm.
p_src = '/common/home/edw/parsekb/b2/*'.
p_dst = '/common/home/edw/parsekb/b1'.
concatenate p_src p_dst into param separated by space.
CALL FUNCTION 'SXPG_CALL_SYSTEM'
EXPORTING
COMMANDNAME = 'Z_YOUR_COMMAND'
ADDITIONAL_PARAMETERS = param
IMPORTING
STATUS = status
EXITCODE = exitcode
TABLES
EXEC_PROTOCOL = it_log
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
OTHERS = 99.
if sy-subrc <> 0.
*TODO: add your error handling logic
endif. -
Logical command...
Hello,
Please help me on how to use the logical command.
Here is the details of my problem.
In program, a flat file is created and put on the file system. Right after storing the flat file on the file system, an additional logical command needs to be called that starts an FTP script.
logical command: Z_POSTING_PUT
The problem is, I don't know how to use the said logical command. Can any body help me please....
Thanks a lot.
massiveit is used to connect the various external system..
the commond varies according to the system you are using
it can be seen in SM49 transaction and according you need to chose that
* connect to the FTP server and send the files.
* Calculate password length
u201C password used for connection
v_slen = strlen( ppwd ).
* Encrypt password
call function 'HTTP_SCRAMBLE'
exporting
source = ppwd
sourcelen = v_slen
key = v_key
importing
destination = v_encrypted_pwd.
* Connect to destination server
call function 'FTP_CONNECT'
exporting
user = puser
password = v_encrypted_pwd
host = phost u201CHost address
rfc_destination = c_rfc_destination u201Cit is a constant c_rfc_destination type rfcdes-rfcdest value 'SAPFTPA'.
importing
handle = v_handle
exceptions
not_connected.
if sy-subrc <> 0.
message e002 with phost sy-subrc.
endif.
refresh it_result.
refresh it_commands.
Commands will depend on which OS is being used on server side and client side.
This code is for unix machines
* change the directory on the destination machine
concatenate 'cd' prpath into wa_command-line separated by space.
append wa_command to it_commands.
* Change the local directory on the sap server
concatenate 'lcd' plpath into wa_command-line separated by space.
append wa_command to it_commands.
* Set Ascii mode
clear wa_command-line.
if pbin eq 'X'.
move 'bin' to wa_command-line.
else.
move 'asc' to wa_command-line.
endif.
append wa_command to it_commands.
* files to be transferred
loop at it_list into wa_list.
* Put the file from the sap server to the destination machine
concatenate 'put' wa_list-name wa_list-name
into wa_command-line separated by space.
append wa_command to it_commands.
endloop.
* Send FTP commands to server
call function 'FTP_COMMAND_LIST'
exporting
handle = v_handle
importing
command_index = v_command_index
tables
data = it_result
commands = it_commands
exceptions
command_error = 1
tcpip_error = 2.
v_subrc = sy-subrc.
if v_subrc ne 0.
* if there is an error disconnect from the server
* and display an appropriate message
perform ftp_disconnect using v_handle c_rfc_destination.
message e004.
endif.
form ftp_disconnect using
in_handle
in_rfc_destination.
* Disconnect from destination server
call function 'FTP_DISCONNECT'
exporting
handle = in_handle.
* Close RFC connection
call function 'RFC_CONNECTION_CLOSE'
exporting
destination = in_rfc_destination
exceptions
others = 1.
endform. "ftp_disconnect -
Is it possible to call ms-dos command in abap program?
Hi,
is it possible to call ms-dos command in abap program?
Thanks.Hi Cemil,
You probably have your answer here:
[Re: DOS/Windows command in app server;
You create your external command with SM69 (you can test it with SM49).
Then you call this command with function module "SXPG_COMMAND_EXECUTE".
(See function group SXPT for all the calls to external commands).
Regards,
Thomas -
AT NEW command in ABAP Objects
Hi everyone!
Is there an equivalent of the AT NEW command in abap oo? When I try to use this command inside a BAdi, I get an error message.
Best Regards,
Luís.Hi,
Thank you for your response
Sample code:
LOOP AT c_t_data ASSIGNING variants are no longer supported in the OO context. Use dynamic variants instead.
Regards,
Luís. -
Hi All,
I need to use unix command (MOVE) in ABAP code for transfering a file from one directory to another directory.
Can any one help with how to used unix commands in ABAP?
Thanks in advance.
Regards,
HemendraThe recommended approach always used to be to use transaction SM69 to define a "soft" command name to the operating system command so that it could be configured to work across Windows, Unix etc. For example:
Command name OS Type OS command Parameters for operating system command
Z_FILE_MOVE SunOS Customer mv ? ?
You can then call function module SXPG_COMMAND_EXECUTE (quite well documented) to actually perform the command passing in the appropriate number of parameters.
Jonathan -
Command in ABAP Editor to improve the source code
Which command in ABAP Editor to be used to improve the readability of the program code ?plzz tell
Edited by: Alvaro Tejada Galindo on Feb 13, 2008 3:48 PMUse Pretty Printer or do a CTRL+F1.
Also u can change the settings of the way u want preety printer to behave by
going in the Settings->Abap Editor -> Pretty Printer -
Hi,
I need to call the following unix command in ABAP to encrypt a file on the app server .
crypt password <org filename> new_filename
1 But when i run it using call 'SYSTEM' .. i get message security risk , command not executed ..
2 I also created the command in SM69 and tries to run it but same error.
3 I also created a shell script , but i get another message when i try to run sh ...
Please help to find out a way to make it work ..
KunalHi kunal,
1. probably ur basis team might be able to help u.
2. even if we have authorisations thru sap
to run external os command,
the actual OS user on application server
must have the right for it
and access/write/read/modify
for the files (provided thru the command)
in question.
3. Due to this , the systems gives the message
of SECURITY RISK.
regards,
amit m. -
Hi All difference between abap and hr-abap urgent pls
Hi All difference between abap and hr-abap urgent pls
Hello,
To add to the above points regarding infotypes
Infotypes stand apart in HR and manage a volume of data in HR domain..they are unique to HR module ranging from basic employee information to time management and finally the custom infotypes.....
Payroll and other monetory activities related to an employee also form a vital part of the HR module....
while considering Reports..in HR data is mainly with respect to infotypes and the concept of PAKEY...7 key fields which uniquely defines any record in an infotype is used..with Pernr(employee number),Begda(begindate) and Endda(enddate) form an integral part of the key..Based on the time constraints(1,2,3) of an infotype the keys are judged (to retrieve data from an infotype)
In ABAP HR we also have lots of predefined function modules that can be used..eg:go to se37..put 'HR*' and press F4...
finally to update an HR infotype record we use the function module hr operation rather than direct updates...also there are standard audit trail reports that monitors various activities such as insert/modify/delete operations on an hr infotype record...
Pls revert back for clarity and reward if helpful
Regards
Byju -
Problem using logical port type "ABAP"
Hi, my problem is that I have to save a txt file with a certanly format who feeds from an IDOCs that is sended nowhere.
Instead of using a BADI the client wants that every time a PO is liberated an IDOC has to be triggered and it has to save that txt in a path, but that IDOC is not sended anywhere is just for saving the file. Dont ask why... they want to do this approach.
So I created a logical port of type ABAP, copy the function "OWN_FUNCTION" as a template and in my custom function I parse the IDOC and save the file... it works. My problem is that the IDOC is created when a PO is created but not triggered !!!
The IDOC is created with status 30 (ready to send).
What I need is that when the PO is saved the file has to be generated in the server but the function is not triggered. I try running the Program RSEOUT00 and the IDOC is not found (dont know why) the only way I can trigger the IDOC is via BD87.
Someone could help me, I dont know why the logical port type ABAP is not triggered. all my setting in WE20 is right.
ThxThe problem was in the WE20, the radio button was in mode 4 (collect IDOCs) instead of 2 (send inmediatly)
-
How to execute os command from ABAP program?
I want to execute some window commands from ABAP. What is the way to do it?
Hi,
See ht e coding below, I have used these Fm to connect to FTP server and get the Files..
*types for the ftp command result internal table
TYPES : BEGIN OF ty_result,
text TYPE char512,
END OF ty_result.
data it_result type standard table of ty_result.
*Connect to the FTP server
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = lv_user " user name pass word to connect
password = l_v_pwd
host = 'dev.eu.pm.com' " Host name here
rfc_destination = 'SAPFTPA' "destination name
*Ask your functional people for the above data
IMPORTING
handle = v_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*Changing directory
CONCATENATE 'cd' '<file path>' INTO l_v_cmd SEPARATED BY space.
you can also ser 'DIR in l_v_cmd which opens the directory and all the folders *get into it_result table..
*Execute the FTP Command
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = v_handle
command = l_v_cmd
TABLES
data = it_result
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
rewards if useful,
regards,
nazeer -
CALCULATE_DIFFERENCE Logic command purpose and usage
Experts,
Recently we are facing the issue of send governor hanging issue and it's causing one of the appserver goes down automatically when users send data using input schedules ,to fix this kind of issues one of the experts suggeted us we should use CALCULATE_DIFFERENCE logic command in the default logic, this is not a permanent fix though but if we use this command the send governor will be active until it reaches the certain no.of sends, for example 20 to 30 , after that we need to manually restart the send governer service.
But as far as I know the purpose of this CALCULATE_DIFFERENCE is at what time delta value should calculated i.e either execution of the logic or posting of the values.
In general when do we use this CALCULATE_DIFFERENCE command? is this command mandatory to include in the logic?
what are the impacts of this command if we include in the logic as currently we are not using command in any of the logic?
How does CALCULATE_DIFFERENCE command affect the send governor service ?
Is there any relation ship between CALCULATE_DIFFERENCE command and send governor service ?
Any help will be apprecited greatly! ThanksHi Krishna,
The CALCULATE_DIFFERENCE option allows you to turn off or on the write back by difference.
Here is some further info:
When posting values, BPC needs to write in the database just the difference between what is already stored and the new value. The calculation of the difference takes time. If such calculation is performed directly by the Logic Module at the time of executing the logic, it is possible that the subsequent posting time will be reduced. This is what the logic module does by default. To override the default, the following instruction can be entered in a logic file:
*CALCULATE_DIFFERENCE = 0 (default is 1)
When the calculation of the difference is turned off, the write engine is instructed of the change in behavior and takes over the job of calculating (and posting) the difference, so that the final values will be correct. The main reason for using this instruction is that the debug file will show the values exactly as the user expects them to look like in the fact tables.
Thanks,
John -
ABAP-Logic/Command: Execute An Expression Stored In A Variable
Consider the following code - <b>Is it possible to execute the statement/expression stored in variables expression1, expression2 and expression3?</b> The result should be:
sum = 5 , subname = 'First' & i_output should be sorted by lifnr and ebeln.
*---DATA DECLARATIONS
DATA: sum TYPE i,
op1 TYPE i,
op2 TYPE i,
name TYPE string,
subname TYPE string,
offset TYPE i,
expression1 TYPE string,
expression2 TYPE string,
expression3 TYPE string.
DATA: BEGIN OF i_output OCCURS 0,
lifnr TYPE lfa1-lifnr,
ebeln TYPE ekko-ebeln,
ebelp TYPE ekpo-ebelp,
END OF i_output.
*---BUILD EXPRESSION 1
op1 = 2.
op2 = 3.
expression1 = 'sum = op1 + op2'.
*---BUILD EXPRESSION 2
name = ' First Name'.
offset = 5.
expression2 = 'subname = name+1(offset)'.
*---POPULATE ITAB I_OUTPUT
MOVE: '111111' TO i_output-lifnr,
'PO1' TO i_output-ebeln,
'010' TO i_output-ebelp.
APPEND i_output.
MOVE: '111511' TO i_output-lifnr,
'PO1' TO i_output-ebeln,
'020' TO i_output-ebelp.
APPEND i_output.
MOVE: '111111' TO i_output-lifnr,
'PO3' TO i_output-ebeln,
'010' TO i_output-ebelp.
APPEND i_output.
MOVE: '114111' TO i_output-lifnr,
'PO2' TO i_output-ebeln,
'010' TO i_output-ebelp.
APPEND i_output.
MOVE: '111121' TO i_output-lifnr,
'PO2' TO i_output-ebeln,
'020' TO i_output-ebelp.
APPEND i_output.
CLEAR i_output.
*---BUILD EXPRESSION 3
expression3 = 'sort i_output by lifnr ebeln'.
Thanks in advance!> You can achieve this by generating a subroutine pool
> dynamically, passing the code lines (expressions) as
> an internal table. Here is the syntax:
>
> GENERATE SUBROUTINE POOL itab NAME name.
>
> Hope this helps,
> Bhanu
Hey Banu, thanks!
Message was edited by: Sam
Maybe you are looking for
-
Report to show breakdown of a particular WBS number
Hi SAP Experts, Is there any report in SAP that I could see a breakdown of costs posted against a particular WBS number. So in other words, I have a WBS number refering to a project and I want to run a report to show me what invoices have been posted
-
Some of my albums track lists are incorrect in my iPod
I've noticed this problem with my iPod probably a week or so after I bought it. It is a brand new 80 gb iPod. What is happening is that a few of my albums on my iPod list the tracks incorrectly. I've noticed this happening with about a dozen of my al
-
How to remove the border from an AWT Component (specifically a ScrollPane)
I've been trying to remove the border from an AWT ScrollPane, but having no luck. I've tried setting the bounds on the ScrollPane to get rid of the border: ScrollPane scrollPane = new ScrollPane(); scrollPane.setBounds(-2, -2, getSize().width+4, getS
-
All, I am learing Sap basis individually and am looking any paid website for IDES.Basically I want to practise by installing the different SAP systems using the paid web site.Pls let me know from the experts who already made use of IDES training web
-
I need to make an multidimensional array solving a maze problem in which the maze has a series of dots (ie 3x6 3 dots down and 6 across in rows) and you have to get to the bottom corner starting from the top corner only moving down and to the right o