on 2024 Oct 15 2:33 PM
Hello,
I thought of creating a custom class in order to call the function 'SO_DOCUMENT_READ_API1' to read the SOFM text from a user's comment and then implement it as text in an email notification task.
I don't want to create a custom object and add this method inside for now so I thought of creating an ABAP Class and calling the method from here.
The code I used is:
method EXTRACT.
DATA: lt_object_content TYPE TABLE OF soli,
lv_document_text TYPE string,
ls_content TYPE soli.
" Call the function module to extract the text from the SOFM object
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = iv_document_id
TABLES
object_content = lt_object_content
EXCEPTIONS
no_authorization = 1
document_not_found = 2
others = 3.
" Check for the return value of the function module
IF sy-subrc = 0.
" Concatenate the text into a single string (using APPEND for better performance)
LOOP AT lt_object_content INTO ls_content.
" Append the line to the final text variable
lv_document_text = lv_document_text && ls_content-line && cl_abap_char_utilities=>newline.
ENDLOOP.
" Set the extracted text to the output parameter
rv_document_text = lv_document_text.
ELSE.
" Handle error scenario with more specific messages
CASE sy-subrc.
WHEN 1.
rv_document_text = 'No authorization to read the document'.
WHEN 2.
rv_document_text = 'Document not found'.
WHEN OTHERS.
rv_document_text = 'Error reading SOFM object'.
ENDCASE.
ENDIF.
endmethod.
with two insert and export parameters
import: IV_DOCUMENT_ID
export: RV_DOCUMENT_TEXT
I dont know if this code works because it is still in process mode when I test, the status doesnt go in completion (yes its a background job, I think a terminating event has to be raised).
What are all the necessary steps I should do? thank you very much in advance!
Request clarification before answering.
Hello thanks for the reply,
i have this error in the workflow
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello thanks for the reply,
I have this error in the workflow when trying to use the function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.