cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically attach file in Notes and Attachment tab in SC

0 Kudos

Hi Experts,

I want to attach an xml file to the notes and attachment tab in Shopping cart automatically in SRM 7. I tried to implement logic in BBP_DOC_CHANGE_BADI. So now it is updating the values in the back end table BBP_PHIO, BBP_PDATT and BBP_PHF. But the file is not showing the notes and attachment tab. Please help me. Its very urgent..

Many thanks in advance




Regards.

Ann.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Ann,

As you see, the database tables are updated. Could you please check it using the FM BBP_PD_SC_GETDETAIL. If the attachment is retrieved, then I suppose that you have attached the file to the header and hence couldnt find it in the UI. Please see that you assign it to any of the items to find it in the Webdynpro screen.

Thanks & Regards,

Karthik Babu

0 Kudos

Hi Karthik,

Actually our requirement got changed again  . Our new scenario is like below.

     While creating a shopping cart, for some of particular items we have smart forms to be filled. Once we fill the smart forms and click save, the form have to be converted to xml file and saved in notes and attachment tab of shopping cart.These Smart forms are custom form which we created and attached to standard component(/SAPSRM/WDC_DODC_SC_I_BD) as link. Depending on the item selected that item specific smart form link get enabled and we can navigate to smartforms. The content of this smartform we need to attach as xml in notes and attachment tab..

Please help me.. Thanks in Advance

robin_janke
Contributor
0 Kudos

Hi Ann,

use the class /SAPSRM/CL_PDO_BO_SC and method /SAPSRM/IF_PDO_DO_ATTACHMENTS~CREATE_ATTACHMENT to add an attachment to the shopping cart item while saving your form

1. First get an instance of your currenct SC

2. open the form

3. save the attachment by filling the necessary data in the method parameters (e.g. P_GUID = item guid)

Regards,

Robin

0 Kudos

I am very new to web dynpro. Can u please tell me how get an instance of current shopping cart in a custom web dynpro component

0 Kudos

Can u please elaborate how to do this

robin_janke
Contributor
0 Kudos

Hi,

example code for the doc_change_badi (from item):


DATA:

    lo_pd_model     TYPE REF TO /sapsrm/cl_pdo_base,

    lo_sc           TYPE REF TO /sapsrm/if_pdo_bo_sc,

    lo_message      TYPE REF TO /sapsrm/if_pdo_msg_consumer,

    lt_attach       TYPE        /sapsrm/t_pdo_att,

    ls_attach       TYPE        /sapsrm/s_pdo_att,

    lv_ext          TYPE        char64,

    lv_temp         TYPE        string.

TRY.

    CALL METHOD /sapsrm/cl_pdo_bo_sc_adv=>get_sc_adv_instance

    EXPORTING

      iv_header_guid = is_item-parent

      iv_mode        = 'EDIT'

      iv_wiid        = '000000000000'

    RECEIVING

      ro_instance    = lo_pd_model.

    lo_sc ?= lo_pd_model.

    REFRESH: lt_attach.

    ls_attach-p_guid         = is_item-guid.

    ls_attach-phio_ext       = <extension>.

    ls_attach-phio_fname     = <file_name>.

    ls_attach-phio_path_file = <file_path>.

    ls_attach-phio_mime      = <file_type>.

    ls_attach-phio_fsize     = <file_size>.

    ls_attach-phio_ps_mime   = <file_type>.

    ls_attach-phio_ps_fsize  = <file_size>.

    ls_attach-description    = <file_description>.

    ls_attach-internal_ind   = abap_true. "initially always internal!

    APPEND ls_attach TO lt_attach.

    CALL METHOD lo_sc->/sapsrm/if_pdo_do_attachments~create_attachment

      EXPORTING

        it_attach          = lt_attach

        iv_content         = <file_contents>

      CHANGING

        co_message_handler = lo_message.

    CATCH /sapsrm/cx_pdo_error_gen .

    CATCH /sapsrm/cx_pdo_wf_mode_ban .

    CATCH /sapsrm/cx_pdo_wrong_bus_type .

    CATCH /sapsrm/cx_pdo_pd_read_error .

    CATCH /sapsrm/cx_pdo_lock_failed .

    CATCH /sapsrm/cx_pdo_no_authorizatio .

    CATCH /sapsrm/cx_pdo_parameter_error .

    CATCH /sapsrm/cx_pdo_status_error .

    CATCH /sapsrm/cx_pdo_incons_user .

    CATCH /sapsrm/cx_pdo_abort .

    CATCH /sapsrm/cx_pdo_error .

ENDTRY.

Regards,

Robin

Answers (0)