08-30-2013 9:01 AM
Hello,
I have a requirement to send a mail to the Approver with tcode MIR4 as attachments.
I have to pass parameters to the t code as well.
I referred to the link, http://wiki.sdn.sap.com/wiki/display/Snippets/Creating+a+SAP+shortcut+for+any+transaction+and+sendin...
I was successful in creating the shortcut, but when I pass parameters the shortcut file created get populated with Junk value.
Below is the contents of the file created.
[System]
Name=SYS
Description=
Client=CLNT
[User]
Name=USERNAME
Language=EN
[Function]
Title=
Command=MIR4 RBKP-BELNR 㴀㔀㜀 㐀㘀㔀㬀刀䈀䬀倀ⴀ䜀䨀䄀䠀刀㴀㈀ ㌀㬀ഀ吀礀瀀攀㴀吀爀愀渀猀愀挀琀椀漀渀ഀ嬀䌀漀渀昀椀最甀爀愀琀椀漀渀崀ഀ䜀甀椀匀椀稀攀㴀一漀爀洀愀氀 眀椀渀搀漀眀ഀ †
System Component Information.
SAP_BASIS | 701 | 0003 | SAPKB70103 | SAP Basis Component |
SAP_ABA | 701 | 0003 | SAPKA70103 | Cross-Application Component |
SAP_APPL | 604 | 0003 | SAPKH60403 | Logistics and Accounting |
Please suggest what is that I am missing.
Regards,
Revathi SJ
08-30-2013 10:09 AM
08-30-2013 10:09 AM
08-30-2013 10:32 AM
Call to FM SWN_CREATE_SHORTCUT, is as below.
where parameter has the value of BELNR and GJHAR.
CALL FUNCTION 'SWN_CREATE_SHORTCUT'
EXPORTING
i_transaction = transaction
i_parameter = parameter
i_sysid = sy-sysid
i_client = sy-mandt
i_user = recipient_user_id
i_language = sy-langu
i_windowsize = 'Normal window'
IMPORTING
shortcut_string = content
EXCEPTIONS
inconsistent_parameters = 1
OTHERS = 2.
Regards,
Revathi SJ
08-30-2013 11:48 AM
This FM call is same as wiki.
I am interested in what exact values are being passed to the FM.
Using that, I can run the same FM in test mode and see whether I also get junk values in shortcut string.
09-03-2013 8:15 AM
Hi Manish,
Below are the details,
TRANSACTION | MIR4 | |
PARAMETER | RBKP-BELNR=5700001465;RBKP-GJAHR=2013; | |
SY-SYSID | DV2 | |
SY-MANDT | 015 | |
RECIPIENT_USER_ID | ||
SY-LANGU | E |
Regards,
Revathi SJ
09-03-2013 8:57 AM
I just ran the FM SWN_CREATE_SHORTCUT with given details, and output does not have junk data.
[System]
Name=DEV
Description=
Client=100
[User]
Name=ABCDE
Language=EN
[Function]
Title=
Command=MIR4 RBKP-BELNR=5700001465;RBKP-GJAHR=2013;
Type=Transaction
[Configuration]
GuiSize=NORMAL WINDOW
You may put a breakpoint at beginning of FM call, and double check whether junk data is present while parameters are being passed.
09-03-2013 9:42 AM
Yes, I did check that. And not junk value is being passed.
Regards,
Revathi SJ
09-03-2013 10:43 AM
I'll make another assumption then.
Assuming that FM is returning data properly, junk data may be getting added at a later stage, when email attachment is being prepared.
The following lines from wiki look relevant.
*** Populate attachment content
CLEAR : tab_lines, it_objbin.
CONCATENATE content it_objbin-line INTO it_objbin-line.
APPEND it_objbin.
DESCRIBE TABLE it_objbin LINES tab_lines.
"content" is returned by FM, and it is then added to internal table it_objbin .
Please track the value in content and it_objbin and see at what point junk data gets added.
If it happens in standard code, you can contact SAP Support.
09-03-2013 2:11 PM
The FM 'SWN_CREATE_SHORTCUT' is working as expected.
The error is actually in the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1', which internally calls 'SO_DOCUMENT_SEND_API1' which again internally calls, FM 'SO_CONVERT_CONTENTS_BIN'.
And the junk is getting populated after this conversion.
Please suggest what needs to be done.
Regards,
Revathi SJ
09-03-2013 3:47 PM
Try out other document types, like BIN, RAW.
it_objpack-doc_type = 'EXT'.
If it doesn't work, maybe CL_BCS needs to be used instead of older method of sending emails.
The issue not related to FM SWN_CREATE_SHORTCUT.
It is just that you are unable to send plain text file with extension .sap as email attachment.
So take an example program of CL_BCS from SCN or wiki or internet, copy and modify it to email attach small file with few lines of text. Once that is working, replace the few lines with shortcut text returned by FM.
09-05-2013 6:30 AM
Hi Manish,
I tried using CL_BCS class, I was able to send the mail.
However when the attachment is of type 'RAW', the file gets generated in the required format. i.e.
[System]
Name=DV2
Description=
Client=015
[User]
Name=
Language=EN
[Function]
Title=
Command=MIR4 RBKP-BELNR=1222222222;RBKP-GJAHR=2013;
Type=Transaction
[Configuration]
GuiSize=Normal window
But if I set the type to 'EXT', the entire text is populated in a single line and with a space after each character. I dint find any help on SCN as well.
Please suggest.
Regards,
Revathi SJ
09-05-2013 10:47 AM
I was successfully able to create the shortcut using CL_BCS. The problem was with extension type.
I changed it from 'EXT' to 'SAP'.
09-05-2013 10:56 AM
Does it mean that RAW format is giving you desired output, and you just want to know why EXT format file is the way it is?