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: 

SO_NEW_DOCUMENT_ATT_SEND_API1

Former Member
0 Kudos
124

Dear All ,

I am using this fuction module to send the payslip is PDF format to mail id . It is working properly when I look at SOST Transaction . But when I am trying to open that PDF document from my mail ID it is giving error ,

error indicates that the file contains the error or file is corrupted . what may be tha reason

7 REPLIES 7

Former Member
0 Kudos
68

Hi,

Check out the atatchment type you are passing,

I have passed attachment type as ALI for PDF&it's working fine,

att_type type so_obj_tp.

att_type = 'ALI'

gs_objpack-doc_type = att_type.

Regards,

Raghavendra

0 Kudos
68

Dear raghavendra

I am passing ATT_TYPE = 'ALI' .

And in scot for ALI we have set PDF .

Former Member
0 Kudos
68

hi,

I also have faced the similar problem when i used this function module...and wen i asked others they told it might be bcoz of some settings with the BASIS.

try with the function module <b>'SO_OBJECT_SEND'i</b> t will work fine..

<b>Rewrd pts if helpful..</b>

Regards,

Ajith

0 Kudos
68

Hello Ajith ,

Can you send me the code for using 'SO_OBJECT_SEND' ,

Thank you in advance .

Former Member
0 Kudos
68

Hi Raghavendra,

hope this code will help you...Change your function module to the one given in this ..will definitely solve your prob...

data : fm_name type rs38L_fnam

DATA: LOC_OWNER TYPE SOUD-USRNAM,

LOC_SOXLL LIKE SOXLL OCCURS 0 WITH HEADER LINE,

LOC_INT_RECEIVERS TYPE STANDARD TABLE OF SOOS1 WITH HEADER LINE,

FS_OTFDATA TYPE ITCOO,

LOC_FS_CONTENTS TYPE SOLI,

LOC_INT_CONTENTS TYPE STANDARD TABLE OF SOLI WITH HEADER LINE.

DATA : LOC_FS_OBJECT_HD_CHANGE LIKE SOOD1.

DATA: INT_OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA : WA_OBJTXT LIKE LINE OF INT_OBJTXT.

FS_OUTPUT_OPTIONS-TDPRINTER = 'PDF1'.

FS_OUTPUT_OPTIONS-XSF = ''. "XSF Output active

FS_OUTPUT_OPTIONS-XSFCMODE = 'X'. "Get XSF params from program

FS_OUTPUT_OPTIONS-XDFCMODE = 'X'.

FS_OUTPUT_OPTIONS-XDF = SPACE.

FS_OUTPUT_OPTIONS-XSFCMODE = 'X'.

FS_OUTPUT_OPTIONS-XDFCMODE = 'X'.

FS_CONTROL_PARAMETERS-LANGU = 'E'.

FS_CONTROL_PARAMETERS-NO_DIALOG = 'X'.

FS_CONTROL_PARAMETERS-GETOTF = 'X'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'Smartform name'

IMPORTING

FM_NAME = FM_NAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

  • error handling

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

EXIT.

ENDIF.

CALL FUNCTION FM_NAME " Smartform Fn module

EXPORTING

CONTROL_PARAMETERS = FS_CONTROL_PARAMETERS

OUTPUT_OPTIONS = FS_OUTPUT_OPTIONS

USER_SETTINGS = ' '

IMPORTING

JOB_OUTPUT_INFO = FS_OUTPUT_DATA

TABLES

IT_167 = INT_167

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOC_FS_OBJECT_HD_CHANGE-OBJLA = SY-LANGU.

LOC_FS_OBJECT_HD_CHANGE-OBJDES = 'Mail Subject'.

LOOP AT FS_OUTPUT_DATA-OTFDATA INTO FS_OTFDATA.

MOVE FS_OTFDATA TO LOC_FS_CONTENTS.

APPEND LOC_FS_CONTENTS TO LOC_INT_CONTENTS.

ENDLOOP.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

OBJECT_HD_CHANGE = LOC_FS_OBJECT_HD_CHANGE

OBJECT_TYPE = 'OTF'

OUTBOX_FLAG = 'X'

TABLES

OBJCONT = LOC_INT_CONTENTS

RECEIVERS = LOC_INT_RECEIVERS

NOTE_TEXT = INT_OBJTXT

LINK_LIST = LOC_SOXLL

EXCEPTIONS

ACTIVE_USER_NOT_EXIST = 1

COMMUNICATION_FAILURE = 2

COMPONENT_NOT_AVAILABLE = 3

FOLDER_NOT_EXIST = 4

FOLDER_NO_AUTHORIZATION = 5

FORWARDER_NOT_EXIST = 6

NOTE_NOT_EXIST = 7

OBJECT_NOT_EXIST = 8

OBJECT_NOT_SENT = 9

OBJECT_NO_AUTHORIZATION = 10

OBJECT_TYPE_NOT_EXIST = 11

OPERATION_NO_AUTHORIZATION = 12

OWNER_NOT_EXIST = 13

PARAMETER_ERROR = 14

SUBSTITUTE_NOT_ACTIVE = 15

SUBSTITUTE_NOT_DEFINED = 16

SYSTEM_FAILURE = 17

TOO_MUCH_RECEIVERS = 18

USER_NOT_EXIST = 19

ORIGINATOR_NOT_EXIST = 20

X_ERROR = 21

OTHERS = 22.

<b>Reward pts if helpful.</b>

Rgds,

Ajith

0 Kudos
68

Hello Ajith ,

Thank you for sending the code . From your code I found that you are passing the data from smartforms . Let me tel my scenario . I am sending payslip which developed in PE51 by HR consultant .

I am attaching the code here what I am doing , Just let if your code can suite here .

select *

from HRPY_RGDIR

into corresponding fields of table itab

where PERNR in s_name

AND

FPPER IN S_PERIOD.

if sy-subrc eq 0.

loop at itab.

  • Create receiver list

refresh RECLIST.

clear RECLIST.

select single *

from PA0105

where PERNR eq ITAB-PERNR

and USRTY eq '0010'.

if SY-SUBRC <> 0.

I_sent-PERNR = ITAB-PERNR.

i_sent-status = 'NO'.

select single *

from pa0002

where pernr eq itab-pernr.

concatenate pa0002-VORNA pa0002-NACHN into i_sent-name

separated by space.

append i_Nsent.

continue.

else.

refresh reclist.

RECLIST-RECEIVER = pa0105-usrid_long.

translate RECLIST-RECEIVER to lower case.

RECLIST-REC_TYPE = 'U'.

append RECLIST.

endif.

call function 'GET_PAYSLIP'

EXPORTING

EMPLOYEE_NUMBER = itab-PERNR

SEQUENCE_NUMBER = itab-SEQNR

PAYSLIP_VARIANT = PAY_VAR

IMPORTING

RETURN = RETURN

P_INFO = P_INFO

TABLES

P_FORM = P_FORM.

loop at P_FORM

where LINDA eq F__CMD-NEWPAGE

and LTYPE eq F__LTYPE-CMD.

P_INDEX-INDEX = SY-TABIX.

append P_INDEX.

endloop.

P_IDX = 1.

refresh P_P_FORM.

append lines of P_FORM from P_IDX to P_INDEX-INDEX

to P_P_FORM.

P_IDX = P_INDEX-INDEX.

export P_P_FORM to memory id '%%_P_FORM_%%'.

export P_INFO to memory id '%%_P_INFO_%%'.

submit RPCEDT_LIST_TO_MEMORY exporting list to memory and return.

call function 'LIST_FROM_MEMORY'

TABLES

LISTOBJECT = P_LIST.

call function 'TABLE_COMPRESS'

TABLES

IN = P_LIST

OUT = OBJBIN

EXCEPTIONS

others = 1.

Read table RECLIST index 1.

I_sent-PERNR = ITAB-PERNR.

i_sent-usrid_long = RECLIST-RECEIVER.

select single *

from pa0002

where pernr eq itab-pernr.

concatenate pa0002-VORNA pa0002-NACHN into i_sent-name

separated by space.

i_sent-status = 'YES'.

append i_sent.

  • concatenate ' Payslip-' '(' ITAB-PERNR+4(4) ')'

  • into DOCDATA-OBJ_DESCR.

CALL FUNCTION 'MONTH_NAMES_GET'

EXPORTING

LANGUAGE = SY-LANGU

TABLES

MONTH_NAMES = month_names

EXCEPTIONS

MONTH_NAMES_NOT_FOUND = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

if sy-datum+4(2) = '01'.

v_month = '12'.

else.

v_month = sy-datum+4(2) - 1.

endif.

read table month_names with key mnr = v_month.

  • Modified By Sabari Prabhu on 30.05.2006

If not s_period-low is initial.

v_year = s_period-low+2(4).

else.

v_year = sy-datum+0(4).

Endif.

concatenate 'Salary Slip for the month of' month_names-LTX

V_Year '-' i_sent-name

into DOCDATA-OBJ_DESCR.

  • End of Modification

DOCDATA-OBJ_NAME = 'Pay Slip'.

DOCDATA-OBJ_LANGU = SY-LANGU.

OBJTXT = 'Dear Mr.'.

concatenate OBJTXT i_sent-name ' , ' into objtxt.

append OBJTXT.

append initial line to objtxt.

OBJTXT = 'Please find enclosed your salary slip for the month of'.

concatenate OBJTXT month_names-LTX sy-datum+0(4)

into objtxt separated by space.

append OBJTXT.

OBJTXT =

'as attachment This is confidential document and not be disclosed or '.

append OBJTXT.

OBJTXT =

'shared with any other employee.In case of any queries on this subject'.

append OBJTXT.

OBJTXT =

append OBJTXT.

append initial line to objtxt.

append initial line to objtxt.

OBJTXT = 'With Kind Regards'.

append OBJTXT.

append initial line to objtxt.

append initial line to objtxt.

OBJTXT = 'Payroll Administrator'.

append OBJTXT.

append OBJTXT.

append OBJTXT.

  • Write Packing List (Main)

describe table objtxt lines TAB_LINES.

read table OBJTXT index TAB_LINES.

DOCDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJTXT ).

clear OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'RAW'.

append OBJPACK.

  • Create Message Attachment

  • Write Packing List (Attachment)

ATT_TYPE = 'ALI'.

describe table OBJBIN lines TAB_LINES.

read table OBJBIN index TAB_LINES.

OBJPACK-DOC_SIZE =

( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = ATT_TYPE.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'Payslip'.

append OBJPACK.

  • Send the document

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOCDATA

PUT_IN_OUTBOX = ''

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

DOCUMENT_TYPE_NOT_EXIST = 3

OPERATION_NO_AUTHORIZATION = 4

PARAMETER_ERROR = 5

X_ERROR = 6

ENQUEUE_ERROR = 7

others = 8.

WAIT UP TO 30 seconds.

REFRESH : OBJPACK , OBJHEAD , OBJBIN , OBJTXT .

CLEAR : OBJPACK , OBJHEAD , OBJBIN , OBJTXT , DOCDATA.

  • End of Insertion

endloop.

0 Kudos
68

Hi ,

Did u check with the function module... 'SO_OBJECT_SEND' ??

Try passing the values to this function module...and chek please..

REgards,

Ajith