cancel
Showing results for 
Search instead for 
Did you mean: 

Attachment storage in shopping cart

Former Member
0 Kudos

Hi All,

I have a requirement of developing similar functionality like attachments in shopping cart. In shopping cart the FM BBP_ATTACH_BUILD_URL is generating the url for the attachments that we add, which will give us a link to the docserver where the file got stored.

But which FM or in which step the storage happening. When exactly the file gets stored in the docserver. Please help.

Thanks in advance.

Brinda.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

<u>Which SRM version are you using ?</u>

Execute the function module BBP_PROCDOC_ITEM_GETDETAIL by providing the item guid,object type . Now it will populate the et_attach importing parameter with the attatchement details. In the ET_ATTATCH internal table , the field PHIO_FNAME/PHIO_PATH_FILE provides the physical storage location of the document.

<u>For Sample code go through these links below -> </u>

<u>Other related links -></u>

Do let me know.

Regards

- Atul

Former Member
0 Kudos

Hi ,

I am using SRM 5. I tried to use FM BBP_PROCDOC_ITEM_GETDETAIL by entring document uid for and objecttype as BUS1006. But its not giving any values in et_attach.

But in my program am getting details into et_attach to passs it for FM BBP_ATTACH_BUILD_URL, so there am having values for PHIO_EXT,PHIO_FSIZE,PHIO_FILENAME,PHIO_MIME even PHIO_CONTENT. So does that mean that file got stored?.

So if i use the BADI BBP_CHANGE_URL will i able be able to store it in my desired location.

Thanks for your fast reply Atul.

Brinda.

Former Member
0 Kudos

Hi

<b>Please Refer SAP OSS Note 668062: Configuration of attachment display</b>

What code are you using for FM - BBP_PROCDOC_ITEM_GETDETAIL ? Please paste the same in the next reply.

<u>URL Generation in an AS-ABAP - Web Dispatcher Configuration</u>

http://help.sap.com/saphelp_erp2005/helpdata/en/42/d547ab30b6473ce10000000a114e5d/frameset.htm

To allow access to attachments by external users, BAdI implementation BBP_CHANGE_URL is available. In this BADI,

you must first distinguish the type of user, whether internal or

external. Then you must pass a different URL depending on the user and

return the URL to BBP_ROOT_URL. Please consider using this BADI to

resolve this issue.

<b>

Try to use BADI BBP_CHANGE_URL</b>

eg.

if iv_url eq '/docserver/'.
replace 'srmpro.ep' in ev_url with 'srmserverformycompany.com'.
endif.

<b>Related links - ></b>

Do let me know.

Regards

- Atul

Former Member
0 Kudos

Hi Atul,

Code for FM BBP_PROCDOC_ITEM_GETDETAIL.

data: ls_attach TYPE bbp_pds_att_t,

ls_attachment type BBPT_PDS_ATT_T,

*Inside this FM uid for the document is getting generated.

CALL FUNCTION 'BBP_ATTACH_BUILD_URL'

EXPORTING

is_attach = ls_attach

IMPORTING

es_attach = ls_attach

ev_url = url

TABLES

et_messages = lt_messages.

CALL FUNCTION 'BBP_PROCDOC_ITEM_GETDETAIL'

EXPORTING

I_GUID = ls_attach-guid

  • IV_ACTIVE_ITEM_SRC_GUID =

I_OBJECT_TYPE = 'BUS1006'

  • I_ATTACH_WITH_DOC =

  • I_READ_I_FLAGS =

  • I_DISP_CURRENCY =

  • I_DISP_DATE =

  • IV_HEADER_GUID =

  • IV_HEADER_SRC_GUID =

  • IV_VERSION_TYPE =

IMPORTING

ET_ATTACH = ls_attachment.

  • ET_CONDITIONS =

  • ET_DYN_ATTR =

Thanks & Regards,

Brinda.

Former Member
0 Kudos

Hi

<b>Use this code instead -></b>

data :         ls_w_attach    TYPE bbp_pds_att_t_ic.

*     Check/Create Attach records
      LOOP AT gw_attach INTO ls_w_attach.
        PERFORM attach_maintain_single USING ls_w_attach
                                             l_set_guid
                                             l_method.
      ENDLOOP.

*&---------------------------------------------------------------------*
*&      Form  attach_maintain_single
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LS_W_ATTACH  text
*      -->P_L_SET_GUID  text
*      -->P_L_METHOD  text
*----------------------------------------------------------------------*
FORM attach_maintain_single
     USING value(w_attach) TYPE bbp_pds_att_t_ic
           value(p_setguid) TYPE any
           value(p_method) TYPE any.

  DATA:  ls_t_attach TYPE bbp_pds_att_t_ic,
         ls_attach   TYPE bbp_pds_att_t,
         lt_messages TYPE bbpt_pd_messages,
         new_attach  TYPE bbp_pds_att_t_ic,
         old_attach  TYPE bbp_pds_att_t_ic,
         ls_new_attach_temp  TYPE bbp_pds_att_t_ic,
         ls_old_attach_temp  TYPE bbp_pds_att_t_ic.

  READ TABLE gt_attach INTO ls_t_attach
        WITH KEY guid = w_attach-guid.
  IF sy-subrc = 0.
    new_attach = w_attach.
    old_attach = ls_t_attach.
  ELSE.
    new_attach = w_attach.
    new_attach-set_guid = p_setguid.
    CALL FUNCTION 'GUID_CREATE'
      IMPORTING
        ev_guid_16 = new_attach-guid.

    CALL FUNCTION 'BBP_PD_LOG_DEFAULTS_SET'
      EXPORTING
        i_set_guid = new_attach-guid.

* get URL for UI
    MOVE-CORRESPONDING new_attach TO ls_attach.
    CALL FUNCTION 'BBP_ATTACH_BUILD_URL'
      EXPORTING
        is_attach   = ls_attach
      IMPORTING
        es_attach   = ls_attach
      TABLES
        et_messages = lt_messages.
    MOVE-CORRESPONDING ls_attach TO new_attach.
* get fileextension for mimetype i.e. PDF for application/pdf
    CALL FUNCTION 'BBP_ATTACH_MIMETYPE2EXT'
      EXPORTING
        iv_mimetype = new_attach-phio_mime
        iv_filename = new_attach-phio_fname
      IMPORTING
        ev_ext      = new_attach-phio_ext.

  ENDIF.

* Delete Attach
  IF p_method = c_delete.
    new_attach-del_ind = c_on.
  ENDIF.

* Attachment changed?
  ls_new_attach_temp = new_attach.
  ls_old_attach_temp = old_attach.

  IF ls_new_attach_temp EQ ls_old_attach_temp.
    IF p_method NE c_check.
      EXIT.
    ENDIF.
  ENDIF.

* ==========================================================
*   SRM 5.0 Development - Document Management
*
*   Check out of an attachment and cancel Check-Out are
*   no changes on the document, so there should be no
*   change version of it. Therefore we have to modify the
*   check logic for changes.
* ==========================================================

  CLEAR ls_new_attach_temp-phio_checked_out.
  CLEAR ls_new_attach_temp-phio_checkout_user.

  IF ls_new_attach_temp NE ls_old_attach_temp.
    g_changed = c_on.
    IF p_method = c_update.
      CALL FUNCTION 'BBP_PDH_MSG_FILL_CHANGED_OBJS'
        EXPORTING
          iv_s_guid = new_attach-guid.
    ENDIF.
  ENDIF.

* Check Attach
  PERFORM attach_check_single CHANGING new_attach.

* Update Attach
  PERFORM attach_update_single USING new_attach p_method.

ENDFORM.                    " attach_maintain_single

*&---------------------------------------------------------------------*
*&      Form  attach_check_single
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--W_ATTACH  text
*----------------------------------------------------------------------*
FORM attach_check_single CHANGING w_attach TYPE bbp_pds_att_t_ic.

  DATA:
    lv_description     TYPE sychar50.

  STATICS:
     sv_checked        TYPE xfeld,
     sv_badi_active    TYPE xfeld,
     si_exit           TYPE REF TO if_ex_bbp_att_check.

  CHECK w_attach-del_ind IS INITIAL.
* check data for attachment types
  CASE w_attach-type.
    WHEN c_att_type_gen.
      IF NOT w_attach-url IS INITIAL.
        MESSAGE e171(bbp_pd) INTO gv_dummy.
        CALL FUNCTION 'BBP_PD_MSG_ADD'
          EXPORTING
            i_msgty       = c_msgty_a
            i_msgid       = sy-msgid
            i_msgno       = sy-msgno
          EXCEPTIONS
            log_not_found = 1
            OTHERS        = 2.
        IF sy-subrc <> 0.
          PERFORM abort.
        ENDIF.
      ENDIF.
      IF w_attach-kz = c_ins AND w_attach-phio_content[] IS INITIAL.
        MESSAGE i012(bbp_att) WITH w_attach-description INTO gv_dummy.
        CALL FUNCTION 'BBP_PD_MSG_ADD'
          EXPORTING
            i_msgty       = c_msgty_a
            i_msgid       = sy-msgid
            i_msgno       = sy-msgno
            i_msgv1       = sy-msgv1
          EXCEPTIONS
            log_not_found = 1
            OTHERS        = 2.
        IF sy-subrc <> 0.
          PERFORM abort.
        ENDIF.
      ENDIF.
    WHEN c_att_type_cep.
      IF w_attach-url IS INITIAL OR
         w_attach-logical_system IS INITIAL.
        MESSAGE e171(bbp_pd) INTO gv_dummy.
        CALL FUNCTION 'BBP_PD_MSG_ADD'
          EXPORTING
            i_msgty       = c_msgty_a
            i_msgid       = sy-msgid
            i_msgno       = sy-msgno
          EXCEPTIONS
            log_not_found = 1
            OTHERS        = 2.
        IF sy-subrc <> 0.
          PERFORM abort.
        ENDIF.
      ENDIF.
      PERFORM log_sys_check_existance USING w_attach-logical_system.
    WHEN c_att_type_url.
      IF w_attach-url IS INITIAL.
        MESSAGE e171(bbp_pd) INTO gv_dummy.
        CALL FUNCTION 'BBP_PD_MSG_ADD'
          EXPORTING
            i_msgty       = c_msgty_a
            i_msgid       = sy-msgid
            i_msgno       = sy-msgno
          EXCEPTIONS
            log_not_found = 1
            OTHERS        = 2.
        IF sy-subrc <> 0.
          PERFORM abort.
        ENDIF.
      ENDIF.
  ENDCASE.

* Check attachment check-out status
  IF w_attach-phio_checked_out EQ gc_yes.
    lv_description = w_attach-description.
    MESSAGE w020(bbp_att) INTO gv_dummy.
    CALL FUNCTION 'BBP_PD_MSG_ADD'
      EXPORTING
        i_msgty       = c_msgty_w
        i_msgid       = sy-msgid
        i_msgno       = sy-msgno
        i_msgv1       = lv_description
      EXCEPTIONS
        log_not_found = 1
        OTHERS        = 2.
    IF sy-subrc <> 0.
      PERFORM abort.
    ENDIF.
  ENDIF.

  IF sv_checked IS INITIAL.
    CLASS cl_exithandler DEFINITION LOAD.
    CALL METHOD cl_exithandler=>get_instance
      EXPORTING
        exit_name              = 'BBP_ATT_CHECK'
        null_instance_accepted = 'X'
      IMPORTING
        act_imp_existing       = sv_badi_active
      CHANGING
        instance               = si_exit.
    sv_checked = c_on.
  ENDIF.

  IF sv_badi_active = 'X'.
    si_exit->check( attachment = w_attach ).
  ENDIF.


ENDFORM.                    " attach_check_single
*&---------------------------------------------------------------------*
*&      Form  attach_update_single
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <-->W_ATTACH  text
*      -->P_METHOD  text
*----------------------------------------------------------------------*
FORM attach_update_single
                    USING value(w_attach) TYPE bbp_pds_att_t_ic
                    value(p_method) TYPE any.

  DATA: ls_t_attach TYPE bbp_pds_att_t_ic.
* Modify Attach table
  READ TABLE gt_attach INTO ls_t_attach
            WITH KEY guid = w_attach-guid.
  IF sy-subrc = 0.
* Update
    ls_t_attach = w_attach.
    IF NOT p_method EQ c_check AND ls_t_attach-kz NE c_ins.
      "no update within check
      ls_t_attach-kz = c_upd.
    ENDIF.
    MODIFY gt_attach FROM ls_t_attach INDEX sy-tabix.
* Insert
  ELSE.
    ls_t_attach = w_attach.
    IF NOT p_method EQ c_check.        "no update within check
      ls_t_attach-kz = c_ins.
    ENDIF.
    READ TABLE gt_attach TRANSPORTING NO FIELDS
        WITH KEY set_guid = ls_t_attach-set_guid
        BINARY SEARCH.
    INSERT ls_t_attach INTO gt_attach INDEX sy-tabix.

  ENDIF.

ENDFORM.                    " attach_update_single

<b>Code taken from Include program - LBBP_PDATTF09</b>

Do let me know.

Regards

- Atul

Former Member
0 Kudos

Hi ,

I have got one doubt, if the attached file have to be stored in an external content server will this procedure work or do we need to set up job in the external server.

Thanks a lot for all those valuable answers.

Regards,

Brinda.

Answers (0)