Skip to Content

Dear All,

This document for KM content file upload & download procedure.

I have used web dynpro ABAP for frontend screen. Displayed using

Webdynpro adobe interactive form.(Please Refer Next Post for access of this class using WDA)

Using class web service we can upload & download file.

Enjoy with this document…….

Create Web service consumer proxy:

Ask your portal consultant for web service WSDL link to create consumer proxy.

http://999.19.99.999:99900/RepositoryFrameworkWS/Config?wsdl

Now system will generate “ZESS_ABCD_REPOSITORY_FRAMEW”.” This is copy of standard class “CO_KMCWS_REPOSITORY_FRAMEWORK”

We will use this class into our ZCLASS below.

Create Logical port name.

Select  Web Service Configuration

Create Your Logical port name.


Now we can start to create our custom Z class. This we will use in our programs.

Create Class:

  ZCL_KM_HPLOAD

Create two methods:

UPLOAD_DOCUMENT

DOWNLOAD_DOCUMENT

Upload Method Parameter:

IM_DOC_NAME    STRING

IM_MIME_TYPE    STRING

IM_CONTENT        HRTMC_XSTRING

IM_LENGTH          STRING

IM_PERNR            CHAR8

IM_DOC_TYPE      STRING

IM_DOC_FOR      STRING

IM_IMG_NAME    STRING

EX_RETURN        STRING

Download Method Parameter:


FILE_PATH    STRING

DOC_NAME    STRING

MIME_TYPE    STRING

CONTENT      HRTMC_XSTRING

LEGNTH          INT4

RETURN        STRING

Upload Code:

METHOD UPLOAD_DOCUMENT.

DATA: OBJ_KM TYPE REF TO ZESS_ABCD_REPOSITORY_FRAMEW.
DATA: ER TYPE REF TO CX_ROOT.
DATA: E_ML1 TYPE STRING.
DATA: TYPE REF TO CX_ROOT.
DATA: E1 TYPE REF TO CX_ROOT.
DATA: E2 TYPE REF TO CX_ROOT.
DATA: E3 TYPE REF TO CX_ROOT.
DATA: E_ML TYPE STRING.
DATA: LV_STRING TYPE STRING.

*************Call Logical port name
TRY.
CREATE OBJECT OBJ_KM
EXPORTING
LOGICAL_PORT_NAME
= ‘LS_ESS_KM’.
CATCH CX_AI_SYSTEM_FAULT INTO ER.
E_ML1
= ER->GET_TEXT( ).
ENDTRY.

*************Create Folder

DATA: INPUT3 TYPE ZESS_HC_KMCREATE_COLLECTION_IN.
DATA: OUTPUT3 TYPE ZESS_HC_KMCREATE_COLLECTION_OU.

INPUT3PARENT_COLLECTION_RID = ‘/documents/Personnel File/Admin Documents’.
INPUT3
CHILD_NAME = IM_PERNR.
CLEAR: E_ML.
TRY.
CALL METHOD OBJ_KM->CREATE_COLLECTION
EXPORTING
INPUT  = INPUT3
IMPORTING
OUTPUT = OUTPUT3.
CATCH CX_AI_SYSTEM_FAULT INTO E.
E_ML
= E->GET_TEXT( ).
CATCH ZESS_HC_KMCX_CREATE_COLLECTION INTO E1.
E_ML
= E1->GET_TEXT( ).
CATCH ZESS_HC_KMCX_REPOSITORY_FRAM71 INTO E2.
E_ML
= E2->GET_TEXT( ).
CATCH CX_AI_APPLICATION_FAULT INTO E3.
E_ML
= E3->GET_TEXT( ).
ENDTRY.
*
CLEAR: LV_STRING.
CONCATENATE ‘/documents/Personnel File/Admin Documents/’IM_PERNR INTO LV_STRING.

INPUT3PARENT_COLLECTION_RID = LV_STRING.
INPUT3
CHILD_NAME = IM_DOC_TYPE.

TRY.
CALL METHOD OBJ_KM->CREATE_COLLECTION
EXPORTING
INPUT  = INPUT3
IMPORTING
OUTPUT = OUTPUT3.
CATCH CX_AI_SYSTEM_FAULT INTO E.
E_ML
= E->GET_TEXT( ).
CATCH ZESS_HC_KMCX_CREATE_COLLECTION INTO E1.
E_ML
= E1->GET_TEXT( ).
CATCH ZESS_HC_KMCX_REPOSITORY_FRAM71 INTO E2.
E_ML
= E2->GET_TEXT( ).
CATCH CX_AI_APPLICATION_FAULT INTO E3.
E_ML
= E3->GET_TEXT( ).
ENDTRY.

CLEAR: LV_STRING.
CONCATENATE ‘/documents/Personnel File/Admin Documents/’  IM_PERNR ‘/’ IM_DOC_TYPE INTO LV_STRING.

INPUT3PARENT_COLLECTION_RID = LV_STRING.
INPUT3
CHILD_NAME = IM_DOC_FOR.
CLEAR: E_ML.
TRY.
CALL METHOD OBJ_KM->CREATE_COLLECTION
EXPORTING
INPUT  = INPUT3
IMPORTING
OUTPUT = OUTPUT3.
CATCH CX_AI_SYSTEM_FAULT INTO E.
E_ML
= E->GET_TEXT( ).
CATCH ZESS_HC_KMCX_CREATE_COLLECTION INTO E1.
E_ML
= E1->GET_TEXT( ).
CATCH ZESS_HC_KMCX_REPOSITORY_FRAM71 INTO E2.
E_ML
= E2->GET_TEXT( ).
CATCH CX_AI_APPLICATION_FAULT INTO E3.
E_ML
= E3->GET_TEXT( ).
ENDTRY.

**********Create New Document

DATA: INPUT1 TYPE ZESS_HC_KMCREATE_DOCUMENT_IN.
DATA: OUTPUT1 TYPE ZESS_HC_KMCREATE_DOCUMENT_OUT.
CLEAR: LV_STRING.
CONCATENATE ‘/documents/Personnel File/Admin Documents/’  IM_PERNR ‘/’ IM_DOC_TYPE ‘/’ IM_DOC_FOR INTO LV_STRING.

INPUT1PARENT_COLLECTION_RID    = LV_STRING.
INPUT1
CHILD_NAME              = IM_IMG_NAME.
INPUT1
CONTENTCONTENT          = IM_CONTENT.
INPUT1
CONTENTMETADATALENGTH  = IM_LENGTH.
INPUT1
CONTENTMETADATATYPE    = IM_MIME_TYPE.
CLEAR: E_ML.
TRY.
CALL METHOD OBJ_KM->CREATE_DOCUMENT
EXPORTING
INPUT  = INPUT1
IMPORTING
OUTPUT = OUTPUT1.
CATCH CX_AI_SYSTEM_FAULT INTO E.
E_ML
= E->GET_TEXT( ).
CATCH ZESS_HC_KMCX_CREATE_DOCUMENT_F INTO E1.
E_ML
= E1->GET_TEXT( ).
CATCH ZESS_HC_KMCX_REPOSITORY_FRAM70 INTO E2.
E_ML
= E2->GET_TEXT( ).
CATCH CX_AI_APPLICATION_FAULT INTO E3.
E_ML
= E3->GET_TEXT( ).

ENDTRY.

********Existing Image Can over write

IF E_ML IS NOT INITIAL.

DATA: INPUT4  TYPE ZESS_HC_KMSET_CONTENT_IN.
DATA: OUTPUT4 TYPE ZESS_HC_KMSET_CONTENT_OUT.
CLEAR: LV_STRING, E_ML.
CONCATENATE ‘/documents/ Personnel File/Admin Documents ‘/’IM_PERNR ‘/’ IM_DOC_TYPE ‘/’ IM_DOC_FOR ‘/’ IM_IMG_NAME INTO LV_STRING.

INPUT4RID = LV_STRING.
INPUT4
CONTENTCONTENT = IM_CONTENT.
INPUT4
CONTENTMETADATALENGTH  = IM_LENGTH.
INPUT4
CONTENTMETADATATYPE    = IM_MIME_TYPE.

TRY.
CALL METHOD OBJ_KM->SET_CONTENT
EXPORTING
INPUT  = INPUT4
IMPORTING
OUTPUT = OUTPUT4.
CATCH CX_AI_SYSTEM_FAULT INTO E.
E_ML
= E->GET_TEXT( ).
CATCH ZESS_HC_KMCX_SET_CONTENT_FAULT INTO E1.
E_ML
= E1->GET_TEXT( ).
CATCH ZESS_HC_KMCX_REPOSITORY_FRAM14 INTO E2.
E_ML
= E2->GET_TEXT( ).
CATCH CX_AI_APPLICATION_FAULT INTO E3.
E_ML
= E3->GET_TEXT( ).
ENDTRY.

ENDIF.

IF E_ML IS NOT INITIAL.
EX_RETURN
= E_ML.
ELSE.
EX_RETURN
= ‘Successfully Uploaded’.
ENDIF.

ENDMETHOD.

Download Code:

METHOD DOWNLOAD_DOCUMENT.

DATA: OBJ_KM TYPE REF TO ZESS_ABCD_REPOSITORY_FRAMEW.
DATA: ER TYPE REF TO CX_ROOT.
DATA: E_ML1 TYPE STRING.

TRY.
CREATE OBJECT OBJ_KM
EXPORTING
LOGICAL_PORT_NAME
= ‘LS_ESS_KM’.
CATCH CX_AI_SYSTEM_FAULT INTO ER.
E_ML1
= ER->GET_TEXT( ).
ENDTRY.

DATA: E    TYPE REF TO CX_ROOT.
DATA: E1    TYPE REF TO CX_ROOT.
DATA: E2    TYPE REF TO CX_ROOT.
DATA: E3    TYPE REF TO CX_ROOT.
DATA: E_ML  TYPE STRING.

DATA: INPUT TYPE ZESS_HC_KMGET_CONTENT_IN,
OUPUT
TYPE ZESS_HC_KMGET_CONTENT_OUT.

INPUTRID = FILE_PATH.

TRY.
CALL METHOD OBJ_KM->GET_CONTENT
EXPORTING
INPUT  = INPUT
IMPORTING
OUTPUT = OUPUT.
CATCH CX_AI_SYSTEM_FAULT  INTO E.
E_ML
= E->GET_TEXT( ).
CATCH ZESS_HC_KMCX_GET_CONTENT_FAULT  INTO E1.
E_ML
= E1->GET_TEXT( ).
CATCH ZESS_HC_KMCX_REPOSITORY_FRAM51  INTO E2.
E_ML
= E2->GET_TEXT( ).
CATCH CX_AI_APPLICATION_FAULT  INTO E3.
E_ML
= E3->GET_TEXT( ).
ENDTRY.
IF E_ML IS INITIAL.
MIME_TYPE
= OUPUTRESPONSEMETADATATYPE.
CONTENT 
= OUPUTRESPONSECONTENT.
LEGNTH   
= OUPUTRESPONSEMETADATALENGTH.
*DOC_NAME =
*FILE_PATH =

ELSE.
RETURN = ‘Image is not gound’.
ENDIF.

ENDMETHOD.

********Next document for This class can use in WDA screen

SAP Portal KM content Image upload/download using web dynpro ABAP

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Chad Schmidt

    Thank you for the excellent article.  The link at the bottom which I was hoping would show the WD4A code for calling your custom class, and more importantly what values you are supplying such as the content, mime type, etc., seems to lead to a page that has limited access (authorization).  Could you possibly re-post somewhere else or even to this comment in reply?

    Thanks!

    (0) 

Leave a Reply