Help Reqd Using SPOOL
Hi,
I am using SPOOL command to save result returned by the SQL command to a file.
1. In the select statement I have 10 fields being retrieved, how do I separate them by comma when the result in written to the file.
2. The result for one record in not stored in one line in the file. It is distributed in 2-3 lines. How do I a make sure that each record retrieved corresponds to one line in the file saved.
My ultimate is to generate a CSV file from the result retrieved by the SQL statement.
Thanks in advance,
Raja
I guess the answers to your questions do not need a master degree in IT, but for once...
1. In the select statement I have 10 fields being
retrieved, how do I separate them by comma when the
result in written to the file.Either use SELECT col1, ',', col2... or, if using SQL*PLUS, do set the COLSEP to fit your needs.
>
2. The result for one record in not stored in one
line in the file. It is distributed in 2-3 lines. How
do I a make sure that each record retrieved
corresponds to one line in the file saved.Try SET LINESIZE. It's amazing what a bit of curiosity can do... ;)
Similar Messages
-
Email multiple spools from background job - SM36 using Spool List recipient
I create a background job using Spool List Recipient to email me the reports. The program that I scheduled to run creates 2 spools. When the spools are sent via email, only the last spool is sent.
Please advise on how I can get the 2 spools sent via email.i would not use the Spool List recipient from Job and use the function RSPO_SPOOLJOB_TO_OFFICE in your Program instead.
tell me if it helps.
Regards,
Laurent -
Preserve a single space at the end of line using spool command
Hi,
Can you please help me to write the result of an sql query into a file with the last column of the row ending with a single space?
For example:
COL1DATA|COL2DATA|COL3DATA<space1>
As mentioned in the example the col3 value in the file should end with a single space. And there should not be any delimiters at the end of the row.
I tried with set trimspool on/off. But, it didn't work. When I say trimspool on - it is trimming all the trailing spaces.
When I say trimspool off - it is retaining all the trailing spaces to the size of the line.
But, I do not wish to modify the file through shell commands once it is written thru spool. I mean I do not wish to append spaces to the end of a line using shell script or any other method.
I do not wish to use other methods like UTL_FILE also.
Please help me how to do it using spool command?
Thank you.
RamanaMy requirement is that all the trailing spaces should be truncated except the last one in the row.Why?
As you have discovered a single column in sqlplus, is always a fixed length regardless of the size of the data, if the length of the data varies the output is padded to the maximum or line size with spaces. The trim and trimpsool commands are there to remove all the spaces from the end of a line if there are any. There are no commands to trim all the spaces except one, or even to trim all the spaces except two, or three even.
If you want such custom processing you should post process the file in the OS using sed, awk or perl or something designed for such things. -
Urgent Help Reqd: Delta Problem....!!!
Hi Experts,
Urgent help reqd regarding follwoing scenario:
I am getting delta to ODS 1 (infosource : 2LIS_12_VCHDR) from R/3. Now this ODS1 gives delta to Cube1. I got one error record which fails when going to cube (due to master data check).And this record would be edited later.
So I thought of re loading cube and using error handling to split request in PSA and load valid records in cube.Later when I have coorect info abt error, I would load erroneous record manually using PSA.
I did following steps:
1)Failed request is not in cube...(setting is PSA and then into target)....also it has been deleted from PSA.
2)Remove data status from source ODS1.
3)Change error handling in infopackage to valid " Valid records update, reporting possible".
4)start loading of cube.
But when I did this I got following message :
<b> "Last delta update is not yet completed.Therefore, no new delta update is possible.You can start the request again if the last delta request is red or green in the monitor"</b>
But both my requests in cube and ODS are Green...no request is in yellow...!!
Now the problem is :
1) I have lost ODS data mart status
2)how to load valid records to cube, since errorneous record can be edited only after 3- 4 days.
3)How not to affect delta load of tomorrow.
Please guide and help me in this.
Thanks in advance and rest assured I will award points to say thanks to SDNers..
Regards,
Sorabh
Message was edited by: sorabh aroraHi Joseph,
Thanks for replying....
I apolgize and I have modified the message above..
I just checked in cube...there is no failed request for today...and neither in PSA....Person who has handed this to me may have deleted this is PSA..and why req is not in failed state in cube...I am not sure..though setting is "PSA and then into data package".....
So how to go frm here....
Thanks
Sorabh -
Hi,
I've a package with 6 procedures.
In one procedure I need to load the data into a flat file. The procedure contains only one select statement.
example:
procedure pro_test as
select * from emp;
end pro_test;
Shell script is being used to call one procedure inside the package and that procedure is calling remaining procedures inside it.
connected to database using sqlplus.
Can anyone help me out how I can spool the select statement inside the procedure. Version of oracle is 11g.Hi,
Why do you want to do
SELECT *
FROM table_name;
inside the procedure? Why not have your script run the procedure (without the query above), and then do that query afterwards, when you can use SPOOL to put the results in a file?
If you really must write a file from a procedure, here's an example of how to use utl_file.
First, SYSTEM (or some other user with the CREATE ANY DIRECCTORY system privilege) must create a directory, and grant privileges to use it. For example:
CREATE OR RPLEACE DIRECTORY a_dir AS 'C:\Foo\A_Folder';
GRANT ALL ON DIRECTORY a_dir TO PUBLIC;
Typically, SYSTEM does this once, and other people use it hundreds of times.
You might create a file in that directory like this:
CREATE OR REPLACE PROCEDURE write_dept
IS
f utl_file.file_type;
BEGIN
f := utl_file.fopen ('A_DIR', 'Dept.txt', 'W');
FOR r IN ( SELECT *
FROM scott.dept
LOOP
utl_file.put_line ( f
, TO_CHAR (r.deptno, 'FM00')
|| ' '
|| RPAD (r.dname, 15)
|| r.loc
END LOOP;
utl_file.fclose (f);
END write_dept;
SHOW ERRORS -
Using spool no send to printer
Hi All
I have a requirement like using Spool no I have to send that PDF directly to Printer.
I am catching the Spool no from FP_JOB_CLOSE function module.
Please suggeset me the way how can I proceed.....?
Thanks to all
Rama
Edited by: rama krishna on Mar 5, 2008 5:18 AMHi,
First for print preview you have to set the printer you want to use , this printer has to be define in your sap system and shouldn't be LOCL because SAP System need to retrieve tpye information of the printer.
Now if you want to print directly your form to the printer you have to set the OUTPUTPARAMS with correct value .
Here is the definition of structure OUTPUTPARAMS :
nodialog : No printer Dialog Popup
noprint : no backend printing
nopdf : no PDF document, only PDL
getpdf : PDF as return parameter
dest : Output device
copies : Number of copies requested
reqnew : start a new spool job
reqfinal : Spool request completed .
Hope this help you
Regards -
Hey SAPians,
i am stuck here with an issue. i am trying to print a report using spool in Russian, its status ends in error. however when i try printing same in english its status is complete.
where am i going wrong, how do i make this work?
THANKS IN ADVANCE
AbhinavHi,
Why do you want to do
SELECT *
FROM table_name;
inside the procedure? Why not have your script run the procedure (without the query above), and then do that query afterwards, when you can use SPOOL to put the results in a file?
If you really must write a file from a procedure, here's an example of how to use utl_file.
First, SYSTEM (or some other user with the CREATE ANY DIRECCTORY system privilege) must create a directory, and grant privileges to use it. For example:
CREATE OR RPLEACE DIRECTORY a_dir AS 'C:\Foo\A_Folder';
GRANT ALL ON DIRECTORY a_dir TO PUBLIC;
Typically, SYSTEM does this once, and other people use it hundreds of times.
You might create a file in that directory like this:
CREATE OR REPLACE PROCEDURE write_dept
IS
f utl_file.file_type;
BEGIN
f := utl_file.fopen ('A_DIR', 'Dept.txt', 'W');
FOR r IN ( SELECT *
FROM scott.dept
LOOP
utl_file.put_line ( f
, TO_CHAR (r.deptno, 'FM00')
|| ' '
|| RPAD (r.dname, 15)
|| r.loc
END LOOP;
utl_file.fclose (f);
END write_dept;
SHOW ERRORS -
Need help in using FM BAPI_MATERIAL_SAVEDATA
Gurus,
I need help in using the FM BAPI_MATERIAL_SAVEDATA. The FM is returning a message that says "The field MARA-MEINS/BAPI_MARA-BASE_UOM(_ISO) is defined as a required field; it does not contain an entry".
I have supplied the necessary details and yet the FM won't push through.
If possible, please post sample codes.
Below is my sample code:
===============================================
REPORT zmm_materialupload.
eject
$$******************************************************************************
$$ TYPES
$$******************************************************************************
eject
$$******************************************************************************
$$ INTERNAL TABLES (custom structure
$$******************************************************************************
eject
$$******************************************************************************
$$ RANGES
$$******************************************************************************
eject
$$******************************************************************************
$$ FIELD-SYMBOLS
$$******************************************************************************
eject
$$******************************************************************************
$$ PARAMETERS & SELECT-OPTIONS
$$******************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.
*SELECT-OPTIONS: s_matnr FOR mara-matnr.
SELECT-OPTIONS: s_mtart FOR mara-mtart.
SELECT-OPTIONS: s_mbrsh FOR mara-mbrsh DEFAULT 'P'.
SELECT-OPTIONS: s_werks FOR marc-werks DEFAULT '1000' OBLIGATORY.
SELECT-OPTIONS: s_lgort FOR marc-lgpro DEFAULT 'OPSL' OBLIGATORY.
PARAMETERS: p_path LIKE rlgrap-filename DEFAULT 'C:\Documents and Settings\training_11\Desktop\Book4 (2ITEMS).txt' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK 1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FNAME'
IMPORTING
file_name = p_path.
eject
$$******************************************************************************
$$ START-OF-SELECTION
$$******************************************************************************
START-OF-SELECTION.
PERFORM check_input.
PERFORM get_file.
PERFORM filter_input.
PERFORM populate_tabs.
PERFORM bapi_mat.
eject
$$******************************************************************************
$$ FORMS
$$******************************************************************************
FORM bapi_mat.
LOOP AT it_tab INTO wa_tab.
CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
EXPORTING
material_type = wa_tab-mtart
industry_sector = wa_tab-mbrsh
required_numbers = 1
TABLES
material_number = it_matnr.
ENDLOOP.
LOOP AT it_matnr INTO wa_matnr.
READ TABLE it_tab INTO wa_tab INDEX sy-tabix.
wa_tab-matnr = wa_matnr-material.
MODIFY it_tab FROM wa_tab INDEX sy-tabix.
ENDLOOP.
PERFORM populate_tabs.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = it_headdata
clientdata = it_clientdata
clientdatax = it_clientdatax
plantdata = it_plantdata
plantdatax = it_plantdatax
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
valuationdata = it_valuationdata
valuationdatax = it_valuationdatax
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
flag_online = ' '
flag_cad_call = ' '
NO_DEQUEUE = ' '
NO_ROLLBACK_WORK = ' '
IMPORTING
return = it_return
TABLES
materialdescription = it_materialdescription
unitsofmeasure = it_unitsofmeasure
unitsofmeasurex = it_unitsofmeasurex
internationalartnos = it_internationalartnos
materiallongtext = it_materiallongtext
taxclassifications = it_taxclassifications
returnmessages = it_returnmessages
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
IF sy-subrc = 0.
ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = it_return.
ENDFORM. "bapi_mat
*& Form GET_FILE
text
FORM get_file.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = 'Getting data from file...'.
MOVE: p_path TO gv_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gv_file
filetype = 'ASC'
has_field_separator = 'X'
read_by_line = 'X'
TABLES
data_tab = it_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "GET_FILE
*& Form check_input
text
FORM check_input.
Material Type
IF s_mtart-low IS INITIAL AND s_mtart-high IS INITIAL.
s_mtart = 'IEQ'.
s_mtart-low = 'ABF'. "Waste
s_mtart-high = 'ZTRD'. "Stock Items
APPEND s_mtart.
ENDIF.
IF s_mtart-low IS NOT INITIAL AND s_mtart-high IS INITIAL.
MOVE: s_mtart-low TO s_mtart-high.
ENDIF.
Industry Sector
IF s_mbrsh-low IS INITIAL AND s_mbrsh-high IS INITIAL.
s_mbrsh = 'IEQ'.
SELECT mbrsh
FROM mara
INTO TABLE it_mbrsh.
s_mbrsh-low = wa_mbrsh-mbrsh.
LOOP AT it_mbrsh INTO wa_mbrsh.
s_mbrsh-high = wa_mbrsh-mbrsh.
ENDLOOP.
APPEND s_mbrsh.
ENDIF.
IF s_mbrsh-low IS NOT INITIAL AND s_mbrsh-high IS INITIAL.
MOVE: s_mbrsh-low TO s_mbrsh-high.
ENDIF.
Plant
IF s_werks-low IS INITIAL AND s_werks-high IS INITIAL.
s_werks = 'IEQ'.
s_werks-low = '1000'.
s_werks-high = '2000'.
ENDIF.
IF s_werks-low IS NOT INITIAL AND s_werks-high IS INITIAL.
MOVE: s_werks-low TO s_werks-high.
ENDIF.
Storage Location
IF s_lgort-low IS NOT INITIAL AND s_lgort-high IS INITIAL.
MOVE: s_lgort-low TO s_lgort-high.
ENDIF.
ENDFORM. "check_input
*& Form Filter_input
text
FORM filter_input.
SORT it_tab BY matnr mtart mbrsh werks lgort.
LOOP AT it_tab INTO wa_tab.
IF wa_tab-mtart NOT IN s_mtart.
DELETE it_tab WHERE mtart NOT IN s_mtart.
ENDIF.
IF wa_tab-mbrsh NOT IN s_mbrsh.
DELETE it_tab WHERE mbrsh NOT IN s_mbrsh.
ENDIF.
IF wa_tab-werks NOT IN s_werks.
DELETE it_tab WHERE werks NOT IN s_werks.
ENDIF.
IF wa_tab-lgort NOT IN s_lgort.
DELETE it_tab WHERE lgort NOT IN s_lgort.
ENDIF.
ENDLOOP.
ENDFORM. "Filter_input
*& Form populate_tabs
text
FORM populate_tabs.
LOOP AT it_tab INTO wa_tab.
MOVE: wa_tab-matnr TO wa_headdata-material,
wa_tab-mbrsh TO wa_headdata-ind_sector,
wa_tab-mtart TO wa_headdata-matl_type,
'X' TO wa_headdata-basic_view,
'X' TO wa_headdata-sales_view,
'X' TO wa_headdata-purchase_view,
'X' TO wa_headdata-mrp_view,
'X' TO wa_headdata-account_view.
wa_tab-matkl TO wa_clientdata-matl_group,
wa_tab-meins TO wa_clientdata-base_uom,
wa_tab-groes TO wa_clientdata-size_dim,
wa_tab-gewei TO wa_clientdata-unit_of_wt,
wa_tab-ntgew TO wa_clientdata-net_weight,
'X' TO wa_clientdatax-matl_group,
'X' TO wa_clientdatax-base_uom,
'X' TO wa_clientdata-size_dim,
'X' TO wa_clientdatax-unit_of_wt,
'X' TO wa_clientdatax-net_weight,
wa_tab-werks TO wa_plantdata-plant,
wa_tab-ekgrp TO wa_plantdata-pur_group,
wa_tab-prctr TO wa_plantdata-profit_ctr,
wa_tab-werks TO wa_plantdatax-plant,
'X' TO wa_plantdatax-pur_group,
'X' TO wa_plantdatax-profit_ctr,
wa_tab-werks TO wa_valuationdata-val_area,
wa_tab-bklas TO wa_valuationdata-val_class,
wa_tab-peinh TO wa_valuationdata-price_unit,
wa_tab-verpr TO wa_valuationdata-moving_pr,
wa_tab-stprs TO wa_valuationdata-std_price,
wa_tab-xlifo TO wa_valuationdata-lifo_fifo,
wa_tab-werks TO wa_valuationdatax-val_area,
'X' TO wa_valuationdatax-val_class,
'X' TO wa_valuationdatax-price_unit,
'X' TO wa_valuationdatax-moving_pr,
'X' TO wa_valuationdatax-std_price,
'X' TO wa_valuationdatax-lifo_fifo.
APPEND wa_headdata TO it_headdata.
APPEND wa_clientdata TO it_clientdata.
APPEND wa_plantdata TO it_plantdata.
APPEND wa_valuationdata TO it_valuationdata.
MODIFY it_tab FROM wa_tab TRANSPORTING matnr.
ENDLOOP.
ENDFORM. "populate_tabs
$$******************************************************************************Hai.
check the below example.
REPORT z34332_bdc_create_material .
data: la_headdata type BAPIMATHEAD,
la_clientdata type BAPI_MARA,
la_CLIENTDATAX type BAPI_MARAX,
la_return type BAPIRET2.
data: i_materialdescription type table of BAPI_MAKT,
wa_materialdescription like line of i_materialdescription.
la_headdata-MATERIAL = '000000000000000004'.
la_headdata-IND_SECTOR = 'M'.
la_headdata-MATL_TYPE = 'FERT'.
la_clientdata-BASE_UOM = 'FT3'.
la_CLIENTDATAX-BASE_UOM = 'X'.
la_clientdata-MATL_GROUP = '01'.
la_CLIENTDATAX-MATL_GROUP = 'X'.
wa_materialdescription = 'TEST'.
append wa_materialdescription to i_materialdescription.
clear: wa_materialdescription.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = la_headdata
CLIENTDATA = la_clientdata
CLIENTDATAX = la_CLIENTDATAX
PLANTDATA =
PLANTDATAX =
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA =
VALUATIONDATAX =
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
FLAG_ONLINE = ' '
FLAG_CAD_CALL = ' '
IMPORTING
RETURN = la_return
TABLES
MATERIALDESCRIPTION = i_materialdescription
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
write: la_return-TYPE, ',', la_return-MESSAGE.
clear: la_headdata, la_return, la_clientdata, la_clientdatax.
regards.
sowjanya.b. -
Need help in using ActiveX to retrieve a VARIANT
Need help in using ActiveX to retrieve a VARIANT.
Variant is shown as var{VT_Ul1,1} in debug
Using the following
hr = CA_VariantGetShort (&var, &value);
I get 0 for my answer instead of 1.
Solved!
Go to Solution.Answered my own question.
VT_Ul1 is an unsigned char and not a short. -
I just updated my IOS to 7.1 and now I can't open Microsoft attachments - I used to always do it. Help - I use my iPad for work and now can't see any attachments. I've tried opening straight into other apps and just get error messages, and I the mail preview there is just a grey screen telling me the file name and size. It worked fine until I did the IOS upgrade
Troubleshooting apps purchased from the App Store
http://support.apple.com/kb/TS1702
Delete the app and redownload.
Downloading Past Purchases from the iTunes Store, App Store and iBooks Store
http://support.apple.com/kb/ht2519
Cheers, Tom -
I have updated my iPhone 4s to iOS7 but when i connect it to itunes on my PC it give me a msg to restore your iPhone in summary tab, Please help m using win 7 and updated itunes.
What is showing on the screen of the iPhone?
Does iTunes say the iPhone is in recovery mode? -
I have setup new instance. Created p.o & done MIGO things worked fine. In MIRO typically error is seen in tax code. I have assigned Tax procedure TAXGB to country IN. In Fin Acct in tax on sales & purchases defined new taxcode VX with country option IN. Still during MIRO its showing error Tax code VN & Country IN doesnot exist in procedure TAXGB. In error msg its M8 249 & origin is shown as check invoice document.
Help reqd from SAP Gurus pls.
RegardsCheck these links
while doing MIRO, i am getting error:-Tax code V0 country IN does not exist
Tax code Z4 country IN does not exist in procedure TAXINJ
Tax code V0 country IN does not exist in procedure TAXINN
Tax code V0 country IN does not exist in procedure TAXINN -
i have to upload video from my hewlett packard t200 camcorder to my mac. but mac won't recognize the camcorder files. i even bought flip4mac by tele stream which so far is useless. please help me use my camcorder with my iMac os mountain lion 10.8.2
i tried to get the installation disc for the camcorder but mac wont' recognize it becaue it is windows based i guess.
i just bought the camcorder a few months ago and when my computer crashed thought i'm finally getting a mac...it's been a costly venture which has resulted in more frustration than before my pc.
now the things i want to use with my mac that i thought would be even simpler...are not even useable...
helpThat camera shoots H.264 in an .avi wrapper.
You will have to transfer the files via the Finder.
Get a free copy of MPEG Streamclip and convert them to QuickTime .mov using the H.264 codec if you are presumably editing in iMovie.
Note that your list of video codecs won't look like mine as I have Final Cut Pro, but H.264 is definitely an option for you. -
Attachments help - C# using Obect API
I'm in my first attempt at integrating GW functionality into a C# application. I am not an expert C# programmer either. Thus far I've been successful at getting logged into GW, creating a new mail message and sending it successfully. However adding code to attach a file to my message returns an exception from the GroupwareTypeLibrary with the unhelpful error message "Unknown Error". Below is my code. If I comment out the line:
objMessage.Attachments.Add("c:\reg.log",1,"reg.log ");
the program runs successfully, happily sending my mail to the recipent mailbox. I know the c:\reg.log file exists and I have permissions to it.
Any advice as to what I'm doing wrong would be of tremendous help, as I've already search and cruised all the forums on GW API I can find to no avail. Running GW 7.03 I think on client and server side.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using GroupwareTypeLibrary;
namespace GWEmailTest
class Program
public static void Main()
GroupwareTypeLibrary.Application objApplication = new GroupwareTypeLibrary.Application();
GroupwareTypeLibrary.Account objAccount;
GroupwareTypeLibrary.Messages objMessages;
GroupwareTypeLibrary.Message objMessage;
GroupwareTypeLibrary.Folder objMailBox;
GroupwareTypeLibrary.Recipients objRecipients;
GroupwareTypeLibrary.Recipient objRecipient;
objAccount = objApplication.Login("dpuls", "", "password", "", "");
objMailBox = objAccount.MailBox;
objMessages = objMailBox.Messages;
objMessage = objMessages.Add("GroupwareTypeLibrary.Message",4," ");
objRecipients = objMessage.Recipients;
objRecipient = objRecipients.Add("dpuls","","");
objMessage.Subject.PlainText = "Here's the message from C#!.";
objMessage.BodyText.PlainText = "Here's the report you wanted.";
objMessage.Attachments.Add("c:\reg.log",1,"reg.log ");
objMessage.Send();Markus,
Thanks so much for your quick reply. I appreciate your willingness to help me overcome my ignorance. Here's what I found:
objMessage = objMessages.Add("GW.MESSAGE.MAIL", 4);
results in a C# compiler error "no overload method for 'add' requires '2' arguments". This tells me the third paramater is required for the GroupwareTypeLibary COM object, so I added the third null parameter back in, eliminating the compiler error. Then I still got the same "unknown error" exception back from the COM library as before.
So I went back to my shotgun approach of trying variations on parameter passing (instance variables instead of literals, etc). I noticed at one point when I tried another test file that I got a compiler error on a string literal of the path\filename "c:\csharptest.txt". Aha, says I ......
To make a long story short, by happenstance, my "c:\reg.log" parameter gets read in C# as containing an escape sequence reference, i.e. "\r" and when I changed to another test file it read "c:\csharptest.txt" as an INVALID escape sequence "\c". The fix then was to correct the problem of the reading of escape sequences in my string literal by changing my line of code to :
objMessage.Attachments.Add(@"c:\reg.log","1","");
Problem solved! Thanks again for your help.
dennis puls
Originally Posted by Markus Colorado
I suppose the way you're adding a draft message to the collection is false.
>> objMessages = objMailBox.Messages;
>> objMessage = objMessages.Add("GroupwareTypeLibrary.Message",4," ");
The function "Add()" takes only 2 parameters, 'ClassName' + 'ObjType'.
'ClassName' stands for the sort/subtype of message you'd like to create.
'ObjType' stands for 'draft' or 'personal'
Try the following:
objMessages = objMailBox.Messages;
objMessage = objMessages.Add("GW.MESSAGE.MAIL", 4);
The rest should be fine; the code for adding the attachment seems OK.
Markus
"dpuls" <[email protected]> schrieb im Newsbeitrag
news:[email protected]...
>
> I'm in my first attempt at integrating GW functionality into a C#
> application. I am not an expert C# programmer either. Thus far I've
> been successful at getting logged into GW, creating a new mail message
> and sending it successfully. However adding code to attach a file to my
> message returns an exception from the GroupwareTypeLibrary with the
> unhelpful error message "Unknown Error". Below is my code. If I
> comment out the line:
> objMessage.Attachments.Add("c:\reg.log",1,"reg.log ");
>
> the program runs successfully, happily sending my mail to the recipent
> mailbox. I know the c:\reg.log file exists and I have permissions to
> it.
>
> Any advice as to what I'm doing wrong would be of tremendous help, as
> I've already search and cruised all the forums on GW API I can find to
> no avail. Running GW 7.03 I think on client and server side.
>
> ****************************
> using System;
> using System.Collections.Generic;
> using System.Text;
> using System.IO;
> using GroupwareTypeLibrary;
>
> namespace GWEmailTest
> {
> class Program
> {
> public static void Main()
> {
> GroupwareTypeLibrary.Application objApplication = new
> GroupwareTypeLibrary.Application();
> GroupwareTypeLibrary.Account objAccount;
> GroupwareTypeLibrary.Messages objMessages;
> GroupwareTypeLibrary.Message objMessage;
> GroupwareTypeLibrary.Folder objMailBox;
> GroupwareTypeLibrary.Recipients objRecipients;
> GroupwareTypeLibrary.Recipient objRecipient;
>
> objAccount = objApplication.Login("dpuls", "", "password", "",
> "");
> objMailBox = objAccount.MailBox;
> objMessages = objMailBox.Messages;
> objMessage = objMessages.Add("GroupwareTypeLibrary.Message",4," ");
> objRecipients = objMessage.Recipients;
> objRecipient = objRecipients.Add("dpuls","","");
> objMessage.Subject.PlainText = "Here's the message from C#!.";
> objMessage.BodyText.PlainText = "Here's the report you wanted.";
> objMessage.Attachments.Add("c:\reg.log",1,"reg.log ");
> objMessage.Send();
> }
> }
> }
> ****************************
>
>
> --
> dpuls
> ------------------------------------------------------------------------
> dpuls's Profile: NOVELL FORUMS - View Profile: dpuls
> View this thread: Attachments help - C# using Obect API - NOVELL FORUMS
> -
How can I print stuff from the 'Help' file using my MacBook Air?
How can I print stuff from the 'Help' file using my MacBook Air?
Open the Help viewer, select a category then from the menu bar top of your screen, click File > Print
Maybe you are looking for
-
My ipod mini won't update the songs anymore.
After updating the software per a prompt when I plugged in, my ipod won't transfer the songs over form itunes. I have done a lot to try to fix this problem. What was happening is that when I connected the ipod (with the same USB that had always worke
-
I have reinstalled the Adobe PSCS5 version to my computer, I talked with support for my Mac and tried several things without success. Is it possible to remove OSXYosemite as my operating system and go back to what I ha previously? I need my Photosh
-
Can Adobe Reader 9.4+ send mail?
Sorry to cross post, but I couldn't figure out how to move my post from the "Adobe Reader" forum to the "Adobe Reader for Unix" forum. The last version of Adobe Reader we had that allowed us to send mail through the envelope icon from Adobe Reader wa
-
IPhone applications previously purchase using iTunes on Windows machine
I have just got my new macbook and is in the process of using my iPhone with iTunes on the Mac. I have my songs on a network server so I have little concern about losing them. However, I bought some applications for my iPhone. The warning message whe
-
Configuring Dynamic drop down in ABAP Function Module based VC application
Dear Expert, Can someone help me in configuring Dynamic Drop down list in ABAP function module based VC application, so that all the backend data like material description list should display in drop down list followed by * search. Thanks & Regards,