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: 

UDM_DISPUTE attach PDF to case ID ABC

Former Member
0 Kudos

HI All,

I need to attach PDF file to a case ID ABC ( in T-code UDM_DISPUTE SAP FI ) .

Path:UDM_DISPUTE-->case ID-->Attridute(button)--->under related Objects select Various--->right click selct Create and add PDF file from Desktop.

Now the user wants to automate just by running a program from ABAP.

I have tried to debug the Std program to find FM,BAPI's to upload the Text but unable to find  FM and BAPI's  to upload PDF file by providing Case ID and PDF file path which can upload the PDF file into UDM_DISPUTE  in order to reach my requirnment.

Any Suggestion will be rewarded.

Thanks

Gopal

1 ACCEPTED SOLUTION

anurag_abbi_tm
Participant
0 Kudos

Hi,

I am unable to replicate the path, probably because we have not used this functionality in our system.

Since this functionality will always require user intervention (because the user will pick from desktop)

it means that the speed is not an issue. So we may use BDC as well instead of BAPI.

So try creating a BDC for this.

Ask the user to create a dedicated folder only for uploading. If possible then give the file exactly same name every time and place the file in the same folder OR you may build a logic for file name.

Regards

Anurag

4 REPLIES 4

anurag_abbi_tm
Participant
0 Kudos

Hi,

I am unable to replicate the path, probably because we have not used this functionality in our system.

Since this functionality will always require user intervention (because the user will pick from desktop)

it means that the speed is not an issue. So we may use BDC as well instead of BAPI.

So try creating a BDC for this.

Ask the user to create a dedicated folder only for uploading. If possible then give the file exactly same name every time and place the file in the same folder OR you may build a logic for file name.

Regards

Anurag

0 Kudos

Hi Gopal.

The attachment in any object can be uploaded in 2 ways - GOS Objects or ArchiveLink. First you need to know what type is your case. Basically uploading a file to an object menas creating a link between the uploaded file and the business object. You also need to know what is the business object type in your case.

I am giving here one sample code for the ArhciveLink upload in the business object LIKP (delivery). If your one is GOS object upload then there will be different FM.

REPORT zvgtr1111_test2.

include <cntn01>.

swc_container l_it_message_container.

*top dec.

type-pools: slis, abap, truxs.



data "l_objid     type ydmfw_objid,

       l_obj       type swc_object,

       l_st_obja     type borident,

       l_st_objb     type borident,

       l_st_binrel   type gbinrel,

       l_it_binatt   type standard table of brelattr,

        l_seq type i.

PARAMETERS : vbeln TYPE vbeln_va,

             p_object TYPE toav0-ar_object DEFAULT 'ZO2CDELXLS',

              p_path TYPE localfile.



AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path .

  PERFORM get_file_path.







START-OF-SELECTION.

  TYPES : BEGIN OF ty_data,

          raw(255) TYPE x,

          END OF ty_data.



  DATA : output_archive TYPE toav0-archiv_id,

         output_doc_class TYPE toadd-doc_type,

         xdata TYPE STANDARD TABLE OF tbl1024,

         l_doc_type TYPE saedoktyp,

         l_object TYPE sapb-sapobjid,

         data TYPE STANDARD TABLE OF ty_data,

         len TYPE SAPB-LENGTH,

         filesize type  i ,

          output_archiv_doc_id type SAPB-SAPADOKID,

          path type string  .



path = p_path .

  CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

      filename                     = path

     filetype                      = 'BIN'

*   HAS_FIELD_SEPARATOR           = ' '

*   HEADER_LENGTH                 = 0

*   READ_BY_LINE                  = 'X'

*   DAT_MODE                      = ' '

*   CODEPAGE                      = ' '

*   IGNORE_CERR                   = ABAP_TRUE

*   REPLACEMENT                   = '#'

*   CHECK_BOM                     = ' '

*   VIRUS_SCAN_PROFILE            =

*   NO_AUTH_CHECK                 = ' '

IMPORTING

   FILELENGTH                    filesize

*   HEADER                        =

    TABLES

      data_tab                      = data

   EXCEPTIONS

     file_open_error               = 1

     file_read_error               = 2

     no_batch                      = 3

     gui_refuse_filetransfer       = 4

     invalid_type                  = 5

     no_authority                  = 6

     unknown_error                 = 7

     bad_data_format               = 8

     header_not_allowed            = 9

     separator_not_allowed         = 10

     header_too_long               = 11

     unknown_dp_error              = 12

     access_denied                 = 13

     dp_out_of_memory              = 14

     disk_full                     = 15

     dp_timeout                    = 16

     OTHERS                        = 17

            .

  IF sy-subrc = 0.

* Implement suitable error handling here



************************Upload ARCHIVE file*****************

  CALL FUNCTION 'ARCHIV_CONNECTDEFINITION_GET'

    EXPORTING

      objecttype    = 'LIKP'

      documenttype  = p_object

      client        = sy-mandt

    IMPORTING

*     CONNECTION    =

      archivid      = output_archive

*     EXPIRYTIME    =

      documentclass = output_doc_class

    EXCEPTIONS

      nothing_found = 1

      OTHERS        = 2.

  IF sy-subrc NE 0.

    RAISE error_at_target.

  ENDIF.



  len = filesize.

  xdata[] = data[].



  CALL FUNCTION 'ARCHIVOBJECT_CREATE_TABLE'

    EXPORTING

      archiv_id                = output_archive

      document_type            = output_doc_class

      length                   = len

    IMPORTING

      archiv_doc_id            = output_archiv_doc_id

    TABLES

      binarchivobject          = xdata

    EXCEPTIONS

      error_archiv             = 1

      error_communicationtable = 2

      error_kernel             = 3

      OTHERS                   = 4.

  IF sy-subrc NE 0.

    RAISE error_at_target.

  ENDIF.



* Get DOcument type from archive object

  SELECT SINGLE doc_type

   FROM toadv

   INTO l_doc_type

   WHERE  ar_object p_object.



  l_object = vbeln.

* Add Link

  CALL FUNCTION 'ARCHIV_CONNECTION_INSERT'

    EXPORTING

      archiv_id             = output_archive

      arc_doc_id            = output_archiv_doc_id

*     AR_DATE               = ' '

      ar_object             = p_object

*     DEL_DATE              = ' '

*     MANDANT               = ' '

      object_id             = l_object

      sap_object            = 'LIKP'

      doc_type              = l_doc_type

*     BARCODE               = ' '

    EXCEPTIONS

      error_connectiontable = 1

      OTHERS                = 2.

  IF sy-subrc NE 0.

    RAISE error_at_target.

  ENDIF.



*************Upload Attachments



    swc_container      l_cont.

    swc_create_object  l_obj  'MESSAGE'       ''.

    swc_set_element    l_cont 'NO_DIALOG'     'X'.

    swc_set_element    l_cont 'DOCUMENTTITLE' path.

    swc_set_table      l_cont 'Content_Hex'   data.

    swc_set_element    l_cont 'DOCUMENTTYPE'  'XLS'.

    swc_set_element    l_cont 'DOCUMENTSIZE'  filesize.

    swc_refresh_object l_obj.

    swc_call_method    l_obj  'CREATE'        l_cont.

    swc_get_object_key l_obj  l_st_objb-objkey.



    l_st_objb-objtype = 'MESSAGE'.   "type of attach document

    l_st_obja-objtype = 'LIKP'.      "BO of SAP Document.

*    concatenate    '0001'  "company code

*                   p_belnr "FI Document

*                   '2009'  "fiscal year

*                   into

*                   gs_obja-objkey.



    l_st_obja-objkey = vbeln .



    call function 'BINARY_RELATION_CREATE_COMMIT'

      exporting

        obj_rolea      = l_st_obja

        obj_roleb      = l_st_objb

        relationtype   = 'ATTA'

      importing

        binrel         = l_st_binrel

      tables

        binrel_attrib  = l_it_binatt

      exceptions

        no_model       = 1

        internal_error = 2

        unknown        = 3

        others         = 4.

    if sy-subrc eq 0.

      message s043(sgos_msg).

    endif.

  endif.

*&---------------------------------------------------------------------*

*&      Form  GET_FILE_PATH

*&---------------------------------------------------------------------*

*       text

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

*  -->  p1        text

*  <--  p2        text

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

FORM get_file_path .

  DATA:       l_it_files TYPE filetable,

                l_st_files TYPE file_table,

                l_rc LIKE sy-subrc.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog

    CHANGING

      file_table              = l_it_files

      rc                      = l_rc

    EXCEPTIONS

      file_open_dialog_failed = 1

      cntl_error              = 2

      error_no_gui            = 3

      not_supported_by_gui    = 4

      OTHERS                  = 5.

  IF sy-subrc <> 0 OR l_rc < 0.

*    MESSAGE i004.

  ENDIF.



  READ TABLE l_it_files INDEX 1 INTO l_st_files.

  p_path = l_st_files-filename.

ENDFORM.                    " GET_FILE_PATH

0 Kudos

Problem solved use the belowpart code.

'BINARY_RELATION_CREATE_COMMIT'

     

0 Kudos

Hi Gopal,

Even I have same requirement to attach document/URL link to dispute case .

can you please help me how you solved this issue.

I have tried with same FM: "BINARY_RELATION_CREATE_COMMIT"

how to pass the values.

also please provide me the Function modules and tables related to this scenario.

Thanks,

Chaitanya.