Application Development and Automation 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: 
Read only

sbwp create new document

former_member183924
Active Participant
0 Likes
2,681

Hi all experts,

i want to create a new document via a function or method in the inbox of a receiver. I already looked for SO_DOCUMENT_SEND_API1 or SO_DOCUMENT_INSERT but it seems that these function are just for creating a email to an external partner.

I also try to use the method "cl_bcs=>short_message" but with this thing i have problems creating the right receiver table, because it is a deep structure.


DATA: it_send_text  TYPE BCSY_TEXT,
      wa_send_text  TYPE soli,
      it_rec        TYPE BCSY_RE3,
      wa_rec        LIKE LINE OF BCSY_RE3
      .

wa_send_text-line = 'some text for the message body'.
append wa_send_text to it_send_text.

*wa_rec-recipient = CL_SAPUSER_BCS=>CREATE( SY-UNAME ).
wa_rec-recipient = 'USER_NAME'.
append wa_rec to it_rec.

CALL METHOD cl_bcs=>short_message
  EXPORTING
    I_subject       = 'doc_title'
    I_TEXT          = it_send_text
    I_RECIPIENTS    = it_rec
.

can anybody help me? I though this is an easy one to create a document?!

Regards,

Steffen

1 ACCEPTED SOLUTION
Read only

former_member183924
Active Participant
0 Likes
2,302

it is more a problem of using this FM which BSP (Business Server Pages)

17 REPLIES 17
Read only

Former Member
0 Likes
2,302

Hi

SO_DOCUMENT_SEND_API1 Fm is also used to send the mail in form of Attachment to

the others also , what is the problem that you are having with this..

Regards Rk

Read only

0 Likes
2,302

Hi Rk,

i don't understand this sbwp messages manager not so well. Everybody is talking about emails, but I just want to send / create a document in the SBWP inbox for a user. Not an email, email with attachement or a workflow or something like that.

So when the Email for an Userprofile is like: "user.name@company.com" and I use the SO_DOCUMENT_SEND_API1, I dont want to send this message into his Outlook-Email-Client...

Regards,

Steffen

Read only

0 Likes
2,302

hi You can send the Document to SBWP also using this Fm

check this Program

In this just look at the parameter

RECEIVER

Name of recipient.

The following entry categories are possible:

SAP use name of the recipient

SAPoffice name of the recipient

Shared distribution list

Fax number in the form of structure SADRFD

Internet address in the form of structure SADRUD

Remote SAP name in the form of structure SADR7D

X.400 address in the form of structure SADR8D

ADR_TYPE

Type of RECEIVER entry.

The following values are permitted:

<b>'B' : SAP user name

' ' : SAPoffice name

'C' : Shared distribution list

'F' : Fax number

'U' : Internet address

'R ' : Remote SAP name

'X' : X.400 address

REC_ID

If the recipient is a SAPoffice user, the user ID, instead of the recipient name in RECEIVER, can be entered in this field.</b>

[code]REPORT ZSSO_DOCUMENT_SEND_API1.

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: TAB_LINES LIKE SY-TABIX.

  • Creating the document to be sent

DOC_CHNG-OBJ_NAME = 'OFFER'.

DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.

OBJTXT = 'Reserve price : $250000'.

APPEND OBJTXT.

OBJTXT = 'A reproduction of the painting to be auctioned'.

APPEND OBJTXT.

OBJTXT = 'is enclosed as an attachment.'.

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).

  • Creating the entry for the compressed document

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.

  • Creating the document attachment

  • (Assume the data in OBJBIN are given in BMP format)

OBJBIN = ' \O/ '. APPEND OBJBIN.

OBJBIN = ' | '. APPEND OBJBIN.

OBJBIN = ' / \ '. APPEND OBJBIN.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.

  • Creating the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'BMP'.

OBJPACK-OBJ_NAME = 'ATTACHMENT'.

OBJPACK-OBJ_DESCR = 'Reproduction object 138'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK..

  • Entering names in the distribution list

RECLIST-RECEIVER = 'guido.geldsack@money.com'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

RECLIST-RECEIVER = 'DLI-NEUREICH'.

RECLIST-REC_TYPE = 'P'.

APPEND RECLIST.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

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

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

CASE SY-SUBRC.

WHEN 0.

WRITE: / 'Result of the send process:'.

LOOP AT RECLIST.

WRITE: / RECLIST-RECEIVER(48), ':'.

IF RECLIST-RETRN_CODE = 0.

WRITE 'sent successfully'.

ELSE.

WRITE 'not sent'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'no authorization to send to the specified number of' 'recipients!'.

WHEN 2.

WRITE: / 'document could not be sent to any of the recipients!'.

WHEN 4.

WRITE: / 'no authorization to send !'.

WHEN OTHERS.

WRITE: / 'error occurred during sending !'.

ENDCASE.[/code]

Regards Rk

Read only

0 Likes
2,302

Hi!

Check out OSS Note 547893 - FAQ for Workflow.

Question:How is an event triggered from the application and a workflow then started?

Answer: An event can be triggered from the application in three different ways:

o Directly:

Within the application, the SWE_EVENT_CREATE function module or the SWE_EVENT_CREAT_IN_UPD_TASK function module, for example, generates an event in the update.

o With a change document:

Change documents are written within the application when you change application objects in the update. You can link events that have the same key with these types of change documents via transaction SWEC.

o With status management:

The SWE_EVENT_CREATE_STATUS function module triggers an event in the same way as the direct method when a status is changed.

This event contains the object type (for example, purchase order), the object key (for example, purchase order 4711) and other information.

Using transaction PFTC, you can assign the event to a specific workflow or single-step task. More settings are available in transaction SWE2.

Regards

Tamá

Read only

0 Likes
2,302

aahhh ok,

now it is clear. I thought if I use the username for the receiver, it sends it to his emailaddress... that was my problem...

Thanks,regards,

Steffen

Read only

Former Member
0 Likes
2,302

hi

good

try this out

check out the excellent weblog on this subject by Thomas Jung which talks about starting from configuring SMTP node and the code sample for sending mail.

Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface

thanks

mrutyun^

Read only

Former Member
0 Likes
2,302

Hi,

using SO_DOCUMENT_INSERT_API1 you may just create a document without any email involved. Documentation of FB includes this example:

Example

A private document is created in the outbox of the active user. The ID

of the outbox is determined via the function module SO_USER_READ_API1.

DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.

DATA: USER_DATA LIKE SOUDATAI1.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DATA: ENTRIES LIKE SY-TABIX.

CALL FUNCTION 'SO_USER_READ_API1'

IMPORTING

USER_DATA = USER_DATA

EXCEPTIONS

OTHERS = 1.

IF SY-SUBRC <> 0.

WRITE: / 'User data could not be read !'.

EXIT.

ENDIF.

DOC_CHNG-OBJ_NAME = 'PRIVAT'.

DOC_CHNG-OBJ_DESCR = 'My private document'.

DOC_CHNG-LANGU = SY_LANGU.

DOC_CHNG-SENSITIVTY = 'P'.

OBJCONT = 'All created myself !'.

APPEND OBJCONT.

OBJCONT = 'No one else has access to it !'.

APPEND OBJCONT.

DESCRIBE TABLE OBJCONT LINES ENTRIES.

READ TABLE OBJCONT INDEX ENTRIES.

DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).

CALL FUNCTION 'SO_DOCUMENT_INSERT_API1'

EXPORTING

FOLDER_ID = USER_DATA-OUTBOXFOL

DOCUMENT_TYPE = 'RAW'

DOCUMENT_DATA = DOC_CHNG

TABLES

OBJECT_CONTENT = OBJCONT

EXCEPTIONS

OTHERS = 1.

CASE SY-SUBRC.

WHEN 0.

WRITE: / 'Document created !'.

WHEN 1.

WRITE: / 'Error creating document !'.

ENDCASE.

Peter

Read only

athavanraja
Active Contributor
0 Likes
2,302

the problem is with this line of code.

*wa_rec-recipient = CL_SAPUSER_BCS=>CREATE( SY-UNAME ).

wa_rec-recipient = 'USER_NAME'.

append wa_rec to it_rec.

the way to fill receipient is as shown in the commented line above and not just passing the userid.

Raja

Read only

0 Likes
2,302

ok, thanks

I debugged my programm a little bit and found out that the FM SO_DOCUMENT_SEND_API1 calls a new DynPro screen. But I'm using Business Server Pages (BSP) and I want to send just two input fields from a website into the SBWP.

My problem in this Forum is solved. I have to found out how to call the right FM which solves my problem.

Thanks so much to all of you, answers are rewareded

Regards,

Steffen

Read only

0 Likes
2,302

You should get the right structure using SO_USER_READ_API1.

Peter

Read only

former_member183924
Active Participant
0 Likes
2,303

it is more a problem of using this FM which BSP (Business Server Pages)

Read only

0 Likes
2,302

the way forward if you want to use it in BSP environment is to use CL_BCS classes.

let me know if you are interested in how to set receiver with CL_BCS class approach, i can provide sample code.

Read only

0 Likes
2,302

Thanks so much,

currently I have this code:


DATA: it_send_text  TYPE BCSY_TEXT,
      wa_send_text  TYPE soli,
      it_rec        TYPE BCSY_RE3,
      wa_rec        TYPE BCSS_RE3
      .

wa_send_text-line = 'some text for body message'.
append wa_send_text to it_send_text.


wa_rec-recipient = CL_SAPUSER_BCS=>CREATE( SY-UNAME ).
append wa_rec to it_rec.

TRY.
CALL METHOD cl_bcs=>short_message
  EXPORTING
    I_subject       = 'doc_title'
    I_TEXT          = it_send_text
    I_RECIPIENTS    = it_rec
*    I_ATTACHMENTS   =
*    I_APPL_OBJECT   =
*    I_STARTING_AT_X =
*    I_STARTING_AT_Y =
*    I_ENDING_AT_Y   =
*    I_ENDING_AT_X   =
*  receiving
*    RESULT          =
  .
  CATCH CX_SEND_REQ_BCS .
  CATCH CX_BCS .
ENDTRY.

but it doesnt work...

Steffen

Read only

0 Likes
2,302

this is not enough .

the method call would return cl_bcs type variable and using that you have to send.

i will write the code and update in a while

Read only

0 Likes
2,302

i just checked this message and you cannot use this BSP page.

cl_bcs=>short_message

message actually brings up the SAP gui screen (short message) where you have to click send. this is not suitable.

you just want to send some text info as email to users sap inbox right. if yes check out this demo programs using cl_bcs classes.

BCS_EXAMPLE_*

If you still find problem following them, do let me know.

Raja

Read only

0 Likes
2,302

also check this code sample.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5931ff64-0a01-0010-2bb7-ff2f9a61...

you can easily modify this code sample to suit your requirement.

Raja

Read only

0 Likes
2,302

alright, these examples helps me so much (especialy example 3), that I have done it!

Thanks

regards,

Steffen