2013 May 06 10:18 AM
Hi all,
This is sam here and i have a prob while printing a smartform.
I have to display material number and also the relevant batch for the material. I have taken batch from MCHB table.
The problem is for a material there are one and more than one batches. If there are more than one batch for the material, then iam able to pick only the first or last batch. How can i pick all the batches which are relevent to that material with the condition where unrestricted stock is more than zero "clabs > '0'.".
Kindly help.
Rgds,
Sam.
2013 May 06 10:43 AM
Dear Samuel Dennis
y can't u use select statement and loop here.
see the below code for your reference.
data: it_mchb type TABLE OF mchb WITH HEADER LINE.
select * from mchb INTO CORRESPONDING FIELDS OF TABLE it_mchb WHERE matnr = p_matnr and clabs > '0'.
loop at it_mchb into wa_mchb . " pass this to main window or whatever it is,based on ur requirement,
endloop.
Regards,
Bastin.G
2013 May 06 10:56 AM
Dear Bastin,
Thanks for your reply,
I tried this query and loop, But it is not fetching....
2013 May 06 11:34 AM
Dear Samuel Dennis,
Not fetching ? really in my case here its working fine
use fm CONVERSION_EXIT_MATN1_INPUT
before select query ,,pass your material number to that fm and then pass to select query.
let me know if any issues.
Regards,
Bastin.G
2013 May 07 4:37 AM
2013 May 20 6:43 AM
2013 May 06 11:52 AM
Hi Samuel ,
You are using table or templates ?
If using Table then within data tab,do not forget to write it_tab & wa_tab (your table name).
Thanks
Gourav.
2013 May 07 4:44 AM
Hi,
I have i have given the internal table name also... but still not working...
2013 May 06 12:04 PM
Dear Samuel,
Kindly look below code, if I am wrong somewhere then plz revert back on this post..
DATA: it_mchb TYPE TABLE OF mchb WITH HEADER LINE.
SELECT * FROM mchb
INTO CORRESPONDING FIELDS OF TABLE it_mchb
WHERE matnr = p_matnr AND clabs > '0'.
SORT it_mchb BY matnr year ASCENDING. " for getting first batch
* or
*SORT it_mchb BY matnr year DESCENDING. " for getting last batch
LOOP AT it_mchb.
AT NEW matnr.
"here you fatch your batch
ENDAT.
ENDLOOP.
Many Thanks / Himanshu Gupta