cancel
Showing results for 
Search instead for 
Did you mean: 

Document Management with KPro csv problem

Former Member
0 Kudos

Hello Experts,

When customer sends e-mail including attachments to sap crm system, it creates activity and through my code I add that attachments into activity. Everything works fine but when customer sends csv type attachments, system cannot find mime type for it and its content. As a result, my code adds csv format document without its content. Clients cannot open csv attachments.System creates mail with ZL_CRM_ERMS_AH_CREATE_IR(CL_CRM_ERMS_AH_CREATE_IR) class and IF_CRM_ERMS_SERVICE~EXECUTE method in it.


lr_sc_mail_data = cl_crm_email_utility=>get_mail_data_from_so( iv_send_request_id = lv_bcs_key ) -> get_mail_data_from_send_req->.GET_MAIL_DATA_FROM_SEND_REQ


code return mail content and attachments content. Without csv type everything it is fine. But system when ı debug here GET_MAIL_DATA_FROM_SEND_REQ method ->

in code

CALL FUNCTION 'SKWF_MIMETYPE_OF_FILE_GET'

       EXPORTING

         FILENAME = LV_FILE

       IMPORTING

         MIMETYPE = LV_MIME_TYPE.


csv format is not found.

I try to add table to csv but now


-> get attachment's content from  KPRO

      CALL FUNCTION 'SO_KPRO_DATA_FROM_OBJCONT_GET'

        IMPORTING

          LOIO_OBJECT       = LS_LOIO_KPRO

        TABLES

          OBJCONT           = LT_OBJCONT

          CONTEXT           = LT_CONTEXT

        EXCEPTIONS

          MISSING_KPRO_DATA = 1

          OTHERS            = 2.

      CALL FUNCTION 'SO_LOIO_PHIO_GET'

        EXPORTING

          LOIO_OBJECT        = LS_LOIO_KPRO

        IMPORTING

          PHIO_OBJECT        = LS_PHIO_KPRO

        TABLES

          CONTEXT            = LT_CONTEXT

        EXCEPTIONS

          KPRO_INCONSISTENCY = 1

          X_ERROR            = 2

          OTHERS             = 3.

* --> Get content

      CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'

        EXPORTING

          OBJECT_ID           = LS_PHIO_KPRO

          TEXT_AS_STREAM      = 'X'

        TABLES

          FILE_CONTENT_BINARY = LT_CONTENT_BINARY

        EXCEPTIONS

          NOT_EXISTING        = 1

          NOT_AUTHORIZED      = 2

          NO_CONTENT          = 3

          BAD_STORAGE_TYPE    = 4

          OTHERS              = 5.


LS_LOIO_KPRO is initial for csv mime type so ı couldnt get csv format content.


so.


Does KPro support csv ? Should ı open note for it ?

Can ı find this csv attachments content somewhere ?

when activity created via class. we can find its relation SOFM in doc_flow. Can ı use  cl_crm_documents=>GET_INFO with this ?

Any suggestion for this situation. Will point given.

Thank You.



Accepted Solutions (1)

Accepted Solutions (1)

benedikt_wagner_mdt
Active Participant
0 Kudos

Hi Acar,

please check if extension "csv" is in tables SDOKMIME or SDOKMIME_C. If not add it in SDOKMIME_C. See note 1940722.

Regards,

Benedikt

Former Member
0 Kudos

Hi Benedikt,


Thank you for your reply.


I already try this way. Still no luck. My problem is this function is not load  LS_LOIO_KPRO.


for example  pdf attachments which in mail attachments.


CALL FUNCTION 'SO_KPRO_DATA_FROM_OBJCONT_GET'

         IMPORTING

           LOIO_OBJECT       = LS_LOIO_KPRO

         TABLES

           OBJCONT           = LT_OBJCONT

           CONTEXT           = LT_CONTEXT

         EXCEPTIONS

           MISSING_KPRO_DATA = 1

           OTHERS            = 2.


this function returns ,


LT_OBJCONT = &SO_KProObjectID=SOFFLOIO  0050568A1C3D1ED58DD319D7BA03D15E


LS_LOIO_KPRO =


                                   CLASS                                  SOFFLOIO
                                   OBJID                                 

0050568A1C3D1ED58DD319D7BA03D15E


here is where sap find attachments content (xstring). But for csv even ı fill tables which notes say. LS_LOIO_KPRO is empty. Without xstring content ı couldnt succesfully add attachemnts in my activity order.

benedikt_wagner_mdt
Active Participant
0 Kudos

Hi Acar,

just to be sure: you added csv (lower case) also to SDOKFEXT_C?

I had a look on coding of 'SO_KPRO_DATA_FROM_OBJCONT_GET'. It's quite simple.

Can you send screenshots of content of table LT_OBJCONT for pdf and csv?

There must be something different. It would be interesting where content of LT_OBJCONT comes from.

Maybe it helps to create a new test case (after csv/mime type is inserted into tables).

Generally KPRO can handle all file types. There is no aversion to csv files 🙂

Regards,

Benedikt

Former Member
0 Kudos

Hi Bendeikt,

Thank you for quick reply.

Yes im sure. Also ı add SDOKMIME table.

I test for xls.

This screenshot  get mime type for xls.

for csv it finds = csv   application/msexcel because ı fill the table with this

here the program find extct K for  xls and pdf but not for csv. For csv it is initial.

please look for if and else . if for -> xls pdf doc.

                                            else for ->csv

IF LS_OBJ_HEADER-EXTCT = 'K'. " because k is fill for pdf it find its content

* -> get attachment's content from  KPRO

       CALL FUNCTION 'SO_KPRO_DATA_FROM_OBJCONT_GET'

         IMPORTING

           LOIO_OBJECT       = LS_LOIO_KPRO

         TABLES

           OBJCONT           = LT_OBJCONT

           CONTEXT           = LT_CONTEXT

         EXCEPTIONS

           MISSING_KPRO_DATA = 1

           OTHERS            = 2.

       CALL FUNCTION 'SO_LOIO_PHIO_GET'

         EXPORTING

           LOIO_OBJECT        = LS_LOIO_KPRO

         IMPORTING

           PHIO_OBJECT        = LS_PHIO_KPRO

         TABLES

           CONTEXT            = LT_CONTEXT

         EXCEPTIONS

           KPRO_INCONSISTENCY = 1

           X_ERROR            = 2

           OTHERS             = 3.

* --> Get content

       CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'

         EXPORTING

           OBJECT_ID           = LS_PHIO_KPRO

           TEXT_AS_STREAM      = 'X'

         TABLES

           FILE_CONTENT_BINARY = LT_CONTENT_BINARY

         EXCEPTIONS

           NOT_EXISTING        = 1

           NOT_AUTHORIZED      = 2

           NO_CONTENT          = 3

           BAD_STORAGE_TYPE    = 4

           OTHERS              = 5.

* --> put data into string.

       CLEAR LV_DATA_BIN.

       LV_SIZE = LS_OBJ_HEADER-OBJLEN.

       CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

         EXPORTING

           INPUT_LENGTH = LV_SIZE

         IMPORTING

           BUFFER       = LV_DATA_BIN

         TABLES

           BINARY_TAB   = LT_CONTENT_BINARY.

       LS_MIME_BODY-CONTENT_BIN = LV_DATA_BIN.

     ELSE. " here for csv is running

* -> content is already in OBJCONT

       LV_SIZE = LS_OBJ_HEADER-OBJLEN.

       CALL FUNCTION 'SCMS_FTEXT_TO_STRING'

         EXPORTING

           LENGTH    = LV_SIZE

         IMPORTING

           FTEXT     = LS_MIME_BODY-CONTENT_ASCII

         TABLES

           FTEXT_TAB = LT_OBJCONT.

     ENDIF.

     APPEND LS_MIME_BODY TO EV_MAIL_DATA->BODY.

     endif.



IF LS_OBJ_HEADER-EXTCT = 'K'.  -> it finds xls content which ı use this content for my code.

for csv this content is initial this is my problem.

ı hope ı can explain myself 😃

benedikt_wagner_mdt
Active Participant
0 Kudos

Hi Acar,

next step is to analyse the output of function module SO_ATTACHMENT_READ.

  • what's the value of LS_OBJ_HEADER-EXTCT for csv?
  • Does LS_OBJ_HEADER-OBJLEN contain a sensible value?
  • Is there something in LT_OBJCONT?
  • there are additional export parameters OBJECT_RC_DISPLAY and OBJECT_FL_DISPLAY (Storage information about object); is there anything in it?

Regards,

Benedikt

Former Member
0 Kudos

Hi Benedikt,

So sorry for my late response because of my business. How can I get the content of the attachments through my code ?(using ZL_CRM_ERMS_AH_CREATE_IR(CL_CRM_ERMS_AH_CREATE_IR) class)

benedikt_wagner_mdt
Active Participant
0 Kudos

Hi Acar,

I have no CRM system here. So we have to do it step by step. Please debug again and give me the input/screenshots for my questions from my replay on Jul 30, 2015 2:36 PM.

Regards,

Benedikt

Former Member
0 Kudos

Hello Benedikt,

So much thanks for your replies.

I solve my problem myself. 😃  Focus wrong places all this time.

Here is my solution :

I make little repair to solve this problem.

Im writing this for people who have same problem.

Solution is :

in GET_MAIL_DATA_FROM_SEND_REQ

for csv code will IF LS_OBJ_HEADER-EXTCT initial.

in condition IF LS_OBJ_HEADER-EXTCT = 'K'. code will enter else.

CONTENT_BIN is what ı try to reach all this time. 😃

ELSE.

* -> content is already in OBJCONT

       LV_SIZE = LS_OBJ_HEADER-OBJLEN.

       CALL FUNCTION 'SCMS_FTEXT_TO_STRING'

         EXPORTING

           LENGTH    = LV_SIZE

         IMPORTING

           FTEXT     = LS_MIME_BODY-CONTENT_ASCII

         TABLES

*{   INSERT         TCPK900019                                        1

*

*}   INSERT

           FTEXT_TAB = LT_OBJCONT.

*{   INSERT         TCPK900019                                        2

*

           DATA LR_CHECK TYPE STRING.

*          IF LR_CHECK eq 'X'.

           CALL FUNCTION 'SCMS_FTEXT_TO_XSTRING'

             EXPORTING

               INPUT_LENGTH       = LV_SIZE

*             FIRST_LINE         = 0

*             LAST_LINE          = 0

*             MIMETYPE           = ' '

*             ENCODING           =

            IMPORTING

              BUFFER             = LV_DATA_BIN

             TABLES

               FTEXT_TAB          = LT_OBJCONT

            EXCEPTIONS

              FAILED             = 1

              OTHERS             = 2

                     .

           IF SY-SUBRC <> 0.

* Implement suitable error handling here

           ENDIF.

            LS_MIME_BODY-CONTENT_BIN = LV_DATA_BIN.

*          ENDIF.

*}   INSERT

     ENDIF.

Answers (0)