cancel
Showing results for 
Search instead for 
Did you mean: 

Display multiple line items

Former Member
0 Kudos

In Duet Enterprise 1.0, I developed a process to get list of Purchase Requistions. List is getting into Duet environment successfully. But when I try to display detailed information, it is showing only one line item information (last occurance of the line item).

IF lo_gsdo IS BOUND.

    lo_gsdo_root_node = lo_gsdo->get_root_node( ).

    CALL METHOD lo_gsdo_root_node->get_key

      IMPORTING

        es_key = ls_key.

    IF ls_response_rfc-pritem IS NOT INITIAL. " read first row

      LOOP AT ls_response_rfc-pritem INTO ls_response_rfc_pr.                " CHANGES ON 5-6-2012

        /iwfnd/cl_id_util=>convert_key_to_string_id( EXPORTING is_key = ls_key

          RECEIVING rv_id = ls_mdl_pr-prscl_key ).

        " fill the other values, this is the mapping here

        ls_mdl_pr-preq_no = ls_key-value.

        ls_mdl_pr-preq_item = ls_response_rfc_pr-preq_item.

        ls_mdl_pr-doc_type = ls_response_rfc_pr-doc_type.       "ADDED ON 6-3-2012  TMK

        ls_mdl_pr-preq_name = ls_response_rfc_pr-preq_name.

        ls_mdl_pr-material = ls_response_rfc_pr-material.

        ls_mdl_pr-quantity = ls_response_rfc_pr-quantity.

        ls_mdl_pr-preq_date = ls_response_rfc_pr-preq_date.

        lo_gsdo_root_node->set_attributes( is_attributes = ls_mdl_pr ).

      ENDLOOP.

    ELSE.

      " do error handling here

    ENDIF.

  ENDIF.

can anybody suggest me to get the multiple line items

thanks,

Kris.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I think there is a "lo_gsdo_root_node->add_child" missing inside the loop. Please take a look at the developer guide. There you will find a similar example where the table of sales order items is being processed and multiple child items being added to the root.

Cheers, Alex

Former Member
0 Kudos

Hi Alex,

Thanks for the solution.

I have followed the same thing. Please find the code below:

/iwfnd/cl_id_util=>convert_key_to_string_id( EXPORTING is_key = ls_key

        RECEIVING rv_id = ls_mdl_pr-prscl_key ).

      LOOP AT ls_response_rfc-pritem INTO ls_response_rfc_pr.      

        ls_key-value = lv_value. "ls_response_rfc_pr-preq_item .

        ls_key-scheme_agency_id = iv_system_alias.

        ls_key-scheme_id = 'PRITEMS'.  "'PRGETITEMSREL'. "'PRGETDETAIL'.

      lo_item = lo_gsdo_root_node->add_child( iv_relation_name = 'PRITEMS' is_child_key =            ls_key ).

          " fill the other values, this is the mapping here

        ls_mdl_pr-preq_no = ls_key-value.

        ls_mdl_pr-preq_item = ls_response_rfc_pr-preq_item.

        ls_mdl_pr-doc_type = ls_response_rfc_pr-doc_type.       "ADDED ON 6-3-2012  TMK

        ls_mdl_pr-preq_name = ls_response_rfc_pr-preq_name.

        ls_mdl_pr-material = ls_response_rfc_pr-material.

        lo_gsdo_root_node->set_attributes( is_attributes = ls_mdl_pr ).

        lo_item->set_attributes( ls_mdl_pr ).

endloop.

Still Iam getting only one item data.

Thanks,

Kris

Advay
Employee
Employee
0 Kudos

Hi Kris,

What is lv_value ?

  ls_key-value = lv_value. "ls_response_rfc_pr-preq_item .

The value for the KEY should always be item number. In this case its a constant (lv_value) and thats why only 1 record is being added inspite of looping through ls_response_rfc-pritem.

Can you update the above code to

ls_key-value = ls_response_rfc_pr-preq_item .

Let me know if this helps.

I also noticed another issue in the line,

    lo_gsdo_root_node->set_attributes( is_attributes = ls_mdl_pr ).

the above piece of code will update the attribute structure of the ROOT (Purchase Requisition) with the last ITEM's attribute structure.

Thanks,

Advay

Former Member
0 Kudos

Hi Advay,

I followed the same thing that you suggested. Please find the code as below:

LOOP AT ls_response_rfc-pritem INTO ls_response_rfc_pr.

        ls_key-value = ls_response_rfc_pr-preq_item.

        ls_key-scheme_agency_id = iv_system_alias.

        ls_key-scheme_id = 'PRITEMS'. 

        lo_item = lo_gsdo_root_node->add_child( iv_relation_name = 'PRITEMS' is_child_key = ls_key ).

        ls_mdl_pr-preq_no    = ls_key-value.

        ls_mdl_pr-preq_item  = ls_response_rfc_pr-preq_item.

        ls_mdl_pr-doc_type   = ls_response_rfc_pr-doc_type.

        ls_mdl_pr-preq_name  = ls_response_rfc_pr-preq_name.

        ls_mdl_pr-material   = ls_response_rfc_pr-material.

        lo_gsdo_root_node->set_attributes( is_attributes = ls_mdl_pr ).

ENDLOOP.

ls_key-value is assigned preq_item and it is dynamic within the loop. At each loop pass preq_item is incrementing (checked in debug mode).

please give me alternative for lo_gsdo_root_node->set_attributes( is_attributes = ls_mdl_pr ).

Thanks,

Kris

Advay
Employee
Employee
0 Kudos

Hi Kris,

The above code will still not work because the attribute structure for PR_ITMES is not being set anywhere. Your code should look like this

The below code explains how header and items of a PR is mapped. For the header part I am providing the pointers (you can translate it into code), for the Items part I have modified the above code,

"FOR PR HEADER

--> Get the RFC Response

--> Get the Header information in local structure (PR HEADER structure from your STC class)

--> do the mapping into ls_mdl_pr_header (structure for header)

--> lo_gsdo_root_node = io_gsdo->get_root_node( ).

--> lo_gsdo_root_node->set_attributes( is_attributes = ls_mdl_pr_header ).

" FOR PR ITEMS

LOOP AT ls_response_rfc-pritem INTO ls_response_rfc_pr.

        ls_key-value = ls_response_rfc_pr-preq_item.

        ls_key-scheme_agency_id = iv_system_alias.

        ls_key-scheme_id = 'PRITEMS'. 

        lo_item = lo_gsdo_root_node->add_child( iv_relation_name = 'PRITEMS' is_child_key = ls_key ).

        ls_mdl_pr-preq_no    = ls_key-value.

        ls_mdl_pr-preq_item  = ls_response_rfc_pr-preq_item.

        ls_mdl_pr-doc_type   = ls_response_rfc_pr-doc_type.

        ls_mdl_pr-preq_name  = ls_response_rfc_pr-preq_name.

        ls_mdl_pr-material   = ls_response_rfc_pr-material.

        lo_item->set_attributes( is_attributes = ls_mdl_pr ).

ENDLOOP.

For more information you can check the dev guide as mentioend by Alex in above post. Go to page number 119-120 for READ method.

Hope this helps.

Thanks,

Advay

Former Member
0 Kudos

Hello Advay,

Thanks alot for your support.

As you said that

"The above code will still not work because the attribute structure for PR_ITMES is not being set anywhere."

Please guide me of how to create the relation so that we can use it in add_child method.

Here I have used PRITEMS in the code.

Thanks,

Kris

Advay
Employee
Employee
0 Kudos

Hi Kris,

You must understand how a GW data model is represented.

In a nutshell, GW data model is metadata, which consist of KEY structure and ATTRIBUTE structure.

For you example, Purchase Requisition, its a complex data object. It has got, Purchase Header (with Key and Attribute structures) and Purchase Items (with its own Key and Attribute structure).

In the mapping code, you are just doing what I wrote in above line.

LOOP AT ls_response_rfc-pritem INTO ls_response_rfc_pr. " Looping thru RFC Response

" Creating KEY for PR ITEM..       

        ls_key-value = ls_response_rfc_pr-preq_item.

        ls_key-scheme_agency_id = iv_system_alias.

        ls_key-scheme_id = 'PRITEMS'.         

" Creating a CHILD object and adding it to ROOT object - ..

lo_item = lo_gsdo_root_node->add_child( iv_relation_name = 'PRITEMS' is_child_key = ls_key ).

" Constructing the ATTRIBUTE structure for CHILD object (in your case PR ITEM)

        ls_mdl_pr-preq_no    = ls_key-value.

        ls_mdl_pr-preq_item  = ls_response_rfc_pr-preq_item.

        ls_mdl_pr-doc_type   = ls_response_rfc_pr-doc_type.

        ls_mdl_pr-preq_name  = ls_response_rfc_pr-preq_name.

        ls_mdl_pr-material   = ls_response_rfc_pr-material.

" Setting the attribute structure for the CHILD object       

     lo_item->set_attributes( is_attributes = ls_mdl_pr ).

ENDLOOP.

"The above code will still not work because the attribute structure for PR_ITMES is not being set anywhere."

I made the above statement because the last line (setting the attr struc for ITME ) was missing from the code.

Thanks,

Advay

Former Member
0 Kudos

Hi Advay,

Thanks for your kind support.

I followed the same methodology as you suggested. But Iam getting a exception like

Relation is not modeled.

Please kindly find the attachements for your reference. Please guide me.

But Iam modelling in the se38 program : /IWFND/R_IFL_TY_MODEL_GEN like below:

Thanks & Regards,

Kris

Advay
Employee
Employee
0 Kudos

Hi Kris,

Sorry, I missed the initial part of your query.

Are you using GENIL model ?

The dev guide which Alex mentioned in one of the above posts and the code which I pointed out (page 119-120) does not work with GENIL model.

Note that, GENIL models were used in Duet Enterprise 1.0 but in Duet Enterprise FP1, the GENIL models were migrated to GW Data models.

You have follow the older dev guide of DE 1.0 present at http://scn.sap.com/docs/DOC-5636

The similar code should be present in pages 60-67, in order to continue with your GENIL models.

I think you should take a look at the entire development process and dev guide before proceeding further.

In addition, you cal also look at some pre-delivered content code,

e.g. class - /IWCNT/CL_BOPRR_CUST_ID_MAP  method - MAP_POST_GET_OBJECTS

Thanks,

Advay

Former Member
0 Kudos

Hello Advay,

Thanks for the update.

Searched the duet developer guide(pages 60-67) and didn't found the similar code which solves this issue. And since we are using GenIL modelling and there is no workaround available, we approached SAP. We got a solution from SAP that --- "In QUERY operation itself, we need to get the PR Numbers Item Wise. i.e., for multiple items, we need to get all PR numbers for all the item numbers. There is nothing to do at READ operation."

But as per Duet Enterprise Developer guide 1.0, we are getting only PurchaseRequisition Number for the PRSclKey.

But how to generate SclKey based on both PR number and PRItem?

/iwfnd/cl_id_util=>convert_key_to_string_id(

      EXPORTING is_key = ls_key
      RECEIVING rv_id = ls_mdl_pr-prscl_key
         ).

Iam assigning PRNumber and Item to ls_key. But it is static. But it should take PreqNo and ItemNo into consideration to get Query list dynamically.

Can you please throw a light on this and suggest me the solution.

Waiting for your valuable suggestion,

Thanks,

Kris

Advay
Employee
Employee
0 Kudos

Hi Kris,

Can you please help me with your requirement ?

I am a bit confused about whether you need

  • A single PR header and then all PR Items for this specific PR header
  • All PR items for all PR headers

The first scenario can be achieved via PR header READ functionality. (and I could see that your GENIL model is exactly similar to this).

If its the second case, then first find out whether you have a RFC which provides you all the PR items for all PR headers? If you have one such RFC, then GENIL model should not be complex, you can just have attributes structure for PR item in the GENIL. (You may have to create a new GENIL model, the existing one might not work).

Let me know where your solution fits in.

Thanks,

Advay

Former Member
0 Kudos

Hi Advay,

Iam not considering Header part(Since header structure doesnot exist in BAPI). Iam directly displaying Item information (since Item part is having Preq Number and Preq Item). But in Query, we need to fetch repeated preq numbers for all the preq items.

For ex, for different PR items, repeated preq numbers exists. We need to show preq numbers along with preq items in the QUERY operation. All the records will be unique from QUERY operation.

From this query operation, we need to fetch detialed data from READ operation.

The BAPI for Query operation (BAPI_REQUISITION_GETITEMSREL) is giving all the header information in item structure itself. Please check the BAPI for ur reference.

Thanks for your kind support,

Kris

Advay
Employee
Employee
0 Kudos

Hi Kris,

I checked the BAPI -  BAPI_REQUISITION_GETITEMSREL, it will provide list of PR items.

You need to provide REL_GROUP and REL_CODE as input to fetch all the items.

You also mentioned:

"From this query operation, we need to fetch detialed data from READ operation."

Do you have another RFC/BAPI for READ operation (to display details of PR item) ?

Depending upon the READ RFC you need set your SCL KEY.

Thanks,

Advay

Former Member
0 Kudos

Hello Advay,

For PurchaseRequisition Read Operation(for PR details), we are having BAPI "BAPI_PR_GETDETAIL" and Iam using that.

In Query, we need to fetch repeated preq numbers for all the preq items.

We should model our PRSclKey like this for example:

0109_0010001000_00010_ZPRHEADER_SPI_SERV_160

0109_0010001000_00020_ZPRHEADER_SPI_SERV_160

0109_0010002000_00010_ZPRHEADER_SPI_SERV_160

0109_0010002000_00020_ZPRHEADER_SPI_SERV_160

0109_0010002000_00030_ZPRHEADER_SPI_SERV_160

(Here for different records repeated preq numbers exists. We need to show preq numbers along with preq items in the QUERY operation. All the records will be unique from QUERY operation)

When we click any single record, it should execute Read Operation(since each record gives item details for particular preq number and preq item)

But currently my PRSclKey format is like

0109_0010002000_ZPRHEADER_SPI_SERV_160.

Please suggest.

Thanks,

Kris

Advay
Employee
Employee
0 Kudos

Hi Kris,

try this.

LOOP AT ls_response_rfc-pritem INTO ls_response_rfc_pr. " Looping thru RFC Response

" Creating KEY for PR ITEM..       

         lv_pr_header_no = ls_response_rfc_pr-preq_no. " PR HEADER NO ..

         lv_pr_item_no = ls_response_rfc_pr-preq. " PR ITEM NO

         concatenate lv_pr_header_no '_'  lv_pr_item_no INTO ls_key-value.

        ls_key-scheme_agency_id = iv_system_alias.

        ls_key-scheme_id = 'PRITEMS'.         

          .

         .

          .

ENDLOOP.

In the above code (QUERY post mapper) you are concatenating the PR HEADER number and PR Item number. Similary, for the READ call for PR item, you need to get back PR ITEM number from the concatenated value. You have to get the value from the key and then do a SPLIT AT on '_' to get the PR Header and PR Item values.

Hope this helps.

Thanks,

Advay

Former Member
0 Kudos

Hi Advay,

Thanks for your continued support.

Problem solved.

Answers (0)