‎2007 Jun 02 8:35 AM
Dear All,
I am working on report. Whare I have few input parameters and based on that input parameters I need to display some field from different-different tables. Now I have cretaed one structure of the fields which i need to display based on input parameters........
So what would be the next step:- I mean to say...
the select stamenet...
the loop statment and all.
How I will proceed further.
regards.....
‎2007 Jun 02 9:05 AM
Hi
I didnt understand what do you mean one structure of fields?you mean internal table?
You declare the parameters or select options
parameters : p_matnr like mara-matnr.
select matnr mtart
from mara into table it_mara
where matnr = p_matnr.
it will fetch all data based on your input.
Loop at it_mara.
write : / itab-matnr, 30 itab-mtart.
endloop.
it will display the output.
This is just an example.
Thanks
‎2007 Jun 02 9:05 AM
Hi
I didnt understand what do you mean one structure of fields?you mean internal table?
You declare the parameters or select options
parameters : p_matnr like mara-matnr.
select matnr mtart
from mara into table it_mara
where matnr = p_matnr.
it will fetch all data based on your input.
Loop at it_mara.
write : / itab-matnr, 30 itab-mtart.
endloop.
it will display the output.
This is just an example.
Thanks
‎2007 Jun 02 10:08 AM
Hi
what i am able to understand from your requirement is you are having some parameters where you are going to enter some values.
Based on the values you have entered you want to retreive the data form different tables and finally you want to display the data retrieved from diifferent tables.
For this scenario
you have a salesorganisation and based on that you want to retreive the sales documents and than the item details for all the sales order than you want to display a combination of fields from vbak and vbap in the final output.
declarations for t_vbak,t_vbap,t_final.....
..........
.............
parameters p_vkorg type vbak-vkorg.
select vbeln into table t_vbak from vbak where vkorg = p_vkorg.
select vbeln posnr matnr from vbap into t_vbap for all enteries in table t_vbak
where vbeln = t_vbak-vbeln.
loop at t_vbap.
t_final-vkorg = p_vkorg.
t_final-vbeln = t_vbap-vbeln.
t_final-posnr = t_vbap-posnr.
t_final-matnr = t_vbap-matnr.
append t_final.
clear t_final.
endloop.
Regards
‎2007 Jun 02 10:36 AM
try this,
use join statement like,
DATA:BEGIN OF IT_FINAL,
INCLUDE STRUCTURE,
DATA:END OF IT_FINAL.
SELECT ZMM002~MATNR MATKL PRDHA MAKTX
MEINS MSTAE MSTAV VMSTA
INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
FROM ZMM002
INNER JOIN MARA ON ZMM002MATNR = MARAMATNR
INNER JOIN MARC ON ZMM002MATNR = MARCMATNR
INNER JOIN MVKE ON ZMM002MATNR = MVKEMATNR
INNER JOIN MLGN ON ZMM002MATNR = MLGNMATNR
WHERE WERKS = 'D002' AND
VKORG = '1000' AND
VTWEG = '10'." AND
LGNUM = 'W01'.
reward points if helpful,
Regards,
Imran
‎2007 Jun 02 10:40 AM
Hi AbhaySingh,
The parameter is used for entering "ONE" value. So based on the value you can
get the data from the database by using the "WHERE" clause to restrict.
<b><u>Example :</u></b> To get the description of a Company Code
<b>And Now Say Declaration of a Parameter</b>
PARAMETER : P_BUKRS LIKE T001-BUKRS.
<b>Selecting the record from the database for th Bukrs (Company Code) which user has entered (p_bukrs)</b>
select * from t001 where bukrs = p_bukrs.
<b>Displaying the Bukrs (company code) and the text of it...</b>
write : t001-bukrs, t001-butxt.
Note :
1. In the above example there will be only one record in the table T001 for a Company code (as BUKRS is a Key field)
2. In case if u know that for that parameter if more than one record resides in the
table, u can use the select as follows ....
DATA : ITAB TYPE TABLE OF T001.
DATA : ISTRU TYPE T001.
SELECT * FROM T001
INTO TABLE ITAB
WHERE BUKRS = P_BUKRS.
LOOP AT ITAB INTO ISTRU.
WRITE : / ISTRU-BUKRS.
WRITE : ISTRU-BUTXT.
ENDLOOP.
Hope this helps !
Please revert if it is not clear !!!!
Cheers
Kripa Rangachari.