Skip to Content

Summary

Supplier registration process is a mandatory process for sourcing activity. For any new suppliers to participate in a bid, they must be created in SRM system. These bidders will be created system using Supplier registration process.Currently we have provision to add attachments in the potential suppliers, but as of now suppliers cannot add attachments during the registration phase. We will have to carry out few enhancements in order to bring the same attachment component to be visible for the suppliers.


Webdynpro Component /SAPSRM/WDC_SUCO_SREG_CA is the base component for the Supplier Registration form, and component usage for attachment is defined by standard itself as below.


Componet.JPG


In view V_SUPP_SREG_CA chance the visibility of element ATTACHMENT_CONTAINER to visible.

Visible.JPG

Create an enhancement for the Component Configuration /SAPSRM/WDCC_SUCO_SREG_CA

CC.JPG

Add the component name ‘/SAPSRM/WDC_DODC_ATTACH in the usages definition for attachment. Save and activate the configuration. Instead of creating enhancement we can also define custom configuration as well.

After completing the above steps, attachments will be visible in the ROS form but the Add Attachment & Delete buttons will be disabled.

To enable the buttons, create a post exit for the method WDDOMODIFYVIEW in view V_DODC_ATTACHMENT of component /SAPSRM/WDC_DODC_ATTACH.

Add below code to set the attribute  DELETE_DOCUMENT in post method.

DATA:lo_nd_m_as_att_data TYPE REF TO if_wd_context_node,

        lo_el_m_as_att_data TYPE REF TO if_wd_context_element,

        ls_m_as_att_data    TYPE        wd_this->element_m_as_att_data,

        lv_delete_document  TYPE        wd_this->element_m_as_att_datadelete_document,

        lo_task_container   TYPE REF TO /sapsrm/if_cll_task_container,

        lo_task_factory     TYPE REF TO /sapsrm/if_cll_taskcon_factory,

        lv_botype           TYPE        crmt_subobject_category_db,

        lv_sub_mode         TYPE        /sapsrm/pdo_inst_mode,

        lv_mode             TYPE        /sapsrm/pdo_inst_mode.

   lo_task_factory = /sapsrm/cl_ch_wd_taskcont_fact=>get_instance( ).

   IF lo_task_factory IS BOUND.

     lo_task_container = lo_task_factory->get_task_container( ).

     IF lo_task_container IS BOUND.

       lv_botype = lo_task_container->get_bo_type( ).

       CALL METHOD lo_task_container->get_transaction_mode

         IMPORTING

           ev_sub_trans_mode = lv_sub_mode

           ev_pdo_trans_mode = lv_mode.

     ENDIF.

   ENDIF.

   IF lv_sub_mode = ‘CREATE’ AND lv_botype = ‘BUP002’.

     lo_nd_m_as_att_data = wd_context->get_child_node( name = wd_this->wdctx_m_as_att_data ).

     lo_el_m_as_att_data = lo_nd_m_as_att_data->get_element( ).

* @TODO fill attribute

     lv_delete_document = ‘X’.

* set single attribute

     lo_el_m_as_att_data->set_attribute(

       name `DELETE_DOCUMENT`

       value = lv_delete_document ).

   ENDIF.


Now buttons also got enabled in the ROS form.


Upon clicking Attachment button a new popup screen appears where we can give attachment and description as below. On selecting add, it will gets saved against the partner number.

Add Attach.JPG


In ROS until we save(While Send button is clicked) the details partner number wont get generated hence attachments will gets saved against a blank partner number. Due to this these attachments saved against blank partner will get fetched every time while opening the form. To overcome this, if partner number is not generated, we will save against a dummy partner ‘DUMMY_ATCH’.


Go to class: /SAPSRM/CL_PDO_DO_ATTACH

Methods->/SAPSRM/IF_PDO_DO_ATTACH~CREATE_ATTACHMENTS, /SAPSRM/IF_PDO_DO_ATTACH~DELETE_ATTACHMENTS, /SAPSRM/IF_PDO_DO_ATTACH~GET_ATTACHMENTS

Before the function call starting with ROS_BUPA_* add below code.

IF lv_partner IS INITIAL.

   lv_partner = ‘DUMMY_ATCH’.

ENDIF.


Create a post exit in the method WDDOINIT of component controller of class /SAPSRM/WDC_DODC_ATTACH and add below code.

DATA:lv_partner        TYPE        bu_partner,

        lv_doc_id         TYPE        bds_docid,

        lt_attachments    TYPE        ros_bp_attachments_t,

        lw_attachments    TYPE        ros_bp_attachments_s,

        lo_task_container TYPE REF TO /sapsrm/if_cll_task_container,

        lo_task_factory   TYPE REF TO /sapsrm/if_cll_taskcon_factory,

        lv_botype         TYPE        crmt_subobject_category_db,

        lv_sub_mode       TYPE        /sapsrm/pdo_inst_mode,

        lv_mode           TYPE        /sapsrm/pdo_inst_mode..

    lo_task_factory = /sapsrm/cl_ch_wd_taskcont_fact=>get_instance( ).

   IF lo_task_factory IS BOUND.

     lo_task_container = lo_task_factory->get_task_container( ).

     IF lo_task_container IS BOUND.

       lv_botype = lo_task_container->get_bo_type( ).

       CALL METHOD lo_task_container->get_transaction_mode

         IMPORTING

           ev_sub_trans_mode = lv_sub_mode

           ev_pdo_trans_mode = lv_mode.

     ENDIF.

   ENDIF.

   IF lv_sub_mode = ‘CREATE’.

     lv_partner = ‘DUMMY_ATCH’.

     CALL FUNCTION ‘ROS_BUPA_ATTACHMENT_GETLIST’

       EXPORTING

         iv_bp_number      = lv_partner

       TABLES

         et_bp_attachments = lt_attachments

       EXCEPTIONS

         nothing_found     = 1

         parameter_error   = 2

         not_allowed       = 3

         internal_error    = 4

         error_kpro        = 5

         not_authorized    = 6

         OTHERS            = 7.

     LOOP AT lt_attachments INTO lw_attachments.

       lv_doc_id = lw_attachmentsdoc_id.

       CALL FUNCTION ‘ROS_BUPA_DELETE_ATTACHMENT’

         EXPORTING

           iv_bp_number    = lv_partner

           iv_doc_id       = lv_doc_id

         EXCEPTIONS

           nothing_found   = 1

           parameter_error = 2

           not_allowed     = 3

           internal_error  = 4

           error_kpro      = 5

           not_authorized  = 6

           OTHERS          = 7.

       IF sysubrc <> 0.

       ENDIF.

     ENDLOOP.

   ENDIF.


This code will prevent displaying of attachments while opening the form for fist time that are saved earlier.

While the supplier click’s on ‘Send’ in ROS form a new Business Partner number will get generated and we will save the attachments against that number.

Create a implementation for the badi: BUPA_GENERAL_UPDATE.

In method: CHANGE_BEFORE_UPDATE add below code.

    DATA:lv_pguid       TYPE bu_partner_guid,

         lw_attach      TYPE ROS_BP_ATTACHMENTS_S,

         lw_but000      TYPE bus000___i,

         lv_fname       TYPE string,

         lv_size        TYPE i,

         lv_mime        TYPE string,

         lv_document_id TYPE bapibds01-doc_id,

         lv_doc_id      TYPE bds_docid,

         lv_partner     TYPE bu_partner,

         lw_att         TYPE /sapsrm/s_pdo_suco_att,

         lt_attachments TYPE ros_bp_attachments_t,

         lw_attachments TYPE ros_bp_attachments_s,

         lv_content     TYPE xstring,

         lt_content     TYPE BBPT_ATT_CONT.

*-Delete Attachemnts saved against dummy partner.

    lv_partner = ‘DUMMY_ATCH’.

    CALL FUNCTION ‘ROS_BUPA_ATTACHMENT_GETLIST’

      EXPORTING

        iv_bp_number      = lv_partner

      TABLES

        et_bp_attachments = lt_attachments

      EXCEPTIONS

        nothing_found     = 1

        parameter_error   = 2

        not_allowed       = 3

        internal_error    = 4

        error_kpro        = 5

        not_authorized    = 6

        OTHERS            = 7.

*-Once getting the attachment in internal table delete those from the dummy partner

    LOOP AT lt_attachments INTO lw_attachments.

      lv_doc_id = lw_attachments-doc_id.

      CALL FUNCTION ‘ROS_BUPA_DELETE_ATTACHMENT’

        EXPORTING

          iv_bp_number    = lv_partner

          iv_doc_id       = lv_doc_id

        EXCEPTIONS

          nothing_found   = 1

          parameter_error = 2

          not_allowed     = 3

          internal_error  = 4

          error_kpro      = 5

          not_authorized  = 6

          OTHERS          = 7.

      IF sy-subrc <> 0.

      ENDIF.

    ENDLOOP.

*-End Delete Attachment

    READ TABLE it_changed_instances INTO lv_pguid INDEX 1.

    IF sy-subrc NE 0.

      RETURN.

    ENDIF.

    CALL FUNCTION ‘BUP_MEMORY_BUT000_GET’

      EXPORTING

        iv_partner_guid  = lv_pguid

      IMPORTING

        es_but000        = lw_but000

      EXCEPTIONS

        not_found        = 1

        parameter_error  = 2

        bpext_not_unique = 3

        OTHERS           = 4.

    IF sy-subrc <> 0.

* Implement suitable error handling here

    ENDIF.

      LOOP AT lt_attachments INTO lw_attach.

        CLEAR:lv_fname,lv_comp_size,lv_mime.

        lv_fname = lw_attach-description.

        MOVE: lw_attach-comp_size TO lv_size,

              lw_attach-mimetype  TO lv_mime.

      CALL FUNCTION ‘BBP_OUTPUT_X_TABLESIZE_CHG’

        EXPORTING

          iv_size    = lv_size

          iv_xstring = lv_content

        TABLES

          et_data    = lt_content

        EXCEPTIONS

          noentries  = 1

          OTHERS     = 2.

* Store the attachment via BDS functionality

        CALL FUNCTION ‘ROS_BUPA_PUT_ATTACHMENT’

          EXPORTING

            iv_bp_number    = lw_but000-partner

            iv_comp_id      = lv_fname

            iv_mimetype     = lv_mime

            iv_comp_size    = lv_comp_size

          IMPORTING

            ev_doc_id       = lv_document_id

          TABLES

            it_content      = lt_content

          EXCEPTIONS

            nothing_found   = 1

            parameter_error = 2

            not_allowed     = 3

            internal_error  = 4

            error_kpro      = 5

            not_authorized  = 6

            OTHERS          = 7.

      ENDLOOP.

Thanks..

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Murali ram

    HI JIXON,

    Super Document , Made my work so easy!!!

    But what is the value you are passing in the lv_content of the function module

    ‘BBP_OUTPUT_X_TABLESIZE_CHG’  since it is in the exporting parameter.???

    lv_content declared as xstring..and starightaway it is mentioned in FM…

    May be am wrong.. Could you please explain??

    Thanks
    mlee

    (0) 
  2. Srinivas Rao

    dear,

    I am getting error becasue there is no  value for lv_content and lt_content for the function module BBP_OUTPUT_X_TABLESIZE_CHG. eventhough I added delete function module  below, it is not working. can you please help how to get the value for  lt_content.

    (0) 

Leave a Reply