Application Development 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: 

Archivelink: Database error SICF ?

RicardoRomero_1
Active Contributor
0 Kudos

Hello,
I would want to use archivelink saving the data in SAP system database.

I've created in OAC0 this content repository:

Table ZSM_FILES_CONT is a copy of SDOKCONT1.

I've created a custom object in swo1 and did the configuration in spro...

I have this in OAC3:

I have a sample program to add content from a file using FM ARCHIVOBJECT_CREATE_FILE and ARCHIV_CONNECTION_INSERT.

I think is working fine It's not returning any exceptions, I have the doc id and table ZSM_FILES_CONT is growing.

But now I want to read the file using FM ARCHIV_GET_CONNECTIONS and ARCHIVOBJECT_GET_BYTES, and with this last FM ARCHIVOBJECT_GET_BYTES I'm getting a error.

This error:

If I go to SICF and put an user, then I get this error CMS025:

HTTP error: 401 unauthorized

Is it necessary to define a user in SCIF for this ??? I only want to save the files in the database....

----
I think the code of the program is ok, If I use another existing content repository (but using HTTP content server) is working fine. I only need to change OAC3 to use this content and works fine.

This is the other content:

Do you know what I need to do to use the SAP System Database ??

Thanks in advance.

Regards.

1 ACCEPTED SOLUTION

karim_benakli_kb
Participant

Hi,

this is SAP standard behaviour, in many cases the /sap/bc/contentserver service is used by default, and must therefore be correctly activated.

This is described in OSS notes 685521 and 1898201

Rgds,

Karim

16 REPLIES 16

RicardoRomero_1
Active Contributor
0 Kudos

This is the code, in case you want to check it:

REPORT ztest_archivelink.
PARAMETERS:
pa_cs TYPE toaar-archiv_id DEFAULT 'ZF',
pa_file TYPE string.
DATA:
lv_document_type LIKE toadd-doc_type VALUE 'ZSM_F_PDF',
lv_path LIKE sapb-sappfad,
lv_doc_id TYPE sapb-sapadokid.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file.
PERFORM ayuda_file.
START-OF-SELECTION.
lv_path = pa_file.
CALL FUNCTION 'ARCHIVOBJECT_CREATE_FILE'
EXPORTING
archiv_id = pa_cs
document_type = lv_document_type
path = lv_path
* VSCAN_PROFILE = '/SCMS/KPRO_CREATE'
IMPORTING
archiv_doc_id = lv_doc_id
EXCEPTIONS
error_archiv = 1
error_communicationtable = 2
error_upload = 3
error_kernel = 4
blocked_by_policy = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE 'Error' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
DATA:
lv_object_id TYPE sapb-sapobjid,
lv_desc TYPE toaat-descr,
lv_ar_object TYPE toaom-ar_object VALUE 'ZSM_F_PDF',
lv_filename TYPE toaat-filename.
CONCATENATE 'ZSM_FILES' sy-datum sy-uzeit INTO
lv_object_id SEPARATED BY '_'.
CONCATENATE 'Test' sy-datum sy-uzeit INTO lv_desc SEPARATED BY '_'.
lv_filename = pa_file.
CALL FUNCTION 'ARCHIV_CONNECTION_INSERT'
EXPORTING
archiv_id = pa_cs
arc_doc_id = lv_doc_id
* AR_DATE = ' '
ar_object = lv_ar_object
* DEL_DATE = ' '
* MANDANT = ' '
object_id = lv_object_id
sap_object = 'ZSM_FILES'
doc_type = ' '
* BARCODE = ' '
filename = lv_filename
descr = lv_desc
* CREATOR = ' '
EXCEPTIONS
error_connectiontable = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE 'Error' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
*--------------------------------------------------------------------*
* All ok at this point, no errores, and I get the DOC_ID
*--------------------------------------------------------------------*
*--------------------------------------------------------------------*
* Now trying to read the file
*--------------------------------------------------------------------*
DATA :
lv_doctype TYPE saedoktyp ,
lv_fullpath TYPE string ,
lv_length TYPE num12 ,
lv_offset TYPE num12 ,
lv_path_down TYPE string ,
lv_size TYPE i ,
ls_objecttype TYPE saeanwdid,
ls_object_id TYPE saeobjid,
ls_connection TYPE toav0,
lt_connections TYPE toav0_t,
lv_file TYPE string ,
lt_data TYPE STANDARD TABLE OF TBL1024.
* Get the list of documents link to the BO
ls_objecttype = 'ZSM_FILES'.
ls_object_id = lv_object_id.
CALL FUNCTION 'ARCHIV_GET_CONNECTIONS'
EXPORTING
objecttype = ls_objecttype
object_id = ls_object_id
TABLES
connections = lt_connections
EXCEPTIONS
nothing_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
RETURN.
ENDIF.
* Read any entry
READ TABLE lt_connections
INTO ls_connection
INDEX 1.
IF sy-subrc <> 0.
MESSAGE 'Error' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDIF.
* Change the type of the field for Document Type (=PDF)
MOVE ls_connection-reserve TO lv_doctype.
* Get the Content of the entry in Binary Mode (more simple for PDF)
CALL FUNCTION 'ARCHIVOBJECT_GET_BYTES'
EXPORTING
archiv_id = ls_connection-archiv_id
archiv_doc_id = ls_connection-arc_doc_id
document_type = lv_doctype
length = lv_length
offset = lv_offset
IMPORTING
binlength = lv_length
TABLES
binarchivobject = lt_data
EXCEPTIONS
error_archiv = 1
error_communicationtable = 2
error_kernel = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
RETURN.
ENDIF.
* Ask user for the name and the location of the file
CALL METHOD cl_gui_frontend_services=>file_save_dialog
CHANGING
filename = lv_file
path = lv_path_down
fullpath = lv_fullpath
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
RETURN.
ENDIF.
MOVE lv_length TO lv_size.
* Save the file.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = lv_size
filename = lv_file
filetype = 'BIN'
CHANGING
data_tab = lt_data
EXCEPTIONS
OTHERS = 24.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
RETURN.
ENDIF.
*&---------------------------------------------------------------------*
*& Form P_AYUDA_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ayuda_file.
DATA: lv_titulo TYPE string.
DATA: ls_filetable TYPE file_table,
lt_filetable TYPE STANDARD TABLE OF file_table.
DATA: lv_rc TYPE i.
lv_titulo = text-001.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = lv_titulo
default_extension = '*.*'
initial_directory = 'U:\'
CHANGING
file_table = lt_filetable
rc = lv_rc.
READ TABLE lt_filetable INDEX 1 INTO ls_filetable.
IF sy-subrc EQ 0.
pa_file = ls_filetable-filename.
ENDIF.
ENDFORM. " P_AYUDA_FILE

FredericGirod
Active Contributor
0 Kudos

Did you check when you try to read the archiv if you access the ZF or Z2 content repository ?

Normally the content repository is available from the link table you have defined TOA01

RicardoRomero_1
Active Contributor
0 Kudos

How to check if I have access to this repositories ? With Z2 it's working fine, I can read the file and download it, and its ok.


I see that tabla TOA01 has the new entries I've created from the report.

FredericGirod
Active Contributor
0 Kudos

Did you try to check if your program get the correct information ?

for example here:

* Get the list of documents link to the BO
ls_objecttype ='ZSM_FILES'.
ls_object_id = lv_object_id.
CALLFUNCTION'ARCHIV_GET_CONNECTIONS'
EXPORTING
objecttype = ls_objecttype
object_id = ls_object_id
TABLES
connections = lt_connections
EXCEPTIONS
nothing_found =1
OTHERS=2.
IFsy-subrc <>0.

Sandra_Rossi
Active Contributor
0 Kudos

I don't understand why you maintain SICF if you're using a database table as content repository to store your documents. SICF is mainly for services corresponding to inbound connections.

What error do you have concerning the database table?

RicardoRomero_1
Active Contributor
0 Kudos

@Sandra, I'm not using SICF, this is the error I've got. Dont know why.
Is there any incorrect in my content repository? may be this is the problem.
Where is the settings to this SICF service used... First time I'm creating a content repository, but I didnt put anything about SICF in it (or not?). I only want to use database tables...
Is there any other FM to get the data instead of ARCHIVOBJECT_GET_BYTES?

@Frederic, Yes, with this FM I've got the files linked to the id of my BO.

FredericGirod
Active Contributor
0 Kudos

yes your customizing looks OK

maybe the link between th document type & the content repository ...

it is why I ask you to check if your report get the correct repository depending of the document.

For me the SICF error is due to incorrect content respository determination

RicardoRomero_1
Active Contributor
0 Kudos

Yes, this sample program is creating the file and afterwards trying to read it.
I've got a Doc Id when I'm creating the file, and with this FM I'm obtaining the same Doc Id.
So I guess it's ok.
To create the file linked with my custom BO I'm using as BO key a different time stamp each time, so I'm only getting one unique connection, only one exists from the file I've just created.

RicardoRomero_1
Active Contributor
0 Kudos

this is the last execution, the ARCHIV_ID is ZF, so I think its ok

Sandra_Rossi
Active Contributor
0 Kudos

Ricardo Romero Mata You must NOT use SICF if you store documents in database table.

Sandra_Rossi
Active Contributor
0 Kudos

There's one design issue in your program: the document type ZSM_F_PDF is hardcoded, so it means that its content repository (OAC3) should be used, consequently defining the content repository as an input parameter is non-sense.

karim_benakli_kb
Participant

Hi,

this is SAP standard behaviour, in many cases the /sap/bc/contentserver service is used by default, and must therefore be correctly activated.

This is described in OSS notes 685521 and 1898201

Rgds,

Karim

0 Kudos

Nice! More easy to follow via the screenshots of the note 1898201 - Access fails to repository on 'R/3 system database'.

I reproduce the symptom, and it happens only with ArchiveLink and only for reading (ARCHIVOBJECT_GET_..., SCMS_AO_...)

If I read directly the content repository via SCMS_DOC_READ (need to define a storage category in OACT to refer to ZF), there is no more error.

I really wonder why there is such a difference...

0 Kudos

That was the problem !!! Thanks !!!

0 Kudos

Hi, Sandra.

Thanks for the reference of FM SCMS_DOC_READ and OACT, this exactly what I need.

The custom BO is not necessary for this requirement anymore !

RicardoRomero_1
Active Contributor
0 Kudos

Hi, Sandra, problem solved with note 685521.


Report has not any problems (well it's a test program... ). As I understood you can specify the same document type for several links in OAC3.

You define the different document types in this SPRO path, with no relation with a content repository:
Spro -> SAP NetWeaver -> Basis Services -> ArchiveLink -> Basic Customizing -> Edit Document Types

Then, in Edit Links, you can use this document type in several "links".

In my case the document type was new, created for this requierement and only used for my custom BO and content repository.