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

Attach a file on Z program

Former Member
0 Likes
2,816

Hello folks,

I need to attach an file (EXE, TXT, DOC, PDF) into my program.... I found a transaction who do that, but I can't find what method/function is used...

The transaction is FO36.

Someone can explain me how this transaction do that or know another way I can do that?

thx a lot...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,667

Yes... this transaction edit an build... but is not the focus... in the first screen, has a button with a pencil and a yellow dialog, with text <i>No Memo</i> or <i>Memo exists</i>... this create a memo, and I need to make a Z program that's do this for other purpose...

The memo is easy to create, but the problem has on attach an files with this memo, a friend passed me this transaction how an sample. But I can do this anyway I want.

6 REPLIES 6
Read only

amit_khare
Active Contributor
0 Likes
1,667

Welcome to SDN.

Are you sure it is FO36 as this tcode is for Real State Management?

http://help.sap.com/saphelp_46c/helpdata/EN/2c/2755eb456a11d189440000e829fbbd/frameset.htm

Instead try CV01N.

Regards,

Amit

Read only

Former Member
0 Likes
1,668

Yes... this transaction edit an build... but is not the focus... in the first screen, has a button with a pencil and a yellow dialog, with text <i>No Memo</i> or <i>Memo exists</i>... this create a memo, and I need to make a Z program that's do this for other purpose...

The memo is easy to create, but the problem has on attach an files with this memo, a friend passed me this transaction how an sample. But I can do this anyway I want.

Read only

0 Likes
1,667

Can't you use GOS Generic Object Services in this transaction for attaching documents ?? I can't test it quickcly overhere to see if it exists for this Tcode

Read only

0 Likes
1,667

I don't know much about GOS, it's not used only on standard transaction? Or can I use on Z program??

My program like a simples CRM, I use a client (kunnr) and a Call ID (Z Field) to make a key for a call memo, I will save with function <i>create text</i>... But also I need to attach an files with this memos, In last case I will use a open dataset and save on server file system... but I want to save the files in SAP using any function or another think like that...

thx for the reply...

Read only

0 Likes
1,667

Since it is not customized in my system I don't know if GOS is working.

But I see the elements available in DMS for use to link documents to.

VIOB01 Asset group

VIOB02 Real estate

VIOB03 Buildings

VIOB22 Room

spro menu

Cross-Application Components -> Document Management -> Control Data -> Define Document Types

if you have a document type you can add object links with

<i>Define object links</i>

where you can add the codes above

you create and link the document to you're assets in CV01N as mentioned above.

advantage of using DMS is that you can also access the documents by searching in CV04N . you can also add classification to maintain specific charateristics from the document (we use it for contracts and save the period and vendor for the contract and total value and responsible person)

hope this helps

arthur

Message was edited by:

A. de Smidt

Message was edited by:

A. de Smidt

Read only

Former Member
0 Likes
1,667

Hi there...

I found I program that do attach a file into a table... I think this will generate some problems on furture, but my client want the this solution... And if it happy I am happy...

Thats is the program to attach were I adapt to my program...

Thanks for all

-

-


REPORT ZARCHIVE.

***

TABLES : ZARCHIVE.

*****************

      • Variables ***

*****************

TYPES : BEGIN OF ty_data,

data type x,

END OF ty_data.

DATA : t_data type standard table of ty_data with header line.

DATA : t_data_tab type standard table of zarchive with header line.

******************

      • Parameters ***

******************

Parameters : p_upload type c radiobutton group rb1,

p_downlo type c radiobutton group rb1,

p_id(15) type n obligatory,

p_file(100) type c.

********************

      • Main Program ***

********************

if not p_upload is initial.

perform f_upload.

else.

perform f_download.

endif.

*************

      • Forms ***

*************

*&----


*

*& Form f_upload

*&----


*

FORM f_upload.

data : l_file type string,

l_c1 type i,

l_c2 type i,

l_data(1000) type x.

delete from zarchive where id = p_id.

l_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_file

FILETYPE = 'BIN'

TABLES

DATA_TAB = t_data

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

IF SY-SUBRC <> 0.

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

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

ENDIF.

***

DESCRIBE TABLE t_data.

CHECK sy-tfill > 0.

***

t_data_tab-id = p_id.

t_data_tab-filename = l_file.

l_c1 = 0.

l_c2 = 0.

loop at t_data.

l_data+l_c1 = t_data-data.

add 1 to l_c1.

if l_c1 = 1000.

add 1 to l_c2.

t_data_tab-partidx = l_c2.

t_data_tab-data_size = l_c1.

t_data_tab-data = l_data.

append t_data_tab.

clear l_c1.

clear l_data.

endif.

endloop.

add 1 to l_c2.

t_data_tab-partidx = l_c2.

t_data_tab-data_size = l_c1.

t_data_tab-data = l_data.

append t_data_tab.

***

modify zarchive from table t_data_tab.

ENDFORM. " f_upload

*&----


*

*& Form f_download

*&----


*

FORM f_download.

data : l_file type string,

l_c1 type i.

l_file = p_file.

SELECT *

INTO TABLE t_data_tab

FROM ZARCHIVE

WHERE ID = P_ID.

CHECK SY-SUBRC = 0.

***

LOOP AT t_data_tab.

DO t_data_tab-data_size times.

l_c1 = sy-index - 1.

t_data-data = t_data_tab-data+l_c1.

APPEND t_data.

ENDDO.

ENDLOOP.

***

DESCRIBE TABLE t_data.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

BIN_FILESIZE = sy-tfill

FILENAME = l_file

FILETYPE = 'BIN'

TABLES

DATA_TAB = t_data

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

IF SY-SUBRC <> 0.

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

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

ENDIF.

ENDFORM. " f_download

***************************************************************

  • Tabela que guarda os arquivos

***************************************************************

*Tabela transparente : ZARCHIVE

*Descrição breve : Files Achive

*

*Campos :

*

  • 1) MANDT MANDT CLNT 3 Mandante

  • 2) ID NUMC15 NUMC 15 Campo numérico do compr. 15

  • 3) PARTIDX NUMC05 NUMC 5 Campo numérico com compr. 5

  • 4) FILENAME CHAR255 CHAR 255 Char255

  • 5) DATA_SIZE INT2 INT2 5 2 Byte Integer (Signed)

  • 6) DATA LRAW1000 LRAW 1000 Cluster dados, compr.max.1000

*

******************************************************************

*Tabela exemplo:

*

*

*ID PARTIDX FILENAME DATA_SIZE DATA

*000000000000001 00001 C:TESTE.DOC 1.000 D0CF11E0...

*000000000000001 00002 C:TESTE.DOC 1.000 0000A353...

*000000000000001 00003 C:TESTE.DOC 1.000 00000000...

*000000000000001 00004 C:TESTE.DOC 1.000 4C494E4B...

*000000000000001 00005 C:TESTE.DOC 922 33362220...

*

*