cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Data from a View

Former Member
0 Kudos

Hi Friends ,

I am making a new report where i need to get the material no(matnr) from a view zmatnr_view . When i select the required plant(werks) on the selection screen it should display all the material no's and the respective plants with some additional calculation . Please suggest on this issue .

Thanks ,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hari,

Why have you created a custom view? I believe the same can be achieved by a simple join on MARA and MARC or infact by writing simple select statements and to carry on your calculation based on the records fetched.

-> Select data from MARC based on ur plant from selection screen

-> Sort based on plant

-> If you need any additional info from MARA ( either use a join or based on the unique material no's selected in the above select statement get the required information)

-> Loop through the internal table to work out ur calculation.

Hope this helps

CHeers

VJ

Answers (1)

Answers (1)

Former Member
0 Kudos

HI

GOOD

HERE IS SOME INSTRUCTIONS

1- CREATE A SELCTION SCREEN USING PARAMETER OR SELECT OPTIONS.

2-SELECT THE APPROPRIATE WERKS FROM THE TABLE AND COMPARE WITH THE VALUE OF THE SELECTION SCREEN

3- IF BOTH ARE SAME THAN SELECT THE MATNR VALUE FROM THE VIEW ZMATNR_VIEW.

THIS IS THE LOGIC BEHIND YOUR REQUIREMENT.

DO YOU WANT ME TO SEND YOU THE CODE FOR THIS.

THANKS

MRUTYUN

Former Member
0 Kudos

Declare the internal table with the type of View.

Data : itab type table of ZMATNR_VIEW.

or write select query as

select * from ZMATNR_VIEW into corresponding fields of itab.

Also you can uncheck the Unicode checks active (checkbox) in the program attributes.

{When you check that unicode checkbox, you should use an internal table without a header line. Instead you should declare a work area)

Hope it helps...

Former Member
0 Kudos

Hi Tripathy ,

Thanks for the instructions it was helpful . If you could send me a sample code it would be great . I really appreciate your help .

I have already designed the selection screen and ALV grid layout with all the fields .

The plant ( werks ) is a mandatory field while matnr is not on the selection screen .

Whenever the user chooses a plant ( werks) on the selection screen it should display the plant , material no and other fields in the ALV grid layout .

If you could kindly send me the sample code it would be appreciated . As i told you before there is a view z_matnr where both these fields werks and matnr are located . All i need to know is how to read plant and get all the material no ?????

Thank you ,

HARI

Former Member
0 Kudos

Hi !

Check out this code.

REPORT Z_MARA .

tables: z_mara.

select-options: matnr for zmara-matnr,

werks for zmara-werks.

start-of-selection.

select * from z_mara

where matnr in matnr

and werks in werks

  • ... fill you ALV table here ...

endselect.

If you still don't get data in your report you shoud check the view z_matnr if it works korrectly.

To do so you can use the SE16 using z_matnr as the table name.

Then type the selection as your report does an execute it. If you don't get results there your view is not correct.

I.e. nor correctly joined tables, mandt not or not correct joint in MARA and MARC(D) or something else.

Just check the SE16...

Regards

Rainer

Some points would be fine if that helpd a bit.