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

Linkage between batch number and material document

berkuamit
Explorer
0 Likes
3,544

Hello,

In a query that I'm writing I have batch number (MCHB-CHARG) and have to find the material document (MSEG-MBLNR) that contains this batch (to print out copy of a label that attached to the material document).

I saw that in MSEG there is a field of CHARG but it's not key and not in standart indexes,

so because it's a huge table, I don't want to do direct select from it.

In the other way, the field MBLNR doesn't exists in MCHA nor MCHB tables.

Do anyone know how can I do this linkage ? is there any appropriate BAPI or standart function ?

Thank you,

Kind Regards,

Amit Berku

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,000

Amit,

No need to create new index on such a large table like MSEG for this requirement atleast.

Select matnr werks lgort charg from mchb into table lt_mchb where charg = ' ...........'.

select * from mseg into table lt_mseg for all entries in lt_mchb

where matnr = lt_mseg-matnr.

werks = ....

lgort = .............

This will use the partial secondary index 'M' of MSEG and should be Fast enough. It is almost the same as Srikant mentioned but I don't feel the need of using MCH1.

Regards,

Diwakar

Hello,

In a query that I'm writing I have batch number (MCHB-CHARG) and have to find the material document (MSEG-MBLNR) that contains this batch (to print out copy of a label that attached to the material document).

I saw that in MSEG there is a field of CHARG but it's not key and not in standart indexes,

so because it's a huge table, I don't want to do direct select from it.

In the other way, the field MBLNR doesn't exists in MCHA nor MCHB tables.

Do anyone know how can I do this linkage ? is there any appropriate BAPI or standart function ?

Thank you,

Kind Regards,

Amit Berku

4 REPLIES 4
Read only

Former Member
0 Likes
2,000

Hi ,

1. U can create a secondary index in the table mseg with the field CHARG , LGORT . Then we can link

MSEG-CHARG = MCHB-CHARG

MSEG-LGORT =MCHB-LGORT

Plant , material , company code , storage location are the primary key fields of the table MCHB.

The only problem with secondary index is it might increase the data load on the system

2. We can set automatic external serial number in migo but this is not a direct link

http://wiki.sdn.sap.com/wiki/display/ABAP/HowtosetautomaticexternalserialnumberinMigo

Thanks,

Rajat Kumar Sharma

Read only

Former Member
0 Likes
2,000

Hi Amit,

Try with the following LINKAGES

LINK1 LNK2 LINK3

MSEG-MATNR MCHB-MATNR MCH1-MATNR

MSEG-WERKS MCHB-WERKS MCH1-CHARG

MSEG-LGORT MCHB-LGORT

MSEG-CHARG MCHB-CHARG

and GET

MSEG-MBLNR

MSEG-MJAHR

Try it out it may work

Revert if found any alternate solution

Thanks

Sri

Read only

Former Member
0 Likes
2,001

Amit,

No need to create new index on such a large table like MSEG for this requirement atleast.

Select matnr werks lgort charg from mchb into table lt_mchb where charg = ' ...........'.

select * from mseg into table lt_mseg for all entries in lt_mchb

where matnr = lt_mseg-matnr.

werks = ....

lgort = .............

This will use the partial secondary index 'M' of MSEG and should be Fast enough. It is almost the same as Srikant mentioned but I don't feel the need of using MCH1.

Regards,

Diwakar

Read only

0 Likes
2,000

Hello Diwakar,

Thank you for your quick answer, I didn't think of this direction, you solved my question.

Kind Regrads,

Amit Berku