Issue with attaching pdf in work item

Ibrahim ikhansap at gmail.com
Sun Jan 8 00:43:42 EST 2012


Hi Ali,
  I tired using COMMIT WORK but still not working. I am still getting
ET_ITEMS as empty from the method GET_LINKS. Please find my code below and
let me know if I am missing something.

   ls_lprob-instid = '123'.
  ls_lprob-catid = 'BO'.
  ls_lprob-typeid =  'ZIKTEST'.

  CALL METHOD cl_fitv_gos=>save
    EXPORTING
      iv_name        = 'Test.pdf'
      iv_content_hex = zxstring
      is_lporb       = ls_lprob
      iv_objtp       = 'EXT'
    RECEIVING
      rt_messages    = lt_message.
  COMMIT WORK AND WAIT.

  CALL METHOD cl_fitv_gos=>get_links
    EXPORTING
      is_lporb    = ls_lprob
    IMPORTING
      et_items    = lt_attach
      et_messages = lt_message1.


  LOOP AT lt_attach INTO ls_sofm.
    CONCATENATE ls_sofm-foltp ls_sofm-folyr ls_sofm-folno
     ls_sofm-objtp ls_sofm-objyr ls_sofm-objno
     INTO lv_key RESPECTING BLANKS.
    CLEAR: ls_sofm.
  ENDLOOP.

swc_create_object lo_sofm 'SOFM' lv_key.
swc_set_element container 'SOFM' lo_sofm.

Regards
IK

On Thu, Jan 5, 2012 at 3:13 PM, Ali Husain <mr_mago40 at hotmail.com> wrote:

>
> Hello Ibrahim,
>
> I think you have to COMMIT AND WAIT after saving. I'll post the whole code
> for the FM that gets the sofm table. You can then use the code i
> sent earlier to extract the keys and create the sofm object which should be
> bound to the attach_object container element:
>
>
> FUNCTION Z_HR_IS_RESOLUTION_SEND_MAIL.
> *"----------------------------------------------------------------------
> *"*"Local Interface:
> *"  IMPORTING
> *"     REFERENCE(P_NUMBER) TYPE  PA9013-IS_NUMBER
> *"     REFERENCE(P_PERNR) TYPE  PA9013-PERNR
> *"  EXPORTING
> *"     REFERENCE(E_SOFM) TYPE  SOFM
> *"----------------------------------------------------------------------
>
>   DATA: FM_NAME           TYPE RS38L_FNAM,
>         FP_DOCPARAMS      TYPE SFPDOCPARAMS,
>         FP_OUTPUTPARAMS   TYPE SFPOUTPUTPARAMS,
>         IN_FPFORMOUTPUT   TYPE FPFORMOUTPUT,
>         PDF_DATA          TYPE XSTRING,
>         PDF_DATA2         TYPE XSTRING.
>   DATA: WA_9013 TYPE PA9013.
>   DATA: RT_MESSAGES TYPE BAPIRETTAB.
>   DATA: WA_MESSAGES TYPE BAPIRET2.
>   DATA IT_ITEMS TYPE FITV_ATTA_TTY.
>   DATA WA_FOLD_OBJ  TYPE SWO_TYPEID.
>   DATA WA_ATTA TYPE FITV_ATTA_STY.
>   DATA L_OBJ TYPE SIBFLPORB.
>   DATA UPDATE_DB TYPE C.
>   UPDATE_DB = 'X'.
> * GETTING THE DATA
>   SELECT SINGLE * FROM PA9013 INTO WA_9013 WHERE PERNR EQ P_PERNR AND
>  IS_NUMBER EQ P_NUMBER.
> * PRINT:
> * Sets the output parameters and opens the spool job
>   FP_OUTPUTPARAMS-DEST = 'HQ18'.
>   FP_OUTPUTPARAMS-NODIALOG = 'X'.
>   FP_OUTPUTPARAMS-NOPREVIEW = 'X'.
>   FP_OUTPUTPARAMS-NOPRINT = 'X'.
>   FP_OUTPUTPARAMS-GETPDF = 'X'.
>   CALL FUNCTION 'FP_JOB_OPEN'
>     CHANGING
>       IE_OUTPUTPARAMS = FP_OUTPUTPARAMS
>     EXCEPTIONS
>       CANCEL          = 1
>       USAGE_ERROR     = 2
>       SYSTEM_ERROR    = 3
>       INTERNAL_ERROR  = 4
>       OTHERS          = 5.
>   IF SY-SUBRC <> 0.
>   ENDIF.
>
> * Get the name of the generated function module
>   CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
>     EXPORTING
>       I_NAME     = 'ZF_HR_ISSUE_RES'
>     IMPORTING
>       E_FUNCNAME = FM_NAME.
>   IF SY-SUBRC <> 0.
>   ENDIF.
> * Language and country setting (here US as an example)
>   CALL FUNCTION FM_NAME
> "'/1BCDWB/SM00000059'
>     EXPORTING
>       /1BCDWB/DOCPARAMS        = FP_DOCPARAMS
>       I_PA9013                 = WA_9013
> *    EMP_COM                  =
> *    LEAD_COM                 =
> *    EMP_RES                  =
> *    ILC_COM                  =
> *    HR_COM                   =
> *    VP_COM                   =
> *    ILR_COM                  =
>    IMPORTING
>      /1BCDWB/FORMOUTPUT       = IN_FPFORMOUTPUT
>    EXCEPTIONS
>      USAGE_ERROR              = 1
>      SYSTEM_ERROR             = 2
>      INTERNAL_ERROR           = 3
>      OTHERS                   = 4
>             .
>   IF SY-SUBRC <> 0.
>   ENDIF.
>   COMMIT WORK AND WAIT.
>
>   FP_DOCPARAMS-LANGU   = 'E'.
>   FP_DOCPARAMS-COUNTRY = 'US'.
>   CALL FUNCTION 'FP_JOB_CLOSE'
> *    IMPORTING
> *     E_RESULT             =
>     EXCEPTIONS
>       USAGE_ERROR           = 1
>       SYSTEM_ERROR          = 2
>       INTERNAL_ERROR        = 3
>       OTHERS               = 4.
>   IF SY-SUBRC <> 0.
>   ENDIF.
>   PDF_DATA = IN_FPFORMOUTPUT-PDF.
>   IF PDF_DATA IS NOT INITIAL.
>     CONCATENATE WA_9013-PERNR WA_9013-SUBTY WA_9013-OBJPS WA_9013-SPRPS
>                 WA_9013-ENDDA WA_9013-BEGDA WA_9013-SEQNR INTO
>  L_OBJ-INSTID RESPECTING BLANKS.
>
>     L_OBJ-TYPEID = 'ZOBJ0006'.
>     L_OBJ-CATID =  'BO'.
>     CALL METHOD CL_FITV_GOS=>GET_LINKS
>       EXPORTING
>         IS_LPORB    = L_OBJ
>       IMPORTING
>         ET_ITEMS    = IT_ITEMS
>         ET_MESSAGES = RT_MESSAGES.
>
>     READ TABLE IT_ITEMS INTO WA_ATTA INDEX 1.
>     CONCATENATE WA_ATTA-FOLTP  WA_ATTA-FOLYR  WA_ATTA-FOLNO
>                 WA_ATTA-OBJTP  WA_ATTA-OBJYR WA_ATTA-OBJNO INTO
>  WA_FOLD_OBJ RESPECTING BLANKS.
>
>     CALL METHOD CL_FITV_GOS=>DELETE
>       EXPORTING
>         IS_LPORB    = L_OBJ
>         IV_ATTA_ID  = WA_FOLD_OBJ
>         IV_CREATOR  = WA_ATTA-SAPNAM
>         IV_OBJTP    = 'EXT'
>         IV_OBJDES   = 'PDF_ATTACHMENT'
>       IMPORTING
>         ET_MESSAGES = RT_MESSAGES.
>     COMMIT WORK AND WAIT.
>
>     REFRESH IT_ITEMS.
>     CALL METHOD CL_FITV_GOS=>GET_LINKS
>       EXPORTING
>         IS_LPORB    = L_OBJ
>       IMPORTING
>         ET_ITEMS    = IT_ITEMS
>         ET_MESSAGES = RT_MESSAGES.
>
>     CALL METHOD CL_FITV_GOS=>SAVE
>       EXPORTING
>         IV_NAME        = 'PDF_ATTACHMENT.PDF'
> *      IV_CONTENT     =
>         IV_CONTENT_HEX  = PDF_DATA
>         IS_LPORB       = L_OBJ
>         IV_OBJTP       = 'EXT'
>       RECEIVING
>         RT_MESSAGES    = RT_MESSAGES .
>
>     COMMIT WORK AND WAIT.
>     READ TABLE RT_MESSAGES INTO WA_MESSAGES WITH KEY TYPE = 'E'.
>     IF SY-SUBRC = 0.
>       CLEAR UPDATE_DB.
>     ENDIF.
>     CALL METHOD CL_FITV_GOS=>GET_LINKS
>       EXPORTING
>         IS_LPORB    = L_OBJ
>       IMPORTING
>         ET_ITEMS    = IT_ITEMS
>         ET_MESSAGES = RT_MESSAGES.
>
>     READ TABLE IT_ITEMS INTO WA_ATTA INDEX 1.
>     MOVE-CORRESPONDING WA_ATTA TO E_SOFM.
>     E_SOFM-MANDT = SY-MANDT.
>     E_SOFM-DOCTP = WA_ATTA-OBJTP  .
>     E_SOFM-DOCYR = WA_ATTA-OBJYR .
>     E_SOFM-DOCNO = WA_ATTA-OBJNO.
>     IF UPDATE_DB = 'X'.
>       CONCATENATE
>  E_SOFM-FOLTP E_SOFM-FOLYR E_SOFM-FOLNO E_SOFM-DOCTP E_SOFM-DOCYR E_SOFM-DOCNO E_SOFM-FORNO
>       INTO WA_9013-FOL_PATH RESPECTING BLANKS.
>       MODIFY PA9013 FROM WA_9013.
>     ENDIF.
>     COMMIT WORK AND WAIT.
>   ENDIF.
> ENDFUNCTION.
>
> Regards,
> Ali
>
> ------------------------------
> From: ikhansap at gmail.com
> Date: Thu, 5 Jan 2012 14:21:02 +0400
>
> Subject: Re: Issue with attaching pdf in work item
> To: mr_mago40 at hotmail.com
> CC: sap-wug at mit.edu
>
>
> Hi Ali,
>   I tried out the way you have mentioned, but its not working. Please find
> the code below, let me know if I am missing something.
> When I debugged this code I found that message parameter(t_message.) from
> SAVE method is empty, but after the GET_LINKS method call the parameter
> et_items is not returning anything.
>
>   CALL METHOD cl_fitv_gos=>save
>     EXPORTING
>       iv_name        = 'Test.pdf'
>       iv_content_hex = zxstring
>       is_lporb       = ls_lprob
>       iv_objtp       = 'EXT'
>     RECEIVING
>       rt_messages    = lt_message.
>
>   CALL METHOD cl_fitv_gos=>get_links
>     EXPORTING
>       is_lporb    = ls_lprob
>     IMPORTING
>       et_items    = lt_attach
>       et_messages = lt_message1.
>
> Regards
> IK
>
> On Thu, Jan 5, 2012 at 11:59 AM, Ali Husain <mr_mago40 at hotmail.com> wrote:
>
>
> Hello,
>
> Yeah i forgot to mention the saving part. It should work that way.
>
> ------------------------------
> From: ikhansap at gmail.com
> Date: Thu, 5 Jan 2012 10:15:12 +0400
> Subject: Re: Issue with attaching pdf in work item
> To: sap-wug at mit.edu
> CC: mr_mago40 at hotmail.com
>
>
> Hi Ali,
>   Thanks for your reply. I have a doubt on your approach. Before calling
> CL_FITV_GOS=>GET_LINKS  i think we should use CL_FITV_GOS=>SAVE to save the
> pdf document(attachment) to GOS and then used GET_LINKS method to get the
> key of the attachment. Correct me if I am wrong.
>
> Regards
> Ibrahim
>
> On Wed, Jan 4, 2012 at 1:49 PM, Ali Husain <mr_mago40 at hotmail.com> wrote:
>
>
> Hello Ibrahim,
>
> I've done that in a different way and it was working fine with me. After
> you convert to pdf, you can call the method CL_FITV_GOS=>GET_LINKS and pass
> it your BOR object along with the keys. The sofm table reference you get
> back you can then perform the following:
>
> LOOP AT ex_sofm INTO ls_sofm.
>   CONCATENATE ls_sofm-foltp ls_sofm-folyr ls_sofm-folno
>   ls_sofm-doctp ls_sofm-docyr ls_sofm-docno ls_sofm-fortp
>  ls_sofm-foryr ls_sofm-forno INTO lv_key RESPECTING BLANKS.
>
>   swc_create_object lr_sofm 'SOFM' lv_key.
>   APPEND lr_sofm TO lt_sofm.
>   CLEAR: ls_sofm, lv_key,lr_sofm.
> ENDLOOP.
>
> swc_set_table container 'EX_SOFM' lt_sofm.
>
> You can then bind lt_sofm with the attach_objects container element and
> the attachment should open when displaying the work item.
>
> Hope this helps,
> Ali
>
>
> > From: sap-wug-request at mit.edu
> > Subject: SAP-WUG Digest, Vol 86, Issue 3
> > To: sap-wug at mit.edu
> > Date: Tue, 3 Jan 2012 12:13:09 -0500
> >
> > Send SAP-WUG mailing list submissions to
> > sap-wug at mit.edu
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > http://mailman.mit.edu/mailman/listinfo/sap-wug
> > or, via email, send a message with subject or body 'help' to
> > sap-wug-request at mit.edu
> >
> > You can reach the person managing the list at
> > sap-wug-owner at mit.edu
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of SAP-WUG digest..."
> >
> >
> > Today's Topics:
> >
> > 1. Issue with attaching pdf in work item (Ibrahim)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Tue, 3 Jan 2012 16:06:34 +0400
> > From: Ibrahim <ikhansap at gmail.com>
> > Subject: Issue with attaching pdf in work item
> > To: "SAP Workflow Users' Group" <SAP-WUG at mit.edu>
> > Message-ID:
> > <CADb5asq-DCxY0HidihMp9BYmzuCb3BAF6CYJad33W25+2yeN-Q at mail.gmail.com>
> > Content-Type: text/plain; charset="iso-8859-1"
>
> >
> > Dear Friends,
> > I am trying to attach Adobe form output to a work item and send it in for
> > approval. I have converted the Adobe form output to binary format inside
> > the program and passed it to the workflow container while starting the
> > workflow and then inside the workflow i used the below method code to
> > convert the binary to xstring format and then attach it to the workitem.
> > But when I open the attachment from business workplace I am getting an
> > error that "*There was an error opening this document, the file is
> damaged
> > and could not be repaired*". I tried to debug the method and everything
>
> > seems to be fine, even I check the Adobe output by sending it as an email
> > attachment and I am able to open the same Adobe form attachment in the
> > email. So I suspect that I am doing something wrong while converting the
> > same in the workflow. Please advise what would be wrong with the below
> code.
> >
> >
> > DATA: wid TYPE swwwihead-wi_id,
> > op_len TYPE wsuser-wsuserinstanceno,
> > it_solix_tab TYPE solix-line OCCURS 0.
> >
> > DATA : zswr_att_header TYPE swr_att_header,
> > zswr_att_id TYPE swr_att_id,
> > lo_sofm TYPE swc_object,
> > zxstring TYPE xstring.
> >
> > swc_get_element container 'WID' wid.
> > swc_get_element container 'OP_LEN' op_len.
> > swc_get_table container 'IT_SOLIX_TAB' it_solix_tab.
> >
> > CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
> > EXPORTING
> > input_length = op_len
> > IMPORTING
> > buffer = zxstring
> > TABLES
> > binary_tab = it_solix_tab.
> >
> > zswr_att_header-file_type = 'B'.
> > zswr_att_header-file_name = 'Attachment.pdf'.
> > zswr_att_header-file_extension = 'PDF'.
> > zswr_att_header-language = 'EN'.
> > BREAK-POINT.
> > CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
> > EXPORTING
> > workitem_id = wid
> > att_header = zswr_att_header
> > att_bin = zxstring
> > IMPORTING
> > att_id = zswr_att_id.
> >
> > swc_create_object lo_sofm 'SOFM' zswr_att_id-doc_id.
> > swc_set_element container 'SOFM' lo_sofm.
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL:
> http://mailman.mit.edu/pipermail/sap-wug/attachments/20120103/40efd24a/attachment-0001.htm
> >
> > ------------------------------
> >
> > _______________________________________________
> > SAP-WUG mailing list
> > SAP-WUG at mit.edu
> > http://mailman.mit.edu/mailman/listinfo/sap-wug
> >
> >
> > End of SAP-WUG Digest, Vol 86, Issue 3
> > **************************************
>
> _______________________________________________
> SAP-WUG mailing list
> SAP-WUG at mit.edu
> http://mailman.mit.edu/mailman/listinfo/sap-wug
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/sap-wug/attachments/20120108/f666d27e/attachment-0001.htm


More information about the SAP-WUG mailing list