Application Development 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: 

Abap function of a material stock

Former Member
0 Kudos

Hello,

would need to know if there is any function that returns the stock of a material on a specific date such as stock material to 16/03/2013

Otherwise, how could calculate the stock of a material to a specific date?

thanks in advance

11 REPLIES 11

Former Member
0 Kudos

Hello Juan,

           this is a classic problem which i have faced in many implementation projects. Now i have found a solution for this. You may be knowing the standard MB5B transaction for doing this and it gives the correct stock with various selection parameters. What i have done is that i have encapsulated this transaction with the selection parameters i want into a function module. For example steps.

Create a Function module with the parameters you want ( as you are saying the date). keep that as an importing parameters . say IM_DATE as importing parameter

inside the sourcecode write

types : begin of ty_list,

             text(256) type c,

            end of ty_list.

data : IS_RSPAR type RSPARAMS,

         IT_RSPAR type table of RSPARAMS,

         IT_LIST type standard table of ABAPLIST,

         IT_LIST1 type standard table of ty_list.

clear : IS_RSPAR

IS_RSPAR-SELNAME = 'DATUM'.

IS_RSPAR-KIND = 'S'.

IS_RSPAR-LOW = IM_DATE.

IS_RSPAR-HIGH = IM_DATE.

IS_RSPAR-SIGN = 'I'.

IS_RSPAR-OPTION = 'BT'.

append IS_RSPAR to IT_RSPAR.

submit RM07MLBD with selection-table IT_RSPAR exporting list to memory and return.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

     listobject = it_list

EXCEPTIONS

     not_found = 1

     others = 2.

CALL FUNCTION 'LIST_TO_ASCI'

TABLES

    listasci = it_list1

    listobject = it_list.

debug now and see the contents of IT_LIST1

you will find the stock values in one row of the above internal table. Now you can start reading the IT_LIST1 and play with the string according to your need and get the required string in the output parameter of the function module.

Regards

Animesh Sundriyal

0 Kudos

Hello Animesh,


to restrict the selection should put more as input parameter the article, society, central and date.

How I can pass these parameters through RSPARAMS?

thanks

,

0 Kudos

Thanks Animesh.

This is very helpful.

Former Member
0 Kudos

Hello Animesh,

to restrict the selection should put more as input parameter the article, society, central and date

How I can pass these parameters through RSPARAMS?

thanks,

0 Kudos

Hello Juan,

       yes you can surely restrict the selection using more input parameters. in my case i have done the same can you give me the technical names of the fields so that i can write the code.

Regards

Animesh Sundriyal

0 Kudos

Hello Animesh,

I have already solved, thank you very much you have been very helpful.

Regards

0 Kudos

Hello Animesh,

I have already solved, thank you very much you have been very helpful.

Regards

0 Kudos

Good to know that my solution helped....

venkateswaran_k
Active Contributor
0 Kudos

Dear Juan

There is a table  - MARDH

This table stores the stock as on Period

Material + Plant + Storage Location + Year + Period

Suppose you want to take stock as on today,  then

1. From the above table  take the balance of  2013 and Period 6.

2. From MSEG table calculate the Receipts and Issues based on movement type

3. Arrive the closing balance

Regards,

Venkat

gurunathkumar_dadamu
Active Contributor
0 Kudos

Hi Juan,

Can you check the MB51 tocde.

Regards,

Gurunath

Former Member
0 Kudos

Hi

try it with the function CSAP_MAT_BOM_READ