SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Хранение данных с использованием GOS



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SAP Business Workflow
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Tue Mar 04, 2008 6:47 pm    Post subject: Хранение данных с использованием GOS Reply with quote

Автор: alex95043
Источник: http: //sapboard.ru/forums/viewtopic.php?t=27132#182947

Попробовал сделать через GOS. Выглядит примерно так:

Code:
REPORT ztn082_set_1 .

* Include for BO macros
INCLUDE : <cntn01>.

TABLES: ztn_eshop_mkey.



PARAMETERS:
 p_msgtyp  LIKE sofm-doctp       DEFAULT 'PDF'     NO-DISPLAY,
 p_docty   LIKE borident-objtype DEFAULT 'MESSAGE' NO-DISPLAY,
* p_reltyp  LIKE breltyp-reltype  DEFAULT 'ATTA'    NO-DISPLAY,
 p_fname   LIKE rlgrap-filename.


DATA: lv_message_key LIKE sofmk.
DATA: lo_message TYPE swc_object.
DATA: lt_doc_content TYPE STANDARD TABLE OF soli-line
                           WITH HEADER LINE.
*  File Name - for upload.
DATA: p_file TYPE string.
*----------------------------------------------------------------------*
at selection-screen ON VALUE-REQUEST FOr p_fname.
  perform get_filename changing p_fname.

start-of-selection.


*----------------------------------------------------------------*

* Create an initial instance of BO 'MESSAGE' - to call the
* instance-independent method 'Create'.
swc_create_object lo_message 'MESSAGE' lv_message_key.

* define container to pass the parameter values to the method call
* in next step.
swc_container   lt_message_container.

* Populate container with parameters for method
swc_set_element lt_message_container 'DOCUMENTTITLE' 'TestDocument'.
swc_set_element lt_message_container 'DOCUMENTLANGU' 'E'.
swc_set_element lt_message_container 'NO_DIALOG'     'X'.
swc_set_element lt_message_container 'DOCUMENTNAME'   p_docty.
swc_set_element lt_message_container 'DOCUMENTTYPE'   p_msgtyp.

p_file = p_fname.

CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
          filename = p_file
          filetype = 'BIN'
     TABLES
          data_tab = lt_doc_content.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

* 'DocumentContent' is a multi-line element ( itab ).
swc_set_table lt_message_container 'DocumentContent' lt_doc_content.

* Size is required in case of File attachments
DATA : lv_doc_size TYPE i.
DATA : l_file_lines TYPE i.

DESCRIBE TABLE lt_doc_content LINES l_file_lines.

READ TABLE lt_doc_content INDEX l_file_lines.

lv_doc_size = ( 255 * ( l_file_lines - 1 ) ) +
            STRLEN( lt_doc_content ).

swc_set_element lt_message_container 'DOCUMENTSIZE'   lv_doc_size .

* Refresh to get the reference of create 'MESSAGE' object for attachment
swc_refresh_object lo_message.
swc_call_method lo_message 'CREATE' lt_message_container.

* Get Key of new object
swc_get_object_key lo_message lv_message_key.


Ключ lv_message_key сохраняею в таблице, после его вызываю
и вытаскиваю документ...

Code:
DATA: document_id LIKE sofolenti1-doc_id.
document_id = lv_message_key.

DATA: doc_data LIKE sofolenti1.

CALL FUNCTION 'SO_DOCUMENT_READ_API1'
     EXPORTING
          document_id                = document_id
          filter                     = 'X'
     IMPORTING
          document_data              = doc_data
     TABLES
          object_header              = lt_header
          object_content             = lt_content
     EXCEPTIONS
          document_id_not_exist      = 1
          operation_no_authorization = 2
          x_error                    = 3
          OTHERS                     = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

...

  CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
            bin_filesize = bin_filesize
            filename     = p_file
            filetype     = 'BIN'
            write_lf     = ''
       TABLES
            data_tab     = lt_content.
  COMMIT WORK.
ENDIF.


файл загружается - выгружается без проблем.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SAP Business Workflow All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.