SOFM
Florin Wach (gmx)
florin.wach at gmx.net
Fri May 2 05:26:57 EDT 2008
Hi,
you'll need to convert an internal table from structure length 1024 to 255.
There is a SAP Function and Kernel Call that can do this. I think it was CONVERT_TABLE
This is working fine.
Before I have stumbled over this simple function call, I have programmed it myself to send an ArchiveLink document as an Office attachment.
This is how I did it (but I'm not a 100% sure if this is the very latest, bugfree, version).
For more programming techniques I would advice to ask in the ABAP Forums of the SDN.
Best wishes,
Florin
FUNCTION Z_WF_GET_DOC_FOR_SAPOFFICE .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(ARCHIV_ID) LIKE TOAV0-ARCHIV_ID
*" VALUE(ARC_DOC_ID) LIKE TOAV0-ARC_DOC_ID
*" EXPORTING
*" VALUE(LENGTH) TYPE I
*" TABLES
*" ATTACHMENT STRUCTURE SOLISTI1 OPTIONAL
*" EXCEPTIONS
*" ERROR_RETRIEVAL
*"----------------------------------------------------------------------
DATA: binobject LIKE TBL1024 OCCURS 200,
archivobject LIKE DOCS OCCURS 200 WITH HEADER LINE,
length_bin TYPE I,
length_att TYPE I,
length_archive LIKE SAPB-LENGTH.
REFRESH: binobject, attachment.
CALL FUNCTION 'SCMS_AO_TABLE_GET'
EXPORTING
ARC_ID = archiv_id
DOC_ID = arc_doc_id
COMP_ID = 'data'
IMPORTING
LENGTH = length_bin
TABLES
DATA = binobject
EXCEPTIONS
error_http = 1
error_archiv = 2
error_kernel = 3
error_config = 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
RAISING ERROR_RETRIEVAL.
ENDIF.
CALL FUNCTION 'SCMS_BINARY_TO_FTEXT'
EXPORTING
input_length = length_bin
IMPORTING
output_length = length_att
TABLES
binary_tab = binobject
ftext_tab = archivobject
EXCEPTIONS
failed = 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
RAISING ERROR_RETRIEVAL.
ENDIF.
length_att = length_bin.
length_archive = length_att.
CALL FUNCTION 'Z_WF_CONVERT_DOCTABLE_2_OFFICE'
EXPORTING
LENGTH = length_archive
TABLES
ARCHIVOBJECT = archivobject
ATTACHMENT = attachment.
length = length_archive.
ENDFUNCTION.
FUNCTION Z_WF_CONVERT_DOCTABLE_2_OFFICE.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(LENGTH) LIKE SAPB-LENGTH
*" TABLES
*" ARCHIVOBJECT STRUCTURE DOCS
*" ATTACHMENT STRUCTURE SOLISTI1
*"----------------------------------------------------------------------
****** Die ArchiveLink-API liefert das Dokument in einer internen
****** Tabelle, der Länge 1024 zurück.
****** SAP-Office-API benötigt eine interne Tabelle der Länge 255.
******
****** Diese Funktion konvertiert von der ArchiveLink-Tabelle in
****** die SAP-Office konforme Tabelle.
DATA: currentPos TYPE I, " Zeiger auf die Leseposition in
" der ArchiveLink-Tabelle
writePos TYPE I, " Zeiger auf Schreibposition
remain TYPE I, " Anzahl Zeichen in der aktuellen
" Zeile des ArchiveLink-Objektes,
" Max=255
written TYPE I, " Anzahl bytes übertragen
targetLines TYPE I, " Größe der Zieltabelle in Zeilen
lines_attachment TYPE I, " Anzahl der Zeilen im Attachement.
currentIndex TYPE I, " Aktuelle Zeile in der Quelltab.
line_out(255) TYPE C,
line_attachment TYPE solix,
line_len TYPE I. " Länge derselbigen
currentPos = 0.
writePos = 0.
REFRESH: attachment.
CLEAR: line_out, attachment.
targetLines = length / 255.
" Rest prüfen
remain = length - ( targetLines * 255 ).
IF remain <> 0. " Ja, noch eine Restzeile
ADD 1 TO targetLines.
ENDIF.
remain = 255. " Wieder initialisieren
currentIndex = 1.
WHILE lines_attachment <= targetLines.
READ TABLE archivobject INDEX currentIndex.
line_Out+writePos(remain) = archivobject+currentPos(remain).
" Concat schluckt spaces
written = remain.
line_len = writePos + remain. " writePos beginnt ja bei 1
writePos = writePos + remain.
IF writePos = 255. " Voll gefüllt, dann appenden
APPEND line_out TO attachment.
CLEAR line_out.
writePos = 0.
ELSEIF writePos > 255.
" exception
ENDIF.
" Jetzt prüfen, ob dies bereits der Rest der Quell-Zeile war.
" Wenn ja, dann müssen wir beim nächsten Durchlauf die
" nächste Zeile lesen.
IF currentPos > 769.
ADD 1 TO currentIndex.
" Und den Rest ausrechnen, mit dem die nächste Zeile
" noch gefüllt werden muss.
remain = currentPos + 255 - 1024.
*---> Insert part IIId
" Wenn die letzten Bytes exakt reingepaßt haben, dann eine
" neue volle zeile lesen
IF remain <= 0.
remain = 255.
ENDIF.
*<---- end of Insert
currentPos = 0.
ELSE. " Die aktuelle Zeile enthält noch genügend Bytes, um
" voll zu lesen.
ADD written TO currentPos. " Zeiger weiterschieben
IF currentPos > 769. " Nächste Zeile kann nicht mehr
" voll gefüllt werden, da keine
" 255 byte übrig sind
*---> Insert part IIId
IF currentPos >= 1024. " Hat genau bis zum Ende gereicht
remain = 255.
ADD 1 TO currentIndex.
currentPos = 0.
ELSE.
remain = 1024 - currentPos. " Rest ausrechnen
ENDIF.
*<---- end of Insert
ELSE.
remain = 255. " sonst voll befüllen
ENDIF.
ENDIF.
DESCRIBE TABLE attachment LINES lines_attachment.
ENDWHILE.
ENDFUNCTION.
----- Original Message -----
From: a.v.n.r kumar
To: SAP Workflow Users' Group
Sent: Friday, May 02, 2008 7:36 AM
Subject: SOFM
Hi,
I can get the doucment details using ARCHIVOBJECT_GET_TABLE. It returns the data in 1024 char table. The SOFM object needs data of 255 char. How can we convert this.
Thanks
Raghavendra
"Florin Wach (gmx)" <florin.wach at gmx.net> wrote:
Hi,
instantiate the object type IMAGE and execute IMAGE.Display as "Secondary Method" to display the archived document together with the workitem's execution.
If you just want to add a hyperlink to the document in the workitem display, use a container operation _ADHOC_OBJECT <- &IMAGE& and add it there.
Best wishes,
Florin
----- Original Message -----
From: a.v.n.r kumar
To: sap-wug at mit.edu
Sent: Thursday, May 01, 2008 3:40 PM
Subject: How to attach archived documents in the Workitem
Hi,
How to attach archived documents in the Workitem.
Thanks
Raghavendra
--------------------------------------------------------------------------
Unlimited freedom, unlimited storage. Get it now
--------------------------------------------------------------------------
_______________________________________________
SAP-WUG mailing list
SAP-WUG at mit.edu
http://mailman.mit.edu/mailman/listinfo/sap-wug
_______________________________________________
SAP-WUG mailing list
SAP-WUG at mit.edu
http://mailman.mit.edu/mailman/listinfo/sap-wug
------------------------------------------------------------------------------
Meet people who discuss and share your passions. Join them now.
------------------------------------------------------------------------------
_______________________________________________
SAP-WUG mailing list
SAP-WUG at mit.edu
http://mailman.mit.edu/mailman/listinfo/sap-wug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20080502/ea34ef36/attachment.htm
More information about the SAP-WUG
mailing list