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: 

Reading Tables from FM

Former Member
0 Kudos

Hi all,

I am a (almost) Newcomer in ABAP programming. Now I have a problem with the FM "BAPI_MATERIAL_STOCK_REQ_LIST".
The FM I'll call as follows.

CALL FUNCTION 'BAPI_MATERIAL_STOCK_REQ_LIST' "Material - Current Requirements/Stock List
     EXPORTING
       material          = i_line-matnr  " bapi_mrp_mat_param-material  Material Number
       plant             = s_plant       " bapi_mrp_mat_param-plant  Plant
       mrp_area          = ''            " bapi_mrp_mat_param-mrp_area  MRP Area
       plan_scenario     = '000'         " bapi_mrp_mat_param-plan_scenario  Planning Scenario of Long-Term Planning
       selection_rule    = ''            " bapi_mrp_list_param-selection_rule  Selection Rule
       display_filter    = ''            " bapi_mrp_list_param-display_filter  Name of Display Filter
       period_indicator  = ''            " bapi_mrp_list_param-period_indicator  Internal Period Indicator
       get_item_details  = ''            " bapi_mrp_list_param-get_item_details  Indicator: Determination of Detail Display for MRP Elements
       get_ind_lines     = ''            " bapi_mrp_list_param-get_ind_lines  Indicator: Determination of Single-Line Display
       get_total_lines   = 'X'           " bapi_mrp_list_param-get_total_lines  Indicator: Determination of Period Totals Display
*     ignore_buffer     =               " bapi_mrp_list_param-ignore_buffer  Indicator: Data Determination of Database (Not from Buffer)
     IMPORTING
       mrp_list          = z_mrp_list            " bapi_mrp_list  MRP: MRP List
       mrp_control_param = z_mrp_control_param   " bapi_mrp_control_param  Material Requirements Planning: Control Parameters for Material
       mrp_stock_detail  = z_mrp_stock_detail    " bapi_mrp_stock_detail  MRP: Statistics Fields for Stocks
       return            = z_return              " bapiret2      Return Parameters
     TABLES
       mrp_items         = z_mrp_items           " bapi_mrp_items  MRP: MRP Document Item
       mrp_ind_lines     = z_mrp_ind_lines       " bapi_mrp_ind_lines  MRP: Single Lines of MRP Elements
       mrp_total_lines   = z_mrp_total_line     " bapi_mrp_total_lines  MRP: Totals Line MRP Elements
*     extensionout      =                       " bapiparex     Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIONOUT
     .                                           " BAPI_MATERIAL_STOCK_REQ_LIST

When I test the FM I see the required data in the tables "z_mrp_total_lines".
Now the question: How can I read this chart?
I only need the first record where the "Sort_dat"> = the current day.

Who of you has a workaround for me?

Greetings from Paderborn
Rolf
1 ACCEPTED SOLUTION

0 Kudos

Hi Rolf

Try this:

data ls_line type BAPI_MRP_TOTAL_LINES.

SORT z_mrp_total_lines by sort_dat.


loop at z_mrp_total_lines into ls_line

where sort_dat >= sy-datum.

  exit.

endloop.

if sy-subrc = 0.

  "Your Record is now in ths structure LS_LINE

endif.


I hope, this will help you.

Peer

2 REPLIES 2

0 Kudos

Hi Rolf

Try this:

data ls_line type BAPI_MRP_TOTAL_LINES.

SORT z_mrp_total_lines by sort_dat.


loop at z_mrp_total_lines into ls_line

where sort_dat >= sy-datum.

  exit.

endloop.

if sy-subrc = 0.

  "Your Record is now in ths structure LS_LINE

endif.


I hope, this will help you.

Peer

0 Kudos

Hi Peer,

Thanks for the great and quick response. Once I have this added to the source code I could evaluate and display the contents of the field.
Thanks for that.


Greetings from Paderborn (Germany)
Rolf