Skip to Content

Scope:
While creating shopping cart in Codac application there  are various fields where same data needs to be entered in all Line Items. As this is a time consuming process, “Copy to all Line Item” functionality developed.

Capture.JPG

Copying items from first line items and to all lines items
Items:
1.Company code
2.Purchasing group
3.Custom fields
4.Application type

5.Quotaion Number

Accounting Assignment category
Accounting Assignment category(All fields(G/L Account,cost center)

in Account Assignment)

Source of Supply

Assign supplier to all line items

Solution:
1. Enhance component /SAPSRM/WDC_UI_SC_DOTC_BD , add Update all button

2.Write code in the update all method

For update the event

wd_comp_controller->mo_bom_sc->/sapsrm/if_cll_bo_mapper~fire_event_update( ).

wd_comp_controller->mo_bom_sc->/sapsrm/if_cll_bo_mapper~fire_event_refresh( iv_perform_updates = abap_false ).

lo_task_factory=/sapsrm/cl_ch_wd_taskcont_fact=>get_instance( )
IF lo_task_factory IS NOT INITIAL.
    lo_task_container = lo_task_factory->get_task_container( ).
     IF lo_task_container IS NOT INITIAL.
       lo_bom_sc = lo_task_container->get_bom_sc( ).
       lo_pdo = lo_bom_sc->/sapsrm/if_cll_bo_mapper~get_pdo( ).
       lo_bo_sc_adv ?= lo_pdo.
       lo_pdo_bo_sc ?= lo_pdo.
       lo_pdo_acc ?= lo_pdo.

       lo_pdo_partner ?= lo_pdo.

Get Header GUID
       CALL METHOD lo_pdo->get_header_guid
         RECEIVING
           rv_header_guid = lv_parent_guid.
     ENDIF.
   ENDIF.
To get the ITEMs guid from the header GUID
CALL METHOD lo_bo_sc_adv->/sapsrm/if_pdo_base~get_item_list
     EXPORTING
       it_parent_guid = lt_parent_guid
     IMPORTING

       et_item_guid   = lt_item_guid.

To get the ITEMS detail  by passing the ITEMS_GUID  .
CALL METHOD lo_bo_sc_adv->/sapsrm/if_pdo_bo_sc~get_item_detail
EXPORTING
   it_item_guids = lt_item_guid_get
IMPORTING
  et_item       = lt_items_d.
Update Items
CALL METHOD LO_BO_SC_ADV->/SAPSRM/IF_PDO_BO_SC~UPDATE_ITEMS
    EXPORTING
      IT_ITEM            = lt_items_u
Submit update
CALL METHOD lo_bo_sc_adv->/sapsrm/if_pdo_base~submit_update
     CHANGING
       co_message_handler = lo_handler.
Get Account assignment by passing items guid
    TRY.
      CALL METHOD lo_pdo_acc->get_account_assignment
         EXPORTING
           iv_parent  = ls_items_v-guid
         IMPORTING
           et_account = lt_account.
        CATCH /sapsrm/cx_pdo_abort .
          EXIT.
      ENDTRY.
Get Item Partners by passing item guid
CALL METHOD lo_pdo_partner->/sapsrm/if_pdo_do_partner_base~get_item_partners
      EXPORTING
        IV_ITEM_GUID          = ls_items_v-guid
      IMPORTING
        ET_PARTNER            = lt_partner
      CHANGING
        CO_MESSAGE_HANDLER    = lo_handler
Update account assignment all
Looping items and pass the account details and item partner to update all line items
CALL METHOD lo_bo_sc_adv->
/sapsrm/if_pdo_do_acct_assgmnt~update_account_assignment_all
            EXPORTING
              it_account = lt_account
            CHANGING
              CO_MESSAGE_HANDLER = lo_handler
              .
Submit Update
CALL METHOD lo_pdo->submit_update
              CHANGING
                CO_MESSAGE_HANDLER = lo_handler.
Update Partners via DO
CALL METHOD lo_pdo_partner->update_item_partners
              EXPORTING
                iv_item_guid       = ls_items_v-guid
                it_partner         = lt_vendor
              CHANGING
                co_message_handler = lo_handler.
To report this post you need to login first.

2 Comments

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

  1. kedhareeswari tekumudi

    Hi Raghav,

    Very useful document!

    And i have one query, now you are coping the account assignment for cost centre as i seen in your screen shot, Is it possible to copy other type of accounts as like cost centre

    ( Eg: WBS element).

    Appreciate your comments!

    Thanks,

    Eswari.

    (0) 

Leave a Reply