Application Development and Automation 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: 
Read only

Batch for a material

Former Member
0 Likes
884

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.

8 REPLIES 8
Read only

bastinvinoth
Contributor
0 Likes
848

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

Read only

0 Likes
848

Dear Bastin,

    Thanks for your reply,

I tried this query and loop, But it is not fetching....

Read only

0 Likes
848

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

Read only

0 Likes
848

This message was moderated.

Read only

0 Likes
848

Dear Bastin,

        The issue has been solved.

Thanks for your reply.

Read only

gouravkumar64
Active Contributor
0 Likes
848

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.

Read only

0 Likes
848

Hi,

   I have i have given the internal table name also... but still not working...

Read only

himanshu_gupta13
Product and Topic Expert
Product and Topic Expert
0 Likes
848

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