06-02-2009 2:32 PM
Hi Experts,
I have three jobs and each job creates a file. I want to run one more job which clubs these three files and merges it in to one.
I know the process of opening each file and appending it in to the target file using DATASET concept.
Instead of that, I want any UNIX Shell command so that I can call that directly from ABAP and execute it
Any help on this would be highly appreciated
Thanks in advance.
Babu Kilari
06-02-2009 3:02 PM
Hello Babu,
We can very well call an OS command from within ABAP, but in your case, I don't think that is really required. Please find below a logic that might be helpful to you.
You have three files, whose contents needs to be merged into a single file.
Read the contents of each file and store it into an internal table.
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'cat /tmp/file1.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.
Internal table 'tabl' will contain the contents of the file.
Accumulate all the contents into a single file and upload to the application server using OPEN DATASET, TRANSFER DATASET and CLOSE DATASET.
Let me know if you need a more detailed explanation.
Regards
Sabu.
06-02-2009 3:02 PM
Hello Babu,
We can very well call an OS command from within ABAP, but in your case, I don't think that is really required. Please find below a logic that might be helpful to you.
You have three files, whose contents needs to be merged into a single file.
Read the contents of each file and store it into an internal table.
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'cat /tmp/file1.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.
Internal table 'tabl' will contain the contents of the file.
Accumulate all the contents into a single file and upload to the application server using OPEN DATASET, TRANSFER DATASET and CLOSE DATASET.
Let me know if you need a more detailed explanation.
Regards
Sabu.
06-02-2009 3:04 PM
My main aim here is to eliminate one more internal table. Because, there will be lakhs of records and i dont want to loop on that final internal table using DATASET.
Simple Unix Command which combines the three files should do. Thats what I am searching for..
Thanks,
Babu Kilari
06-02-2009 3:25 PM
Try this:
DATA: command LIKE rs37a-line.
DATA: BEGIN OF tabl OCCURS 0,
line(2000),
END OF tabl.
command = 'cat /tmp/file1.txt /tmp/file2.txt /tmp/file3.txt > /tmp/file4.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD command
ID 'TAB' FIELD tabl-*sys*.
Regards
Sabu.
06-13-2009 1:18 PM