Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Shortcut created using FM SO_NEW_DOCUMENT_ATT_SEND_API1 has junk values

Former Member
0 Kudos

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_BASIS7010003SAPKB70103SAP Basis Component
SAP_ABA7010003SAPKA70103Cross-Application Component
SAP_APPL6040003SAPKH60403Logistics and Accounting

Please suggest what is that I am missing.

Regards,

Revathi SJ

1 ACCEPTED SOLUTION

Former Member
0 Kudos

What data is being passed to FM SWN_CREATE_SHORTCUT?

12 REPLIES 12

Former Member
0 Kudos

What data is being passed to FM SWN_CREATE_SHORTCUT?

0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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.

0 Kudos

Yes, I did check that. And not junk value is being passed.

Regards,

Revathi SJ

0 Kudos

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.

0 Kudos

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


0 Kudos

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.

0 Kudos

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

0 Kudos

I was successfully able to create the shortcut using CL_BCS. The problem was with extension type.

I changed it from 'EXT' to 'SAP'.

0 Kudos

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?