Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI Select Query

sastry_gunturi
Active Participant
0 Kudos
    call function 'BAPI_COSTCENTERGROUP_GETDETAIL'
         exporting
              controllingarea = p_kokrs
              groupname       = p_ksgru
         tables
              hierarchynodes  = itab_nodes
              hierarchyvalues = gt_cgrp.

    if sy-subrc = 0.
      refresh s_kostl.
      move: 'I' to s_kostl-sign,
            'BT' to s_kostl-option.
      loop at gt_cgrp.
        move gt_cgrp-valfrom to s_kostl-low.
        move gt_cgrp-valto   to s_kostl-high.
        append s_kostl.
      endloop.
    endif.

In the above code even though the BAPI returns 33 values

S_KOSTL has 66 values ( values are replicated into it).

How to fix this problem.......

2 REPLIES 2

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


call function 'BAPI_COSTCENTERGROUP_GETDETAIL'
  exporting
    controllingarea = p_kokrs
    groupname       = p_ksgru
  tables
    hierarchynodes  = itab_nodes
    hierarchyvalues = gt_cgrp.
 
if sy-subrc = 0.
  refresh s_kostl.
  move: 'I' to s_kostl-sign,
        'BT' to s_kostl-option.
  loop at gt_cgrp.
    move gt_cgrp-valfrom to s_kostl-low.
    move gt_cgrp-valto   to s_kostl-high.
    append s_kostl.
  endloop.
endif.

sort s_kostl.
delete adjacent duplicates from s_kostl.

Regards,

Ferry Lianto

Former Member
0 Kudos

Karthik - your code works with no problems in our system.

On the other hand, you are checking the return code after the BAPI call. You should be checking the BAPI return structure instead. So it may be that the BAPI is not returning values, and you have tables that are filled with old values.

Rob

Message was edited by:

Rob Burbank