2007 Feb 05 1:14 AM
Hi Gurus,
My req. is like this ....
I need to collect data related to primary key from different DD tables and put them into a file and send it to Unix server.
For this I know that I need to use OPEN DATASET & CLOSE DATASET.
But my problem is .....
I have to put | ( pipe symbol) as seperator between the fields.
Another problem is ...if the field value is absent..then I need to put || ( double pipe symbol) between the fields.
I don't know how to do these ...anyone please help me doing this.
Thanks in Advance,
Ramana
2007 Feb 05 1:34 AM
while moving the data to the final internal table which u need to send to unix server, use the CONCATENATE statement between the fields.
concatenate IS_STR-STR IS_UNIX-SUPP_NO into IS_STR-STR separated by '|'.
This will create the file with | as field seperator.
EXAMPLE :
<b>loop at IT_UNIX into IS_UNIX.
if not IS_UNIX-field1 is initial.
shift IS_UNIX-MO left deleting leading '0'.
concatenate IS_STR-STR IS_UNIX-field1 into IS_STR-STR.
else.
concatenate IS_STR-STR IS_UNIX-field1 into IS_STR-STR.
endif.
if not IS_UNIX-field2 is initial.
shift IS_UNIX-field2 left deleting leading '0'.
concatenate IS_STR-STR IS_UNIX-field2 into IS_STR-STR separated by '|'.
else.
concatenate IS_STR-STR IS_UNIX-field2 into IS_STR-STR separated by '|'.
endif.
clear : is_unix.
endloop.</b> " similar to ur requirement.
Regards
Gopi
2007 Feb 05 1:34 AM
while moving the data to the final internal table which u need to send to unix server, use the CONCATENATE statement between the fields.
concatenate IS_STR-STR IS_UNIX-SUPP_NO into IS_STR-STR separated by '|'.
This will create the file with | as field seperator.
EXAMPLE :
<b>loop at IT_UNIX into IS_UNIX.
if not IS_UNIX-field1 is initial.
shift IS_UNIX-MO left deleting leading '0'.
concatenate IS_STR-STR IS_UNIX-field1 into IS_STR-STR.
else.
concatenate IS_STR-STR IS_UNIX-field1 into IS_STR-STR.
endif.
if not IS_UNIX-field2 is initial.
shift IS_UNIX-field2 left deleting leading '0'.
concatenate IS_STR-STR IS_UNIX-field2 into IS_STR-STR separated by '|'.
else.
concatenate IS_STR-STR IS_UNIX-field2 into IS_STR-STR separated by '|'.
endif.
clear : is_unix.
endloop.</b> " similar to ur requirement.
Regards
Gopi
2007 Feb 05 1:51 AM
Hi Narendra ,
Can you please put this code along with the <b>open data set and close data set</b> ?
This is the first time I am doing this requirement.I am not able to complete the code.
How do I put this <b>IT_UNIX</b> data /records into a file?
I was not able to write the correct code ...please help me out.
Thanks
2007 Feb 05 1:56 AM
Hi,
data : IT_STR type standard table of TY_STR,
IS_STR type TY_STR.
data : UNIX_FILE type RLGRAP-FILENAME.
IT_UNIX is the final internal table without seperators.
IT_STR is the internal table with seperators.
loop at it_unix into is_unix.
now use the logic in my previous thread for concatenation IT_STR with seperators
endloop.
Open Dataset
catch system-exceptions DATASET_CANT_OPEN = 8.
open dataset UNIX_FILE for output in text mode encoding default.
endcatch.
Write to Dataset
loop at IT_STR into IS_STR.
catch system-exceptions DATASET_NOT_OPEN = 0 .
transfer IS_STR-STR to UNIX_FILE.
endcatch.
clear : IS_STR.
endloop.
Close Dataset
close dataset UNIX_FILE.
Regards
Gopi
2007 Feb 05 2:13 AM