‎2011 Sep 22 7:41 AM
Hi,
I am working in BDC for update valuation class for T-code mm01.Actually In this BDC i am using two recoding based on material type.
i am using two internal table : I_DATA and ITAB
Use I_DATA to hold excle data in which material No, plant , valuation type , valuation No. and ITAB for material No, material type Only.
So, i am fetching material Type ( MARA-MTART ) through select query. But Select query is not working. and also i did check MARA table according that Material Number then material no. exit in Mara Table.
Note : at run time I_DATA have 1 row but ITAB have 0 row ....
***********************************
DATA: BEGIN OF I_DATA OCCURS 0,
MATNR TYPE MARA-MATNR,
WERKS TYPE MARC-WERKS,
BWTAR TYPE RMMG1-BWTAR,
VERPR TYPE BMMH1-VERPR,
BKLAS TYPE MBEW-BKLAS,
STATUS TYPE C,
END OF I_DATA.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
END OF ITAB.
Loop at I_DATA.
select matnr mtart from mara into table itab where matnr = I_DATA-matnr.
endloop.
************************************************************************************************
Guide me..........
‎2011 Sep 22 7:53 AM
Hi,
Before using the value of MATNR in the select query, use conversion exit (CONVERSION_EXIT_ALPHA_INPUT)
to add the prefixed zeroes to the value.
Loop at I_DATA.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = I_DATA-matnr
IMPORTING
output = I_DATA-matnr.
select matnr mtart from mara into table itab where matnr = I_DATA-matnr.
endloop.
‎2011 Sep 22 7:53 AM
Hi,
Before using the value of MATNR in the select query, use conversion exit (CONVERSION_EXIT_ALPHA_INPUT)
to add the prefixed zeroes to the value.
Loop at I_DATA.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = I_DATA-matnr
IMPORTING
output = I_DATA-matnr.
select matnr mtart from mara into table itab where matnr = I_DATA-matnr.
endloop.
‎2011 Sep 22 8:36 AM
Hi vinraaj,
this CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' is gud working . actually I have 10 rows in I_DATA. and
loop is working 10 time .
But I have only 1 row in ITAB after loop ending. i want append every loop iteration in ITAB.
So, I am using Code......
*********************************************************
Loop at I_DATA.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = I_DATA-matnr
IMPORTING
output = I_DATA-matnr.
select matnr mtart from mara into table itab where matnr = I_DATA-matnr.
MODIFY itab TRANSPORTING matnr mtart.
APPEND itab.
modify itab.
endloop.
*********************************************************
How can possible...........?
Guide me.........
‎2011 Sep 22 9:53 AM
Hi vinraaj,
Thanks vinraj my problem has been solved ..
But I have not able to understand. why I am not able to fetch data from MARA on the basis of internal Table I_DATA .
why inside loop at I_DATA this query
select matnr mtart from mara into table itab where matnr = I_DATA-matnr. ?
‎2011 Sep 22 10:12 AM
But I have not able to understand. why I am not able to fetch data from MARA on the basis of internal Table I_DATA .
See in table I_DATA the value of MATNR will be for example : 98968493.
But in table it will be stored as 000000000098968493. So when we fetch using 98968493 from table MARA the same will not be fetched. The type of MATNR is CHAR, so in CHAR '001' and '1' are different. Both 001 and 1 are same only if the type is integer.
If your problem is solved, please <removed by moderator> close the thread.
Edited by: Thomas Zloch on Sep 22, 2011 9:02 PM
‎2011 Sep 22 11:02 AM
I agree, if data comes from an external source, like a file on presentation server, with material reference in external format, you don't have anything to do for a BDC as it accepts data in external format, but to enrich the data in your program you have to convert it in internal format.
LOOP AT i_data ASSIGNING <wa>.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = <wa>-mfrpn " external format, you can keep for BDC
IMPORTING
output = <wa>-matnr " internal format required for SELECT
EXCEPTIONS
length_error = 1
OTHERS = 2.
ENDLOOP.But before coding, look via SE11 for the correct conversion exit associated to domain MATNR on your system. (Customizing and Solutions applied on system)
Regards,
Raymond
‎2011 Sep 22 9:29 AM
If you use your
Loop at I_DATA.
select matnr mtart from mara into table itab
where matnr = I_DATA-matnr.
endloop.At end of loop, itab will only contain the result of the last select, so use a
Loop at I_DATA.
select matnr mtart from mara APPENDING table itab
where matnr = I_DATA-matnr.
endloop.better
if I_DATA[] is not initial.
select matnr mtart from mara into table itab
FOR ALL ENTRIES IN i_data where matnr = i_data-matnr.
endif.Some Remarks
- If actually required (where does I_DATA come from, is it an external format, you need the internal value to use in SELECT statement), check via SE11 the correct [conversion exit|http://help.sap.com/saphelp_nw04/helpdata/en/35/26b217afab52b9e10000009b38f974/content.htm] associated with domain MATNR (Is it truly ALPHA, and not something like MATN1, so [CONVERSION_EXIT_MATN1_INPUT|http://www.sdn.sap.com/irj/scn/advancedsearch?query=conversion_exit_matn1_input])
- You could try to use BAPI like [BAPI_MATERIAL_SAVEDATA|http://www.sdn.sap.com/irj/scn/advancedsearch?query=bapi_material_savedata] and not BDC
Regards,
Raymond