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 is send with spaces between every character

Former Member
0 Kudos

I've got the following program:

However when I test this an email is send with a SAP shortcut fille in attachment.

However the shortcut is not working correctly because every character is seperated by a space.

[ S y s t e m ]

N a m e = D E V

D e s c r i p t i o n =

C l i e n t = 0 1 0

[ U s e r ]

N a m e = T L E Y S

L a n g u a g e = E N

[ F u n c t i o n ]

T i t l e =

C o m m a n d = M E 5 5 p _ f r g a b = O R ;

T y p e = T r a n s a c t i o n

[ C o n f i g u r a t i o n ]

G u i S i z e = N o r m a l w i n d o w

REPORT  zrp_mail_shortcut.
***http://wiki.sdn.sap.com/wiki/display/Snippets/Creating+a+SAP+shortcut+for+any+transaction+and+sending+it+by+mail
*********************************************************************************
***    Report to send mail to employee to release his Purchase requisitions   ***
*********************************************************************************
*** Declarations for attachment creation
DATA: doc_chng  LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix,
      body_start LIKE sy-tabix.
DATA: it_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: it_objpack   LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: it_objbin    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: it_reclist   LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: it_shortcut_param LIKE zst_shortcut_par OCCURS 0 WITH HEADER LINE.
DATA: content TYPE string.

*** Pass the required parameters and create the shortcut
CLEAR it_shortcut_param.
REFRESH it_shortcut_param.


it_shortcut_param-fieldname = 'p_frgab'.
it_shortcut_param-fieldvalue = 'OR'. " Release code
APPEND it_shortcut_param.

CALL FUNCTION 'ZCREATE_SHORTCUT'
  EXPORTING
    recipient_user_id = 'XXXX'
    transaction       = 'ME55'
  IMPORTING
    content           = content
  TABLES
    shortcut_param    = it_shortcut_param.

*** Mail Subject
doc_chng-obj_descr = 'Purchase requisitions require release'.
*** Mail Contents
CONCATENATE ' Please release Purchase requisition.'
' You can use the attached link to jump to the transaction and realease the purchase requisition(s)'
INTO it_objtxt.
APPEND it_objtxt.

*** Creation of the entry for the document
DESCRIBE TABLE it_objtxt LINES tab_lines.
CLEAR it_objpack-transf_bin.
it_objpack-head_start = 1.
it_objpack-head_num = 0.
it_objpack-body_start = 1.
it_objpack-body_num = tab_lines.
it_objpack-doc_type = 'RAW'.
APPEND it_objpack.

*** 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.

*** Creation of the entry for the compressed attachment
it_objpack-transf_bin = 'X'. "Will get content from content_bin
it_objpack-head_start = 1.
it_objpack-head_num   = 1.
it_objpack-body_start = 1.
it_objpack-body_num   = tab_lines.
it_objpack-doc_type   = 'EXT'.
it_objpack-obj_name   = 'SAPSHORTCUTMAIL'.
it_objpack-obj_descr  = 'Release_PR.SAP'.
it_objpack-doc_size   = tab_lines * 255.
APPEND it_objpack.


*** target recipent(s)
CLEAR it_reclist.
it_reclist-receiver = 'email @provider.com'.
it_reclist-rec_type = 'U'.
APPEND it_reclist.

*** Sending the document to recipients with the shortcut attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    document_data              = doc_chng
    put_in_outbox              = 'X'
    commit_work                = 'X'
  TABLES
    packing_list               = it_objpack
    contents_bin               = it_objbin
    contents_txt               = it_objtxt
    receivers                  = it_reclist
  EXCEPTIONS
    too_many_receivers         = 1
    document_not_sent          = 2
    operation_no_authorization = 4
    OTHERS                     = 99.

1 REPLY 1

Former Member
0 Kudos

Problem has been resolved.

These lines solved the problem

ls_obj_header = '&SO_FORMAT=ASC'.

APPEND ls_obj_header TO lt_obj_header.