08-03-2011 2:46 PM
Dear Guru!
I'm new to ABAP, but I have to write a little in ABAP.
I create a LSMW project using BAPI for changing standart price of material.
Input data: material, price, posting date.
The point is: system should found in table MBEW all valuation areas and valuation types fo which the material record is exist and cang price for all these records.
I wrote a code for these fields in Field Mapping menu. But it puts in only one record whereas I need it to execute BAPI for all records.
I wrote the folliwing:
VALUATIONAREA Valuation Area
Code: tables MBEW.
select * from MBEW
where MATNR = ZHEADER-MATNR.
E1MATERIALVALUATION_PRICECH-VALUATIONAREA = MBEW-BWKEY.
endselect.
VALUATIONTYPE Valuation Type
Code: select * from MBEW
where MATNR = ZHEADER-MATNR.
E1MATERIALVALUATION_PRICECH-VALUATIONTYPE = MBEW-BWTAR.
endselect.
May be it's simple, may be not. But I don't know how do do it.
Will be grateful for any hints.
Thanks.
Edited by: assoli on Aug 3, 2011 3:51 PM
08-04-2011 3:14 AM
select endselect goes like a Loop, so if you don't store the value in some table (internal table), only the last row will be available to you as it will be overwritten everytime in the loop.
There is no need of using 2 selects, one select itself will give you all the data for that material in MBEW table. I don't understand what you are doing with
E1MATERIALVALUATION_PRICECH-VALUATIONAREA = MBEW-BWKEY
Is E1MATERIALVALUATION_PRICECH a structure ? You need somethng like
select * from MBEW
where MATNR = ZHEADER-MATNR.
E1MATERIALVALUATION_PRICECH-MATERIAL = ZHEADER-MATNR
E1MATERIALVALUATION_PRICECH-VALUATIONAREA = MBEW-BWKEY.
E1MATERIALVALUATION_PRICECH-VALUATIONTYPE = MBEW-BWTAR.
Append E1MATERIALVALUATION_PRICECH to itab. "(itab is internal table)
endselect.
Then use that itab for your purpose.