‎2006 Nov 29 8:33 PM
Hi All,
Can any one tell me how to display data for different materials using a function module.
ie If i enter around 10 materials, then it should display the details of all the 10 materials using a function module.
Thanks
Raj
‎2006 Nov 29 8:47 PM
Hi Rajkumar,
Use function module <b>BAPI_MATERIAL_GET_DETAIL</b> to get the details of a material.
This function module accepts only one material, so in your case you need loop for all materials.
Another function module which gives material details is <b>SPP01_MATERIAL_DETAILS</b>.
Thanks,
Vinay
‎2006 Nov 29 8:53 PM
Vinay,
But in the function module BAPI_MATERIAL_GET_DETAIL it is displaying data for a single material but my question is how to display the data for more than 10 materials.
Is it possible to display the data for more than 10 materials?
waiting for ur reply....
Ramesh
‎2006 Nov 29 8:56 PM
Hi Raj Kumar,
Loop the function module BAPI_MATERIAL_GET_DETAIL and in loop append the Material details to some internal table. After coming out of the loop, the internal table has 10 materials and u can display them from there.
regards,
Shylesh
‎2006 Nov 29 9:20 PM
Hi Shylesh,
Can u provide me the code for the logic that you said.
Waiting for ur reply.
Thanks
Raj Kumar
‎2006 Nov 29 10:14 PM
Hi Raj,
please refer this code
REPORT ztest1 MESSAGE-ID z1.
tables: mara.
types: begin of t_matnr,
matnr type matnr,
end of t_matnr.
data: it_matnr type t_matnr occurs 0.
data: w_matnr type t_matnr.
data: imat_gen type table of BAPIMATDOA with header line.
data: imat_gen1 type table of BAPIMATDOA with header line.
*SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-006.
Select-options: p_matnr for mara-matnr.
*SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-006.
loop at p_matnr.
append p_matnr-low to it_matnr.
endloop.
loop at it_matnr into w_matnr.
CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
EXPORTING
MATERIAL = w_MATNR
PLANT = ' '
VALUATIONAREA = ' '
VALUATIONTYPE = ' '
IMPORTING
MATERIAL_GENERAL_DATA = IMAT_GEN.
RETURN =
MATERIALPLANTDATA =
MATERIALVALUATIONDATA =
imat_gen1 = imat_gen.
append imat_gen to imat_gen1.
endloop.
Loop at imat_gen1.
write: imat_gen1-MATL_TYPE.
endloop.
Here, the Internal table imat_gen1 has the ten records. This is an sample program. You have to change this as per your requirement.
Hope it will help you.
Shylesh