cancel
Showing results for 
Search instead for 
Did you mean: 

Child nodes of the business object

Former Member
0 Kudos

Hi,

I am trying to update PR having multiple line items using the below code.

lo_gsdo_node_list = lo_gsdo_root_node->get_children( ).
lo_gsdo_child_node = lo_gsdo_node_list->get_first( ).

The first line of the code works fine. The second line fails to get the child node of the first line item.I dont have any problems using the same code for Create operation. Create and Read operations works just fine.

Please let me know if I am missing something as I am new to OOPS.

Thanks,

Pranil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Pranil,

get_first method get the first instance of in the child collection of the GSDO. This may throw an error if the collection of child is empty. But if you want to add a child use the add_child method.

It is little difficult to find the issue with out the context, can you please share the complete code and the context of the usage?

Thanks,

Girimurugan

Former Member
0 Kudos

Hi Girimurugan,

I am calling the BAPI 'BAPI_PR_CHANGE' to update the PR. Below is the code.

method /IWFND/IF_SRD_BOP_MAP_UPDATE~MAP_PRE_UPDATE.
  DATA:lo_bop_do TYPE REF TO zcl_ppr_e_bop_do,
            lo_gsdo_root_node TYPE REF TO /iwfnd/if_srd_gsdo_node,
            lo_gsdo_node_list TYPE REF TO /iwfnd/if_srd_gsdo_node_list,
            lo_gsdo_child_node TYPE REF TO /iwfnd/if_srd_gsdo_node,
            ls_request TYPE zcl_ppr_e_bop=>_params_request,
            lt_pritem LIKE ls_request-pritem,
            ls_pritem LIKE LINE OF lt_pritem,
            lt_pritemx LIKE ls_request-pritemx,
            ls_pritemx LIKE LINE OF lt_pritemx,
            ls_key TYPE /iwfnd/s_cor_id,
            ls_model_attributes TYPE ZMDLZzPR_DETAILS,
            lt_model_attributes TYPE STANDARD TABLE OF ZMDLZPR_DETAILS,
            ls_model_relation TYPE zmdlzzpr_items,
            lt_model_relation TYPE STANDARD TABLE OF zmdlzzpr_items.

  CONSTANTS:c_x(1) TYPE c VALUE 'X'.

  CLEAR ev_process_code.

  lo_gsdo_root_node = io_gsdo->get_root_node( ).
  IF lo_gsdo_root_node IS NOT BOUND.
    RETURN.
  ENDIF.

  CALL METHOD lo_gsdo_root_node->get_key
    IMPORTING
      es_key = ls_key.

  CALL METHOD lo_gsdo_root_node->get_attributes
    IMPORTING
      es_attributes = ls_model_attributes.
* get the model's item structure
  FREE lt_model_relation.
  lo_gsdo_node_list = lo_gsdo_root_node->get_children( ).
* the child node should always be bound
  IF lo_gsdo_node_list IS NOT BOUND.
    RETURN.
  ENDIF.

  *lo_gsdo_child_node = lo_gsdo_node_list->get_first( ).*  {color:green}This is the line which is not working{color} 

  DO.
    IF lo_gsdo_child_node IS BOUND.
*       get the model's create item structure
      CALL METHOD lo_gsdo_child_node->get_attributes
        IMPORTING
          es_attributes = ls_model_relation.
      APPEND ls_model_relation TO lt_model_relation.
    ELSE.
      EXIT.
    ENDIF.
    lo_gsdo_child_node = lo_gsdo_node_list->get_next( ).
  ENDDO.

  ls_request-number = ls_key-value.

  FREE: lt_pritem,
            lt_pritemx.

* PR Item information
  CLEAR ls_pritem.
  LOOP AT lt_model_relation
    INTO ls_model_relation.
  ls_pritem-preq_item = ls_model_relation-purchase_req_item.
  ls_pritem-pur_group = ls_model_relation-purchase_group.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input         = ls_model_relation-material
   IMPORTING
     OUTPUT        = ls_pritem-material
            .

  ls_pritem-plant = ls_model_relation-plant.
  ls_pritem-quantity = ls_model_relation-quantity.
  ls_pritem-deliv_date = ls_model_relation-delivery_date.
  ls_pritem-rel_date = ls_model_relation-release_date.
  ls_pritem-purch_org = ls_model_relation-purchase_organization.
  APPEND ls_pritem TO lt_pritem.

* PO ItemX information
  CLEAR ls_pritemx.
  ls_pritemx-preq_item = ls_model_relation-purchase_req_item.
  ls_pritemx-preq_itemx = c_x.
  ls_pritemx-pur_group = c_x.
  ls_pritemx-material = c_x.
  ls_pritemx-plant = c_x.
  ls_pritemx-quantity = c_x.
  ls_pritemx-deliv_date = c_x.
  ls_pritemx-rel_date = c_x.
  ls_pritemx-purch_org = c_x.
  APPEND ls_pritemx TO lt_pritemx.
  ENDLOOP.

  ls_request-pritem = lt_pritem.
  ls_request-pritemx = lt_pritemx.

  lo_bop_do ?= io_bop_do.
  lo_bop_do->set_request( ls_request ).
endmethod.

Thanks,

Pranil

Former Member
0 Kudos

Hi Pranil,

First you have to get child result of relation and call the get_first method get the first instance of in the child collection of the GSDO.

If child GSDO is not intial then call the 'get_attributes' method for getting model parameters.

Append the all parameters and loop that internal table and modify the fields and pass it to requst of BAPI.

Below see the below simple code of PR.

CALL METHOD lo_gsdo_root_node->get_relation
    EXPORTING
      iv_relation_name = c_relation_pritem
    RECEIVING
      rv_result        = lo_gsdo_child_result.

  lo_gsdo_child = lo_gsdo_child_result->get_first( ).
  WHILE lo_gsdo_child IS BOUND.
    lo_gsdo_child->get_attributes( IMPORTING es_attributes = ls_mod_pritem ).
    MOVE-CORRESPONDING ls_mod_pritem TO ls_request_pritem .
    APPEND   ls_request_pritem TO  lt_request_pritem.
    lo_gsdo_child = lo_gsdo_child_result->get_next( ).
    CLEAR ls_mod_pritem.
  ENDWHILE.

Regards,

Venkatmuni

Answers (0)